Skip to content

Commit 5fa24fa

Browse files
Review Telemetry testclasses, added UnitTests, added/renamed Tests (#398)
* Clarifications on Subscribe Testclasses * Improve gitignore content * Improve UnitTests of path handling * Add Testcases UnitTests to linting and formatting * Add UnitTests for Telemetry Once * Added telemetry_once.CountUpdatePaths * Changes to Telemetry Once * Check always that the Updates belong to the subscribed path * Add `CountUpdatePaths` testclass * Rename `CheckLeafs` to `CheckLeafsFromModel` * Changes to Telemetry Sample * Check always that the Updates belong to the subscribed path * Rename `CountUpdates` to `CountUpdatePaths` * Rename `CheckLeafs` to `CheckLeafsFromModel` * Update sample Test Files * Update Demo * Reviewed CheckLeafsFromModel From telemetry_once and telemetry_sample Also, added UnitTests * Correct arg in docstring * Increase Version, as some Testclasses have changed
1 parent 817dbda commit 5fa24fa

File tree

17 files changed

+1335
-169
lines changed

17 files changed

+1335
-169
lines changed

oc_config_validate/.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
/venv/
2-
/oc_config_validate.egg-info/
3-
/dist/
1+
venv/
2+
oc_config_validate.egg-info/
3+
dist/
4+
.pytype/

oc_config_validate/demo/config_results.json

Lines changed: 118 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"FOO",
66
"BAR"
77
],
8-
"start_time_sec": 1681289912.9265878,
9-
"end_time_sec": 1681289923.6248236,
8+
"start_time_sec": 1755724163.3086755,
9+
"end_time_sec": 1755724180.9333513,
1010
"results": [
1111
{
1212
"test_name": "Get System Config",
@@ -17,7 +17,7 @@
1717
"test_case": "test0200",
1818
"test_class": "Get",
1919
"test_module": "oc_config_validate.testcases",
20-
"start_time_sec": 1681289912,
20+
"start_time_sec": 1755724163,
2121
"duration_sec": 0,
2222
"result": "PASS",
2323
"log": ""
@@ -27,14 +27,14 @@
2727
{
2828
"test_name": "Check System Config",
2929
"success": true,
30-
"duration_sec": 1,
30+
"duration_sec": 0,
3131
"results": [
3232
{
3333
"test_case": "testGetJsonCheck",
3434
"test_class": "GetJsonCheck",
3535
"test_module": "oc_config_validate.testcases",
36-
"start_time_sec": 1681289912,
37-
"duration_sec": 1,
36+
"start_time_sec": 1755724163,
37+
"duration_sec": 0,
3838
"result": "PASS",
3939
"log": ""
4040
}
@@ -49,7 +49,7 @@
4949
"test_case": "testGetJsonCheck",
5050
"test_class": "GetJsonCheck",
5151
"test_module": "oc_config_validate.testcases",
52-
"start_time_sec": 1681289913,
52+
"start_time_sec": 1755724163,
5353
"duration_sec": 0,
5454
"result": "PASS",
5555
"log": ""
@@ -65,7 +65,23 @@
6565
"test_case": "testGetCompare",
6666
"test_class": "GetCompare",
6767
"test_module": "oc_config_validate.testcases",
68-
"start_time_sec": 1681289913,
68+
"start_time_sec": 1755724163,
69+
"duration_sec": 0,
70+
"result": "PASS",
71+
"log": ""
72+
}
73+
]
74+
},
75+
{
76+
"test_name": "Compare Domain Configured",
77+
"success": true,
78+
"duration_sec": 0,
79+
"results": [
80+
{
81+
"test_case": "testGetCompare",
82+
"test_class": "GetCompare",
83+
"test_module": "oc_config_validate.testcases",
84+
"start_time_sec": 1755724163,
6985
"duration_sec": 0,
7086
"result": "PASS",
7187
"log": ""
@@ -81,7 +97,7 @@
8197
"test_case": "testGetCompare",
8298
"test_class": "GetCompare",
8399
"test_module": "oc_config_validate.testcases",
84-
"start_time_sec": 1681289913,
100+
"start_time_sec": 1755724163,
85101
"duration_sec": 0,
86102
"result": "PASS",
87103
"log": ""
@@ -97,39 +113,39 @@
97113
"test_case": "testGetCompare",
98114
"test_class": "GetCompare",
99115
"test_module": "oc_config_validate.testcases",
100-
"start_time_sec": 1681289913,
116+
"start_time_sec": 1755724163,
101117
"duration_sec": 0,
102118
"result": "PASS",
103119
"log": ""
104120
}
105121
]
106122
},
107123
{
108-
"test_name": "Bad Compare mgmt Interface state JSON",
124+
"test_name": "FAIL Compare mgmt Interface state JSON",
109125
"success": false,
110126
"duration_sec": 0,
111127
"results": [
112128
{
113129
"test_case": "testGetCompare",
114130
"test_class": "GetCompare",
115131
"test_module": "oc_config_validate.testcases",
116-
"start_time_sec": 1681289913,
132+
"start_time_sec": 1755724163,
117133
"duration_sec": 0,
118134
"result": "FAIL",
119-
"log": "\n Traceback (most recent call last):\n File \"/home/itamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 56, in inner\n method(self, *args, **kw)\n File \"/home/itamayo/gnxi/oc_config_validate/oc_config_validate/testcases/get.py\", line 49, in testGetCompare\n self.assertTrue(cmp, diff)\nAssertionError: False is not true : key openconfig-interfaces:enabled: got 'True', wanted 'False'\n"
135+
"log": "\n Traceback (most recent call last):\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 55, in inner\n method(self, *args, **kw)\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testcases/get.py\", line 49, in testGetCompare\n self.assertTrue(cmp, diff)\nAssertionError: False is not true : key openconfig-interfaces:enabled: got 'True', wanted 'False'\n"
120136
}
121137
]
122138
},
123139
{
124-
"test_name": "Set Hostname",
140+
"test_name": "Update Hostname",
125141
"success": true,
126142
"duration_sec": 2,
127143
"results": [
128144
{
129145
"test_case": "testSetUpdate",
130146
"test_class": "SetUpdate",
131147
"test_module": "oc_config_validate.testcases",
132-
"start_time_sec": 1681289913,
148+
"start_time_sec": 1755724163,
133149
"duration_sec": 2,
134150
"result": "PASS",
135151
"log": ""
@@ -145,55 +161,71 @@
145161
"test_case": "testGetJsonCheckCompare",
146162
"test_class": "GetJsonCheckCompare",
147163
"test_module": "oc_config_validate.testcases",
148-
"start_time_sec": 1681289915,
164+
"start_time_sec": 1755724165,
149165
"duration_sec": 0,
150166
"result": "PASS",
151167
"log": ""
152168
}
153169
]
154170
},
155171
{
156-
"test_name": "Bad model to compare System config",
172+
"test_name": "Replace System Config",
157173
"success": true,
174+
"duration_sec": 2,
175+
"results": [
176+
{
177+
"test_case": "testSetReplace",
178+
"test_class": "SetReplace",
179+
"test_module": "oc_config_validate.testcases",
180+
"start_time_sec": 1755724165,
181+
"duration_sec": 2,
182+
"result": "PASS",
183+
"log": ""
184+
}
185+
]
186+
},
187+
{
188+
"test_name": "FAIL Check System config - model",
189+
"success": false,
158190
"duration_sec": 0,
159191
"results": [
160192
{
161193
"test_case": "testGetJsonCheckCompare",
162194
"test_class": "GetJsonCheckCompare",
163195
"test_module": "oc_config_validate.testcases",
164-
"start_time_sec": 1681289915,
196+
"start_time_sec": 1755724167,
165197
"duration_sec": 0,
166-
"result": "PASS",
167-
"log": ""
198+
"result": "FAIL",
199+
"log": "\n Traceback (most recent call last):\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 55, in inner\n method(self, *args, **kw)\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testcases/get.py\", line 99, in testGetJsonCheckCompare\n self.assertModelXpath(self.model, self.xpath)\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 471, in assertModelXpath\n self.assertTrue(\nAssertionError: False is not true : xpath system/config does not point to a container in model interfaces.openconfig_interfaces: 'openconfig_interfaces' object has no attribute 'system'\n"
168200
}
169201
]
170202
},
171203
{
172-
"test_name": "Bad data to compare System config",
204+
"test_name": "FAIL Compare System config - data",
173205
"success": false,
174206
"duration_sec": 0,
175207
"results": [
176208
{
177209
"test_case": "testGetJsonCheckCompare",
178210
"test_class": "GetJsonCheckCompare",
179211
"test_module": "oc_config_validate.testcases",
180-
"start_time_sec": 1681289915,
212+
"start_time_sec": 1755724167,
181213
"duration_sec": 0,
182214
"result": "FAIL",
183-
"log": "\n Traceback (most recent call last):\n File \"/home/itamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 56, in inner\n method(self, *args, **kw)\n File \"/home/itamayo/gnxi/oc_config_validate/oc_config_validate/testcases/get.py\", line 108, in testGetJsonCheckCompare\n self.assertTrue(cmp, diff)\nAssertionError: False is not true : key openconfig-system:domain-name: got 'foo.bar.com', wanted 'la.la.la.com'\n"
215+
"log": "\n Traceback (most recent call last):\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 55, in inner\n method(self, *args, **kw)\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testcases/get.py\", line 108, in testGetJsonCheckCompare\n self.assertTrue(cmp, diff)\nAssertionError: False is not true : key openconfig-system:domain-name: got 'foo.bar.com', wanted 'la.la.la.com'\n"
184216
}
185217
]
186218
},
187219
{
188-
"test_name": "Set timezone with a valid Json blob",
220+
"test_name": "Update timezone with a valid Json blob",
189221
"success": true,
190222
"duration_sec": 2,
191223
"results": [
192224
{
193225
"test_case": "testJsonCheckSetUpdate",
194226
"test_class": "JsonCheckSetUpdate",
195227
"test_module": "oc_config_validate.testcases",
196-
"start_time_sec": 1681289915,
228+
"start_time_sec": 1755724167,
197229
"duration_sec": 2,
198230
"result": "PASS",
199231
"log": ""
@@ -203,69 +235,117 @@
203235
{
204236
"test_name": "Compare Timezone",
205237
"success": true,
206-
"duration_sec": 0,
238+
"duration_sec": 1,
207239
"results": [
208240
{
209241
"test_case": "testGetJsonCheckCompare",
210242
"test_class": "GetJsonCheckCompare",
211243
"test_module": "oc_config_validate.testcases",
212-
"start_time_sec": 1681289917,
213-
"duration_sec": 0,
244+
"start_time_sec": 1755724169,
245+
"duration_sec": 1,
214246
"result": "PASS",
215247
"log": ""
216248
}
217249
]
218250
},
219251
{
220-
"test_name": "Set timezone with a valid Json blob",
252+
"test_name": "Update timezone with a valid Json blob",
221253
"success": true,
222254
"duration_sec": 2,
223255
"results": [
224256
{
225257
"test_case": "testSetGetJsonCheck",
226258
"test_class": "SetGetJsonCheck",
227259
"test_module": "oc_config_validate.testcases",
228-
"start_time_sec": 1681289917,
260+
"start_time_sec": 1755724170,
229261
"duration_sec": 2,
230262
"result": "PASS",
231263
"log": ""
232264
}
233265
]
234266
},
235267
{
236-
"test_name": "Set timezone with a valid Json blob, and check it is Zurich",
268+
"test_name": "Update timezone with a valid Json blob, and check it is Zurich",
237269
"success": true,
238270
"duration_sec": 2,
239271
"results": [
240272
{
241273
"test_case": "testSetGetJsonCheckCompare",
242274
"test_class": "SetGetJsonCheckCompare",
243275
"test_module": "oc_config_validate.testcases",
244-
"start_time_sec": 1681289919,
276+
"start_time_sec": 1755724172,
245277
"duration_sec": 2,
246278
"result": "PASS",
247279
"log": ""
248280
}
249281
]
250282
},
251283
{
252-
"test_name": "Bad Set Clock Check State",
284+
"test_name": "FAIL Update Clock Check State",
253285
"success": false,
254286
"duration_sec": 2,
255287
"results": [
256288
{
257289
"test_case": "testSetConfigCheckState",
258290
"test_class": "SetConfigCheckState",
259291
"test_module": "oc_config_validate.testcases",
260-
"start_time_sec": 1681289921,
292+
"start_time_sec": 1755724174,
261293
"duration_sec": 2,
262294
"result": "FAIL",
263-
"log": "\n Traceback (most recent call last):\n File \"/home/itamayo/gnxi/oc_config_validate/oc_config_validate/testcases/config_state.py\", line 72, in testSetConfigCheckState\n self._get_check_retry()\n File \"/home/itamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 56, in inner\n method(self, *args, **kw)\n File \"/home/itamayo/gnxi/oc_config_validate/oc_config_validate/testcases/config_state.py\", line 64, in _get_check_retry\n self.assertTrue(cmp, diff)\nAssertionError: False is not true : key openconfig-system:timezone-name: got 'Europe/Stockholm', wanted 'Europe/Paris'\n"
295+
"log": "\n Traceback (most recent call last):\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testcases/config_state.py\", line 72, in testSetConfigCheckState\n self._get_check_retry()\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 55, in inner\n method(self, *args, **kw)\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testcases/config_state.py\", line 64, in _get_check_retry\n self.assertTrue(cmp, diff)\nAssertionError: False is not true : key openconfig-system:timezone-name: got 'Europe/Stockholm', wanted 'Europe/Paris'\n"
296+
}
297+
]
298+
},
299+
{
300+
"test_name": "FAIL Replace System Config - model",
301+
"success": false,
302+
"duration_sec": 0,
303+
"results": [
304+
{
305+
"test_case": "testJsonCheckSetReplace",
306+
"test_class": "JsonCheckSetReplace",
307+
"test_module": "oc_config_validate.testcases",
308+
"start_time_sec": 1755724176,
309+
"duration_sec": 0,
310+
"result": "FAIL",
311+
"log": "\n Traceback (most recent call last):\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testcases/set.py\", line 120, in testJsonCheckSetReplace\n self.assertJsonModel(json.dumps(self.json_value), model,\n File \"/home/joseignaciotamayo/gnxi/oc_config_validate/oc_config_validate/testbase.py\", line 427, in assertJsonModel\n self.assertTrue(match, \"%s: %s\" % (msg, error))\nAssertionError: False is not true : JSON to Set does not match the model: JSON object contained a key that did not exist (host)\n"
312+
}
313+
]
314+
},
315+
{
316+
"test_name": "Replace System Config",
317+
"success": true,
318+
"duration_sec": 2,
319+
"results": [
320+
{
321+
"test_case": "testSetGetJsonCheck",
322+
"test_class": "SetGetJsonCheck",
323+
"test_module": "oc_config_validate.testcases",
324+
"start_time_sec": 1755724176,
325+
"duration_sec": 2,
326+
"result": "PASS",
327+
"log": ""
328+
}
329+
]
330+
},
331+
{
332+
"test_name": "Replace and Get System Config",
333+
"success": true,
334+
"duration_sec": 2,
335+
"results": [
336+
{
337+
"test_case": "testSetGetJsonCheckCompare",
338+
"test_class": "SetGetJsonCheckCompare",
339+
"test_module": "oc_config_validate.testcases",
340+
"start_time_sec": 1755724178,
341+
"duration_sec": 2,
342+
"result": "PASS",
343+
"log": ""
264344
}
265345
]
266346
}
267347
],
268-
"tests_pass": 13,
269-
"tests_total": 16,
270-
"tests_fail": 3
348+
"tests_pass": 16,
349+
"tests_total": 21,
350+
"tests_fail": 5
271351
}

0 commit comments

Comments
 (0)