Skip to content

Commit 316b0ff

Browse files
committed
tests: ovsdb-idl: Fix flaky insert and delete tests.
The weak reference test sends two transactions and then waits for an update and sends a third transaction. First transaction adds a row and the second one deletes it. The test relies on an IDL run between the second and the third transactions to receive and process updates from both previous transactions, and that is not guaranteed. This is causing frequent test failures in CI. If the server is slow to send an update for the second transaction, the IDL run will return without receiving it and the test application has no way to know that it needs to wait for one more update. The change sequence number doesn't have a meaning other than it changes on updates, so we can't rely on it to wait for two updates. The strong reference test has somewhat similar issue, it sends two transactions and then expects both updates to be received together. And that is, again, not guaranteed. However, the difference here is that the issue (crash) that it tries to reproduce requires both updates to be received within the same IDL run, which was not a hard requirement for the weak reference test. The weak reference test tolerates receiving updates in two separate IDL runs, so we could have fixed it by waiting for an update after the first transaction without clearing the tracking and then waiting again after the second. But such approach would not work for the strong reference test. And there is actually no way for us to ensure that both updates will be received within the same IDL run. Best we can do is to sleep for some time hoping that it's enough for both updates to be queued up. So, let's do that. Tests are very simple and fast, so sleeping for 1 second should be enough. 'refs to link[12]' tests are similar to a strong reference test in terms that they require changes to be processed within the same IDL run. Fixes: 02f31a1 ("ovsdb-idl: Preserve references for rows deleted in same IDL run as their insertion.") Fixes: 91e1ff5 ("ovsdb-idl: Don't reparse orphaned rows.") Fixes: 4102674 ("ovsdb-idl: Preserve change_seqno when deleting rows.") Acked-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
1 parent 9310e17 commit 316b0ff

File tree

2 files changed

+43
-32
lines changed

2 files changed

+43
-32
lines changed

tests/ovsdb-idl.at

+40-32
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,7 @@ OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated, weak references,
15621562
{"op": "delete",
15631563
"table": "simple",
15641564
"where": [["s", "==", "row1_s"]]}]' \
1565+
'+sleep' \
15651566
'["idltest",
15661567
{"op": "insert",
15671568
"table": "simple",
@@ -1574,16 +1575,17 @@ OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated, weak references,
15741575
001: table simple: updated columns: s
15751576
002: {"error":null,"result":[{"uuid":["uuid","<3>"]},{"count":1}]}
15761577
003: {"error":null,"result":[{"count":1}]}
1577-
004: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1578-
004: table simple6: updated columns: weak_ref
1579-
004: table simple: inserted/deleted row: i=0 r=0 b=false s=row1_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1580-
004: table simple: updated columns: s
1581-
005: {"error":null,"result":[{"uuid":["uuid","<4>"]}]}
1582-
006: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1583-
006: table simple: i=0 r=0 b=false s=row0_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<0>
1584-
006: table simple: inserted row: i=0 r=0 b=false s=row2_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<4>
1585-
006: table simple: updated columns: s
1586-
007: done
1578+
004: sleep
1579+
005: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1580+
005: table simple6: updated columns: weak_ref
1581+
005: table simple: inserted/deleted row: i=0 r=0 b=false s=row1_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1582+
005: table simple: updated columns: s
1583+
006: {"error":null,"result":[{"uuid":["uuid","<4>"]}]}
1584+
007: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1585+
007: table simple: i=0 r=0 b=false s=row0_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<0>
1586+
007: table simple: inserted row: i=0 r=0 b=false s=row2_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<4>
1587+
007: table simple: updated columns: s
1588+
008: done
15871589
]])
15881590

15891591
dnl This test checks that deleting both the destination and source of the
@@ -1757,14 +1759,16 @@ OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, strong references, in
17571759
'+["idltest",
17581760
{"op": "delete",
17591761
"table": "link2",
1760-
"where": [["i", "==", 2]]}]'
1762+
"where": [["i", "==", 2]]}]' \
1763+
'+sleep'
17611764
]],
17621765
[[000: empty
17631766
001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
17641767
002: {"error":null,"result":[{"count":1}]}
1765-
003: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<0>
1766-
003: table link1: updated columns: i k
1767-
004: done
1768+
003: sleep
1769+
004: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<0>
1770+
004: table link1: updated columns: i k
1771+
005: done
17681772
]])
17691773

