3rd party ci: Create jobs for ODL netvirt testing in OPNFV 09/25309/5
authorFatih Degirmenci <fatih.degirmenci@ericsson.com>
Thu, 1 Dec 2016 09:41:31 +0000 (10:41 +0100)
committerFatih Degirmenci <fatih.degirmenci@ericsson.com>
Mon, 12 Dec 2016 12:34:07 +0000 (13:34 +0100)
This change creates basic job structure for ODL netvirt testing in OPNFV.
The job should be triggered once the below job is completed
    https://jenkins.opendaylight.org/releng/job/netvirt-patch-test-current-carbon
and fetch the artifact that is already built by the job. The build result
codes OPNFV is interested in are SUCCESSFUL and UNSTABLE.

Once the job gets triggered, the build URL will be fetched from ODL Gerrit using
Gerrit REST API and the artifact will be downloaded from ODL Jenkins.
The downloaded artifacts will then be installed on the Apex environment.

There are 3 points that need to be highlighted.

- The Apex environment will be created using the promoted snaphots/qcow2
images and already deployed VMs will be brought up. See below for the details.
    https://jira.opnfv.org/browse/APEX-360

- The hardcoded values in download-netvirt-artifact.sh are there to get the
basics in place. (branch name, job name, etc.) Once things work as expected,
they will be made dynamic.

- A workaround using Gerrit REST API is put in place to get build number of the
job netvirt-patch-test-current-carbon to download the artifact.
The reason why we use Gerrit REST API is that the OPNFV Jenkins has an older
version of Gerrit Trigger Plugin which lacks feature that injects review
comments as environment variables. Upgrading Gerrit Trigger Plugin will not
help either since OpenStack JJB does not support the new version of Gerrit
Trigger Plugin and does not generate the new job XML.

JIRA: RELENG-171

Change-Id: I7ff8c5809dcb2e8ffa5c7c5aeb9cdf70e4e7e2f4
Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
jjb/3rd_party_ci/download-netvirt-artifact.sh [new file with mode: 0755]
jjb/3rd_party_ci/functest-netvirt.sh [new file with mode: 0755]
jjb/3rd_party_ci/install-netvirt.sh [new file with mode: 0755]
jjb/3rd_party_ci/odl-netvirt.yml [new file with mode: 0644]
jjb/3rd_party_ci/postprocess-netvirt.sh [new file with mode: 0755]
jjb/global/slave-params.yml

