Add an option to not delete a namespace after e2e test

This commit is contained in:
gmarek 2015-10-26 14:25:08 +01:00
parent 2d29d266e7
commit 0150d87a73
4 changed files with 14 additions and 7 deletions

View File

@ -59,6 +59,7 @@ cpu-percent
default-container-cpu-limit
default-container-mem-limit
delay-shutdown
delete-namespace
deleting-pods-burst
deleting-pods-qps
deployment-label-key

View File

@ -82,6 +82,7 @@ func init() {
flag.StringVar(&testContext.UpgradeTarget, "upgrade-target", "ci/latest", "Version to upgrade to (e.g. 'release/stable', 'release/latest', 'ci/latest', '0.19.1', '0.19.1-669-gabac8c8') if doing an upgrade test.")
flag.StringVar(&testContext.PrometheusPushGateway, "prom-push-gateway", "", "The URL to prometheus gateway, so that metrics can be pushed during e2es and scraped by prometheus. Typically something like 127.0.0.1:9091.")
flag.BoolVar(&testContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
flag.BoolVar(&testContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
}
func TestE2E(t *testing.T) {

View File

@ -100,6 +100,7 @@ func (f *Framework) afterEach() {
Failf("All nodes should be ready after test, %v", err)
}
if testContext.DeleteNamespace {
By(fmt.Sprintf("Destroying namespace %q for this suite.", f.Namespace.Name))
timeout := 5 * time.Minute
@ -109,6 +110,9 @@ func (f *Framework) afterEach() {
if err := deleteNS(f.Client, f.Namespace.Name, timeout); err != nil {
Failf("Couldn't delete ns %q: %s", f.Namespace.Name, err)
}
} else {
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
}
// Paranoia-- prevent reuse!
f.Namespace = nil
f.Client = nil

View File

@ -120,6 +120,7 @@ type TestContextType struct {
UpgradeTarget string
PrometheusPushGateway string
VerifyServiceAccount bool
DeleteNamespace bool
}
var testContext TestContextType