17701774
OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops],
@@ -2741,6 +2745,7 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link1],
27412745
"table": "link2",
27422746
"where": [["i", "==", 2]]}
27432747
]' \
2748+
'+sleep' \
27442749
'["idltest",
27452750
{"op": "delete",
27462751
"table": "link2",
@@ -2750,15 +2755,16 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link1],
27502755
[[000: empty
27512756
001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
27522757
002: {"error":null,"result":[{"count":1}]}
2753-
003: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<1>
2754-
003: table link1: updated columns: i k
2755-
003: table link2: inserted row: i=1 l1=1 uuid=<0>
2756-
003: table link2: inserted/deleted row: i=2 l1=1 uuid=<2>
2757-
003: table link2: updated columns: i l1
2758-
003: table link2: updated columns: i l1
2759-
004: {"error":null,"result":[{"count":1}]}
2760-
005: table link1: i=1 k=1 ka=[] l2= uuid=<1>
2761-
006: done
2758+
003: sleep
2759+
004: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<1>
2760+
004: table link1: updated columns: i k
2761+
004: table link2: inserted row: i=1 l1=1 uuid=<0>
2762+
004: table link2: inserted/deleted row: i=2 l1=1 uuid=<2>
2763+
004: table link2: updated columns: i l1
2764+
004: table link2: updated columns: i l1
2765+
005: {"error":null,"result":[{"count":1}]}
2766+
006: table link1: i=1 k=1 ka=[] l2= uuid=<1>
2767+
007: done
27622768
]])
27632769
OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link2],
27642770
[],
@@ -2784,6 +2790,7 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link2],
27842790
"table": "link1",
27852791
"where": [["i", "==", 2]]}
27862792
]' \
2793+
'+sleep' \
27872794
'["idltest",
27882795
{"op": "delete",
27892796
"table": "link1",
@@ -2793,15 +2800,16 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link2],
27932800
[[000: empty
27942801
001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
27952802
002: {"error":null,"result":[{"count":1}]}
2796-
003: table link1: inserted row: i=1 k=1 ka=[] l2=1 uuid=<0>
2797-
003: table link1: inserted/deleted row: i=2 k=1 ka=[] l2=1 uuid=<2>
2798-
003: table link1: updated columns: i k l2
2799-
003: table link1: updated columns: i k l2
2800-
003: table link2: inserted row: i=1 l1= uuid=<1>
2801-
003: table link2: updated columns: i
2802-
004: {"error":null,"result":[{"count":1}]}
2803-
005: table link2: i=1 l1= uuid=<1>
2804-
006: done
2803+
003: sleep
2804+
004: table link1: inserted row: i=1 k=1 ka=[] l2=1 uuid=<0>
2805+
004: table link1: inserted/deleted row: i=2 k=1 ka=[] l2=1 uuid=<2>
2806+
004: table link1: updated columns: i k l2
2807+
004: table link1: updated columns: i k l2
2808+
004: table link2: inserted row: i=1 l1= uuid=<1>
2809+
004: table link2: updated columns: i
2810+
005: {"error":null,"result":[{"count":1}]}
2811+
006: table link2: i=1 l1= uuid=<1>
2812+
007: done
28052813
]])
28062814

28072815
m4_define([OVSDB_CHECK_IDL_PERS_UUID_INSERT_C],

tests/test-ovsdb.c

+3
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,9 @@ do_idl(struct ovs_cmdl_context *ctx)
28842884
if (!strcmp(arg, "reconnect")) {
28852885
print_and_log("%03d: reconnect", step++);
28862886
ovsdb_idl_force_reconnect(idl);
2887+
} else if (!strcmp(arg, "sleep")) {
2888+
print_and_log("%03d: sleep", step++);
2889+
xsleep(1);
28872890
} else if (!strncmp(arg, remote_s, strlen(remote_s))) {
28882891
ovsdb_idl_set_remote(idl, arg + strlen(remote_s), true);
28892892
print_and_log("%03d: new remotes: %s, is connected: %s", step++,

0 commit comments

Comments
 (0)