Skip to content

Commit

Permalink
Auto-kill test runner after 10 retries (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Oct 28, 2019
1 parent 0ef3bce commit eaad598
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
github.com/ory/herodot v0.6.2
github.com/ory/ladon v1.0.1
github.com/ory/viper v1.5.6
github.com/ory/x v0.0.79
github.com/ory/x v0.0.80
github.com/pborman/uuid v1.2.0
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ github.com/ory/ladon v1.0.1/go.mod h1:1VhCA2mBtaMhRUS6VS0d9qrNVDQnFXqSRb5D0NvQUP
github.com/ory/pagination v0.0.1/go.mod h1:d1ToRROAUleriPhmb2dYbhANhhLwZ8s395m2yJCDFh8=
github.com/ory/viper v1.5.6 h1:w4ceGgWwWLzAFYQ7bHaDZmwNsAto2JPVdyQjQnn7VWI=
github.com/ory/viper v1.5.6/go.mod h1:TYmpFpKLxjQwvT4f0QPpkOn4sDXU1kDgAwJpgLYiQ28=
github.com/ory/x v0.0.79 h1:epo/41vLUB/GdgJ1qNxKK7hYqzCUu1GpKVsAGUu9EA0=
github.com/ory/x v0.0.79/go.mod h1:WVlPrVNe4wtPfdXqE6B+x7a7xoTR2EFGIGxZTPdAuxw=
github.com/ory/x v0.0.80 h1:Gv8puLh2Yn3cyx0k9vweQSfoR+xwgQAPQotkqX43Rjo=
github.com/ory/x v0.0.80/go.mod h1:WVlPrVNe4wtPfdXqE6B+x7a7xoTR2EFGIGxZTPdAuxw=
github.com/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
Expand Down
21 changes: 20 additions & 1 deletion test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
set -euxo pipefail

waitport() {
while ! nc -z localhost $1 ; do sleep 1 ; done
i=0
while ! nc -z localhost "$1" ; do
sleep 1
if [ $i -gt 10 ]; then
cat ./oathkeeper.e2e.log
echo "-----"
cat ./api.e2e.log
exit 1
fi
i=$((i+1))
done
}

cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
Expand All @@ -27,7 +37,16 @@ waitport 6660
waitport 6661
waitport 6662

function finish {
cat ./oathkeeper.e2e.log
echo "-----"
cat ./api.e2e.log
}
trap finish EXIT

okclient

kill %1 || true
kill %2 || true

trap - EXIT
2 changes: 1 addition & 1 deletion test/reload/config.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ serve:
port: 6060

access_rules:
repositories:
repositories: []

authenticators:
noop:
Expand Down
2 changes: 1 addition & 1 deletion test/reload/config.6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ serve:
port: 6060

access_rules:
repositories:
repositories: []

authenticators:
noop:
Expand Down
32 changes: 23 additions & 9 deletions test/reload/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
set -euxo pipefail

waitport() {
while ! nc -z localhost $1 ; do sleep 1 ; done
i=0
while ! nc -z localhost "$1" ; do
sleep 1
if [ $i -gt 10 ]; then
cat ./oathkeeper.log
exit 1
fi
i=$((i+1))
done
}

cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
Expand All @@ -23,38 +31,44 @@ LOG_LEVEL=debug oathkeeper --config ./config.yaml serve >> ./oathkeeper.log 2>&1
waitport 6060
waitport 6061

sleep 2
function finish {
cat ./oathkeeper.log
}
trap finish EXIT

sleep 5

echo "Executing request against no configured rules -> 404"
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 404 ]] && exit 1

echo "Executing request against a now configured rule -> 200"
cp config.2.yaml config.yaml; sleep 1; [[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 200 ]] && exit 1
cp config.2.yaml config.yaml; sleep 3; [[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 200 ]] && exit 1

echo "Executing request against updated rule with deny in it -> 403"
cp config.3.yaml config.yaml; sleep 1; [[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 403 ]] && exit 1
cp config.3.yaml config.yaml; sleep 3; [[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 403 ]] && exit 1

echo "Executing request against updated rule with deny deny disabled -> 500"
cp config.4.yaml config.yaml; sleep 1; [[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 500 ]] && exit 1
cp config.4.yaml config.yaml; sleep 3; [[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 500 ]] && exit 1

echo "Making sure route to be registered is not available yet -> 404"
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/other-rules -w '%{http_code}') -ne 404 ]] && exit 1

echo "Load another rule set -> all 200"
cp rules.3.1.json rules.3.json
cp config.5.yaml config.yaml; sleep 1
cp config.5.yaml config.yaml; sleep 3
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 200 ]] && exit 1
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/other-rules -w '%{http_code}') -ne 200 ]] && exit 1

echo "Make changes to other rule -> should 403"
cp rules.3.2.json rules.3.json; sleep 1
cp rules.3.2.json rules.3.json; sleep 3
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 200 ]] && exit 1
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/other-rules -w '%{http_code}') -ne 403 ]] && exit 1

echo "Remove all configs -> all 404"
cp config.6.yaml config.yaml; sleep 1
cp config.6.yaml config.yaml; sleep 3
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/rules -w '%{http_code}') -ne 404 ]] && exit 1
[[ $(curl --silent --output /dev/null -f ${OATHKEEPER_PROXY}/other-rules -w '%{http_code}') -ne 404 ]] && exit 1

kill %1 || true
exit 0

trap - EXIT

0 comments on commit eaad598

Please sign in to comment.