Attempt to check CSIT
Consul and CBS discovery fix

Change-Id: I0e3ded421b9f285c28a3b5307138adcdec022cca
Issue-ID: INT-989
Signed-off-by: Marcin Migdal <marcin.migdal@nokia.com>
diff --git a/plans/dcaegen2/prh-testsuites/setup.sh b/plans/dcaegen2/prh-testsuites/setup.sh
index 9040ae6..5ce3d0e 100644
--- a/plans/dcaegen2/prh-testsuites/setup.sh
+++ b/plans/dcaegen2/prh-testsuites/setup.sh
@@ -6,6 +6,9 @@
 export SSL_PRH_SERVICE="ssl_prh"
 export DMAAP_SIMULATOR="dmaap_simulator"
 export AAI_SIMULATOR="aai_simulator"
+export CONSUL="consul"
+export CONSUL_CONFIG="consul-cfg"
+export CBS="consul-cfg"
 
 cd ${WORKSPACE}/tests/dcaegen2/prh-testcases/resources/
 
@@ -14,20 +17,30 @@
 pip install -U docker
 docker-compose up -d --build
 
+# Extract docker images IPs
 PRH_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${PRH_SERVICE})
 SSL_PRH_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${SSL_PRH_SERVICE})
 DMAAP_SIMULATOR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${DMAAP_SIMULATOR})
 AAI_SIMULATOR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${AAI_SIMULATOR})
+CONSUL_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${CONSUL})
+CONSUL_CONFIG_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${CONSUL_CONFIG})
+CBS_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${CBS})
 
 bypass_ip_adress ${PRH_IP}
 bypass_ip_adress ${SSL_PRH_IP}
 bypass_ip_adress ${DMAAP_SIMULATOR_IP}
 bypass_ip_adress ${AAI_SIMULATOR_IP}
+bypass_ip_adress ${CONSUL_IP}
+bypass_ip_adress ${CONSUL_CONFIG_IP}
+bypass_ip_adress ${CBS_IP}
 
 echo PRH_IP=${PRH_IP}
 echo SSL_PRH_IP=${SSL_PRH_IP}
 echo DMAAP_SIMULATOR_IP=${DMAAP_SIMULATOR_IP}
 echo AAI_SIMULATOR_IP=${AAI_SIMULATOR_IP}
+echo CONSUL_IP=${CONSUL_IP}
+echo CONSUL_CONFIG_IP=${CONSUL_CONFIG_IP}
+echo CBS_IP=${CBS_IP}
 
 # Wait for initialization of PRH services
 wait_for_service_init localhost:8100/heartbeat
@@ -35,4 +48,3 @@
 
 # #Pass any variables required by Robot test suites in ROBOT_VARIABLES
 ROBOT_VARIABLES="-v DMAAP_SIMULATOR_SETUP:${DMAAP_SIMULATOR_IP}:2224 -v AAI_SIMULATOR_SETUP:${AAI_SIMULATOR_IP}:3335"
-
diff --git a/plans/dcaegen2/prh-testsuites/teardown.sh b/plans/dcaegen2/prh-testsuites/teardown.sh
index 45a3b8b..bb5f8f9 100644
--- a/plans/dcaegen2/prh-testsuites/teardown.sh
+++ b/plans/dcaegen2/prh-testsuites/teardown.sh
@@ -19,3 +19,6 @@
 kill-instance.sh ssl_prh
 kill-instance.sh dmaap_simulator
 kill-instance.sh aai_simulator
+kill-instance.sh consul
+kill-instance.sh consul-cfg
+kill-instance.sh cbs
diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/aai-pnf-registration-simple.json b/tests/dcaegen2/prh-testcases/assets/json_events/aai-pnf-registration-simple.json
new file mode 100644
index 0000000..18f4345
--- /dev/null
+++ b/tests/dcaegen2/prh-testcases/assets/json_events/aai-pnf-registration-simple.json
@@ -0,0 +1,12 @@
+{"pnf-name":"Nokia123",
+  "pnf-name2-source":"",
+  "pnf-id":"Nokia123",
+  "serial-number":"",
+  "equip-type":"FSM-4",
+  "equip-vendor":"",
+  "equip-model":"",
+  "nf-role":"",
+  "management-option":"Nokia-option",
+  "ipaddress-v4-oam": "",
+  "ipaddress-v6-oam": ""
+}
\ No newline at end of file
diff --git a/tests/dcaegen2/prh-testcases/prh_tests.robot b/tests/dcaegen2/prh-testcases/prh_tests.robot
index 31a7d0d..1e9802c 100644
--- a/tests/dcaegen2/prh-testcases/prh_tests.robot
+++ b/tests/dcaegen2/prh-testcases/prh_tests.robot
@@ -13,6 +13,7 @@
 ${AAI_SIMULATOR_SETUP_URL}    http://${AAI_SIMULATOR_SETUP}
 
 ${VES_EVENT_PNF_REGISTRATION_SIMPLE}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/ves-event-pnf-registration-simple.json
+${AAI_PNF_REGISTRATION_SIMPLE}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/aai-pnf-registration-simple.json
 ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json
 ${EVENT_WITH_IPV4}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json
 ${EVENT_WITH_IPV6}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json
@@ -29,11 +30,11 @@
 ${Not_json_format}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json
 
 *** Test Cases ***
