Skip to content

Commit

Permalink
tests: ovsdb: Add relay and replication execution with config file.
Browse files Browse the repository at this point in the history
Basic relay and active-backup command execution tests extended
to run some copies of ovsdb-server processes with --config-file.

Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Dec 13, 2023
1 parent 8edefe5 commit 3d738df
Showing 1 changed file with 85 additions and 18 deletions.
103 changes: 85 additions & 18 deletions tests/ovsdb-server.at
Original file line number Diff line number Diff line change
Expand Up @@ -1593,12 +1593,30 @@ m4_define([OVSDB_CHECK_EXECUTION_RELAY],
], [0], [ignore], [ignore])

for i in $(seq 2 ${n_servers}); do
AT_CHECK([ovsdb-server --detach --no-chdir dnl
--log-file=ovsdb-server$i.log dnl
--pidfile=${i}.pid --remote=punix:db${i}.sock dnl
--unixctl=unixctl${i} -vjsonrpc:file:dbg dnl
relay:${schema_name}:unix:db$((i-1)).sock
], [0], [ignore], [ignore])
dnl Run every second relay with a config file.
if test $(expr $i % 2) -eq 0; then
echo "{
\"remotes\": { \"punix:db${i}.sock\": {} },
\"databases\": {
\"${schema_name}\": {
\"service-model\": \"relay\",
\"source\": { \"unix:db$((i-1)).sock\": {} }
}
}
}" > config${i}.json
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=${i}.pid \
--log-file=ovsdb-server$i.log \
--unixctl=unixctl${i} -vjsonrpc:file:dbg \
--config-file=config${i}.json
], [0], [ignore], [ignore])
else
AT_CHECK([ovsdb-server --detach --no-chdir \
--log-file=ovsdb-server$i.log \
--pidfile=${i}.pid --remote=punix:db${i}.sock \
--unixctl=unixctl${i} -vjsonrpc:file:dbg \
relay:${schema_name}:unix:db$((i-1)).sock
], [0], [ignore], [ignore])
fi
done

m4_foreach([txn], [$4],
Expand Down Expand Up @@ -1660,22 +1678,43 @@ m4_define([OVSDB_CHECK_EXECUTION],
$2 > schema
AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])

on_exit 'kill `cat *.pid`'
AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])
i

AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=2.pid --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore])
AT_CHECK([ovsdb-tool create db3 schema], [0], [stdout], [ignore])

on_exit 'kill $(cat *.pid)'
AT_CHECK([ovsdb-server -vfile --detach --no-chdir --log-file=ovsdb-server1.log \
--pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])

AT_CHECK([ovsdb-server -vfile --detach --no-chdir --log-file=ovsdb-server2.log \
--pidfile=2.pid --remote=punix:db2.sock --unixctl=unixctl2 \
--sync-from=unix:db.sock db2], [0], [ignore], [ignore])

AT_DATA([config3.json], [
{
"remotes": { "punix:db3.sock": {} },
"databases": {
"db3": {
"service-model": "active-backup",
"backup": true,
"source": { "unix:db.sock": {} }
}
}
}
])
AT_CHECK([ovsdb-server -vfile --detach --no-chdir --log-file=ovsdb-server3.log \
--pidfile=3.pid --unixctl=unixctl3 --config-file=config3.json],
[0], [ignore], [ignore])

m4_foreach([txn], [$3],
[AT_CHECK([ovsdb-client transact 'txn'], [0], [stdout], [ignore])
])

AT_CHECK([ovsdb-client dump], [0], [stdout], [ignore])
OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock > dump2; diff stdout dump2])
OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock > dump2; diff -u stdout dump2])
OVS_WAIT_UNTIL([ ovsdb-client dump unix:db3.sock > dump3; diff -u stdout dump3])

OVSDB_SERVER_SHUTDOWN
OVSDB_SERVER_SHUTDOWN2
OVSDB_SERVER_SHUTDOWN_N([3])
AT_CLEANUP])

EXECUTION_EXAMPLES
Expand Down Expand Up @@ -1705,11 +1744,33 @@ m4_define([OVSDB_CHECK_REPLICATION],
$2 > schema
AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])

on_exit 'kill `cat *.pid`'
AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])

AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=2.pid --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock --sync-exclude-tables=mydb:b db2], [0], [ignore], [ignore])
AT_CHECK([ovsdb-tool create db3 schema], [0], [stdout], [ignore])

on_exit 'kill $(cat *.pid)'
AT_CHECK([ovsdb-server -vfile --detach --no-chdir --log-file=ovsdb-server1.log \
--pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])

AT_CHECK([ovsdb-server -vfile --detach --no-chdir --log-file=ovsdb-server2.log \
--pidfile=2.pid --remote=punix:db2.sock --unixctl=unixctl2 \
--sync-from=unix:db.sock --sync-exclude-tables=mydb:b db2],
[0], [ignore], [ignore])

AT_DATA([config3.json], [
{
"remotes": { "punix:db3.sock": {} },
"databases": {
"db3": {
"service-model": "active-backup",
"backup": true,
"source": { "unix:db.sock": {} },
"exclude-tables": [["b"]]
}
}
}
])
AT_CHECK([ovsdb-server -vfile --detach --no-chdir --log-file=ovsdb-server3.log \
--pidfile=3.pid --unixctl=unixctl3 --config-file=config3.json],
[0], [ignore], [ignore])

m4_foreach([txn], [$3],
[AT_CHECK([ ovsdb-client transact 'txn' ], [0], [stdout], [ignore])
Expand All @@ -1722,13 +1783,19 @@ m4_define([OVSDB_CHECK_REPLICATION],
AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore])
cat stdout > dump2

OVS_WAIT_UNTIL([ ovsdb-client dump unix:db3.sock | grep one ])
AT_CHECK([ovsdb-client dump unix:db3.sock], [0], [stdout], [ignore])
cat stdout > dump3
AT_CHECK([diff -u dump2 dump3])

AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore])
cat stdout > output

AT_CHECK([uuidfilt output], [0], [$4], [ignore])

OVSDB_SERVER_SHUTDOWN
OVSDB_SERVER_SHUTDOWN2
OVSDB_SERVER_SHUTDOWN_N([3])
AT_CLEANUP])

REPLICATION_EXAMPLES
Expand Down

0 comments on commit 3d738df

Please sign in to comment.