diff options
author | Joanna Jeremicz <joanna.jeremicz@nokia.com> | 2019-06-25 13:39:33 +0200 |
---|---|---|
committer | Joanna Jeremicz <joanna.jeremicz@nokia.com> | 2019-07-02 13:32:31 +0200 |
commit | 4a70dd3bcf1dde19d511f528650b08714b92448f (patch) | |
tree | 617142ce66a80ae19e7e9f551cce3a8bf5044116 /tests/dcaegen2/prh-testcases/resources | |
parent | d74cd46cf68d7b60a8b07edf6c05bc06dd861bd6 (diff) |
New BBS PRH testcases
Issue-ID: INT-1100
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Change-Id: I19455f401beeecf28c94575b8115e6ce8249bf0a
Diffstat (limited to 'tests/dcaegen2/prh-testcases/resources')
-rw-r--r-- | tests/dcaegen2/prh-testcases/resources/prh_library.robot | 43 | ||||
-rw-r--r-- | tests/dcaegen2/prh-testcases/resources/simulator/AAI.py | 47 |
2 files changed, 86 insertions, 4 deletions
diff --git a/tests/dcaegen2/prh-testcases/resources/prh_library.robot b/tests/dcaegen2/prh-testcases/resources/prh_library.robot index 3ed377c7..cf3f1097 100644 --- a/tests/dcaegen2/prh-testcases/resources/prh_library.robot +++ b/tests/dcaegen2/prh-testcases/resources/prh_library.robot @@ -15,6 +15,13 @@ Verify PNF ready sent Wait Until Keyword Succeeds 10x 3000ms Check CBS ready Wait Until Keyword Succeeds 10x 3000ms Check created PNF_READY notification ${expected_pnf_ready_event} +Verify PNF ready sent and old logical link removed from AAI + [Arguments] ${test_case_directory} + ${logical_link}= Get Data From File ${test_case_directory}/logical-link.json + Add logical link entry in AAI ${logical_link} + Verify PNF ready sent ${test_case_directory} + Wait Until Keyword Succeeds 10x 3000ms Check no logical link in AAI ${test_case_directory} + Verify PNF ready sent and logical link created [Arguments] ${test_case_directory} ${expected_logical_link}= Get Data From File ${test_case_directory}/expected-logical-link.json @@ -63,11 +70,38 @@ Verify PNF re registration Add PNF entry in AAI ${aai_entry} ${service_instance}= Get Data From File ${test_case_directory}/aai-entry-service-instance.json Add service instance entry in AAI ${service_instance} + ${logical_link}= Get Data From File ${test_case_directory}/logical-link.json + Add logical link entry in AAI ${logical_link} ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json Set VES event in DMaaP ${ves_event} ${expected_pnf_update_event}= Get Data From File ${test_case_directory}/expected-pnf-update-event.json Wait Until Keyword Succeeds 10x 3000ms Check created PNF_UPDATE notification ${expected_pnf_update_event} + Wait Until Keyword Succeeds 10x 3000ms Check logical link not modified ${test_case_directory} + +Verify PNF ready sent when service instance non active + [Arguments] ${test_case_directory} + ${pnf_entry}= Get Data From File ${test_case_directory}/aai-entry.json + ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json + ${expected_pnf_ready_event}= Get Data From File ${test_case_directory}/expected-pnf-ready-event.json + ${service_instance}= Get Data From File ${test_case_directory}/aai-entry-service-instance.json + Add PNF entry in AAI ${pnf_entry} + Add service instance entry in AAI ${service_instance} + + Set VES event in DMaaP ${ves_event} + Wait Until Keyword Succeeds 10x 3000ms Check CBS ready + Wait Until Keyword Succeeds 10x 3000ms Check created PNF_READY notification ${expected_pnf_ready_event} + +Check logical link not modified + [Arguments] ${test_case_directory} + ${expected_logical_link}= Get Data From File ${test_case_directory}/logical-link.json + ${actual_logical_link}= Get Request ${aai_session} /verify/logical-link/bbs-link headers=${suite_headers} + Should Be Equal As JSON ${expected_logical_link} ${actual_logical_link.content} + +Check no logical link in AAI + [Arguments] ${test_case_directory} + ${logical_links}= Get Request ${aai_session} /verify/logical-links headers=${suite_headers} + Should Be Equal As JSON {} ${logical_links.content} Check CBS ready ${resp}= Get Request ${consul_session} /v1/catalog/services @@ -86,7 +120,7 @@ Check created PNF_UPDATE notification ${resp}= Get Request ${dmaap_session} /verify/pnf_update headers=${suite_headers} Log Response from DMaaP: ${resp.content} Should Be Equal As Strings ${resp.status_code} 200 - #Should Be Equal As JSON ${resp.content} ${expected_event_pnf_ready_in_dpaap} + Should Be Equal As JSON ${resp.content} ${expected_event_pnf_update_in_dpaap} Check created Logical Link [Arguments] ${expected_logical_link_in_aai} @@ -124,6 +158,13 @@ Add service instance entry in AAI ${resp}= Put Request ${aai_session} /setup/add_service_instace headers=${suite_headers} data=${aai_service_instance} Should Be Equal As Strings ${resp.status_code} 200 +Add logical link entry in AAI + [Arguments] ${logical_link} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + Log AAI url ${AAI_SIMULATOR_SETUP_URL} + ${resp}= Put Request ${aai_session} /setup/add_logical_link headers=${suite_headers} data=${logical_link} + Should Be Equal As Strings ${resp.status_code} 200 + Set VES event in DMaaP [Arguments] ${ves_event} ${resp}= Put Request ${dmaap_session} /setup/ves_event headers=${suite_headers} data=${ves_event} diff --git a/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py b/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py index f6d3b1f6..e5f0b102 100644 --- a/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py +++ b/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py @@ -20,6 +20,7 @@ logger = logging.getLogger('AAI-simulator-logger') AAI_RESOURCE_NOT_FOUND = b'{}' pnf_entries = {} +logical_links = {} patched_pnf = AAI_RESOURCE_NOT_FOUND created_logical_link = AAI_RESOURCE_NOT_FOUND service_instance = AAI_RESOURCE_NOT_FOUND @@ -34,6 +35,12 @@ class AAISetup(BaseHTTPRequestHandler): elif re.search('/verify/created_logical_link', self.path): httpServerLib.set_response_200_ok(self, payload = created_logical_link) logger.debug('AAISetup GET /setup/created_logical_link -> 200 OK') + elif re.search('/verify/logical-links', self.path): + httpServerLib.set_response_200_ok(self, payload= json.dumps(logical_links).encode('utf-8')) + elif re.search('/verify/logical-link/bbs-link', self.path): + link_name = basename(self.path) + if link_name in logical_links: + httpServerLib.set_response_200_ok(self, payload = logical_links[link_name]) else: httpServerLib.set_response_404_not_found(self) logger.info('AAISetup GET ' + self.path + ' -> 404 Not found') @@ -60,6 +67,18 @@ class AAISetup(BaseHTTPRequestHandler): service_instance = json.loads(service_instance_payload) httpServerLib.set_response_200_ok(self) logger.debug('AAISetup PUT /setup/add_service_instace -> 200 OK') + elif re.search('/setup/add_logical_link', self.path): + logical_link_payload = httpServerLib.get_payload(self) + logical_link_name = json.loads(logical_link_payload).get("link-name") + if logical_link_name == None: + raise Exception("Invalid logical link entry, could not extract `link-name`") + + global logical_link + logical_links[logical_link_name] = logical_link_payload + + logical_link = json.loads(logical_link_payload) + httpServerLib.set_response_200_ok(self) + logger.debug('AAISetup PUT /setup/add_logical_link -> 200 OK') elif re.search('/set_pnf', self.path): pnf_name = httpServerLib.get_payload(self).decode() @@ -105,9 +124,17 @@ class AAIHandler(BaseHTTPRequestHandler): else: httpServerLib.set_response_404_not_found(self) logger.info('AAIHandler GET /aai/v12/network/pnfs/pnf/' + pnf_name + ' -> 404 Not found, actual entries: ' + str(pnf_entries.keys())) - elif re.search('aai/v12/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/bbs_service', self.path): - httpServerLib.set_response_200_ok(self, payload = service_instance) - logger.debug('AAIHandler GET aai/v12/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/bbs_service -> 200 OK') + elif re.search('/aai/v12/network/logical-links/logical-link/[^/]*$', self.path): + logical_link_name = basename(self.path) + if logical_link_name in logical_links: + httpServerLib.set_response_200_ok(self, payload = logical_links[logical_link_name]) + logger.debug('AAIHandler GET /aai/v12/network/logical-links/logical-link/' + logical_link_name + ' -> 200 OK') + else: + httpServerLib.set_response_404_not_found(self) + logger.info('AAIHandler GET /aai/v12/network/logical-links/logical-link/' + logical_link_name + ' -> 404 Not found, actual entries: ' + str(logical_links.keys())) + elif re.search('aai/v12/network/pnfs/pnf/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/bbs_service', self.path): + httpServerLib.set_response_200_ok(self, payload = json.dumps(service_instance).encode('utf-8')) + logger.debug('AAIHandler GET aai/v12/network/pnfs/pnf/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/bbs_service -> 200 OK') else: httpServerLib.set_response_404_not_found(self) logger.info('AAIHandler GET ' + self.path + ' -> 404 Not found') @@ -152,6 +179,20 @@ class AAIHandler(BaseHTTPRequestHandler): logger.error(e) httpServerLib.set_response_500_server_error(self) + def do_DELETE(self): + try: + if re.search('/aai/v12/network/logical-links/logical-link/[^/]*\?resource-version=\d+$', self.path): + httpServerLib.set_response_200_ok(self) + logical_link_name = re.search('.+?(?=\?)', basename(self.path)).group(0) + + del logical_links[logical_link_name] + logger.debug('AAIHandler DELETE /aai/v12/network/logical-links/logical-link/' + logical_link_name + ' -> 200 OK') + else: + httpServerLib.set_response_404_not_found(self) + logger.info('AAIHandler DELETE ' + self.path + ' -> 404 Not found') + except Exception as e: + logger.error(e) + httpServerLib.set_response_500_server_error(self) def _main_(handler_class=AAIHandler, protocol="HTTP/1.0"): handler_class.protocol_version = protocol |