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