9898 make dev-deploy MANAGER_IMG=test/tf-controller RUNNER_IMG=test/tf-runner TAG=$VERSION || true
9999 make dev-deploy MANAGER_IMG=test/tf-controller RUNNER_IMG=test/tf-runner TAG=$VERSION
100100
101+ # All of these old cert would be cleaned up by GC at the start of the test
102+ kubectl -n tf-system apply -f config/testdata/gc-old-certs/test.yaml
103+
101104 # Increase the concurrency of the controller to speed up tests
105+ # --cert-rotation-check-frequency=6m0s, then GC will run every 1 minute
102106 kubectl patch deployment \
103107 tf-controller \
104108 --namespace tf-system \
@@ -109,6 +113,7 @@ jobs:
109113 "--log-encoding=json",
110114 "--enable-leader-election",
111115 "--concurrent=10",
116+ "--cert-rotation-check-frequency=6m0s",
112117 ]}]'
113118
114119 kubectl -n tf-system rollout status deploy/source-controller --timeout=1m
@@ -192,11 +197,17 @@ jobs:
192197
193198 - name : Set up chaos testing environment
194199 run : |
195- # TODO we'll test a race condition with replica=3 later
196- kubectl -n tf-system scale --replicas=1 deploy/tf-controller
200+ kubectl -n tf-system scale --replicas=0 deploy/tf-controller
201+ sleep 3
197202
198203 kubectl -n chaos-testing apply -f ./config/testdata/chaos
199204 kubectl -n chaos-testing apply -f ./config/testdata/source
205+
206+ # Set up namespace-scoped old certs for GC
207+ kubectl -n chaos-testing apply -f ./config/testdata/gc-old-certs/test.yaml
208+
209+ kubectl -n tf-system scale --replicas=1 deploy/tf-controller
210+
200211 sleep 10
201212 - name : Randomly delete runner pods
202213 run : |
@@ -212,6 +223,34 @@ jobs:
212223 kubectl -n chaos-testing wait terraform/helloworld-chaos03 --for=condition=ready --timeout=30m
213224 kubectl -n chaos-testing wait terraform/helloworld-chaos04 --for=condition=ready --timeout=30m
214225 kubectl -n chaos-testing wait terraform/helloworld-chaos05 --for=condition=ready --timeout=30m
226+ - name : Check that all old certs were GCed
227+ run : |
228+ echo "wait 120 seconds for GC to happen"
229+ sleep 120
230+
231+ (kubectl get secret terraform-runner.tls-0 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
232+ (kubectl get secret terraform-runner.tls-1 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
233+ (kubectl get secret terraform-runner.tls-2 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
234+ (kubectl get secret terraform-runner.tls-3 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
235+ (kubectl get secret terraform-runner.tls-4 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
236+ (kubectl get secret terraform-runner.tls-5 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
237+ (kubectl get secret terraform-runner.tls-6 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
238+ (kubectl get secret terraform-runner.tls-7 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
239+ (kubectl get secret terraform-runner.tls-8 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
240+ (kubectl get secret terraform-runner.tls-9 -n chaos-testing >/dev/null 2>&1 && exit 1 || exit 0)
241+
242+ (kubectl get secret terraform-runner.tls-0 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
243+ (kubectl get secret terraform-runner.tls-1 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
244+ (kubectl get secret terraform-runner.tls-2 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
245+ (kubectl get secret terraform-runner.tls-3 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
246+ (kubectl get secret terraform-runner.tls-4 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
247+ (kubectl get secret terraform-runner.tls-5 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
248+ (kubectl get secret terraform-runner.tls-6 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
249+ (kubectl get secret terraform-runner.tls-7 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
250+ (kubectl get secret terraform-runner.tls-8 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
251+ (kubectl get secret terraform-runner.tls-9 -n tf-system >/dev/null 2>&1 && exit 1 || exit 0)
252+
253+ echo "All tests are true, all of the old secrets were GCed."
215254 - name : Logs
216255 run : |
217256 kubectl -n tf-system logs deploy/source-controller
0 commit comments