Skip to content

Commit

Permalink
feat fuzzer target test
Browse files Browse the repository at this point in the history
  • Loading branch information
kukkok3 committed Jan 30, 2024
1 parent b18285a commit ea91ece
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 534 deletions.
6 changes: 4 additions & 2 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ hosted-check:

# Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# Only used to validate tooling is working across host toolsets.
all-hosts-check:
all-hosts-check:
BUILD --platform=linux/amd64 --platform=linux/arm64 +hosted-check

hosted-build:
Expand All @@ -39,7 +39,7 @@ hosted-build:

# Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# Only used to validate tooling is working across host toolsets.
all-hosts-build:
all-hosts-build:
BUILD --platform=linux/amd64 --platform=linux/arm64 +hosted-build

unit-test-hosted:
Expand Down Expand Up @@ -103,9 +103,11 @@ test:
IF [ "$USERARCH" == "arm64" ]
BUILD --platform=linux/arm64 +unit-test-hosted
BUILD --platform=linux/arm64 ./tests+integration-test
BUILD --platform=linux/arm64 ./tests+fuzzer-api-test
ELSE
BUILD --platform=linux/amd64 +unit-test-hosted
BUILD --platform=linux/amd64 ./tests+integration-test
BUILD --platform=linux/arm64 ./tests+fuzzer-api-test
END

# Publish packages if all integration tests have passed. (Failure to pass tests will prevent packages being published.)
Expand Down
54 changes: 47 additions & 7 deletions catalyst-gateway/tests/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ deps:
fuzzer-api-test:
FROM earthly/dind:alpine
LET address="127.0.0.1:3030"
LET max-examples=100
LET max-response-time=50
LET max_examples=1
LET max_response_time=50

COPY +deps/cat-gateway .
COPY integration/docker-compose.yml .
Expand All @@ -22,21 +22,61 @@ fuzzer-api-test:
--load event-db:latest=(../event-db+build --with_historic_data=false) \
--service event-db \
--allow-privileged
RUN --no-cache (./cat-gateway run \
RUN --no-cache touch ~/junit-report.xml && (./cat-gateway run \
--address $address \
--database-url=postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev \
--log-level=error > cat-gateway.log &) && \
docker run --net=host schemathesis/schemathesis:stable \
run --checks all http://$address/docs/cat-gateway.json \
-D all --wait-for-schema=15 --contrib-openapi-fill-missing-examples \
--max-response-time=$max-response-time --hypothesis-max-examples=$max-examples \
--show-trace --junit-xml junit-report.xml || echo fail > fail
run -E ^/api/health/started http://$address/docs/cat-gateway.json \
--wait-for-schema=15 --contrib-openapi-fill-missing-examples --skip-deprecated-operations \
--max-response-time=$max_response_time --hypothesis-max-examples=$max_examples --validate-schema=false \
--show-trace --junit-xml junit-report.xml && ls

END

SAVE ARTIFACT junit-report.xml AS LOCAL junit-report.xml
SAVE ARTIFACT cat-gateway.log AS LOCAL cat-gateway.log

fuzzy-test:
FROM python:3.12-alpine3.18

# Install extra packages we will need to support plugins.
RUN apk add --no-cache \
curl \
libffi-dev \
gcc \
musl-dev \
libgcc
DO github.com/earthly/lib:2.2.11+INSTALL_DIND
RUN python -m pip install schemathesis

LET address="127.0.0.1:3030"
LET max_examples=1
LET max_response_time=50

COPY +deps/cat-gateway .
COPY integration/docker-compose.yml .

WITH DOCKER \
--compose docker-compose.yml \
--load event-db:latest=(../event-db+build --with_historic_data=false) \
--service event-db \
--allow-privileged
RUN --no-cache (./cat-gateway run \
--address $address \
--database-url=postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev \
--log-level=error > cat-gateway.log &) && \
st run -E ^/api/health/started http://$address/docs/cat-gateway.json \
--wait-for-schema=15 --contrib-openapi-fill-missing-examples --skip-deprecated-operations \
--max-response-time=$max_response_time --hypothesis-max-examples=$max_examples --validate-schema=false \
--show-trace --junit-xml junit-report.xml && ls

END

SAVE ARTIFACT junit-report.xml AS LOCAL junit-report.xml
SAVE ARTIFACT cat-gateway.log AS LOCAL cat-gateway.log


integration-test:
# Example of a setup for integration testing
FROM ../+builder
Expand Down
Loading

0 comments on commit ea91ece

Please sign in to comment.