cloud-infra: Add periodic jobs to verify the stability

Change-Id: I3d96126b6a6da5655fd6612ef5b01a6672c9bab3
diff --git a/jjb/cloud-infra/cloud-infra-periodic-engine.yaml b/jjb/cloud-infra/cloud-infra-periodic-engine.yaml
new file mode 100644
index 0000000..64a2d0d
--- /dev/null
+++ b/jjb/cloud-infra/cloud-infra-periodic-engine.yaml
@@ -0,0 +1,258 @@
+---
+#
+# ============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 cloud-infra
+# engine from the tip of the master branch periodically to check the stability of it.
+#
+# 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-periodic-engine'
+
+    project: 'infra/engine'
+
+    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'
+      - centos7:
+          disabled: 'true'
+          distribution: 'centos7'
+          ipa_dib_os_element: 'coreos'
+          dib_os_release: '7'
+          dib_os_element: 'centos-minimal'
+
+    type:
+      - virtual
+
+    phase:
+      - deploy
+      - test
+
+    jobs:
+      - 'cloud-infra-periodic-engine-{os}-{type}-{stream}'
+      - 'cloud-infra-periodic-{os}-{phase}-{type}-{stream}'
+
+- job-template:
+    name: 'cloud-infra-periodic-engine-{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: 'vpod-deploy-{os}'
+          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: 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: 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-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: 120
+      - fix-workspace-permissions
+      - openstack:
+          single-use: True
+
+    scm:
+      - git-scm:
+          ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
+          branch: '{branch}'
+          refspec: ''
+
+    triggers:
+      - timed: 'H H/2 * * *'
+
+    builders:
+      - multijob:
+          name: deploy
+          condition: SUCCESSFUL
+          projects:
+            - name: 'cloud-infra-periodic-{os}-deploy-{type}-{stream}'
+              current-parameters: true
+              predefined-parameters: |
+                DISTRIBUTION=$DISTRIBUTION
+                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
+                CLEANUP=$CLEANUP
+              git-revision: true
+              node-parameters: true
+              kill-phase-on: FAILURE
+              abort-all-job: true
+      - multijob:
+          name: test
+          condition: SUCCESSFUL
+          projects:
+            - name: 'cloud-infra-periodic-{os}-test-{type}-{stream}'
+              current-parameters: true
+              predefined-parameters: |
+                DISTRIBUTION=$DISTRIBUTION
+                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
+                CLEANUP=$CLEANUP
+              node-parameters: true
+              kill-phase-on: test
+              abort-all-job: true
+
+- job-template:
+    name: 'cloud-infra-periodic-{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: 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: 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: 120
+      - fix-workspace-permissions
+
+    scm:
+      - git-scm:
+          ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
+          branch: '{branch}'
+          refspec: ''
+
+    builders:
+      - 'cloud-infra-periodic-{phase}-macro'
+
+# -------------------------------
+# builder macros
+# -------------------------------
+
+- builder:
+    name: 'cloud-infra-periodic-deploy-macro'
+    builders:
+      - shell:
+          !include-raw: ./wait-for-pkg-manager.sh
+      - shell:
+          !include-raw: ./cloud-infra-deploy.sh
+
+- builder:
+    name: 'cloud-infra-periodic-test-macro'
+    builders:
+      - shell:
+          !include-raw: ./prepare-for-test.sh
+      - shell:
+          !include-raw: ./cloud-infra-test.sh
+
+# 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 5dced57..922bdfb 100644
--- a/jjb/cloud-infra/cloud-infra-verify-engine.yaml
+++ b/jjb/cloud-infra/cloud-infra-verify-engine.yaml
@@ -126,6 +126,7 @@
           use-build-blocker: true
           blocking-jobs:
             - 'cloud-infra-verify-engine-{os}-.*'
+            - 'cloud-infra-periodic-engine-{os}-.*'
             - 'cloud-infra-os-.*'
             - 'cloud-infra-k8-.*'
           block-level: 'NODE'