xci: Create post merge jobs to promote scenarios 99/53599/11
authorFatih Degirmenci <fdegir@gmail.com>
Mon, 12 Mar 2018 19:31:13 +0000 (20:31 +0100)
committerFatih Degirmenci <fdegir@gmail.com>
Wed, 14 Mar 2018 19:48:13 +0000 (20:48 +0100)
This change lays down the basic job structure for post merge promotion
jobs. The job structure will be

- a top level multijob job that is scenario specific and can not run
concurrently. This job runs distro deploy and test jobs for all the
distros in the first phase concurrently, followed by a common promote job.
- the deploy and test jobs are same as the xci-verify jobs except the
trigger. They are triggered by top level multijob.
- the promote job is run once all the deploy & test phase jobs successfully
completed, uploading promotion metadata to artifacts.opnfv.org.

The builders except set-scenario are left empty in order to try the basic
job setup first. Followup changes will get real things in.

Once the basics are in place, the first promotion will be done using functest
healthcheck and then we will start working on gating scenarios for promotion
using functest smoke and perhaps feature test cases.

Change-Id: Ib91ffe0f3003b86841a62537c52fde176cafa70f
Signed-off-by: Fatih Degirmenci <fdegir@gmail.com>
jjb/xci/xci-merge-jobs.yml
jjb/xci/xci-set-scenario.sh
jjb/xci/xci-verify-jobs.yml

index 92eea19..8a3a7cf 100644 (file)
@@ -2,6 +2,7 @@
 - project:
     name: 'opnfv-xci-merge'
 
+    project: releng-xci
     # -------------------------------
     # branches
     # -------------------------------
       - opensuse:
           disabled: false
     # -------------------------------
+    # scenarios
+    # -------------------------------
+    scenario:
+      - 'os-odl-sfc':
+          project: sfc
+    # -------------------------------
     # type
     # -------------------------------
     type:
       - virtual
     # -------------------------------
-    # patch verification phases
+    # postmerge promotion phases
     # -------------------------------
     phase:
       - 'deploy'
       - 'healthcheck'
-      - 'promote'
-    # -------------------------------
-    # scenarios
-    # -------------------------------
-    scenario:
-      - 'os-odl-sfc':
-          project: sfc
     # -------------------------------
     # jobs
     # -------------------------------
     jobs:
-      - 'xci-{scenario}-{type}-{distro}-merge-{stream}'
-      - 'xci-{phase}-{type}-{distro}-merge-{stream}'
+      - 'xci-{scenario}-{type}-merge-{stream}'
+      - 'xci-{scenario}-{type}-promote-merge-{stream}'
+      - 'xci-merge-{distro}-{type}-{stream}'
+      - 'xci-merge-{distro}-{phase}-{type}-{stream}'
 # -------------------------------
 # job templates
 # -------------------------------
 - job-template:
-    name: 'xci-{scenario}-{type}-{distro}-merge-{stream}'
+    name: 'xci-{scenario}-{type}-merge-{stream}'
 
     project-type: multijob
 
 
     properties:
       - logrotate-default
-      - build-blocker:
-          use-build-blocker: true
-          blocking-jobs:
-            - 'xci-verify-{distro}-.*'
-            - 'xci-.*-{distro}-merge-.*'
-            - 'openstack-bifrost-verify-{distro}-.*'
-            - 'xci-osa-verify-{distro}-.*'
-            - 'xci-osa-periodic-{distro}-.*'
-            - 'xci-(os|k8s).*?-virtual-{distro}-.*'
-          block-level: 'NODE'
-      - throttle:
-          max-per-node: 2
-          max-total: 10
-          categories:
-            - xci-verify-virtual
-          option: category
 
     wrappers:
       - ssh-agent-wrapper
       - fix-workspace-permissions
 
     scm:
-      - git:
-          credentials-id: '$SSH_CREDENTIAL_ID'
-          url: 'https://gerrit.opnfv.org/gerrit/releng-xci'
-          branches:
-            - 'origin/master'
-          timeout: 15
+      - git-scm-gerrit
 
     triggers:
       - gerrit:
 
     parameters:
       - project-parameter:
-          project: '{obj:project}'
+          project: $GERRIT_PROJECT
           branch: '{branch}'
       - label:
           name: SLAVE_LABEL
           default: 'xci-virtual'
       - string:
-          name: DEPLOY_SCENARIO
-          default: '{scenario}'
+          name: DISTRO
+          default: 'all'
       - string:
           name: CLEAN_DIB_IMAGES
           default: 'true'
 
     builders:
       - description-setter:
