Add basic REST API check to RPM tests 92/67592/3
authorDaniel Farrell <dfarrell@redhat.com>
Fri, 26 Jan 2018 01:56:05 +0000 (20:56 -0500)
committerDaniel Farrell <dfarrell@redhat.com>
Mon, 29 Jan 2018 23:18:07 +0000 (18:18 -0500)
Change-Id: I9e786a0d83e1a615911e71c6666b89a79e05e4a3
Fixes: INTPAK-17
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
jjb/packaging/packaging-macros.yaml
jjb/packaging/packaging.yaml
jjb/packaging/test-rest-ok.sh [new file with mode: 0644]

index 57830eaea0109373c7f5158e8907c304c9482141..96cee5a78847f2ba26e94acd5726d61a4fce4ce0 100644 (file)
@@ -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: |
index ea80567dbce8ecaecacb5fef2f028598e028e2c3..f84cbb2fd0c827fc90730f48e2389d99bf5867dc 100644 (file)
           # 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 (file)
index 0000000..a2ed5e5
--- /dev/null
@@ -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