From e9ecdf3534e97751e6630ce4537b5907fa414031 Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 25 Feb 2023 00:40:15 -0800 Subject: [PATCH] test: Emit ginkgo log for each node e2e When running multiple node e2e with multiple machine images, the tests are run separately for each node. The final build log has all of the results for each of the hosts combined together which make debugging the log difficult. To make it easier, emit a log for each host that was run. This log will be written to the results directory and uploaded as an artifact in prow jobs. Signed-off-by: David Porter --- test/e2e_node/remote/node_e2e.go | 9 ++++++--- test/e2e_node/runner/remote/run_remote.go | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/e2e_node/remote/node_e2e.go b/test/e2e_node/remote/node_e2e.go index afbcd18af35..cf5efaee111 100644 --- a/test/e2e_node/remote/node_e2e.go +++ b/test/e2e_node/remote/node_e2e.go @@ -196,12 +196,15 @@ func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePr systemSpecFile = systemSpecName + ".yaml" } + outputGinkgoFile := filepath.Join(results, fmt.Sprintf("%s-ginkgo.log", host)) + // Run the tests klog.V(2).Infof("Starting tests on %q", host) cmd := getSSHCommand(" && ", fmt.Sprintf("cd %s", workspace), - fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --runtime-config=%s --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s", - timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, extraEnvs, runtimeConfig, host, results, junitFilePrefix, imageDesc, testArgs), + // Note, we need to have set -o pipefail here to ensure we return the appriorate exit code from ginkgo; not tee + fmt.Sprintf("set -o pipefail; timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --runtime-config=%s --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s 2>&1 | tee -i %s", + timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, extraEnvs, runtimeConfig, host, results, junitFilePrefix, imageDesc, testArgs, outputGinkgoFile), ) - return SSH(host, "sh", "-c", cmd) + return SSH(host, "/bin/bash", "-c", cmd) } diff --git a/test/e2e_node/runner/remote/run_remote.go b/test/e2e_node/runner/remote/run_remote.go index 5ce543b17f3..26199fb5b1b 100644 --- a/test/e2e_node/runner/remote/run_remote.go +++ b/test/e2e_node/runner/remote/run_remote.go @@ -289,9 +289,9 @@ func main() { fmt.Printf("%s\n", tr.output) if tr.err != nil { errCount++ - fmt.Printf("Failure Finished Test Suite on Host %s\n%v\n", host, tr.err) + fmt.Printf("Failure Finished Test Suite on Host %s. Refer to artifacts directory for ginkgo log for this host.\n%v\n", host, tr.err) } else { - fmt.Printf("Success Finished Test Suite on Host %s\n", host) + fmt.Printf("Success Finished Test Suite on Host %s. Refer to artifacts directory for ginkgo log for this host.\n", host) } exitOk = exitOk && tr.exitOk fmt.Printf("%s<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<%s\n", blue, noColour)