1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
AT_BANNER([OVSDB -- ovsdb-server monitors])
OVS_START_SHELL_HELPERS
# ovsdb_check_monitor SCHEMA_FUNC DB TABLE OUTPUT COLUMNS
# PRE-MONITOR-TXN... -- TRANSACTION...
ovsdb_check_monitor () {
local schema_func=$1 db=$2 table=$3 output=$4 columns=$5
shift; shift; shift; shift; shift
$schema_func > schema
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
while test "$1" != "--"; do
AT_CHECK([ovsdb-tool transact db "$1"], [0], [ignore], [ignore])
shift
done
shift
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db > ovsdb-server.stdout 2> ovsdb-server.stderr],
[0], [], [])
on_exit 'kill `cat ovsdb-server.pid`'
if test "$IS_WIN32" = "yes"; then
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --log-file -d json monitor --format=csv unix:socket $db $table $columns > output 2> ovsdb-client.stderr &],
[0], [ignore], [ignore])
sleep 1
else
AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile --log-file -d json monitor --format=csv unix:socket $db $table $columns > output 2> ovsdb-client.stderr],
[0], [ignore], [ignore])
fi
on_exit 'kill `cat ovsdb-client.pid`'
for txn in ${1+"$@"} '[["'$db'"]]'; do
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
done
OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])
OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid])
AT_CHECK_UNQUOTED([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$output], [ignore])
}
OVS_END_SHELL_HELPERS
# OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
# TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS])
#
# Creates a database with the given SCHEMA, starts an ovsdb-server on
# that database, and runs each of the TRANSACTIONS (which should be a
# quoted list of quoted strings) against it with ovsdb-client one at a
# time. COLUMNS, if specified, is passed to ovsdb-client as the set
# of columns and operations to select.
#
# Checks that the overall output is OUTPUT, but UUIDs in the output
# are replaced by markers of the form <N> where N is a number. The
# first unique UUID is replaced by <0>, the next by <1>, and so on.
# If a given UUID appears more than once it is always replaced by the
# same marker.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_MONITOR],
[AT_SETUP([$1])
AT_KEYWORDS([ovsdb server monitor positive $9])
AT_CAPTURE_FILE([ovsdb-server.log])
AT_CAPTURE_FILE([ovsdb-server.stdout])
AT_CAPTURE_FILE([ovsdb-server.stderr])
AT_CAPTURE_FILE([ovsdb-client.log])
AT_CAPTURE_FILE([ovsdb-client.stderr])
ovsdb_check_monitor '$2' '$4' '$5' '$7' '$8' \
m4_foreach([txn], [$3], ['txn' ]) -- \
m4_foreach([txn], [$6], ['txn' ])
AT_CLEANUP])
# OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
# TRANSACTIONS, OUTPUT, CONDITIONS, [COLUMNS], [KEYWORDS],
# [CONDITIONS_CHANGE])
#
# Creates a database with the given SCHEMA, starts an ovsdb-server on
# that database, and runs each of the TRANSACTIONS (which should be a
# quoted list of quoted strings) against it with ovsdb-client one at a
# time. COLUMNS, if specified, is passed to ovsdb-client as the set
# of columns and operations to select.
#
# Checks that the overall output is OUTPUT, but UUIDs in the output
# are replaced by markers of the form <N> where N is a number. The
# first unique UUID is replaced by <0>, the next by <1>, and so on.
# If a given UUID appears more than once it is always replaced by the
# same marker.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_MONITOR_COND],
[AT_SETUP([$1])
AT_KEYWORDS([ovsdb server monitor monitor-cond positive $10])
$2 > schema
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
for txn in m4_foreach([txn], [$3], ['txn' ]); do
AT_CHECK([ovsdb-tool transact db "$txn"], [0], [ignore], [ignore])
done
AT_CAPTURE_FILE([ovsdb-server-log])
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
on_exit 'kill `cat ovsdb-server.pid`'
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond --format=csv unix:socket $4 '[$8]' $5 $9 > output],
[0], [ignore], [ignore])
on_exit 'kill `cat ovsdb-client.pid`'
for txn in m4_foreach([txn], [$6], ['txn' ]); do
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
[ignore], [ignore], [kill `cat server-pid client-pid`])
done
for cond in m4_foreach([cond], [$10], ['cond' ]); do
AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change $5 "$cond"], [0], [ignore], [ignore])
done
AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
[ignore], [ignore])
AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
AT_CHECK([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore])
AT_CLEANUP])
OVSDB_CHECK_MONITOR([monitor insert into empty table],
[ordinal_schema],
[],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}}]]]],
[[row,action,name,number,_version
<0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
]])
OVSDB_CHECK_MONITOR([monitor insert into populated table],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
]])
OVSDB_CHECK_MONITOR([monitor delete],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "delete",
"table": "ordinals",
"where": [["number", "==", 10]]}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
]])
OVSDB_CHECK_MONITOR([monitor row update],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "update",
"table": "ordinals",
"where": [["number", "==", 10]],
"row": {"name": "five plus five"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<0>,old,"""ten""",,"[""uuid"",""<1>""]"
,new,"""five plus five""",10,"[""uuid"",""<2>""]"
]])
OVSDB_CHECK_MONITOR([monitor no-op row updates],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "update",
"table": "ordinals",
"where": [["number", "==", 10]],
"row": {"number": 10, "name": "ten"}}]]],
[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 9, "name": "nine"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
]])
OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 9, "name": "nine"},
"uuid-name": "nine"},
{"op": "update",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]],
"row": {"name": "three squared"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
]])
OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 9, "name": "nine"},
"uuid-name": "nine"},
{"op": "update",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]],
"row": {"name": "three squared"}},
{"op": "delete",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]]},
{"op": "insert",
"table": "ordinals",
"row": {"number": 7, "name": "seven"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
]])
OVSDB_CHECK_MONITOR([monitor weak reference change],
[weak_schema],
[[[["weak",
{"op": "insert",
"table": "a",
"row": {"a": 0,
"a2a1": ["named-uuid", "a0"],
"a2b": ["named-uuid", "b2"]},
"uuid-name": "a0"},
{"op": "insert",
"table": "a",
"row": {"a": 1,
"a2a": ["named-uuid", "a0"],
"a2a1": ["named-uuid", "a1"],
"a2b": ["named-uuid", "b2"]},
"uuid-name": "a1"},
{"op": "insert",
"table": "b",
"row": {"b": 2},
"uuid-name": "b2"}]]]],
[weak], [a],
[[[["weak",
{"op": "delete",
"table": "a",
"where": [["a", "==", 0]]}]]]],
[[row,action,a,a2a,a2a1,a2b,_version
<0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
<3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
row,action,a,a2a,a2a1,a2b,_version
<0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
<3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
]])
OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 9, "name": "nine"},
"uuid-name": "nine"},
{"op": "update",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]],
"row": {"name": "three squared"}},
{"op": "delete",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]]},
{"op": "insert",
"table": "ordinals",
"row": {"number": 7, "name": "seven"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
]])
AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
m4_define([OVSDB_MONITOR_INITIAL],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]])
m4_define([OVSDB_MONITOR_TXNS],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 5, "name": "five"}}]]],
[[["ordinals",
{"op": "update",
"table": "ordinals",
"where": [["name", "==", "five"]],
"row": {"name": "FIVE"}}]]],
[[["ordinals",
{"op": "delete",
"table": "ordinals",
"where": []}]]]])
OVSDB_CHECK_MONITOR([monitor all operations],
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""five""",5,"[""uuid"",""<3>""]"
row,action,name,number,_version
<2>,old,"""five""",,"[""uuid"",""<3>""]"
,new,"""FIVE""",5,"[""uuid"",""<4>""]"
row,action,name,number,_version
<2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
<0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
]])
dnl A monitor with "initial" only doesn't really make sense,
dnl but it's still allowed and should work.
OVSDB_CHECK_MONITOR([monitor initial only],
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
]], [!insert,!delete,!modify])
OVSDB_CHECK_MONITOR([monitor insert only],
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
[[row,action,name,number,_version
<0>,insert,"""five""",5,"[""uuid"",""<1>""]"
]], [!initial,!delete,!modify])
OVSDB_CHECK_MONITOR([monitor delete only],
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
[[row,action,name,number,_version
<0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
<2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
]], [!initial,!insert,!modify])
OVSDB_CHECK_MONITOR([monitor modify only],
[ordinal_schema], [OVSDB_MONITOR_INITIAL],
[ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
[[row,action,name,number,_version
<0>,old,"""five""",,"[""uuid"",""<1>""]"
,new,"""FIVE""",5,"[""uuid"",""<2>""]"
]], [!initial,!insert,!delete])
AT_BANNER([ovsdb -- ovsdb-monitor-cond conditional monitor only some operations])
OVSDB_CHECK_MONITOR_COND([monitor-cond empty condition],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 11, "name": "eleven"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
<2>,initial,"""two""",2,"[""uuid"",""<3>""]"
<4>,initial,"""zero""",,"[""uuid"",""<5>""]"
row,action,name,number,_version
<6>,insert,"""eleven""",11,"[""uuid"",""<7>""]"
<8>,insert,"""ten""",10,"[""uuid"",""<9>""]"
]],
[[]])
OVSDB_CHECK_MONITOR_COND([monitor-cond multiple conditions],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 11, "name": "eleven"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""ten""",10,"[""uuid"",""<3>""]"
]],
[[["name","==","one"],["name","==","ten"]]])
OVSDB_CHECK_MONITOR_COND([monitor-cond delete from populated table],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "delete",
"table": "ordinals",
"where": []}]]]],
[[row,action,name,number,_version
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
row,action,name,number,_version
<0>,delete,,,
]],
[[["name","==","one"],["name","==","ten"]]])
OVSDB_CHECK_MONITOR_COND([monitor-cond insert due to modify],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "update",
"table": "ordinals",
"where": [["name", "==", "one"]],
"row": {"name": "ONE"}}]]]],
[[row,action,name,number,_version
<0>,insert,"""ONE""",1,"[""uuid"",""<1>""]"
]],
[[["name","==","ONE"]]],
[!initial,!delete,!modify])
OVSDB_CHECK_MONITOR_COND([monitor-cond delete due to modify],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "update",
"table": "ordinals",
"where": [["name", "==", "one"]],
"row": {"name": "ONE"}}]]]],
[[row,action,name,number,_version
<0>,delete,,,
]],
[[["name","==","one"]]],
[!initial,!insert,!modify])
OVSDB_CHECK_MONITOR_COND([monitor-cond condition non-monitored columns],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]],
[ordinals], [ordinals],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 11, "name": "eleven"}}]]]],
[[row,action,number
<0>,initial,1
row,action,number
<1>,insert,10
]],
[[["name","==","one"],["name","==","ten"]]],
["number"])
OVSDB_CHECK_MONITOR_COND([monitor-cond-change],
[ordinal_schema],
[[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]],
[ordinals], [ordinals],
[],
[[row,action,name,number,_version
<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
<2>,initial,"""two""",2,"[""uuid"",""<3>""]"
<4>,initial,"""zero""",,"[""uuid"",""<5>""]"
row,action,name,number,_version
<4>,delete,,,
row,action,name,number,_version
<2>,delete,,,
row,action,name,number,_version
<0>,delete,,,
row,action,name,number,_version
<0>,insert,"""one""",1,"[""uuid"",""<1>""]"
<2>,insert,"""two""",2,"[""uuid"",""<3>""]"
<4>,insert,"""zero""",,"[""uuid"",""<5>""]"
]],
[[]],
[],
[[[[["name","==","one"],["name","==","two"]]]],
[[[["name","==","one"]]]],
[[[false]]],
[[[true]]]])
AT_SETUP(monitor-cond-change with many sessions pending)
AT_KEYWORDS([ovsdb server monitor monitor-cond negative])
ordinal_schema > schema
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
AT_CAPTURE_FILE([ovsdb-server-log])
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
on_exit 'kill `cat ovsdb-server.pid`'
for txn in m4_foreach([txn], [[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 1, "name": "one"}},
{"op": "insert",
"table": "ordinals",
"row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
done
# 1001 clients monitoring column "name" and with condition for "name" only.
# The clients are created in a way that the 991th client will request condition
# change, so that the chance is high that the condition change will be handled
# before some pending changes are freed.
cond='[[["name","==","ten"]]]'
for i in `seq 1 990`; do
AT_CHECK([ovsdb-client -vjsonrpc --pidfile=ovsdb-client$i.pid --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"]], [0], [ignore], [ignore])
done
AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"] > output],
[0], [ignore], [ignore])
for i in `seq 991 1000`; do
AT_CHECK([ovsdb-client -vjsonrpc --pidfile=ovsdb-client$i.pid --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"]], [0], [ignore], [ignore])
done
for txn in m4_foreach([txn], [[[["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]], ['txn' ]); do
AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
[ignore], [ignore], [kill `cat server-pid client-pid`])
done
# Change the condition so that a new column "number" is added to monitor table.
cond='[[["number","==",1]]]'
AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change ordinals $cond], [0], [ignore], [ignore])
# Give some time for the server to flush and free pending changes
# (to crash, when n_columns is not handled properly)
sleep 1
AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
[ignore], [ignore])
AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
AT_CHECK([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [[row,action,name
<0>,insert,"""ten"""
row,action,name
<0>,delete,
<1>,insert,"""one"""
]], [ignore])
AT_CLEANUP
|