Fix for HV-VES TA sunny scenario.

Introducing wait mechanism in test until topic is created after 1st message sent by HV-VES to Kafka.

Issue-ID: INT-650

Change-Id: Ie21bad0a690a39621f9bf49618d0b19e202b2913
Signed-off-by: marekpl <marek.pondel@nokia.com>
diff --git a/robot/resources/test_templates/hvves_template.robot b/robot/resources/test_templates/hvves_template.robot
index 5ee9a02..9924b82 100644
--- a/robot/resources/test_templates/hvves_template.robot
+++ b/robot/resources/test_templates/hvves_template.robot
@@ -4,6 +4,7 @@
 Library     Rammbock
 Library     KafkaLibrary
 Library     BuiltIn
+Library     Collections
 
 *** Variables ***
 ${hvves_message}    0x0a94020a0e73616d706c652d76657273696f6e12087065726633677070180120012a0a70657266334750503232321173616d706c652d6576656e742d6e616d653a1173616d706c652d6576656e742d7479706540f19afddd0548f19afddd05521573616d706c652d6e662d6e616d696e672d636f64655a1673616d706c652d6e66632d6e616d696e672d636f6465621573616d706c652d6e662d76656e646f722d6e616d656a1a73616d706c652d7265706f7274696e672d656e746974792d6964721c73616d706c652d7265706f7274696e672d656e746974792d6e616d657a1073616d706c652d736f757263652d696482010f73616d706c652d786e662d6e616d658a01095554432b30323a3030920105372e302e32120e7465737420746573742074657374
@@ -19,6 +20,14 @@
     Run Keyword If      '${status}' == 'FAIL'   Return From Keyword     0
     Run Keyword If      '${status}' == 'PASS'   Return From Keyword     ${msg_number}
 
+Check If Topic Exists
+    [Documentation]      Checks if specific topic exists on kafka.
+    [Arguments]      ${kafka_server}      ${kafka_port}      ${kafka_topic}
+    [Teardown]      Close
+    Connect Consumer      bootstrap_servers=${kafka_server}:${kafka_port}
+    ${topics}=      Get Kafka Topics
+    List Should Contain Value      ${topics}      ${kafka_topic}
+
 Define WTP Protocol
     [Documentation]     Defines Wire Transfer Protocol.
     New Protocol    WireTransferProtocol
diff --git a/robot/testsuites/hvves.robot b/robot/testsuites/hvves.robot
index b7c718a..49cb9d7 100644
--- a/robot/testsuites/hvves.robot
+++ b/robot/testsuites/hvves.robot
@@ -1,7 +1,7 @@
 *** Settings ***
 Documentation   HV-VES 'Sunny Scenario' Robot Framwork test - message is sent to the collector and Kafka topic is checked if the message has been published.
 Default Tags    HVVES
-Test Timeout    30s
+Test Timeout    10s
 Resource    ${EXECDIR}/robot/resources/global_properties.robot
 Resource    ${EXECDIR}/robot/resources/test_templates/hvves_template.robot
 Suite Teardown  Reset Rammbock
@@ -13,6 +13,7 @@
     ${msg_number_initial}=  Check Number Of Messages On Topic   ${GLOBAL_DNS_MESSAGE_ROUTER_KAFKA_NAME}  ${GLOBAL_MESSAGE_ROUTER_KAFKA_PORT}  ${hvves_kafka_topic}
     Define WTP Protocol
     Start HV-VES TCP Client And Send Message     ${GLOBAL_DNS_HV_VES_NAME}   ${GLOBAL_HV_VES_SERVER_PORT}
+    Wait Until Keyword Succeeds      5s      1s      Check If Topic Exists     ${GLOBAL_DNS_MESSAGE_ROUTER_KAFKA_NAME}      ${GLOBAL_MESSAGE_ROUTER_KAFKA_PORT}      ${hvves_kafka_topic}
     ${msg_number_after}=    Check Number Of Messages On Topic   ${GLOBAL_DNS_MESSAGE_ROUTER_KAFKA_NAME}  ${GLOBAL_MESSAGE_ROUTER_KAFKA_PORT}  ${hvves_kafka_topic}
     Should Not Be Equal As Integers     ${msg_number_initial}   ${msg_number_after}
     Download VesEvent Proto File    ${EXECDIR}