From bc1f8967c878f9075cd915569a0d7bb392c2d71f Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Mon, 3 Sep 2018 11:05:11 +0200 Subject: Remove race condition - moved containers logs to separate folder in archives to allow easier debugging. Also saved xNF simulators logs there as they are not specified in docker-compose file - renamed message-routing test file as it's name was accidentaly set during one of rebases - fixed bug where variables passed from Robot testcase were evaluated as strings instead of booleans Change-Id: If21c3983df0869bbc7b8378f3bf5344cad05350b Issue-ID: DCAEGEN2-664 Signed-off-by: Filip Krzywka --- .../dcaegen2-collectors-hv-ves/testsuites/setup.sh | 10 +- .../testsuites/teardown.sh | 2 +- .../testcases/hv-ves.robot | 118 --------------------- .../testcases/libraries/XnfSimulatorLibrary.py | 66 ++++++------ .../testcases/message-routing.robot | 93 ++++++++++++++++ .../testcases/resources/common-keywords.robot | 6 +- 6 files changed, 132 insertions(+), 163 deletions(-) delete mode 100644 test/csit/tests/dcaegen2-collectors-hv-ves/testcases/hv-ves.robot create mode 100644 test/csit/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot (limited to 'test/csit') diff --git a/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/setup.sh b/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/setup.sh index 72dacf6a2..6b527fc22 100755 --- a/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/setup.sh +++ b/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/setup.sh @@ -25,16 +25,8 @@ make FILE=invalid_client CA=invalid_trust cd .. export DOCKER_REGISTRY="nexus3.onap.org:10001" -CURRENT_DIR=${PWD##*/} -VES_HV_CONTAINER_NAME=ves-hv-collector - -# little race condition between container start-up and required files copying below docker-compose up -d -COMPOSE_VES_HV_CONTAINER_NAME=${CURRENT_DIR}_${VES_HV_CONTAINER_NAME}_1 -echo "COPY tls authorization files to container: ${COMPOSE_VES_HV_CONTAINER_NAME}" -docker cp ssl/. ${COMPOSE_VES_HV_CONTAINER_NAME}:/etc/ves-hv -# race condition end - +mkdir ${WORKSPACE}/archives/containers_logs export ROBOT_VARIABLES="--pythonpath ${WORKSPACE}/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries" \ No newline at end of file diff --git a/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/teardown.sh b/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/teardown.sh index 91ad90305..84d36667e 100755 --- a/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/teardown.sh +++ b/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/teardown.sh @@ -4,7 +4,7 @@ cd ssl make clean cd .. -docker-compose logs > ${WORKSPACE}/archives/docker-compose.log +docker-compose logs > ${WORKSPACE}/archives/containers_logs/docker-compose.log docker-compose down docker-compose rm -f diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/hv-ves.robot b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/hv-ves.robot deleted file mode 100644 index 482b698fe..000000000 --- a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/hv-ves.robot +++ /dev/null @@ -1,118 +0,0 @@ -*** Settings *** -Library DcaeAppSimulatorLibrary -Library XnfSimulatorLibrary -Library VesHvContainersUtilsLibrary -Library Collections - -Suite Setup Message Routing Suite Setup -Suite Teardown VES-HV Collector Suite Teardown -Test Teardown VES-HV Collector Test Shutdown - -*** Test Cases *** -Correct Messages Routing - [Documentation] VES-HV Collector should route all valid messages to topics specified in configuration - ... and do not change message payload generated in XNF simulator - - ${SIMULATORS_LIST}= Get xNF Simulators 1 - Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} - - -Too big payload message handling - [Documentation] VES-HV Collector should interrupt the stream when encountered message with too big payload - - ${SIMULATORS_LIST}= Get xNF Simulators 1 - Send Messages From xNF Simulators ${SIMULATORS_LIST} ${XNF_TOO_BIG_PAYLOAD_REQUEST} - - Wait until keyword succeeds 60 sec 5 sec - ... Assert Dcae App Consumed Less Equal Than ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_25000} - - -Invalid wire frame message handling - [Documentation] VES-HV Collector should skip messages with invalid wire frame - - ${SIMULATORS_LIST}= Get xNF Simulators 1 - Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} - - -Invalid GPB data message handling - [Documentation] VES-HV Collector should skip messages with invalid GPB data - - ${SIMULATORS_LIST}= Get xNF Simulators 1 - Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} - - -Unsupported domain message handling - [Documentation] VES-HV Collector should skip messages with unsupported domain - - ${SIMULATORS_LIST}= Get xNF Simulators 1 - Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} - -*** Keywords *** -Message Routing Suite Setup - Log Started Suite: VES-HV Message Routing - ${XNF_PORTS_LIST}= Create List 7000 - Configure xNF Simulators On Ports ${XNF_PORTS_LIST} - Log Suite setup finished - -Configure xNF Simulators On Ports - [Arguments] ${XNF_PORTS_LIST} - ${XNF_SIMULATORS_ADDRESSES}= Start Xnf Simulators ${XNF_PORTS_LIST} True - Set Suite Variable ${XNF_SIMULATORS_ADDRESSES} - - -Get xNF Simulators - [Arguments] ${AMOUNT} - ${SIMULATORS}= Get Slice From List ${XNF_SIMULATORS_ADDRESSES} 0 ${AMOUNT} - [Return] ${SIMULATORS} - - -Send Messages From xNF Simulators - [Arguments] ${XNF_HOSTS_LIST} ${MESSAGE_FILEPATH} - :FOR ${HOST} IN @{XNF_HOSTS_LIST} - \ ${XNF_SIM_API_ACCESS}= Get xNF Sim Api Access Url ${HTTP_METHOD_URL} ${HOST} - \ ${XNF_SIM_API_URL}= Catenate SEPARATOR= ${XNF_SIM_API_ACCESS} ${XNF_SIM_API_PATH} - \ Send messages ${XNF_SIM_API_URL} ${MESSAGE_FILEPATH} - - -VES-HV Collector Test Shutdown - Reset DCAE App Simulator ${DCAE_APP_API_MESSAGE_RESET_URL} - - -VES-HV Collector Suite Teardown - Stop And Remove All Xnf Simulators - -*** Variables *** -${HTTP_METHOD_URL} http:// - -${XNF_SIM_API_PATH} /simulator/async - -${VES_HV_SCENARIOS} %{WORKSPACE}/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/scenarios -${XNF_FIXED_PAYLOAD_REQUEST} ${VES_HV_SCENARIOS}/fixed-payload/xnf-fixed-payload-request.json -${XNF_TOO_BIG_PAYLOAD_REQUEST} ${VES_HV_SCENARIOS}/too-big-payload/xnf-too-big-payload-request.json -${XNF_INVALID_WIRE_FRAME_REQUEST} ${VES_HV_SCENARIOS}/invalid-wire-frame/xnf-invalid-wire-frame-request.json -${XNF_INVALID_GPB_DATA_REQUEST} ${VES_HV_SCENARIOS}/invalid-gpb-data/xnf-invalid-gpb-data-request.json -${XNF_UNSUPPORTED_DOMAIN_REQUEST} ${VES_HV_SCENARIOS}/unsupported-domain/xnf-unsupported-domain-request.json - -${DCAE_FIXED_PAYLOAD_REQUEST} ${VES_HV_SCENARIOS}/fixed-payload/dcae-fixed-payload-request.json -${DCAE_INVALID_WIRE_FRAME_REQUEST} ${VES_HV_SCENARIOS}/invalid-wire-frame/dcae-invalid-wire-frame-request.json -${DCAE_INVALID_GPB_DATA_REQUEST} ${VES_HV_SCENARIOS}/invalid-gpb-data/dcae-invalid-gpb-data-request.json -${DCAE_UNSUPPORTED_DOMAIN_REQUEST} ${VES_HV_SCENARIOS}/unsupported-domain/dcae-unsupported-domain-request.json - -${AMOUNT_25000} 25000 -${AMOUNT_50000} 50000 diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/XnfSimulatorLibrary.py b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/XnfSimulatorLibrary.py index d85eb4dee..b2466d7ca 100644 --- a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/XnfSimulatorLibrary.py +++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/XnfSimulatorLibrary.py @@ -8,9 +8,12 @@ from time import sleep XNF_SIMULATOR_NAME = "xNF Simulator" SIMULATOR_IMAGE_NAME = "onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-xnf-simulator" SIMULATOR_IMAGE_FULL_NAME = os.getenv("DOCKER_REGISTRY") + "/" + SIMULATOR_IMAGE_NAME + ":latest" -certificates_dir_path = os.getenv("WORKSPACE") + "/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/ssl/" +WORKSPACE_ENV = os.getenv("WORKSPACE") +certificates_dir_path = WORKSPACE_ENV + "/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/ssl/" +collector_certs_lookup_dir = "/etc/ves-hv/" ONE_SECOND_IN_NANOS = 10 ** 9 + class XnfSimulatorLibrary: def start_xnf_simulators(self, list_of_ports, valid_certs=True): @@ -36,48 +39,43 @@ class XnfSimulatorLibrary: simulators_addresses = [] for port in list_of_ports: container = self.run_simulator(dockerClient, port, - "/etc/ves-hv/" + cert_name_prefix + "client.crt", - "/etc/ves-hv/" + cert_name_prefix + "client.key", - "/etc/ves-hv/" + cert_name_prefix + "trust.crt" + collector_certs_lookup_dir + cert_name_prefix + "client.crt", + collector_certs_lookup_dir + cert_name_prefix + "client.key", + collector_certs_lookup_dir + cert_name_prefix + "trust.crt" ) - self.copy_required_certificates_into_simulator(container) logger.info("Started container: " + container.name + " " + container.id) simulators_addresses.append(container.name + ":" + port) return simulators_addresses def run_simulator(self, dockerClient, port, client_crt_path, client_key_path, client_trust_store): + xNF_startup_command = ["--listen-port", port, + "--ves-host", "ves-hv-collector", + "--ves-port", "6061", + "--cert-file", client_crt_path, + "--private-key-file", client_key_path, + "--trust-cert-file", client_trust_store] + xNF_healthcheck_command = { + "interval": 5 * ONE_SECOND_IN_NANOS, + "timeout": 3 * ONE_SECOND_IN_NANOS, + "retries": 1, + "test": ["CMD", "curl", "--request", "GET", + "--fail", "--silent", "--show-error", + "localhost:" + port + "/healthcheck"] + } + logger.info("Startup command: " + str(xNF_startup_command)) + logger.info("Healthcheck command: " + str(xNF_healthcheck_command)) return dockerClient.containers.run(SIMULATOR_IMAGE_FULL_NAME, - command=["--listen-port", port, - "--ves-host", "ves-hv-collector", - "--ves-port", "6061", - "--cert-file", client_crt_path, - "--private-key-file", client_key_path, - "--trust-cert-file", client_trust_store - ], - healthcheck={ - "interval": 5 * ONE_SECOND_IN_NANOS, - "timeout": 3 * ONE_SECOND_IN_NANOS, - "retries": 1, - "test": ["CMD", "curl", "--request", "GET", - "--fail", "--silent", "--show-error", - "localhost:" + port + "/healthcheck"] - }, + command=xNF_startup_command, + healthcheck=xNF_healthcheck_command, detach=True, network="ves-hv-default", ports={port + "/tcp": port}, + volumes=self.container_volumes(), name="ves-hv-collector-xnf-simulator" + port) - def copy_required_certificates_into_simulator(self, container): - container.exec_run("mkdir -p /etc/ves-hv") - copy_to_container(container.id, [ - certificates_dir_path + "client.crt", - certificates_dir_path + "client.key", - certificates_dir_path + "trust.crt", - certificates_dir_path + "invalid_client.crt", - certificates_dir_path + "invalid_client.key", - certificates_dir_path + "invalid_trust.crt", - ]) + def container_volumes(self): + return {certificates_dir_path: {"bind": collector_certs_lookup_dir, "mode": 'rw'}} def assert_containers_startup_was_successful(self, dockerClient): checks_amount = 6 @@ -95,11 +93,15 @@ class XnfSimulatorLibrary: container_health = container.attrs['State']['Health']['Status'] return container_health == 'healthy' and container.status == 'running' - def stop_and_remove_all_xnf_simulators(self): + def stop_and_remove_all_xnf_simulators(self, suite_name): dockerClient = docker.from_env() for container in self.get_simulators_list(dockerClient): logger.info("Stopping and removing container: " + container.id) - logger.debug(container.logs()) + log_filename = WORKSPACE_ENV + "/archives/containers_logs/" + \ + suite_name.split(".")[-1] + "_" + container.name + ".log" + file = open(log_filename, "w+") + file.write(container.logs()) + file.close() container.stop() container.remove() dockerClient.close() diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot new file mode 100644 index 000000000..6153afa0a --- /dev/null +++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot @@ -0,0 +1,93 @@ +*** Settings *** +Library DcaeAppSimulatorLibrary +Library XnfSimulatorLibrary +Library VesHvContainersUtilsLibrary +Library Collections + +Resource resources/common-keywords.robot + +Suite Setup Message Routing Suite Setup +Suite Teardown VES-HV Collector Suite Teardown +Test Teardown VES-HV Collector Test Shutdown + +*** Keywords *** +Message Routing Suite Setup + Log Started Suite: VES-HV Message Routing + ${XNF_PORTS_LIST}= Create List 7000 + Configure Valid xNF Simulators On Ports ${XNF_PORTS_LIST} + Log Suite setup finished + +*** Test Cases *** +Correct Messages Routing + [Documentation] VES-HV Collector should route all valid messages to topics specified in configuration + ... and do not change message payload generated in XNF simulator + + ${SIMULATORS_LIST}= Get Valid xNF Simulators 1 + Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} + + +Too big payload message handling + [Documentation] VES-HV Collector should interrupt the stream when encountered message with too big payload + + ${SIMULATORS_LIST}= Get Valid xNF Simulators 1 + Send Messages From xNF Simulators ${SIMULATORS_LIST} ${XNF_TOO_BIG_PAYLOAD_REQUEST} + + Wait until keyword succeeds 60 sec 5 sec + ... Assert Dcae App Consumed Less Equal Than ${DCAE_APP_API_MESSAGES_COUNT_URL} ${AMOUNT_25000} + + +Invalid wire frame message handling + [Documentation] VES-HV Collector should skip messages with invalid wire frame + + ${SIMULATORS_LIST}= Get Valid xNF Simulators 1 + Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} + + +Invalid GPB data message handling + [Documentation] VES-HV Collector should skip messages with invalid GPB data + + ${SIMULATORS_LIST}= Get Valid xNF Simulators 1 + Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} + + +Unsupported domain message handling + [Documentation] VES-HV Collector should skip messages with unsupported domain + + ${SIMULATORS_LIST}= Get Valid xNF Simulators 1 + Send Messages From xNF Simulators ${SIMULATORS_LIST} ${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} + +*** Variables *** +${HTTP_METHOD_URL} http:// + +${XNF_SIM_API_PATH} /simulator/async + +${VES_HV_SCENARIOS} %{WORKSPACE}/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/scenarios +${XNF_FIXED_PAYLOAD_REQUEST} ${VES_HV_SCENARIOS}/fixed-payload/xnf-fixed-payload-request.json +${XNF_TOO_BIG_PAYLOAD_REQUEST} ${VES_HV_SCENARIOS}/too-big-payload/xnf-too-big-payload-request.json +${XNF_INVALID_WIRE_FRAME_REQUEST} ${VES_HV_SCENARIOS}/invalid-wire-frame/xnf-invalid-wire-frame-request.json +${XNF_INVALID_GPB_DATA_REQUEST} ${VES_HV_SCENARIOS}/invalid-gpb-data/xnf-invalid-gpb-data-request.json +${XNF_UNSUPPORTED_DOMAIN_REQUEST} ${VES_HV_SCENARIOS}/unsupported-domain/xnf-unsupported-domain-request.json + +${DCAE_FIXED_PAYLOAD_REQUEST} ${VES_HV_SCENARIOS}/fixed-payload/dcae-fixed-payload-request.json +${DCAE_INVALID_WIRE_FRAME_REQUEST} ${VES_HV_SCENARIOS}/invalid-wire-frame/dcae-invalid-wire-frame-request.json +${DCAE_INVALID_GPB_DATA_REQUEST} ${VES_HV_SCENARIOS}/invalid-gpb-data/dcae-invalid-gpb-data-request.json +${DCAE_UNSUPPORTED_DOMAIN_REQUEST} ${VES_HV_SCENARIOS}/unsupported-domain/dcae-unsupported-domain-request.json + +${AMOUNT_25000} 25000 +${AMOUNT_50000} 50000 diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot index 345118657..bc03de232 100644 --- a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot +++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot @@ -6,13 +6,13 @@ Library Collections *** Keywords *** Configure Valid xNF Simulators On Ports [Arguments] ${XNF_PORTS_LIST} - ${VALID_XNF_SIMULATORS_ADDRESSES}= Start Xnf Simulators ${XNF_PORTS_LIST} True + ${VALID_XNF_SIMULATORS_ADDRESSES}= Start Xnf Simulators ${XNF_PORTS_LIST} ${true} Set Suite Variable ${VALID_XNF_SIMULATORS_ADDRESSES} Configure Invalid xNF Simulators On Ports [Arguments] ${XNF_PORTS_LIST} - ${INVALID_XNF_SIMULATORS_ADDRESSES}= Start Xnf Simulators ${XNF_PORTS_LIST} False + ${INVALID_XNF_SIMULATORS_ADDRESSES}= Start Xnf Simulators ${XNF_PORTS_LIST} ${false} Set Suite Variable ${INVALID_XNF_SIMULATORS_ADDRESSES} @@ -41,7 +41,7 @@ VES-HV Collector Test Shutdown VES-HV Collector Suite Teardown - Stop And Remove All Xnf Simulators + Stop And Remove All Xnf Simulators ${SUITE NAME} *** Variables *** ${HTTP_METHOD_URL} http:// -- cgit 1.2.3-korg