X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftransportpce_tests%2Fwith_docker%2Ftest02_nbinotifications.py;fp=tests%2Ftransportpce_tests%2Fwith_docker%2Ftest02_nbinotifications.py;h=a235b0f5205400cbeac6805eea733d6b5d6d4eb3;hb=88dcd9efdcbf9092362e6c05d67a0c1876e5aee6;hp=5e5edfae16bb6324feb5c3a60d98e7cced884777;hpb=a729ecdb14642bec6112775cae2ead7adbd65689;p=transportpce.git diff --git a/tests/transportpce_tests/with_docker/test02_nbinotifications.py b/tests/transportpce_tests/with_docker/test02_nbinotifications.py index 5e5edfae1..a235b0f52 100644 --- a/tests/transportpce_tests/with_docker/test02_nbinotifications.py +++ b/tests/transportpce_tests/with_docker/test02_nbinotifications.py @@ -21,12 +21,12 @@ import requests sys.path.append('transportpce_tests/common/') # pylint: disable=wrong-import-position # pylint: disable=import-error -import test_utils # nopep8 +import test_utils_rfc8040 # nopep8 class TransportNbiNotificationstesting(unittest.TestCase): processes = [] - cr_serv_sample_data = {"input": { + cr_serv_input_data = { "sdnc-request-header": { "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", "rpc-action": "service-create", @@ -57,6 +57,22 @@ class TransportNbiNotificationstesting(unittest.TestCase): "due-date": "2016-11-28T00:00:01Z", "operator-contact": "pw1234" } + + del_serv_input_data = { + "sdnc-request-header": { + "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58", + "rpc-action": "service-delete", + "request-system-id": "appname", + "notification-url": "http://localhost:8585/NotificationServer/notify"}, + "service-delete-req-info": { + "service-name": "TBD", + "tail-retention": "no"} + } + + nbi_notif_input_data = { + "connection-type": "service", + "id-consumer": "consumer", + "group-id": "transportpceTest" } WAITING = 20 # nominal value is 300 @@ -67,33 +83,33 @@ class TransportNbiNotificationstesting(unittest.TestCase): # pylint: disable=unsubscriptable-object # TODO: for lighty manage the activation of NBI notification feature cls.init_failed = False - cls.processes = test_utils.start_tpce() + cls.processes = test_utils_rfc8040.start_tpce() # NBI notification feature is not installed by default in Karaf if "USE_LIGHTY" not in os.environ or os.environ['USE_LIGHTY'] != 'True': print("installing NBI notification feature...") - result = test_utils.install_karaf_feature("odl-transportpce-nbinotifications") + result = test_utils_rfc8040.install_karaf_feature("odl-transportpce-nbinotifications") if result.returncode != 0: cls.init_failed = True print("Restarting OpenDaylight...") - test_utils.shutdown_process(cls.processes[0]) - cls.processes[0] = test_utils.start_karaf() - test_utils.process_list[0] = cls.processes[0] - cls.init_failed = not test_utils.wait_until_log_contains( - test_utils.KARAF_LOG, test_utils.KARAF_OK_START_MSG, time_to_wait=60) + test_utils_rfc8040.shutdown_process(cls.processes[0]) + cls.processes[0] = test_utils_rfc8040.start_karaf() + test_utils_rfc8040.process_list[0] = cls.processes[0] + cls.init_failed = not test_utils_rfc8040.wait_until_log_contains( + test_utils_rfc8040.KARAF_LOG, test_utils_rfc8040.KARAF_OK_START_MSG, time_to_wait=60) if cls.init_failed: print("NBI notification installation feature failed...") - test_utils.shutdown_process(cls.processes[0]) + test_utils_rfc8040.shutdown_process(cls.processes[0]) sys.exit(2) - cls.processes = test_utils.start_sims([('xpdra', cls.NODE_VERSION), - ('roadma', cls.NODE_VERSION), - ('roadmc', cls.NODE_VERSION), - ('xpdrc', cls.NODE_VERSION)]) + cls.processes = test_utils_rfc8040.start_sims([('xpdra', cls.NODE_VERSION), + ('roadma', cls.NODE_VERSION), + ('roadmc', cls.NODE_VERSION), + ('xpdrc', cls.NODE_VERSION)]) @classmethod def tearDownClass(cls): # pylint: disable=not-an-iterable for process in cls.processes: - test_utils.shutdown_process(process) + test_utils_rfc8040.shutdown_process(process) print("all processes killed") def setUp(self): # instruction executed before each test method @@ -101,90 +117,85 @@ class TransportNbiNotificationstesting(unittest.TestCase): print("execution of {}".format(self.id().split(".")[-1])) def test_01_connect_xpdrA(self): - response = test_utils.mount_device("XPDR-A1", ('xpdra', self.NODE_VERSION)) - self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) + response = test_utils_rfc8040.mount_device("XPDR-A1", ('xpdra', self.NODE_VERSION)) + self.assertEqual(response.status_code, + requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201) def test_02_connect_xpdrC(self): - response = test_utils.mount_device("XPDR-C1", ('xpdrc', self.NODE_VERSION)) - self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) + response = test_utils_rfc8040.mount_device("XPDR-C1", ('xpdrc', self.NODE_VERSION)) + self.assertEqual(response.status_code, + requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201) def test_03_connect_rdmA(self): - response = test_utils.mount_device("ROADM-A1", ('roadma', self.NODE_VERSION)) - self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) + response = test_utils_rfc8040.mount_device("ROADM-A1", ('roadma', self.NODE_VERSION)) + self.assertEqual(response.status_code, + requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201) def test_04_connect_rdmC(self): - response = test_utils.mount_device("ROADM-C1", ('roadmc', self.NODE_VERSION)) - self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201) + response = test_utils_rfc8040.mount_device("ROADM-C1", ('roadmc', self.NODE_VERSION)) + self.assertEqual(response.status_code, + requests.codes.created, test_utils_rfc8040.CODE_SHOULD_BE_201) def test_05_connect_xprdA_N1_to_roadmA_PP1(self): - response = test_utils.connect_xpdr_to_rdm_request("XPDR-A1", "1", "1", - "ROADM-A1", "1", "SRG1-PP1-TXRX") - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'transportpce-networkutils', 'init-xpdr-rdm-links', + {'links-input': {'xpdr-node': 'XPDR-A1', 'xpdr-num': '1', 'network-num': '1', + 'rdm-node': 'ROADM-A1', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'}}) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertIn('Xponder Roadm Link created successfully', response["output"]["result"]) time.sleep(2) def test_06_connect_roadmA_PP1_to_xpdrA_N1(self): - response = test_utils.connect_rdm_to_xpdr_request("XPDR-A1", "1", "1", - "ROADM-A1", "1", "SRG1-PP1-TXRX") - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'transportpce-networkutils', 'init-rdm-xpdr-links', + {'links-input': {'xpdr-node': 'XPDR-A1', 'xpdr-num': '1', 'network-num': '1', + 'rdm-node': 'ROADM-A1', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'}}) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertIn('Roadm Xponder links created successfully', response["output"]["result"]) time.sleep(2) def test_07_connect_xprdC_N1_to_roadmC_PP1(self): - response = test_utils.connect_xpdr_to_rdm_request("XPDR-C1", "1", "1", - "ROADM-C1", "1", "SRG1-PP1-TXRX") - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertIn('Xponder Roadm Link created successfully', res["output"]["result"]) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'transportpce-networkutils', 'init-xpdr-rdm-links', + {'links-input': {'xpdr-node': 'XPDR-C1', 'xpdr-num': '1', 'network-num': '1', + 'rdm-node': 'ROADM-C1', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'}}) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertIn('Xponder Roadm Link created successfully', response["output"]["result"]) time.sleep(2) def test_08_connect_roadmC_PP1_to_xpdrC_N1(self): - response = test_utils.connect_rdm_to_xpdr_request("XPDR-C1", "1", "1", - "ROADM-C1", "1", "SRG1-PP1-TXRX") - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertIn('Roadm Xponder links created successfully', res["output"]["result"]) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'transportpce-networkutils', 'init-rdm-xpdr-links', + {'links-input': {'xpdr-node': 'XPDR-C1', 'xpdr-num': '1', 'network-num': '1', + 'rdm-node': 'ROADM-C1', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'}}) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertIn('Roadm Xponder links created successfully', response["output"]["result"]) time.sleep(2) def test_09_get_notifications_service1(self): - data = { - "input": { - "connection-type": "service", - "id-consumer": "consumer", - "group-id": "transportpceTest" - } - } - response = test_utils.get_notifications_process_service_request(data) - self.assertEqual(response.status_code, requests.codes.no_content) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'nbi-notifications', 'get-notifications-process-service', self.nbi_notif_input_data) + self.assertEqual(response['status_code'], requests.codes.no_content) time.sleep(2) def test_10_create_eth_service1(self): - self.cr_serv_sample_data["input"]["service-name"] = "service1" - response = test_utils.service_create_request(self.cr_serv_sample_data) - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() + self.cr_serv_input_data["service-name"] = "service1" + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'org-openroadm-service', 'service-create', self.cr_serv_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) self.assertIn('PCE calculation in progress', - res['output']['configuration-response-common']['response-message']) + response['output']['configuration-response-common']['response-message']) time.sleep(self.WAITING) def test_11_get_notifications_service1(self): - data = { - "input": { - "connection-type": "service", - "id-consumer": "consumer", - "group-id": "transportpceTest" - } - } - response = test_utils.get_notifications_process_service_request(data) - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertEqual(res['output']['notifications-process-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notifications-process-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notifications-process-service'][-1]['message'], + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'nbi-notifications', 'get-notifications-process-service', self.nbi_notif_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertEqual(response['output']['notifications-process-service'][-1]['service-name'], 'service1') + self.assertEqual(response['output']['notifications-process-service'][-1]['connection-type'], 'service') + self.assertEqual(response['output']['notifications-process-service'][-1]['message'], 'ServiceCreate request failed ...') - self.assertEqual(res['output']['notifications-process-service'][-1]['response-failed'], + self.assertEqual(response['output']['notifications-process-service'][-1]['response-failed'], 'PCE path computation failed !') time.sleep(2) @@ -200,7 +211,8 @@ class TransportNbiNotificationstesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - response = test_utils.add_oms_attr_request("ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX", data) + response = test_utils_rfc8040.add_oms_attr_request( + "ROADM-A1-DEG2-DEG2-TTP-TXRXtoROADM-C1-DEG1-DEG1-TTP-TXRX", data) self.assertEqual(response.status_code, requests.codes.created) def test_13_add_omsAttributes_ROADMC_ROADMA(self): @@ -215,65 +227,45 @@ class TransportNbiNotificationstesting(unittest.TestCase): "fiber-type": "smf", "SRLG-length": 100000, "pmd": 0.5}]}} - response = test_utils.add_oms_attr_request("ROADM-C1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG2-DEG2-TTP-TXRX", data) + response = test_utils_rfc8040.add_oms_attr_request( + "ROADM-C1-DEG1-DEG1-TTP-TXRXtoROADM-A1-DEG2-DEG2-TTP-TXRX", data) self.assertEqual(response.status_code, requests.codes.created) # test service-create for Eth service from xpdr to xpdr def test_14_create_eth_service1(self): - self.cr_serv_sample_data["input"]["service-name"] = "service1" - response = test_utils.service_create_request(self.cr_serv_sample_data) - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() + self.cr_serv_input_data["service-name"] = "service1" + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'org-openroadm-service', 'service-create', self.cr_serv_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) self.assertIn('PCE calculation in progress', - res['output']['configuration-response-common']['response-message']) + response['output']['configuration-response-common']['response-message']) time.sleep(self.WAITING) def test_15_get_eth_service1(self): - response = test_utils.get_service_list_request("services/service1") - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertEqual( - res['services'][0]['administrative-state'], 'inService') - self.assertEqual( - res['services'][0]['service-name'], 'service1') - self.assertEqual( - res['services'][0]['connection-type'], 'service') - self.assertEqual( - res['services'][0]['lifecycle-state'], 'planned') - time.sleep(2) + response = test_utils_rfc8040.get_ordm_serv_list_attr_request("services", "service1") + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertEqual(response['services'][0]['administrative-state'], 'inService') + self.assertEqual(response['services'][0]['service-name'], 'service1') + self.assertEqual(response['services'][0]['connection-type'], 'service') + self.assertEqual(response['services'][0]['lifecycle-state'], 'planned') def test_16_get_notifications_service1(self): - data = { - "input": { - "connection-type": "service", - "id-consumer": "consumer", - "group-id": "transportpceTest" - } - } - response = test_utils.get_notifications_process_service_request(data) - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertEqual(res['output']['notifications-process-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notifications-process-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notifications-process-service'][-1]['message'], 'Service implemented !') - time.sleep(2) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'nbi-notifications', 'get-notifications-process-service', self.nbi_notif_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertEqual(response['output']['notifications-process-service'][-1]['service-name'], 'service1') + self.assertEqual(response['output']['notifications-process-service'][-1]['connection-type'], 'service') + self.assertEqual(response['output']['notifications-process-service'][-1]['message'], 'Service implemented !') def test_17_get_notifications_alarm_service1(self): - data = { - "input": { - "connection-type": "service", - "id-consumer": "consumer", - "group-id": "transportpceTest" - } - } - response = test_utils.get_notifications_alarm_service_request(data) - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertEqual(res['output']['notifications-alarm-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notifications-alarm-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notifications-alarm-service'][-1]['operational-state'], 'inService') - self.assertEqual(res['output']['notifications-alarm-service'][-1]['message'], 'The service is now inService') - time.sleep(2) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'nbi-notifications', 'get-notifications-alarm-service', self.nbi_notif_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertEqual(response['output']['notifications-alarm-service'][-1]['service-name'], 'service1') + self.assertEqual(response['output']['notifications-alarm-service'][-1]['connection-type'], 'service') + self.assertEqual(response['output']['notifications-alarm-service'][-1]['operational-state'], 'inService') + self.assertEqual(response['output']['notifications-alarm-service'][-1]['message'], + 'The service is now inService') def test_18_change_status_port_roadma_srg(self): url = "{}/config/org-openroadm-device:org-openroadm-device/circuit-packs/3%2F0/ports/C1" @@ -285,28 +277,21 @@ class TransportNbiNotificationstesting(unittest.TestCase): "administrative-state": "outOfService", "port-qual": "roadm-external"}]} response = requests.request("PUT", url.format("http://127.0.0.1:8141/restconf"), - data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, - auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD), - timeout=test_utils.REQUEST_TIMEOUT) + data=json.dumps(body), headers=test_utils_rfc8040.TYPE_APPLICATION_JSON, + auth=(test_utils_rfc8040.ODL_LOGIN, test_utils_rfc8040.ODL_PWD), + timeout=test_utils_rfc8040.REQUEST_TIMEOUT) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(2) def test_19_get_notifications_alarm_service1(self): - data = { - "input": { - "connection-type": "service", - "id-consumer": "consumer", - "group-id": "transportpceTest" - } - } - response = test_utils.get_notifications_alarm_service_request(data) - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertEqual(res['output']['notifications-alarm-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notifications-alarm-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notifications-alarm-service'][-1]['operational-state'], 'outOfService') - self.assertEqual(res['output']['notifications-alarm-service'][-1]['message'], 'The service is now outOfService') - time.sleep(2) + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'nbi-notifications', 'get-notifications-alarm-service', self.nbi_notif_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertEqual(response['output']['notifications-alarm-service'][-1]['service-name'], 'service1') + self.assertEqual(response['output']['notifications-alarm-service'][-1]['connection-type'], 'service') + self.assertEqual(response['output']['notifications-alarm-service'][-1]['operational-state'], 'outOfService') + self.assertEqual(response['output']['notifications-alarm-service'][-1]['message'], + 'The service is now outOfService') def test_20_restore_status_port_roadma_srg(self): url = "{}/config/org-openroadm-device:org-openroadm-device/circuit-packs/3%2F0/ports/C1" @@ -318,9 +303,9 @@ class TransportNbiNotificationstesting(unittest.TestCase): "administrative-state": "inService", "port-qual": "roadm-external"}]} response = requests.request("PUT", url.format("http://127.0.0.1:8141/restconf"), - data=json.dumps(body), headers=test_utils.TYPE_APPLICATION_JSON, - auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD), - timeout=test_utils.REQUEST_TIMEOUT) + data=json.dumps(body), headers=test_utils_rfc8040.TYPE_APPLICATION_JSON, + auth=(test_utils_rfc8040.ODL_LOGIN, test_utils_rfc8040.ODL_PWD), + timeout=test_utils_rfc8040.REQUEST_TIMEOUT) self.assertEqual(response.status_code, requests.codes.ok) time.sleep(2) @@ -328,44 +313,38 @@ class TransportNbiNotificationstesting(unittest.TestCase): self.test_17_get_notifications_alarm_service1() def test_22_delete_eth_service1(self): - response = test_utils.service_delete_request("service1") - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() + self.del_serv_input_data["service-delete-req-info"]["service-name"] = "service1" + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'org-openroadm-service', 'service-delete', self.del_serv_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) self.assertIn('Renderer service delete in progress', - res['output']['configuration-response-common']['response-message']) + response['output']['configuration-response-common']['response-message']) time.sleep(20) def test_23_get_notifications_service1(self): - data = { - "input": { - "connection-type": "service", - "id-consumer": "consumer", - "group-id": "transportpceTest" - } - } - response = test_utils.get_notifications_process_service_request(data) - self.assertEqual(response.status_code, requests.codes.ok) - res = response.json() - self.assertEqual(res['output']['notifications-process-service'][-1]['service-name'], 'service1') - self.assertEqual(res['output']['notifications-process-service'][-1]['connection-type'], 'service') - self.assertEqual(res['output']['notifications-process-service'][-1]['message'], 'Service deleted !') + response = test_utils_rfc8040.transportpce_api_rpc_request( + 'nbi-notifications', 'get-notifications-process-service', self.nbi_notif_input_data) + self.assertEqual(response['status_code'], requests.codes.ok) + self.assertEqual(response['output']['notifications-process-service'][-1]['service-name'], 'service1') + self.assertEqual(response['output']['notifications-process-service'][-1]['connection-type'], 'service') + self.assertEqual(response['output']['notifications-process-service'][-1]['message'], 'Service deleted !') time.sleep(2) def test_24_disconnect_XPDRA(self): - response = test_utils.unmount_device("XPDR-A1") - self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) + response = test_utils_rfc8040.unmount_device("XPDR-A1") + self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content)) def test_25_disconnect_XPDRC(self): - response = test_utils.unmount_device("XPDR-C1") - self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) + response = test_utils_rfc8040.unmount_device("XPDR-C1") + self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content)) def test_26_disconnect_ROADMA(self): - response = test_utils.unmount_device("ROADM-A1") - self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) + response = test_utils_rfc8040.unmount_device("ROADM-A1") + self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content)) def test_27_disconnect_ROADMC(self): - response = test_utils.unmount_device("ROADM-C1") - self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200) + response = test_utils_rfc8040.unmount_device("ROADM-C1") + self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content)) if __name__ == "__main__":