engine: Adapt testing to stack oriented framework

Change-Id: I28fdaec0f103651cfc6361aba09639c55aa4aa2a
diff --git a/jjb/engine/scripts/deploy.sh b/jjb/engine/scripts/deploy.sh
index d52bbfa..abd2414 100755
--- a/jjb/engine/scripts/deploy.sh
+++ b/jjb/engine/scripts/deploy.sh
@@ -44,6 +44,10 @@
 /bin/cp -f $OPENRC_FILE /tmp/openrc
 
 cd "$ENGINE_ROOT_DIR/engine"
-./deploy.sh -s "$STACK_TYPE" -b "$STACK_VERSION" -p "$PDF" -i "$IDF" -o /tmp/openrc -d "$DISTRO" -v
+./deploy.sh -s "$STACK_TYPE" -b "$STACK_VERSION" -c "$DEPLOY_SCENARIO" -p "$PDF" -i "$IDF" -o /tmp/openrc -d "$DISTRO" -v
+
+# NOTE (fdegir): we need inventory.ini for test execution
+/bin/rm -f /tmp/inventory.ini
+/bin/cp -f /opt/engine/.cache/config/inventory.ini /tmp/inventory.ini
 
 # vim: set ts=2 sw=2 expandtab:
diff --git a/jjb/engine/scripts/functest.sh b/jjb/engine/scripts/functest.sh
index 14a2b0c..6438dda 100755
--- a/jjb/engine/scripts/functest.sh
+++ b/jjb/engine/scripts/functest.sh
@@ -42,7 +42,11 @@
 cd $HOME && /bin/rm -rf $WORKSPACE
 git clone -q $TEST_REPO_URL $WORKSPACE
 
+# NOTE (fdegir): we need to override execution mode variable coming from change.properties file
+export EXECUTION_MODE=$(echo "$EXECUTION_MODE" | sed 's/deployment/test/g')
+
 cd $WORKSPACE/test
-./test.sh -f $TEST_FW -t $TEST_SUITE -s $STACK_TYPE -y $YARDSTICK_DISPATCHER -d
+./test.sh -s "$STACK_TYPE" -b "$STACK_VERSION" -c "$DEPLOY_SCENARIO" -f "$TEST_FW" -t "$TEST_SUITE" \
+    -o /tmp/openrc -i /tmp/inventory.ini -y "$YARDSTICK_DISPATCHER" -v
 
 # vim: set ts=2 sw=2 expandtab:
diff --git a/jjb/engine/scripts/generate-change-metadata.sh b/jjb/engine/scripts/generate-change-metadata.sh
index 2ad1e5f..84b7146 100755
--- a/jjb/engine/scripts/generate-change-metadata.sh
+++ b/jjb/engine/scripts/generate-change-metadata.sh
@@ -49,13 +49,33 @@
   export STACK_VERSION="$GERRIT_PATCHSET_REVISION"
   export STACK_REFSPEC="$GERRIT_REFSPEC"
 
+  case "${STACK_TYPE}" in
+    openstack)
+      echo "Info  : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
+      ;;
+    kubernetes)
+      echo "Info  : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
+      ;;
+    onap)
+      echo "Info  : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
+      ;;
+    ironic)
+      export DEPLOY_SCENARIO="ubuntu1804"
+      ;;
+    *) echo "ERROR : Invalid stack $ENGINE_COMPONENT"; exit 1;;
+  esac
+
+  export STACK_VERSION="$GERRIT_BRANCH"
+
   # log info to console
   echo "        STACK_TYPE=$STACK_TYPE"
+  echo "        DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
   echo "        STACK_VERSION=$GERRIT_PATCHSET_REVISION"
   echo "        STACK_REFSPEC=$GERRIT_REFSPEC"
 
   # record vars to properties file
   echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
+  echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
   echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
   echo "STACK_REFSPEC=$STACK_REFSPEC" >> "$CHANGE_METADATA_FILE"
 elif [[ "$GERRIT_PROJECT" =~ /installer/ ]]; then
@@ -63,12 +83,15 @@
   case "${ENGINE_COMPONENT}" in
     kolla)
       export STACK_TYPE="openstack"
+      echo "Info  : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
       ;;
     kubespray)
       export STACK_TYPE="kubernetes"
+      echo "Info  : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
       ;;
     oom)
       export STACK_TYPE="onap"
+      echo "Info  : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
       ;;
     *) echo "ERROR : Invalid engine component $ENGINE_COMPONENT"; exit 1;;
   esac
@@ -76,12 +99,14 @@
 
   # log info to console
   echo "        STACK_TYPE=$STACK_TYPE"
+  echo "        DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
   echo "        STACK_VERSION=$STACK_VERSION"
   echo "        NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION"
   echo "        NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC"
 
   # record vars to properties file
   echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
+  echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
   echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
   echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE"
   echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE"
@@ -92,12 +117,14 @@
 
   # log info to console
   echo "        STACK_TYPE=$STACK_TYPE"
+  echo "        DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
   echo "        STACK_VERSION=$STACK_VERSION"
   echo "        NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION"
   echo "        NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC"
 
   # record vars to properties file
-  echo "STACK_TYPE=kubernetes" >> "$CHANGE_METADATA_FILE"
+  echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
+  echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
   echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
   echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE"
   echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE"
