]>
Commit | Line | Data |
---|---|---|
7ed92408 BP |
1 | AT_BANNER([OVSDB -- ovsdb-client commands]) |
2 | ||
33785c07 | 3 | AT_SETUP([ovsdb-client get-schema-version and get-schema-cksum]) |
7ed92408 BP |
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 | |
9 | ]) | |
33785c07 BP |
10 | AT_CHECK([ovsdb-client get-schema-cksum unix:socket ordinals], [0], [12345678 9 |
11 | ]) | |
7ed92408 BP |
12 | OVSDB_SERVER_SHUTDOWN |
13 | AT_CLEANUP | |
4d0a31b6 | 14 | |
fe0fb885 | 15 | AT_SETUP([ovsdb-client backup and restore]) |
4d0a31b6 BP |
16 | AT_KEYWORDS([ovsdb client positive]) |
17 | ||
18 | on_exit 'kill `cat *.pid`' | |
19 | ||
20 | dnl Create a database. | |
21 | ordinal_schema > schema | |
22 | touch .db.~lock~ | |
23 | AT_CHECK([ovsdb-tool create db schema]) | |
24 | ||
25 | dnl Put some data in the database. | |
26 | AT_CHECK( | |
27 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
28 | set -- $pair | |
29 | ovsdb-tool transact db ' | |
30 | ["ordinals", | |
31 | {"op": "insert", | |
32 | "table": "ordinals", | |
33 | "row": {"name": "'$1'", "number": '$2'}}, | |
34 | {"op": "comment", | |
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>"]},{}] | |
43 | ]], [ignore]) | |
44 | ||
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]) | |
48 | ||
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]) | |
52 | ||
fe0fb885 BP |
53 | dnl Mess up the data a little, verify that it changed, then restore it |
54 | dnl and verify restoration. | |
55 | AT_CHECK( | |
56 | [[ovsdb-client transact ' | |
57 | ["ordinals", | |
58 | {"op": "update", | |
59 | "table": "ordinals", | |
5a0e4aec BP |
60 | "where": [], |
61 | "row": {"name": ""}}]']], | |
fe0fb885 BP |
62 | [0], |
63 | [[[{"count":6}] | |
64 | ]]) | |
65 | AT_CHECK([ovsdb-client --no-headings dump ordinals | sort -k 3 | uuidfilt], [0], [dnl | |
66 | ordinals table | |
80f66ee0 BP |
67 | <0> "" 0 |
68 | <1> "" 1 | |
69 | <2> "" 2 | |
70 | <3> "" 3 | |
71 | <4> "" 4 | |
72 | <5> "" 5 | |
fe0fb885 BP |
73 | ]) |
74 | AT_CHECK([ovsdb-client restore < backup]) | |
75 | AT_CHECK([ovsdb-client dump | tr -s ' ' | sort -k 3 | uuidfilt], [0], [dnl | |
76 | ordinals table | |
77 | ------------------------------------ ----- ------ | |
78 | <0> zero 0 | |
79 | <1> one 1 | |
80 | <2> two 2 | |
81 | <3> three 3 | |
82 | <4> four 4 | |
83 | <5> five 5 | |
84 | _uuid name number | |
85 | ]) | |
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 | |
89 | ordinals table | |
90 | ordinals table | |
91 | ------------------------------------ ----- ------ | |
92 | ------------------------------------ ----- ------ | |
93 | <0> zero 0 | |
94 | <1> zero 0 | |
95 | <2> one 1 | |
96 | <3> one 1 | |
97 | <4> two 2 | |
98 | <5> two 2 | |
99 | <6> three 3 | |
100 | <7> three 3 | |
101 | <8> four 4 | |
102 | <9> four 4 | |
103 | <10> five 5 | |
104 | <11> five 5 | |
105 | _uuid name number | |
106 | _uuid name number | |
107 | ]) | |
108 | ||
4d0a31b6 BP |
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]) | |
112 | ||
113 | dnl Dump a new copy of the data. | |
114 | AT_CHECK([ovsdb-client dump > dump2]) | |
115 | sort dump2 > expout | |
116 | ||
117 | dnl Verify that the two dumps are the same. | |
118 | AT_CHECK([sort dump1], [0], [expout]) | |
119 | ||
120 | AT_CLEANUP | |
838f9c31 BP |
121 | |
122 | AT_SETUP([ovsdb-client query]) | |
123 | AT_KEYWORDS([ovsdb client positive]) | |
124 | ||
125 | on_exit 'kill `cat *.pid`' | |
126 | ||
127 | dnl Create a database. | |
128 | ordinal_schema > schema | |
129 | touch .db.~lock~ | |
130 | AT_CHECK([ovsdb-tool create db schema]) | |
131 | ||
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]) | |
135 | ||
136 | dnl Put some data in the database. | |
137 | dnl Use "query" for some of them, which won't have any effect. | |
138 | AT_CHECK( | |
139 | [[for txn in 'transact zero 0' \ | |
140 | 'query one 1' \ | |
5a0e4aec BP |
141 | 'transact two 2' \ |
142 | 'query three 3' \ | |
143 | 'transact four 4' \ | |
144 | 'query five 5' | |
838f9c31 BP |
145 | do |
146 | set -- $txn | |
147 | ovsdb-client $1 ' | |
148 | ["ordinals", | |
149 | {"op": "insert", | |
150 | "table": "ordinals", | |
151 | "row": {"name": "'$2'", "number": '$3'}}, | |
152 | {"op": "comment", | |
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>"]},{}] | |
161 | ]], [ignore]) | |
162 | ||
163 | AT_CHECK([ovsdb-client -f csv dump | sort -t, -k 3 | uuidfilt], [0], [dnl | |
164 | ordinals table | |
165 | <0>,zero,0 | |
166 | <1>,two,2 | |
167 | <2>,four,4 | |
168 | _uuid,name,number | |
169 | ]) | |
170 | ||
171 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
172 | ||
173 | AT_CLEANUP |