From: Fatih Degirmenci Date: Wed, 10 Apr 2019 07:36:03 +0000 (+0200) Subject: Create jobs to verify changes to scenarios X-Git-Url: https://gerrit.nordix.org/gitweb?a=commitdiff_plain;ds=sidebyside;h=d48647dcfa5724ec1ebdb4b883580e3f3ad48215;p=infra%2Fcicd.git Create jobs to verify changes to scenarios Currently only commit message based scenario determination is in place. Determining the scenario based on the changed files is yet to be implemented. The scripts and the jobs will be refactored to increase the reuse and reduce the duplication once the basic scenario verification is working. Change-Id: I4b936c955828f34f263e9825a465bba25e4688c1 --- diff --git a/jjb/cloud-infra/cloud-infra-macros.yaml b/jjb/cloud-infra/cloud-infra-macros.yaml index d5df7fc3b..499c41aeb 100644 --- a/jjb/cloud-infra/cloud-infra-macros.yaml +++ b/jjb/cloud-infra/cloud-infra-macros.yaml @@ -31,7 +31,7 @@ name: 'cloud-infra-functest-macro' builders: - shell: - !include-raw: ./prepare-for-test.sh + !include-raw: ./prepare-for-testfw-verify.sh - shell: !include-raw: ./cloud-infra-test.sh @@ -39,7 +39,7 @@ name: 'cloud-infra-yardstick-macro' builders: - shell: - !include-raw: ./prepare-for-test.sh + !include-raw: ./prepare-for-testfw-verify.sh - shell: !include-raw: ./cloud-infra-test.sh @@ -49,4 +49,17 @@ - shell: !include-raw: ./cloud-infra-test.sh +- builder: + name: 'cloud-infra-scenario-deploy-macro' + builders: + - shell: + !include-raw: ./wait-for-pkg-manager.sh + - shell: + !include-raw: ./cloud-infra-scenario-deploy.sh + +- builder: + name: 'cloud-infra-scenario-functest-macro' + builders: + - shell: + !include-raw: ./cloud-infra-scenario-test.sh # vim: set ts=2 sw=2 expandtab: diff --git a/jjb/cloud-infra/cloud-infra-periodic-engine.yaml b/jjb/cloud-infra/cloud-infra-periodic-engine.yaml index 97c230659..5cf2eace8 100644 --- a/jjb/cloud-infra/cloud-infra-periodic-engine.yaml +++ b/jjb/cloud-infra/cloud-infra-periodic-engine.yaml @@ -138,6 +138,7 @@ use-build-blocker: true blocking-jobs: - 'cloud-infra-verify-engine-{os}-.*' + - 'cloud-infra-verify-scenario-{os}-.*' - 'cloud-infra-periodic-engine-{os}-.*' - 'cloud-infra-os-.*' - 'cloud-infra-k8-.*' diff --git a/jjb/cloud-infra/cloud-infra-scenario-deploy.sh b/jjb/cloud-infra/cloud-infra-scenario-deploy.sh new file mode 100644 index 000000000..978ab61f4 --- /dev/null +++ b/jjb/cloud-infra/cloud-infra-scenario-deploy.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2019 The Nordix Foundation. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +set -o errexit +set -o nounset +set -o pipefail + +# this function processes commit message to determine the impacted scenario +# using the input provided by the committer. +# +# installer type and scenario should be placed at the beginning of lines +# separately and the format of the entry in commit message is as below +# +# installer-type: +# deploy-scenario: +# +# example is +# +# installer-type: kubespray +# deploy-scenario: k8-calico-nofeature +function override_installer_scenario() { + echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC to determine the installer and the scenario" + cd $WORKSPACE + COMMIT_MESSAGE=$(git show -s --format=%B) + + if [[ "$COMMIT_MESSAGE" =~ "deploy-scenario:" && "$COMMIT_MESSAGE" =~ "installer-type:" ]]; then + export INSTALLER_TYPE=$(echo "$COMMIT_MESSAGE" | grep '^installer-type:' | cut -d":" -f2 | sed 's/\s*//g') + export DEPLOY_SCENARIO=$(echo "$COMMIT_MESSAGE" | grep '^deploy-scenario:' | cut -d":" -f2 | sed 's/\s*//g') + generate_temporary_sdf + else + echo "Installer type or deploy scenario is not specified." + echo "Falling back to programmatically determining them." + determine_scenario + fi +} + +# this function will process the changed files to determine the impacted scenario +# if it is no specified by the committer. only one scenario per change should be +# touched. +# TODO: this is not implented yet. +function determine_scenario() { + echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC" + cd $WORKSPACE + COMMIT_MESSAGE=$(git show -s --format=%B) + echo "Not implemented!" + exit 1 +} + +# this function generates temporary sdf file with the details of the impacted +# scenario. +function generate_temporary_sdf() { +echo "Generating temporary SDF to use for verification" + cat << EOF > $WORKSPACE/sdf.yml +scenario: + $DEPLOY_SCENARIO: + scm: git + src: $PROJECT_GIT_URL + version: $GERRIT_PATCHSET_REVISION + refspec: $GERRIT_REFSPEC + installers: + $INSTALLER_TYPE: + role: scenarios/$DEPLOY_SCENARIO/$INSTALLER_TYPE/role/$DEPLOY_SCENARIO + distros: + - ubuntu +EOF +} + +echo "Determining the impacted scenario" + +declare -a DEPLOY_SCENARIO + +override_installer_scenario +generate_temporary_sdf + +# determine PDF +if [[ $DEPLOY_TYPE == "baremetal" ]]; then + PDF="https://gerrit.nordix.org/gitweb?p=infra/hwconfig.git;a=blob_plain;f=pods/${NODE_NAME}-pdf.yml" + IDF="https://gerrit.nordix.org/gitweb?p=infra/hwconfig.git;a=blob_plain;f=pods/${NODE_NAME}-idf.yml" +else + PDF="https://gerrit.nordix.org/gitweb?p=infra/hwconfig.git;a=blob_plain;f=pods/nordix-vpod1-pdf.yml" + IDF="https://gerrit.nordix.org/gitweb?p=infra/hwconfig.git;a=blob_plain;f=pods/nordix-vpod1-idf.yml" +fi + +# clone infra/engine repository +echo "Deploying scenario $DEPLOY_SCENARIO using $INSTALLER_TYPE" +cd $WORKSPACE && git clone -q $ENGINE_REPO_URL +cd engine +./engine/deploy.sh -d kubespray -s $DEPLOY_SCENARIO -p $PDF -i $IDF -b $WORKSPACE/sdf.yml -c + +# vim: set ts=2 sw=2 expandtab: diff --git a/jjb/cloud-infra/cloud-infra-scenario-test.sh b/jjb/cloud-infra/cloud-infra-scenario-test.sh new file mode 100644 index 000000000..755ad730c --- /dev/null +++ b/jjb/cloud-infra/cloud-infra-scenario-test.sh @@ -0,0 +1,102 @@ +#!/bin/bash + + +# vim: set ts=2 sw=2 expandtab: +#!/bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2019 The Nordix Foundation. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +set -o errexit +set -o nounset +set -o pipefail + +# this function processes commit message to determine the impacted scenario +# using the input provided by the committer. +# +# installer type and scenario should be placed at the beginning of lines +# separately and the format of the entry in commit message is as below +# +# installer-type: +# deploy-scenario: +# +# example is +# +# installer-type: kubespray +# deploy-scenario: k8-calico-nofeature +function override_installer_scenario() { + echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC to determine the installer and the scenario" + cd $WORKSPACE + COMMIT_MESSAGE=$(git show -s --format=%B) + + if [[ "$COMMIT_MESSAGE" =~ "deploy-scenario:" && "$COMMIT_MESSAGE" =~ "installer-type:" ]]; then + export INSTALLER_TYPE=$(echo "$COMMIT_MESSAGE" | grep '^installer-type:' | cut -d":" -f2 | sed 's/\s*//g') + export DEPLOY_SCENARIO=$(echo "$COMMIT_MESSAGE" | grep '^deploy-scenario:' | cut -d":" -f2 | sed 's/\s*//g') + generate_temporary_sdf + else + echo "Installer type or deploy scenario is not specified." + echo "Falling back to programmatically determining them." + determine_scenario + fi +} + +# this function will process the changed files to determine the impacted scenario +# if it is no specified by the committer. only one scenario per change should be +# touched. +# TODO: this is not implented yet. +function determine_scenario() { + echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC" + cd $WORKSPACE + COMMIT_MESSAGE=$(git show -s --format=%B) + echo "Not implemented!" + exit 1 +} + +# this function generates temporary sdf file with the details of the impacted +# scenario. +function generate_temporary_sdf() { +echo "Generating temporary SDF to use for verification" + cat << EOF > $WORKSPACE/sdf.yml +scenario: + $DEPLOY_SCENARIO: + scm: git + src: $PROJECT_GIT_URL + version: $GERRIT_PATCHSET_REVISION + refspec: $GERRIT_REFSPEC + installers: + $INSTALLER_TYPE: + role: scenarios/$DEPLOY_SCENARIO/$INSTALLER_TYPE/role/$DEPLOY_SCENARIO + distros: + - ubuntu +EOF +} + +echo "Determining the impacted scenario" + +declare -a DEPLOY_SCENARIO + +override_installer_scenario +generate_temporary_sdf + +# execute cloud engine test.sh script with arguments +echo "Testing scenario $DEPLOY_SCENARIO deployed using $INSTALLER_TYPE" +cd $WORKSPACE && git clone -q $TEST_REPO_URL +cd test +./test/test.sh -c -f $TEST_FW -t $TEST_SUITE -s $DEPLOY_SCENARIO + +# vim: set ts=2 sw=2 expandtab: diff --git a/jjb/cloud-infra/cloud-infra-verify-engine.yaml b/jjb/cloud-infra/cloud-infra-verify-engine.yaml index e7f768195..61a6eacc4 100644 --- a/jjb/cloud-infra/cloud-infra-verify-engine.yaml +++ b/jjb/cloud-infra/cloud-infra-verify-engine.yaml @@ -75,7 +75,7 @@ jobs: - 'cloud-infra-verify-engine-{os}-{type}-{stream}' - - 'cloud-infra-verify-{os}-{phase}-{type}-{stream}' + - 'cloud-infra-verify-engine-{os}-{phase}-{type}-{stream}' - job-template: name: 'cloud-infra-verify-engine-{os}-{type}-{stream}' @@ -138,6 +138,7 @@ use-build-blocker: true blocking-jobs: - 'cloud-infra-verify-engine-{os}-.*' + - 'cloud-infra-verify-scenario-{os}-.*' - 'cloud-infra-periodic-engine-{os}-.*' - 'cloud-infra-os-.*' - 'cloud-infra-k8-.*' @@ -169,7 +170,7 @@ name: deploy condition: SUCCESSFUL projects: - - name: 'cloud-infra-verify-{os}-deploy-{type}-{stream}' + - name: 'cloud-infra-verify-engine-{os}-deploy-{type}-{stream}' current-parameters: true predefined-parameters: | DISTRIBUTION=$DISTRIBUTION @@ -192,7 +193,7 @@ name: functest condition: SUCCESSFUL projects: - - name: 'cloud-infra-verify-{os}-functest-{type}-{stream}' + - name: 'cloud-infra-verify-engine-{os}-functest-{type}-{stream}' current-parameters: true predefined-parameters: | DISTRIBUTION=$DISTRIBUTION @@ -214,7 +215,7 @@ abort-all-job: true - job-template: - name: 'cloud-infra-verify-{os}-{phase}-{type}-{stream}' + name: 'cloud-infra-verify-engine-{os}-{phase}-{type}-{stream}' disabled: false diff --git a/jjb/cloud-infra/cloud-infra-verify-scenario.yaml b/jjb/cloud-infra/cloud-infra-verify-scenario.yaml new file mode 100644 index 000000000..0d4157061 --- /dev/null +++ b/jjb/cloud-infra/cloud-infra-verify-scenario.yaml @@ -0,0 +1,287 @@ +--- +# +# ============LICENSE_START======================================================= +# Copyright (C) 2019 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +#-------------------------------------------------------------------------------------- +# The jobs declared in this JJB configuration file are used for verifying patches +# that are sent to the repositories below +# - cloud-infra/swconfig +# +# These jobs verify changes that +# - implement new scenarios or fix bugs in the existing scenarios +# +# These jobs are set to run on slaves with label vpod-deploy-ubuntu1604. +# The slaves have +# - Ubuntu1604 as the base distro +# - nested virtualization +# - internet access +# - passwordless sudo +# - 16 CPUs/32GB RAM/200 GB Disk +# - docker, git vim curl wget zip unzip chrony apt-transport-https ca-certificates curl +# gnupg-agent software-properties-common docker-ce docker-ce-cli containerd.io openjdk-8-jre +# +# The slaves should not have a cloud infra scenario deployed on them. +#-------------------------------------------------------------------------------------- + +- project: + name: 'cloud-infra-verify-scenario' + + project: 'infra/swconfig' + + stream: + - 'master': + branch: '{stream}' + disabled: 'false' + + os: + - ubuntu1804: + disabled: 'false' + distribution: 'ubuntu18' + ipa_dib_os_element: 'coreos' + dib_os_release: 'bionic' + dib_os_element: 'ubuntu-minimal' + + type: + - virtual: + slave-label: 'vpod-deploy-city' + + phase: + - deploy: + build-timeout: 60 + - functest: + build-timeout: 30 + + jobs: + - 'cloud-infra-verify-scenario-{os}-{type}-{stream}' + - 'cloud-infra-verify-scenario-{os}-{phase}-{type}-{stream}' + +- job-template: + name: 'cloud-infra-verify-scenario-{os}-{type}-{stream}' + + project-type: multijob + + disabled: '{obj:disabled}' + + concurrent: true + + parameters: + - project-parameters: + project: '{project}' + branch: '{branch}' + - nordix-gerrit-parameters + - label: + name: SLAVE_LABEL + default: '{slave-label}' + description: 'Slave label to schedule this job on. All slaves have Ubuntu1604 no matter what distro target nodes use' + - string: + name: DISTRIBUTION + default: '{distribution}' + description: 'Distribution to use for configuring target nodes (networking etc.)' + - string: + name: DEPLOY_TYPE + default: '{type}' + description: 'Type of the deployment' + - string: + name: USE_PREBUILT_DEPLOYMENT_IMAGE + default: 'true' + description: 'Use prebuilt deployment image while running as part of CI/CD' + - string: + name: IPA_DIB_OS_ELEMENT + default: '{ipa_dib_os_element}' + description: 'DIB OS Element to use for building the ramdisk image' + - string: + name: DIB_OS_RELEASE + default: '{dib_os_release}' + description: 'DIB OS Release to use for building the deployment image to provision target nodes with' + - string: + name: DIB_OS_ELEMENT + default: '{dib_os_element}' + description: 'DIB OS Element to use for building the deployment image to provision target nodes with' + - string: + name: DEPLOY_SCENARIO + default: 'k8-calico-nofeature' + description: 'Scenario to deploy and test' + - string: + name: TEST_SUITE + default: 'healthcheck' + description: 'Test suite to run' + - string: + name: CLEANUP + default: 'true' + description: 'Cleanup leftovers of the previous run' + + properties: + - logrotate + - build-blocker: + use-build-blocker: true + blocking-jobs: + - 'cloud-infra-verify-engine-{os}-.*' + - 'cloud-infra-verify-scenario-{os}-.*' + - 'cloud-infra-periodic-engine-{os}-.*' + - 'cloud-infra-os-.*' + - 'cloud-infra-k8-.*' + block-level: 'NODE' + - throttle: + max-per-node: 1 + max-total: 3 + option: project + + wrappers: + - build-timeout: + timeout: 90 + - fix-workspace-permissions + + scm: + - git-scm-gerrit: + ssh-credentials-id: nordixinfra-nordix-gerrit-ssh + branch: '{branch}' + refspec: $GERRIT_REFSPEC + + triggers: + - nordix-gerrit-trigger-patchset-created: + project: 'infra\/swconfig' + branch: '{branch}' + files: '**' + + builders: + - multijob: + name: deploy + condition: SUCCESSFUL + projects: + - name: 'cloud-infra-verify-scenario-{os}-deploy-{type}-{stream}' + current-parameters: true + predefined-parameters: | + DISTRIBUTION=$DISTRIBUTION + DEPLOY_TYPE=$DEPLOY_TYPE + USE_PREBUILT_DEPLOYMENT_IMAGE=$USE_PREBUILT_DEPLOYMENT_IMAGE + IPA_DIB_OS_ELEMENT=$IPA_DIB_OS_ELEMENT + DIB_OS_RELEASE=$DIB_OS_RELEASE + DIB_OS_ELEMENT=$DIB_OS_ELEMENT + DEPLOY_SCENARIO=$DEPLOY_SCENARIO + CLEANUP=$CLEANUP + 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 + node-parameters: true + kill-phase-on: FAILURE + abort-all-job: true + - multijob: + name: functest + condition: SUCCESSFUL + projects: + - name: 'cloud-infra-verify-scenario-{os}-functest-{type}-{stream}' + current-parameters: true + predefined-parameters: | + DISTRIBUTION=$DISTRIBUTION + DEPLOY_TYPE=$DEPLOY_TYPE + USE_PREBUILT_DEPLOYMENT_IMAGE=$USE_PREBUILT_DEPLOYMENT_IMAGE + IPA_DIB_OS_ELEMENT=$IPA_DIB_OS_ELEMENT + DIB_OS_RELEASE=$DIB_OS_RELEASE + DIB_OS_ELEMENT=$DIB_OS_ELEMENT + DEPLOY_SCENARIO=$DEPLOY_SCENARIO + TEST_SUITE=$TEST_SUITE + CLEANUP=$CLEANUP + 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 + node-parameters: true + kill-phase-on: FAILURE + abort-all-job: true + +- job-template: + name: 'cloud-infra-verify-scenario-{os}-{phase}-{type}-{stream}' + + disabled: false + + concurrent: true + + properties: + - logrotate + + parameters: + - string: + name: PROJECT + default: $GERRIT_PROJECT + - string: + name: DISTRIBUTION + default: 'ubuntu18' + description: 'Distribution to use for configuring target nodes (networking etc.). Overriden by upstream job.' + - string: + name: DEPLOY_TYPE + default: 'virtual' + description: 'Type of the deployment. Overriden by upstream job.' + - string: + name: USE_PREBUILT_DEPLOYMENT_IMAGE + default: 'false' + description: 'Use prebuilt deployment image while running as part of CI/CD' + - string: + name: IPA_DIB_OS_ELEMENT + default: 'fedora' + description: 'DIB OS Element to use for building the ramdisk image. Overriden by upstream job.' + - string: + name: DIB_OS_RELEASE + default: 'bionic' + description: 'DIB OS Release to use for building the deployment image to provision target nodes with. Overriden by upstream job.' + - string: + name: DIB_OS_ELEMENT + default: 'ubuntu-minimal' + description: 'DIB OS Element to use for building the deployment image to provision target nodes with. Overriden by upstream job.' + - string: + name: DEPLOY_SCENARIO + default: 'k8-calico-nofeature' + description: 'Scenario to deploy and test' + - string: + name: TEST_FW + default: '{phase}' + description: 'Test framework to use' + - string: + name: TEST_SUITE + default: 'healthcheck' + description: 'Test suite to run' + - string: + name: ENGINE_REPO_URL + default: 'https://gerrit.nordix.org/infra/engine.git' + description: 'URL to Nordix Cloud Infra engine repository' + - string: + name: TEST_REPO_URL + default: 'https://gerrit.nordix.org/infra/test.git' + description: 'URL to Nordix Cloud Infra test repository' + - string: + name: CLEANUP + default: 'false' + + wrappers: + - build-timeout: + timeout: '{build-timeout}' + - fix-workspace-permissions + + scm: + - git-scm-gerrit: + ssh-credentials-id: nordixinfra-nordix-gerrit-ssh + branch: '{branch}' + refspec: $GERRIT_REFSPEC + + builders: + - 'cloud-infra-scenario-{phase}-macro' + +# vim: set ts=2 sw=2 expandtab: diff --git a/jjb/cloud-infra/prepare-for-scenario-verify.sh b/jjb/cloud-infra/prepare-for-scenario-verify.sh new file mode 100644 index 000000000..f654dc842 --- /dev/null +++ b/jjb/cloud-infra/prepare-for-scenario-verify.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2019 The Nordix Foundation. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +set -o errexit +set -o nounset + +echo "Info: Cloning infra/engine repository" +cd $HOME && /bin/rm -rf $WORKSPACE +git clone -q $ENGINE_REPO_URL $WORKSPACE + +# vim: set ts=2 sw=2 expandtab: diff --git a/jjb/cloud-infra/prepare-for-test.sh b/jjb/cloud-infra/prepare-for-testfw-verify.sh similarity index 100% rename from jjb/cloud-infra/prepare-for-test.sh rename to jjb/cloud-infra/prepare-for-testfw-verify.sh