Skip to content

Commit

Permalink
fix end to end
Browse files Browse the repository at this point in the history
  • Loading branch information
escoand committed Jun 17, 2024
1 parent e4ebe08 commit 2dad2a9
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions test-kube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ set -euo pipefail
trap teardown EXIT TERM INT

KUBEDIR=kube
TMP1=$(mktemp)
TMP2=$(mktemp)
TMP=$(mktemp -d)
echo $TMP

# shellcheck disable=SC2317
teardown() {
[ -s "$TMP1" ] && return
date >"$TMP1"
[ -f "$TMP/teardown" ] && return
touch "$TMP/teardown"
echo "# tear down"
find "$KUBEDIR" secrets.sample.yaml -name '*.yaml' -exec podman kube play --down --force {} \; >/dev/null
sed -n 's/^[[:blank:]]*claimName:[[:blank:]]*//p' "$KUBEDIR"/*.yaml |
xargs podman volume rm -f >/dev/null
rm -f "$TMP1" "$TMP2"
rm -fr "$TMP"
}

getsecret() {
Expand All @@ -29,19 +29,27 @@ endtoend() {
DOMAIN=$1
PAGE=$2
RESULT=$3
RC=0
shift 3
if curl -ikLsS --noproxy "*" -o "$TMP2" "$@" \
--connect-to "$DOMAIN:80:127.0.0.1:8080" \
--connect-to "$DOMAIN:443:127.0.0.1:8443" \
"http://$DOMAIN/$PAGE" ||
# ignore max redir error
[ $? = 47 ]; then
grep -Fq "$RESULT" "$TMP2"
else
echo "# -> failed"
cat "$TMP2"
return 1
{
set -x
# shellcheck disable=SC2015
{
curl -ikLsS --noproxy "*" -o "$TMP/output" "$@" \
--connect-to "$DOMAIN:80:127.0.0.1:8080" \
--connect-to "$DOMAIN:443:127.0.0.1:8443" \
"http://$DOMAIN/$PAGE" ||
[ $? = 47 ] # ignore max redirect
} && grep -iq "$RESULT" "$TMP/output" || RC=$?
set +x
} >"$TMP/endtoend" 2>&1
if [ $RC != 0 ]; then
echo "# -> failed:"
cat "$TMP/endtoend"
echo "# -> output:"
cat "$TMP/output"
fi
return $RC
}

echo "# patch pods for testing"
Expand Down Expand Up @@ -80,8 +88,8 @@ endtoend "$DOMAIN" status.php '"installed":true'
echo "# test Redir end-to-end"
DOMAIN=$(getsecret redir_domain)
TARGET=$(getsecret redir_target)
endtoend "$DOMAIN" test.php "Location: $TARGET" --max-redirs 1 --no-show-error
endtoend "$DOMAIN" test.php "Location: $TARGET" --max-redirs 1

echo "# test Wordpress end-to-end"
DOMAIN=$(getsecret wordpress_domain)
endtoend "$DOMAIN" wp-admin/install.php "HTTP/1.1 200"
endtoend "$DOMAIN" wp-admin/install.php "^HTTP/[1-9\.]* 200"

0 comments on commit 2dad2a9

Please sign in to comment.