diff --git a/jjb/engine/verify-jobs/engine-verify-deploy-test.yaml b/jjb/engine/verify-jobs/engine-verify-deploy-test.yaml
index b00de3f..7834f1b 100644
--- a/jjb/engine/verify-jobs/engine-verify-deploy-test.yaml
+++ b/jjb/engine/verify-jobs/engine-verify-deploy-test.yaml
@@ -25,6 +25,7 @@
     stream:
       - 'master':
           branch: '{stream}'
+          deploy-scenario: 'k8-multus-plugins'
 
     environment-type:
       - online:
@@ -85,6 +86,10 @@
 
     parameters:
       - string:
+          name: DEPLOY_SCENARIO
+          default: '{deploy-scenario}'
+          description: 'Scenario to test change with.'
+      - string:
           name: DISTRO
           default: '{distro}'
           description: 'Distribution to use for configuring target nodes (networking etc.)'
diff --git a/jjb/engine/verify-jobs/ironic-verify-deploy-test.yaml b/jjb/engine/verify-jobs/ironic-verify-deploy-test.yaml
index 2ac1df6..2ae78fe 100644
--- a/jjb/engine/verify-jobs/ironic-verify-deploy-test.yaml
+++ b/jjb/engine/verify-jobs/ironic-verify-deploy-test.yaml
@@ -25,6 +25,7 @@
     stream:
       - 'master':
           branch: '{stream}'
+          deploy-scenario: 'k8-multus-plugins'
 
     environment-type:
       - online:
@@ -78,6 +79,10 @@
 
     parameters:
       - string:
+          name: DEPLOY_SCENARIO
+          default: '{deploy-scenario}'
+          description: 'Scenario to test change with. This depends on the branch of the stack'
+      - string:
           name: DISTRO
           default: '{distro}'
           description: 'Distribution to use for configuring target nodes (networking etc.)'
diff --git a/jjb/engine/verify-jobs/kubernetes-verify-deploy-test.yaml b/jjb/engine/verify-jobs/kubernetes-verify-deploy-test.yaml
index 45e5f41..4093ba5 100644
--- a/jjb/engine/verify-jobs/kubernetes-verify-deploy-test.yaml
+++ b/jjb/engine/verify-jobs/kubernetes-verify-deploy-test.yaml
@@ -28,10 +28,13 @@
     stream:
       - 'master':
           branch: 'master'
+          deploy-scenario: 'k8-multus-plugins'
       - '1_17':
           branch: '1.17'
+          deploy-scenario: 'k8-multus-plugins'
       - '1_15':
           branch: '1.15'
+          deploy-scenario: 'k8-calico-nofeature'
 
     environment-type:
       - online:
@@ -92,6 +95,10 @@
 
     parameters:
       - string:
+          name: DEPLOY_SCENARIO
+          default: '{deploy-scenario}'
+          description: 'Scenario to test change with. This depends on the branch of the stack'
+      - string:
           name: DISTRO
           default: '{distro}'
           description: 'Distribution to use for configuring target nodes (networking etc.)'
diff --git a/jjb/engine/verify-jobs/onap-verify-deploy-test.yaml b/jjb/engine/verify-jobs/onap-verify-deploy-test.yaml
index b2726ca..cf3a3db 100644
--- a/jjb/engine/verify-jobs/onap-verify-deploy-test.yaml
+++ b/jjb/engine/verify-jobs/onap-verify-deploy-test.yaml
@@ -25,10 +25,13 @@
     stream:
       - 'master':
           branch: '{stream}'
+          deploy-scenario: 'onap-sdc-full'
       - 'frankfurt':
           branch: '{stream}'
+          deploy-scenario: 'onap-sdc-full'
       - 'elalto':
           branch: '{stream}'
+          deploy-scenario: 'onap-sdc-full'
 
     environment-type:
       - online:
@@ -83,6 +86,10 @@
 
     parameters:
       - string:
+          name: DEPLOY_SCENARIO
+          default: '{deploy-scenario}'
+          description: 'Scenario to test change with.'
+      - string:
           name: DISTRO
           default: '{distro}'
           description: 'Distribution to use for configuring target nodes (networking etc.)'
diff --git a/jjb/engine/verify-jobs/openstack-verify-deploy-test.yaml b/jjb/engine/verify-jobs/openstack-verify-deploy-test.yaml
index d492e57..5125be3 100644
--- a/jjb/engine/verify-jobs/openstack-verify-deploy-test.yaml
+++ b/jjb/engine/verify-jobs/openstack-verify-deploy-test.yaml
@@ -25,10 +25,13 @@
     stream:
       - 'master':
           branch: '{stream}'
+          deploy-scenario: 'os-nosdn-nofeature'
       - 'train':
           branch: '{stream}'
+          deploy-scenario: 'os-nosdn-nofeature'
       - 'stein':
           branch: '{stream}'
+          deploy-scenario: 'os-nosdn-nofeature'
 
     environment-type:
       - online:
@@ -83,6 +86,10 @@
 
     parameters:
       - string:
+          name: DEPLOY_SCENARIO
+          default: '{deploy-scenario}'
+          description: 'Scenario to test change with.'
+      - string:
           name: DISTRO
           default: '{distro}'
           description: 'Distribution to use for configuring target nodes (networking etc.)'