]> git.proxmox.com Git - ovs.git/blame - tests/ovsdb-types.at
Fix ovs-dpctl-top by removing 3 wrong hunks in py3-compat.patch.
[ovs.git] / tests / ovsdb-types.at
CommitLineData
f85f8ebb
BP
1AT_BANNER([OVSDB -- atomic types])
2
99155935 3OVSDB_CHECK_POSITIVE_CPY([integer],
f85f8ebb 4 [[parse-atomic-type '["integer"]' ]], ["integer"])
99155935 5OVSDB_CHECK_POSITIVE_CPY([real],
f85f8ebb 6 [[parse-atomic-type '["real"]' ]], ["real"])
99155935 7OVSDB_CHECK_POSITIVE_CPY([boolean],
f85f8ebb 8 [[parse-atomic-type '["boolean"]' ]], ["boolean"])
99155935 9OVSDB_CHECK_POSITIVE_CPY([string],
f85f8ebb 10 [[parse-atomic-type '["string"]' ]], ["string"])
99155935 11OVSDB_CHECK_POSITIVE_CPY([uuid],
f85f8ebb 12 [[parse-atomic-type '["uuid"]' ]], ["uuid"])
99155935 13OVSDB_CHECK_NEGATIVE_CPY([void is not a valid atomic-type],
f85f8ebb
BP
14 [[parse-atomic-type '["void"]' ]], ["void" is not an atomic-type])
15
bd76d25d
BP
16AT_BANNER([OVSDB -- base types])
17
99155935 18OVSDB_CHECK_POSITIVE_CPY([integer enum],
bfc96d9b
BP
19 [[parse-base-type '{"type": "integer", "enum": ["set", [-1, 4, 5]]}' ]],
20 [[{"enum":["set",[-1,4,5]],"type":"integer"}]])
99155935 21OVSDB_CHECK_POSITIVE_CPY([integer >= 5],
bd76d25d
BP
22 [[parse-base-type '{"type": "integer", "minInteger": 5}' ]],
23 [{"minInteger":5,"type":"integer"}])
99155935 24OVSDB_CHECK_POSITIVE_CPY([integer <= 7],
bd76d25d
BP
25 [[parse-base-type '{"type": "integer", "maxInteger": 7}' ]],
26 [{"maxInteger":7,"type":"integer"}])
99155935 27OVSDB_CHECK_POSITIVE_CPY([integer between -5 and 10],
bd76d25d
BP
28 [[parse-base-type '{"type": "integer", "minInteger": -5, "maxInteger": 10}']],
29 [{"maxInteger":10,"minInteger":-5,"type":"integer"}])
99155935 30OVSDB_CHECK_NEGATIVE_CPY([integer max may not be less than min],
bd76d25d
BP
31 [[parse-base-type '{"type": "integer", "minInteger": 5, "maxInteger": 3}']],
32 [minInteger exceeds maxInteger])
33
99155935 34OVSDB_CHECK_POSITIVE_CPY([real enum],
bfc96d9b
BP
35 [[parse-base-type '{"type": "real", "enum": ["set", [1.5, 0, 2.75]]}' ]],
36 [[{"enum":["set",[0,1.5,2.75]],"type":"real"}]])
99155935 37OVSDB_CHECK_POSITIVE_CPY([real >= -1.5],
bd76d25d
BP
38 [[parse-base-type '{"type": "real", "minReal": -1.5}']],
39 [{"minReal":-1.5,"type":"real"}])
99155935 40OVSDB_CHECK_POSITIVE_CPY([real <= 1e5],
bd76d25d
BP
41 [[parse-base-type '{"type": "real", "maxReal": 1e5}']],
42 [{"maxReal":100000,"type":"real"}])
99155935 43OVSDB_CHECK_POSITIVE_CPY([real between -2.5 and 3.75],
bd76d25d
BP
44 [[parse-base-type '{"type": "real", "minReal": -2.5, "maxReal": 3.75}']],
45 [{"maxReal":3.75,"minReal":-2.5,"type":"real"}])
99155935 46OVSDB_CHECK_NEGATIVE_CPY([real max may not be less than min],
bd76d25d
BP
47 [[parse-base-type '{"type": "real", "minReal": 555, "maxReal": 444}']],
48 [minReal exceeds maxReal])
49
99155935 50OVSDB_CHECK_POSITIVE_CPY([boolean],
bd76d25d 51 [[parse-base-type '[{"type": "boolean"}]' ]], ["boolean"])
99155935 52OVSDB_CHECK_POSITIVE_CPY([boolean enum],
bfc96d9b
BP
53 [[parse-base-type '{"type": "boolean", "enum": true}' ]],
54 [[{"enum":true,"type":"boolean"}]])
bd76d25d 55
99155935 56OVSDB_CHECK_POSITIVE_CPY([string enum],
bfc96d9b
BP
57 [[parse-base-type '{"type": "string", "enum": ["set", ["def", "abc"]]}']],
58 [[{"enum":["set",["abc","def"]],"type":"string"}]])
99155935 59OVSDB_CHECK_POSITIVE_CPY([string minLength],
bd76d25d
BP
60 [[parse-base-type '{"type": "string", "minLength": 1}']],
61 [{"minLength":1,"type":"string"}])
99155935 62OVSDB_CHECK_POSITIVE_CPY([string maxLength],
bd76d25d
BP
63 [[parse-base-type '{"type": "string", "maxLength": 5}']],
64 [{"maxLength":5,"type":"string"}])
99155935 65OVSDB_CHECK_POSITIVE_CPY([string minLength and maxLength],
bd76d25d
BP
66 [[parse-base-type '{"type": "string", "minLength": 1, "maxLength": 5}']],
67 [{"maxLength":5,"minLength":1,"type":"string"}])
99155935 68OVSDB_CHECK_NEGATIVE_CPY([maxLength must not be less than minLength],
bd76d25d
BP
69 [[parse-base-type '{"type": "string", "minLength": 5, "maxLength": 3}']],
70 [minLength exceeds maxLength])
99155935 71OVSDB_CHECK_NEGATIVE_CPY([maxLength must not be negative],
bd76d25d
BP
72 [[parse-base-type '{"type": "string", "maxLength": -1}']],
73 [maxLength out of valid range 0 to 4294967295])
74
99155935 75OVSDB_CHECK_POSITIVE_CPY([uuid enum],
bfc96d9b
BP
76 [[parse-base-type '{"type": "uuid", "enum": ["uuid", "36bf19c0-ad9d-4232-bb85-b3d73dfe2123"]}' ]],
77 [[{"enum":["uuid","36bf19c0-ad9d-4232-bb85-b3d73dfe2123"],"type":"uuid"}]])
99155935 78OVSDB_CHECK_POSITIVE_CPY([uuid refTable],
0d0f05b9
BP
79 [[parse-base-type '{"type": "uuid", "refTable": "myTable"}' ]],
80 [{"refTable":"myTable","type":"uuid"}])
99155935 81OVSDB_CHECK_NEGATIVE_CPY([uuid refTable must be valid id],
0d0f05b9
BP
82 [[parse-base-type '{"type": "uuid", "refTable": "a-b-c"}' ]],
83 [Type mismatch for member 'refTable'])
84
99155935 85OVSDB_CHECK_NEGATIVE_CPY([void is not a valid base-type],
bd76d25d 86 [[parse-base-type '["void"]' ]], ["void" is not an atomic-type])
99155935 87OVSDB_CHECK_NEGATIVE_CPY(["type" member must be present],
bd76d25d
BP
88 [[parse-base-type '{}']], [Parsing ovsdb type failed: Required 'type' member is missing.])
89
f85f8ebb
BP
90AT_BANNER([OVSDB -- simple types])
91
99155935 92OVSDB_CHECK_POSITIVE_CPY([simple integer],
f85f8ebb 93 [[parse-type '["integer"]' ]], ["integer"])
99155935 94OVSDB_CHECK_POSITIVE_CPY([simple real],
f85f8ebb 95 [[parse-type '["real"]' ]], ["real"])
99155935 96OVSDB_CHECK_POSITIVE_CPY([simple boolean],
f85f8ebb 97 [[parse-type '["boolean"]' ]], ["boolean"])
99155935 98OVSDB_CHECK_POSITIVE_CPY([simple string],
f85f8ebb 99 [[parse-type '["string"]' ]], ["string"])
99155935 100OVSDB_CHECK_POSITIVE_CPY([simple uuid],
f85f8ebb 101 [[parse-type '["uuid"]' ]], ["uuid"])
99155935 102OVSDB_CHECK_POSITIVE_CPY([integer in object],
f85f8ebb 103 [[parse-type '{"key": "integer"}' ]], ["integer"])
99155935 104OVSDB_CHECK_POSITIVE_CPY([real in object with explicit min and max],
f85f8ebb
BP
105 [[parse-type '{"key": "real", "min": 1, "max": 1}' ]], ["real"])
106
99155935 107OVSDB_CHECK_NEGATIVE_CPY([key type is required],
f85f8ebb 108 [[parse-type '{}' ]], [Required 'key' member is missing.])
99155935 109OVSDB_CHECK_NEGATIVE_CPY([void is not a valid type],
f85f8ebb
BP
110 [[parse-type '["void"]' ]], ["void" is not an atomic-type])
111
112AT_BANNER([OVSDB -- set types])
113
99155935 114OVSDB_CHECK_POSITIVE_CPY([optional boolean],
f85f8ebb
BP
115 [[parse-type '{"key": "boolean", "min": 0}' ]],
116 [[{"key":"boolean","min":0}]],
117 [set])
99155935 118OVSDB_CHECK_POSITIVE_CPY([set of 1 to 3 uuids],
f85f8ebb
BP
119 [[parse-type '{"key": "uuid", "min": 1, "max": 3}' ]],
120 [[{"key":"uuid","max":3}]])
99155935 121OVSDB_CHECK_POSITIVE_CPY([set of 0 to 3 strings],
f85f8ebb
BP
122 [[parse-type '{"key": "string", "min": 0, "max": 3}' ]],
123 [[{"key":"string","max":3,"min":0}]])
99155935 124OVSDB_CHECK_POSITIVE_CPY([set of 0 or more integers],
f85f8ebb
BP
125 [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
126 [[{"key":"integer","max":"unlimited","min":0}]])
99155935 127OVSDB_CHECK_POSITIVE_CPY([set of 1 or more reals],
31a763d7
BP
128 [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
129 [[{"key":"real","max":"unlimited"}]])
f85f8ebb 130
99155935 131OVSDB_CHECK_NEGATIVE_CPY([set max cannot be less than min],
f85f8ebb
BP
132 [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
133 [ovsdb type fails constraint checks])
99155935 134OVSDB_CHECK_NEGATIVE_CPY([set max cannot be negative],
f85f8ebb
BP
135 [[parse-type '{"key": "real", "max": -1}' ]],
136 [bad min or max value])
99155935 137OVSDB_CHECK_NEGATIVE_CPY([set min cannot be negative],
f85f8ebb
BP
138 [[parse-type '{"key": "real", "min": -1}' ]],
139 [bad min or max value])
99155935 140OVSDB_CHECK_NEGATIVE_CPY([set min cannot be greater than one],
31a763d7
BP
141 [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
142 [ovsdb type fails constraint checks])
f85f8ebb
BP
143
144AT_BANNER([OVSDB -- map types])
145
99155935 146OVSDB_CHECK_POSITIVE_CPY([map of 1 integer to boolean],
f85f8ebb
BP
147 [[parse-type '{"key": "integer", "value": "boolean"}' ]],
148 [[{"key":"integer","value":"boolean"}]])
99155935 149OVSDB_CHECK_POSITIVE_CPY([map of 1 boolean to integer, explicit min and max],
f85f8ebb
BP
150 [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
151 [[{"key":"boolean","value":"integer"}]])
99155935 152OVSDB_CHECK_POSITIVE_CPY([map of 1 to 5 uuid to real],
31a763d7
BP
153 [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
154 [[{"key":"uuid","max":5,"value":"real"}]])
99155935 155OVSDB_CHECK_POSITIVE_CPY([map of 0 to 10 string to uuid],
f85f8ebb
BP
156 [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
157 [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
99155935 158OVSDB_CHECK_POSITIVE_CPY([map of 1 to 20 real to string],
31a763d7
BP
159 [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
160 [[{"key":"real","max":20,"value":"string"}]])
99155935 161OVSDB_CHECK_POSITIVE_CPY([map of 0 or more string to real],
31a763d7
BP
162 [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
163 [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
f85f8ebb 164
99155935 165OVSDB_CHECK_NEGATIVE_CPY([map key type is required],
f85f8ebb
BP
166 [[parse-type '{"value": "integer"}' ]],
167 [Required 'key' member is missing.])