Skip to content

Commit

Permalink
Fail on error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
federicotdn committed Dec 20, 2024
1 parent f0a9aba commit 6a2658b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
# 2. Run ACT using the `--container-architecture linux/amd64` flag. For example:
# act -W .github/workflows/k6-tests.yaml --container-architecture linux/amd64

- name: Install jq
uses: dcarbone/[email protected]

- name: Run k6 foundations tests
run: ./scripts/run-tests.sh -t **/k6/foundations/*.js -u http://localhost:3333
env:
Expand Down
2 changes: 1 addition & 1 deletion k6/foundations/16.grpc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client, StatusOK } from 'k6/net/grpc';
import { check, sleep } from 'k6';

const BASE_URL = __ENV.BASE_GRPC_URL || 'localhost:3334';
const BASE_URL = __ENV.BASE_GRPC_URL || 'http://localhost:3334';

const client = new Client();
client.load(['definitions'], '../../../proto/quickpizza.proto');
Expand Down
13 changes: 11 additions & 2 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ done

BASE_URL="${BASE_URL:=http://localhost:3333}"
TESTS="${TESTS:=**/k6/foundations/*.js}"
LOGS=logs.txt

export K6_BROWSER_HEADLESS=true
export K6_BROWSER_ARGS='no-sandbox'
Expand All @@ -19,10 +20,18 @@ fi

for test in $TESTS; do
# Disable thresholds because some threshold examples fail
k6 run --no-thresholds -e BASE_URL=$BASE_URL "$test"
rm -f $LOGS
k6 run --no-thresholds -e BASE_URL=$BASE_URL --log-output=file=$LOGS --log-format=json -w --no-summary "$test"

exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
done

jq .level --raw-output < $LOGS | grep -v error

exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
done

0 comments on commit 6a2658b

Please sign in to comment.