diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2c51ec..4741410 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -197,140 +197,81 @@ release: sys.exit(0) PYTEST_SCRIPT -# Reset stage template - runs in-cluster with IRSA for Secrets Manager access +# Reset stage template - runs from CI runner, uses CI variable for auth # Calls the /api/v1/admin/factory-reset endpoint which handles DB and S3 cleanup .reset_stage_template: &reset_stage_template stage: deploy - image: deps.global.bsf.tools/registry-1.docker.io/alpine/k8s:1.29.12 - timeout: 10m + image: deps.global.bsf.tools/docker/python:3.12-slim + timeout: 5m retry: 1 - variables: - NAMESPACE: orch-stage-namespace before_script: - - kubectl config use-context esv/bsf/bsf-integration/orchard/orchard-mvp:orchard-stage + - pip install --index-url "$PIP_INDEX_URL" httpx script: - | - # Create a Job to run the reset in the cluster - cat < /tmp/test_smoke.py << 'TESTEOF' - import os - import httpx - - def test_health(): - url = os.environ["ORCHARD_TEST_URL"] - r = httpx.get(f"{url}/health", timeout=30) - assert r.status_code == 200 - - def test_login(): - url = os.environ["ORCHARD_TEST_URL"] - password = os.environ["ORCHARD_TEST_PASSWORD"] - with httpx.Client(base_url=url, timeout=30) as client: - r = client.post("/api/v1/auth/login", json={"username": "admin", "password": password}) - assert r.status_code == 200, f"Login failed: {r.status_code} {r.text}" - - def test_api(): - url = os.environ["ORCHARD_TEST_URL"] - r = httpx.get(f"{url}/api/v1/projects", timeout=30) - assert r.status_code == 200 - TESTEOF - - python -m pytest /tmp/test_smoke.py -v - EOF - - | - echo "Waiting for test job to complete..." - kubectl wait --for=condition=complete --timeout=15m job/integration-test-${CI_PIPELINE_ID} -n ${NAMESPACE} || { - echo "Job failed or timed out. Fetching logs..." - kubectl logs job/integration-test-${CI_PIPELINE_ID} -n ${NAMESPACE} || true - kubectl delete job integration-test-${CI_PIPELINE_ID} -n ${NAMESPACE} || true - exit 1 - } - - kubectl logs job/integration-test-${CI_PIPELINE_ID} -n ${NAMESPACE} - - kubectl delete job integration-test-${CI_PIPELINE_ID} -n ${NAMESPACE} || true + ORCHARD_TEST_URL: $STAGE_URL + ORCHARD_TEST_PASSWORD: $STAGE_ADMIN_PASSWORD rules: - if: '$CI_COMMIT_BRANCH == "main"' when: on_success