Skip to content

Commit 89af055

Browse files
fegeAl-Pragliola
andauthored
Add api tests stateless (kubeflow#1242)
* Add api tests stateless Signed-off-by: fege <[email protected]> * Fix github action failures, lint and nox Signed-off-by: fege <[email protected]> * Add too_slow and remove code to force the model version id Signed-off-by: fege <[email protected]> * Add filter_too_much Signed-off-by: fege <[email protected]> * add hook to avoid Unsatisfiable Signed-off-by: fege <[email protected]> * remove variable Signed-off-by: fege <[email protected]> * add artifact_states Signed-off-by: fege <[email protected]> * Add example to schema Signed-off-by: fege <[email protected]> * Add example in src Signed-off-by: fege <[email protected]> * register strategy for string of int64 Signed-off-by: fege <[email protected]> * sort imports Signed-off-by: fege <[email protected]> * modify case for problematic endpoints Signed-off-by: fege <[email protected]> * add more examples Signed-off-by: fege <[email protected]> * pin urllib Signed-off-by: fege <[email protected]> * exclude problematic endpoints and test with valid data Signed-off-by: fege <[email protected]> * Add gha to run the test and mark them with fuzz Signed-off-by: fege <[email protected]> * revert change in Makefile pushed by error Signed-off-by: fege <[email protected]> * skip test not marked with e2e or fuzz, trigger the fuzz on pr comment Signed-off-by: fege <[email protected]> * trigger with label Signed-off-by: fege <[email protected]> * correct the label name Signed-off-by: fege <[email protected]> * add types and semplify the if Signed-off-by: fege <[email protected]> * do not run e2e if test-fuzz label is added Signed-off-by: fege <[email protected]> * unpin urllib Signed-off-by: fege <[email protected]> * modify lock Signed-off-by: fege <[email protected]> * fix: remove proc on label Signed-off-by: Alessio Pragliola <[email protected]> --------- Signed-off-by: fege <[email protected]> Signed-off-by: Alessio Pragliola <[email protected]> Co-authored-by: Alessio Pragliola <[email protected]>
1 parent 5f69126 commit 89af055

File tree

11 files changed

+949
-83
lines changed

11 files changed

+949
-83
lines changed

.github/workflows/python-tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ on:
1313
- ".github/ISSUE_TEMPLATE/**"
1414
- ".github/dependabot.yml"
1515
- "docs/**"
16-
1716
jobs:
1817
lint:
1918
name: ${{ matrix.session }}
@@ -221,6 +220,15 @@ jobs:
221220
kubectl port-forward service/distribution-registry-test-service 5001:5001 &
222221
sleep 2
223222
nox --python=${{ matrix.python }} --session=e2e -- --cov-report=xml
223+
- name: Nox test fuzz (main only)
224+
if: github.ref == 'refs/heads/main'
225+
working-directory: clients/python
226+
run: |
227+
kubectl port-forward -n kubeflow service/model-registry-service 8080:8080 &
228+
kubectl port-forward -n minio svc/minio 9000:9000 &
229+
kubectl port-forward service/distribution-registry-test-service 5001:5001 &
230+
sleep 2
231+
nox --python=${{ matrix.python }} --session=fuzz
224232
225233
docs-build:
226234
name: ${{ matrix.session }}

clients/python/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
__pycache__/
88
venv/
99
.port-forwards.pid
10+
.hypothesis/

clients/python/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ test-e2e: deploy-latest-mr deploy-local-registry deploy-test-minio
3636
$(MAKE) test-e2e-cleanup
3737
@exit $$STATUS
3838

39+
.PHONY: test-fuzz
40+
test-fuzz: deploy-latest-mr deploy-local-registry deploy-test-minio
41+
@echo "Starting test-fuzz"
42+
poetry install --all-extras
43+
@set -a; . ../../scripts/manifests/minio/.env; set +a; \
44+
poetry run pytest --fuzz -v -s --hypothesis-show-statistics
45+
@rm -f ../../scripts/manifests/minio/.env
46+
$(MAKE) test-e2e-cleanup
47+
@exit $$STATUS
48+
3949
.PHONY: test-e2e-run
4050
test-e2e-run:
4151
@echo "Ensuring all extras are installed..."

clients/python/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ Then you can run tests:
345345
make test test-e2e
346346
```
347347

348+
Then you can run fuzz tests:
349+
350+
```bash
351+
make test-fuzz
352+
```
353+
348354
### Using Nox
349355

350356
Common tasks, such as building documentation and running tests, can be executed using [`nox`](https://github.com/wntrblm/nox) sessions.

clients/python/noxfile.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def tests(session: Session) -> None:
6060
"pytest-asyncio",
6161
"uvloop",
6262
"olot",
63+
"schemathesis",
6364
)
6465
session.run(
6566
"pytest",
@@ -83,6 +84,7 @@ def e2e_tests(session: Session) -> None:
8384
"boto3",
8485
"olot",
8586
"uvloop",
87+
"schemathesis",
8688
)
8789
try:
8890
session.run(
@@ -99,6 +101,22 @@ def e2e_tests(session: Session) -> None:
99101
session.notify("coverage", posargs=[])
100102

101103

104+
@session(name="fuzz", python=python_versions)
105+
def fuzz_tests(session: Session) -> None:
106+
"""Run the fuzzing tests."""
107+
session.install(
108+
".",
109+
"requests",
110+
"pytest",
111+
"uvloop",
112+
"olot",
113+
"schemathesis",
114+
)
115+
session.run(
116+
"pytest",
117+
"--fuzz",
118+
"-rA",
119+
)
102120
@session(python=python_versions[0])
103121
def coverage(session: Session) -> None:
104122
"""Produce the coverage report."""

0 commit comments

Comments
 (0)