Skip to content

Commit

Permalink
test: Fix artifact collection for bad log failures
Browse files Browse the repository at this point in the history
When a test fails because a bad log message is found [1], the per-test
artifacts are not collected and exposed in the Jenkins UI. This issue is
visible at [2] at the time of writing this.

We only collect per-test artifacts for failing tests, which we detect
with ginkgo.CurrentGinkgoTestDescription().Failed. Unfortunately, this
variable is not updated when the test fails in a JustAfterEach block.
That's the case for the bad log messages, which are almost always
checked from a JustAfterEach block.

This commit fixes that issue by using the dedicated function TestFailed
instead of ginkgo.CurrentGinkgoTestDescription().Failed. At the time of
writing this, the result can be seen at [3].

This issue was discovered before in da25f94 ("k8sT: Clean up services
in JustAfterEach"), but the fix was not extended to the existing code
at the time.

1 - https://github.com/cilium/cilium/blob/v1.10.0/test/helpers/cons.go#L291
2 - https://jenkins.cilium.io/job/Cilium-PR-Runtime-4.9/4917/testReport/junit/(root)/Suite-runtime/RuntimeFQDNPolicies_toFQDNs_populates_toCIDRSet__data_from_proxy__L3_dependent_L7_HTTP_with_toFQDN_updates_proxy_policy/
3 - https://jenkins.cilium.io/job/Cilium-PR-K8s-1.20-kernel-4.19/637/testReport/junit/Suite-k8s-1/20/K8sServicesTest_Checks_service_across_nodes_Supports_IPv4_fragments/
Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
pchaigno authored and aanm committed Jun 11, 2021
1 parent b08f700 commit 740cecb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ var _ = AfterEach(func() {
}

// This piece of code is to enable zip attachments on Junit Output.
if ginkgo.CurrentGinkgoTestDescription().Failed && helpers.IsRunningOnJenkins() {
if TestFailed() && helpers.IsRunningOnJenkins() {
// ReportDirectory is already created. No check the error
path, _ := helpers.CreateReportDirectory()
zipFileName := fmt.Sprintf("%s_%s.zip", helpers.MakeUID(), GetTestName())
Expand All @@ -331,7 +331,7 @@ var _ = AfterEach(func() {
GinkgoPrint("[[ATTACHMENT|%s]]", zipFileName)
}

if !ginkgo.CurrentGinkgoTestDescription().Failed && helpers.IsRunningOnJenkins() {
if !TestFailed() && helpers.IsRunningOnJenkins() {
// If the test success delete the monitor.log filename to not store all
// the data in Jenkins
testPath, err := helpers.CreateReportDirectory()
Expand Down

0 comments on commit 740cecb

Please sign in to comment.