-
Notifications
You must be signed in to change notification settings - Fork 0
chore: added/updated tests for backend #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
f5fabe3
event repo update
HardMax71 4c0ea42
small bug fixes (domain vs doc inconsistency) + removed unused function
HardMax71 6ddf1e5
flaky test fix
HardMax71 4afcf95
idempotent logic in manager: skipping any alr existing doc, adding on…
HardMax71 f92148f
idempotent logic in manager: atomic upserts
HardMax71 34fa313
idempotent logic in manager: atomic upserts
HardMax71 8c47240
idempotent logic in manager: terminal states ignored
HardMax71 45e7115
idempotent logic in manager: terminal states ignored
HardMax71 297f9ef
updated tests, trying to fix flakiness
HardMax71 3d52bf3
other flaky tests
HardMax71 1ac646f
faker redis lib added, also removed exclusion of mypy+ruff for /tests
HardMax71 6d49185
further fixes
HardMax71 c16a8dd
further fixes
HardMax71 3266dcf
further fixes
HardMax71 8d80def
further fixes
HardMax71 fc63193
further fixes
HardMax71 8bd6494
further fixes
HardMax71 04edff1
further fixes
HardMax71 a382c06
further fixes, new lib for async comms to k8s
HardMax71 34a08ec
further fixes
HardMax71 87b078f
further fixes
HardMax71 522e0e5
init event schemas - from now only in fastapi server, removed from wo…
HardMax71 23ade68
fixes
HardMax71 2b2fa54
removed init beanie from all workers, now only main fastapi server do…
HardMax71 d4adcd2
removed EventStore from 8s worker
HardMax71 0ac6f8b
fix in test
HardMax71 06374a4
removed flaky test, also added module scoped init_beanie
HardMax71 6368e14
scope mismatch in e2e tests
HardMax71 54bb765
hcl stuff for deploy, also removed separate compose file for CI, now …
HardMax71 bcdb8ea
frontend e2e ci fix, also asgitransport fix (now testing against real…
HardMax71 506dcf1
further fixes
HardMax71 1b4a85b
dumb error fix
HardMax71 cf513f8
removed cleanup - test workers use separate dbs
HardMax71 8c53c26
further fixes
HardMax71 1017815
further fixes
HardMax71 b011e5e
further fixes
HardMax71 4a00f3c
further fixes
HardMax71 e2153bf
urllib 2.6.2 -> 2.6.3
HardMax71 00e2f42
more tests
HardMax71 d1da7ed
mypy
HardMax71 d2bde04
invalid yamls
HardMax71 78498f6
fixes
HardMax71 5f5e025
fixes
HardMax71 229e473
fixes
HardMax71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,21 +5,24 @@ on: | |
| branches: [main, dev] | ||
| paths: | ||
| - 'backend/**' | ||
| - 'docker-compose.yaml' | ||
| - 'docker-bake.hcl' | ||
| - '.github/workflows/backend-ci.yml' | ||
| - 'docker-compose.ci.yaml' | ||
| pull_request: | ||
| branches: [main, dev] | ||
| paths: | ||
| - 'backend/**' | ||
| - 'docker-compose.yaml' | ||
| - 'docker-bake.hcl' | ||
| - '.github/workflows/backend-ci.yml' | ||
| - 'docker-compose.ci.yaml' | ||
| workflow_dispatch: | ||
|
|
||
| # Pin image versions for cache key consistency | ||
| env: | ||
| MONGO_IMAGE: mongo:8.0 | ||
| REDIS_IMAGE: redis:7-alpine | ||
| KAFKA_IMAGE: apache/kafka:3.9.0 | ||
| ZOOKEEPER_IMAGE: confluentinc/cp-zookeeper:7.5.0 | ||
| KAFKA_IMAGE: confluentinc/cp-kafka:7.5.0 | ||
| SCHEMA_REGISTRY_IMAGE: confluentinc/cp-schema-registry:7.5.0 | ||
|
|
||
| jobs: | ||
|
|
@@ -71,7 +74,7 @@ jobs: | |
| - name: Cache and load Docker images | ||
| uses: ./.github/actions/docker-cache | ||
| with: | ||
| images: ${{ env.MONGO_IMAGE }} ${{ env.REDIS_IMAGE }} ${{ env.KAFKA_IMAGE }} ${{ env.SCHEMA_REGISTRY_IMAGE }} | ||
| images: ${{ env.MONGO_IMAGE }} ${{ env.REDIS_IMAGE }} ${{ env.ZOOKEEPER_IMAGE }} ${{ env.KAFKA_IMAGE }} ${{ env.SCHEMA_REGISTRY_IMAGE }} | ||
|
|
||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v7 | ||
|
|
@@ -86,9 +89,13 @@ jobs: | |
| uv sync --frozen | ||
|
|
||
| - name: Start infrastructure services | ||
| env: | ||
| KAFKA_HEAP_OPTS: "-Xms256M -Xmx512M" | ||
| run: | | ||
| docker compose -f docker-compose.ci.yaml up -d --wait --wait-timeout 120 | ||
| docker compose -f docker-compose.ci.yaml ps | ||
| # Start only infra services (no workers, no build) | ||
| docker compose up -d --wait --wait-timeout 180 \ | ||
| mongo redis zookeeper-certgen zookeeper kafka schema-registry | ||
| docker compose ps | ||
|
|
||
| - name: Create Kafka topics | ||
| timeout-minutes: 2 | ||
|
|
@@ -134,15 +141,15 @@ jobs: | |
| if: failure() | ||
| run: | | ||
| mkdir -p logs | ||
| docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log 2>&1 | ||
| docker compose -f docker-compose.ci.yaml logs kafka > logs/kafka.log 2>&1 | ||
| docker compose -f docker-compose.ci.yaml logs schema-registry > logs/schema-registry.log 2>&1 | ||
| docker compose logs > logs/docker-compose.log 2>&1 | ||
| docker compose logs kafka > logs/kafka.log 2>&1 | ||
| docker compose logs schema-registry > logs/schema-registry.log 2>&1 | ||
|
|
||
| - name: Upload logs | ||
| if: failure() | ||
| uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: backend-logs | ||
| name: integration-logs | ||
| path: logs/ | ||
|
|
||
| e2e: | ||
|
|
@@ -152,10 +159,31 @@ jobs: | |
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| # Cache third-party images (mongo, redis, kafka, etc.) | ||
| - name: Cache and load Docker images | ||
| uses: ./.github/actions/docker-cache | ||
| with: | ||
| images: ${{ env.MONGO_IMAGE }} ${{ env.REDIS_IMAGE }} ${{ env.KAFKA_IMAGE }} ${{ env.SCHEMA_REGISTRY_IMAGE }} | ||
| images: ${{ env.MONGO_IMAGE }} ${{ env.REDIS_IMAGE }} ${{ env.ZOOKEEPER_IMAGE }} ${{ env.KAFKA_IMAGE }} ${{ env.SCHEMA_REGISTRY_IMAGE }} | ||
|
|
||
| # Set up Docker Buildx for bake action (use latest for GHA cache v2 support) | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| with: | ||
| version: latest | ||
|
|
||
| # Build all backend images using bake with GitHub Actions cache | ||
| - name: Build images with cache | ||
| uses: docker/bake-action@v6 | ||
| with: | ||
| files: docker-bake.hcl | ||
| targets: backend-e2e | ||
| load: true | ||
| set: | | ||
| *.cache-from=type=gha | ||
| *.cache-to=type=gha,mode=max | ||
|
|
||
| - name: Prune Docker build cache | ||
| run: docker builder prune -af | ||
|
|
||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v7 | ||
|
|
@@ -169,29 +197,48 @@ jobs: | |
| uv python install 3.12 | ||
| uv sync --frozen | ||
|
|
||
| - name: Start infrastructure services | ||
| run: | | ||
| docker compose -f docker-compose.ci.yaml up -d --wait --wait-timeout 120 | ||
| docker compose -f docker-compose.ci.yaml ps | ||
|
|
||
| # Setup K3s before starting services (workers need kubeconfig) | ||
| - name: Setup Kubernetes (k3s) | ||
| run: | | ||
| curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik" sh - | ||
| curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik --tls-san host.docker.internal" sh - | ||
| mkdir -p /home/runner/.kube | ||
| sudo k3s kubectl config view --raw > /home/runner/.kube/config | ||
| sudo chmod 600 /home/runner/.kube/config | ||
| export KUBECONFIG=/home/runner/.kube/config | ||
| timeout 90 bash -c 'until sudo k3s kubectl cluster-info; do sleep 5; done' | ||
| kubectl create namespace integr8scode --dry-run=client -o yaml | kubectl apply -f - | ||
| # Create kubeconfig for containers: use kubectl config view which is more reliable | ||
| sudo k3s kubectl config view --raw | sed 's/127.0.0.1/host.docker.internal/g' > backend/kubeconfig.yaml | ||
| # Verify the kubeconfig is valid | ||
| echo "=== Verifying kubeconfig ===" | ||
| grep -q "current-context" backend/kubeconfig.yaml && echo "OK: current-context found" || (echo "ERROR: current-context missing"; cat backend/kubeconfig.yaml; exit 1) | ||
| grep -q "host.docker.internal" backend/kubeconfig.yaml && echo "OK: host.docker.internal found" || (echo "ERROR: host.docker.internal missing"; exit 1) | ||
|
|
||
| - name: Create Kafka topics | ||
| timeout-minutes: 2 | ||
| # Start all services (images already built by bake) | ||
| - name: Start services | ||
| env: | ||
| KAFKA_BOOTSTRAP_SERVERS: localhost:9092 | ||
| KAFKA_TOPIC_PREFIX: "ci.${{ github.run_id }}." | ||
| MONGO_ROOT_USER: root | ||
| MONGO_ROOT_PASSWORD: rootpassword | ||
| ENABLE_TRACING: "false" | ||
| KAFKA_HEAP_OPTS: "-Xms256M -Xmx512M" | ||
| run: | | ||
| cd backend | ||
| uv run python -m scripts.create_topics | ||
| # Start cert generation first (backend needs certs) | ||
| docker compose up -d --no-build shared-ca | ||
| docker compose up -d --no-build cert-generator | ||
|
|
||
| # Wait for certs to be generated | ||
| timeout 60 bash -c 'until [ -f backend/certs/server.key ]; do sleep 2; done' | ||
| echo "Certificates generated" | ||
|
|
||
| # Start infra | ||
| docker compose up -d --no-build --wait --wait-timeout 180 \ | ||
| mongo redis zookeeper-certgen zookeeper kafka schema-registry | ||
|
|
||
| # Start backend and workers (Docker Compose handles init job dependencies via service_completed_successfully) | ||
| docker compose up -d --no-build --wait --wait-timeout 180 \ | ||
| backend coordinator saga-orchestrator k8s-worker pod-monitor result-processor | ||
|
|
||
| docker compose ps | ||
|
|
||
| - name: Run E2E tests | ||
| timeout-minutes: 10 | ||
|
|
@@ -200,13 +247,18 @@ jobs: | |
| MONGO_ROOT_PASSWORD: rootpassword | ||
| MONGODB_URL: mongodb://root:[email protected]:27017/?authSource=admin | ||
| KAFKA_BOOTSTRAP_SERVERS: localhost:9092 | ||
| KAFKA_TOPIC_PREFIX: "ci.${{ github.run_id }}." | ||
| KAFKA_TOPIC_PREFIX: "" | ||
| SCHEMA_REGISTRY_URL: http://localhost:8081 | ||
| REDIS_HOST: localhost | ||
| REDIS_PORT: 6379 | ||
| SCHEMA_SUBJECT_PREFIX: "ci.${{ github.run_id }}." | ||
| SCHEMA_SUBJECT_PREFIX: "" | ||
| KUBECONFIG: /home/runner/.kube/config | ||
| K8S_NAMESPACE: integr8scode | ||
| # Tests connect to backend running in container (HTTPS) | ||
| BACKEND_URL: https://localhost:443 | ||
| # Trust self-signed certs | ||
| REQUESTS_CA_BUNDLE: "" | ||
| CURL_CA_BUNDLE: "" | ||
| run: | | ||
| cd backend | ||
| uv run pytest tests/e2e -v -rs \ | ||
|
|
@@ -228,13 +280,18 @@ jobs: | |
| if: failure() | ||
| run: | | ||
| mkdir -p logs | ||
| docker compose -f docker-compose.ci.yaml logs > logs/docker-compose.log 2>&1 | ||
| docker compose logs > logs/docker-compose.log 2>&1 | ||
| docker compose logs backend > logs/backend.log 2>&1 | ||
| docker compose logs saga-orchestrator > logs/saga-orchestrator.log 2>&1 | ||
| docker compose logs k8s-worker > logs/k8s-worker.log 2>&1 | ||
| docker compose logs pod-monitor > logs/pod-monitor.log 2>&1 | ||
| kubectl get events --sort-by='.metadata.creationTimestamp' -A > logs/k8s-events.log 2>&1 || true | ||
| kubectl describe pods -A > logs/k8s-describe-pods.log 2>&1 || true | ||
| kubectl logs -l app=executor -n integr8scode --tail=100 > logs/executor-pods.log 2>&1 || true | ||
|
|
||
| - name: Upload logs | ||
| if: failure() | ||
| uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: k8s-logs | ||
| name: e2e-logs | ||
| path: logs/ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.