Create Jenkins job to test RPM 07/49707/2
authorAlok Anand <alok4nand@gmail.com>
Wed, 21 Dec 2016 16:17:50 +0000 (21:47 +0530)
committerAlok Anand <alok4nand@gmail.com>
Wed, 4 Jan 2017 07:17:31 +0000 (12:47 +0530)
This job installs an ODL package using either a .repo or a .rpm
link. It does checks like systemctl start/status opendaylight,
pgrep java, verifies SSH access to Karaf shell and verifies
expected features.

Change-Id: I110d194ae7768ac2182a2ba0138f868fa165f4a0
Signed-off-by: Alok Anand <alok4nand@gmail.com>
jjb/packaging/include-raw-test-karaf.sh [new file with mode: 0644]
jjb/packaging/include-raw-test-rpm.sh [new file with mode: 0644]
jjb/packaging/packaging.yaml

diff --git a/jjb/packaging/include-raw-test-karaf.sh b/jjb/packaging/include-raw-test-karaf.sh
new file mode 100644 (file)
index 0000000..d2e2080
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/expect
+# This script starts the karaf shell and sends the password for SSH auth.
+# Further tests in karaf shell can be done here
+
+# Default password
+set password "karaf"
+# Default prompt
+set prompt "opendaylight-user@root>"
+
+# OpenDaylight service requires some time after it starts for a successful
+# SSH connection
+sleep 10
+
+# SSH into Karaf shell
+spawn ssh -p 8101 -o StrictHostKeyChecking=no karaf@127.0.0.1
+expect "Password: "
+send "$password\r"
+
+# Verify expected features
+expect "$prompt"
+send "feature:list | grep netvirt-openstack\r"
+expect "$prompt"
+
+# TODO Add further tests here
diff --git a/jjb/packaging/include-raw-test-rpm.sh b/jjb/packaging/include-raw-test-rpm.sh
new file mode 100644 (file)
index 0000000..1ebe855
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Options:
+#   -x: Echo commands
+#   -e: Fail on errors
+#   -o pipefail: Fail on errors in scripts this calls, give stacktrace
+set -ex -o pipefail
+
+# Remove opendaylight if already installed
+if rpm -q opendaylight > /dev/null;
+then
+  sudo yum remove -y opendaylight;
+fi
+
+# Install ODL from .rpm link or .repo url
+if [[ $URL == *.rpm ]]
+then
+  sudo yum install -y "$URL"
+elif [[ $URL == *.repo ]]
+then
+  sudo curl --silent -o "$REPO_FILE" "$URL"
+  sudo yum install -y opendaylight
+else
+  echo "URL is not a link to .rpm or .repo"
+fi
+
+# Install expect to interact with karaf shell
+sudo yum install -y expect
+
+# Start OpenDaylight
+sudo systemctl start opendaylight
+
+# Check status of OpenDaylight
+sudo systemctl status opendaylight
+
+# Get process id of Java
+pgrep java
index c37189376df0465c5da28d3d34df9786ef7e14d9..ab313679fd091b5ffc5edd30aecf97b1df80f834 100644 (file)
@@ -6,6 +6,7 @@
         - '{project-name}-verify-python-{stream}'
         - '{project-name}-build-rpm-{stream}'
         - '{project-name}-build-rpm-snap-{stream}'
+        - '{project-name}-test-rpm-{stream}'
         - '{project-name}-build-deb-{stream}'
 
     project: 'integration/packaging'
     - archive-artifacts:
          artifacts: '**/*.rpm'
 
+- job-template:
+    name: '{project-name}-test-rpm-{stream}'
+
+    node: dynamic_verify
+
+    parameters:
+        - opendaylight-infra-parameters:
+            project: '{project}'
+            branch: '{branch}'
+            refspec: 'refs/heads/{branch}'
+            artifacts: '{archive-artifacts}'
+        - string:
+            name: URL
+            default: 'https://raw.githubusercontent.com/opendaylight/integration-packaging/master/rpm/example_repo_configs/opendaylight-51-release.repo'
+            description: 'Link to .repo or .rpm file'
+        - string:
+            name: REPO_FILE
+            default: '/etc/yum.repos.d/opendaylight-51-release.repo'
+            description: 'Name of the .repo file'
+
+    scm:
+        - integration-gerrit-scm:
+            basedir: 'packaging'
+            refspec: '$GERRIT_REFSPEC'
+            branch: 'master'
+
+    wrappers:
+        - opendaylight-infra-wrappers:
+            build-timeout: '{build-timeout}'
+
+    builders:
+        - shell: !include-raw: include-raw-test-rpm.sh
+        - shell: !include-raw: include-raw-test-karaf.sh
+
+    publishers:
+    - archive-artifacts:
+         artifacts: '**'
+
 - job-template:
     name: '{project-name}-build-deb-{stream}'