Skip to content

Commit 4a4e9da

Browse files
authored
Merge pull request #79 from datum-cloud/feat-test-environment
feat: add local dev environment and e2e test infrastructure
2 parents 52aebfc + 363ae26 commit 4a4e9da

File tree

73 files changed

+3818
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3818
-449
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build and Push Docker Image
22

33
on:
44
push:
5+
branches:
6+
- main
57
paths-ignore:
68
- "README.md"
79

.github/workflows/lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: Lint
22

33
on:
44
push:
5-
pull_request:
5+
branches:
6+
- main
7+
pull_request: {}
68

79
jobs:
810
lint:

.github/workflows/test-e2e.yml

Lines changed: 183 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,203 @@
1-
name: E2E Tests
1+
name: End-to-End Tests
22

33
on:
44
push:
5-
pull_request:
5+
branches:
6+
- main
7+
pull_request: {}
8+
workflow_dispatch:
9+
inputs:
10+
test_suite:
11+
description: 'Test suite to run (e.g., machineaccount, userdeactivation or empty for all)'
12+
required: false
13+
default: ''
14+
type: string
15+
16+
env:
17+
# Enable experimental remote taskfiles feature
18+
TASK_X_REMOTE_TASKFILES: 1
19+
# Test infrastructure configuration
20+
TEST_INFRA_CLUSTER_NAME: test-infra
21+
IMAGE_NAME: ghcr.io/datum-cloud/auth-provider-zitadel
22+
IMAGE_TAG: dev
623

724
jobs:
825
test-e2e:
9-
name: Run on Ubuntu
1026
runs-on: ubuntu-latest
27+
timeout-minutes: 60
28+
1129
steps:
12-
- name: Clone the code
13-
uses: actions/checkout@v4
30+
- name: Checkout code
31+
uses: actions/checkout@v6
1432

15-
- name: Setup Go
16-
uses: actions/setup-go@v5
33+
- name: Set up Go
34+
uses: actions/setup-go@v6
1735
with:
18-
go-version-file: go.mod
36+
go-version-file: 'go.mod'
37+
cache: true
1938

20-
- name: Install docker-compose
39+
- name: Install Task CLI
2140
run: |
22-
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
23-
sudo chmod +x /usr/local/bin/docker-compose
24-
docker-compose --version
41+
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
2542
26-
- name: Install the latest version of kind
43+
- name: Verify Task installation
2744
run: |
28-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
29-
chmod +x ./kind
30-
sudo mv ./kind /usr/local/bin/kind
45+
task --version
46+
echo "Available tasks:"
47+
task --list
3148
32-
- name: Verify kind installation
33-
run: kind version
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v4
51+
with:
52+
buildkitd-config-inline: |
53+
[worker.oci]
54+
max-parallelism = 4
3455
35-
- name: Create kind cluster
36-
run: make kind-create
56+
- name: Install kubectl
57+
uses: azure/setup-kubectl@v4
58+
with:
59+
version: 'v1.30.0'
3760

