Merge "Fix of configmap issue"
diff --git a/tools/performance/cloud/cloud-based-performance-test.sh b/tools/performance/cloud/cloud-based-performance-test.sh
index 12daeb4..78ab771 100755
--- a/tools/performance/cloud/cloud-based-performance-test.sh
+++ b/tools/performance/cloud/cloud-based-performance-test.sh
@@ -32,6 +32,8 @@
 MAXIMUM_BACK_OFF_CHECK_ITERATIONS=30
 CHECK_NUMBER=0
 NAME_REASON_PATTERN="custom-columns=NAME:.metadata.name,REASON:.status.containerStatuses[].state.waiting.reason"
+HVVES_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep hv-ves-collector)
+HVVES_CERT_PATH=/etc/ves-hv/ssl/
 
 function clean() {
     echo "Cleaning up environment"
@@ -63,9 +65,23 @@
     echo "Attempting to delete producer pods"
     kubectl delete pods -l app=${PRODUCER_APPS_LABEL} -n ${ONAP_NAMESPACE}
 
+    echo "Attempting to delete client certs secret"
+    kubectl delete secret cert -n ${ONAP_NAMESPACE}
+
     echo "Environment clean up finished!"
 }
 
+function copy_certs_to_hvves() {
+	 cd ../../ssl
+	 echo "Creating cert directory: ${HVVES_CERT_PATH}"
+	 kubectl exec ${HVVES_POD_NAME} mkdir ${HVVES_CERT_PATH} -n ${ONAP_NAMESPACE}
+	 for file in {trust.p12,trust.pass,server.p12,server.pass}
+	 do
+       echo "Copying file: ${file}"
+       kubectl cp ${file} ${ONAP_NAMESPACE}/${HVVES_POD_NAME}:${HVVES_CERT_PATH}
+   done
+}
+
 function create_producers() {
     echo "Recreating test properties ConfigMap from: $PROPERTIES_FILE"
     kubectl delete configmap performance-test-config -n ${ONAP_NAMESPACE}
@@ -81,10 +97,17 @@
     set +e
 }
 
+function generate_certs() {
+    echo "Generation of certs"
+    cd ../../ssl
+    ./gen-certs.sh
+}
+
 function usage() {
     echo ""
     echo "Run cloud based HV-VES performance test"
-    echo "Usage $0 setup|start|clean|help"
+    echo "Usage $0 gen_certs|setup|start|clean|help"
+    echo "  gen_certs: generate certs in ../../ssl directory"
     echo "  setup    : set up ConfigMap and consumers"
     echo "  start    : create producers - start the performance test"
     echo "    Optional parameters:"
@@ -93,6 +116,7 @@
     echo "  clean    : remove ConfigMap, HV-VES consumers and producers"
     echo "  help     : print usage"
     echo "Example invocations:"
+    echo "./cloud-based-performance-test.sh gen_certs"
     echo "./cloud-based-performance-test.sh setup"
     echo "./cloud-based-performance-test.sh start"
     echo "./cloud-based-performance-test.sh start --containers 10"
@@ -103,6 +127,13 @@
 
 function setup_environment() {
     echo "Setting up environment"
+    echo "Copying certs to hv-ves pod"
+    copy_certs_to_hvves
+
+    echo "Creating secrets with clients cert"
+    kubectl create secret generic cert --from-file=./client.p12 --from-file=./client.pass -n ${ONAP_NAMESPACE}
+    cd ${SCRIPT_DIRECTORY}
+
     echo "Creating test properties ConfigMap from: $PROPERTIES_FILE"
     kubectl create configmap performance-test-config --from-env-file=${PROPERTIES_FILE} -n ${ONAP_NAMESPACE}
 
@@ -110,7 +141,7 @@
     kubectl apply -f consumer-deployment.yaml
 
     echo "Creating ConfigMap for prometheus deployment"
-    kubectl apply -f prometheus-config-map.yaml
+    kubectl apply -f prometheus/prometheus-config-map.yaml
 
     echo "Creating prometheus deployment"
     kubectl apply -f prometheus-deployment.yaml
@@ -181,6 +212,9 @@
     for arg in ${@}
     do
         case ${arg} in
+            gen_certs)
+            generate_certs
+            ;;
             setup)
             setup_environment
             ;;
diff --git a/tools/performance/cloud/grafana/dashboards/performance-tests.yaml b/tools/performance/cloud/grafana/dashboards/performance-tests.yaml
index 24626b7..9ee405e 100644
--- a/tools/performance/cloud/grafana/dashboards/performance-tests.yaml
+++ b/tools/performance/cloud/grafana/dashboards/performance-tests.yaml
@@ -42,7 +42,7 @@
       "editable": true,
       "gnetId": null,
       "graphTooltip": 0,
-      "iteration": 1570533687099,
+      "iteration": 1570772689346,
       "links": [],
       "panels": [
         {
@@ -484,7 +484,7 @@
           },
           "yaxes": [
             {
-              "format": "s",
+              "format": "ns",
               "label": null,
               "logBase": 1,
               "max": null,
diff --git a/tools/performance/cloud/producer-pod.yaml b/tools/performance/cloud/producer-pod.yaml
index 9381b58..5b41c4e 100755
--- a/tools/performance/cloud/producer-pod.yaml
+++ b/tools/performance/cloud/producer-pod.yaml
@@ -27,6 +27,10 @@
   containers:
     - name: hv-collector-producer
       image: the-a-team-registry-local.esisoj70.emea.nsn-net.net/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-go-client:latest
+      volumeMounts:
+        - name: ssl-certs
+          mountPath: /ssl
+          readOnly: true
       env:
         - name: HV_VES_ADDRESS
           valueFrom:
@@ -53,9 +57,25 @@
             configMapKeyRef:
               name: performance-test-config
               key: producer.client.count
+        - name: CERT_FILE
+          valueFrom:
+            configMapKeyRef:
+              name: performance-test-config
+              key: client.cert.path
+        - name: CERT_PASS_FILE
+          valueFrom:
+            configMapKeyRef:
+              name: performance-test-config
+              key: client.cert.pass.path
       args: ["--address", "$(HV_VES_ADDRESS)",
              "--clients", "$(CLIENTS_PER_CONTAINER)",
              "--msgsize", "$(MSG_SIZE)",
              "--msgcount", "$(MSG_COUNT)",
-             "--intervalms", "$(INTERVAL_MS)"]
+             "--intervalms", "$(INTERVAL_MS)",
+             "--certfile", "$(CERT_FILE)",
+             "--certpass", "$(CERT_PASS_FILE)"]
+  volumes:
+    - name: ssl-certs
+      secret:
+        secretName: cert
   restartPolicy: Never
\ No newline at end of file
diff --git a/tools/performance/cloud/prometheus-config-map.yaml b/tools/performance/cloud/prometheus/prometheus-config-map.yaml
similarity index 100%
rename from tools/performance/cloud/prometheus-config-map.yaml
rename to tools/performance/cloud/prometheus/prometheus-config-map.yaml
diff --git a/tools/performance/cloud/test.properties b/tools/performance/cloud/test.properties
index 092c51c..53a38e2 100644
--- a/tools/performance/cloud/test.properties
+++ b/tools/performance/cloud/test.properties
@@ -10,7 +10,10 @@
 producer.message.count=1000
 # Interval between messages in milliseconds
 producer.message.interval=1
-
+# Path to client cert file
+client.cert.path=/ssl/client.p12
+# Path to cert pass file
+client.cert.pass.path=/ssl/client.pass
 # CONSUMER CONFIGURATION
 
 # Addresses of Kafka services to consume from