Skip to content

Commit a40efb5

Browse files
kukkok3stevenjminikin
authored
test(cat-gateway): schemathesis for health endpoints (#1485)
* wip * wip * wip * wip * wip * wip * fix: remove scylla earthfile * feat: runs schemathesis only on api/started endpoint * clean up * fix: blueprint * fix: blueprint * fix: blueprint * fix: blueprint * fix: remove hooks * fix: remove some checks * feat: adds seed param to chemathesis package * fix: poetry * fix: earthly dockerd bug * fix: remove checks all param * fix: remove duplicated function * fix: regex * adds all check * chore: clean up * clean up * chore: update schemathesis version * fix: update schemathesis option to latest version * fixes * fix: st target failing statment --------- Co-authored-by: Steven Johnson <[email protected]> Co-authored-by: Oleksandr Prokhorenko <[email protected]>
1 parent 40afc42 commit a40efb5

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,8 @@ test-results/
123123
/playwright/.cache/
124124
extensions/
125125
browser_extensions/
126-
!catalyst_voices/packages/internal/catalyst_voices_driver/lib/src/extensions/
126+
!catalyst_voices/packages/internal/catalyst_voices_driver/lib/src/extensions/
127+
128+
#Test report and coverage
129+
*.junit-report.xml
130+
*.coverage.info

Overall,

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__pycache__
2-
junit-report.xml
3-
.hypothesis/
2+
.hypothesis/
3+
cassette.yaml

catalyst-gateway/tests/schemathesis_tests/Earthfile

+16-8
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ VERSION 0.8
33
package-schemathesis:
44
FROM python:3.12-alpine3.20
55
# TODO: https://github.com/input-output-hk/catalyst-voices/issues/465
6+
ARG openapi_spec
7+
# optional argument that can be used to pass a --hypothesis-seed to replicate specific test failures
8+
ARG seed
9+
ARG version=3.39.5
10+
611
RUN apk add --no-cache gcc musl-dev
7-
RUN python -m pip install schemathesis==3.27.1
12+
RUN python -m pip install schemathesis==$version
813
RUN mkdir /results
914
COPY ./hooks/hooks.py .
1015
VOLUME /results
11-
ARG openapi_spec
12-
# optional argument that can be used to pass a --hypothesis-seed to replicate specific test failures
13-
ARG seed
14-
ENTRYPOINT st run --endpoint '^/api/v1/health' $openapi_spec \
16+
ENTRYPOINT st run --include-path-regex '^/api/v1/health/' \
17+
--exclude-path '/api/v1/health/inspection' \ #excluding since this is a internal debug endpoint
18+
--checks=all $openapi_spec \
1519
--workers=2 \
1620
--wait-for-schema=120 \
1721
--max-response-time=5000 \
1822
--hypothesis-max-examples=1000 \
1923
--data-generation-method=all \
20-
--skip-deprecated-operations \
24+
--exclude-deprecated \
2125
--force-schema-version=30 \
2226
--show-trace \
2327
--force-color \
@@ -31,7 +35,7 @@ package-schemathesis:
3135
# test-fuzzer-api - Fuzzy test cat-gateway using openapi specs.
3236
test-fuzzer-api:
3337
FROM earthly/dind:alpine-3.19-docker-25.0.5-r0
34-
RUN apk update && apk add iptables-legacy # workaround for https://github.com/earthly/earthly/issues/3784
38+
RUN apk update && apk add iptables-legacy curl # workaround for https://github.com/earthly/earthly/issues/3784
3539
COPY schemathesis-docker-compose.yml .
3640
LET OPENAPI_SPEC="http://0.0.0.0:3030/docs/cat-gateway.json"
3741
ARG seed
@@ -45,11 +49,15 @@ test-fuzzer-api:
4549
--service cat-gateway \
4650
--allow-privileged
4751

48-
RUN docker run --net=host --name=st schemathesis:latest && \
52+
RUN docker run --net=host --name=st schemathesis:latest || echo fail > fail; \
4953
docker cp st:/results/junit-report.xml junit-report.xml && \
5054
docker cp st:/results/cassette.yaml cassette.yaml
5155
END
5256
WAIT
5357
SAVE ARTIFACT junit-report.xml AS LOCAL schemathesis.junit-report.xml
5458
SAVE ARTIFACT cassette.yaml AS LOCAL cassette.yaml
59+
END
60+
IF [ -f fail ]
61+
RUN --no-cache echo "Schemathesis test failed. Check the logs for more details" && \
62+
exit 1
5563
END

0 commit comments

Comments
 (0)