Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve schemathesis logs #374

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions catalyst-gateway/tests/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,50 @@ package-schemathesis:
RUN mkdir /results

VOLUME /results

ENTRYPOINT st run --checks all \
# TODO: https://github.com/input-output-hk/catalyst-voices/issues/330
--exclude-checks content_type_conformance \
--exclude-checks response_schema_conformance \
--data-generation-method all \
--workers=$workers \
--wait-for-schema=$wait_for_schema \
--max-response-time=$max_response_time \
--hypothesis-max-examples=$max_examples \
--force-color \
--skip-deprecated-operations \
--show-trace \
--force-schema-version=$schema_version \
--junit-xml=/results/junit-report.xml \
$openapi_spec
ENTRYPOINT st run --checks all $openapi_spec --workers=$workers --wait-for-schema=$wait_for_schema \
--max-response-time=$max_response_time --hypothesis-max-examples=$max_examples \
--data-generation-method=all --skip-deprecated-operations \
--force-schema-version=$schema_version --show-trace --force-color \
--junit-xml /results/junit-report.xml --cassette-path=/results/cassette.yaml \
# TODO: https://github.com/input-output-hk/catalyst-voices/issues/330
--exclude-checks content_type_conformance \
--exclude-checks response_schema_conformance

SAVE IMAGE schemathesis:$tag

# test-fuzzer-api - Fuzzy test cat-gateway using openapi specs
test-fuzzer-api:
FROM earthly/dind:alpine-3.19
RUN apk update && apk add iptables-legacy # workaround for https://github.com/earthly/earthly/issues/3784
RUN apk add yq
ARG DB_URL="postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev"
ARG CAT_ADDRESS="127.0.0.1:3030"
ARG OPENAPI_SPEC="http://127.0.0.1:3030/docs/cat-gateway.json"

COPY schemathesis-docker-compose.yml .
WITH DOCKER \
--compose schemathesis-docker-compose.yml \
--load schemathesis:latest=(+package-schemathesis --openapi_spec="http://127.0.0.1:3030/docs/cat-gateway.json") \
--load schemathesis:latest=(+package-schemathesis --openapi_spec=$OPENAPI_SPEC) \
--load event-db:latest=(../event-db+build) \
--load cat-gateway:latest=(../+package-cat-gateway --address="127.0.0.1:3030" \
--db_url="postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev") \
--load cat-gateway:latest=(../+package-cat-gateway --address=$CAT_ADDRESS --db_url=$DB_URL) \
--service event-db \
--service cat-gateway \
--allow-privileged
RUN docker run --net=host --name=st schemathesis:latest || echo fail > fail && \
docker logs cat-gateway > ./cat-gateway.log && \
docker cp st:/results/junit-report.xml junit-report.xml
docker cp st:/results/junit-report.xml junit-report.xml && \
docker cp st:/results/cassette.yaml cassette.yaml
END
WAIT
SAVE ARTIFACT junit-report.xml AS LOCAL schemathesis.junit-report.xml
SAVE ARTIFACT cat-gateway.log AS LOCAL cat-gateway.log
SAVE ARTIFACT cassette.yaml AS LOCAL cassette.yaml
END
IF [ -f fail ]
RUN echo "Schemathesis run failed" && \
echo "Printing catalyst gateway logs..." && \
RUN echo -e "\033[0;31mSchemathesis test run failed\n" && \
echo -e "\033[0;31mFailed tests:" && \
yq -PC '.http_interactions.[] | select(.status == "FAILURE")' cassette.yaml && \
echo -e "\033[0;31mCatalyst Gateway logs:" && \
jq --color-output . cat-gateway.log cat-gateway.log && \
exit 1
END
Expand Down
Loading