[PMSH] Update CSITs to use DMaaP MR

Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Change-Id: I1be0373cffde124a4a20cf0530cd756389eec532
Issue-ID: DCAEGEN2-2186
diff --git a/plans/dcaegen2-services-pmsh/testsuite/assets/cbs_sim/cbs-initializer.json b/plans/dcaegen2-services-pmsh/testsuite/assets/cbs_sim/cbs-initializer.json
index 8caf200..5b6e6fe 100644
--- a/plans/dcaegen2-services-pmsh/testsuite/assets/cbs_sim/cbs-initializer.json
+++ b/plans/dcaegen2-services-pmsh/testsuite/assets/cbs_sim/cbs-initializer.json
@@ -86,7 +86,7 @@
                 "dmaap_info": {
                   "client_id": "1475976809466",
                   "client_role": "org.onap.dcae.pmPublisher",
-                  "topic_url": "https://mr-sim:3095/events/unauthenticated.DCAE_CL_OUTPUT",
+                  "topic_url": "http://dmaap:3904/events/unauthenticated.DCAE_CL_OUTPUT",
                   "location": "san-francisco"
                 },
                 "type": "message_router"
@@ -98,14 +98,14 @@
                 "dmaap_info": {
                   "client_id": "1575976809466",
                   "client_role": "org.onap.dcae.aaiSub",
-                  "topic_url": "https://mr-sim:3095/events/AAI_EVENT",
+                  "topic_url": "http://dmaap:3904/events/AAI_EVENT",
                   "location": "san-francisco"
                 }
               },
               "policy_pm_subscriber": {
                 "dmaap_info": {
                   "location": "san-francisco",
-                  "topic_url": "https://mr-sim:3095/events/unauthenticated.PMSH_CL_INPUT",
+                  "topic_url": "http://dmaap:3904/events/unauthenticated.PMSH_CL_INPUT",
                   "client_role": "org.onap.dcae.pmSubscriber",
                   "client_id": "1575876809456"
                 },
diff --git a/plans/dcaegen2-services-pmsh/testsuite/assets/mr_sim/mr-initializer.json b/plans/dcaegen2-services-pmsh/testsuite/assets/mr_sim/mr-initializer.json
deleted file mode 100644
index 6c2c480..0000000
--- a/plans/dcaegen2-services-pmsh/testsuite/assets/mr_sim/mr-initializer.json
+++ /dev/null
@@ -1,53 +0,0 @@
-[
-  {
-    "httpRequest": {
-      "path": "/events/AAI_EVENT/.*",
-      "queryStringParameters" : {
-        "timeout" : [ "1000" ]
-      }
-    },
-    "httpResponse": {
-      "statusCode": 200,
-      "headers": {
-        "content-type": [
-          "application/json"
-        ]
-      },
-      "body": []
-    }
-  },
-  {
-    "httpRequest": {
-      "path": "/events/unauthenticated.DCAE_CL_OUTPUT",
-      "queryStringParameters" : {
-        "timeout" : [ "1000" ]
-      }
-    },
-    "httpResponse": {
-      "statusCode": 200,
-      "headers": {
-        "content-type": [
-          "application/json"
-        ]
-      },
-      "body": []
-    }
-  },
-  {
-    "httpRequest": {
-      "path": "/events/unauthenticated.PMSH_CL_INPUT/.*",
-      "queryStringParameters" : {
-        "timeout" : [ "1000" ]
-      }
-    },
-    "httpResponse": {
-      "statusCode": 200,
-      "headers": {
-        "content-type": [
-          "application/json"
-        ]
-      },
-      "body": []
-    }
-  }
-]
diff --git a/plans/dcaegen2-services-pmsh/testsuite/assets/mr_sim/mr_mockserver.properties b/plans/dcaegen2-services-pmsh/testsuite/assets/mr_sim/mr_mockserver.properties
deleted file mode 100644
index 9c59230..0000000
--- a/plans/dcaegen2-services-pmsh/testsuite/assets/mr_sim/mr_mockserver.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#######################################
-# MockServer & Proxy Example Settings #
-#######################################
-
-# Socket & Port Settings
-
-# socket timeout in milliseconds (default 120000)
-mockserver.maxSocketTimeout=120000
-
-# Certificate Generation
-
-# delete KeyStore file on JVM shutdown (default true)
-mockserver.deleteGeneratedKeyStoreOnExit=true
-# certificate domain name (default "localhost")
-mockserver.sslCertificateDomainName=localhost
-# comma separated list of domain names for Subject Alternative Name domain names (default empty list)
-mockserver.sslSubjectAlternativeNameDomains=www.example.com,www.another.com
-# comma separated list of ip addresses for Subject Alternative Name ips (default empty list)
-mockserver.sslSubjectAlternativeNameIps=127.0.0.1
-
-# CORS
-
-# enable CORS for MockServer REST API
-mockserver.enableCORSForAPI=true
-# enable CORS for all responses
-mockserver.enableCORSForAllResponses=true
diff --git a/plans/dcaegen2-services-pmsh/testsuite/docker-compose.yml b/plans/dcaegen2-services-pmsh/testsuite/docker-compose.yml
index 6df60f1..6541ddb 100644
--- a/plans/dcaegen2-services-pmsh/testsuite/docker-compose.yml
+++ b/plans/dcaegen2-services-pmsh/testsuite/docker-compose.yml
@@ -9,7 +9,9 @@
       POSTGRES_PASSWORD: $DB_PASSWORD
       POSTGRES_USER: $DB_USER
     networks:
-      pmsh-network:
+      dockercompose_net:
+        aliases:
+        - db
 
   aai:
     container_name: aai-sim
@@ -24,7 +26,9 @@
       - ./assets/ssl_certs/mock_server_cacert.pem:/var/tmp/mock_server_cacert.pem
       - ./assets/ssl_certs/mock_server_key.pem:/var/tmp/mock_server_key.pem
     networks:
-      pmsh-network:
+      dockercompose_net:
+        aliases:
+        - aai-sim
 
   cbs-sim:
     container_name: cbs-sim
@@ -40,21 +44,9 @@
       - ./assets/ssl_certs/mock_server_cacert.pem:/var/tmp/mock_server_cacert.pem
       - ./assets/ssl_certs/mock_server_key.pem:/var/tmp/mock_server_key.pem
     networks:
-      pmsh-network:
-
-  mr-sim:
-    container_name: mr-sim
-    image: mockserver/mockserver:mockserver-5.9.0
-    environment:
-      MOCKSERVER_PROPERTY_FILE: /config/mockserver.properties
-      MOCKSERVER_INITIALIZATION_JSON_PATH: /config/mr-initializer.json
-      LOG_LEVEL: "DEBUG"
-      SERVER_PORT: 3095
-    volumes:
-      - ./assets/mr_sim/mr_mockserver.properties:/config/mockserver.properties
-      - ./assets/mr_sim/mr-initializer.json:/config/mr-initializer.json
-    networks:
-      pmsh-network:
+      dockercompose_net:
+        aliases:
+        - cbs-sim
 
   pmsh:
     container_name: pmsh
@@ -74,8 +66,11 @@
       AAI_SERVICE_PORT: 1080
       DCAE_CA_CERTPATH: '/opt/app/pmsh/etc/certs/cacert.pem'
     networks:
-      pmsh-network:
+      dockercompose_net:
+        aliases:
+        - pmsh
 
 networks:
-  pmsh-network:
-    driver: bridge
+  dockercompose_net:
+    external: true
+
diff --git a/plans/dcaegen2-services-pmsh/testsuite/setup.sh b/plans/dcaegen2-services-pmsh/testsuite/setup.sh
index 4b939fd..d7b988e 100644
--- a/plans/dcaegen2-services-pmsh/testsuite/setup.sh
+++ b/plans/dcaegen2-services-pmsh/testsuite/setup.sh
@@ -1,12 +1,16 @@
 #!/bin/bash
 # Place the scripts in run order:
 
+source ${WORKSPACE}/scripts/dmaap-message-router/dmaap-mr-launch.sh
+dmaap_mr_launch
+DMAAP_MR_IP=${IP}
+
 export DB_USER=pmsh
 export DB_PASSWORD=pmsh
 
 TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite
 
-docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d db aai cbs-sim mr-sim
+docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d db aai cbs-sim
 
 # Slow machine running CSITs can affect db coming up in time for PMSH
 echo "Waiting for postgres db to come up..."
@@ -82,7 +86,6 @@
     fi
     if [[ $(docker inspect --format '{{ .State.Running }}' cbs-sim) ]] && \
        [[ $(docker inspect --format '{{ .State.Running }}' aai-sim) ]] && \
-       [[ $(docker inspect --format '{{ .State.Running }}' mr-sim) ]] && \
        [[ $(docker inspect --format '{{ .State.Running }}' db) ]] && \
        [[ $(docker inspect --format '{{ .State.Running }}' pmsh) ]]
     then
@@ -91,9 +94,14 @@
 done
 [[ "$containers_ok" == "false" ]] && echo "Error: required container not running." && exit 1
 
+# Create topics on MR
+curl -X POST http://${DMAAP_MR_IP}:3904/events/AAI_EVENT --header 'Content-Type: application/json' --data-raw '{"message": "dummy message"}'
+sleep 2
+curl -X POST http://${DMAAP_MR_IP}:3904/events/unauthenticated.PMSH_CL_INPUT --header 'Content-Type: application/json' --data-raw '{"message": "dummy message"}'
+
+
 DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db)
