From f0c222536547c68dffdab39c155606c84c0fa7d5 Mon Sep 17 00:00:00 2001 From: Daniel Farrell Date: Thu, 25 Jan 2018 20:56:05 -0500 Subject: [PATCH] Add basic REST API check to RPM tests Change-Id: I9e786a0d83e1a615911e71c6666b89a79e05e4a3 Fixes: INTPAK-17 Signed-off-by: Daniel Farrell --- jjb/packaging/packaging-macros.yaml | 2 +- jjb/packaging/packaging.yaml | 1 + jjb/packaging/test-rest-ok.sh | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 jjb/packaging/test-rest-ok.sh diff --git a/jjb/packaging/packaging-macros.yaml b/jjb/packaging/packaging-macros.yaml index 57830eaea0..96cee5a788 100644 --- a/jjb/packaging/packaging-macros.yaml +++ b/jjb/packaging/packaging-macros.yaml @@ -5,7 +5,6 @@ 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 @@ -15,6 +14,7 @@ # 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: test-rest-ok.sh - shell: !include-raw: stop-odl.sh - shell: !include-raw: uninstall-rpm.sh - shell: | diff --git a/jjb/packaging/packaging.yaml b/jjb/packaging/packaging.yaml index ea80567dbc..f84cbb2fd0 100644 --- a/jjb/packaging/packaging.yaml +++ b/jjb/packaging/packaging.yaml @@ -382,6 +382,7 @@ # 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-escape: test-rest-ok.sh - shell: !include-raw: stop-odl.sh - shell: !include-raw: uninstall-rpm.sh diff --git a/jjb/packaging/test-rest-ok.sh b/jjb/packaging/test-rest-ok.sh new file mode 100644 index 0000000000..a2ed5e587d --- /dev/null +++ b/jjb/packaging/test-rest-ok.sh @@ -0,0 +1,25 @@ +#!/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 + +echo "Waiting for ODL REST API to come up..." +COUNT="0" +while true; do + # Will fail if 8181 isn't open, check for that first + RESP=$( curl --user admin:admin --silent --head --output /dev/null --write-out '%{http_code}' http://localhost:8181/restconf/modules ) + echo "Curl of ODL REST API HTTP response code: $RESP" + if [[ $RESP = *200* ]]; then + echo "ODL REST API returned 200" + break + elif [ $COUNT -gt 120 ]; then + echo "Timeout waiting for HTTP 200 from REST API" + exit 1 + else + ((COUNT+=1)) + sleep 1 + fi +done -- 2.36.6