cloud-infra: Add basic verify jobs 46/346/3
authorFatih Degirmenci <fdegir@gmail.com>
Thu, 7 Feb 2019 10:24:29 +0000 (11:24 +0100)
committerFatih Degirmenci <fdegir@gmail.com>
Thu, 7 Feb 2019 10:48:14 +0000 (11:48 +0100)
This change adds a multijob that gets triggered due to changes
coming to any of the projects listed below on Gerrit.

- infra/engine
- infra/swconfig

When the job gets triggered, it will trigger 2 multijob phases

- deploy: deployment of the stack using VMs will be done
- test: healthcheck of the deployed stack is done

If the main job or any of the phase jobs fail, the result will
be posted to Gerrit as Verified-1, blocking the change from
being merged to master.

It is expected that these jobs to evolve over time so they are
created only in order to have some basic verification in place.

The reason to choose multijob job type is that when a new patch
is published for an existing change, multijob aborts the build
that is running for the previous patch and starts a new build for
the new patch so this helps keeping things clean and tidy.

Change-Id: I21375ef2254e8b47ab2b5268366469f3d100fa99
Signed-off-by: Fatih Degirmenci <fdegir@gmail.com>
jjb/cloud-infra/cloud-infra-deploy.sh [new file with mode: 0644]
jjb/cloud-infra/cloud-infra-test.sh [new file with mode: 0644]
jjb/cloud-infra/cloud-infra-verify-jobs.yaml [new file with mode: 0644]

diff --git a/jjb/cloud-infra/cloud-infra-deploy.sh b/jjb/cloud-infra/cloud-infra-deploy.sh
new file mode 100644 (file)
index 0000000..a73f3f6
--- /dev/null
@@ -0,0 +1,39 @@
+#!/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 script is a wrapper around actual cloud infra engine deploy.sh script which gets
+# executed when the job that uses this script gets triggered due to Gerrit change.
+#
+# Logic in this script should be kept at minimum and the changes should be pushed into
+# the cloud infra engine deploy.sh script.
+
+# The verify job will verify changes coming to other repositories as well such as
+# infra/swconfig so it needs to be handled here in order to ensure $WORKSPACE contains
+# the actual engine repo clone. This will be added later on.
+
+# execute cloud engine deploy.sh script
+cd $WORKSPACE
+./engine/deploy.sh
+
+# vim: set ts=2 sw=2 expandtab:
diff --git a/jjb/cloud-infra/cloud-infra-test.sh b/jjb/cloud-infra/cloud-infra-test.sh
new file mode 100644 (file)
index 0000000..d12c943
--- /dev/null
@@ -0,0 +1,39 @@
+#!/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 script is a wrapper around actual cloud infra engine test.sh script which gets
+# executed when the job that uses this script gets triggered due to Gerrit change.
+#
+# Logic in this script should be kept at minimum and the changes should be pushed into
+# the cloud infra engine and/or test repo.
+
+# The verify job will verify changes coming to other repositories as well such as
+# infra/swconfig so it needs to be handled here in order to ensure $WORKSPACE contains
+# the actual engine repo clone. This will be added later on.
+
+# we currently only do Hello World here and this will be adapted to do test instead
+cd $WORKSPACE
+echo "Hello World!"
+
+# vim: set ts=2 sw=2 expandtab:
diff --git a/jjb/cloud-infra/cloud-infra-verify-jobs.yaml b/jjb/cloud-infra/cloud-infra-verify-jobs.yaml
new file mode 100644 (file)
index 0000000..a2e2050
--- /dev/null
@@ -0,0 +1,181 @@
+---
+#
+# ============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=========================================================
+
+- project:
+    name: 'cloud-infra-verify'
+
+    project: 'cloud-infra'
+
+    stream:
+      - 'master':
+          branch: '{stream}'
+          disabled: 'false'
+
+    distro:
+      - ubuntu1604
+
+    type:
+      - virtual
+
+    phase:
+      - deploy
+      - test
+
+    jobs:
+      - 'cloud-infra-verify-{distro}-{type}-{stream}'
+      - 'cloud-infra-verify-{distro}-{phase}-{type}-{stream}'
+
+- job-template:
+    name: 'cloud-infra-verify-{distro}-{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: 'cloud-infra-vpod'
+          all-nodes: false
+          node-eligibility: 'ignore-offline'
+      - string:
+          name: DISTRO
+          default: '{distro}'
+
+    properties:
+      - logrotate
+      - build-blocker:
+          use-build-blocker: true
+          blocking-jobs:
+            - 'cloud-infra-verify-{distro}-.*'
+            - 'cloud-infra-os-.*'
+            - 'cloud-infra-k8-.*'
+          blocking-level: 'NODE'
+      - throttle:
+          max-per-node: 1
+          max-total: 2
+          option: project
+
+    wrappers:
+      - build-timeout:
+          timeout: 120
+      - 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/engine|infra/swconfig'
+          branch: '{branch}'
+          files: '**'
+
+    builders:
+      - multijob:
+          name: deploy
+          condition: SUCCESSFUL
+          projects:
+            - name: 'cloud-infra-verify-{distro}-deploy-{type}-{stream}'
+              current-parameters: true
+              predefined-parameters: |
+                DISTRO={distro}
+                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: test
+          condition: SUCCESSFUL
+          projects:
+            - name: 'cloud-infra-verify-{distro}-test-{type}-{stream}'
+              current-parameters: true
+              predefined-parameters: |
+                DISTRO={distro}
+                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: test
+              abort-all-job: true
+
+- job-template:
+    name: 'cloud-infra-verify-{distro}-{phase}-{type}-{stream}'
+
+    disabled: false
+
+    concurrent: true
+
+    properties:
+      - logrotate
+
+    parameters:
+      - string:
+          name: PROJECT
+          default: $GERRIT_PROJECT
+      - string:
+          name: DISTRO
+          default: 'ubuntu1604'
+
+    wrappers:
+      - build-timeout:
+          timeout: 120
+      - fix-workspace-permissions
+
+    scm:
+      - git-scm-gerrit:
+          ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
+          branch: '{branch}'
+          refspec: $GERRIT_REFSPEC
+
+    builders:
+      - 'cloud-infra-verify-{phase}-macro'
+
+# -------------------------------
+# builder macros
+# -------------------------------
+
+- builder:
+    name: 'cloud-infra-verify-deploy-macro'
+    builders:
+      - shell:
+          !include-raw: ./cloud-infra-deploy.sh
+
+- builder:
+    name: 'cloud-infra-verify-test-macro'
+    builders:
+      - shell:
+          !include-raw: ./cloud-infra-test.sh
+
+# vim: set ts=2 sw=2 expandtab: