forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovsdb-monitor.at
162 lines (152 loc) · 5.54 KB
/
ovsdb-monitor.at
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
AT_BANNER([OVSDB -- ovsdb-server monitors])
# OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], MONITOR-ARGS,
# TRANSACTIONS, OUTPUT, [KEYWORDS])
#
# Creates a database with the given SCHEMA, starts an ovsdb-server on
# that database, and runs each of the TRANSACTIONS (which should be a
# quoted list of quoted strings) against it with ovsdb-client one at a
# time.
#
# Checks that the overall output is OUTPUT, but UUIDs in the output
# are replaced by markers of the form <N> where N is a number. The
# first unique UUID is replaced by <0>, the next by <1>, and so on.
# If a given UUID appears more than once it is always replaced by the
# same marker.
#
# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
m4_define([OVSDB_CHECK_MONITOR],
[AT_SETUP([$1])
AT_KEYWORDS([ovsdb server monitor positive $7])
AT_DATA([schema], [$2
])
AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
m4_foreach([txn], [$3],
[AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])])
AT_CHECK([ovsdb-server --detach --pidfile=$PWD/server-pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
AT_CHECK([ovsdb-client --detach --pidfile=$PWD/client-pid monitor --format=csv unix:socket $4 > output],
[0], [ignore], [ignore], [kill `cat server-pid`])
m4_foreach([txn], [$5],
[AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
[ignore], [ignore], [kill `cat server-pid client-pid`])])
AT_CHECK([ovsdb-client transact unix:socket '[[]]'], [0],
[ignore], [ignore], [kill `cat server-pid client-pid`])
AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore])
OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$6], [ignore])
AT_CLEANUP])
OVSDB_CHECK_MONITOR([monitor insert into empty table],
[ORDINAL_SCHEMA],
[],
[ordinals],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}}]]]],
[[row,action,name,number,_version
<0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
]])
OVSDB_CHECK_MONITOR([monitor insert into populated table],
[ORDINAL_SCHEMA],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 0, "name": "zero"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
]])
OVSDB_CHECK_MONITOR([monitor delete],
[ORDINAL_SCHEMA],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals],
[[[[{"op": "delete",
"table": "ordinals",
"where": [["number", "==", 10]]}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
]])
OVSDB_CHECK_MONITOR([monitor row update],
[ORDINAL_SCHEMA],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals],
[[[[{"op": "update",
"table": "ordinals",
"where": [["number", "==", 10]],
"row": {"name": "five plus five"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<0>,old,"""ten""",,"[""uuid"",""<1>""]"
,new,"""five plus five""",10,"[""uuid"",""<2>""]"
]])
OVSDB_CHECK_MONITOR([monitor no-op row updates],
[ORDINAL_SCHEMA],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals],
[[[[{"op": "update",
"table": "ordinals",
"where": [["number", "==", 10]],
"row": {"number": 10, "name": "ten"}}]]],
[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 9, "name": "nine"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
]])
OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
[ORDINAL_SCHEMA],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 9, "name": "nine"},
"uuid-name": "nine"},
{"op": "update",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]],
"row": {"name": "three squared"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
]])
OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
[ORDINAL_SCHEMA],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 10, "name": "ten"}}]]]],
[ordinals],
[[[[{"op": "insert",
"table": "ordinals",
"row": {"number": 9, "name": "nine"},
"uuid-name": "nine"},
{"op": "update",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]],
"row": {"name": "three squared"}},
{"op": "delete",
"table": "ordinals",
"where": [["_uuid", "==", ["named-uuid", "nine"]]]},
{"op": "insert",
"table": "ordinals",
"row": {"number": 7, "name": "seven"}}]]]],
[[row,action,name,number,_version
<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
row,action,name,number,_version
<2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
]])