Skip to content

Commit b1e21a3

Browse files
Fix pdp-tester CI job for K8s-based refactor (PER-13630) (#307)
* Fix pdp-tester CI job for K8s-based refactor The pdp-tester was refactored from Docker-based to Kubernetes-based (permitio/pdp-tester#80). The old CI used Docker directly to run PDP containers, but the new code requires a Kubernetes cluster. Changes: - Add k3d cluster setup (same approach as pdp-tester's own CI) - Import both PDP image and pdp-tester image into k3d - Deploy via Helm chart in job mode with tag 'next' (the PR's PDP build) - Wait for Job completion and check test results from logs - Teardown k3d cluster on completion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix: tag PDP image as 'latest' for k3d so pdp-tester discovers it The pdp-tester discovers PDP tags via Docker Hub. The 'next' tag only exists locally, so tag discovery fails. Fix: tag the PDP image as 'latest' before importing into k3d, which matches pdp-tester's default includeTags config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Use pdp.localTags for local PDP image (bypass Docker Hub discovery) Use LOCAL_TAGS=["next"] to tell pdp-tester to use the locally built PDP image without querying Docker Hub for tag discovery. Clear includeTags to avoid pulling anything from Docker Hub. Requires permitio/pdp-tester to have LOCAL_TAGS support in the Helm chart (permitio/pdp-tester PR pending). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Temporarily set skipGenerate=false to populate new Permit environment Will revert to skipGenerate=true after first successful run. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Revert skipGenerate back to true (environment now populated) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix: clear includeTags properly to avoid Docker Hub timeout --set 'pdp.includeTags={}' rendered as [""] (non-empty list), causing Docker Hub tag discovery to run and timeout. Use --set 'pdp.includeTags=' which makes the value falsy, skipping INCLUDE_TAGS env var entirely. Only LOCAL_TAGS=["next"] is used. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 74451bd commit b1e21a3

1 file changed

Lines changed: 65 additions & 27 deletions

File tree

.github/workflows/tests.yml

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,43 +104,81 @@ jobs:
104104
token: ${{ secrets.CLONE_REPO_TOKEN }}
105105
path: './pdp-tester'
106106

107-
# Setup Python environment
108-
- name: Setup Python
109-
uses: actions/setup-python@v5
107+
# Start k3d cluster for Kubernetes-based pdp-tester
108+
- name: Start k3d cluster
109+
uses: AbsaOSS/k3d-action@v2.4.0
110110
with:
111-
python-version: "3.12"
111+
cluster-name: pdp-tester
112+
args: --k3s-arg "--disable=traefik@server:0"
113+
114+
# Import PDP image into k3d with 'next' tag (locally built)
115+
- name: Import PDP image into k3d
116+
run: k3d image import permitio/pdp-v2:next -c pdp-tester
112117

113-
# Install dependencies for pdp-tester
114-
- name: Install pdp-tester dependencies
118+
# Build pdp-tester image and import into k3d
119+
- name: Build and import pdp-tester image
115120
working-directory: ./pdp-tester
116121
run: |
117-
pip install -r requirements.txt
122+
docker build -t pdp-tester:ci .
123+
k3d image import pdp-tester:ci -c pdp-tester
118124
119-
# Run pdp-tester
120-
- name: Run pdp-tester
121-
working-directory: ./pdp-tester
125+
# Create namespace and secrets
126+
- name: Create secrets
122127
env:
123-
TOKEN: ${{ secrets.PDP_TESTER_API_KEY }}
124-
LOCAL_TAGS: '["next"]'
125-
INCLUDE_TAGS: '[]'
126-
AUTO_REMOVE: "False"
127-
SKIP_GENERATE: "True"
128-
ENABLE_APM: "False"
128+
PERMIT_TOKEN: ${{ secrets.PDP_TESTER_API_KEY }}
129+
run: |
130+
kubectl create namespace pdp-tester || true
131+
kubectl create secret generic pdp-tester-credentials \
132+
-n pdp-tester \
133+
--from-literal=token="${PERMIT_TOKEN}" \
134+
--dry-run=client -o yaml | kubectl apply -f -
135+
136+
# Deploy pdp-tester via Helm with the "next" PDP image
137+
- name: Deploy pdp-tester via Helm
138+
working-directory: ./pdp-tester
139+
run: |
140+
helm install pdp-tester ./deploy/helm/pdp-tester \
141+
--set mode=job \
142+
--set permit.existingSecret=pdp-tester-credentials \
143+
--set permit.apiUrl=https://permitio.api.stg.permit.io \
144+
--set image.repository=pdp-tester \
145+
--set image.tag=ci \
146+
--set image.pullPolicy=Never \
147+
--set pdp.image=permitio/pdp-v2 \
148+
--set 'pdp.localTags[0]=next' \
149+
--set 'pdp.includeTags=' \
150+
--set tests.skipGenerate=true \
151+
--set tests.startTimeout=180 \
152+
--set namespace.create=false \
153+
--set logJson=false
154+
155+
- name: Wait for Job completion
129156
run: |
130-
python -m pdp_tester.main
157+
kubectl wait --for=condition=complete job/pdp-tester \
158+
-n pdp-tester --timeout=600s
131159
132-
- name: Print Docker container logs
160+
- name: Check test results
161+
run: |
162+
LOGS=$(kubectl logs job/pdp-tester -n pdp-tester)
163+
echo "$LOGS" | tail -30
164+
if echo "$LOGS" | grep -q "test cases failed"; then
165+
echo "::error::Some test cases failed!"
166+
exit 1
167+
fi
168+
169+
- name: Print tester logs
133170
if: always()
134171
run: |
135-
echo "Fetching logs for all Docker containers..."
136-
for container in $(docker ps -aq); do
137-
echo "========================================"
138-
echo "Logs for container: $container"
139-
echo "----------------------------------------"
140-
docker logs "$container" || true
141-
echo "========================================"
142-
echo ""
143-
done
172+
echo "=== PDP Tester logs ==="
173+
kubectl logs job/pdp-tester -n pdp-tester --tail=200 || true
174+
echo ""
175+
echo "=== PDP Pod logs ==="
176+
kubectl logs -l pdp-tester.permit.io/managed-by=pdp-tester \
177+
-n pdp-tester --tail=50 || true
178+
179+
- name: Teardown k3d cluster
180+
if: always()
181+
run: k3d cluster delete pdp-tester || true
144182

145183
docker-scout:
146184
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)