-          description: "Built on $NODE_NAME"
+          description: "Node: $NODE_NAME"
+      - 'xci-merge-set-scenario-macro'
+      - multijob:
+          name: deploy and test
+          condition: SUCCESSFUL
+          projects:
+            - name: 'xci-merge-opensuse-{type}-{stream}'
+              current-parameters: false
+              predefined-parameters: |
+                DISTRO=opensuse
+                CLEAN_DIB_IMAGES=$CLEAN_DIB_IMAGES
+                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: false
+              kill-phase-on: FAILURE
+              abort-all-job: true
+            - name: 'xci-merge-ubuntu-{type}-{stream}'
+              current-parameters: false
+              predefined-parameters: |
+                DISTRO=ubuntu
+                CLEAN_DIB_IMAGES=$CLEAN_DIB_IMAGES
+                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: false
+              kill-phase-on: FAILURE
+              abort-all-job: true
+            - name: 'xci-merge-centos-{type}-{stream}'
+              current-parameters: false
+              predefined-parameters: |
+                DISTRO=centos
+                CLEAN_DIB_IMAGES=$CLEAN_DIB_IMAGES
+                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: false
+              kill-phase-on: FAILURE
+              abort-all-job: true
+      - inject:
+          properties-file: "/tmp/$GERRIT_CHANGE_NUMBER/$DISTRO/scenario.properties"
+      - multijob:
+          name: promote
+          condition: SUCCESSFUL
+          projects:
+            - name: 'xci-{scenario}-{type}-promote-merge-{stream}'
+              current-parameters: true
+              predefined-parameters: |
+                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: NEVER
+              abort-all-job: true
+
+- job-template:
+    name: 'xci-merge-{distro}-{type}-{stream}'
+
+    project-type: multijob
+
+    disabled: '{obj:disabled}'
+
+    concurrent: true
+
+    properties:
+      - logrotate-default
+      - build-blocker:
+          use-build-blocker: true
+          blocking-jobs:
+            - 'xci-verify-{distro}-.*'
+            - 'xci-merge-{distro}-.*'
+            - 'openstack-bifrost-verify-{distro}-.*'
+            - 'xci-osa-verify-{distro}-.*'
+            - 'xci-osa-periodic-{distro}-.*'
+          block-level: 'NODE'
+      - throttle:
+          max-per-node: 1
+          max-total: 3
+          categories:
+            - xci-verify-virtual
+          option: category
+
+    wrappers:
+      - ssh-agent-wrapper
+      - build-timeout:
+          timeout: 240
+      - fix-workspace-permissions
+
+    scm:
+      - git-scm-gerrit
+
+    parameters:
+      - project-parameter:
+          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:
+          name: GIT_BASE
+          default: https://gerrit.opnfv.org/gerrit/$PROJECT
+          description: 'Git URL to use on this Jenkins Slave'
+
+    builders:
+      - 'xci-merge-set-scenario-macro'
+      - inject:
+          properties-file: "/tmp/$GERRIT_CHANGE_NUMBER/$DISTRO/scenario.properties"
+      - description-setter:
+          description: "Scenario: $DEPLOY_SCENARIO | Node: $NODE_NAME"
       - multijob:
           name: deploy
           condition: SUCCESSFUL
           projects:
-            - name: 'xci-deploy-{type}-{distro}-merge-{stream}'
+            - name: 'xci-merge-{distro}-deploy-{type}-{stream}'
               current-parameters: true
               predefined-parameters: |
-                PROJECT=$PROJECT
                 DISTRO={distro}
-                DEPLOY_SCENARIO={scenario}
                 CLEAN_DIB_IMAGES=$CLEAN_DIB_IMAGES
+                GERRIT_PROJECT=$GERRIT_PROJECT
                 GERRIT_BRANCH=$GERRIT_BRANCH
                 GERRIT_REFSPEC=$GERRIT_REFSPEC
                 GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
           name: healthcheck
           condition: SUCCESSFUL
           projects:
-            - name: 'xci-healthcheck-{type}-{distro}-merge-{stream}'
+            - name: 'xci-merge-{distro}-healthcheck-{type}-{stream}'
               current-parameters: true
               predefined-parameters: |
-                PROJECT=$PROJECT
                 DISTRO={distro}
-                DEPLOY_SCENARIO={scenario}
                 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
                 !include-raw: ./xci-cleanup.sh
 
 - job-template:
-    name: 'xci-{phase}-{type}-{distro}-merge-{stream}'
+    name: 'xci-merge-{distro}-{phase}-{type}-{stream}'
 
     disabled: false
 
     parameters:
       - string:
           name: PROJECT
-          default: 'releng-xci'
+          default: $GERRIT_PROJECT
       - string:
           name: DISTRO
           default: 'ubuntu'
-      - string:
-          name: DEPLOY_SCENARIO
-          default: 'os-nosdn-nofeature-noha'
       - string:
           name: FUNCTEST_MODE
           default: 'tier'
       - string:
           name: OPNFV_RELENG_DEV_PATH
           default: $WORKSPACE/
-      - string:
-          name: INSTALLER_TYPE
-          default: 'osa'
       - string:
           name: GIT_BASE
           default: https://gerrit.opnfv.org/gerrit/$PROJECT
           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
       - fix-workspace-permissions
 
     scm:
-      - git:
-          credentials-id: '$SSH_CREDENTIAL_ID'
-          url: 'https://gerrit.opnfv.org/gerrit/releng-xci'
-          branches:
-            - 'origin/master'
-          timeout: 15
+      - git-scm-gerrit
 
     builders:
       - description-setter:
-          description: "Built on $NODE_NAME"
+          description: "Scenario: $DEPLOY_SCENARIO | Node: $NODE_NAME"
       - 'xci-merge-{phase}-macro'
 
+- job-template:
+    name: 'xci-{scenario}-{type}-promote-merge-{stream}'
+
+    disabled: false
+
+    concurrent: false
+
+    properties:
+      - logrotate-default
+
+    parameters:
+      - string:
+          name: PROJECT
+          default: $GERRIT_PROJECT
+      - string:
+          name: DISTRO
+          default: 'all'
+      - string:
+          name: OPNFV_RELENG_DEV_PATH
+          default: $WORKSPACE/
+      - string:
+          name: GIT_BASE
+          default: https://gerrit.opnfv.org/gerrit/$PROJECT
+          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
+      - fix-workspace-permissions
+
+    builders:
+      - description-setter:
+          description: "Scenario: $DEPLOY_SCENARIO | Node: $NODE_NAME"
+      - 'xci-merge-promote-macro'
+
 # -------------------------------
 # builder macros
 # -------------------------------
 - builder:
-    name: 'xci-merge-deploy-macro'
+    name: 'xci-merge-set-scenario-macro'
     builders:
       - shell:
-          !include-raw: ./xci-start-new-vm.sh
-      - shell:
-          !include-raw: ./xci-start-deployment.sh
+          !include-raw: ./xci-set-scenario.sh
+
+- builder:
+    name: 'xci-merge-deploy-macro'
+    builders:
+      - shell: |
+          #!/bin/bash
+          echo "Hello World"
 
 - builder:
     name: 'xci-merge-healthcheck-macro'
     builders:
-      - shell:
-          !include-raw: ./xci-run-functest.sh
+      - shell: |
+          #!/bin/bash
+          echo "Hello World"
 
 - builder:
     name: 'xci-merge-promote-macro'
     builders:
-      - shell:
-          !include-raw: ./xci-promote.sh
+      - shell: |
+          #!/bin/bash
+          echo "Hello World"
index 62b26c0..c602957 100755 (executable)
@@ -108,6 +108,12 @@ function determine_generic_scenario() {
                 ;;
             esac
     done
+
+    # extract releng-xci sha
+    RELENG_XCI_SHA=$(cd $WORKSPACE && git rev-parse HEAD)
+
+    # extract scenario sha which is same as releng-xci sha for generic scenarios
+    SCENARIO_SHA=$RELENG_XCI_SHA
 }
 
 # This function determines the impacted external scenario by processing the Gerrit
@@ -134,6 +140,12 @@ function determine_external_scenario() {
 
     # 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)
+
+    # extract releng-xci sha
+    RELENG_XCI_SHA=$(cd $WORKSPACE && git rev-parse HEAD)
+
+    # extract scenario sha
+    SCENARIO_SHA=$(cd $WORK_DIRECTORY/$GERRIT_PROJECT && git rev-parse HEAD)
 }
 
 echo "Determining the impacted scenario"
@@ -179,9 +191,16 @@ 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 '$INSTALLER_TYPE' and scenario '${DEPLOY_SCENARIO[0]}' for downstream jobs"
+echo "Recording the installer '$INSTALLER_TYPE' and scenario '${DEPLOY_SCENARIO[0]}' and SHAs for downstream jobs"
 echo "INSTALLER_TYPE=$INSTALLER_TYPE" > $WORK_DIRECTORY/scenario.properties
 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> $WORK_DIRECTORY/scenario.properties
+echo "RELENG_XCI_SHA=$RELENG_XCI_SHA" >> $WORK_DIRECTORY/scenario.properties
+echo "SCENARIO_SHA=$SCENARIO_SHA" >> $WORK_DIRECTORY/scenario.properties
+
+# skip scenario support check if the job is promotion job
+if [[ "$JOB_NAME" =~ (os|k8) ]]; then
+    exit 0
+fi
 
 # skip the deployment if the scenario is not supported on this distro
 OPNFV_SCENARIO_REQUIREMENTS=$WORKSPACE/xci/opnfv-scenario-requirements.yml
index 4c9ff9e..383af2f 100644 (file)
@@ -66,7 +66,7 @@
           use-build-blocker: true
           blocking-jobs:
             - 'xci-verify-{distro}-.*'
-            - 'xci-.*-{distro}-merge-.*'
+            - 'xci-merge-{distro}-.*'
             - 'openstack-bifrost-verify-{distro}-.*'
             - 'xci-osa-verify-{distro}-.*'
             - 'xci-osa-periodic-{distro}-.*'