Merge "[compass4nfv] add DEPLOY_SCENARIO macro"
authormei mei <meimei@huawei.com>
Tue, 27 Feb 2018 00:59:49 +0000 (00:59 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Tue, 27 Feb 2018 00:59:49 +0000 (00:59 +0000)
jjb/dovetail/dovetail-run.sh
jjb/xci/xci-run-functest.sh
jjb/xci/xci-set-scenario.sh [new file with mode: 0755]
jjb/xci/xci-start-deployment.sh
jjb/xci/xci-start-new-vm.sh
jjb/xci/xci-verify-jobs.yml

index 451662a..ec879e3 100755 (executable)
@@ -199,6 +199,27 @@ if [[ ! -f ${cirros_image} ]]; then
 fi
 sudo cp ${cirros_image} ${DOVETAIL_CONFIG}
 
+# snaps_smoke test case needs to download this image first before running
+ubuntu14_image=${image_path}/ubuntu-14.04-server-cloudimg-amd64-disk1.img
+if [[ ! -f ${ubuntu14_image} ]]; then
+    echo "Download image ubuntu-14.04-server-cloudimg-amd64-disk1.img ..."
+    wget -q -nc https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P ${image_path}
+fi
+sudo cp ${ubuntu14_image} ${DOVETAIL_CONFIG}
+
+# cloudify_ims test case needs to download these 2 images first before running
+cloudify_image=${image_path}/cloudify-manager-premium-4.0.1.qcow2
+if [[ ! -f ${cloudify_image} ]]; then
+    echo "Download image cloudify-manager-premium-4.0.1.qcow2 ..."
+    wget -q -nc http://repository.cloudifysource.org/cloudify/4.0.1/sp-release/cloudify-manager-premium-4.0.1.qcow2 -P ${image_path}
+fi
+sudo cp ${cloudify_image} ${DOVETAIL_CONFIG}
+trusty_image=${image_path}/trusty-server-cloudimg-amd64-disk1.img
+if [[ ! -f ${trusty_image} ]]; then
+    echo "Download image trusty-server-cloudimg-amd64-disk1.img ..."
+    wget -q -nc http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img -P ${image_path}
+fi
+sudo cp ${trusty_image} ${DOVETAIL_CONFIG}
 
 opts="--privileged=true -id"
 
@@ -238,18 +259,6 @@ if [ $(docker ps | grep "${DOCKER_REPO}:${DOCKER_TAG}" | wc -l) == 0 ]; then
     exit 1
 fi
 
-if [[ ! "${SUT_BRANCH}" =~ "danube" && ${INSTALLER_TYPE} == 'fuel' && ${DEPLOY_TYPE} == 'baremetal' ]]; then
-    source_cmd="source ${OPENRC}"
-    get_public_url_cmd="openstack --insecure endpoint list --service keystone --interface public | sed -n 4p | awk '{print \$14}'"
-    public_url=$(sudo docker exec "$container_id" /bin/bash -c "${source_cmd} && ${get_public_url_cmd}")
-    sed -i 's#OS_AUTH_URL=.*#OS_AUTH_URL='"${public_url}"'#g' ${OPENRC}
-    sed -i 's/internal/public/g' ${OPENRC}
-    if [[ ${public_url} =~ 'v2' ]]; then
-        sed -i "s/OS_IDENTITY_API_VERSION=3/OS_IDENTITY_API_VERSION=2.0/g" ${OPENRC}
-    fi
-    cat ${OPENRC}
-fi
-
 # Modify tempest_conf.yaml file
 tempest_conf_file=${DOVETAIL_CONFIG}/tempest_conf.yaml
 if [[ ${INSTALLER_TYPE} == 'compass' || ${INSTALLER_TYPE} == 'apex' ]]; then
index b2421de..39d4ea1 100755 (executable)
@@ -20,6 +20,18 @@ if [[ "$GERRIT_TOPIC" =~ skip-verify|skip-deployment ]]; then
     exit 0
 fi
 
+# if the scenario is external, we need to wipe WORKSPACE to place releng-xci there since
+# the project where the scenario is coming from is cloned and the patch checked out to the
+# xci/scenarios/$DEPLOY_SCENARIO to be synched on clean VM
+# apart from that, we need releng-xci stuff in WORKSPACE for things to function correctly on Jenkins.
+# if the change is coming to releng-xci, we don't need to do anything since the patch is checked
+# out to the WORKSPACE anyways
+if [[ $GERRIT_PROJECT != "releng-xci" ]]; then
+    cd $HOME && /bin/rm -rf $WORKSPACE
+    git clone https://gerrit.opnfv.org/gerrit/releng-xci $WORKSPACE && cd $WORKSPACE
+    chmod -R go-rwx $WORKSPACE/xci/scripts/vm
+fi
+
 # skip the deployment if the scenario is not supported on this distro
 OPNFV_SCENARIO_REQUIREMENTS=$WORKSPACE/xci/opnfv-scenario-requirements.yml
 if ! sed -n "/^- scenario: $DEPLOY_SCENARIO$/,/^$/p" $OPNFV_SCENARIO_REQUIREMENTS | grep -q $DISTRO; then
diff --git a/jjb/xci/xci-set-scenario.sh b/jjb/xci/xci-set-scenario.sh
new file mode 100755 (executable)
index 0000000..4fffafb
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018 SUSE and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+set -o errexit
+set -o nounset
+set -o pipefail
+
+#----------------------------------------------------------------------
+# This script is used by CI and executed by Jenkins jobs.
+# You are not supposed to use this script manually if you don't know
+# what you are doing.
+#----------------------------------------------------------------------
+
+# ensure GERRIT_TOPIC is set
+GERRIT_TOPIC="${GERRIT_TOPIC:-''}"
+# skip the healthcheck if the patch doesn't impact the deployment
+if [[ "$GERRIT_TOPIC" =~ skip-verify|skip-deployment ]]; then
+    echo "Skipping the healthcheck!"
+    exit 0
+fi
+
+# if the scenario is external, we need to wipe WORKSPACE to place releng-xci there since
+# the project where the scenario is coming from is cloned and the patch checked out to the
+# xci/scenarios/$DEPLOY_SCENARIO to be synched on clean VM
+# apart from that, we need releng-xci stuff in WORKSPACE for things to function correctly on Jenkins.
+# if the change is coming to releng-xci, we don't need to do anything since the patch is checked
+# out to the WORKSPACE anyways
+if [[ $GERRIT_PROJECT != "releng-xci" ]]; then
+    cd $HOME && /bin/rm -rf $WORKSPACE
+    git clone https://gerrit.opnfv.org/gerrit/releng-xci $WORKSPACE && cd $WORKSPACE
+    chmod -R go-rwx $WORKSPACE/xci/scripts/vm
+fi
+
+WORK_DIRECTORY=/tmp/$GERRIT_CHANGE_NUMBER/$DISTRO
+/bin/rm -rf $WORK_DIRECTORY && mkdir -p $WORK_DIRECTORY
+
+# if change is coming to releng-xci, continue as usual until that part is fixed as well
+if [[ $GERRIT_PROJECT == "releng-xci" ]]; then
+    # save the scenario name into java properties file to be injected to downstream jobs via envInject
+    echo "Recording scenario name for downstream jobs"
+    echo "DEPLOY_SCENARIO=os-nosdn-nofeature" > $WORK_DIRECTORY/scenario.properties
+    exit 0
+fi
+
+# projects develop different scenarios and jobs need to know which scenario got the
+# change under test so the jobs can deploy and test the right scenario.
+# we need to fetch the change and look at the changeset to find out the scenario instead
+# of hardcoding scenario per project.
+
+git clone https://gerrit.opnfv.org/gerrit/$GERRIT_PROJECT $WORK_DIRECTORY/$GERRIT_PROJECT
+cd $WORK_DIRECTORY/$GERRIT_PROJECT
+git fetch https://gerrit.opnfv.org/gerrit/$GERRIT_PROJECT $GERRIT_REFSPEC && git checkout FETCH_HEAD
+DEPLOY_SCENARIO=$(git diff HEAD^..HEAD --name-only | grep scenarios | sed -r 's/scenarios\/(.*?)\/.*/\1/' | uniq)
+
+# ensure single scenario is impacted
+if [[ $(echo $DEPLOY_SCENARIO | wc -w) != 1 ]]; then
+    echo "Change impacts multiple scenarios!"
+    echo "XCI doesn't support testing of changes that impact multiple scenarios currently."
+    echo "Please split your change into multiple different/dependent changes, each modifying single scenario."
+    exit 1
+fi
+
+# save the scenario name into java properties file to be injected to downstream jobs via envInject
+echo "Recording scenario name '$DEPLOY_SCENARIO' for downstream jobs"
+echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" > $WORK_DIRECTORY/scenario.properties
+
+# skip the deployment if the scenario is not supported on this distro
+OPNFV_SCENARIO_REQUIREMENTS=$WORKSPACE/xci/opnfv-scenario-requirements.yml
+if ! sed -n "/^- scenario: $DEPLOY_SCENARIO$/,/^$/p" $OPNFV_SCENARIO_REQUIREMENTS | grep -q $DISTRO; then
+    echo "# SKIPPED: Scenario $DEPLOY_SCENARIO is NOT supported on $DISTRO"
+    exit 0
+fi
index e86f5b3..cb75b51 100755 (executable)
@@ -20,6 +20,18 @@ if [[ "$GERRIT_TOPIC" =~ skip-verify|skip-deployment ]]; then
     exit 0
 fi
 
+# if the scenario is external, we need to wipe WORKSPACE to place releng-xci there since
+# the project where the scenario is coming from is cloned and the patch checked out to the
+# xci/scenarios/$DEPLOY_SCENARIO to be synched on clean VM
+# apart from that, we need releng-xci stuff in WORKSPACE for things to function correctly on Jenkins.
+# if the change is coming to releng-xci, we don't need to do anything since the patch is checked
+# out to the WORKSPACE anyways
+if [[ $GERRIT_PROJECT != "releng-xci" ]]; then
+    cd $HOME && /bin/rm -rf $WORKSPACE
+    git clone https://gerrit.opnfv.org/gerrit/releng-xci $WORKSPACE && cd $WORKSPACE
+    chmod -R go-rwx $WORKSPACE/xci/scripts/vm
+fi
+
 # skip the deployment if the scenario is not supported on this distro
 OPNFV_SCENARIO_REQUIREMENTS=$WORKSPACE/xci/opnfv-scenario-requirements.yml
 if ! sed -n "/^- scenario: $DEPLOY_SCENARIO$/,/^$/p" $OPNFV_SCENARIO_REQUIREMENTS | grep -q $DISTRO; then
index b38ebe5..d676e26 100755 (executable)
@@ -20,6 +20,18 @@ if [[ "$GERRIT_TOPIC" =~ 'skip-verify' ]]; then
     exit 0
 fi
 
+# if the scenario is external, we need to wipe WORKSPACE to place releng-xci there since
+# the project where the scenario is coming from is cloned and the patch checked out to the
+# xci/scenarios/$DEPLOY_SCENARIO to be synched on clean VM
+# apart from that, we need releng-xci stuff in WORKSPACE for things to function correctly on Jenkins.
+# if the change is coming to releng-xci, we don't need to do anything since the patch is checked
+# out to the WORKSPACE anyways
+if [[ $GERRIT_PROJECT != "releng-xci" ]]; then
+    cd $HOME && /bin/rm -rf $WORKSPACE
+    git clone https://gerrit.opnfv.org/gerrit/releng-xci $WORKSPACE && cd $WORKSPACE
+    chmod -R go-rwx $WORKSPACE/xci/scripts/vm
+fi
+
 # skip the deployment if the scenario is not supported on this distro
 OPNFV_SCENARIO_REQUIREMENTS=$WORKSPACE/xci/opnfv-scenario-requirements.yml
 if ! sed -n "/^- scenario: $DEPLOY_SCENARIO$/,/^$/p" $OPNFV_SCENARIO_REQUIREMENTS | grep -q $DISTRO; then
index c6b6bc4..3902e8e 100644 (file)
                 comment-contains-value: 'reverify'
           projects:
             - project-compare-type: 'ANT'
-              project-pattern: '{project}'
+              project-pattern: 'releng-xci'
               branches:
                 - branch-compare-type: 'ANT'
                   branch-pattern: '**/{branch}'
               forbidden-file-paths:
                 - compare-type: ANT
                   pattern: 'xci/scripts/vm/**'
+            - project-compare-type: 'REG_EXP'
+              project-pattern: 'sfc|bgpvpn'
+              branches:
+                - branch-compare-type: 'ANT'
+                  branch-pattern: '**/{branch}'
+              disable-strict-forbidden-file-verification: 'true'
+              file-paths:
+                - compare-type: ANT
+                  pattern: 'scenarios/**'
           readable-message: true
           custom-url: '* $JOB_NAME $BUILD_URL'
           skip-vote:
 
     parameters:
       - project-parameter:
-          project: '{project}'
+          project: $GERRIT_PROJECT
           branch: '{branch}'
       - label:
           name: SLAVE_LABEL
           default: 'xci-virtual'
+      - string:
+          name: DISTRO
+          default: '{distro}'
       - string:
           name: CLEAN_DIB_IMAGES
           default: 'true'
           description: 'Git URL to use on this Jenkins Slave'
 
     builders:
+      - 'xci-verify-set-scenario-macro'
+      - inject:
+          properties-file: "/tmp/$GERRIT_CHANGE_NUMBER/$DISTRO/scenario.properties"
       - description-setter:
-          description: "Built on $NODE_NAME"
+          description: "Scenario: $DEPLOY_SCENARIO | Node: $NODE_NAME"
       - multijob:
           name: deploy
           condition: SUCCESSFUL
               current-parameters: true
               predefined-parameters: |
                 DISTRO={distro}
-                DEPLOY_SCENARIO=os-nosdn-nofeature
                 CLEAN_DIB_IMAGES=$CLEAN_DIB_IMAGES
+                GERRIT_PROJECT=$GERRIT_PROJECT
                 GERRIT_BRANCH=$GERRIT_BRANCH
                 GERRIT_REFSPEC=$GERRIT_REFSPEC
                 GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
               current-parameters: true
               predefined-parameters: |
                 DISTRO={distro}
-                DEPLOY_SCENARIO=os-nosdn-nofeature
                 CLEAN_DIB_IMAGES=$CLEAN_DIB_IMAGES
-                FUNCTEST_MODE=tier
-                FUNCTEST_TIER=healthcheck
+                GERRIT_PROJECT=$GERRIT_PROJECT
                 GERRIT_BRANCH=$GERRIT_BRANCH
                 GERRIT_REFSPEC=$GERRIT_REFSPEC
                 GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
                 GERRIT_CHANGE_COMMIT_MESSAGE=$GERRIT_CHANGE_COMMIT_MESSAGE
+                FUNCTEST_MODE=tier
+                FUNCTEST_TIER=healthcheck
               node-parameters: true
               kill-phase-on: NEVER
               abort-all-job: true
     parameters:
       - string:
           name: PROJECT
-          default: 'releng-xci'
+          default: $GERRIT_PROJECT
       - string:
           name: DISTRO
           default: 'ubuntu'
-      - string:
-          name: DEPLOY_SCENARIO
-          default: 'os-nosdn-nofeature'
       - string:
           name: FUNCTEST_MODE
           default: 'tier'
           description: 'Git URL to use on this Jenkins Slave'
 
     wrappers:
+      - inject:
+          properties-file: "/tmp/$GERRIT_CHANGE_NUMBER/$DISTRO/scenario.properties"
       - ssh-agent-wrapper
       - build-timeout:
           timeout: 240
 
     builders:
       - description-setter:
-          description: "Built on $NODE_NAME"
+          description: "Scenario: $DEPLOY_SCENARIO | Node: $NODE_NAME"
       - 'xci-verify-{phase}-macro'
 
 # -------------------------------
 # builder macros
 # -------------------------------
+- builder:
+    name: 'xci-verify-set-scenario-macro'
+    builders:
+      - shell:
+          !include-raw: ./xci-set-scenario.sh
+
 - builder:
     name: 'xci-verify-deploy-macro'
     builders: