Merge "Extract common RPM test builder steps to macro"
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 24 Jan 2018 23:22:23 +0000 (23:22 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 24 Jan 2018 23:22:23 +0000 (23:22 +0000)
jjb/packaging/build-rpm.sh
jjb/packaging/install-rpm.sh
jjb/packaging/packaging-macros.yaml [new file with mode: 0644]
jjb/packaging/packaging.yaml
jjb/packaging/test-rpm-deps.sh

index 9218d5a5fba25473e9554206c554ddfe5524354f..7613e521916e3843a471217ba52e5a48c59be033 100644 (file)
@@ -20,10 +20,10 @@ $PYTHON -m pip install -r "$WORKSPACE/packaging/packages/requirements.txt"
 # If URL is to zip, check if there's a tar.gz available to avoid repackaging.
 if [[ $DOWNLOAD_URL = *.zip ]]; then
   # shellcheck disable=SC2154
-  candidate_tarball_url="${{DOWNLOAD_URL//zip/tar.gz}}"
+  candidate_tarball_url="${DOWNLOAD_URL//zip/tar.gz}"
   # shellcheck disable=SC2154
   url_status=$(curl --silent --head --location --output /dev/null --write-out \
-    '%{{http_code}}' "$candidate_tarball_url")
+    '%{http_code}' "$candidate_tarball_url")
   if [[ $url_status = 2* ]]; then
     DOWNLOAD_URL="$candidate_tarball_url"
   fi
index 2ccc50078f18452dfe42bc5aabf50aa3d3c1d9a7..2816c4a7865ba11949c1de41aca7c33938eca5ca 100644 (file)
@@ -19,7 +19,7 @@ elif [[ $URL == *.rpm ]]; then
   sudo yum install -y "$URL"
 elif [[ $URL == *.repo ]]; then
   # shellcheck disable=SC2154
-  repo_file="${{URL##*/}}"
+  repo_file="${URL##*/}"
   sudo curl --silent -o /etc/yum.repos.d/"$repo_file" "$URL"
   sudo yum install -y opendaylight
 else
diff --git a/jjb/packaging/packaging-macros.yaml b/jjb/packaging/packaging-macros.yaml
new file mode 100644 (file)
index 0000000..57830ea
--- /dev/null
@@ -0,0 +1,22 @@
+# Integration/Packaging macros
+---
+- builder:
+    name: install-test-uninstall-rpm
+    builders:
+      - inject:
+          properties-content: 'URL=/home/$USER/rpmbuild/RPMS/noarch/*.rpm'
+      # Use *-escape to make double brace expansion work. JJB strangeness.
+      - shell: !include-raw: test-rpm-deps.sh
+      - shell: !include-raw-escape: install-rpm.sh
+      - shell: !include-raw: start-odl.sh
+      # Install deps needed interactive Karaf shell tests
+      - shell: |
+          # Install expect to interact with Karaf shell
+          # Install nmap to check status of ODL's SSH port
+          sudo yum install -y expect nmap
+      - shell: !include-raw: test-karaf.expect
+      - shell: !include-raw: stop-odl.sh
+      - shell: !include-raw: uninstall-rpm.sh
+      - shell: |
+          # Remove old host key so future installs don't fail to SSH
+          rm /home/jenkins/.ssh/known_hosts
index 38ff5df9d7ddf5bbadb0c96cf42131e92b1b04b3..ea80567dbce8ecaecacb5fef2f028598e028e2c3 100644 (file)
           build-timeout: '{build-timeout}'
 
     builders:
-      - shell: !include-raw: build-rpm.sh
-      - shell: !include-raw: test-rpm-deps.sh
-      - inject:
-          properties-content: 'URL=/home/$USER/rpmbuild/RPMS/noarch/*.rpm'
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: |
-          # Install expect to interact with Karaf shell
-          sudo yum install -y expect
-          # Install nmap to check status of ODL's SSH port
-          sudo yum install -y nmap
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
+      - shell: !include-raw-escape: build-rpm.sh
+      - install-test-uninstall-rpm
       - lf-infra-deploy-maven-file:
           global-settings-file: 'global-settings'
           settings-file: 'packaging-settings'
       - inject:
           properties-content: 'STREAM={stream}'
       - shell: !include-raw: build-rpm-snap.sh
-      - shell: !include-raw: test-rpm-deps.sh
+      - install-test-uninstall-rpm
       - lf-infra-deploy-maven-file:
           global-settings-file: 'global-settings'
           settings-file: 'packaging-settings'
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/karaf/0.7.0/karaf-0.7.0.tar.gz'
-      - shell: !include-raw: build-rpm.sh
+      - shell: !include-raw-escape: build-rpm.sh
 
       # Test Oxygen pre-release autorelease tarball
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/autorelease-2052/org/opendaylight/integration/karaf/0.8.0/karaf-0.8.0.tar.gz'
-      - shell: !include-raw: build-rpm.sh
+      - shell: !include-raw-escape: build-rpm.sh
 
       # Test Oxygen multipatch zip (no parallel tarball available)
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/integration/distribution/karaf/0.8.0-SNAPSHOT/karaf-0.8.0-20171128.175421-68.zip'
-      - shell: !include-raw: build-rpm.sh
+      - shell: !include-raw-escape: build-rpm.sh
 
       # Test latest Oxygen snapshot
       - inject:
           build-timeout: '{build-timeout}'
 
     builders:
-      # Install deps needed for all tests
-      - shell: |
-          # Install expect to interact with Karaf shell
-          sudo yum install -y expect
-          # Install nmap to check status of ODL's SSH port
-          sudo yum install -y nmap
-
-      # Each new build will rm and replace this dir, only need to inject once
-      - inject:
-          properties-content: 'URL=/home/$USER/rpmbuild/RPMS/noarch/*.rpm'
-
       # Test Carbon SR2 tarball
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.6.2-Carbon/distribution-karaf-0.6.2-Carbon.tar.gz'
-      - shell: !include-raw: build-rpm.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - shell: !include-raw-escape: build-rpm.sh
+      - install-test-uninstall-rpm
 
       # Test Carbon multipatch zip (no parallel tarball available)
       # NB: This will need to be updated as old builds expire
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/integration/distribution/distribution-karaf/0.6.3-SNAPSHOT/distribution-karaf-0.6.3-20180115.181738-1.zip'
-      - shell: !include-raw: build-rpm.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - shell: !include-raw-escape: build-rpm.sh
+      - install-test-uninstall-rpm
 
       # Test latest Carbon snapshot
       - inject:
           properties-content: 'STREAM=carbon'
       - shell: !include-raw: build-rpm-snap.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - install-test-uninstall-rpm
 
       # Test Nitrogen tarball
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/karaf/0.7.0/karaf-0.7.0.tar.gz'
-      - shell: !include-raw: build-rpm.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - shell: !include-raw-escape: build-rpm.sh
+      - install-test-uninstall-rpm
 
       # Test Nitrogen SR1 tarball
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/karaf/0.7.1/karaf-0.7.1.tar.gz'
-      - shell: !include-raw: build-rpm.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - shell: !include-raw-escape: build-rpm.sh
+      - install-test-uninstall-rpm
 
       # Test Nitrogen multipatch zip (no parallel tarball available)
       # NB: This will need to be updated as old builds expire
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/integration/distribution/karaf/0.7.2-SNAPSHOT/karaf-0.7.2-20180115.183312-2.zip'
-      - shell: !include-raw: build-rpm.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - shell: !include-raw-escape: build-rpm.sh
+      - install-test-uninstall-rpm
 
       # Test latest Nitrogen snapshot
       - inject:
           properties-content: 'STREAM=nitrogen'
       - shell: !include-raw: build-rpm-snap.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - install-test-uninstall-rpm
 
       # Test Oxygen pre-release autorelease tarball
       # NB: This will need to be updated as old builds expire
       - inject:
           # yamllint disable-line rule:line-length
           properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/autorelease-2052/org/opendaylight/integration/karaf/0.8.0/karaf-0.8.0.tar.gz'
-      - shell: !include-raw: build-rpm.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - shell: !include-raw-escape: build-rpm.sh
+      - install-test-uninstall-rpm
 
       # Test Oxygen multipatch zip (no parallel tarball available)
       # FIXME: Something is wrong with current Oxygen multipatch builds
       # yamllint disable-line rule:line-length
       #     properties-content: 'DOWNLOAD_URL=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/integration/distribution/karaf/0.8.0-SNAPSHOT/karaf-0.8.0-20180111.030942-90.zip'
       # - shell: !include-raw: build-rpm.sh
-      # - shell: !include-raw: install-rpm.sh
-      # - shell: !include-raw: start-odl.sh
-      # - shell: !include-raw: test-karaf.expect
-      # - shell: !include-raw: stop-odl.sh
-      # - shell: !include-raw: uninstall-rpm.sh
-      # - shell: |
-      #     Remove old host key so future installs don't fail to SSH
-      #     rm /home/jenkins/.ssh/known_hosts
+      # - install-test-uninstall-rpm
 
       # Test latest Oxygen snapshot
       - inject:
           properties-content: 'STREAM=oxygen'
       - shell: !include-raw: build-rpm-snap.sh
-      - shell: !include-raw: install-rpm.sh
-      - shell: !include-raw: start-odl.sh
-      - shell: !include-raw: test-karaf.expect
-      - shell: !include-raw: stop-odl.sh
-      - shell: !include-raw: uninstall-rpm.sh
-      - shell: |
-          # Remove old host key so future installs don't fail to SSH
-          rm /home/jenkins/.ssh/known_hosts
+      - install-test-uninstall-rpm
 
     triggers:
       - timed: '@daily'
           build-timeout: '{build-timeout}'
 
     builders:
-      - shell: !include-raw: install-rpm.sh
+      - shell: !include-raw-escape: install-rpm.sh
       - shell: !include-raw: start-odl.sh
       - shell: |
           # Install expect to interact with Karaf shell
-          sudo yum install -y expect
           # Install nmap to check status of ODL's SSH port
-          sudo yum install -y nmap
+          sudo yum install -y expect nmap
       - shell: !include-raw: test-karaf.expect
       - shell: !include-raw: stop-odl.sh
       - shell: !include-raw: uninstall-rpm.sh
           build-timeout: '{build-timeout}'
 
     builders:
-      - shell: !include-raw: install-rpm.sh
+      - shell: !include-raw-escape: install-rpm.sh
       - shell: !include-raw: start-odl.sh
       - shell: |
           # Install expect to interact with Karaf shell
index 460bdaeed14f7d78e72aeacfa5871cf0816057d2..2bb0db6dbda972cc7368a4dfee44ae40dd9e008d 100644 (file)
@@ -45,16 +45,16 @@ fi
 # shellcheck disable=SC2034
 mapfile -t actual_deps < <( rpm -qp /home/$USER/rpmbuild/RPMS/noarch/*.rpm --requires )
 # shellcheck disable=SC2154 disable=SC2145
-printf 'Dependency found: %s\n' "${{actual_deps[@]}}"
+printf 'Dependency found: %s\n' "${actual_deps[@]}"
 
 # shellcheck disable=SC2154,SC2145,SC2034,SC2207
-diff_deps=(`echo "${{expected_deps[@]}}" "${{actual_deps[@]}}" | tr ' ' '\n' | sort | uniq -u`)
+diff_deps=(`echo "${expected_deps[@]}" "${actual_deps[@]}" | tr ' ' '\n' | sort | uniq -u`)
 # shellcheck disable=SC2154 disable=SC2145 disable=SC2068 disable=SC2170 disable=SC1083
-if [ ${{#diff_deps[*]}} -eq 0 ]; then
+if [ ${#diff_deps[*]} -eq 0 ]; then
     echo "RPM requirements are as expected"
 else
     echo "RPM requirements don't match the expected requirements"
     # shellcheck disable=SC2154 disable=SC2145
-    printf 'Dependency mismatch: %s\n' ${{diff_deps[@]}}
+    printf 'Dependency mismatch: %s\n' ${diff_deps[@]}
     exit 1
 fi