From 2696e35be3d09c9d9d1dcab2366781d517e0c293 Mon Sep 17 00:00:00 2001 From: gmarek Date: Wed, 11 May 2016 16:53:30 +0200 Subject: [PATCH] Add a flag to disable dumpig logs after e2e test failure --- hack/verify-flags/known-flags.txt | 1 + test/e2e/framework/framework.go | 2 +- test/e2e/framework/test_context.go | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hack/verify-flags/known-flags.txt b/hack/verify-flags/known-flags.txt index 27e26f73aca..c1de27d9440 100644 --- a/hack/verify-flags/known-flags.txt +++ b/hack/verify-flags/known-flags.txt @@ -95,6 +95,7 @@ dockercfg-path driver-port drop-embedded-fields dry-run +dump-logs-on-failure duration-sec e2e-output-dir e2e-verify-service-account diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index d855c753639..e5d9c1e0854 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -204,7 +204,7 @@ func (f *Framework) AfterEach() { }() // Print events if the test failed. - if CurrentGinkgoTestDescription().Failed { + if CurrentGinkgoTestDescription().Failed && TestContext.DumpLogsOnFailure { DumpAllNamespaceInfo(f.Client, f.Namespace.Name) } diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index dfbd729be55..ab0c755c89b 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -58,6 +58,8 @@ type TestContextType struct { // It accepts namespace base name, which will be prepended with e2e prefix, kube client // and labels to be applied to a namespace. CreateTestingNS CreateTestingNSFn + // If set to true test will dump data about the namespace in which test was running. + DumpLogsOnFailure bool } type CloudConfig struct { @@ -125,4 +127,5 @@ func RegisterFlags() { flag.BoolVar(&TestContext.GatherLogsSizes, "gather-logs-sizes", false, "If set to true framework will be monitoring logs sizes on all machines running e2e tests.") flag.BoolVar(&TestContext.GatherMetricsAfterTest, "gather-metrics-at-teardown", false, "If set to true framwork will gather metrics from all components after each test.") flag.StringVar(&TestContext.OutputPrintType, "output-print-type", "hr", "Comma separated list: 'hr' for human readable summaries 'json' for JSON ones.") + flag.BoolVar(&TestContext.DumpLogsOnFailure, "dump-logs-on-failure", true, "If set to true test will dump data about the namespace in which test was running.") }