Skip to content

Commit c46b1ef

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 42d3148 commit c46b1ef

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
@@ -1576,6 +1576,7 @@ OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated, weak references,
15761576
{"op": "delete",
15771577
"table": "simple",
15781578
"where": [["s", "==", "row1_s"]]}]' \
1579+
'+sleep' \
15791580
'["idltest",
15801581
{"op": "insert",
15811582
"table": "simple",
@@ -1588,16 +1589,17 @@ OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated, weak references,
15881589
001: table simple: updated columns: s
15891590
002: {"error":null,"result":[{"uuid":["uuid","<3>"]},{"count":1}]}
15901591
003: {"error":null,"result":[{"count":1}]}
1591-
004: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1592-
004: table simple6: updated columns: weak_ref
1593-
004: table simple: inserted/deleted row: i=0 r=0 b=false s=row1_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1594-
004: table simple: updated columns: s
1595-
005: {"error":null,"result":[{"uuid":["uuid","<4>"]}]}
1596-
006: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1597-
006: table simple: i=0 r=0 b=false s=row0_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<0>
1598-
006: table simple: inserted row: i=0 r=0 b=false s=row2_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<4>
1599-
006: table simple: updated columns: s
1600-
007: done
1592+
004: sleep
1593+
005: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1594+
005: table simple6: updated columns: weak_ref
1595+
005: table simple: inserted/deleted row: i=0 r=0 b=false s=row1_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1596+
005: table simple: updated columns: s
1597+
006: {"error":null,"result":[{"uuid":["uuid","<4>"]}]}
1598+
007: table simple6: name=row0_s6 weak_ref=[<0>] uuid=<1>
1599+
007: table simple: i=0 r=0 b=false s=row0_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<0>
1600+
007: table simple: inserted row: i=0 r=0 b=false s=row2_s u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<4>
1601+
007: table simple: updated columns: s
1602+
008: done
16011603
]])
16021604

16031605
dnl This test checks that deleting both the destination and source of the
@@ -1771,14 +1773,16 @@ OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, strong references, in
17711773
'+["idltest",
17721774
{"op": "delete",
17731775
"table": "link2",
1774-
"where": [["i", "==", 2]]}]'
1776+
"where": [["i", "==", 2]]}]' \
1777+
'+sleep'
17751778
]],
17761779
[[000: empty
17771780
001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
17781781
002: {"error":null,"result":[{"count":1}]}
1779-
003: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<0>
1780-
003: table link1: updated columns: i k
1781-
004: done
1782+
003: sleep
1783+
004: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<0>
1784+
004: table link1: updated columns: i k
1785+
005: done
17821786
]])
17831787

17841788
OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops],
@@ -2755,6 +2759,7 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link1],
27552759
"table": "link2",
27562760
"where": [["i", "==", 2]]}
27572761
]' \
2762+
'+sleep' \
27582763
'["idltest",
27592764
{"op": "delete",
27602765
"table": "link2",
@@ -2764,15 +2769,16 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link1],
27642769
[[000: empty
27652770
001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
27662771
002: {"error":null,"result":[{"count":1}]}
2767-
003: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<1>
2768-
003: table link1: updated columns: i k
2769-
003: table link2: inserted row: i=1 l1=1 uuid=<0>
2770-
003: table link2: inserted/deleted row: i=2 l1=1 uuid=<2>
2771-
003: table link2: updated columns: i l1
2772-
003: table link2: updated columns: i l1
2773-
004: {"error":null,"result":[{"count":1}]}
2774-
005: table link1: i=1 k=1 ka=[] l2= uuid=<1>
2775-
006: done
2772+
003: sleep
2773+
004: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<1>
2774+
004: table link1: updated columns: i k
2775+
004: table link2: inserted row: i=1 l1=1 uuid=<0>
2776+
004: table link2: inserted/deleted row: i=2 l1=1 uuid=<2>
2777+
004: table link2: updated columns: i l1
2778+
004: table link2: updated columns: i l1
2779+
005: {"error":null,"result":[{"count":1}]}
2780+
006: table link1: i=1 k=1 ka=[] l2= uuid=<1>
2781+
007: done
27762782
]])
27772783
OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link2],
27782784
[],
@@ -2798,6 +2804,7 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link2],
27982804
"table": "link1",
27992805
"where": [["i", "==", 2]]}
28002806
]' \
2807+
'+sleep' \
28012808
'["idltest",
28022809
{"op": "delete",
28032810
"table": "link1",
@@ -2807,15 +2814,16 @@ OVSDB_CHECK_IDL_TRACK([track, insert and delete, refs to link2],
28072814
[[000: empty
28082815
001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
28092816
002: {"error":null,"result":[{"count":1}]}
2810-
003: table link1: inserted row: i=1 k=1 ka=[] l2=1 uuid=<0>
2811-
003: table link1: inserted/deleted row: i=2 k=1 ka=[] l2=1 uuid=<2>
2812-
003: table link1: updated columns: i k l2
2813-
003: table link1: updated columns: i k l2
2814-
003: table link2: inserted row: i=1 l1= uuid=<1>
2815-
003: table link2: updated columns: i
2816-
004: {"error":null,"result":[{"count":1}]}
2817-
005: table link2: i=1 l1= uuid=<1>
2818-
006: done
2817+
003: sleep
2818+
004: table link1: inserted row: i=1 k=1 ka=[] l2=1 uuid=<0>
2819+
004: table link1: inserted/deleted row: i=2 k=1 ka=[] l2=1 uuid=<2>
2820+
004: table link1: updated columns: i k l2
2821+
004: table link1: updated columns: i k l2
2822+
004: table link2: inserted row: i=1 l1= uuid=<1>
2823+
004: table link2: updated columns: i
2824+
005: {"error":null,"result":[{"count":1}]}
2825+
006: table link2: i=1 l1= uuid=<1>
2826+
007: done
28192827
]])
28202828

28212829
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)