aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dcaegen2-collectors-hv-ves
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dcaegen2-collectors-hv-ves')
-rw-r--r--tests/dcaegen2-collectors-hv-ves/testcases/libraries/KafkaLibrary.py61
-rw-r--r--tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot8
-rw-r--r--tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot10
3 files changed, 71 insertions, 8 deletions
diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/libraries/KafkaLibrary.py b/tests/dcaegen2-collectors-hv-ves/testcases/libraries/KafkaLibrary.py
new file mode 100644
index 00000000..e262ff01
--- /dev/null
+++ b/tests/dcaegen2-collectors-hv-ves/testcases/libraries/KafkaLibrary.py
@@ -0,0 +1,61 @@
+# ============LICENSE_START====================================
+# csit-dcaegen2-collectors-hv-ves
+# =========================================================
+# Copyright (C) 2019 Nokia. All rights reserved.
+# =========================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=====================================
+
+import docker
+from robot.api import logger
+
+KAFKA_IMAGE_FULL_NAME = "wurstmeister/kafka"
+KAFKA_ADDRESS = "kafka:9092"
+ZOOKEEPER_ADDRESS = "zookeeper:2181"
+
+LIST_TOPICS_COMMAND = "kafka-topics.sh --list --zookeeper %s" % ZOOKEEPER_ADDRESS
+TOPIC_STATUS_COMMAND = "kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list " + KAFKA_ADDRESS + " --topic %s --time -1"
+DELETE_TOPIC_COMMAND = "kafka-topics.sh --zookeeper " + ZOOKEEPER_ADDRESS + " --delete --topic %s"
+
+
+class KafkaLibrary:
+
+ def log_kafka_status(self):
+ dockerClient = docker.from_env()
+ kafka = dockerClient.containers.list(filters={"ancestor": KAFKA_IMAGE_FULL_NAME}, all=True)[0]
+
+ topics = self.get_topics(kafka)
+ logger.info("Topics initialized in Kafka cluster: " + str(topics))
+ for topic in topics:
+ if topic == "__consumer_offsets":
+ # kafka-internal topic, ignore it
+ continue
+
+ self.log_topic_status(kafka, topic)
+ self.reset_topic(kafka, topic)
+
+ dockerClient.close()
+
+ def get_topics(self, kafka):
+ exitCode, output = kafka.exec_run(LIST_TOPICS_COMMAND)
+ return output.splitlines()
+
+ def log_topic_status(self, kafka, topic):
+ _, topic_status = kafka.exec_run(TOPIC_STATUS_COMMAND % topic)
+ logger.info("Messages on topic: " + str(topic_status))
+
+ def reset_topic(self, kafka, topic):
+ logger.info("Removing topic " + str(
+ topic) + " (note that it will be recreated by dcae-app-simulator/hv-ves-collector, however the offset will be reseted)")
+ _, output = kafka.exec_run(DELETE_TOPIC_COMMAND % topic)
+ logger.info(str(output))
diff --git a/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot b/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot
index 2fab3295..985c3793 100644
--- a/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot
+++ b/tests/dcaegen2-collectors-hv-ves/testcases/message-routing.robot
@@ -31,8 +31,7 @@ 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 xNF Simulators Using Valid Certificates On Ports ${XNF_PORTS_LIST}
+ Configure Single xNF Simulator
Log Suite setup finished
*** Test Cases ***
@@ -40,7 +39,6 @@ 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
- ${XNF_SIMULATOR}= Get xNF Simulators Using Valid Certificates
Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_FIXED_PAYLOAD_REQUEST}
Wait until keyword succeeds 60 sec 5 sec
@@ -51,7 +49,6 @@ Correct Messages Routing
Too big payload message handling
[Documentation] VES-HV Collector should interrupt the stream when encountered message with too big payload
- ${XNF_SIMULATOR}= Get xNF Simulators Using Valid Certificates
Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_TOO_BIG_PAYLOAD_REQUEST}
Wait until keyword succeeds 60 sec 5 sec
@@ -62,7 +59,6 @@ Too big payload message handling
Invalid wire frame message handling
[Documentation] VES-HV Collector should skip messages with invalid wire frame
- ${XNF_SIMULATOR}= Get xNF Simulators Using Valid Certificates
Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_INVALID_WIRE_FRAME_REQUEST}
Wait until keyword succeeds 60 sec 5 sec
@@ -73,7 +69,6 @@ Invalid wire frame message handling
Invalid GPB data message handling
[Documentation] VES-HV Collector should skip messages with invalid GPB data
- ${XNF_SIMULATOR}= Get xNF Simulators Using Valid Certificates
Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_INVALID_GPB_DATA_REQUEST}
Wait until keyword succeeds 60 sec 5 sec
@@ -84,7 +79,6 @@ Invalid GPB data message handling
Unsupported domain message handling
[Documentation] VES-HV Collector should skip messages with unsupported domain
- ${XNF_SIMULATOR}= Get xNF Simulators Using Valid Certificates
Send Messages From xNF Simulators ${XNF_SIMULATOR} ${XNF_UNSUPPORTED_DOMAIN_REQUEST}
Wait until keyword succeeds 60 sec 5 sec
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 3a37c9b0..07e886a0 100644
--- a/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.robot
+++ b/tests/dcaegen2-collectors-hv-ves/testcases/resources/common-keywords.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.
@@ -19,9 +19,16 @@
*** Settings ***
Library XnfSimulatorLibrary
Library VesHvContainersUtilsLibrary
+Library KafkaLibrary
Library Collections
*** Keywords ***
+Configure Single xNF Simulator
+ ${XNF_PORTS_LIST}= Create List 7000
+ ${XNF_SIMULATORS_ADDRESSES}= Configure xNF Simulators ${XNF_PORTS_LIST}
+ ${XNF_SIMULATOR}= Get Slice From List ${XNF_SIMULATORS_ADDRESSES} 0 1
+ Set Suite Variable ${XNF_SIMULATOR}
+
Configure xNF Simulators Using Valid Certificates On Ports
[Arguments] ${XNF_PORTS_LIST}
${VALID_XNF_SIMULATORS_ADDRESSES}= Configure xNF Simulators ${XNF_PORTS_LIST}
@@ -57,6 +64,7 @@ VES-HV Collector Test Shutdown
VES-HV Collector Suite Teardown
+ Log Kafka Status
Stop And Remove All Xnf Simulators ${SUITE NAME}
*** Variables ***