1 # ============LICENSE_START=======================================================
2 # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=========================================================
18 """test otihandler package of DCAE-Controller"""
29 # from urlparse import urlparse, parse_qsl
30 from datetime import datetime
34 from cherrypy.test import helper
36 from otihandler.config import Config
37 from otihandler.consul_client import (ConsulClient,
38 ConsulClientConnectionError, ConsulClientServiceNotFoundError,
39 ConsulClientKVEntryNotFoundError)
40 from otihandler.onap.audit import (Audit, AuditHttpCode)
41 from otihandler.__main__ import LogWriter
42 from otihandler.web_server import _DTIWeb
44 OTIHANDLER_VERSION = "1.0.0"
50 class Settings(object):
54 RUN_TS = datetime.utcnow().isoformat()[:-3] + 'Z'
55 discovered_config = None
61 os.environ["CLOUDIFY"] = '{"cloudify":{"protocol":"https","user":"XXXXX","password":"XXXX","address":"cloudify.bogus.com","port":"443"}}'
62 os.environ["CONSUL_URL"] = "http://consul:8500"
63 os.environ["OTI_HANDLER_URL"] = "https://oti_handler:8443"
65 Config.load_from_file()
67 with open("etc/config.json", 'r') as config_json:
68 Settings.discovered_config = json.load(config_json)
70 Config.load_from_file("etc/config.json")
72 Settings.logger = logging.getLogger("otihandler.unit_test")
73 sys.stdout = LogWriter(Settings.logger.info)
74 sys.stderr = LogWriter(Settings.logger.error)
76 print("print ========== run_otihandler ==========")
77 Settings.logger.info("========== run_otihandler ==========")
78 Audit.init(Config.get_system_name(), OTIHANDLER_VERSION, Config.LOGGER_CONFIG_FILE_PATH)
80 Settings.logger.info("starting otihandler with config:")
81 Settings.logger.info(Audit.log_json_dumps(Config.config))
86 class MonkeyHttpResponse(object):
87 """Monkey http response"""
89 def __init__(self, headers):
92 self.headers = headers or {}
94 class MonkeyRequestsResponse(object):
97 def __init__(self, full_path, res_json, json_body=None, headers=None, status_code=200):
100 self.full_path = full_path
101 self.req_json = json_body or {}
102 self.status_code = status_code
103 self.request = MonkeyHttpResponse(headers)
105 self.text = json.dumps(self.res)
108 """returns json of response"""
112 def raise_for_status(self):
115 if self.status_code == 200:
118 Settings.logger.warning("raise_for_status found status_code: {}".format(self.status_code))
120 def kv_encode(key, value):
121 """helper function to encode a consul key value"""
127 "Value": base64.b64encode(bytes(value, "utf-8")).decode("utf-8"),
133 def monkey_consul_client_get(full_path, **kwargs):
134 """monkeypatch for GET from consul"""
138 if full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "cloudify_manager"):
140 "ID": "048ec7c9-aa2e-bfad-34c7-6755e0007c9c",
141 "Node": "zldcdyh1adcc1orcl00.novalocal",
142 "Address": "192.168.1.13",
143 "Datacenter": "zldcdyh1adcc1",
145 "lan": "192.168.1.13",
146 "wan": "192.168.1.13"
149 "ServiceID": "cloudify_manager",
150 "ServiceName": "cloudify_manager",
152 "ServiceAddress": "1.1.1.1",
154 "ServiceEnableTagOverride": false,
155 "CreateIndex": 1569262,
156 "ModifyIndex": 1569262
158 rv = MonkeyRequestsResponse(full_path, res_json)
160 elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_handler"):
162 "ID": "476991b8-7f40-e3c2-9d5e-f936c2aeaf56",
163 "Node": "zldcdyh1adcc1dokr00",
164 "Address": "32.68.15.149",
165 "Datacenter": "zldcdyh1adcc1",
167 "lan": "32.68.15.149",
168 "wan": "32.68.15.149"
171 "fqdn": "oti_handler"
173 "ServiceID": "58a417002f89:oti_handler:8443",
174 "ServiceName": "oti_handler",
179 "ServiceAddress": "1.1.1.2",
181 "ServiceEnableTagOverride": false,
182 "CreateIndex": 1161355,
183 "ModifyIndex": 1161355
185 rv = MonkeyRequestsResponse(full_path, res_json)
187 elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "deployment_handler"):
189 "ID": "476991b8-7f40-e3c2-9d5e-f936c2aeaf56",
190 "Node": "zldcdyh1adcc1dokr00",
191 "Address": "32.68.15.149",
192 "Datacenter": "zldcdyh1adcc1",
194 "lan": "32.68.15.149",
195 "wan": "32.68.15.149"
198 "fqdn": "deployment_handler:8188"
200 "ServiceID": "58a417002f89:deployment_handler:8188",
201 "ServiceName": "deployment_handler",
203 "deployment_handler",
206 "ServiceAddress": "1.1.1.2",
208 "ServiceEnableTagOverride": false,
209 "CreateIndex": 1502800,
210 "ModifyIndex": 1502800
212 rv = MonkeyRequestsResponse(full_path, res_json)
214 elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "zldcdyh1adcc1-component-dockerhost-1"):
216 "ID": "4ffed53d-7601-7d47-df93-c091ea66fb45",
217 "Node": "zldcdyh1adcc1dokr02",
218 "Address": "32.68.15.163",
219 "Datacenter": "zldcdyh1adcc1",
221 "lan": "32.68.15.163",
222 "wan": "32.68.15.163"
225 "fqdn": "zldcdyh1adcc1dokr02.bogus.com"
227 "ServiceID": "zldcdyh1adcc1-component-dockerhost-1",
228 "ServiceName": "zldcdyh1adcc1-component-dockerhost-1",
233 "ServiceAddress": "1.1.1.5",
235 "ServiceEnableTagOverride": false,
236 "CreateIndex": 1704211,
237 "ModifyIndex": 1704211
239 rv = MonkeyRequestsResponse(full_path, res_json)
241 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), Config.get_system_name()):
242 res_json = copy.deepcopy(Settings.discovered_config)
243 rv = MonkeyRequestsResponse(full_path, res_json)
245 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "cloudify_manager"):
246 res_json = [kv_encode("cloudify_manager", json.dumps(
247 {"cloudify":{"protocol" : "http", "user": "admin", "password":"XXXX"}}
249 rv = MonkeyRequestsResponse(full_path, res_json)
251 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_2:oti"):
253 kv_encode("SCN_2:oti", json.dumps(
256 "another01ems003": {"dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_target_name": "another01ems003", "dcae_target_collection": "true", "event": {}, "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV"}
261 rv = MonkeyRequestsResponse(full_path, res_json)
263 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "docker_plugin/docker_logins"):
265 kv_encode("docker_plugin/docker_logins", json.dumps(
266 [{"username": "fake_user", "password": "fake_password",
267 "registry": "registry.bogus.com:5100" }]
270 rv = MonkeyRequestsResponse(full_path, res_json)
272 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/") \
273 or full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/"):
275 kv_encode("oti_events/anot-her/another01ems003", json.dumps(
276 {"dcae_service_location": "LSLEILAA",
277 "dcae_target_type": "ANOT-her",
278 "dcae_service_action": "deploy",
279 "dcae_service-instance_model-version-id": "1",
280 "dcae_target_collection_ip": "107.239.85.3",
281 "dcae_target_is-closed-loop-disabled": "false",
282 "dcae_target_in-maint": "false",
283 "dcae_target_name": "another01ems003",
284 "dcae_target_collection": "true",
286 "dcae_snmp_version": "2c",
287 "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
288 "dcae_snmp_community_string": "my_first_community",
289 "dcae_generic-vnf_model-version-id": "1",
290 "dcae_target_prov-status": "PROV"
293 kv_encode("oti_events/anot-her/another01ems042", json.dumps(
294 {"dcae_service_location": "LSLEILAA",
295 "dcae_target_type": "ANOT-her",
296 "dcae_service_action": "deploy",
297 "dcae_service-instance_model-version-id": "1",
298 "dcae_target_collection_ip": "107.239.85.42",
299 "dcae_target_is-closed-loop-disabled": "false",
300 "dcae_target_in-maint": "false",
301 "dcae_target_name": "another01ems042",
302 "dcae_target_collection": "true",
304 "dcae_snmp_version": "2c",
305 "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
306 "dcae_snmp_community_string": "my_first_community",
307 "dcae_generic-vnf_model-version-id": "1",
308 "dcae_target_prov-status": "PROV"
311 kv_encode("oti_events/anot-her/another01ems044", json.dumps(
312 {"dcae_service_location": "MDTWNJC1",
313 "dcae_target_type": "ANOT-her",
314 "dcae_service_action": "deploy",
315 "dcae_service-instance_model-version-id": "1",
316 "dcae_target_collection_ip": "107.239.85.42",
317 "dcae_target_is-closed-loop-disabled": "false",
318 "dcae_target_in-maint": "false",
319 "dcae_target_name": "another01ems044",
320 "dcae_target_collection": "true",
322 "dcae_snmp_version": "2c",
323 "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
324 "dcae_snmp_community_string": "my_first_community",
325 "dcae_generic-vnf_model-version-id": "1",
326 "dcae_target_prov-status": "PROV"
330 rv = MonkeyRequestsResponse(full_path, res_json)
332 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/birth-day/"):
334 kv_encode("oti_events/birth-day/birthdy01ems055", json.dumps(
335 {"dcae_service_location": "LSLEILAA",
336 "dcae_target_type": "birth-day",
337 "dcae_service_action": "deploy",
338 "dcae_service-instance_model-version-id": "1",
339 "dcae_target_collection_ip": "107.239.85.3",
340 "dcae_target_is-closed-loop-disabled": "false",
341 "dcae_target_in-maint": "false",
342 "dcae_target_name": "birthdy01ems055",
343 "dcae_target_collection": "true",
345 "dcae_snmp_version": "2c",
346 "aai_additional_info": {"TasksItems": {"birthdy01ems055_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "birthdy01ems055"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
347 "dcae_snmp_community_string": "my_first_community",
348 "dcae_generic-vnf_model-version-id": "1",
349 "dcae_target_prov-status": "PROV"
355 rv = MonkeyRequestsResponse(full_path, res_json)
357 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/new-type/"):
359 kv_encode("oti_events/new-type/newtype01ems084", json.dumps(
360 {"dcae_service_location": "LSLEILAA",
361 "dcae_target_type": "new-type",
362 "dcae_service_action": "deploy",
363 "dcae_service-instance_model-version-id": "1",
364 "dcae_target_collection_ip": "107.239.85.3",
365 "dcae_target_is-closed-loop-disabled": "false",
366 "dcae_target_in-maint": "false",
367 "dcae_target_name": "newtype01ems084",
368 "dcae_target_collection": "true",
370 "dcae_snmp_version": "2c",
371 "aai_additional_info": {"TasksItems": {"newtype01ems084_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "newtype01ems084"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
372 "dcae_snmp_community_string": "my_first_community",
373 "dcae_generic-vnf_model-version-id": "1",
374 "dcae_target_prov-status": "PROV"
380 rv = MonkeyRequestsResponse(full_path, res_json)
382 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/pcrf-oam/"):
384 kv_encode("oti_events/pcrf-oam/pcrfoam01ems009", json.dumps(
385 {"dcae_service_location": "LSLEILAA",
386 "dcae_target_type": "pcrf-oam",
387 "dcae_service_action": "deploy",
388 "dcae_service-instance_model-version-id": "1",
389 "dcae_target_collection_ip": "107.239.85.3",
390 "dcae_target_is-closed-loop-disabled": "false",
391 "dcae_target_in-maint": "false",
392 "dcae_target_name": "pcrfoam01ems009",
393 "dcae_target_collection": "true",
395 "dcae_snmp_version": "2c",
396 "aai_additional_info": {"TasksItems": {"pcrfoam01ems009_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "pcrfoam01ems009"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
397 "dcae_snmp_community_string": "my_first_community",
398 "dcae_generic-vnf_model-version-id": "1",
399 "dcae_target_prov-status": "PROV"
405 rv = MonkeyRequestsResponse(full_path, res_json)
407 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/pnga-xxx/"):
409 kv_encode("oti_events/pnga-xxx/pngaxxx01ems007", json.dumps(
410 {"dcae_service_location": "LSLEILAA",
411 "dcae_target_type": "pnga-xxx",
412 "dcae_service_action": "deploy",
413 "dcae_service-instance_model-version-id": "1",
414 "dcae_target_collection_ip": "107.239.85.3",
415 "dcae_target_is-closed-loop-disabled": "false",
416 "dcae_target_in-maint": "false",
417 "dcae_target_name": "pngaxxx01ems007",
418 "dcae_target_collection": "true",
420 "dcae_snmp_version": "2c",
421 "aai_additional_info": {"TasksItems": {"pngaxxx01ems007_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "pngaxxx01ems007"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
422 "dcae_snmp_community_string": "my_first_community",
423 "dcae_generic-vnf_model-version-id": "1",
424 "dcae_target_prov-status": "PROV"
430 rv = MonkeyRequestsResponse(full_path, res_json)
432 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/vhss-ems/"):
434 kv_encode("oti_events/vhss-ems/vhssems01ems019", json.dumps(
435 {"dcae_service_location": "LSLEILAA",
436 "dcae_target_type": "vhss-ems",
437 "dcae_service_action": "deploy",
438 "dcae_service-instance_model-version-id": "1",
439 "dcae_target_collection_ip": "107.239.85.3",
440 "dcae_target_is-closed-loop-disabled": "false",
441 "dcae_target_in-maint": "false",
442 "dcae_target_name": "vhssems01ems019",
443 "dcae_target_collection": "true",
445 "dcae_snmp_version": "2c",
446 "aai_additional_info": {"TasksItems": {"vhssems01ems019_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "vhssems01ems019"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
447 "dcae_snmp_community_string": "my_first_community",
448 "dcae_generic-vnf_model-version-id": "1",
449 "dcae_target_prov-status": "PROV"
455 rv = MonkeyRequestsResponse(full_path, res_json)
457 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/another01ems003"):
459 kv_encode("oti_events/anot-her/another01ems003", json.dumps(
460 {"dcae_service_location": "LSLEILAA",
461 "dcae_target_type": "ANOT-her",
462 "dcae_service_action": "deploy",
463 "dcae_service-instance_model-version-id": "1",
464 "dcae_target_collection_ip": "107.239.85.3",
465 "dcae_target_is-closed-loop-disabled": "false",
466 "dcae_target_in-maint": "false",
467 "dcae_target_name": "another01ems003",
468 "dcae_target_collection": "true",
470 "dcae_snmp_version": "2c",
471 "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
472 "dcae_snmp_community_string": "my_first_community",
473 "dcae_generic-vnf_model-version-id": "1",
474 "dcae_target_prov-status": "PROV"
478 rv = MonkeyRequestsResponse(full_path, res_json)
480 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/another01ems042"):
482 kv_encode("oti_events/anot-her/another01ems042", json.dumps(
483 {"dcae_service_location": "LSLEILAA",
484 "dcae_target_type": "ANOT-her",
485 "dcae_service_action": "deploy",
486 "dcae_service-instance_model-version-id": "1",
487 "dcae_target_collection_ip": "107.239.85.42",
488 "dcae_target_is-closed-loop-disabled": "false",
489 "dcae_target_in-maint": "false",
490 "dcae_target_name": "another01ems042",
491 "dcae_target_collection": "true",
493 "dcae_snmp_version": "2c",
494 "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
495 "dcae_snmp_community_string": "my_first_community",
496 "dcae_generic-vnf_model-version-id": "1",
497 "dcae_target_prov-status": "PROV"
501 rv = MonkeyRequestsResponse(full_path, res_json)
503 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/another01ems044"):
505 kv_encode("oti_events/anot-her/another01ems044", json.dumps(
506 {"dcae_service_location": "MDTWNJC1",
507 "dcae_target_type": "ANOT-her",
508 "dcae_service_action": "deploy",
509 "dcae_service-instance_model-version-id": "1",
510 "dcae_target_collection_ip": "107.239.85.42",
511 "dcae_target_is-closed-loop-disabled": "false",
512 "dcae_target_in-maint": "false",
513 "dcae_target_name": "another01ems044",
514 "dcae_target_collection": "true",
516 "dcae_snmp_version": "2c",
517 "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044"}]}}, "protocol": "sftp", "collectionInterval": "300"}}},
518 "dcae_snmp_community_string": "my_first_community",
519 "dcae_generic-vnf_model-version-id": "1",
520 "dcae_target_prov-status": "PROV"
524 rv = MonkeyRequestsResponse(full_path, res_json)
526 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1"):
528 kv_encode("SCN_1", json.dumps(
529 {"dcae_target_type": ["pnga-xxx"]}
532 rv = MonkeyRequestsResponse(full_path, res_json)
534 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:oti"):
536 kv_encode("SCN_1:oti", json.dumps(
537 {"new-type": {}, "pnga-xxx": {}, "birth-day": {}, "anot-her": {}, "vhss-ems": {}, "pcrf-oam": {}}
540 rv = MonkeyRequestsResponse(full_path, res_json)
542 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:dmaap"):
544 kv_encode("SCN_1:dmaap", json.dumps(
546 "topic_url": "https://dcae-mrtr.bogus.com:3005/events/com.bogus.HelloWorld-PubTopic",
547 "client_role": "com.bogus.member",
549 "client_id": "1575649224792"
552 "topic_url": "https://dcae-mrtr.bogus.com:3005/events/com.bogus.HelloWorld-PubTopic",
553 "client_role": "com.bogus.member",
555 "client_id": "1575649221094"
560 rv = MonkeyRequestsResponse(full_path, res_json)
562 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:rel"):
564 kv_encode("SCN_1:rel", json.dumps(
565 {"who-knows", "what this content might look like?"}
568 rv = MonkeyRequestsResponse(full_path, res_json)
570 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1"):
572 kv_encode("SCN_1", json.dumps(
573 {"dcae_target_type": ["pnga-xxx"]}
575 kv_encode("SCN_1:oti", json.dumps(
576 {"new-type": {}, "pnga-xxx": {}, "birth-day": {}, "anot-her": {}, "vhss-ems": {}, "pcrf-oam": {}}
578 kv_encode("SCN_1:policies/event", json.dumps(
579 {"action": "updated", "timestamp": "2018-07-16T15:11:44.845Z", "update_id": "e6102aab-3079-435a-ae0d-0397a2cb3c4d", "policies_count": 3}
581 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors", json.dumps(
582 {"policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "type": "JSON", "property": null, "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "package_type": "plastic", "polling_frequency": "30m"}, "policyVersion": "1"}
584 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific", json.dumps(
585 {"policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "type": "JSON", "property": null, "config": {"conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy", "preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel"}, "policyVersion": "5"}
587 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_In_Service", json.dumps(
588 {"policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "type": "JSON", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyVersion": "1"}
591 rv = MonkeyRequestsResponse(full_path, res_json)
593 elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/"):
595 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors", json.dumps(
596 {"policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "type": "JSON", "property": null, "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "package_type": "plastic", "polling_frequency": "30m"}, "policyVersion": "1"}
598 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific", json.dumps(
599 {"policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "type": "JSON", "property": null, "config": {"conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy", "preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel"}, "policyVersion": "5"}
601 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_In_Service", json.dumps(
602 {"policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "type": "JSON", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyVersion": "1"}
605 rv = MonkeyRequestsResponse(full_path, res_json)
607 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors"):
609 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors", json.dumps(
610 {"policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "type": "JSON", "property": null, "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "package_type": "plastic", "polling_frequency": "30m"}, "policyVersion": "1"}
613 rv = MonkeyRequestsResponse(full_path, res_json)
615 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific"):
617 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific", json.dumps(
618 {"policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "type": "JSON", "property": null, "config": {"conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy", "preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel"}, "policyVersion": "5"}
621 rv = MonkeyRequestsResponse(full_path, res_json)
623 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/DCAE_FTL3B.Config_In_Service"):
625 kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_In_Service", json.dumps(
626 {"policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "type": "JSON", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyVersion": "1"}
629 rv = MonkeyRequestsResponse(full_path, res_json)
631 elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "bogus:oti"):
633 rv = MonkeyRequestsResponse(full_path, res_json)
635 elif full_path == "{}/v1/catalog/services".format(os.environ.get("CONSUL_URL").rstrip("/")):
639 "cloudify_manager": [],
640 "config_binding_service": [],
643 "deployment_handler": [
646 "dmaap_bus_controller": [],
651 "http_dmaap_bus_controller_api": [],
652 "https_dmaap_bus_controller_api": [],
665 "service-change-handler": [
666 "service-change-handler"
668 "zldcdyh1adcc1-component-dockerhost-1": [
672 "zldcdyh1adcc1-component-dockerhost-2": [
676 "zldcdyh1adcc1-component-dockerhost-3": [
680 "zldcdyh1adcc1-component-dockerhost-4": [
684 "zldcdyh1adcc1-platform-dockerhost-1": [
688 "zldcdyh1adcc1-platform-dockerhost-2": [
692 "zldcdyh1adce1-component-dockerhost-1": [
696 "zldcdyh1adce1-component-dockerhost-2": [
700 "zldcdyh1adce1-component-dockerhost-3": [
704 "zldcdyh1adce1-component-dockerhost-4": [
708 "zldcdyh1adce1-platform-dockerhost-1": [
712 "zldcdyh1adce1-platform-dockerhost-2": [
717 rv = MonkeyRequestsResponse(full_path, res_json)
719 elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1"):
722 "ID": "966d0ef5-7ca2-1b25-d587-2f0541a6ef78",
724 "Address": "10.1.14.15",
725 "Datacenter": "zldcdyh1adcc1",
731 "consul-network-segment": "",
732 "fqdn": "kpma00.897658.bogus.com"
735 "ServiceID": "scn-1-service-301",
736 "ServiceName": "scn-1-service",
738 "com-bogus-dcae-controller"
740 "ServiceAddress": "scn-1.bogus.com",
749 "ServiceEnableTagOverride": false,
750 "ServiceProxyDestination": "",
752 "ServiceConnect": {},
753 "CreateIndex": 30535167,
754 "ModifyIndex": 30535167
757 rv = MonkeyRequestsResponse(full_path, res_json)
759 elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "bogus"):
762 rv = MonkeyRequestsResponse(full_path, res_json)
764 elif full_path == "{}/v1/catalog/node/node_1".format(os.environ.get("CONSUL_URL").rstrip("/")):
767 "ID": "966d0ef5-7ca2-1b25-d587-2f0541a6ef78",
769 "Address": "10.1.14.15",
770 "Datacenter": "zldcdyh1adcc1",
776 "consul-network-segment": "",
777 "fqdn": "kpma00.897658.bogus.com"
779 "CreateIndex": 28443495,
780 "ModifyIndex": 28443495
787 "com-bogus-controller-mgmt"
789 "Address": "apple.bogus.com",
798 "EnableTagOverride": false,
799 "ProxyDestination": "",
802 "CreateIndex": 28598335,
803 "ModifyIndex": 28598335
805 "banana-service-301": {
806 "ID": "banana-service-301",
807 "Service": "banana-service",
809 "com-bogus-controller-dev"
811 "Address": "banana.bogus.com",
820 "EnableTagOverride": false,
821 "ProxyDestination": "",
824 "CreateIndex": 30535167,
825 "ModifyIndex": 30535167
827 "d3_kp_platform_kubernetes_master": {
828 "ID": "d3_kp_platform_kubernetes_master",
829 "Service": "d3_kp_platform_kubernetes_master",
833 "Address": "10.1.14.15",
840 "EnableTagOverride": false,
841 "ProxyDestination": "",
844 "CreateIndex": 28443495,
845 "ModifyIndex": 28443495
849 rv = MonkeyRequestsResponse(full_path, res_json)
852 Settings.logger.error("monkey_consul_client_get had no mock for {}".format(full_path))
854 rv = MonkeyRequestsResponse(full_path, res_json, status_code=404)
858 def monkey_consul_client_put(full_path, **kwargs):
859 """monkeypatch for PUT from consul"""
861 Settings.logger.info("monkey_consul_client called with full_path={}, kwargs={}".format(full_path, kwargs))
864 if full_path == ConsulClient.CONSUL_TRANSACTION_URL.format(os.environ.get("CONSUL_URL").rstrip("/")):
867 Settings.logger.info("monkey_consul_client called with txn={}".format(str(kwargs.get('json'))))
868 txn = kwargs.get('json')[0]
874 "Key": txn.get('Key'),
877 "CreateIndex": 99999,
887 if KV and KV.get('Verb') == 'delete' and KV.get('Key') == 'oti_events/anot-her/bogus':
889 r_dict["Errors"].append({
891 "What": "That KV does not exist."
893 res_json = [ r_dict ]
894 Settings.logger.info("monkey_consul_client produced res_json={} with status_code={}".format(json.dumps(res_json), status_code))
895 rv = MonkeyRequestsResponse(full_path, res_json, status_code=status_code)
897 elif full_path.startswith(ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), '')): # wants to write
898 # parse_url = urlparse(url)
899 # query_dict = dict(parse_qsl(parse_url.query))
902 Settings.logger.info("monkey_consul_client produced res_json={}".format(json.dumps(res_json)))
903 rv = MonkeyRequestsResponse(full_path, res_json)
906 Settings.logger.error("monkey_consul_client_put had no mock for {}".format(full_path))
910 class MonkeyCloudifyNode(object):
911 """fake cloudify node_instance"""
913 def __init__(self, **kwargs):
916 self.runtime_properties = kwargs.get('runtime_properties', {})
917 self.deployment_id = kwargs.get('deployment_id')
918 self.node_id = kwargs.get('node_id')
919 self.id = kwargs.get('id')
920 self.state = kwargs.get('state')
922 class MonkeyCloudifyClient(object):
923 """monkeypatch for CloudifyClient"""
925 def __init__(self, **kwargs):
928 Settings.logger.info("MonkeyCloudifyClient called with kwargs={}".format(json.dumps(kwargs)))
929 self._host = kwargs.get('host')
930 self._port = kwargs.get('port')
931 self._protocol = kwargs.get('protocol')
932 self._headers = kwargs.get('headers')
934 self.node_instances = self
936 def list(self, **kwargs):
937 """list node_instances"""
939 Settings.logger.info("MonkeyCloudifyClient.list() called with kwargs={}".format(json.dumps(kwargs)))
941 deployment_id = kwargs.get('deployment_id')
942 sort_field = kwargs.get('_sort')
943 if deployment_id or sort_field:
947 "container_id": "container_1",
948 "dti_reconfig_script": "dti_reconfig_script_1",
951 "dti": "dti_reconfig_script_1",
952 "app": "app_reconfig_script_1",
953 "special": "special_reconfig_script_1"
956 "service_component_name": "SCN_1",
957 "selected_container_destination": "zldcdyh1adcc1-component-dockerhost-1",
958 "service_component_type": "SCType_1"
960 deployment_id = 'deployment_id_1',
961 node_id = 'node_id_1',
967 "container_id": "container_2",
968 "dti_reconfig_script": "dti_reconfig_script_2",
971 "dti": "dti_reconfig_script_2",
972 "app": "app_reconfig_script_2",
973 "special": "special_reconfig_script_2"
976 "service_component_name": "SCN_2",
977 "selected_container_destination": "zldcdyh1adcc1-component-dockerhost-1",
978 "service_component_type": "SCType_2"
980 deployment_id = 'deployment_id_2',
981 node_id = 'node_id_2',
989 class MonkeyEventDbAccess(object):
990 """monkdypatch for otihandler.dbclient.apis.EventDbAccess()"""
992 def __init__(self, **kwargs):
994 Settings.logger.info("MonkeyEventDbAccess called with kwargs={}".format(json.dumps(kwargs)))
996 def saveDomainObject(self, obj):
999 def deleteDomainObject(self, obj):
1002 def query_event_item(self, target_type, target_name):
1003 Settings.logger.info("MonkeyEventDbAccess.query_event_item({}, {})".format(target_type, target_name))
1006 def query_event_data(self, target_type, target_name):
1007 Settings.logger.info("MonkeyEventDbAccess.query_event_data({}, {})".format(target_type, target_name))
1010 def query_event_data_k8s(self, target_type, target_name):
1011 Settings.logger.info("MonkeyEventDbAccess.query_event_data_k8s({}, {})".format(target_type, target_name))
1014 def query_event_info_docker(self, curr_evt, component_scn, deployment_id, container_id):
1015 Settings.logger.info("MonkeyEventDbAccess.query_event_info_docker({}, {}, {}, {})".format(curr_evt, component_scn, deployment_id, container_id))
1018 def update_event_item(self, event, target_type, target_name):
1019 Settings.logger.info("MonkeyEventDbAccess.update_event_item({}, {}, {})".format(event, target_type, target_name))
1022 def query_raw_k8_events(self, cluster, pod, namespace):
1023 Settings.logger.info("MonkeyEventDbAccess.query_raw_k8_events({}, {}, {})".format(cluster, pod, namespace))
1026 def query_raw_docker_events(self, target_types, locations):
1027 Settings.logger.info("MonkeyEventDbAccess.query_raw_docker_events({}, {})".format(target_types, locations))
1030 def query_event_data_k8s_pod(self, curr_evt, component_scn):
1031 Settings.logger.info("MonkeyEventDbAccess.query_event_k8s_pod({}, {})".format(curr_evt, component_scn))
1034 class MonkeyDockerClient(object):
1035 """monkeypatch for docker.APIClient()"""
1037 def __init__(self, **kwargs):
1040 Settings.logger.info("MonkeyDockerClient called with kwargs={}".format(json.dumps(kwargs)))
1041 self._base_url = kwargs.get('base_url')
1042 self._timeout = kwargs.get('timeout')
1044 def exec_create(self, **kwargs):
1045 """monkey exec_create"""
1047 return {"Id": "fake_container_ID"}
1049 def exec_start(self, **kwargs):
1050 """monkey exec_create"""
1052 return "component reconfigured successfully"
1054 def login(self, **kwargs):
1060 def fix_external_interfaces(monkeypatch):
1061 """monkey consul_client request.get"""
1063 Settings.logger.info("setup fix_external_interfaces")
1064 monkeypatch.setattr('otihandler.consul_client.requests.get', monkey_consul_client_get)
1065 monkeypatch.setattr('otihandler.consul_client.requests.put', monkey_consul_client_put)
1067 monkeypatch.setattr('otihandler.cfy_client.CloudifyClient', MonkeyCloudifyClient)
1069 monkeypatch.setattr('otihandler.docker_client.docker.APIClient', MonkeyDockerClient)
1071 monkeypatch.setattr('otihandler.dti_processor.EventDbAccess', MonkeyEventDbAccess)
1073 yield fix_external_interfaces # provide the fixture value
1074 Settings.logger.info("teardown fix_external_interfaces")
1077 def monkey_cherrypy_engine_exit():
1078 """monkeypatch for cherrypy exit"""
1080 Settings.logger.info("monkey_cherrypy_engine_exit()")
1083 def fix_cherrypy_engine_exit(monkeypatch):
1084 """monkey cherrypy.engine.exit()"""
1086 Settings.logger.info("setup fix_cherrypy_engine_exit")
1087 monkeypatch.setattr('otihandler.web_server.cherrypy.engine.exit',
1088 monkey_cherrypy_engine_exit)
1089 yield fix_cherrypy_engine_exit # provide the fixture value
1090 Settings.logger.info("teardown fix_cherrypy_engine_exit")
1093 #----- Tests ----------------------------------------------------------------------------
1095 def test_healthcheck():
1096 """test /healthcheck"""
1098 Settings.logger.info("=====> test_healthcheck")
1099 audit = Audit(req_message="get /healthcheck")
1100 audit.metrics_start("test /healthcheck")
1103 audit.metrics("test /healthcheck")
1104 health = Audit.health() or {}
1105 audit.audit_done(result=json.dumps(health))
1107 Settings.logger.info("healthcheck: %s", json.dumps(health))
1110 def test_healthcheck_with_error():
1111 """test /healthcheck"""
1113 Settings.logger.info("=====> test_healthcheck_with_error")
1114 audit = Audit(req_message="get /healthcheck")
1115 audit.metrics_start("test /healthcheck")
1117 audit.error("error from test_healthcheck_with_error")
1118 audit.fatal("fatal from test_healthcheck_with_error")
1119 audit.debug("debug from test_healthcheck_with_error")
1120 audit.warn("warn from test_healthcheck_with_error")
1121 audit.info_requested("info_requested from test_healthcheck_with_error")
1122 if audit.is_success():
1123 audit.set_http_status_code(AuditHttpCode.DATA_NOT_FOUND_ERROR.value)
1124 audit.set_http_status_code(AuditHttpCode.SERVER_INTERNAL_ERROR.value)
1125 audit.metrics("test /healthcheck")
1127 health = Audit.health() or {}
1128 audit.audit_done(result=json.dumps(health))
1130 Settings.logger.info("healthcheck: %s", json.dumps(health))
1133 def test_consul_client_lookup_service_bogus():
1134 """test consul_client.lookup_service with bogus service_name"""
1136 Settings.logger.info("=====> test_consul_client_lookup_service_bogus")
1137 with pytest.raises(ConsulClientConnectionError, match=r'lookup_service(.*) requests.get(.*)'):
1138 ConsulClient.lookup_service("bogus")
1140 def test_consul_client_get_service_fqdn_port_none():
1141 """test consul_client.get_service_fqdn_port with no service_name"""
1143 Settings.logger.info("=====> test_consul_client_get_service_fqdn_port_none")
1144 with pytest.raises(ConsulClientConnectionError):
1145 rv = ConsulClient.get_service_fqdn_port(None)
1148 def test_consul_client_store_kvs_none():
1149 """test consul_client.store_kvs with no key"""
1151 Settings.logger.info("=====> test_consul_client_store_kvs_none")
1152 rv = ConsulClient.store_kvs(None)
1155 def test_consul_client_delete_key_none():
1156 """test consul_client.delete_key with no key"""
1158 Settings.logger.info("=====> test_consul_client_delete_key_none")
1159 rv = ConsulClient.delete_key(None)
1162 def test_consul_client_delete_kvs_none():
1163 """test consul_client.delete_kvs with no key"""
1165 Settings.logger.info("=====> test_consul_client_delete_kvs_none")
1166 rv = ConsulClient.delete_kvs(None)
1169 def test_consul_client_delete_kvs_bogus():
1170 """test consul_client.delete_kvs with bogus key"""
1172 Settings.logger.info("=====> test_consul_client_delete_kvs_bogus")
1173 rv = ConsulClient.delete_kvs("bogus")
1176 def test_consul_client_get_value_none():
1177 """test consul_client.get_value with no key"""
1179 Settings.logger.info("=====> test_consul_client_get_value_none")
1180 with pytest.raises(ConsulClientConnectionError, match=r'get_value(.*) requests.get(.*)'):
1181 ConsulClient.get_value(None)
1183 def test_consul_client_get_kvs_none():
1184 """test consul_client.get_kvs with no prefix"""
1186 Settings.logger.info("=====> test_consul_client_get_kvs_none")
1187 with pytest.raises(ConsulClientConnectionError, match=r'get_kvs(.*) requests.get(.*)'):
1188 ConsulClient.get_kvs(None)
1190 def test_consul_client_run_transaction_invalid():
1191 """test consul_client._run_transaction with invalid operation"""
1193 Settings.logger.info("=====> test_consul_client_run_transaction_invalid")
1194 rv = ConsulClient._run_transaction("invalid", {"bogus": "bad"})
1197 class TestsBase(helper.CPWebCase):
1199 helper.CPWebCase.interactive = False
1201 @pytest.mark.usefixtures("fix_external_interfaces")
1202 class WebServerTest(TestsBase):
1203 """testing the web-server - runs tests in alphabetical order of method names"""
1206 """setup the web-server"""
1208 cherrypy.tree.mount(_DTIWeb(), '/')
1210 setup_server = staticmethod(setup_server)
1212 def test_web_healthcheck(self):
1213 """test /healthcheck"""
1215 Settings.logger.info("=====> test_web_healthcheck")
1216 result = self.getPage("/healthcheck")
1217 Settings.logger.info("got healthcheck: %s", self.body)
1218 self.assertStatus('200 OK')
1220 def test_web_events_get(self):
1221 """test GET /events -- wrong method"""
1223 Settings.logger.info("=====> test_web_events_get")
1224 result = self.getPage("/events")
1225 self.assertStatus(404)
1227 def test_web_events_missing_dcae_service_action(self):
1228 """test POST /events < <dti_event>"""
1230 Settings.logger.info("=====> test_web_events_missing_dcae_service_action")
1231 body = json.dumps({})
1232 expected_result = {"ERROR": "dcae_service_action is missing"}
1233 result = self.getPage("/events", method='POST', body=body,
1235 ("Content-Type", "application/json"),
1236 ('Content-Length', str(len(body)))
1238 self.assertStatus('400 Bad Request')
1239 assert ( json.loads(self.body) == expected_result )
1241 def test_web_events_invalid_dcae_service_action(self):
1242 """test POST /events < <dti_event>"""
1244 Settings.logger.info("=====> test_web_events_invalid_dcae_service_action")
1245 body = json.dumps({"dcae_service_action": "bogus"})
1246 expected_result = {"ERROR": "dcae_service_action is invalid"}
1247 result = self.getPage("/events", method='POST', body=body,
1249 ("Content-Type", "application/json"),
1250 ('Content-Length', str(len(body)))
1252 self.assertStatus('400 Bad Request')
1253 assert ( json.loads(self.body) == expected_result )
1255 def test_web_events_missing_dcae_target_name(self):
1256 """test POST /events < <dti_event>"""
1258 Settings.logger.info("=====> test_web_events_missing_dcae_target_name")
1259 body = json.dumps({"dcae_service_action": "deploy"})
1260 expected_result = {"ERROR": "dcae_target_name is missing"}
1261 result = self.getPage("/events", method='POST', body=body,
1263 ("Content-Type", "application/json"),
1264 ('Content-Length', str(len(body)))
1266 self.assertStatus('400 Bad Request')
1267 assert ( json.loads(self.body) == expected_result )
1269 def test_web_events_missing_dcae_target_type(self):
1270 """test POST /events < <dti_event>"""
1272 Settings.logger.info("=====> test_web_events_missing_dcae_target_type")
1273 body = json.dumps({"dcae_service_action": "deploy",
1274 "dcae_target_name": "another01ems003"
1276 expected_result = {"ERROR": "dcae_target_type is missing"}
1277 result = self.getPage("/events", method='POST', body=body,
1279 ("Content-Type", "application/json"),
1280 ('Content-Length', str(len(body)))
1282 self.assertStatus('400 Bad Request')
1283 assert ( json.loads(self.body) == expected_result )
1285 def test_web_events_deploy(self):
1286 """test POST /events < <dti_event>"""
1288 Settings.logger.info("=====> test_web_events_deploy")
1289 body = json.dumps({"dcae_service_action": "deploy",
1290 "dcae_target_name": "another01ems003",
1291 "dcae_target_type": "ANOT-her"
1294 "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully",
1295 "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully"
1299 result = self.getPage("/events", method='POST', body=body,
1301 ("Content-Type", "application/json"),
1302 ('Content-Length', str(len(body)))
1304 self.assertStatus('200 OK')
1305 assert ( json.loads(self.body) == expected_result )
1307 def test_web_events_undeploy(self):
1308 """test POST /events < <dti_event>"""
1310 Settings.logger.info("=====> test_web_events_undeploy")
1311 body = json.dumps({"dcae_service_action": "undeploy",
1312 "dcae_target_name": "another01ems003",
1313 "dcae_target_type": "ANOT-her"
1317 result = self.getPage("/events", method='POST', body=body,
1319 ("Content-Type", "application/json"),
1320 ('Content-Length', str(len(body)))
1322 self.assertStatus('200 OK')
1323 assert ( json.loads(self.body) == expected_result )
1325 def test_web_events_add(self):
1326 """test POST /events < <dti_event>"""
1328 Settings.logger.info("=====> test_web_events_add")
1329 body = json.dumps({"dcae_service_action": "add",
1330 "dcae_target_name": "another01ems003",
1331 "dcae_target_type": "ANOT-her"
1334 "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully",
1335 "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully"
1337 result = self.getPage("/events", method='POST', body=body,
1339 ("Content-Type", "application/json"),
1340 ('Content-Length', str(len(body)))
1342 self.assertStatus('200 OK')
1343 assert ( json.loads(self.body) == expected_result )
1345 def test_web_events_delete(self):
1346 """test POST /events < <dti_event>"""
1348 Settings.logger.info("=====> test_web_events_delete")
1349 body = json.dumps({"dcae_service_action": "delete",
1350 "dcae_target_name": "another01ems003",
1351 "dcae_target_type": "ANOT-her"
1354 "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully",
1355 "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully"
1357 result = self.getPage("/events", method='POST', body=body,
1359 ("Content-Type", "application/json"),
1360 ('Content-Length', str(len(body)))
1362 self.assertStatus('200 OK')
1363 assert ( json.loads(self.body) == expected_result )
1365 def test_web_events_update(self):
1366 """test POST /events < <dti_event>"""
1368 Settings.logger.info("=====> test_web_events_update")
1369 body = json.dumps({"dcae_service_action": "update",
1370 "dcae_target_name": "another01ems003",
1371 "dcae_target_type": "ANOT-her"
1374 "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully",
1375 "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully",
1376 "WARNING": "processing update event for anot-her/another01ems003, but current event info is not found in database, executing add event"
1378 result = self.getPage("/events", method='POST', body=body,
1380 ("Content-Type", "application/json"),
1381 ('Content-Length', str(len(body)))
1383 self.assertStatus('200 OK')
1384 assert ( json.loads(self.body) == expected_result )
1386 def test_web_events_notify(self):
1387 """test POST /events < <dti_event>"""
1389 Settings.logger.info("=====> test_web_events_notify")
1390 body = json.dumps({"dcae_service_action": "notify",
1391 "dcae_target_name": "another01ems003",
1392 "dcae_target_type": "ANOT-her"
1396 result = self.getPage("/events", method='POST', body=body,
1398 ("Content-Type", "application/json"),
1399 ('Content-Length', str(len(body)))
1401 self.assertStatus('200 OK')
1402 assert ( json.loads(self.body) == expected_result )
1404 def test_web_events_location(self):
1405 """test POST /events < <dti_event>"""
1407 Settings.logger.info("=====> test_web_events_location")
1408 body = json.dumps({"dcae_service_action": "deploy",
1409 "dcae_target_name": "another01ems003",
1410 "dcae_target_type": "ANOT-her",
1411 "dcae_service_location": "LSLEILAA"
1414 "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully",
1415 "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully"
1419 result = self.getPage("/events", method='POST', body=body,
1421 ("Content-Type", "application/json"),
1422 ('Content-Length', str(len(body)))
1424 self.assertStatus('200 OK')
1425 Settings.logger.info("got result: %s", self.body)
1426 assert ( json.loads(self.body) == expected_result )
1428 def test_web_events_undeploy_bad(self):
1429 """test POST /events < <dti_event> -- bad dcae_target_name"""
1431 Settings.logger.info("=====> test_web_events_undeploy_bad")
1432 body = json.dumps({"dcae_service_action": "undeploy",
1433 "dcae_target_name": "bogus",
1434 "dcae_target_type": "ANOT-her"
1437 "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully",
1438 "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully",
1439 "WARNING": "VNF instance bogus was not in Consul oti_events historical folder"
1443 result = self.getPage("/events", method='POST', body=body,
1445 ("Content-Type", "application/json"),
1446 ('Content-Length', str(len(body)))
1448 self.assertStatus('200 OK')
1449 Settings.logger.info("got result: %s", self.body)
1450 assert ( json.loads(self.body) == expected_result )
1452 def test_web_events_undeploy(self):
1453 """test POST /events < <dti_event>"""
1455 Settings.logger.info("=====> test_web_events_undeploy")
1456 body = json.dumps({"dcae_service_action": "undeploy",
1457 "dcae_target_name": "another01ems003",
1458 "dcae_target_type": "ANOT-her"
1461 "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully",
1462 "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully"
1466 result = self.getPage("/events", method='POST', body=body,
1468 ("Content-Type", "application/json"),
1469 ('Content-Length', str(len(body)))
1471 self.assertStatus('200 OK')
1472 Settings.logger.info("got result: %s", self.body)
1473 assert ( json.loads(self.body) == expected_result )
1475 def test_web_mockevents(self):
1476 """test GET /mockevents"""
1478 Settings.logger.info("=====> test_web_mockevents")
1479 expected_result = {"KubeNamespace":"com-my-dcae-test", "KubePod":"pod-0", "KubeServiceName":"pod-0.service.local", "KubeServicePort":"8880", "KubeClusterFqdn":"fqdn-1"}
1480 result = self.getPage("/mockevents")
1481 self.assertStatus('200 OK')
1482 Settings.logger.info("got result: %s", self.body)
1483 assert ( json.loads(self.body) == expected_result )
1485 def test_web_dti_docker_events_put(self):
1486 """test PUT /dti_docker_events?service=SCN_1"""
1488 Settings.logger.info("=====> test_web_dti_docker_events_put")
1489 result = self.getPage("/dti_docker_events?service=SCN_1", method='PUT')
1490 self.assertStatus(404)
1492 def test_web_dti_docker_events_bad_service(self):
1493 """test GET /dti_docker_events?service=bogus"""
1495 Settings.logger.info("=====> test_web_dti_docker_events_bad_service")
1496 expected_result = {}
1497 result = self.getPage("/dti_docker_events?service=bogus")
1498 self.assertStatus('200 OK')
1499 Settings.logger.info("got result: %s", self.body)
1500 assert ( json.loads(self.body) == expected_result )
1502 def test_web_dti_docker_events(self):
1503 """test GET /dti_docker_events?service=SCN_1"""
1505 Settings.logger.info("=====> test_web_dti_docker_events")
1506 expected_result = {}
1507 result = self.getPage("/dti_docker_events?service=SCN_1")
1508 self.assertStatus('200 OK')
1509 Settings.logger.info("got result: %s", self.body)
1510 assert ( json.loads(self.body) == expected_result )
1512 def test_web_dti_docker_events_bad_location(self):
1513 """test GET /dti_docker_events?service=SCN_1&location=bogus"""
1515 Settings.logger.info("=====> test_web_dti_docker_events_bad_location")
1516 expected_result = {}
1517 result = self.getPage("/dti_docker_events?service=SCN_1&location=bogus")
1518 self.assertStatus('200 OK')
1519 Settings.logger.info("got result: %s", self.body)
1520 assert ( json.loads(self.body) == expected_result )
1522 def test_web_dti_docker_events_location(self):
1523 """test GET /dti_docker_events?service=SCN_1&location=LSLEILAA"""
1525 Settings.logger.info("=====> test_web_dti_docker_events_location")
1526 expected_result = {}
1527 result = self.getPage("/dti_docker_events?service=SCN_1&location=LSLEILAA")
1528 self.assertStatus('200 OK')
1529 Settings.logger.info("got result: %s", self.body)
1530 assert ( json.loads(self.body) == expected_result )
1532 def test_web_dti_docker_events_locations(self):
1533 """test GET /dti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1"""
1535 Settings.logger.info("=====> test_web_dti_docker_events_locations")
1536 expected_result = {}
1537 result = self.getPage("/dti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1")
1538 self.assertStatus('200 OK')
1539 Settings.logger.info("got result: %s", self.body)
1540 assert ( json.loads(self.body) == expected_result )
1542 def test_web_dti_docker_events_bad_locations(self):
1543 """test GET /dti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1"""
1545 Settings.logger.info("=====> test_web_dti_docker_events_bad_locations")
1546 expected_result = {}
1547 result = self.getPage("/dti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1")
1548 self.assertStatus('200 OK')
1549 Settings.logger.info("got result: %s", self.body)
1550 assert ( json.loads(self.body) == expected_result )
1552 def test_web_oti_docker_events_put(self):
1553 """test PUT /oti_docker_events?service=SCN_1"""
1555 Settings.logger.info("=====> test_web_oti_docker_events_put")
1556 result = self.getPage("/oti_docker_events?service=SCN_1", method='PUT')
1557 self.assertStatus(404)
1559 def test_web_oti_docker_events_bad_service(self):
1560 """test GET /oti_docker_events?service=bogus"""
1562 Settings.logger.info("=====> test_web_oti_docker_events_bad_service")
1563 expected_result = {}
1564 result = self.getPage("/oti_docker_events?service=bogus")
1565 self.assertStatus('200 OK')
1566 Settings.logger.info("got result: %s", self.body)
1567 assert ( json.loads(self.body) == expected_result )
1569 def test_web_oti_docker_events(self):
1570 """test GET /oti_docker_events?service=SCN_1"""
1572 Settings.logger.info("=====> test_web_oti_docker_events")
1573 expected_result = {}
1574 result = self.getPage("/oti_docker_events?service=SCN_1")
1575 self.assertStatus('200 OK')
1576 Settings.logger.info("got result: %s", self.body)
1577 assert ( json.loads(self.body) == expected_result )
1579 def test_web_oti_docker_events_bad_location(self):
1580 """test GET /oti_docker_events?service=SCN_1&location=bogus"""
1582 Settings.logger.info("=====> test_web_oti_docker_events_bad_location")
1583 expected_result = {}
1584 result = self.getPage("/oti_docker_events?service=SCN_1&location=bogus")
1585 self.assertStatus('200 OK')
1586 Settings.logger.info("got result: %s", self.body)
1587 assert ( json.loads(self.body) == expected_result )
1589 def test_web_oti_docker_events_location(self):
1590 """test GET /oti_docker_events?service=SCN_1&location=LSLEILAA"""
1592 Settings.logger.info("=====> test_web_oti_docker_events_location")
1593 expected_result = {}
1594 result = self.getPage("/oti_docker_events?service=SCN_1&location=LSLEILAA")
1595 self.assertStatus('200 OK')
1596 Settings.logger.info("got result: %s", self.body)
1597 assert ( json.loads(self.body) == expected_result )
1599 def test_web_oti_docker_events_locations(self):
1600 """test GET /oti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1"""
1602 Settings.logger.info("=====> test_web_oti_docker_events_locations")
1603 expected_result = {}
1604 result = self.getPage("/oti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1")
1605 self.assertStatus('200 OK')
1606 Settings.logger.info("got result: %s", self.body)
1607 assert ( json.loads(self.body) == expected_result )
1609 def test_web_oti_docker_events_bad_locations(self):
1610 """test GET /oti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1"""
1612 Settings.logger.info("=====> test_web_oti_docker_events_bad_locations")
1613 expected_result = {}
1614 result = self.getPage("/oti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1")
1615 self.assertStatus('200 OK')
1616 Settings.logger.info("got result: %s", self.body)
1617 assert ( json.loads(self.body) == expected_result )
1619 def test_web_reconfig_put(self):
1620 """test PUT /reconfig -- wrong method"""
1622 Settings.logger.info("=====> test_web_reconfig_put")
1623 result = self.getPage("/reconfig/deployment_id_1", method='PUT')
1624 self.assertStatus(404)
1626 def test_web_dti_put(self):
1627 """test PUT /dti -- wrong method"""
1629 Settings.logger.info("=====> test_web_dti_put")
1630 result = self.getPage("/dti", method='PUT')
1631 self.assertStatus(404)
1633 def test_web_dti(self):
1636 Settings.logger.info("=====> test_web_dti")
1637 result = self.getPage("/dti")
1638 Settings.logger.info("got dti: %s", self.body)
1639 self.assertStatus('200 OK')
1643 "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1644 "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1645 "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1648 assert ( json.loads(self.body) == expected_result )
1650 def test_web_dti_SCN_bogus(self):
1651 """test GET /dti/<service_name> -- bogus SCN"""
1653 Settings.logger.info("=====> test_web_dti_SCN_bogus")
1654 result = self.getPage("/dti/SCN_bogus")
1655 self.assertStatus(404)
1657 def test_web_dti_SCN(self):
1658 """test GET /dti/<service_name>"""
1660 Settings.logger.info("=====> test_web_dti_SCN")
1661 result = self.getPage("/dti/SCN_1")
1662 Settings.logger.info("got dti: %s", self.body)
1663 self.assertStatus('200 OK')
1667 "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1668 "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1669 "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1672 assert ( json.loads(self.body) == expected_result )
1674 def test_web_dti_SCN_type(self):
1675 """test GET /dti/<service_name>?vnf_type=<vnf_type>"""
1677 Settings.logger.info("=====> test_web_dti_SCN_type")
1678 result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her")
1679 Settings.logger.info("got dti: %s", self.body)
1680 self.assertStatus('200 OK')
1683 "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1684 "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1685 "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1687 assert ( json.loads(self.body) == expected_result )
1689 def test_web_dti_types(self):
1690 """test GET /dti?vnf_type=<vnf_types>"""
1692 Settings.logger.info("=====> test_web_dti_types")
1693 result = self.getPage("/dti?vnf_type=ANOT-her,new-type")
1694 Settings.logger.info("got dti: %s", self.body)
1695 self.assertStatus('200 OK')
1699 "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1700 "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1701 "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1704 assert ( json.loads(self.body) == expected_result )
1706 def test_web_dti_SCN_type_miss(self):
1707 """test GET /dti/<service_name>?vnf_type=<vnf_type>"""
1709 Settings.logger.info("=====> test_web_dti_SCN_type_miss")
1710 result = self.getPage("/dti/SCN_1?vnf_type=NO-match")
1711 Settings.logger.info("got dti: %s", self.body)
1712 self.assertStatus('200 OK')
1714 expected_result = {}
1715 assert ( json.loads(self.body) == expected_result )
1717 def test_web_dti_SCN_type_vnf_id(self):
1718 """test GET /dti/<service_name>?vnf_type=<vnf_type>;vnf_id=<vnf_id>"""
1720 Settings.logger.info("=====> test_web_dti_SCN_type_vnf_id")
1721 result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her;vnf_id=another01ems003")
1722 Settings.logger.info("got dti: %s", self.body)
1723 self.assertStatus('200 OK')
1725 expected_result = {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1726 assert ( json.loads(self.body) == expected_result )
1728 def test_web_dti_SCN_type_vnf_id_location(self):
1729 """test GET /dti/<service_name>?vnf_type=<vnf_type>;vnf_id=<vnf_id>;service_location=<service_location>"""
1731 Settings.logger.info("=====> test_web_dti_SCN_type_vnf_id_location")
1732 result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her;vnf_id=another01ems003;service_location=LSLEILAA")
1733 Settings.logger.info("got dti: %s", self.body)
1734 self.assertStatus('200 OK')
1736 expected_result = {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1737 assert ( json.loads(self.body) == expected_result )
1739 def test_web_dti_SCN_types_location(self):
1740 """test GET /dti/<service_name>?vnf_type=<vnf_types>;service_location=<service_location>"""
1742 Settings.logger.info("=====> test_web_dti_SCN_types_location")
1743 result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her,new-type;service_location=MDTWNJC1")
1744 Settings.logger.info("got dti: %s", self.body)
1745 self.assertStatus('200 OK')
1749 "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1752 assert ( json.loads(self.body) == expected_result )
1754 def test_web_dti_location(self):
1755 """test GET /dti?service_location=<service_location>"""
1757 Settings.logger.info("=====> test_web_dti_location")
1758 result = self.getPage("/dti?service_location=LSLEILAA")
1759 Settings.logger.info("got dti: %s", self.body)
1760 self.assertStatus('200 OK')
1764 "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1765 "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1768 assert ( json.loads(self.body) == expected_result )
1770 def test_web_dti_type_location(self):
1771 """test GET /dti?vnf_type=<vnf_type>;service_location=<service_location>"""
1773 Settings.logger.info("=====> test_web_dti_type_location")
1774 result = self.getPage("/dti?vnf_type=ANOT-her;service_location=LSLEILAA")
1775 Settings.logger.info("got dti: %s", self.body)
1776 self.assertStatus('200 OK')
1779 "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}},
1780 "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}
1782 assert ( json.loads(self.body) == expected_result )
1784 def test_web_service_component_put(self):
1785 """test PUT /service_component -- wrong method"""
1787 Settings.logger.info("=====> test_web_service_component_put")
1788 result = self.getPage("/service_component/SCN_1", method='PUT')
1789 self.assertStatus(404)
1791 def test_web_service_component_bogus(self):
1792 """test GET /service_component/<service_name> -- bogus SCN"""
1794 Settings.logger.info("=====> test_web_service_component_bogus")
1795 result = self.getPage("/service_component/SCN_bogus")
1796 self.assertStatus(404)
1798 def test_web_service_component(self):
1799 """test GET /service_component/<service_name>"""
1801 Settings.logger.info("=====> test_web_service_component")
1802 result = self.getPage("/service_component/SCN_1")
1803 Settings.logger.info("got service_component: %s", self.body)
1804 self.assertStatus('200 OK')
1806 expected_result = {"dcae_target_type": ["pnga-xxx"]}
1807 assert ( json.loads(self.body) == expected_result )
1809 def test_web_service_component_all_put(self):
1810 """test PUT /service_component_all -- wrong method"""
1812 Settings.logger.info("=====> test_web_service_component_all_put")
1813 result = self.getPage("/service_component_all/SCN_1", method='PUT')
1814 self.assertStatus(404)
1816 def test_web_service_component_all_bogus(self):
1817 """test GET /service_component_all/<service_name> -- bogus SCN"""
1819 Settings.logger.info("=====> test_web_service_component_all_bogus")
1820 result = self.getPage("/service_component_all/SCN_bogus")
1821 self.assertStatus(404)
1823 def test_web_service_component_all(self):
1824 """test GET /service_component_all/<service_name>"""
1826 Settings.logger.info("=====> test_web_service_component_all")
1827 result = self.getPage("/service_component_all/SCN_1")
1828 Settings.logger.info("got service_component_all: %s", self.body)
1829 self.assertStatus('200 OK')
1831 expected_result = {"oti": {"anot-her": {"another01ems003": {"dcae_target_name": "another01ems003", "dcae_target_collection_ip": "107.239.85.3", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "LSLEILAA", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "isPrimary": "true", "remoteServerName": "another01ems003"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}, "another01ems042": {"dcae_target_name": "another01ems042", "dcae_target_collection_ip": "107.239.85.42", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "LSLEILAA", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "isPrimary": "true", "remoteServerName": "another01ems042"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}, "another01ems044": {"dcae_target_name": "another01ems044", "dcae_target_collection_ip": "107.239.85.42", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "MDTWNJC1", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "isPrimary": "true", "remoteServerName": "another01ems044"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}}}, "policies": {"event": {"update_id": "e6102aab-3079-435a-ae0d-0397a2cb3c4d", "action": "updated", "timestamp": "2018-07-16T15:11:44.845Z", "policies_count": 3}, "items": {"DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel", "conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "5", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_Green_Collectors": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "polling_frequency": "30m", "package_type": "plastic"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Collectors", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_In_Service": {"property": null, "policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "In_Service", "ECOMPName": "dcae"}}}}, "config": {"dcae_target_type": ["pnga-xxx"]}}
1832 assert ( json.loads(self.body) == expected_result )
1834 def test_web_service_component_all_location(self):
1835 """test GET /service_component_all/<service_name>?service_location=<service_location>"""
1837 Settings.logger.info("=====> test_web_service_component_all_location")
1838 result = self.getPage("/service_component_all/SCN_1?service_location=MDTWNJC1")
1839 Settings.logger.info("got service_component_all: %s", self.body)
1840 self.assertStatus('200 OK')
1842 expected_result = {"oti": {"anot-her": {"another01ems044": {"dcae_target_name": "another01ems044", "dcae_target_collection_ip": "107.239.85.42", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "MDTWNJC1", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "isPrimary": "true", "remoteServerName": "another01ems044"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}}}, "policies": {"event": {"update_id": "e6102aab-3079-435a-ae0d-0397a2cb3c4d", "action": "updated", "timestamp": "2018-07-16T15:11:44.845Z", "policies_count": 3}, "items": {"DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel", "conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "5", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_Green_Collectors": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "polling_frequency": "30m", "package_type": "plastic"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Collectors", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_In_Service": {"property": null, "policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "In_Service", "ECOMPName": "dcae"}}}}, "config": {"dcae_target_type": ["pnga-xxx"]}}
1843 assert ( json.loads(self.body) == expected_result )
1845 def test_web_policies_put(self):
1846 """test PUT /policies/<service_name> -- wrong method"""
1848 Settings.logger.info("=====> test_web_policies_put")
1849 result = self.getPage("/policies/SCN_1", method='PUT')
1850 self.assertStatus(404)
1852 def test_web_policies_bogus(self):
1853 """test GET /policies/<service_name> -- bogus SCN"""
1855 Settings.logger.info("=====> test_web_policies_bogus")
1856 result = self.getPage("/policies/SCN_bogus")
1857 self.assertStatus(404)
1859 def test_web_policies(self):
1860 """test GET /policies/<service_name>"""
1862 Settings.logger.info("=====> test_web_policies")
1863 result = self.getPage("/policies/SCN_1")
1864 Settings.logger.info("got policies: %s", self.body)
1865 self.assertStatus('200 OK')
1867 expected_result = {"DCAE_FTL3B.Config_In_Service": {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "1", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyName": "DCAE_FTL3B.Config_In_Service.1.xml"}, "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific": {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "5", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"preparation": "scrambled", "bread": "pumpernickel", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "conflicting_key": "green_eggs_and_ham_are_better", "egg_color": "green", "bacon": "soft, not crispy"}, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml"}, "DCAE_FTL3B.Config_Green_Collectors": {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "1", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"conflicting_key": "green_collectors_wins", "package_type": "plastic", "power_source": "lemmings", "polling_frequency": "30m"}, "policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml"}}
1868 assert ( json.loads(self.body) == expected_result )
1870 def test_web_policies_policy(self):
1871 """test GET /policies/<service_name>?policy_id=<policy_id>"""
1873 Settings.logger.info("=====> test_web_policies_policy")
1874 result = self.getPage("/policies/SCN_1?policy_id=DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific")
1875 Settings.logger.info("got policies: %s", self.body)
1876 self.assertStatus('200 OK')
1878 expected_result = {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "5", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"preparation": "scrambled", "bread": "pumpernickel", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "conflicting_key": "green_eggs_and_ham_are_better", "egg_color": "green", "bacon": "soft, not crispy"}, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml"}
1879 assert ( json.loads(self.body) == expected_result )
1881 @pytest.mark.usefixtures("fix_cherrypy_engine_exit")
1882 def test_zzz_web_shutdown(self):
1883 """test /shutdown"""
1885 Settings.logger.info("=====> test_zzz_web_shutdown")
1886 Settings.logger.info("sleep before shutdown...")
1889 result = self.getPage("/shutdown")
1890 Settings.logger.info("shutdown result: %s", result)
1891 self.assertStatus('200 OK')
1892 Settings.logger.info("got shutdown: %s", self.body)
1893 self.assertInBody('goodbye! shutdown requested ')