From 66d4335e1721cdedb20d9cee9407b8c5aa2c45ec Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Fri, 5 Apr 2019 13:14:45 +0200 Subject: Adjust to new dcae-app-simulator api This change is a follow up to changes made in DCAEGEN2-1399. - move custom keywords from Robot to python for ease of use - enhanced logs in here - removed unused keyword Change-Id: I05cda5f2418d562a96dd00ae5b02025bc67b35a4 Issue-ID: DCAEGEN2-1399 Signed-off-by: Filip Krzywka --- .../testcases/__init__.robot | 25 ++--------- .../testcases/authorization.robot | 8 ++-- .../testcases/libraries/DcaeAppSimulatorLibrary.py | 50 +++++++++++++--------- .../testcases/message-routing.robot | 20 ++++----- .../testcases/multiple-clients.robot | 6 +-- .../testcases/resources/common-keywords.robot | 2 +- 6 files changed, 50 insertions(+), 61 deletions(-) diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot b/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot index 1e574b0e..7fffd9c3 100644 --- a/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot +++ b/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot @@ -37,20 +37,9 @@ Configure collector Publish HV VES Configuration In Consul ${CONSUL_API_URL} ${HV_VES_CONFIGURATION_JSON_FILEPATH} Configure Dcae App - ${DCAE_APP_API_ACCESS}= Get Dcae App Api Access Url ${HTTP_METHOD_URL} ${DCAE_APP_CONTAINER_HOST} ${DCAE_APP_CONTAINER_PORT} - - ${DCAE_APP_API_MESSAGE_RESET_URL}= Catenate SEPARATOR= ${DCAE_APP_API_ACCESS} ${DCAE_APP_API_MESSAGES_RESET_PATH} - Set Suite Variable ${DCAE_APP_API_MESSAGE_RESET_URL} children=True - - ${DCAE_APP_API_MESSAGES_COUNT_URL}= Catenate SEPARATOR= ${DCAE_APP_API_ACCESS} ${DCAE_APP_API_MESSAGES_COUNT_PATH} - Set Suite Variable ${DCAE_APP_API_MESSAGES_COUNT_URL} children=True - - ${DCAE_APP_API_MESSAGES_VALIDATION_URL}= Catenate SEPARATOR= ${DCAE_APP_API_ACCESS} ${DCAE_APP_API_MESSAGES_VALIDATION_PATH} - Set Suite Variable ${DCAE_APP_API_MESSAGES_VALIDATION_URL} children=True - - ${DCAE_APP_API_TOPIC_CONFIGURATION_URL}= Catenate SEPARATOR= ${DCAE_APP_API_ACCESS} ${DCAE_APP_API_TOPIC_CONFIGURATION_PATH} Wait until keyword succeeds 10 sec 5 sec - ... Configure Dcae App Simulator To Consume Messages From Topics ${DCAE_APP_API_TOPIC_CONFIGURATION_URL} ${ROUTED_MESSAGES_TOPIC} + ... Configure Dcae App Simulator To Consume Messages From Topics ${DEFAULT_PERF3GPP_TOPIC} + Set Suite Variable ${DEFAULT_PERF3GPP_TOPIC} children=True *** Variables *** @@ -60,15 +49,7 @@ ${CONSUL_CONTAINER_HOST} consul-server ${CONSUL_CONTAINER_PORT} 8500 ${CONSUL_HV_VES_CONFIGURATION_KEY_PATH} /v1/kv/dcae-hv-ves-collector -${DCAE_APP_CONTAINER_HOST} dcae-app-simulator -${DCAE_APP_CONTAINER_PORT} 6063 -${DCAE_APP_API_TOPIC_CONFIGURATION_PATH} /configuration/topics -${DCAE_APP_API_MESSAGES_RESET_PATH} /messages -${DCAE_APP_API_MESSAGES_PATH} /messages/all -${DCAE_APP_API_MESSAGES_COUNT_PATH} ${DCAE_APP_API_MESSAGES_PATH}/count -${DCAE_APP_API_MESSAGES_VALIDATION_PATH} ${DCAE_APP_API_MESSAGES_PATH}/validate - -${ROUTED_MESSAGES_TOPIC} TEST_HV_VES_PERF3GPP +${DEFAULT_PERF3GPP_TOPIC} TEST_HV_VES_PERF3GPP ${HV_VES_RESOURCES} %{WORKSPACE}/tests/dcaegen2-collectors-hv-ves/testcases/resources ${HV_VES_CONFIGURATION_JSON_FILEPATH} ${HV_VES_RESOURCES}/hv-ves-configuration.json diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/authorization.robot b/tests/dcaegen2-collectors-hv-ves/testcases/authorization.robot index 4d13a6bf..537cb8c1 100644 --- a/tests/dcaegen2-collectors-hv-ves/testcases/authorization.robot +++ b/tests/dcaegen2-collectors-hv-ves/testcases/authorization.robot @@ -1,7 +1,7 @@ # ============LICENSE_START======================================================= # csit-dcaegen2-collectors-hv-ves # ================================================================================ -# Copyright (C) 2018 NOKIA +# Copyright (C) 2018-2019 NOKIA # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ Authorization Send Messages From xNF Simulators ${XNF_WITH_INVALID_CERTIFICATES} ${XNF_VALID_MESSAGES_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_0} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_0} Unencrypted connection from client [Documentation] VES-HV Collector should not authorize XNF trying to connect through unencrypted connection @@ -59,7 +59,7 @@ Unencrypted connection from client Send Messages From xNF Simulators ${XNF_WITHOUT_SSL} ${XNF_VALID_MESSAGES_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_0} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_0} Unencrypted connection on both ends [Documentation] When run without SSL turned on, VES-HV Collector should route all valid messages @@ -68,7 +68,7 @@ Unencrypted connection on both ends Send Messages From xNF Simulators ${XNF_WITHOUT_SSL_CONNECTING_TO_UNENCRYPTED_HV_VES} ${XNF_VALID_MESSAGES_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_5000} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_5000} *** Variables *** diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py b/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py index dd41c6a3..60c2c46d 100644 --- a/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py +++ b/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py @@ -1,7 +1,7 @@ # ============LICENSE_START======================================================= # csit-dcaegen2-collectors-hv-ves # ================================================================================ -# Copyright (C) 2018 NOKIA +# Copyright (C) 2018-2019 NOKIA # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,19 +16,37 @@ # limitations under the License. # ============LICENSE_END========================================================= import HttpRequests +from VesHvContainersUtilsLibrary import VesHvContainersUtilsLibrary from robot.api import logger +import json -DCAE_APP_NAME = "DCAE App" +DCAE_APP_NAME = "DCAE App Simulator" + +DCAE_APP_HOST = "dcae-app-simulator" +DCAE_APP_PORT = "6063" +DCAE_APP_ADDRESS = VesHvContainersUtilsLibrary().get_dcae_app_api_access_url("http://", DCAE_APP_HOST, DCAE_APP_PORT) + +TOPIC_CONFIGURATION_PATH = DCAE_APP_ADDRESS + "/configuration/topics" + +MESSAGES_PATH = "/messages/%s" +MESSAGES_RESET_PATH = DCAE_APP_ADDRESS + MESSAGES_PATH +MESSAGES_COUNT_PATH = DCAE_APP_ADDRESS + MESSAGES_PATH + "/count" +MESSAGES_VALIDATION_PATH = DCAE_APP_ADDRESS + MESSAGES_PATH + "/validate" class DcaeAppSimulatorLibrary: - def configure_dcae_app_simulator_to_consume_messages_from_topics(self, app_url, topics): - logger.info("PUT at: " + app_url) - resp = HttpRequests.session_without_env().put(app_url, data={'topics': topics}, timeout=10) + def configure_dcae_app_simulator_to_consume_messages_from_topics(self, topics): + app_url = TOPIC_CONFIGURATION_PATH + logger.info("PUT " + str(topics) + " at: " + app_url) + resp = HttpRequests.session_without_env().put(app_url, data=self.not_escaped(topics), timeout=10) HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME) - def assert_DCAE_app_consumed(self, app_url, expected_messages_amount): + def not_escaped(self, data): + return json.dumps(data) + + def assert_DCAE_app_consumed(self, topic, expected_messages_amount): + app_url = MESSAGES_COUNT_PATH % topic logger.info("GET at: " + app_url) resp = HttpRequests.session_without_env().get(app_url, timeout=10) HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME) @@ -36,28 +54,18 @@ class DcaeAppSimulatorLibrary: assert int(resp.content) == int(expected_messages_amount), \ "Messages consumed by simulator: " + str(resp.content) + " expecting: " + str(expected_messages_amount) - def assert_DCAE_app_consumed_less_equal_than(self, app_url, messages_threshold): - logger.info("GET at: " + app_url) - resp = HttpRequests.session_without_env().get(app_url, timeout=10) - HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME) - - logger.debug("Messages consumed by simulator: " + resp.content + - " expecting more than 0 and less/equal than " + messages_threshold) - - assert 0 < int(resp.content) <= int(messages_threshold), \ - "Messages consumed by simulator: " + str(resp.content) + \ - " expecting more than 0 and less/equal than " + str(messages_threshold) - - def reset_DCAE_app_simulator(self, app_url): + def reset_DCAE_app_simulator(self, topic): + app_url = MESSAGES_RESET_PATH % topic logger.info("DELETE at: " + app_url) resp = HttpRequests.session_without_env().delete(app_url, timeout=10) HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME) - def assert_DCAE_app_consumed_proper_messages(self, app_url, message_filepath): - logger.info("POST at: " + app_url) + def assert_DCAE_app_consumed_proper_messages(self, topic, message_filepath): + app_url = MESSAGES_VALIDATION_PATH % topic file = open(message_filepath, "rb") data = file.read() file.close() + logger.info("POST " + str(data) + "at: " + app_url) resp = HttpRequests.session_without_env().post(app_url, data=data, timeout=10) HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME) diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot b/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot index 985c3793..40923aab 100644 --- a/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot +++ b/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot @@ -42,8 +42,8 @@ Correct Messages Routing Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_FIXED_PAYLOAD_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_25000} - Assert Dcae App Consumed Proper Messages ${DCAE_APP_API_MESSAGES_VALIDATION_URL} ${DCAE_FIXED_PAYLOAD_REQUEST} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_25000} + Assert Dcae App Consumed Proper Messages ${DEFAULT_PERF3GPP_TOPIC} ${DCAE_FIXED_PAYLOAD_REQUEST} Too big payload message handling @@ -52,8 +52,8 @@ Too big payload message handling Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_TOO_BIG_PAYLOAD_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_25000} - Assert Dcae App Consumed Proper Messages ${DCAE_APP_API_MESSAGES_VALIDATION_URL} ${DCAE_TOO_BIG_PAYLOAD_REQUEST} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_25000} + Assert Dcae App Consumed Proper Messages ${DEFAULT_PERF3GPP_TOPIC} ${DCAE_TOO_BIG_PAYLOAD_REQUEST} Invalid wire frame message handling @@ -62,8 +62,8 @@ Invalid wire frame message handling Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_INVALID_WIRE_FRAME_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_50000} - Assert Dcae App Consumed Proper Messages ${DCAE_APP_API_MESSAGES_VALIDATION_URL} ${DCAE_INVALID_WIRE_FRAME_REQUEST} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_50000} + Assert Dcae App Consumed Proper Messages ${DEFAULT_PERF3GPP_TOPIC} ${DCAE_INVALID_WIRE_FRAME_REQUEST} Invalid GPB data message handling @@ -72,8 +72,8 @@ Invalid GPB data message handling Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_INVALID_GPB_DATA_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_50000} - Assert Dcae App Consumed Proper Messages ${DCAE_APP_API_MESSAGES_VALIDATION_URL} ${DCAE_INVALID_GPB_DATA_REQUEST} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_50000} + Assert Dcae App Consumed Proper Messages ${DEFAULT_PERF3GPP_TOPIC} ${DCAE_INVALID_GPB_DATA_REQUEST} Unsupported domain message handling @@ -82,8 +82,8 @@ Unsupported domain message handling Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_UNSUPPORTED_DOMAIN_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_50000} - Assert Dcae App Consumed Proper Messages ${DCAE_APP_API_MESSAGES_VALIDATION_URL} ${DCAE_UNSUPPORTED_DOMAIN_REQUEST} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_50000} + Assert Dcae App Consumed Proper Messages ${DEFAULT_PERF3GPP_TOPIC} ${DCAE_UNSUPPORTED_DOMAIN_REQUEST} *** Variables *** ${HTTP_METHOD_URL} http:// diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/multiple-clients.robot b/tests/dcaegen2-collectors-hv-ves/testcases/multiple-clients.robot index 735a2085..109ec469 100644 --- a/tests/dcaegen2-collectors-hv-ves/testcases/multiple-clients.robot +++ b/tests/dcaegen2-collectors-hv-ves/testcases/multiple-clients.robot @@ -1,7 +1,7 @@ # ============LICENSE_START======================================================= # csit-dcaegen2-collectors-hv-ves # ================================================================================ -# Copyright (C) 2018 NOKIA +# Copyright (C) 2018-2019 NOKIA # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -40,8 +40,8 @@ Handle Multiple Connections Send Messages From xNF Simulators ${SIMULATORS_LIST} ${XNF_SMALLER_PAYLOAD_REQUEST} Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_15000} - Assert Dcae App Consumed Proper Messages ${DCAE_APP_API_MESSAGES_VALIDATION_URL} ${DCAE_SMALLER_PAYLOAD_REQUEST} + ... Assert Dcae App Consumed ${DEFAULT_PERF3GPP_TOPIC} ${AMOUNT_15000} + Assert Dcae App Consumed Proper Messages ${DEFAULT_PERF3GPP_TOPIC} ${DCAE_SMALLER_PAYLOAD_REQUEST} *** Variables *** diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot b/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot index 07e886a0..ecf2d028 100644 --- a/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot +++ b/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot @@ -60,7 +60,7 @@ Send Messages From xNF Simulators VES-HV Collector Test Shutdown - Reset DCAE App Simulator ${DCAE_APP_API_MESSAGE_RESET_URL} + Reset DCAE App Simulator ${DEFAULT_PERF3GPP_TOPIC} VES-HV Collector Suite Teardown -- cgit 1.2.3-korg