-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/selectable-db-query-performance-logging
- Loading branch information
Showing
8 changed files
with
107 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
__pycache__ | ||
junit-report.xml | ||
junit-report.xml | ||
.hypothesis/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__pycache__ | ||
junit-report.xml | ||
.hypothesis/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
VERSION 0.8 | ||
|
||
package-schemathesis: | ||
FROM python:3.12-alpine3.19 | ||
|
||
ARG tag="latest" | ||
ARG max_examples=1000 | ||
# TODO: https://github.com/input-output-hk/catalyst-voices/issues/465 | ||
ARG max_response_time=3000 | ||
ARG wait_for_schema=15 | ||
ARG workers=2 | ||
ARG schema_version=30 | ||
ARG openapi_spec | ||
|
||
RUN apk add --no-cache gcc musl-dev | ||
RUN python -m pip install schemathesis==3.27.1 | ||
RUN mkdir /results | ||
COPY ./hooks/hooks.py . | ||
|
||
VOLUME /results | ||
ENTRYPOINT export SCHEMATHESIS_HOOKS=hooks \ | ||
&& 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 | ||
|
||
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 zstd | ||
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=$OPENAPI_SPEC) \ | ||
--load event-db:latest=(../../event-db+build) \ | ||
--load cat-gateway:latest=(../../+package-cat-gateway) \ | ||
--service event-db \ | ||
--service cat-gateway \ | ||
--allow-privileged | ||
RUN docker run --net=host --name=st schemathesis:latest || echo fail > fail && \ | ||
docker-compose logs cat-gateway > ./cat-gateway.log && zstd -9 cat-gateway.log && \ | ||
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.zst AS LOCAL cat-gateway.log.zst | ||
SAVE ARTIFACT cassette.yaml AS LOCAL cassette.yaml | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import copy | ||
import schemathesis | ||
import schemathesis.schemas | ||
from typing import Any, Dict | ||
|
||
@schemathesis.hook | ||
def before_load_schema( | ||
context: schemathesis.hooks.HookContext, | ||
raw_schema: Dict[str, Any], | ||
) -> None: | ||
paths = dict(raw_schema["paths"]) | ||
for endpoint in paths.keys(): | ||
endpoint_data = dict(raw_schema["paths"][endpoint]) | ||
|
||
# Get first method data as reference | ||
ref_info = next(iter(endpoint_data.values())) | ||
|
||
# Create new method data using reference data, replacing 'responses' field | ||
new_info = copy.deepcopy(ref_info) | ||
new_info["responses"] = {"405": {"description": "method not allowed"}} | ||
|
||
# Update endpoint if a method is not declared | ||
if "get" not in endpoint_data: | ||
endpoint_data.update([("get", new_info),]) | ||
if "post" not in endpoint_data: | ||
endpoint_data.update([("post", new_info),]) | ||
if "put" not in endpoint_data: | ||
endpoint_data.update([("put", new_info),]) | ||
if "patch" not in endpoint_data: | ||
endpoint_data.update([("patch", new_info),]) | ||
if "delete" not in endpoint_data: | ||
endpoint_data.update([("delete", new_info),]) | ||
|
||
# Update endpoint | ||
raw_schema["paths"][endpoint] = endpoint_data | ||
|
File renamed without changes.