Merge "Move dlux Sonar scan to Sonarcloud"
[releng/builder.git] / jjb / packaging / test-rest-ok.sh
1 #!/bin/bash
2
3 # Options:
4 #   -x: Echo commands
5 #   -e: Fail on errors
6 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
7 set -ex -o pipefail
8
9 echo "Waiting for ODL REST API to come up..."
10 COUNT="0"
11 while true; do
12     # Will fail if 8181 isn't open, check for that first
13     RESP=$( curl --user admin:admin --silent --head --output /dev/null --write-out '%{http_code}' http://localhost:8181/restconf/modules )
14     echo "Curl of ODL REST API HTTP response code: $RESP"
15     if [[ $RESP = *200* ]]; then
16         echo "ODL REST API returned 200"
17         break
18     elif [ $COUNT -gt 120 ]; then
19         echo "Timeout waiting for HTTP 200 from REST API"
20         exit 1
21     else
22         ((COUNT+=1))
23         sleep 1
24     fi
25 done