summaryrefslogtreecommitdiffstats
path: root/jjb/xci
diff options
context:
space:
mode:
Diffstat (limited to 'jjb/xci')
-rwxr-xr-xjjb/xci/xci-run-functest.sh12
-rwxr-xr-xjjb/xci/xci-set-scenario.sh80
-rwxr-xr-xjjb/xci/xci-start-deployment.sh12
-rwxr-xr-xjjb/xci/xci-start-new-vm.sh13
-rw-r--r--jjb/xci/xci-verify-jobs.yml46
5 files changed, 151 insertions, 12 deletions
diff --git a/jjb/xci/xci-run-functest.sh b/jjb/xci/xci-run-functest.sh
index b2421de32..39d4ea190 100755
--- a/jjb/xci/xci-run-functest.sh
+++ b/jjb/xci/xci-run-functest.sh
@@ -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
index 000000000..59205e291
--- /dev/null
+++ b/jjb/xci/xci-set-scenario.sh
@@ -0,0 +1,80 @@
+#!/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.
+#----------------------------------------------------------------------
+
+WORK_DIRECTORY=/tmp/$GERRIT_CHANGE_NUMBER/$DISTRO
+/bin/rm -rf $WORK_DIRECTORY && mkdir -p $WORK_DIRECTORY
+
+# 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 verify!"
+ echo "DEPLOY_SCENARIO=os-nosdn-nofeature" > $WORK_DIRECTORY/scenario.properties
+ 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
+
+# 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
diff --git a/jjb/xci/xci-start-deployment.sh b/jjb/xci/xci-start-deployment.sh
index e86f5b3a1..cb75b511e 100755
--- a/jjb/xci/xci-start-deployment.sh
+++ b/jjb/xci/xci-start-deployment.sh
@@ -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-start-new-vm.sh b/jjb/xci/xci-start-new-vm.sh
index 2c6ec3fad..d676e2662 100755
--- a/jjb/xci/xci-start-new-vm.sh
+++ b/jjb/xci/xci-start-new-vm.sh
@@ -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
@@ -35,6 +47,7 @@ cd $WORKSPACE
# yourself.
cat > xci_test.sh<<EOF
#!/bin/bash
+set -o pipefail
export DISTRO=$DISTRO
export DEPLOY_SCENARIO=$DEPLOY_SCENARIO
export FUNCTEST_MODE=$FUNCTEST_MODE
diff --git a/jjb/xci/xci-verify-jobs.yml b/jjb/xci/xci-verify-jobs.yml
index c6b6bc43b..c54a1b941 100644
--- a/jjb/xci/xci-verify-jobs.yml
+++ b/jjb/xci/xci-verify-jobs.yml
@@ -102,7 +102,7 @@
comment-contains-value: 'reverify'
projects:
- project-compare-type: 'ANT'
- project-pattern: '{project}'
+ project-pattern: 'releng-xci'
branches:
- branch-compare-type: 'ANT'
branch-pattern: '**/{branch}'
@@ -110,6 +110,15 @@
forbidden-file-paths:
- compare-type: ANT
pattern: 'xci/scripts/vm/**'
+ - project-compare-type: 'REG_EXP'
+ project-pattern: 'sfc|sdnvpn'
+ 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:
@@ -120,12 +129,15 @@
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'
- string:
@@ -134,8 +146,11 @@
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
@@ -144,8 +159,8 @@
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
@@ -161,14 +176,14 @@
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
@@ -194,14 +209,11 @@
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'
- string:
@@ -225,6 +237,8 @@
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
@@ -235,13 +249,19 @@
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:
- shell:
@@ -254,4 +274,6 @@
name: 'xci-verify-healthcheck-macro'
builders:
- shell:
+ !include-raw: ./xci-run-functest.sh
+ - shell:
!include-raw: ./xci-cleanup.sh