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
|
AT_BANNER([OVSDB -- ovsdb-client commands])
AT_SETUP([ovsdb-client get-schema-version and get-schema-cksum])
AT_KEYWORDS([ovsdb client positive])
ordinal_schema > schema
on_exit 'kill `cat *.pid`'
AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
AT_CHECK([ovsdb-server --detach --no-chdir --log-file --pidfile --remote=punix:socket db], [0], [ignore], [ignore])
AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3
])
AT_CHECK([ovsdb-client get-schema-cksum unix:socket ordinals], [0], [12345678 9
])
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP
AT_SETUP([ovsdb-client needs-conversion (no conversion needed)])
AT_KEYWORDS([ovsdb client file positive])
on_exit 'kill `cat *.pid`'
ordinal_schema > schema
touch .db.~lock~
AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
AT_CHECK([ovsdb-server --detach --no-chdir --log-file --pidfile --remote=punix:socket db], [0], [ignore], [ignore])
AT_CHECK([ovsdb-client needs-conversion unix:socket schema], [0], [no
])
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP
AT_SETUP([ovsdb-client needs-conversion (conversion needed)])
AT_KEYWORDS([ovsdb client file positive])
ordinal_schema > schema
touch .db.~lock~
on_exit 'kill `cat *.pid`'
AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
AT_CHECK([ovsdb-server --detach --no-chdir --log-file --pidfile --remote=punix:socket db], [0], [ignore], [ignore])
sed 's/5\.1\.3/5.1.4/' < schema > schema2
AT_CHECK([diff schema schema2], [1], [ignore])
AT_CHECK([ovsdb-client needs-conversion unix:socket schema2], [0], [yes
])
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP
AT_SETUP([ovsdb-client backup and restore])
AT_KEYWORDS([ovsdb client positive])
on_exit 'kill `cat *.pid`'
dnl Create a database.
ordinal_schema > schema
touch .db.~lock~
AT_CHECK([ovsdb-tool create db schema])
dnl Put some data in the database.
AT_CHECK(
[[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
set -- $pair
ovsdb-tool transact db '
["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"name": "'$1'", "number": '$2'}},
{"op": "comment",
"comment": "add row for '"$pair"'"}]'
done | uuidfilt]], [0],
[[[{"uuid":["uuid","<0>"]},{}]
[{"uuid":["uuid","<1>"]},{}]
[{"uuid":["uuid","<2>"]},{}]
[{"uuid":["uuid","<3>"]},{}]
[{"uuid":["uuid","<4>"]},{}]
[{"uuid":["uuid","<5>"]},{}]
]], [ignore])
dnl Start the database server.
AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], [0])
AT_CAPTURE_FILE([ovsdb-server.log])
dnl Dump a copy of the data and a backup of it.
AT_CHECK([ovsdb-client dump > dump1])
AT_CHECK([ovsdb-client backup > backup])
dnl Mess up the data a little, verify that it changed, then restore it
dnl and verify restoration.
AT_CHECK(
[[ovsdb-client transact '
["ordinals",
{"op": "update",
"table": "ordinals",
"where": [],
"row": {"name": ""}}]']],
[0],
[[[{"count":6}]
]])
AT_CHECK([ovsdb-client --no-headings dump ordinals | sort -k 3 | uuidfilt], [0], [dnl
ordinals table
<0> "" 0
<1> "" 1
<2> "" 2
<3> "" 3
<4> "" 4
<5> "" 5
])
AT_CHECK([ovsdb-client restore < backup])
AT_CHECK([ovsdb-client dump | tr -s ' ' | sort -k 3 | uuidfilt], [0], [dnl
ordinals table
------------------------------------ ----- ------
<0> zero 0
<1> one 1
<2> two 2
<3> three 3
<4> four 4
<5> five 5
_uuid name number
])
# Combining the original dump and the backup dump should reveal that the
# rows have different uuids:
AT_CHECK([(ovsdb-client dump; cat dump1) | tr -s ' ' | sort -k 3 | uuidfilt], [0], [dnl
ordinals table
ordinals table
------------------------------------ ----- ------
------------------------------------ ----- ------
<0> zero 0
<1> zero 0
<2> one 1
<3> one 1
<4> two 2
<5> two 2
<6> three 3
<7> three 3
<8> four 4
<9> four 4
<10> five 5
<11> five 5
_uuid name number
_uuid name number
])
dnl Stop the database server, then re-start it based on the backup.
OVSDB_SERVER_SHUTDOWN
AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock backup], [0])
dnl Dump a new copy of the data.
AT_CHECK([ovsdb-client dump > dump2])
sort dump2 > expout
dnl Verify that the two dumps are the same.
AT_CHECK([sort dump1], [0], [expout])
AT_CLEANUP
AT_SETUP([ovsdb-client query])
AT_KEYWORDS([ovsdb client positive])
on_exit 'kill `cat *.pid`'
dnl Create a database.
ordinal_schema > schema
touch .db.~lock~
AT_CHECK([ovsdb-tool create db schema])
dnl Start the database server.
AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], [0])
AT_CAPTURE_FILE([ovsdb-server.log])
dnl Put some data in the database.
dnl Use "query" for some of them, which won't have any effect.
AT_CHECK(
[[for txn in 'transact zero 0' \
'query one 1' \
'transact two 2' \
'query three 3' \
'transact four 4' \
'query five 5'
do
set -- $txn
ovsdb-client $1 '
["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"name": "'$2'", "number": '$3'}},
{"op": "comment",
"comment": "add row for '"$pair"'"}]'
done | uuidfilt]], [0],
[[[{"uuid":["uuid","<0>"]},{}]
[{"uuid":["uuid","<1>"]},{}]
[{"uuid":["uuid","<2>"]},{}]
[{"uuid":["uuid","<3>"]},{}]
[{"uuid":["uuid","<4>"]},{}]
[{"uuid":["uuid","<5>"]},{}]
]], [ignore])
AT_CHECK([ovsdb-client -f csv dump | sort -t, -k 3 | uuidfilt], [0], [dnl
ordinals table
<0>,zero,0
<1>,two,2
<2>,four,4
_uuid,name,number
])
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP
AT_SETUP([ovsdb-client record/replay])
AT_KEYWORDS([ovsdb client record replay])
on_exit 'kill `cat *.pid`'
dnl Create a database.
ordinal_schema > schema
touch .db.~lock~
AT_CHECK([ovsdb-tool create db schema])
dnl Start the database server.
AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile dnl
--log-file --remote=punix:db.sock db], [0])
AT_CAPTURE_FILE([ovsdb-server.log])
dnl Start a monitor on the 'ordinals' db with recording enabled.
AT_CHECK([mkdir replay_dir])
AT_CHECK([ovsdb-client --record=./replay_dir dnl
-vfile -vvlog:off --detach --no-chdir dnl
--pidfile --log-file=monitor.log dnl
--db-change-aware --no-headings dnl
monitor unix:db.sock dnl
ordinals ordinals number name dnl
> monitor.stdout 2> monitor.stderr])
AT_CAPTURE_FILE([monitor.log])
dnl Put some data in the database.
AT_CHECK(
[[for txn in 'transact zero 0' \
'transact two 2' \
'transact four 4'
do
set -- $txn
ovsdb-client $1 '
["ordinals",
{"op": "insert",
"table": "ordinals",
"row": {"name": "'$2'", "number": '$3'}},
{"op": "comment",
"comment": "add row for '"$pair"'"}]'
done | uuidfilt]], [0],
[[[{"uuid":["uuid","<0>"]},{}]
[{"uuid":["uuid","<1>"]},{}]
[{"uuid":["uuid","<2>"]},{}]
]], [ignore])
AT_CHECK([ovsdb-client -f csv dump | sort -t, -k 3 | uuidfilt], [0], [dnl
ordinals table
<0>,zero,0
<1>,two,2
<2>,four,4
_uuid,name,number
])
dnl Stopping the server.
OVSDB_SERVER_SHUTDOWN
dnl ovsdb-client should exit by itself after disconnection form the server.
OVS_WAIT_WHILE([test -e ovsdb-client.pid])
dnl Starting replay.
AT_CHECK([ovsdb-client --replay=./replay_dir dnl
-vfile -vvlog:off --detach --no-chdir dnl
--pidfile --log-file=monitor-replay.log dnl
--db-change-aware --no-headings dnl
monitor unix:db.sock dnl
ordinals ordinals number name dnl
> monitor-replay.stdout 2> monitor-replay.stderr])
dnl Waiting for client to exit the same way as it exited during recording.
OVS_WAIT_WHILE([test -e ovsdb-client.pid])
AT_CHECK([diff -u monitor.stdout monitor-replay.stdout])
AT_CHECK([diff -u monitor.stderr monitor-replay.stderr])
dnl Stripping out timestamps, PIDs and poll_loop warnings from the log.
dnl Also stripping socket_util errors as sockets are not used in replay.
m4_define([CLEAN_LOG_FILE],
[sed 's/[[0-9\-]]*T[[0-9:\.]]*Z|[[0-9]]*\(|.*$\)/\1/g' $1 | dnl
sed '/|poll_loop|/d' | dnl
sed '/|socket_util|/d' | dnl
sed 's/[[0-9]]*\.ctl/<cleared>\.ctl/g'> $2])
CLEAN_LOG_FILE([monitor.log], [monitor.log.clear])
CLEAN_LOG_FILE([monitor-replay.log], [monitor-replay.log.clear])
AT_CHECK([diff -u monitor.log.clear monitor-replay.log.clear])
AT_CLEANUP
|