ovs.db.types: Add table reference to ovs.db.types.BaseType.
[sliver-openvswitch.git] / tests / ovsdb-idl-py.at
1 AT_BANNER([OVSDB -- interface description language (IDL) - Python])
2
3 # OVSDB_CHECK_IDL(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
4 #                 [FILTER])
5 #
6 # Creates a database with a schema derived from idltest.ovsidl, runs
7 # each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
8 # and runs "test-ovsdb idl" passing each of the TRANSACTIONS along.
9 #
10 # Checks that the overall output is OUTPUT.  Before comparison, the
11 # output is sorted (using "sort") and UUIDs in the output are replaced
12 # by markers of the form <N> where N is a number.  The first unique
13 # UUID is replaced by <0>, the next by <1>, and so on.  If a given
14 # UUID appears more than once it is always replaced by the same
15 # marker.  If FILTER is supplied then the output is also filtered
16 # through the specified program.
17 #
18 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
19 m4_define([OVSDB_CHECK_IDL_PY], 
20   [AT_SETUP([$1])
21    AT_SKIP_IF([test $HAVE_PYTHON = no])
22    AT_KEYWORDS([ovsdb server idl positive Python $5])
23    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
24                   [0], [stdout], [ignore])
25    AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
26    m4_if([$2], [], [],
27      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
28    AT_CHECK([$PYTHON $srcdir/test-ovsdb.py  -t10 idl unix:socket $3], 
29             [0], [stdout], [ignore], [kill `cat pid`])
30    AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
31             [0], [$4], [], [kill `cat pid`])
32    OVSDB_SERVER_SHUTDOWN
33    AT_CLEANUP])
34
35 OVSDB_CHECK_IDL_PY([simple idl, initially empty, no ops - Python],
36   [],
37   [],
38   [000: empty
39 001: done
40 ])
41
42 OVSDB_CHECK_IDL_PY([simple idl, initially empty, various ops - Python],
43   [],
44   [['["idltest",
45       {"op": "insert",
46        "table": "simple",
47        "row": {"i": 1,
48                "r": 2.0,
49                "b": true,
50                "s": "mystring",
51                "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
52                "ia": ["set", [1, 2, 3]],
53                "ra": ["set", [-0.5]],
54                "ba": ["set", [true]],
55                "sa": ["set", ["abc", "def"]], 
56                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
57                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
58       {"op": "insert",
59        "table": "simple",
60        "row": {}}]' \
61     '["idltest",
62       {"op": "update",
63        "table": "simple",
64        "where": [],
65        "row": {"b": true}}]' \
66     '["idltest",
67       {"op": "update",
68        "table": "simple",
69        "where": [],
70        "row": {"r": 123.5}}]' \
71     '["idltest",
72       {"op": "insert",
73        "table": "simple",
74        "row": {"i": -1,
75                "r": 125,
76                "b": false,
77                "s": "",
78                "ia": ["set", [1]],
79                "ra": ["set", [1.5]],
80                "ba": ["set", [false]],
81                "sa": ["set", []], 
82                "ua": ["set", []]}}]' \
83     '["idltest",
84       {"op": "update",
85        "table": "simple",
86        "where": [["i", "<", 1]],
87        "row": {"s": "newstring"}}]' \
88     '["idltest",
89       {"op": "delete",
90        "table": "simple",
91        "where": [["i", "==", 0]]}]' \
92     'reconnect']],
93   [[000: empty
94 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
95 002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
96 002: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<4> <5>] uuid=<0>
97 003: {"error":null,"result":[{"count":2}]}
98 004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
99 004: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<4> <5>] uuid=<0>
100 005: {"error":null,"result":[{"count":2}]}
101 006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
102 006: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<4> <5>] uuid=<0>
103 007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
104 008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=false sa=[] ua=[] uuid=<6>
105 008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
106 008: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<4> <5>] uuid=<0>
107 009: {"error":null,"result":[{"count":2}]}
108 010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=false sa=[] ua=[] uuid=<6>
109 010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
110 010: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<4> <5>] uuid=<0>
111 011: {"error":null,"result":[{"count":1}]}
112 012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=false sa=[] ua=[] uuid=<6>
113 012: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<4> <5>] uuid=<0>
114 013: reconnect
115 014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=false sa=[] ua=[] uuid=<6>
116 014: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<4> <5>] uuid=<0>
117 015: done
118 ]])
119
120 OVSDB_CHECK_IDL_PY([simple idl, initially populated - Python],
121   [['["idltest",
122       {"op": "insert",
123        "table": "simple",
124        "row": {"i": 1,
125                "r": 2.0,
126                "b": true,
127                "s": "mystring",
128                "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
129                "ia": ["set", [1, 2, 3]],
130                "ra": ["set", [-0.5]],
131                "ba": ["set", [true]],
132                "sa": ["set", ["abc", "def"]], 
133                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
134                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
135       {"op": "insert",
136        "table": "simple",
137        "row": {}}]']],
138   [['["idltest",
139       {"op": "update",
140        "table": "simple",
141        "where": [],
142        "row": {"b": true}}]']],
143   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
144 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<3> <4>] uuid=<5>
145 001: {"error":null,"result":[{"count":2}]}
146 002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
147 002: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=true sa=[abc def] ua=[<3> <4>] uuid=<5>
148 003: done
149 ]])