summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDumitru Ceara <dceara@redhat.com>2020-08-05 21:40:51 +0200
committerIlya Maximets <i.maximets@ovn.org>2020-08-06 22:22:05 +0200
commitf2cf667730c980e3343228b0e44b6e3ca8538964 (patch)
treed9d592da889b77633ac063f7b87e9de26411c36d /tests
parentd5659751f65ebc17d9aec40b60c1cff3a2d87162 (diff)
downloadopenvswitch-f2cf667730c980e3343228b0e44b6e3ca8538964.tar.gz
ovsdb-server: Replace in-memory DB contents at raft install_snapshot.
Every time a follower has to install a snapshot received from the leader, it should also replace the data in memory. Right now this only happens when snapshots are installed that also change the schema. This can lead to inconsistent DB data on follower nodes and the snapshot may fail to get applied. Fixes: bda1f6b60588 ("ovsdb-server: Don't disconnect clients after raft install_snapshot.") Acked-by: Han Zhou <hzhou@ovn.org> Signed-off-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/idltest.ovsschema9
-rw-r--r--tests/ovsdb-cluster.at32
-rw-r--r--tests/ovsdb-idl.at1
3 files changed, 39 insertions, 3 deletions
diff --git a/tests/idltest.ovsschema b/tests/idltest.ovsschema
index e02b975bc..e04755ea0 100644
--- a/tests/idltest.ovsschema
+++ b/tests/idltest.ovsschema
@@ -54,6 +54,15 @@
},
"isRoot" : true
},
+ "indexed": {
+ "columns": {
+ "i": {
+ "type": "integer"
+ }
+ },
+ "indexes": [["i"]],
+ "isRoot" : true
+ },
"simple": {
"columns": {
"b": {
diff --git a/tests/ovsdb-cluster.at b/tests/ovsdb-cluster.at
index 971454515..e0758e954 100644
--- a/tests/ovsdb-cluster.at
+++ b/tests/ovsdb-cluster.at
@@ -332,13 +332,29 @@ for i in `seq $n`; do
AT_CHECK([ovsdb_client_wait unix:s$i.ovsdb $schema_name connected])
done
+AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
+ {"op": "insert",
+ "table": "indexed",
+ "row": {"i": 0}}]]'], [0], [ignore], [ignore])
+
# Kill one follower (s2) and write some data to cluster, so that the follower is falling behind
printf "\ns2: stopping\n"
OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/s2], [s2.pid])
+# Delete "i":0 and readd it to get a different UUID for it.
+AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
+ {"op": "delete",
+ "table": "indexed",
+ "where": [["i", "==", 0]]}]]'], [0], [ignore], [ignore])
+
AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
{"op": "insert",
- "table": "simple",
+ "table": "indexed",
+ "row": {"i": 0}}]]'], [0], [ignore], [ignore])
+
+AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
+ {"op": "insert",
+ "table": "indexed",
"row": {"i": 1}}]]'], [0], [ignore], [ignore])
# Compact leader online to generate snapshot
@@ -355,8 +371,18 @@ AT_CHECK([ovsdb_client_wait unix:s2.ovsdb $schema_name connected])
# succeed.
AT_CHECK([ovsdb-client transact unix:s2.ovsdb '[["idltest",
{"op": "insert",
- "table": "simple",
- "row": {"i": 1}}]]'], [0], [ignore], [ignore])
+ "table": "indexed",
+ "row": {"i": 2}}]]'], [0], [ignore], [ignore])
+
+# The snapshot should overwrite the in-memory contents of the DB on S2
+# without generating any constraint violations. All tree records (0, 1, 2)
+# should be in the DB at this point.
+AT_CHECK([ovsdb-client --no-headings dump unix:s2.ovsdb idltest indexed | uuidfilt | sort -k 2], [0], [dnl
+<0> 0
+<1> 1
+<2> 2
+indexed table
+])
for i in `seq $n`; do
OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/s$i], [s$i.pid])
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index 4efed88e4..789ae23a9 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -954,6 +954,7 @@ AT_CHECK([sort stdout | uuidfilt], [0],
# Check that ovsdb-idl figured out that table link2 and column l2 are missing.
AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl
+test-ovsdb|ovsdb_idl|idltest database lacks indexed table (database needs upgrade?)
test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?)
test-ovsdb|ovsdb_idl|idltest database lacks simple5 table (database needs upgrade?)
test-ovsdb|ovsdb_idl|idltest database lacks singleton table (database needs upgrade?)