-
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.
core: add end-to-end testing with distribution
Signed-off-by: tarilabs <[email protected]>
- Loading branch information
Showing
9 changed files
with
182 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ jobs: | |
poetry install | ||
- name: Run tests | ||
run: | | ||
poetry run pytest | ||
poetry run pytest -s -x |
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,34 @@ | ||
name: end-to-end testing | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Install Poetry | ||
run: | | ||
pipx install poetry | ||
- name: Install dependencies | ||
run: | | ||
poetry install | ||
- name: Start Kind Cluster | ||
uses: helm/kind-action@v1 | ||
with: | ||
cluster_name: kind-kind | ||
e2e-distribution-registry: | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
steps: | ||
- name: Start distribution-registry | ||
run: | | ||
e2e/deploy_distribution_registry.sh | ||
- name: Run tests | ||
run: | | ||
poetry run pytest --e2e -s -x |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#! /bin/bash | ||
|
||
SCRIPT_DIR="$(dirname "$(realpath "$BASH_SOURCE")")" | ||
|
||
kubectl apply -f "${SCRIPT_DIR}/distribution-registry/" | ||
|
||
echo "Waiting for Deployment..." | ||
kubectl wait --for=condition=available deployment/distribution-registry-test-deployment --timeout=5m | ||
kubectl logs deployment/distribution-registry-test-deployment | ||
echo "Deployment looks ready." | ||
|
||
echo "Starting port-forward..." | ||
kubectl port-forward service/distribution-registry-test-service 5001:5001 & | ||
PID=$! | ||
sleep 2 | ||
echo "I have launched port-forward in background with: $PID." |
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,59 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: distribution-registry-test-deployment | ||
labels: | ||
app: distribution-registry-test | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: distribution-registry-test | ||
template: | ||
metadata: | ||
labels: | ||
app: distribution-registry-test | ||
spec: | ||
containers: | ||
- name: distribution-registry-test | ||
image: docker.io/library/registry:2 | ||
args: | ||
- /etc/docker/registry/config.yml | ||
env: | ||
- name: REGISTRY_HTTP_ADDR | ||
value: 0.0.0.0:5001 | ||
ports: | ||
- containerPort: 5001 | ||
volumeMounts: | ||
- mountPath: /var/lib/registry | ||
name: distribution-registry-storage | ||
volumes: | ||
- name: distribution-registry-storage | ||
persistentVolumeClaim: | ||
claimName: distribution-registry-pvc | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: distribution-registry-test-service | ||
labels: | ||
app: distribution-registry-test | ||
spec: | ||
selector: | ||
app: distribution-registry-test | ||
ports: | ||
- protocol: TCP | ||
port: 5001 | ||
targetPort: 5001 | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: distribution-registry-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 100Mi |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
if config.getoption("--e2e"): | ||
skip_not_e2e = pytest.mark.skip(reason="skipping non-e2e tests") | ||
for item in items: | ||
if "e2e" not in item.keywords: | ||
item.add_marker(skip_not_e2e) | ||
return | ||
skip_e2e = pytest.mark.skip(reason="test requires --e2e option to run") | ||
for item in items: | ||
if "e2e" in item.keywords: | ||
item.add_marker(skip_e2e) | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--e2e", action="store_true", default=False, help="opt-in to run tests marked with e2e" | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def target() -> str: | ||
return "localhost:5001/mmortari/mlartifact:v1" | ||
|
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