[ROBOT] Add new E2E test for 5G BulkPM usecase from HTTP server to ONAP gating

Fix of failng test cases

Issue-ID: INT-1815
Signed-off-by: Krzysztof Kuzmicki <krzysztof.kuzmicki@nokia.com>
Change-Id: Id6f0c1ecfcf0cf7d4211aa614eeed08e72762b3e
diff --git a/robot/assets/cmpv2/k8s-mongo-ves-client.yaml b/robot/assets/cmpv2/k8s-mongo-ves-client.yaml
new file mode 100644
index 0000000..4252399
--- /dev/null
+++ b/robot/assets/cmpv2/k8s-mongo-ves-client.yaml
@@ -0,0 +1,37 @@
+tosca_definitions_version: cloudify_dsl_1_3
+imports:
+  - 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
+  - 'plugin:k8splugin?version=>=3.4.2,<4.0.0'
+inputs:
+  tag_version:
+    type: string
+    description: Docker image to be used
+    default: 'mongo'
+  replicas:
+    type: integer
+    description: Number of instances
+    default: 1
+  service_component_type:
+    type: string
+    default: "mongo-ves-client"
+  service_component_name_override:
+    type: string
+    default: "mongo-ves-client"
+node_templates:
+  mongo:
+    type: dcae.nodes.ContainerizedServiceComponent
+    interfaces:
+      cloudify.interfaces.lifecycle:
+        start:
+          inputs:
+            envs:
+              MONGO_INITDB_ROOT_USERNAME: root
+              MONGO_INITDB_ROOT_PASSWORD: zXcVbN123!
+              MONGO_INITDB_DATABASE: pnf_simulator
+            ports:
+              - '27017:0'
+    properties:
+      service_component_type: { get_input: service_component_type }
+      service_component_name_override: { get_input: service_component_name_override }
+      image: { get_input: tag_version }
+      replicas: { get_input: replicas }
diff --git a/robot/assets/cmpv2/k8s-mongo.yaml b/robot/assets/cmpv2/k8s-mongo.yaml
index 3823bff..010eb65 100644
--- a/robot/assets/cmpv2/k8s-mongo.yaml
+++ b/robot/assets/cmpv2/k8s-mongo.yaml
@@ -11,6 +11,12 @@
     type: integer
     description: Number of instances
     default: 1
+  service_component_type:
+    type: string
+    default: "mongo"
+  service_component_name_override:
+    type: string
+    default: "mongo"
 node_templates:
   mongo:
     type: dcae.nodes.ContainerizedServiceComponent
@@ -25,7 +31,7 @@
             ports:
               - '27017:0'
     properties:
-      service_component_type: mongo
-      service_component_name_override: mongo
+      service_component_type: { get_input: service_component_type }
+      service_component_name_override: { get_input: service_component_name_override }
       image: { get_input: tag_version }
       replicas: { get_input: replicas }
diff --git a/robot/assets/cmpv2/k8s-ves-client.yaml b/robot/assets/cmpv2/k8s-ves-client.yaml
new file mode 100644
index 0000000..cfb5fd5
--- /dev/null
+++ b/robot/assets/cmpv2/k8s-ves-client.yaml
@@ -0,0 +1,75 @@
+tosca_definitions_version: cloudify_dsl_1_3
+imports:
+  - 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
+  - 'plugin:k8splugin?version=>=3.4.2,<4.0.0'
+inputs:
+  tag_version:
+    type: string
+    description: Docker image to be used
+    default: 'nexus3.onap.org:10001/onap/org.onap.integration.nfsimulator.vesclient:latest'
+  replicas:
+    type: integer
+    description: Number of instances
+    default: 1
+  external_cert_cert_type:
+    type: string
+    description: Output type
+    default: 'P12'
+  external_cert_ca_name:
+    type: string
+    description: Name of Certificate Authority configured on CertService side.
+    default: 'RA'
+  external_cert_common_name:
+    type: string
+    description: Common name which should be present in certificate.
+    default: 'ves-client'
+  external_cert_sans:
+    type: string
+    description: 'List of Subject Alternative Names (SANs) which should be present
+      in certificate. Delimiter - , Should contain common_name value and other FQDNs
+      under which given component is accessible.'
+    default: 'ves-client'
+  external_cert_use_external_tls:
+    type: boolean
+    description: Flag to indicate external tls enable/disable.
+    default: true
+  service_component_type:
+    type: string
+    default: "ves-client"
+  service_component_name_override:
+    type: string
+    default: "ves-client"
+node_templates:
+  ves-client:
+    type: dcae.nodes.ContainerizedServiceComponent
+    interfaces:
+      cloudify.interfaces.lifecycle:
+        start:
+          inputs:
+            envs:
+              STRICT_HOSTNAME_VERIFICATION: 'true'
+              MONGO_HOSTNAME:
+                concat: ["mongo-", {get_input: service_component_name_override}]
+            ports:
+              - '5000:0'
+    properties:
+      service_component_type: { get_input: service_component_type }
+      service_component_name_override: { get_input: service_component_name_override }
+      image: { get_input: tag_version }
+      replicas: { get_input: replicas }
+      always_pull_image: true
+      tls_info:
+        cert_directory: '/app/store/'
+      external_cert:
+        external_cert_directory: '/app/store/'
+        use_external_tls:
+          get_input: external_cert_use_external_tls
+        cert_type:
+          get_input: external_cert_cert_type
+        ca_name:
+          get_input: external_cert_ca_name
+        external_certificate_parameters:
+          common_name:
+            get_input: external_cert_common_name
+          sans:
+            get_input: external_cert_sans
diff --git a/robot/resources/usecases/5gbulkpm_interface.robot b/robot/resources/usecases/5gbulkpm_interface.robot
index db01f91..00d7306 100644
--- a/robot/resources/usecases/5gbulkpm_interface.robot
+++ b/robot/resources/usecases/5gbulkpm_interface.robot
@@ -42,6 +42,8 @@
 ${EXPECTED_PRINT}                                   StrictHostKeyChecking is enabled but environment variable KNOWN_HOSTS_FILE_PATH is not set or points to not existing file
 ${MONGO_BLUEPRINT_PATH}                             ${EXECDIR}/robot/assets/cmpv2/k8s-mongo.yaml
 ${PNF_SIMULATOR_BLUEPRINT_PATH}                     ${EXECDIR}/robot/assets/cmpv2/k8s-pnf-simulator.yaml
+${MONGO_VES_CLIENT_BLUEPRINT_PATH}                  ${EXECDIR}/robot/assets/cmpv2/k8s-mongo-ves-client.yaml
+${VES_CLIENT_BLUEPRINT_PATH}                        ${EXECDIR}/robot/assets/cmpv2/k8s-ves-client.yaml
 ${VES_INPUTS}                                       deployment/VesTlsCmpv2Inputs.jinja
 ${pm_notification_event}                            dfc/notification.jinja
 ${consul_change_event}                              dfc/consul.jinja
@@ -139,19 +141,26 @@
 
 Usecase Teardown
     Disable Warnings
-    Undeploy Service                    sftpserver
-    Undeploy Service                    ${serviceTypeId-Sftp}
-    Undeploy Service                    datafile
-    Undeploy Service                    pmmapper
-    Undeploy Service                    mongo-dep-5gbulkpm
-    Undeploy Service                    ves-rest-client-dep
-    Undeploy Service                    ves-collector-for-bulkpm-over-https
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                    datafile
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                    pmmapper
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                   sftpserver
+    Delete Blueprint From Inventory     ${serviceTypeId-Sftp}
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                    ves-collector-for-bulkpm-over-https
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                    https-server-dep
+    Delete Blueprint From Inventory     ${serviceTypeId-Https}
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                    https-server-wrong-sans-dep
+    Delete Blueprint From Inventory     ${serviceTypeId-Https-wrong-sans}
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                    mongo-dep-5gbulkpm
+    Wait Until Keyword Succeeds         2 min                      20 sec                       Undeploy Service With Check                    ves-rest-client-dep
     Delete Blueprint From Inventory     ${serviceTypeIdMongo}
     Delete Blueprint From Inventory     ${serviceTypeIdVesClient}
-    Undeploy Service                    https-server-dep
-    Delete Blueprint From Inventory     ${serviceTypeId-Https}
-    Undeploy Service                    https-server-wrong-sans-dep
-    Delete Blueprint From Inventory     ${serviceTypeId-Https-wrong-sans}
+
+
+Undeploy Service With Check
+    [Arguments]                          ${deployment_name}
+    ${resp}                              Undeploy Service               ${deployment_name}
+    Should Not Be Equal As Strings       ${resp.status_code}            400
+
 
 Setting Global Variables
     [Documentation]
@@ -316,12 +325,12 @@
     Set Global Variable                 ${httpsServerWrongSansOperationId}
 
 Deploying VES Client with correct certificates
-    ${serviceTypeIdMongo}               Load Blueprint To Inventory        ${MONGO_BLUEPRINT_PATH}              mongo-5g-bulk-pm
-    ${serviceTypeIdVesClient}           Load Blueprint To Inventory        ${PNF_SIMULATOR_BLUEPRINT_PATH}      ves-rest-client
+    ${serviceTypeIdMongo}               Load Blueprint To Inventory        ${MONGO_VES_CLIENT_BLUEPRINT_PATH}   mongo-5g-bulk-pm
+    ${serviceTypeIdVesClient}           Load Blueprint To Inventory        ${VES_CLIENT_BLUEPRINT_PATH}         ves-rest-client
     Set Suite Variable                  ${serviceTypeIdMongo}
     Set Suite Variable                  ${serviceTypeIdVesClient}
-    ${deployment_data}=                 Set Variable                       {"serviceTypeId": "${serviceTypeIdMongo}"}
-    Deploy Service                      ${deployment_data}                 mongo-dep-5gbulkpm                            2 minutes
+    ${deployment_data}=                 Set Variable                       {"serviceTypeId": "${serviceTypeIdMongo}", "inputs": {"service_component_type": "mongo-ves-client", "service_component_name_override": "mongo-ves-client"}}
+    Deploy Service                      ${deployment_data}                 mongo-dep-5gbulkpm                             2 minutes
     ${resp}=                            Get Blueprint From Inventory       ves-rest-client
     ${json}=                            Set Variable                       ${resp.json()}
     ${image}                            Get Regexp Matches                 ${json['items'][0]['blueprintTemplate']}               nexus3(.)*?(?=\')
@@ -443,4 +452,3 @@
     Should Be Equal As Integers 	${rc} 	                        0
     Wait Until Keyword Succeeds         60 sec          5 sec       Check DFC logs                  kubectl logs -n onap $(kubectl get pods -n onap | grep datafile-collector | awk '{print $1}' | grep -v NAME) ${container_name}-datafile-collector
 
-