Skip to content

Commit fb38f06

Browse files
authored
Merge pull request #10 from SolidLabResearch/integration-tests
Integration tests
2 parents 7395a29 + 0cbf9de commit fb38f06

9 files changed

Lines changed: 1354 additions & 73 deletions

File tree

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: Integration Tests
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
jobs:
7+
integration-tests:
8+
name: Integration Tests
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Set up Go
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: '1.21'
17+
cache: true
18+
cache-dependency-path: integration-test/go.sum
19+
- name: Cache Go modules
20+
uses: actions/cache@v3
21+
with:
22+
path: |
23+
~/.cache/go-build
24+
~/go/pkg/mod
25+
key: ${{ runner.os }}-go-${{ hashFiles('integration-test/go.sum') }}
26+
restore-keys: |
27+
${{ runner.os }}-go-
28+
- name: Set up Docker
29+
uses: docker/setup-buildx-action@v3
30+
with:
31+
driver-opts: network=host
32+
- name: Cache Docker layers
33+
uses: actions/cache@v3
34+
with:
35+
path: /tmp/.buildx-cache
36+
key: ${{ runner.os }}-buildx-${{ github.sha }}
37+
restore-keys: |
38+
${{ runner.os }}-buildx-
39+
- name: Install Kind
40+
run: |
41+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
42+
chmod +x ./kind
43+
sudo mv ./kind /usr/local/bin/kind
44+
- name: Install kubectl
45+
run: |
46+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
47+
chmod +x kubectl
48+
sudo mv kubectl /usr/local/bin/
49+
- name: Install Helm
50+
run: |
51+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
52+
- name: Verify installations
53+
run: |
54+
docker version
55+
kind version
56+
kubectl version --client
57+
helm version
58+
- name: Build Docker images
59+
run: |
60+
export DOCKER_BUILDKIT=1
61+
export BUILDKIT_PROGRESS=plain
62+
make containers-build
63+
timeout-minutes: 30
64+
env:
65+
DOCKER_BUILDKIT: 1
66+
- name: Create Kind cluster
67+
run: |
68+
kind create cluster --name aggregator --config k8s/kind-config.yaml --wait 120s
69+
timeout-minutes: 10
70+
- name: Load images into Kind
71+
run: |
72+
echo "Loading images in parallel..."
73+
find containers -maxdepth 1 -mindepth 1 -type d | \
74+
xargs -I {} -P 4 sh -c '
75+
name=$(basename {})
76+
echo "📥 Loading $name..."
77+
if kind load docker-image "$name:latest" --name aggregator; then
78+
echo "✅ Loaded $name"
79+
else
80+
echo "❌ Failed to load $name"
81+
exit 1
82+
fi
83+
'
84+
timeout-minutes: 10
85+
- name: Generate key pair for UMA proxy
86+
run: |
87+
kubectl config use-context kind-aggregator
88+
kubectl wait --for=condition=Ready nodes --all --timeout=120s
89+
openssl genrsa -out uma-proxy.key 4096
90+
openssl req -x509 -new -nodes -key uma-proxy.key -sha256 -days 3650 -out uma-proxy.crt -subj "/CN=Aggregator MITM CA"
91+
kubectl delete secret uma-proxy-key-pair -n default --ignore-not-found
92+
kubectl create secret generic uma-proxy-key-pair --from-file=uma-proxy.crt=uma-proxy.crt --from-file=uma-proxy.key=uma-proxy.key -n default
93+
rm uma-proxy.crt uma-proxy.key
94+
- name: Deploy aggregator-cleaner
95+
run: |
96+
kubectl apply -f k8s/ops/ns.yaml
97+
kubectl apply -f k8s/ops/cleaner.yaml
98+
kubectl wait --namespace aggregator-ops --for=condition=available deployment/aggregator-cleaner --timeout=60s || true
99+
- name: Deploy Traefik
100+
run: |
101+
helm repo add traefik https://traefik.github.io/charts
102+
helm repo update
103+
helm upgrade --install aggregator-traefik traefik/traefik \
104+
--namespace aggregator-traefik \
105+
--create-namespace \
106+
--set ingressClass.enabled=true \
107+
--set ingressClass.name=aggregator-traefik \
108+
--set ports.web.hostPort=80 \
109+
--set ports.websecure.hostPort=443 \
110+
--set service.type=ClusterIP \
111+
--set providers.kubernetesCRD.allowCrossNamespace=true \
112+
--wait --timeout=3m
113+
kubectl rollout status deployment aggregator-traefik -n aggregator-traefik --timeout=180s
114+
- name: Deploy aggregator
115+
run: |
116+
kubectl apply -f k8s/app/ns.yaml
117+
kubectl apply -f k8s/app/config.yaml
118+
kubectl apply -f k8s/app/aggregator.yaml
119+
kubectl rollout status deployment aggregator-server -n aggregator-app --timeout=120s
120+
- name: Add /etc/hosts entry
121+
run: |
122+
echo "127.0.0.1 aggregator.local" | sudo tee -a /etc/hosts
123+
- name: Run integration tests
124+
run: |
125+
cd integration-test
126+
go test -v -timeout 30m ./...
127+
timeout-minutes: 35
128+
- name: Collect logs on failure
129+
if: failure()
130+
run: |
131+
echo "=== Cluster Info ==="
132+
kubectl cluster-info dump --output-directory=./cluster-logs --namespaces aggregator-app,aggregator-ops 2>&1 || true
133+
echo "=== Docker Containers ==="
134+
docker ps -a
135+
echo "=== Kind Logs ==="
136+
kind export logs ./kind-logs --name aggregator || true
137+
- name: Upload logs on failure
138+
if: failure()
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: test-logs
142+
path: |
143+
cluster-logs/
144+
kind-logs/
145+
retention-days: 7
146+
- name: Cleanup
147+
if: always()
148+
run: |
149+
kind delete cluster --name aggregator || true
150+
notify:
151+
name: Notify Results
152+
needs: integration-tests
153+
runs-on: ubuntu-latest
154+
if: always()
155+
steps:
156+
- name: Check test results
157+
run: |
158+
if [ "${{ needs.integration-tests.result }}" == "success" ]; then
159+
echo "✅ All integration tests passed!"
160+
else
161+
echo "❌ Integration tests failed"
162+
exit 1
163+
fi

0 commit comments

Comments
 (0)