Skip to content

Commit

Permalink
feat: add schematesis target
Browse files Browse the repository at this point in the history
  • Loading branch information
kukkok3 committed Jan 30, 2024
1 parent ed887e3 commit b18285a
Show file tree
Hide file tree
Showing 4 changed files with 1,634 additions and 6 deletions.
46 changes: 40 additions & 6 deletions catalyst-gateway/tests/Earthfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,54 @@
VERSION 0.7
VERSION --arg-scope-and-set 0.7

deps:
FROM ../+builder
RUN cargo build -p cat-gateway --release
RUN ./target/release/cat-gateway docs cat-gateway-api.json
SAVE ARTIFACT cat-gateway-api.json cat-gateway-api.json
SAVE ARTIFACT target/release/cat-gateway cat-gateway

fuzzer-api-test:
FROM earthly/dind:alpine
LET address="127.0.0.1:3030"
LET max-examples=100
LET max-response-time=50

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

WITH DOCKER \
--compose docker-compose.yml \
--pull schemathesis/schemathesis:stable \
--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 &) && \
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

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
# the cat-gateway binary will be replaced by the cat-gateway package when this will be available

FROM ../+builder
DO github.com/earthly/lib:2.2.11+INSTALL_DIND
COPY ../+hosted-build/cat-gateway .
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 sleep 5 && \
(./cat-gateway run \
RUN (./cat-gateway run \
--address "127.0.0.1:3030" \
--database-url=postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev \
--log-level=debug &) && \
Expand Down
Loading

0 comments on commit b18285a

Please sign in to comment.