Skip to content

Commit

Permalink
test: improve e2e script and add record option
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Mar 9, 2021
1 parent ac95a33 commit 9d4764d
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 83 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ jobs:

- go/mod-download-cached

- run: ./test/e2e/circle-ci.bash memory
- run: ./test/e2e/circle-ci.bash memory-jwt
- run: ./test/e2e/circle-ci.bash postgres
- run: ./test/e2e/circle-ci.bash postgres-jwt
- run: ./test/e2e/circle-ci.bash cockroach
- run: ./test/e2e/circle-ci.bash cockroach-jwt
- run: ./test/e2e/circle-ci.bash mysql
- run: ./test/e2e/circle-ci.bash mysql-jwt
- run: ./test/e2e/circle-ci.bash memory --record
- run: ./test/e2e/circle-ci.bash memory-jwt --record
- run: ./test/e2e/circle-ci.bash postgres --record
- run: ./test/e2e/circle-ci.bash postgres-jwt --record
- run: ./test/e2e/circle-ci.bash cockroach --record
- run: ./test/e2e/circle-ci.bash cockroach-jwt --record
- run: ./test/e2e/circle-ci.bash mysql --record
- run: ./test/e2e/circle-ci.bash mysql-jwt --record

workflows:
bdt:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ hydra-login-consent-node
*-packr.go
packrd/
persistence/sql/migrations/schema.sql
cypress/videos
157 changes: 82 additions & 75 deletions test/e2e/circle-ci.bash
Original file line number Diff line number Diff line change
Expand Up @@ -55,81 +55,9 @@ export SERVE_ADMIN_PORT=5001
export LOG_LEAK_SENSITIVE_VALUES=true
export TEST_DATABASE_SQLITE="sqlite://$(mktemp -d -t ci-XXXXXXXXXX)/e2e.sqlite?_fk=true"

case "$1" in
memory)
./hydra migrate sql --yes $TEST_DATABASE_SQLITE > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_SQLITE \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

memory-jwt)
./hydra migrate sql --yes $TEST_DATABASE_SQLITE > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_SQLITE \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

postgres)
./hydra migrate sql --yes $TEST_DATABASE_POSTGRESQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_POSTGRESQL \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

postgres-jwt)
./hydra migrate sql --yes $TEST_DATABASE_POSTGRESQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_POSTGRESQL \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

mysql)
./hydra migrate sql --yes $TEST_DATABASE_MYSQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_MYSQL \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

mysql-jwt)
./hydra migrate sql --yes $TEST_DATABASE_MYSQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_MYSQL \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

cockroach)
./hydra migrate sql --yes $TEST_DATABASE_COCKROACHDB > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_COCKROACHDB \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

cockroach-jwt)
./hydra migrate sql --yes $TEST_DATABASE_COCKROACHDB > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_COCKROACHDB \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

*)
echo $"Usage: $0 {memory|postgres|mysql|cockroach|memory-jwt|postgres-jwt|mysql-jwt|cockroach-jwt} [--watch]"
exit 1
esac

npm run wait-on -- -l -t 300000 \
--interval 1000 -s 1 -d 1000 \
http-get://localhost:5000/health/ready http-get://localhost:5001/health/ready http-get://localhost:5002/ http-get://localhost:5003/oauth2/callback

WATCH=no
RECORD=no

for i in "$@"
do
Expand All @@ -138,16 +66,95 @@ case $i in
WATCH=yes
shift # past argument=value
;;
--record)
RECORD=yes
shift # past argument=value
;;
*)
# unknown option

case "$i" in
memory)
./hydra migrate sql --yes $TEST_DATABASE_SQLITE > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_SQLITE \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

memory-jwt)
./hydra migrate sql --yes $TEST_DATABASE_SQLITE > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_SQLITE \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

postgres)
./hydra migrate sql --yes $TEST_DATABASE_POSTGRESQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_POSTGRESQL \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

postgres-jwt)
./hydra migrate sql --yes $TEST_DATABASE_POSTGRESQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_POSTGRESQL \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

mysql)
./hydra migrate sql --yes $TEST_DATABASE_MYSQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_MYSQL \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

mysql-jwt)
./hydra migrate sql --yes $TEST_DATABASE_MYSQL > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_MYSQL \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

cockroach)
./hydra migrate sql --yes $TEST_DATABASE_COCKROACHDB > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_COCKROACHDB \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=false
;;

cockroach-jwt)
./hydra migrate sql --yes $TEST_DATABASE_COCKROACHDB > ./hydra-migrate.e2e.log 2>&1
DSN=$TEST_DATABASE_COCKROACHDB \
STRATEGIES_ACCESS_TOKEN=jwt \
OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public \
./hydra serve all --dangerous-force-http --sqa-opt-out > ./hydra.e2e.log 2>&1 &
export CYPRESS_jwt_enabled=true
;;

*)
echo $"Usage: $0 {memory|postgres|mysql|cockroach|memory-jwt|postgres-jwt|mysql-jwt|cockroach-jwt} [--watch]"
exit 1
esac
;;
esac
done

npm run wait-on -- -l -t 300000 \
--interval 1000 -s 1 -d 1000 \
http-get://localhost:5000/health/ready http-get://localhost:5001/health/ready http-get://localhost:5002/ http-get://localhost:5003/oauth2/callback

if [[ $WATCH = "yes" ]]; then
(cd ../..; npm run test:watch)
else
(cd ../..; npm run test)
if [[ $RECORD = "yes" ]]; then
(cd ../..; npm run test -- record )
fi
fi

kill %1 || true # This is oauth2-client
Expand Down

0 comments on commit 9d4764d

Please sign in to comment.