diff --git a/jjb/3rd_party_ci/download-netvirt-artifact.sh b/jjb/3rd_party_ci/download-netvirt-artifact.sh
new file mode 100755 (executable)
index 0000000..d0b9a05
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+echo "Attempting to fetch the artifact location from ODL Jenkins"
+CHANGE_DETAILS_URL="https://git.opendaylight.org/gerrit/changes/netvirt~master~$GERRIT_CHANGE_ID/detail"
+# due to limitation with the Jenkins Gerrit Trigger, we need to use Gerrit REST API to get the change details
+ODL_JOB_URL=$(curl -s $CHANGE_DETAILS_URL | grep netvirt-patch-test-current-carbon | tail -1 | \
+    sed 's/\\n//g' | awk '{print $6}')
+NETVIRT_ARTIFACT_URL="${ODL_JOB_URL}org.opendaylight.integration\$distribution-karaf/artifact/org.opendaylight.integration/distribution-karaf/0.6.0-SNAPSHOT/distribution-karaf-0.6.0-SNAPSHOT.tar.gz"
+echo -e "URL to artifact is\n\t$NETVIRT_ARTIFACT_URL"
+echo "Downloading the artifact. This could take time..."
+curl -s -o $NETVIRT_ARTIFACT $NETVIRT_ARTIFACT_URL
+echo "Download complete"
+ls -al $NETVIRT_ARTIFACT
diff --git a/jjb/3rd_party_ci/functest-netvirt.sh b/jjb/3rd_party_ci/functest-netvirt.sh
new file mode 100755 (executable)
index 0000000..23bf47c
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello World"
diff --git a/jjb/3rd_party_ci/install-netvirt.sh b/jjb/3rd_party_ci/install-netvirt.sh
new file mode 100755 (executable)
index 0000000..c24e890
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo "Using the downloaded artifact to install netvirt"
+ls -al $NETVIRT_ARTIFACT
diff --git a/jjb/3rd_party_ci/odl-netvirt.yml b/jjb/3rd_party_ci/odl-netvirt.yml
new file mode 100644 (file)
index 0000000..3fd0077
--- /dev/null
@@ -0,0 +1,207 @@
+- project:
+    name: 'netvirt'
+
+    project: 'netvirt'
+
+    installer: 'apex'
+#####################################
+# branch definitions
+#####################################
+    stream:
+        - master:
+            branch: '{stream}'
+            gs-pathname: ''
+            disabled: false
+#####################################
+# patch verification phases
+#####################################
+    phase:
+        - 'install'
+        - 'functest'
+        - 'postprocess'
+#####################################
+# jobs
+#####################################
+    jobs:
+        - 'odl-netvirt-verify-virtual-{stream}'
+        - 'odl-netvirt-verify-virtual-{phase}-{stream}'
+#####################################
+# job templates
+#####################################
+- job-template:
+    name: 'odl-netvirt-verify-virtual-{stream}'
+
+    project-type: multijob
+
+    disabled: '{obj:disabled}'
+
+    concurrent: true
+
+    properties:
+        - throttle:
+            enabled: true
+            max-total: 5
+            max-per-node: 1
+            option: 'project'
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: '{branch}'
+        - string:
+            name: NETVIRT_ARTIFACT
+            default: $WORKSPACE/distribution-karaf.tar.gz"
+        - 'odl-netvirt-virtual-defaults'
+
+    scm:
+        - git:
+            url: 'https://git.opendaylight.org/gerrit/p/$PROJECT.git'
+            refspec: '$GERRIT_REFSPEC'
+            branches:
+                - 'origin/$GERRIT_BRANCH'
+            skip-tag: true
+            choosing-strategy: 'gerrit'
+            timeout: 10
+            wipe-workspace: true
+
+    triggers:
+        - gerrit:
+            server-name: 'git.opendaylight.org'
+            trigger-on:
+                - comment-added-contains-event:
+                    comment-contains-value: 'https://jenkins.opendaylight.org/releng/job/netvirt-patch-test-current-carbon/.*?/ : SUCCESS'
+                - comment-added-contains-event:
+                    comment-contains-value: 'https://jenkins.opendaylight.org/releng/job/netvirt-patch-test-current-carbon/.*?/ : UNSTABLE'
+            projects:
+              - project-compare-type: 'ANT'
+                project-pattern: '{project}'
+                branches:
+                  - branch-compare-type: 'ANT'
+                    branch-pattern: '**/{branch}'
+            readable-message: true
+
+    builders:
+        - description-setter:
+            description: "Built on $NODE_NAME"
+        - multijob:
+            name: install
+            condition: SUCCESSFUL
+            projects:
+                - name: 'odl-netvirt-verify-virtual-install-{stream}'
+                  current-parameters: false
+                  predefined-parameters: |
+                    GERRIT_BRANCH=$GERRIT_BRANCH
+                    GERRIT_REFSPEC=$GERRIT_REFSPEC
+                    GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+                    GERRIT_CHANGE_ID=$GERRIT_CHANGE_ID
+                    GERRIT_PATCHSET_NUMBER=$GERRIT_PATCHSET_NUMBER
+                    GERRIT_PATCHSET_REVISION=$GERRIT_PATCHSET_REVISION
+                    NETVIRT_ARTIFACT=$NETVIRT_ARTIFACT
+                  node-parameters: true
+                  kill-phase-on: FAILURE
+                  abort-all-job: true
+        - multijob:
+            name: functest
+            condition: SUCCESSFUL
+            projects:
+                - name: 'odl-netvirt-verify-virtual-functest-{stream}'
+                  current-parameters: false
+                  predefined-parameters: |
+                    GERRIT_BRANCH=$GERRIT_BRANCH
+                    GERRIT_REFSPEC=$GERRIT_REFSPEC
+                    GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+                    GERRIT_CHANGE_ID=$GERRIT_CHANGE_ID
+                    GERRIT_PATCHSET_NUMBER=$GERRIT_PATCHSET_NUMBER
+                    GERRIT_PATCHSET_REVISION=$GERRIT_PATCHSET_REVISION
+                    NETVIRT_ARTIFACT=$NETVIRT_ARTIFACT
+                  node-parameters: true
+                  kill-phase-on: FAILURE
+                  abort-all-job: true
+        - multijob:
+            name: postprocess
+            condition: SUCCESSFUL
+            projects:
+                - name: 'odl-netvirt-verify-virtual-postprocess-{stream}'
+                  current-parameters: false
+                  predefined-parameters: |
+                    GERRIT_BRANCH=$GERRIT_BRANCH
+                    GERRIT_REFSPEC=$GERRIT_REFSPEC
+                    GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+                    GERRIT_CHANGE_ID=$GERRIT_CHANGE_ID
+                    GERRIT_PATCHSET_NUMBER=$GERRIT_PATCHSET_NUMBER
+                    GERRIT_PATCHSET_REVISION=$GERRIT_PATCHSET_REVISION
+                    NETVIRT_ARTIFACT=$NETVIRT_ARTIFACT
+                  node-parameters: true
+                  kill-phase-on: FAILURE
+                  abort-all-job: true
+
+- job-template:
+    name: 'odl-netvirt-verify-virtual-{phase}-{stream}'
+
+    disabled: '{obj:disabled}'
+
+    concurrent: true
+
+    properties:
+        - throttle:
+            enabled: true
+            max-total: 5
+            max-per-node: 1
+            option: 'project'
+        - build-blocker:
+            use-build-blocker: true
+            blocking-jobs:
+                - 'odl-netvirt-verify-virtual-install-.*'
+                - 'odl-netvirt-verify-virtual-functest-.*'
+                - 'odl-netvirt-verify-virtual-postprocess-.*'
+            block-level: 'NODE'
+
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            refspec: '$GERRIT_REFSPEC'
+            choosing-strategy: 'gerrit'
+
+    wrappers:
+        - ssh-agent-credentials:
+            users:
+                - '{ssh-credentials}'
+        - timeout:
+            timeout: 360
+            fail: true
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: '{branch}'
+        - 'odl-netvirt-virtual-defaults'
+        - '{installer}-defaults'
+
+    builders:
+        - description-setter:
+            description: "Built on $NODE_NAME"
+        - '{project}-verify-{phase}-builder'
+#####################################
+# builder macros
+#####################################
+- builder:
+    name: 'netvirt-verify-install-builder'
+    builders:
+        - shell:
+            !include-raw: ./download-netvirt-artifact.sh
+        - shell:
+            !include-raw: ./install-netvirt.sh
+
+- builder:
+    name: 'netvirt-verify-functest-builder'
+    builders:
+        - shell:
+            !include-raw: ./functest-netvirt.sh
+
+- builder:
+    name: 'netvirt-verify-postprocess-builder'
+    builders:
+        - shell:
+            !include-raw: ./postprocess-netvirt.sh
diff --git a/jjb/3rd_party_ci/postprocess-netvirt.sh b/jjb/3rd_party_ci/postprocess-netvirt.sh
new file mode 100755 (executable)
index 0000000..23bf47c
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello World"
index dd0c979..8661b95 100644 (file)
             name: GIT_BASE
             default: https://gerrit.opnfv.org/gerrit/$PROJECT
             description: 'Git URL to use on this Jenkins Slave'
+- parameter:
+    name: 'odl-netvirt-virtual-defaults'
+    parameters:
+        - label:
+            name: SLAVE_LABEL
+            default: 'odl-netvirt-virtual'
 #####################################################
 # These slaves are just dummy slaves for sandbox jobs
 #####################################################