-MR_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mr-sim)
 CBS_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" cbs-sim)
 
 #Pass any variables required by Robot test suites in ROBOT_VARIABLES
-ROBOT_VARIABLES="-v PMSH_IP:${PMSH_IP} -v MR_SIM_IP_ADDRESS:${MR_SIM_IP_ADDRESS} -v DB_IP_ADDRESS:${DB_IP_ADDRESS} -v CBS_SIM_IP_ADDRESS:${CBS_SIM_IP_ADDRESS}"
+ROBOT_VARIABLES="-v PMSH_IP:${PMSH_IP} -v MR_IP_ADDRESS:${DMAAP_MR_IP} -v DB_IP_ADDRESS:${DB_IP_ADDRESS} -v CBS_SIM_IP_ADDRESS:${CBS_SIM_IP_ADDRESS}"
diff --git a/plans/dcaegen2-services-pmsh/testsuite/teardown.sh b/plans/dcaegen2-services-pmsh/testsuite/teardown.sh
index a01dfda..75e624e 100644
--- a/plans/dcaegen2-services-pmsh/testsuite/teardown.sh
+++ b/plans/dcaegen2-services-pmsh/testsuite/teardown.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 echo "Starting teardown script"
+source ${WORKSPACE}/scripts/dmaap-message-router/dmaap-mr-teardown.sh
+dmaap_mr_teardown
 TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite
 mkdir -p $WORKSPACE/archives
 docker exec pmsh /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pmsh/*"