Add CSITs for Pm-mapper files processing performance 76/117876/31
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>
Tue, 16 Feb 2021 08:34:13 +0000 (09:34 +0100)
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>
Tue, 2 Mar 2021 06:59:49 +0000 (07:59 +0100)
Issue-ID: DCAEGEN2-2600
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: Id7e4d345380fd5fd08f28a3ddff04a4fde8f7730

26 files changed:
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/addSubscriber.json [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/cbs.json [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/cert.jks [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config.json [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/createFeed.json [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/jks.pass [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/mrserver.js [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/node.properties [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/provserver.properties [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/trust.jks [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/trust.pass [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/docker-compose.yml [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/setup.sh [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/teardown.sh [new file with mode: 0644]
plans/dcaegen2-pmmapper/files-processing-config-pmmapper/testplan.txt [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/__init__.robot [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/.gitattributes [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/ABigFile.xml [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_10_1.env [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_1.env [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_10.env [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/valid_metadata.json [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/files-processing-config-pmmapper.robot [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/DockerContainerManager.py [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/EnvsReader.py [new file with mode: 0644]
tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/LogReader.py [new file with mode: 0644]

diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/addSubscriber.json b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/addSubscriber.json
new file mode 100644 (file)
index 0000000..0666a7d
--- /dev/null
@@ -0,0 +1,20 @@
+{
+    "delivery":{
+       "url":"http://dcae-pm-mapper:8081/delivery",
+       "user":"username",
+       "password":"password",
+       "use100":true
+    },
+    "follow_redirect":false,
+    "metadataOnly":false,
+    "suspend":false,
+    "groupid":0,
+    "links":{
+       "self": "https://dmaap-dr-prov/subscribe/1",
+       "log": "https://dmaap-dr-prov/feedlog/1",
+       "feed": "https://dmaap-dr-prov/feed/1"
+    },
+    "subscriber":"pmmapper",
+    "decompress":true,
+    "privilegedSubscriber": true
+ }
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/cbs.json b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/cbs.json
new file mode 100644 (file)
index 0000000..a29956f
--- /dev/null
@@ -0,0 +1,7 @@
+{
+    "ID": "cbs",
+    "Name": "config_binding_service",
+    "Tags": ["cbs"],
+    "Address": "ipaddress",
+    "Port": 10000
+}
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/cert.jks b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/cert.jks
new file mode 100644 (file)
index 0000000..33dc9a3
Binary files /dev/null and b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/cert.jks differ
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config.json b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config.json
new file mode 100644 (file)
index 0000000..3f1009d
--- /dev/null
@@ -0,0 +1,35 @@
+{
+  "pm-mapper-filter": { "filters":[]},
+  "key_store_path": "/opt/app/pm-mapper/etc/certs/cert.jks",
+  "key_store_pass_path": "/opt/app/pm-mapper/etc/certs/jks.pass",
+  "trust_store_path": "/opt/app/pm-mapper/etc/certs/trust.jks",
+  "trust_store_pass_path": "/opt/app/pm-mapper/etc/certs/trust.pass",
+  "dmaap_dr_delete_endpoint": "https://dmaap-dr-node:8443/delete",
+  "dmaap_dr_feed_name": "1",
+  "aaf_identity": "aaf_admin@people.osaaf.org",
+  "aaf_password": "demo123456!",
+  "enable_http": true,
+  "streams_publishes": {
+    "dmaap_publisher": {
+      "type": "message_router",
+      "dmaap_info": {
+        "topic_url": "http://message-router:3904/events/org.onap.dmaap.mr.VES_PM",
+        "client_role": "org.onap.dcae.pmPublisher",
+        "location": "csit-pmmapper",
+        "client_id": "1562763644939"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "dmaap_subscriber": {
+      "type": "data_router",
+      "dmaap_info": {
+        "username": "username",
+        "password": "password",
+        "location": "csit-pmmapper",
+        "delivery_url": "http://dcae-pm-mapper:8081/delivery",
+        "subscriber_id": 1
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/createFeed.json b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/createFeed.json
new file mode 100644 (file)
index 0000000..f93633d
--- /dev/null
@@ -0,0 +1,18 @@
+{
+    "name": "PM Mapper Feed",
+    "version": "m1.0",
+    "description": "PM Mapper Feed",
+    "business_description": "PM Mapper",
+    "suspend": false,
+    "deleted": false,
+    "changeowner": true,
+    "authorization": {
+      "classification": "unclassified",
+      "endpoint_addrs": [],
+      "endpoint_ids": [
+        {
+          "password": "pmmapper",
+          "id": "pmmapper"
+        }]
+    }
+  }
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/jks.pass b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/jks.pass
new file mode 100644 (file)
index 0000000..ae8f7e7
--- /dev/null
@@ -0,0 +1 @@
+Er1tmip;T4w[%1}YE?x{fN9v
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/mrserver.js b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/mrserver.js
new file mode 100644 (file)
index 0000000..cc84571
--- /dev/null
@@ -0,0 +1,28 @@
+var httpServer = function () {
+  var http = require('http'),
+      url = require('url'),
+      fs = require('fs'),
+
+      start = function (port) {
+        var server = http.createServer(function (req, res) {
+          processHttpRequest(res);
+        });
+        server.listen(port, function () {
+          console.log('Listening on ' + port + '...');
+        });
+      },
+
+      processHttpRequest = function (res) {
+        res.writeHead(200, {'Content-Type': 'text/plain'});
+        console.log('received message');
+        setTimeout(() => {
+          res.end('Published Successfully.\n');
+        }, 100);
+      };
+
+  return {
+    start: start
+  }
+}();
+
+httpServer.start(3904);
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/node.properties b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/node.properties
new file mode 100644 (file)
index 0000000..7abaf60
--- /dev/null
@@ -0,0 +1,89 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright � 2017 AT&T Intellectual Property. All rights reserved.
+# * ===========================================================================
+# * Modifications Copyright (C) 2021 Nokia Intellectual Property
+# * ===========================================================================
+# * 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====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+#
+#    Configuration parameters set at startup for the DataRouter node
+#
+#    URL to retrieve dynamic configuration
+ProvisioningURL = https://dmaap-dr-prov:8443/internal/prov
+#
+#    URL to upload PUB/DEL/EXP logs
+LogUploadURL = https://dmaap-dr-prov:8443/internal/logs
+#
+#    The port number for http as seen within the server
+IntHttpPort = 8080
+#
+#    The port number for https as seen within the server
+IntHttpsPort = 8443
+#
+#    The external port number for https taking port mapping into account
+ExtHttpsPort = 443
+#
+#    The minimum interval between fetches of the dynamic configuration from the provisioning server
+MinProvFetchInterval = 10000
+#
+#    The minimum interval between saves of the redirection data file
+MinRedirSaveInterval = 10000
+#
+#    The path to the directory where log files are stored
+LogDir = /opt/app/datartr/logs
+#
+#    The retention interval (in days) for log files
+LogRetention = 30
+#
+#    The path to the directories where data and meta data files are stored
+SpoolDir = /opt/app/datartr/spool
+#
+#    The path to the redirection data file
+RedirectionFile = etc/redirections.dat
+#
+#    The type of keystore for https
+KeyStoreType = PKCS12
+#
+#    The type of truststore for https
+TrustStoreType = jks
+#
+#    The path to the file used to trigger an orderly shutdown
+QuiesceFile = etc/SHUTDOWN
+#
+#    The key used to generate passwords for node to node transfers
+NodeAuthKey = Node123!
+#
+#    DR_NODE DEFAULT ENABLED TLS PROTOCOLS
+NodeHttpsProtocols = TLSv1.1|TLSv1.2
+#
+#    AAF type to generate permission string
+AAFType = org.onap.dmaap-dr.feed
+#
+#    AAF default instance to generate permission string - default should be legacy
+AAFInstance = legacy
+#
+#    AAF action to generate permission string - default should be publish
+AAFAction = publish
+#
+#    AAF CADI enabled flag
+CadiEnabled = false
+#
+#    AAF Props file path
+AAFPropsFilePath = /opt/app/osaaf/local/org.onap.dmaap-dr.props
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/provserver.properties b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/provserver.properties
new file mode 100644 (file)
index 0000000..cd333ef
--- /dev/null
@@ -0,0 +1,62 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright � 2017 AT&T Intellectual Property. All rights reserved.
+# * ===========================================================================
+# * Modifications Copyright (C) 2021 Nokia Intellectual Property
+# * ===========================================================================
+# * 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====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+
+#Jetty Server properties
+org.onap.dmaap.datarouter.provserver.http.port           = 8080
+org.onap.dmaap.datarouter.provserver.https.port          = 8443
+org.onap.dmaap.datarouter.provserver.https.relaxation    = true
+
+org.onap.dmaap.datarouter.provserver.aafprops.path       = /opt/app/osaaf/local/org.onap.dmaap-dr.props
+
+org.onap.dmaap.datarouter.provserver.accesslog.dir       = /opt/app/datartr/logs
+org.onap.dmaap.datarouter.provserver.spooldir            = /opt/app/datartr/spool
+org.onap.dmaap.datarouter.provserver.dbscripts           = /opt/app/datartr/etc/misc
+org.onap.dmaap.datarouter.provserver.logretention        = 30
+
+#DMAAP-597 (Tech Dept) REST request source IP auth
+# relaxation to accommodate OOM kubernetes deploy
+org.onap.dmaap.datarouter.provserver.isaddressauthenabled = false
+
+#Localhost address config
+org.onap.dmaap.datarouter.provserver.localhost = 127.0.0.1
+
+# Database access
+org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver
+org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://datarouter-mariadb:3306/datarouter
+org.onap.dmaap.datarouter.db.login    = datarouter
+org.onap.dmaap.datarouter.db.password = datarouter
+
+# PROV - DEFAULT ENABLED TLS PROTOCOLS
+org.onap.dmaap.datarouter.provserver.https.include.protocols = TLSv1.1|TLSv1.2
+
+# AAF config
+org.onap.dmaap.datarouter.provserver.cadi.enabled = false
+
+org.onap.dmaap.datarouter.provserver.passwordencryption   = PasswordEncryptionKey#@$%^&1234#
+org.onap.dmaap.datarouter.provserver.aaf.feed.type        = org.onap.dmaap-dr.feed
+org.onap.dmaap.datarouter.provserver.aaf.sub.type         = org.onap.dmaap-dr.sub
+org.onap.dmaap.datarouter.provserver.aaf.instance         = legacy
+org.onap.dmaap.datarouter.provserver.aaf.action.publish   = publish
+org.onap.dmaap.datarouter.provserver.aaf.action.subscribe = subscribe
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/trust.jks b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/trust.jks
new file mode 100644 (file)
index 0000000..679c95a
Binary files /dev/null and b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/trust.jks differ
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/trust.pass b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/trust.pass
new file mode 100644 (file)
index 0000000..d3d01b0
--- /dev/null
@@ -0,0 +1 @@
+583Ls;XF(qDQu3p!L22gyh1t
\ No newline at end of file
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/docker-compose.yml b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/docker-compose.yml
new file mode 100644 (file)
index 0000000..66946ea
--- /dev/null
@@ -0,0 +1,119 @@
+version: '3.3'
+
+services:
+  datarouter-prov:
+    image: nexus3.onap.org:10001/onap/dmaap/datarouter-prov
+    container_name: datarouter-prov
+    hostname: dmaap-dr-prov
+    ports:
+     - "443:8443"
+     - "8443:8443"
+     - "8080:8080"
+    volumes:
+     - /var/tmp/provserver.properties:/opt/app/datartr/etc/provserver.properties
+    depends_on:
+      - mariadb
+    healthcheck:
+      test: ["CMD", "curl", "-f", "http://dmaap-dr-prov:8080/internal/prov"]
+      interval: 10s
+      timeout: 10s
+      retries: 5
+    networks:
+      pmmapper-network:
+        ipv4_address: $DR_PROV_IP
+    extra_hosts:
+      - "dmaap-dr-node:$DR_NODE_IP"
+      - "dcae-pm-mapper:$PMMAPPER_IP"
+
+  datarouter-node:
+    image: nexus3.onap.org:10001/onap/dmaap/datarouter-node
+    container_name: datarouter-node
+    hostname: dmaap-dr-node
+    ports:
+     - "9443:8443"
+     - "9090:8080"
+    volumes:
+     - /var/tmp/node.properties:/opt/app/datartr/etc/node.properties
+    depends_on:
+      - datarouter-prov
+    networks:
+      pmmapper-network:
+        ipv4_address: $DR_NODE_IP
+    extra_hosts:
+      - "dmaap-dr-prov:$DR_PROV_IP"
+      - "dcae-pm-mapper:$PMMAPPER_IP"
+
+  node:
+    image: nexus3.onap.org:10001/node:10-slim
+    container_name: mr-simulator
+    volumes:
+      - /var/tmp/mrserver.js:/tmp/mrserver.js
+    command:
+      nodejs /tmp/mrserver.js
+    networks:
+      pmmapper-network:
+        ipv4_address: $NODE_IP
+
+  mariadb:
+    image: nexus3.onap.org:10001/mariadb:10.2.14
+    container_name: mariadb
+    ports:
+      - "3306:3306"
+    environment:
+      MYSQL_ROOT_PASSWORD: datarouter
+      MYSQL_DATABASE: datarouter
+      MYSQL_USER: datarouter
+      MYSQL_PASSWORD: datarouter
+    healthcheck:
+      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "--silent"]
+      interval: 10s
+      timeout: 30s
+      retries: 5
+    networks:
+      pmmapper-network:
+        ipv4_address: $MARIADB_IP
+
+  consul:
+    container_name: consul
+    image: nexus3.onap.org:10001/consul:latest
+    networks:
+      pmmapper-network:
+        ipv4_address: $CONSUL_IP
+
+  cbs:
+    container_name: cbs
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app:latest
+    environment:
+       CONSUL_HOST: $CONSUL_IP
+    networks:
+      pmmapper-network:
+        ipv4_address: $CBS_IP
+
+  pmmapper:
+    container_name: pmmapper
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pm-mapper:latest
+    ports:
+     - "8081:8081"
+    volumes:
+      - /var/tmp/:/opt/app/pm-mapper/etc/certs/
+    depends_on:
+      - datarouter-prov
+    environment:
+       CONFIG_BINDING_SERVICE_SERVICE_HOST: $CBS_IP
+       CONFIG_BINDING_SERVICE_SERVICE_PORT: 10000
+       HOSTNAME: pmmapper
+    networks:
+      pmmapper-network:
+        ipv4_address: $PMMAPPER_IP
+    extra_hosts:
+      - "dmaap-dr-node:$DR_NODE_IP"
+      - "message-router:$NODE_IP"
+
+
+networks:
+  pmmapper-network:
+    driver: bridge
+    ipam:
+      config:
+        - subnet: 172.18.0.0/16
+
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/setup.sh b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/setup.sh
new file mode 100644 (file)
index 0000000..f314055
--- /dev/null
@@ -0,0 +1,101 @@
+#!/bin/bash
+# Place the scripts in run order:
+source ${SCRIPTS}/common_functions.sh
+
+docker login -u docker -p docker nexus3.onap.org:10001
+
+TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-pmmapper/files-processing-config-pmmapper
+
+export GATEWAY_IP=172.18.0.1
+export DR_NODE_IP=172.18.0.2
+export DR_PROV_IP=172.18.0.3
+export CONSUL_IP=172.18.0.4
+export CBS_IP=172.18.0.5
+export MARIADB_IP=172.18.0.6
+export NODE_IP=172.18.0.7
+export PMMAPPER_IP=172.18.0.8
+
+for asset in provserver.properties node.properties cbs.json mrserver.js cert.jks jks.pass trust.jks trust.pass; do
+  cp $TEST_PLANS_DIR/assets/${asset} /var/tmp/
+done
+
+sed -i 's/datarouter-mariadb/'$MARIADB_IP'/g' /var/tmp/provserver.properties
+sed -i 's/ipaddress//g' /var/tmp/cbs.json
+
+# ------------------------------------
+#Prepare enviroment for client
+#install docker sdk
+echo "Uninstall docker-py and reinstall docker."
+pip uninstall -y docker-py
+pip uninstall -y docker
+pip install -U docker==2.7.0
+
+docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d mariadb consul cbs node
+
+echo "Waiting for MariaDB to come up healthy..."
+for i in {1..30}; do
+    mariadb_state=$(docker inspect --format='{{json .State.Health.Status}}' mariadb)
+    if [ $mariadb_state = '"healthy"' ]
+    then
+      break
+    else
+      sleep 2
+    fi
+done
+[ "$mariadb_state" != '"healthy"' ] && echo "Error: MariaDB container state not healthy" && exit 1
+
+docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d datarouter-node datarouter-prov
+
+unset http_proxy
+unset https_proxy
+curl --request PUT --data @/var/tmp/cbs.json http://$CONSUL_IP:8500/v1/agent/service/register
+curl 'http://'$CONSUL_IP':8500/v1/kv/pmmapper?dc=dc1' -X PUT \
+      -H 'Accept: application/json' \
+      -H 'Content-Type: application/json' \
+      -H 'X-Requested-With: XMLHttpRequest' \
+      --data @$TEST_PLANS_DIR/assets/config.json
+
+docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d pmmapper
+sleep 2
+
+# Wait for initialization of Docker container for datarouter-node, datarouter-prov and mariadb, Consul, CBS
+containers_ok=false
+for i in {1..5}; do
+    if [ $(docker inspect --format '{{ .State.Running }}' datarouter-node) ] && \
+        [ $(docker inspect --format '{{ .State.Running }}' datarouter-prov) ] && \
+        [ $(docker inspect --format '{{ .State.Running }}' mariadb) ] && \
+        [ $(docker inspect --format '{{ .State.Running }}' mr-simulator) ] && \
+        [ $(docker inspect --format '{{ .State.Running }}' consul) ] && \
+        [ $(docker inspect --format '{{ .State.Running }}' cbs) ] && \
+        [ $(docker inspect --format '{{ .State.Running }}' pmmapper) ]
+    then
+        echo "All required docker containers are up."
+        containers_ok=true
+        break
+    else
+        sleep $i
+    fi
+done
+[ "$containers_ok" = "false" ] && echo "Error: required container not running." && exit 1
+
+# Data Router Configuration.
+docker exec -i datarouter-prov sh -c \
+    "curl -k  -X PUT https://$DR_PROV_IP:8443/internal/api/NODES?val=dmaap-dr-node\|$GATEWAY_IP"
+docker exec -i datarouter-prov sh -c \
+    "curl -k  -X PUT https://$DR_PROV_IP:8443/internal/api/PROV_AUTH_ADDRESSES?val=dmaap-dr-prov\|$GATEWAY_IP"
+
+# Create PM Mapper feed and create PM Mapper subscriber on data router
+curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \
+      --data-ascii @$TEST_PLANS_DIR/assets/createFeed.json \
+      --post301 --location-trusted -k https://${DR_PROV_IP}:8443
+curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" \
+      --data-ascii @$TEST_PLANS_DIR/assets/addSubscriber.json \
+      --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1
+
+docker cp pmmapper:/var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log /tmp/pmmapper.log
+sleep 10
+docker exec -it datarouter-prov sh -c "curl http://dmaap-dr-node:8080/internal/fetchProv"
+curl -k https://$DR_PROV_IP:8443/internal/prov
+
+#Pass any variables required by Robot test suites in ROBOT_VARIABLES
+ROBOT_VARIABLES="-v CONSUL_IP:${CONSUL_IP} -v DR_PROV_IP:${DR_PROV_IP} -v DMAAP_MR_IP:${DMAAP_MR_IP} -v CBS_IP:${CBS_IP} -v PMMAPPER_IP:${PMMAPPER_IP} -v DR_NODE_IP:${DR_NODE_IP} -v NODE_IP:${NODE_IP}"
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/teardown.sh b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/teardown.sh
new file mode 100644 (file)
index 0000000..ffa2da6
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+echo "Starting teardown script"
+TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-pmmapper/files-processing-config-pmmapper
+mkdir -p $WORKSPACE/archives
+docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log"
+kill-instance.sh pmmapper
+docker-compose -f $TEST_PLANS_DIR/docker-compose.yml logs > $WORKSPACE/archives/files-processing-config-pmmapper-docker-compose.log
+docker-compose -f $TEST_PLANS_DIR/docker-compose.yml down -v
diff --git a/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/testplan.txt b/plans/dcaegen2-pmmapper/files-processing-config-pmmapper/testplan.txt
new file mode 100644 (file)
index 0000000..543973d
--- /dev/null
@@ -0,0 +1,3 @@
+# Test suites are relative paths under [integration/csit.git]/tests/.
+# Place the suites in run order.
+dcaegen2-pmmapper/files-processing-config-pmmapper
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/__init__.robot b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/__init__.robot
new file mode 100644 (file)
index 0000000..9eda6de
--- /dev/null
@@ -0,0 +1,2 @@
+*** Settings ***
+Documentation    Files Processing Config PM Mapper Testcases
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/.gitattributes b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/.gitattributes
new file mode 100644 (file)
index 0000000..57cdc50
--- /dev/null
@@ -0,0 +1 @@
+*.gz binary
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/ABigFile.xml b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/ABigFile.xml
new file mode 100644 (file)
index 0000000..8a3bcf4
--- /dev/null
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="MeasDataCollection.xsl"?>
+<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
+       <fileHeader fileFormatVersion="32.435 V7.0" vendorName="Company NN" dnPrefix="DC=a1.companyNN.com,SubNetwork=1,IRPAgent=1">
+               <fileSender localDn="SubNetwork=CountryNN,MeContext=MEC-Gbg-1,ManagedElement=RNC-Gbg-1" elementType="RNC"/>
+               <measCollec beginTime="2000-03-01T14:00:00+02:00"/>
+       </fileHeader>
+       <measData>
+               <managedElement localDn="SubNetwork=CountryNN,MeContext=MEC-Gbg-1,ManagedElement=RNC-Gbg-1" userLabel="RNC Telecomville"/>
+               <measInfo>
+                       <job jobId="1231"/>
+                       <granPeriod duration="PT900S" endTime="2000-03-01T14:14:30+02:00"/>
+                       <repPeriod duration="PT1800S"/>
+                       <measType p="1">attTCHSeizures</measType>
+                       <measType p="2">succTCHSeizures</measType>
+                       <measType p="3">attImmediateAssignProcs</measType>
+                       <measType p="4">succImmediateAssignProcs</measType>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-997">
+                               <r p="1">234</r>
+                               <r p="2">345</r>
+                               <r p="3">567</r>
+                               <r p="4">789</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-998">
+                               <r p="1">890</r>
+                               <r p="2">901</r>
+                               <r p="3">123</r>
+                               <r p="4">234</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-999">
+                               <r p="1">456</r>
+                               <r p="2">567</r>
+                               <r p="3">678</r>
+                               <r p="4">789</r>
+                               <suspect>true</suspect>
+                       </measValue>
+               </measInfo>
+               <measInfo measInfoId="ENodeBFunction">
+            <job jobId="1232"/>
+                       <granPeriod duration="PT900S" endTime="2000-03-01T14:14:30+02:00"/>
+                       <repPeriod duration="PT1800S"/>
+            <measType p="1">attTCHSeizures1</measType>
+            <measType p="2">succTCHSeizures2</measType>
+            <measType p="3">attImmediateAssignProcs3</measType>
+            <measType p="4">succImmediateAssignProcs4</measType>
+            <measValue measObjLdn="ManagedElement=RNC-Gbg-1,ENodeBFunction=1">
+                <r p="1">4</r>
+                <r p="2">86,87,2,6,77,96,75,33,24</r>
+                <r p="3">40</r>
+                <r p="4">90</r>
+                <suspect>false</suspect>
+            </measValue>
+        </measInfo>
+               <measInfo>
+                       <job jobId="1233"/>
+                       <granPeriod duration="PT900S" endTime="2000-03-01T14:14:30+02:00"/>
+                       <repPeriod duration="PT1800S"/>
+                       <measType p="1">attTCHSeizures5</measType>
+                       <measType p="2">succTCHSeizures6</measType>
+                       <measType p="3">attImmediateAssignProcs7</measType>
+                       <measType p="4">succImmediateAssignProcs8</measType>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-997">
+                               <r p="1">238</r>
+                               <r p="2">344</r>
+                               <r p="3">563</r>
+                               <r p="4">787</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-998">
+                               <r p="1">898</r>
+                               <r p="2">905</r>
+                               <r p="3">127</r>
+                               <r p="4">238</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-999">
+                               <r p="1">454</r>
+                               <r p="2">569</r>
+                               <r p="3">672</r>
+                               <r p="4">785</r>
+                               <suspect>true</suspect>
+                       </measValue>
+               </measInfo>
+       </measData>
+       <measData>
+               <managedElement localDn="SubNetwork=CountryNN,MeContext=MEC-Gbg-1,ManagedElement=RNC-Gbg-1" userLabel="RNC Telecomville"/>
+               <measInfo>
+                       <job jobId="1231"/>
+                       <granPeriod duration="PT900S" endTime="2000-03-01T14:14:30+02:00"/>
+                       <repPeriod duration="PT1800S"/>
+                       <measType p="1">attTCHSeizures</measType>
+                       <measType p="2">succTCHSeizures</measType>
+                       <measType p="3">attImmediateAssignProcs</measType>
+                       <measType p="4">succImmediateAssignProcs</measType>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-997">
+                               <r p="1">234</r>
+                               <r p="2">345</r>
+                               <r p="3">567</r>
+                               <r p="4">789</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-998">
+                               <r p="1">890</r>
+                               <r p="2">901</r>
+                               <r p="3">123</r>
+                               <r p="4">234</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-999">
+                               <r p="1">456</r>
+                               <r p="2">567</r>
+                               <r p="3">678</r>
+                               <r p="4">789</r>
+                               <suspect>true</suspect>
+                       </measValue>
+               </measInfo>
+               <measInfo measInfoId="ENodeBFunction">
+                       <job jobId="1232"/>
+                       <granPeriod duration="PT900S" endTime="2000-03-01T14:14:30+02:00"/>
+                       <repPeriod duration="PT1800S"/>
+                       <measType p="1">attTCHSeizures1</measType>
+                       <measType p="2">succTCHSeizures2</measType>
+                       <measType p="3">attImmediateAssignProcs3</measType>
+                       <measType p="4">succImmediateAssignProcs4</measType>
+                       <measValue measObjLdn="ManagedElement=RNC-Gbg-1,ENodeBFunction=1">
+                               <r p="1">4</r>
+                               <r p="2">86,87,2,6,77,96,75,33,24</r>
+                               <r p="3">40</r>
+                               <r p="4">90</r>
+                               <suspect>false</suspect>
+                       </measValue>
+               </measInfo>
+               <measInfo>
+                       <job jobId="1233"/>
+                       <granPeriod duration="PT900S" endTime="2000-03-01T14:14:30+02:00"/>
+                       <repPeriod duration="PT1800S"/>
+                       <measType p="1">attTCHSeizures5</measType>
+                       <measType p="2">succTCHSeizures6</measType>
+                       <measType p="3">attImmediateAssignProcs7</measType>
+                       <measType p="4">succImmediateAssignProcs8</measType>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-997">
+                               <r p="1">238</r>
+                               <r p="2">344</r>
+                               <r p="3">563</r>
+                               <r p="4">787</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-998">
+                               <r p="1">898</r>
+                               <r p="2">905</r>
+                               <r p="3">127</r>
+                               <r p="4">238</r>
+                       </measValue>
+                       <measValue measObjLdn="RncFunction=RF-1,UtranCell=Gbg-999">
+                               <r p="1">454</r>
+                               <r p="2">569</r>
+                               <r p="3">672</r>
+                               <r p="4">785</r>
+                               <suspect>true</suspect>
+                       </measValue>
+               </measInfo>
+       </measData>
+       <fileFooter>
+               <measCollec endTime="2000-03-01T14:15:00+02:00"/>
+       </fileFooter>
+</measCollecFile>
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_10_1.env b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_10_1.env
new file mode 100644 (file)
index 0000000..050d2f2
--- /dev/null
@@ -0,0 +1,3 @@
+PROCESSING_LIMIT_RATE=10
+THREADS_MULTIPLIER=1
+PROCESSING_THREADS_COUNT=1
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_1.env b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_1.env
new file mode 100644 (file)
index 0000000..c138912
--- /dev/null
@@ -0,0 +1,3 @@
+PROCESSING_LIMIT_RATE=1
+THREADS_MULTIPLIER=1
+PROCESSING_THREADS_COUNT=1
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_10.env b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_10.env
new file mode 100644 (file)
index 0000000..b4c290e
--- /dev/null
@@ -0,0 +1,3 @@
+PROCESSING_LIMIT_RATE=1
+THREADS_MULTIPLIER=1
+PROCESSING_THREADS_COUNT=10
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/valid_metadata.json b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/valid_metadata.json
new file mode 100644 (file)
index 0000000..da809d7
--- /dev/null
@@ -0,0 +1,12 @@
+{
+    "productName": "gnb",
+    "vendorName": "Ericsson",
+    "lastEpochMicrosec": "1538478000000",
+    "sourceName": "oteNB5309",
+    "startEpochMicrosec": "1538478900000",
+    "timeZoneOffset": "UTC+05.00",
+    "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz",
+    "compression": "gzip",
+    "fileFormatType": "org.3GPP.32.435#measCollec",
+    "fileFormatVersion": "V9"
+  }
\ No newline at end of file
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/files-processing-config-pmmapper.robot b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/files-processing-config-pmmapper.robot
new file mode 100644 (file)
index 0000000..09a7de4
--- /dev/null
@@ -0,0 +1,148 @@
+*** Settings ***
+Documentation     Testing PM Mapper functionality
+Library           Collections
+Library           OperatingSystem
+Library           RequestsLibrary
+Library           Process
+Library           String
+Library           libraries/DockerContainerManager.py
+Library           libraries/LogReader.py
+
+*** Variables ***
+
+${NR_VALID_METADATA_PATH}                %{WORKSPACE}/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/valid_metadata.json
+${CLI_EXEC_CLI_PM_LOG_CLEAR}             docker exec pmmapper /bin/sh -c "echo -n "" > /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log"
+${PUBLISH_NODE_URL}                      https://${DR_NODE_IP}:8443/publish/1
+${CLI_EXEC_LOGS_LIST}                    docker exec datarouter-node /bin/sh -c "ls /opt/app/datartr/logs"
+${DOCKER_CLIENT_IMAGE}                   nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.pm-mapper:latest
+${CLIENT_CONTAINER_NAME}                 pmmapper
+${FILE_PATH}                             %{WORKSPACE}/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/ABigFile.xml
+${CONFIG_ENVS_1_1}                       %{WORKSPACE}/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_1.env
+${CONFIG_ENVS_4_1}                       %{WORKSPACE}/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_4_1.env
+${CONFIG_ENVS_10_1}                      %{WORKSPACE}/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_10_1.env
+${CONFIG_ENVS_1_10}                      %{WORKSPACE}/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/assets/config_1_10.env
+
+*** Test Cases ***
+
+Verify that PM Mapper rejects 6-9 messages when limitRate is 1 and threads count is 1
+    [Tags]                          FILES_PROCESSING_CONFIG_PM_MAPPER_1
+    [Documentation]                 Verify that PM Mapper rejects 6-9/10 messages. Configuration: limitRate=1, threadsCount=1
+    [Timeout]                       15 minute
+
+    RestartPmmapper                 ${CONFIG_ENVS_1_1}
+
+    ${testname}=                    Set Variable                    Afirst-
+
+    SendFilesToDatarouter           ${testname}
+    ${alllogs}=                     GetLogsOutput
+    ${filtered_logs}=               GetFilteredLogs                 ${alllogs}                                    ${testname}
+    ${dropped_nr}=                  GetDroppedNumber                ${filtered_logs}
+
+    Sleep                           40s
+    ${isCorrectDroppedCount}=       Evaluate  ${5} < ${dropped_nr} < ${10}
+    SavePmMapperLogsAndDroppedCount  config_1_1  ${dropped_nr}
+    Should Be True                  ${isCorrectDroppedCount}  Pm-mapper drop: ${dropped_nr} messages. Expected drop count: 6-9
+    ClearLogs
+
+Verify that PM Mapper rejects 0 messages when limitRate is 10 and threads count is 1
+    [Tags]                          FILES_PROCESSING_CONFIG_PM_MAPPER_2
+    [Documentation]                 Verify that PM Mapper rejects 0/10 messages. Configuration: limitRate=10, threadsCount=1
+    [Timeout]                       25 minute
+
+    RestartPmmapper                 ${CONFIG_ENVS_10_1}
+
+    ${testname}=                    Set Variable                    Athird-
+
+    SendFilesToDatarouter           ${testname}
+    ${alllogs}=                     GetLogsOutput
+    ${filtered_logs}=               GetFilteredLogs                 ${alllogs}                                    ${testname}
+    ${dropped_nr}=                  GetDroppedNumber                ${filtered_logs}
+
+    Sleep                           15s
+    SavePmMapperLogsAndDroppedCount  config_10_1  ${dropped_nr}
+    Should Be Equal As Numbers      ${dropped_nr}   0   Pm-mapper drop: ${dropped_nr} messages. Expected drop count: 0
+    ClearLogs
+
+Verify that PM Mapper rejects 0 messages when limitRate is 1 and threads count is 10
+    [Tags]                          FILES_PROCESSING_CONFIG_PM_MAPPER_3
+    [Documentation]                 Verify that PM Mapper rejects 0/10 messages. Configuration: limitRate=1, threadsCount=10
+    [Timeout]                       25 minute
+
+    RestartPmmapper                 ${CONFIG_ENVS_1_10}
+
+    ${testname}=                    Set Variable                    Afourth-
+
+    SendFilesToDatarouter           ${testname}
+    ${alllogs}=                     GetLogsOutput
+    ${filtered_logs}=               GetFilteredLogs                 ${alllogs}                                    ${testname}
+    ${dropped_nr}=                  GetDroppedNumber                ${filtered_logs}
+
+    Sleep                           15s
+    SavePmMapperLogsAndDroppedCount  config_1_10  ${dropped_nr}
+    Should Be Equal As Numbers      ${dropped_nr}   0   Pm-mapper drop: ${dropped_nr} messages. Expected drop count: 0
+    ClearLogs
+
+*** Keywords ***
+
+SendFilesToDatarouter
+    [Arguments]                     ${testnr}
+    FOR                             ${i}                             IN RANGE                     10
+                                    SendToDatarouter                 ${FILE_PATH}                 ${NR_VALID_METADATA_PATH}                 X-ONAP-RequestID=${i}        ${testnr}         ${i}
+    END
+    Sleep                           20s
+
+SendToDatarouter
+    [Arguments]                     ${filepath}                      ${metadatapath}            ${request_id}            ${testnr}      ${i}
+    ${pmdata}=                      Get File                         ${filepath}
+    ${metatdata}                    Get File                         ${metadatapath}
+    ${newFilename}                  Catenate                         SEPARATOR=                 ${testnr}               ${i}               .xml
+    ${resp}=                        PutCall                          ${PUBLISH_NODE_URL}/${newFilename}        ${request_id}    ${pmdata}    ${metatdata.replace("\n","")}    pmmapper
+    VerifyResponse                  ${resp.status_code}              204
+
+PutCall
+    [Arguments]                     ${url}                           ${request_id}              ${data}            ${meta}          ${user}
+    ${headers}=                     Create Dictionary                X-ONAP-RequestID=${request_id}                X-DMAAP-DR-META=${meta}    Content-Type=application/octet-stream     X-DMAAP-DR-ON-BEHALF-OF=${user}    Authorization=Basic cG1tYXBwZXI6cG1tYXBwZXI=
+    ${resp}=                        Evaluate                         requests.put('${url}', data="""${data}""", headers=${headers}, verify=False, allow_redirects=False)    requests
+    [Return]                        ${resp}
+
+VerifyResponse
+    [Arguments]                     ${actual_response_value}         ${expected_response_value}
+    Should Be Equal As Strings      ${actual_response_value}         ${expected_response_value}
+
+ClearLogs
+    Run Process                     ${CLI_EXEC_CLI_PM_LOG_CLEAR}                     shell=yes
+
+GetLogsOutput
+    ${filesString}=                   Run Process                      ${CLI_EXEC_LOGS_LIST}                     shell=yes
+    ${filesList}=                     Get Log Files List               ${filesString.stdout}
+    ${output}=                        Set Variable                     ${EMPTY}
+    FOR                               ${file}                          IN                                        @{filesList}
+                                      ${file_path}=                    Catenate                                  SEPARATOR=    "cat /opt/app/datartr/logs/      ${file}       "
+                                      ${exec}=                         Catenate                                  docker exec datarouter-node /bin/sh -c      ${file_path}
+                                      ${single_file}=                  Run Process                               ${exec}         shell=yes
+                                      ${output}=                       Catenate                                  SEPARATOR=\n         ${output}                  ${single_file.stdout}
+    END
+    [Return]                          ${output}
+
+GetFilteredLogs
+    [Arguments]                       ${all_logs}                      ${testname}
+    ${filtered_logs}=                 Filter Unique                    ${all_logs}                               ${testname}
+    [Return]                          ${filtered_logs}
+
+GetDroppedNumber
+    [Arguments]                       ${logs_output}
+    ${number}=                        Get Number Of Dropped Messages  ${logs_output}
+    [Return]                          ${number}
+
+RestartPmmapper
+    [Arguments]                       ${envs}
+    Remove Container                  ${CLIENT_CONTAINER_NAME}
+    Sleep                             5s
+    Run Pmmapper Container            ${DOCKER_CLIENT_IMAGE}      ${CLIENT_CONTAINER_NAME}        ${envs}        ${DR_NODE_IP}          ${NODE_IP}
+    Sleep                             15s
+
+SavePmMapperLogsAndDroppedCount
+    [Arguments]                       ${test_name}                ${dropped_count}
+    Run Process                      echo "Dropped: ${dropped_count}" > %{WORKSPACE}/archives/${test_name}_dropped_count.log  shell=yes
+    Run Process                      docker logs ${CLIENT_CONTAINER_NAME} > %{WORKSPACE}/archives/${test_name}_pm_mapper_container_logs.log  shell=yes
+
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/DockerContainerManager.py b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/DockerContainerManager.py
new file mode 100644 (file)
index 0000000..3e3ae58
--- /dev/null
@@ -0,0 +1,29 @@
+import docker
+from EnvsReader import EnvsReader
+from docker.types import Mount
+
+class DockerContainerManager:
+
+    def run_pmmapper_container(self, client_image, container_name, path_to_env, dr_node_ip, mr_ip):
+        client = docker.from_env()
+        environment = EnvsReader().read_env_list_from_file(path_to_env)
+        environment.append("CONFIG_BINDING_SERVICE_SERVICE_HOST=172.18.0.5")
+        environment.append("CONFIG_BINDING_SERVICE_SERVICE_PORT=10000")
+        environment.append("HOSTNAME=pmmapper")
+        client.containers.run(
+            image=client_image,
+            name=container_name,
+            environment=environment,
+            ports={'8081': 8081},
+            network='filesprocessingconfigpmmapper_pmmapper-network',
+            extra_hosts={'dmaap-dr-node': dr_node_ip, 'message-router': mr_ip},
+            user='root',
+            mounts=[Mount(target='/opt/app/pm-mapper/etc/certs/', source='/var/tmp/', type='bind')],
+            detach=True
+        )
+
+    def remove_container(self, container_name):
+        client = docker.from_env()
+        container = client.containers.get(container_name)
+        container.stop()
+        container.remove()
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/EnvsReader.py b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/EnvsReader.py
new file mode 100644 (file)
index 0000000..cc60eed
--- /dev/null
@@ -0,0 +1,11 @@
+
+class EnvsReader:
+
+  def read_env_list_from_file(self, path):
+    f = open(path, "r")
+    r_list = []
+    for line in f:
+      line = line.strip()
+      if line[0] != "#":
+        r_list.append(line)
+    return r_list
diff --git a/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/LogReader.py b/tests/dcaegen2-pmmapper/files-processing-config-pmmapper/libraries/LogReader.py
new file mode 100644 (file)
index 0000000..01718e3
--- /dev/null
@@ -0,0 +1,22 @@
+import re
+
+class LogReader:
+
+  def filter_unique(self, merged_logs_output, testname):
+    logs = merged_logs_output.splitlines()
+    del_logs = list(filter(lambda line: "|DEL|" in line, logs))
+    nrs_set = set()
+    ret_logs = set()
+    for log in del_logs:
+      filename = re.findall(testname + "\d", log)
+      if len(filename) > 0 and filename[0] not in nrs_set:
+        ret_logs.add(log)
+        nrs_set.add(filename[0])
+    return ret_logs
+
+  def get_number_of_dropped_messages(self, logs_output):
+    return len(list(filter(lambda line: "|429|" in line, logs_output)))
+
+  def get_log_files_list(self, fileNames):
+    files = fileNames.split()
+    return files