aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/csit/plans/dcaegen2-collectors-hv-ves/testsuites/setup.sh2
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot48
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/hv-ves.robot8
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/ConsulLibrary.py16
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py26
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/HttpRequests.py12
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py34
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/ves-hv-configuration.json9
8 files changed, 152 insertions, 3 deletions
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 48e39807f..72dacf6a2 100755
--- a/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/setup.sh
+++ b/test/csit/plans/dcaegen2-collectors-hv-ves/testsuites/setup.sh
@@ -37,4 +37,4 @@ docker cp ssl/. ${COMPOSE_VES_HV_CONTAINER_NAME}:/etc/ves-hv
# race condition end
-export ROBOT_VARIABLES="--pythonpath ${WORKSPACE}/test/csit/tests/dcaegen2/hv-ves-testcases/libraries" \ No newline at end of file
+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/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot
index e69de29bb..322d17bd2 100644
--- a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/__init__.robot
@@ -0,0 +1,48 @@
+*** Settings ***
+Library DcaeAppSimulatorLibrary
+Library ConsulLibrary
+Library VesHvContainersUtilsLibrary
+
+Suite Setup HV-VES Collector Suites Setup
+
+*** Keywords ***
+HV-VES Collector Suites Setup
+ Log Started Suite: HV-VES
+ Configure collector
+ Configure Dcae App
+ Log Suite setup finished
+
+
+Configure collector
+ ${CONSUL_API_ACCESS}= Get Consul Api Access Url ${HTTP_METHOD_URL} ${CONSUL_CONTAINER_HOST} ${CONSUL_CONTAINER_PORT}
+ ${CONSUL_API_URL}= Catenate SEPARATOR= ${CONSUL_API_ACCESS} ${CONSUL_VES_HV_CONFIGURATION_KEY_PATH}
+ Publish HV VES Configuration In Consul ${CONSUL_API_URL} ${VES_HV_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_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_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}
+
+
+*** Variables ***
+${HTTP_METHOD_URL} http://
+
+${CONSUL_CONTAINER_HOST} consul
+${CONSUL_CONTAINER_PORT} 8500
+${CONSUL_VES_HV_CONFIGURATION_KEY_PATH} /v1/kv/veshv-config
+
+${DCAE_APP_CONTAINER_HOST} dcae-app-simulator
+${DCAE_APP_CONTAINER_PORT} 6063
+${DCAE_APP_API_TOPIC_CONFIGURATION_PATH} /configuration/topics
+${DCAE_APP_API_MESSAGES_PATH} /messages/all
+${DCAE_APP_API_MESSAGES_COUNT_PATH} ${DCAE_APP_API_MESSAGES_PATH}/count
+
+${ROUTED_MESSAGES_TOPIC} test-hv-ran-meas
+
+${VES_HV_RESOURCES} %{WORKSPACE}/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources
+${VES_HV_CONFIGURATION_JSON_FILEPATH} ${VES_HV_RESOURCES}/ves-hv-configuration.json
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
index 36093f449..38ce248d0 100644
--- a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/hv-ves.robot
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/hv-ves.robot
@@ -1,4 +1,8 @@
+*** Settings ***
+Library DcaeAppSimulatorLibrary
+
*** Test Cases ***
Initial testcase
- [Documentation] Testing tests setup script
- Log Robot framework execution successful \ No newline at end of file
+ [Documentation] Testing dcae app connection
+ Wait until keyword succeeds 60 sec 5 sec
+ ... Assert Dcae App Consumed ${DCAE_APP_API_MESSAGES_COUNT_URL} 0
diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/ConsulLibrary.py b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/ConsulLibrary.py
new file mode 100644
index 000000000..52d7e0eab
--- /dev/null
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/ConsulLibrary.py
@@ -0,0 +1,16 @@
+from robot.api import logger
+import HttpRequests
+
+CONSUL_NAME = "Consul"
+
+class ConsulLibrary:
+
+ def publish_hv_ves_configuration_in_consul(self, consul_url, consul_configuration_filepath):
+ logger.info("Reading consul configuration file from: " + consul_configuration_filepath)
+ file = open(consul_configuration_filepath, "rb")
+ data = file.read()
+ file.close()
+
+ logger.info("PUT at: " + consul_url)
+ resp = HttpRequests.session_without_env().put(consul_url, data=data, timeout=5)
+ HttpRequests.checkStatusCode(resp.status_code, CONSUL_NAME) \ No newline at end of file
diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py
new file mode 100644
index 000000000..29e5b5721
--- /dev/null
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/DcaeAppSimulatorLibrary.py
@@ -0,0 +1,26 @@
+import HttpRequests
+from robot.api import logger
+
+DCAE_APP_NAME = "DCAE App"
+
+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=5)
+ HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME)
+
+ def assert_DCAE_app_consumed(self, app_url, expected_messages_amount):
+ logger.info("GET at: " + app_url)
+ resp = HttpRequests.session_without_env().get(app_url, timeout=5)
+ HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME)
+
+ assert resp.content == expected_messages_amount, \
+ "Messages consumed by simulator: " + resp.content + " expecting: " + expected_messages_amount
+
+
+ def reset_DCAE_app_simulator(self, app_url):
+ logger.info("DELETE at: " + app_url)
+ resp = HttpRequests.session_without_env().delete(app_url, timeout=5)
+ HttpRequests.checkStatusCode(resp.status_code, DCAE_APP_NAME)
+
diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/HttpRequests.py b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/HttpRequests.py
new file mode 100644
index 000000000..0d1d928b5
--- /dev/null
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/HttpRequests.py
@@ -0,0 +1,12 @@
+import requests
+from robot.api import logger
+
+def session_without_env():
+ session = requests.Session()
+ session.trust_env = False
+ return session
+
+def checkStatusCode(status_code, server_name):
+ if status_code != 200:
+ logger.error("Response status code from " + server_name + ": " + str(status_code))
+ raise (Exception(server_name + " returned status code " + status_code)) \ No newline at end of file
diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
new file mode 100644
index 000000000..4db04612e
--- /dev/null
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
@@ -0,0 +1,34 @@
+from time import time
+
+from robot.api import logger
+import os.path
+
+LOCALHOST = "localhost"
+
+
+class VesHvContainersUtilsLibrary:
+
+ def get_consul_api_access_url(self, method, image_name, port):
+ return self.create_url(
+ method,
+ self.get_instance_address(image_name, port)
+ )
+
+ def get_dcae_app_api_access_url(self, method, image_name, port):
+ return self.create_url(
+ method,
+ self.get_instance_address(image_name, port)
+ )
+
+ def get_instance_address(self, image_name, port):
+ if is_running_inside_docker():
+ return image_name + ":" + port
+ else:
+ logger.info("File `/.dockerenv` not found. Assuming local environment and using localhost.")
+ return LOCALHOST + ":" + port
+
+ def create_url(self, method, host_address):
+ return method + host_address
+
+def is_running_inside_docker():
+ return os.path.isfile("/.dockerenv")
diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/ves-hv-configuration.json b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/ves-hv-configuration.json
new file mode 100644
index 000000000..3235a0c0e
--- /dev/null
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/resources/ves-hv-configuration.json
@@ -0,0 +1,9 @@
+{
+ "kafkaBootstrapServers": "kafka:9092",
+ "routing": [
+ {
+ "fromDomain": 11,
+ "toTopic": "test-hv-ran-meas"
+ }
+ ]
+} \ No newline at end of file