-Valid DMaaP event can be converted to PNF_READY notification
+Process valid simple PNF Registration DMaaP event which can be converted to PNF_READY notification
     [Documentation]    PRH get valid event from DMaaP with required fields - PRH produce PNF_READY notification
     [Tags]    PRH    Valid event
     [Template]    Valid event processing
-    ${VES_EVENT_PNF_REGISTRATION_SIMPLE}
+    ${VES_EVENT_PNF_REGISTRATION_SIMPLE}    ${AAI_PNF_REGISTRATION_SIMPLE}
     #${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
     #${EVENT_WITH_IPV4}
     #${EVENT_WITH_IPV6}
diff --git a/tests/dcaegen2/prh-testcases/resources/docker-compose.yml b/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
index 45c71dc..aca9d6a 100644
--- a/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
+++ b/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
@@ -60,6 +60,7 @@
     command: ["agent", "-bootstrap", "-client=0.0.0.0", "-server", "-ui", "-config-dir=/consul/consul.d"]
     volumes:
       - ./consul.d/:/consul/consul.d
+    container_name: consul
 
   consul-cfg:
     image: consul:1.0.6
@@ -145,6 +146,7 @@
                                               }
                                             }'
     ]
+    container_name: consul-cfg
     depends_on:
       - consul
 
@@ -156,3 +158,4 @@
       - CONSUL_HOST
     depends_on:
       - consul-cfg
+    container_name: cbs
\ No newline at end of file
diff --git a/tests/dcaegen2/prh-testcases/resources/prh_library.robot b/tests/dcaegen2/prh-testcases/resources/prh_library.robot
index c231185..9b7e783 100644
--- a/tests/dcaegen2/prh-testcases/resources/prh_library.robot
+++ b/tests/dcaegen2/prh-testcases/resources/prh_library.robot
@@ -30,15 +30,18 @@
     #Wait Until Keyword Succeeds    100x    100ms    Check PRH log    ${notification}
 
 Valid event processing
-    [Arguments]    ${input_valid__ves_event_in_dmaap}
+    [Arguments]    ${input_valid__ves_event_in_dmaap}    ${input_aai}
     [Timeout]    30s
     ${data}=    Get Data From File    ${input_valid__ves_event_in_dmaap}
+    ${aai_entry_to_be_set}=    Get Data From File    ${input_aai}
     Set event in DMaaP    ${data}
     ${pnf_name}=    Create PNF name    ${data}
     Set PNF name in AAI    ${pnf_name}
+    Set PNF content in AAI    ${aai_entry_to_be_set}
     ${expected_event_pnf_ready_in_dpaap}=    create pnf ready_notification as pnf ready    ${data}
     #TODO to fix after CBS merge
-    #Wait Until Keyword Succeeds    100x    300ms    Check PNF_READY notification    ${expected_event_pnf_ready_in_dpaap}
+    #Wait Until Keyword Succeeds    10x    300ms    Check PNF_READY notification    ${expected_event_pnf_ready_in_dpaap}
+    #Wait Until Keyword Succeeds    10x    5000ms    Check PRH log    Mandingo
 
 Check PRH log
     [Arguments]    ${searched_log}
@@ -59,6 +62,15 @@
     ${resp}=    Put Request    ${aai_setup_session}    /set_pnf    headers=${headers}    data=${pnf_name}
     Should Be Equal As Strings    ${resp.status_code}    200
 
+Set PNF content in AAI
+    [Arguments]    ${aai_pnf_content}
+    ${headers}=    Create Dictionary    Accept=application/json    Content-Type=text/html
+    Log    AAI url ${AAI_SIMULATOR_SETUP_URL}
+    Log    Http headers ${headers}
+    Log    PNF AAI content ${aai_pnf_content}
+    ${resp}=    Put Request    ${aai_setup_session}    /setup/add_pnf_entry    headers=${headers}    data=${aai_pnf_content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
 Set event in DMaaP
     [Arguments]    ${event_in_dmaap}
     ${resp}=    Put Request    ${dmaap_setup_session}    /set_get_event    headers=${suite_headers}    data=${event_in_dmaap}
diff --git a/tests/dcaegen2/prh-testcases/ssl_prh_tests.robot b/tests/dcaegen2/prh-testcases/ssl_prh_tests.robot
index 111a4fb..be260bd 100644
--- a/tests/dcaegen2/prh-testcases/ssl_prh_tests.robot
+++ b/tests/dcaegen2/prh-testcases/ssl_prh_tests.robot
@@ -13,6 +13,7 @@
 ${AAI_SIMULATOR_SETUP_URL}    http://${AAI_SIMULATOR_SETUP}
 
 ${VES_EVENT_PNF_REGISTRATION_SIMPLE}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/ves-event-pnf-registration-simple.json
+${AAI_PNF_REGISTRATION_SIMPLE}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/aai-pnf-registration-simple.json
 ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json
 ${EVENT_WITH_IPV4}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json
 ${EVENT_WITH_IPV6}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json
@@ -23,7 +24,7 @@
     [Documentation]    PRH get valid event from DMaaP with required fields - PRH produce PNF_READY notification
     [Tags]    PRH    Valid event
     [Template]    Valid event processing
-    ${VES_EVENT_PNF_REGISTRATION_SIMPLE}
+    ${VES_EVENT_PNF_REGISTRATION_SIMPLE}    ${AAI_PNF_REGISTRATION_SIMPLE}
     #${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
     #${EVENT_WITH_IPV4}
     #${EVENT_WITH_IPV6}