1 AT_BANNER([OVSDB -- ovsdb-client commands])
3 AT_SETUP([ovsdb-client get-schema-version and get-schema-cksum])
4 AT_KEYWORDS([ovsdb client positive])
5 ordinal_schema > schema
6 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
7 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db], [0], [ignore], [ignore])
8 AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3
10 AT_CHECK([ovsdb-client get-schema-cksum unix:socket ordinals], [0], [12345678 9
15 AT_SETUP([ovsdb-client backup and restore])
16 AT_KEYWORDS([ovsdb client positive])
18 on_exit 'kill `cat *.pid`'
20 dnl Create a database.
21 ordinal_schema > schema
23 AT_CHECK([ovsdb-tool create db schema])
25 dnl Put some data in the database.
27 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
29 ovsdb-tool transact db '
33 "row": {"name": "'$1'", "number": '$2'}},
35 "comment": "add row for '"$pair"'"}]'
36 done | uuidfilt]], [0],
37 [[[{"uuid":["uuid","<0>"]},{}]
38 [{"uuid":["uuid","<1>"]},{}]
39 [{"uuid":["uuid","<2>"]},{}]
40 [{"uuid":["uuid","<3>"]},{}]
41 [{"uuid":["uuid","<4>"]},{}]
42 [{"uuid":["uuid","<5>"]},{}]
45 dnl Start the database server.
46 AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], [0])
47 AT_CAPTURE_FILE([ovsdb-server.log])
49 dnl Dump a copy of the data and a backup of it.
50 AT_CHECK([ovsdb-client dump > dump1])
51 AT_CHECK([ovsdb-client backup > backup])
53 dnl Mess up the data a little, verify that it changed, then restore it
54 dnl and verify restoration.
56 [[ovsdb-client transact '
61 "row": {"name": ""}}]']],
65 AT_CHECK([ovsdb-client --no-headings dump ordinals | sort -k 3 | uuidfilt], [0], [dnl
74 AT_CHECK([ovsdb-client restore < backup])
75 AT_CHECK([ovsdb-client dump | tr -s ' ' | sort -k 3 | uuidfilt], [0], [dnl
77 ------------------------------------ ----- ------
86 # Combining the original dump and the backup dump should reveal that the
87 # rows have different uuids:
88 AT_CHECK([(ovsdb-client dump; cat dump1) | tr -s ' ' | sort -k 3 | uuidfilt], [0], [dnl
91 ------------------------------------ ----- ------
92 ------------------------------------ ----- ------
109 dnl Stop the database server, then re-start it based on the backup.
110 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
111 AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock backup], [0])
113 dnl Dump a new copy of the data.
114 AT_CHECK([ovsdb-client dump > dump2])
117 dnl Verify that the two dumps are the same.
118 AT_CHECK([sort dump1], [0], [expout])
122 AT_SETUP([ovsdb-client query])
123 AT_KEYWORDS([ovsdb client positive])
125 on_exit 'kill `cat *.pid`'
127 dnl Create a database.
128 ordinal_schema > schema
130 AT_CHECK([ovsdb-tool create db schema])
132 dnl Start the database server.
133 AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], [0])
134 AT_CAPTURE_FILE([ovsdb-server.log])
136 dnl Put some data in the database.
137 dnl Use "query" for some of them, which won't have any effect.
139 [[for txn in 'transact zero 0' \
151 "row": {"name": "'$2'", "number": '$3'}},
153 "comment": "add row for '"$pair"'"}]'
154 done | uuidfilt]], [0],
155 [[[{"uuid":["uuid","<0>"]},{}]
156 [{"uuid":["uuid","<1>"]},{}]
157 [{"uuid":["uuid","<2>"]},{}]
158 [{"uuid":["uuid","<3>"]},{}]
159 [{"uuid":["uuid","<4>"]},{}]
160 [{"uuid":["uuid","<5>"]},{}]
163 AT_CHECK([ovsdb-client -f csv dump | sort -t, -k 3 | uuidfilt], [0], [dnl
171 OVS_APP_EXIT_AND_WAIT([ovsdb-server])