Skip to content

Commit 42bc2a0

Browse files
Merge pull request #101 from cybozu-go/print-logs-on-e2e-test-failure
print controller logs on e2e test failure
2 parents 9ab13e3 + d1310ef commit 42bc2a0

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

test/e2e/Makefile

+22-4
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,31 @@ do_test: $(GINKGO)
249249
PATH=${PATH} \
250250
E2ETEST=1 \
251251
KUBECTL=$(KUBECTL) \
252-
$(GINKGO) --fail-fast -v $(GINKGO_FLAGS) singlek8s
252+
$(GINKGO) --fail-fast -v $(GINKGO_FLAGS) singlek8s; \
253+
if [ "$$?" -ne 0 ]; then \
254+
echo "Controller logs for $(CEPH_CLUSTER1_NAMESPACE) namespace:"; \
255+
$(KUBECTL) logs --tail 100 -n $(CEPH_CLUSTER1_NAMESPACE) -l app.kubernetes.io/name=mantle -c mantle; \
256+
echo ""; \
257+
echo "Controller logs for $(CEPH_CLUSTER2_NAMESPACE) namespace:"; \
258+
$(KUBECTL) logs --tail 100 -n $(CEPH_CLUSTER2_NAMESPACE) -l app.kubernetes.io/name=mantle -c mantle; \
259+
# Explicitly fail the test to mark the CI job as failed. \
260+
exit 1; \
261+
fi
253262

254263
.PHONY: do-test-multik8s
255264
do-test-multik8s: $(GINKGO)
265+
export KUBECTL_PRIMARY="$(MINIKUBE) -p $(MINIKUBE_PROFILE_PRIMARY) kubectl -- "; \
266+
export KUBECTL_SECONDARY="$(MINIKUBE) -p $(MINIKUBE_PROFILE_SECONDARY) kubectl -- "; \
256267
env \
257268
PATH=${PATH} \
258269
E2ETEST=1 \
259-
KUBECTL_PRIMARY="$(MINIKUBE) -p $(MINIKUBE_PROFILE_PRIMARY) kubectl -- " \
260-
KUBECTL_SECONDARY="$(MINIKUBE) -p $(MINIKUBE_PROFILE_SECONDARY) kubectl -- " \
261-
$(GINKGO) --fail-fast -v $(GINKGO_FLAGS) $(addprefix multik8s/, $(TEST_MULTIK8S_PACKAGES))
270+
$(GINKGO) --fail-fast -v $(GINKGO_FLAGS) $(addprefix multik8s/, $(TEST_MULTIK8S_PACKAGES)); \
271+
if [ "$$?" -ne 0 ]; then \
272+
echo "Controller logs for $(MINIKUBE_PROFILE_PRIMARY):"; \
273+
$${KUBECTL_PRIMARY} logs --tail 100 -n $(CEPH_CLUSTER1_NAMESPACE) -l app.kubernetes.io/name=mantle -c mantle; \
274+
echo ""; \
275+
echo "Controller logs for $(MINIKUBE_PROFILE_SECONDARY):"; \
276+
$${KUBECTL_SECONDARY} logs --tail 100 -n $(CEPH_CLUSTER1_NAMESPACE) -l app.kubernetes.io/name=mantle -c mantle; \
277+
# Explicitly fail the test to mark the CI job as failed. \
278+
exit 1; \
279+
fi

test/e2e/multik8s/testutil/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ func WaitControllerToBeReady() {
423423
}).Should(Succeed())
424424

425425
Eventually(func() error {
426-
return CheckDeploymentReady(PrimaryK8sCluster, CephClusterNamespace, "mantle-controller")
426+
return CheckDeploymentReady(SecondaryK8sCluster, CephClusterNamespace, "mantle-controller")
427427
}).Should(Succeed())
428428
})
429429
}

0 commit comments

Comments
 (0)