-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update openresty to 1.15.8.1, add tests
Signed-off-by: Graham Weldon <graham@grahamweldon.com>
- Loading branch information
1 parent
85e5adb
commit 3454437
Showing
3 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
TEST_PKG_VERSION="$(echo "${TEST_PKG_IDENT}" | cut -d/ -f3)" | ||
|
||
@test "Version matches" { | ||
result="$(hab pkg exec ${TEST_PKG_IDENT} openresty -v 2>&1 | head -n 1 | awk -F'/' '{print $2}')" | ||
[ "$result" = "${TEST_PKG_VERSION}" ] | ||
} | ||
|
||
@test "Service is running" { | ||
[ "$(hab svc status | grep "openresty[0-9]*\.default" | awk '{print $4}' | grep up)" ] | ||
} | ||
|
||
@test "Listening on port 80" { | ||
result="$(netstat -peanut | grep nginx | awk '{print $4}' | awk -F':' '{print $2}')" | ||
[ "${result}" -eq 80 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
#/ Usage: test.sh <pkg_ident> | ||
#/ | ||
#/ Example: test.sh core/php/7.2.8/20181108151533 | ||
#/ | ||
|
||
set -euo pipefail | ||
|
||
if [[ -z "${1:-}" ]]; then | ||
grep '^#/' < "${0}" | cut -c4- | ||
exit 1 | ||
fi | ||
|
||
TEST_PKG_IDENT="${1}" | ||
export TEST_PKG_IDENT | ||
hab pkg install core/bats --binlink | ||
hab pkg install core/busybox-static | ||
hab pkg binlink core/busybox-static netstat | ||
hab pkg install "${TEST_PKG_IDENT}" | ||
|
||
hab sup term | ||
hab sup run & | ||
sleep 5 | ||
|
||
hab svc load "${TEST_PKG_IDENT}" | ||
|
||
# Allow service start | ||
WAIT_SECONDS=5 | ||
echo "Waiting ${WAIT_SECONDS} seconds for service to start..." | ||
sleep "${WAIT_SECONDS}" | ||
|
||
bats "$(dirname "${0}")/test.bats" | ||
|
||
hab svc unload "${TEST_PKG_IDENT}" || true |