Update multipatch test to use a gerrit topic 57/71857/12
authorLuis Gomez <ecelgp@gmail.com>
Tue, 8 May 2018 18:35:17 +0000 (11:35 -0700)
committerLuis Gomez <ecelgp@gmail.com>
Wed, 9 May 2018 21:28:54 +0000 (14:28 -0700)
- New parameter BUILD_ORDER is required when topic is used.
- Documentation is updated.

Change-Id: Ib107967d8887a8ae73816ea0235ca117d33166e3
JIRA: RELENG-119
Signed-off-by: Luis Gomez <ecelgp@gmail.com>
docs/jenkins.rst
jjb/integration/integration-test-jobs.yaml
jjb/integration/multipatch-distribution.sh
jjb/releng-macros.yaml

index 93c5bdf6eec32550604a5c9699e90c6a157af901..25e5370f922310a886152e8906f3009194590286 100644 (file)
@@ -805,6 +805,11 @@ TODO: Document test-{project}-{feature} and test-{project}-all.
           cherry-pick 59/60259/17 and build netvirt, finally it will checkout latest distribution
           code and build a distribution. The resulting distribution is stored in Nexus and the URL
           is stored in a variable called BUNDLE_URL visible in the job console.
+          This job also accepts a gerrit topic, for example: multipatch-build:topic=binding-tlc-rpc,
+          in this case the job will find all patches in the topic binding-tlc-rpc for the projects
+          specified in the BUILD_ORDER parameter and will build all projects from the first a patch
+          has been found, for successive projects the branch HEAD is used if no patch is found.
+          The job uses patch numbers to sort patches in the same project.
           Use multipatch-build-fast (vs multipatch-build) for building projects fast (-Pq).
           This job should not alter Gerrit votes for a given patch, nor will do anything with the
           given patch unless the patch is added to the build list.
index 698ca010dde8ff83b8a65029bfa92bda774e47fa..38555dbc0abaed833421804f8e71292498dd0979 100644 (file)
           branch: 'master'
           mvn-version: 'mvn33'
           csit-list: !include: csit-jobs-fluorine.lst
+          build-order: >
+              infrautils mdsal controller aaa netconf daexim bgpcep ovsdb neutron
+              lispflowmapping openflowplugin coe genius sfc netvirt
 
       - oxygen:
           branch: 'stable/oxygen'
           mvn-version: 'mvn33'
           csit-list: !include: csit-jobs-oxygen.lst
+          build-order: >
+              infrautils mdsal controller aaa netconf daexim bgpcep ovsdb neutron
+              lispflowmapping openflowplugin coe genius sfc netvirt
 
       - nitrogen:
           branch: 'stable/nitrogen'
           mvn-version: 'mvn33'
           csit-list: !include: csit-jobs-nitrogen.lst
+          build-order: >
+              infrautils mdsal controller aaa netconf daexim bgpcep ovsdb neutron
+              lispflowmapping openflowplugin coe genius sfc netvirt
 
 - project:
     name: integration-distribution
     parameters:
       - patches-to-build-parameter:
           patches_to_build: '$PATCHES_TO_BUILD'
-      - run-test-parameter:
-          run-test: 'false'
+      - build-order-parameter:
+          build-order: '{build-order}'
       - build-fast-parameter:
           build-fast: 'false'
+      - run-test-parameter:
+          run-test: 'false'
       - integration-distribution-branch:
           branch: '{branch}'
       - integration-distribution-stream:
index 6fbdcfd6e02603ca84aa238de7b0c40d309ee745..ae9791d7446c7ff0c94f35b7d5cb7d66b32b6fa6 100644 (file)
@@ -43,6 +43,44 @@ if ${BUILD_FAST}; then
 else
     fast_option=""
 fi
+# check if topic exists, e.g. topic=binding-tlc-rpc
+if [[ "${PATCHES_TO_BUILD}" == *topic* ]]; then
+    TOPIC="${PATCHES_TO_BUILD#*=}"
+    echo "Create topic ${TOPIC} patch list"
+    PATCHES_TO_BUILD=""
+    read -ra PROJECT_LIST <<< "${BUILD_ORDER}"
+    for PROJECT in "${PROJECT_LIST[@]}"; do
+        # get all patches number for a topic for a given project
+        IFS=$'\n' read -rd '' -a GERRIT_PATCH_LIST <<< "$(ssh -p 29418 jenkins-$SILO@git.opendaylight.org gerrit query status:open topic:${TOPIC} project:${PROJECT} \
+        | grep 'number:' | awk '{{ print $2 }}')" || true
+        echo "Add ${PROJECT}:${GERRIT_PATCH_LIST[*]}"
+        # add project if it is the first with patches or it is not the first
+        if [[ -z "${PATCHES_TO_BUILD}" && ! -z "${GERRIT_PATCH_LIST[*]}" ]]; then
+            PATCHES_TO_BUILD="${PROJECT}"
+        elif [[ ! -z "${PATCHES_TO_BUILD}" ]]; then
+            PATCHES_TO_BUILD="${PATCHES_TO_BUILD},${PROJECT}"
+        fi
+        # sort project patches
+        if [[ ! -z "${GERRIT_PATCH_LIST[*]}" ]]; then
+            REF_LIST=()
+            # create reference list with patch number-refspec
+            for PATCH in "${GERRIT_PATCH_LIST[@]}"; do
+                REFSPEC=$(ssh -p 29418 jenkins-$SILO@git.opendaylight.org gerrit query change:${PATCH} --current-patch-set \
+                | grep 'ref:' | awk '{{ print $2 }}')
+                REF_LIST+=("${PATCH}-${REFSPEC/refs\/changes\/}")
+            done
+            # sort reference list by patch number
+            IFS=$'\n' SORT_REF=$(sort <<<"${REF_LIST[*]}") && unset IFS
+            read -rd '' -a SORT_REF_LIST <<< "${SORT_REF[*]}" || true
+            # add refspec to patches to build list
+            for PATCH in "${SORT_REF_LIST[@]}"; do
+                PATCHES_TO_BUILD="${PATCHES_TO_BUILD}:${PATCH/*-/}"
+            done
+        fi
+    done
+fi
+
+echo "Patches to build: ${PATCHES_TO_BUILD}"
 IFS=',' read -ra PATCHES <<< "${PATCHES_TO_BUILD}"
 
 # For each patch:
index f57959410608274c5f4200b4d047b899e9958e52..7ae65fe2a6b2fc7d8e9c03cdd5a2966c2fb7bf6a 100644 (file)
           default: ''
           description: |
               Ordered list of patches to build in the format of project=changeset (checkout) or
-              project:changeset (cherry-pick) for example: genius=32/53632/9,netvirt:59/50259/47
+              project:changeset (cherry-pick) for example: genius=32/53632/9,netvirt:59/50259/47.
+              A topic is also allowed, for example: topic=binding-tlc-rpc
 
 - parameter:
-    name: run-test-parameter
+    name: build-order-parameter
     parameters:
       - string:
-          name: RUN_TEST
-          default: '{run-test}'
-          description: 'Set true to run test after build'
+          name: BUILD_ORDER
+          default: '{build-order}'
+          description: 'Build order for multipatch test when topic is used'
 
 - parameter:
     name: build-fast-parameter
           default: '{build-fast}'
           description: 'Set true to build fast -Pq'
 
+- parameter:
+    name: run-test-parameter
+    parameters:
+      - string:
+          name: RUN_TEST
+          default: '{run-test}'
+          description: 'Set true to run test after build'
+
 - parameter:
     name: distribution-branch-to-build-parameter
     parameters: