summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFatih Degirmenci <fdegir@gmail.com>2018-03-12 12:42:30 +0100
committerFatih Degirmenci <fdegir@gmail.com>2018-03-12 12:46:44 +0100
commit822d2780d4987441b7f379ca670f4c8e9c782489 (patch)
tree38b9a4b00449b845b98c5eb8030f8a96800a0b16
parent2bf0aeb40a0c9801a49820874ae2de809d0045bc (diff)
xci: Determine impacted generic scenario
Change-Id: Ifbe676cd347c2d3c68f04b5137f3ccaa83a95894 Signed-off-by: Fatih Degirmenci <fdegir@gmail.com>
-rwxr-xr-xjjb/xci/xci-set-scenario.sh54
1 files changed, 39 insertions, 15 deletions
diff --git a/jjb/xci/xci-set-scenario.sh b/jjb/xci/xci-set-scenario.sh
index 9a6cb51c5..5e97b8b43 100755
--- a/jjb/xci/xci-set-scenario.sh
+++ b/jjb/xci/xci-set-scenario.sh
@@ -8,7 +8,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
set -o errexit
-set -o nounset
set -o pipefail
#----------------------------------------------------------------------
@@ -17,14 +16,37 @@ set -o pipefail
# what you are doing.
#----------------------------------------------------------------------
-# This function will determine the impacted generic scenario by processing the
-# change and using diff to see what changed.
-# It currently sets the scenario to os-nosdn-nofeature.
+# This function determines the impacted generic scenario by processing the
+# change and using diff to see what changed. If changed files belong to a scenario
+# its name gets recorded for deploying and testing the right scenario.
+#
+# Pattern
+# releng-xci/scenarios/<scenario>/<impacted files>: <scenario>
+# releng-xci/xci/installer/osa/<impacted files>: os-nosdn-nofeature
+# releng-xci/xci/installer/kubespray/<impacted files>: k8-nosdn-nofeature
+# the rest: os-nosdn-nofeature
function determine_generic_scenario() {
- echo "Processing $GERRIT_PROJECT $GERRIT_REFSPEC"
-
- # set the default scenario
- DEPLOY_SCENARIO="os-nosdn-nofeature"
+ echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC"
+
+ # get the changeset
+ cd $WORKSPACE
+ CHANGESET=$(git diff HEAD^..HEAD --name-only)
+ for CHANGED_FILE in $CHANGESET; do
+ case $CHANGED_FILE in
+ *k8-nosdn*|*kubespray*)
+ [[ ${DEPLOY_SCENARIO[@]} =~ "k8-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='k8-nosdn-nofeature'
+ ;;
+ *os-odl*)
+ [[ ${DEPLOY_SCENARIO[@]} =~ "os-odl-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-odl-nofeature'
+ ;;
+ *os-nosdn*|*osa*)
+ [[ ${DEPLOY_SCENARIO[@]} =~ "os-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-nosdn-nofeature'
+ ;;
+ *)
+ [[ ${DEPLOY_SCENARIO[@]} =~ "os-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-nosdn-nofeature'
+ ;;
+ esac
+ done
}
# This function determines the impacted external scenario by processing the Gerrit
@@ -34,7 +56,7 @@ function determine_generic_scenario() {
# Pattern
# <project-repo>/scenarios/<scenario>/<impacted files>: <scenario>
function determine_external_scenario() {
- echo "Processing $GERRIT_PROJECT $GERRIT_REFSPEC"
+ echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC"
# remove the clone that is done via jenkins and place releng-xci there so the
# things continue functioning properly
@@ -50,11 +72,13 @@ function determine_external_scenario() {
git fetch -q https://gerrit.opnfv.org/gerrit/$GERRIT_PROJECT $GERRIT_REFSPEC && git checkout -q FETCH_HEAD
# process the diff to find out what scenario(s) are impacted - there should only be 1
- DEPLOY_SCENARIO=$(git diff HEAD^..HEAD --name-only | grep scenarios | awk -F '[/|/]' '{print $2}' | uniq)
+ DEPLOY_SCENARIO+=$(git diff HEAD^..HEAD --name-only | grep scenarios | awk -F '[/|/]' '{print $2}' | uniq)
}
echo "Determining the impacted scenario"
+declare -a DEPLOY_SCENARIO
+
# ensure GERRIT_TOPIC is set
GERRIT_TOPIC="${GERRIT_TOPIC:-''}"
@@ -77,7 +101,7 @@ else
fi
# ensure single scenario is impacted
-if [[ $(echo $DEPLOY_SCENARIO | wc -w) != 1 ]]; then
+ if [[ $(IFS=$'\n' 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."
@@ -85,7 +109,7 @@ if [[ $(echo $DEPLOY_SCENARIO | wc -w) != 1 ]]; then
fi
# set the installer
-case $DEPLOY_SCENARIO in
+case ${DEPLOY_SCENARIO[0]} in
os-*)
XCI_INSTALLER=osa
;;
@@ -100,13 +124,13 @@ esac
# save the installer and scenario names into java properties file
# so they can be injected to downstream jobs via envInject
-echo "Recording the installer '$XCI_INSTALLER' and scenario '$DEPLOY_SCENARIO' for downstream jobs"
+echo "Recording the installer '$XCI_INSTALLER' and scenario '${DEPLOY_SCENARIO[0]}' for downstream jobs"
echo "XCI_INSTALLER=$XCI_INSTALLER" > $WORK_DIRECTORY/scenario.properties
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"
+if ! sed -n "/^- scenario: ${DEPLOY_SCENARIO[0]}$/,/^$/p" $OPNFV_SCENARIO_REQUIREMENTS | grep -q $DISTRO; then
+ echo "# SKIPPED: Scenario ${DEPLOY_SCENARIO[0]} is NOT supported on $DISTRO"
exit 0
fi