38-
- name: Running Test e2e
61+
- name: Install KinD
62+
uses: helm/kind-action@v1
63+
with:
64+
install_only: true
65+
version: v0.24.0
66+
67+
- name: Verify prerequisites
68+
run: |
69+
echo "=== Checking prerequisites ==="
70+
docker version
71+
kubectl version --client
72+
kind version
73+
echo "Go version: $(go version)"
74+
75+
- name: Set up test environment
3976
run: |
40-
go mod tidy
41-
make test-e2e
77+
echo "=== Setting up test environment ==="
78+
# This task handles cluster creation, image build/load, and deployment
79+
task ci:setup
4280
43-
- name: Cleanup kind cluster
81+
- name: Verify components
82+
run: |
83+
echo "=== Verifying Auth Provider Zitadel components ==="
84+
85+
APP_NAMESPACE="auth-provider-zitadel-system"
86+
ZITADEL_NAMESPACE="zitadel-system"
87+
88+
# Verify components are running
89+
echo "Checking Auth Provider Zitadel components:"
90+
task test-infra:kubectl -- get pods -n $APP_NAMESPACE
91+
92+
# Wait for components to be ready
93+
echo "⏳ Waiting for controller manager to be ready..."
94+
task test-infra:kubectl -- wait --for=condition=Available deployment/controller-manager -n $APP_NAMESPACE --timeout=1000s
95+
96+
echo "⏳ Waiting for API server to be ready..."
97+
task test-infra:kubectl -- wait --for=condition=Available deployment/apiserver -n $APP_NAMESPACE --timeout=1000s
98+
99+
echo "⏳ Waiting for AuthN webhook to be ready..."
100+
task test-infra:kubectl -- wait --for=condition=Available deployment/authn-webhook -n $APP_NAMESPACE --timeout=1000s
101+
102+
echo "⏳ Checking Zitadel status..."
103+
task test-infra:kubectl -- wait --for=condition=Available deployment/zitadel -n $ZITADEL_NAMESPACE --timeout=1000s
104+
105+
# Verify Aggregated API Availability (CA Injection)
106+
echo "⏳ Verifying Aggregated API Availability..."
107+
for i in {1..30}; do
108+
CA_LEN=$(task test-infra:kubectl -- get apiservice v1alpha1.identity.miloapis.com -o jsonpath='{len(.spec.caBundle)}' 2>/dev/null || echo "0")
109+
if [ "$CA_LEN" -gt "0" ]; then
110+
echo "✅ CA Bundle injected into APIService."
111+
break
112+
fi
113+
echo "⏳ Waiting for CA injection into identity APIService (attempt $i/30)..."
114+
sleep 2
115+
done
116+
117+
# Verify Discovery works
118+
echo "Verifying API Discovery..."
119+
task test-infra:kubectl -- get apiservice v1alpha1.identity.miloapis.com
120+
121+
echo "✓ Components verification complete"
122+
123+
- name: Run end-to-end tests
124+
run: |
125+
echo "=== Running end-to-end tests ==="
126+
127+
# Determine which tests to run based on input
128+
if [ -n "${{ github.event.inputs.test_suite }}" ]; then
129+
echo "Running specified test suite: ${{ github.event.inputs.test_suite }}"
130+
task test:end-to-end -- ${{ github.event.inputs.test_suite }}
131+
else
132+
echo "Running all end-to-end tests..."
133+
task test:end-to-end
134+
fi
135+
136+
- name: Collect debug information on failure
137+
if: failure()
138+
run: |
139+
echo "=== Collecting debug information ==="
140+
APP_NAMESPACE="auth-provider-zitadel-system"
141+
ZITADEL_NAMESPACE="zitadel-system"
142+
143+
# Cluster status
144+
echo "=== Infrastructure Cluster Status ==="
145+
task test-infra:kubectl -- get pods -A || true
146+
task test-infra:kubectl -- get nodes -o wide || true
147+
148+
# App status and logs
149+
echo "=== Auth Provider Zitadel Status ==="
150+
task test-infra:kubectl -- describe pods -n $APP_NAMESPACE || true
151+
152+
echo "--- Controller Manager Logs ---"
153+
task test-infra:kubectl -- logs -n $APP_NAMESPACE -l app.kubernetes.io/component=controller-manager --tail=500 || true
154+
155+
echo "--- API Server Logs ---"
156+
task test-infra:kubectl -- logs -n $APP_NAMESPACE -l app.kubernetes.io/component=apiserver --tail=500 || true
157+
158+
echo "--- AuthN Webhook Logs ---"
159+
task test-infra:kubectl -- logs -n $APP_NAMESPACE -l app.kubernetes.io/component=authn-webhook --tail=500 || true
160+
161+
# Zitadel status and logs
162+
echo "=== Zitadel Status ==="
163+
task test-infra:kubectl -- describe pods -n $ZITADEL_NAMESPACE || true
164+
165+
echo "--- Zitadel Logs ---"
166+
task test-infra:kubectl -- logs -n $ZITADEL_NAMESPACE -l app.kubernetes.io/name=zitadel --tail=500 || true
167+
168+
# PostgreSQL status
169+
echo "--- PostgreSQL Logs ---"
170+
task test-infra:kubectl -- logs -n $ZITADEL_NAMESPACE -l app=zitadel-postgresql --tail=100 || true
171+
172+
# Docker container status
173+
echo "=== Docker Containers ==="
174+
docker ps -a || true
175+
176+
# KinD cluster info
177+
echo "=== KinD cluster info ==="
178+
kind get clusters || true
179+
kind export logs /tmp/kind-logs --name $TEST_INFRA_CLUSTER_NAME || true
180+
181+
- name: Upload debug artifacts
182+
if: failure()
183+
uses: actions/upload-artifact@v7
184+
with:
185+
name: debug-logs
186+
path: |
187+
/tmp/kind-logs/
188+
if-no-files-found: ignore
189+
190+
- name: Cleanup test infrastructure
44191
if: always()
45-
run: make kind-delete
192+
run: |
193+
echo "=== Cleaning up test infrastructure ==="
194+
195+
# Clean up test infrastructure cluster
196+
task test-infra:cluster-down || true
197+
198+
# Verify cleanup
199+
echo "Remaining KinD clusters:"
200+
kind get clusters || true
201+
202+
echo "Remaining Docker containers:"
203+
docker ps -a --filter "name=$TEST_INFRA_CLUSTER_NAME" || true

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: Tests
22

33
on:
44
push:
5-
pull_request:
5+
branches:
6+
- main
7+
pull_request: {}
68

79
jobs:
810
test:

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ go.work
2929
zitadel-admin-sa.json
3030
controller.log
3131

32-
certs/
32+
certs/
33+
34+
.task/
35+
.claude/

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ help: ## Display this help.
5252

5353
.PHONY: manifests
5454
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
55-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
55+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases output:rbac:artifacts:config=config/rbac
56+
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="./..." output:rbac:artifacts:config=config/base/rbac
5657

5758
.PHONY: generate
5859
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

0 commit comments

Comments
 (0)