mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
add delete-namespace-on-failure flag
This commit is contained in:
parent
3933ddbc9a
commit
47ccd15b1d
@ -137,6 +137,9 @@ go run hack/e2e.go -v --test --test_args="--ginkgo.skip=Pods.*env"
|
|||||||
# Run tests in parallel, skip any that must be run serially
|
# Run tests in parallel, skip any that must be run serially
|
||||||
GINKGO_PARALLEL=y go run hack/e2e.go --v --test --test_args="--ginkgo.skip=\[Serial\]"
|
GINKGO_PARALLEL=y go run hack/e2e.go --v --test --test_args="--ginkgo.skip=\[Serial\]"
|
||||||
|
|
||||||
|
# Run tests in parallel, skip any that must be run serially and keep the test namespace if test failed
|
||||||
|
GINKGO_PARALLEL=y go run hack/e2e.go --v --test --test_args="--ginkgo.skip=\[Serial\] --delete-namespace-on-falure=false"
|
||||||
|
|
||||||
# Flags can be combined, and their actions will take place in this order:
|
# Flags can be combined, and their actions will take place in this order:
|
||||||
# --build, --up, --test, --down
|
# --build, --up, --test, --down
|
||||||
#
|
#
|
||||||
|
@ -118,6 +118,7 @@ delete-collection-workers
|
|||||||
delete-instances
|
delete-instances
|
||||||
delete-local-data
|
delete-local-data
|
||||||
delete-namespace
|
delete-namespace
|
||||||
|
delete-namespace-on-failure
|
||||||
deleting-pods-burst
|
deleting-pods-burst
|
||||||
deleting-pods-qps
|
deleting-pods-qps
|
||||||
deployment-controller-sync-period
|
deployment-controller-sync-period
|
||||||
|
@ -311,7 +311,10 @@ func (f *Framework) AfterEach() {
|
|||||||
// expectation failures preventing deleting the namespace.
|
// expectation failures preventing deleting the namespace.
|
||||||
defer func() {
|
defer func() {
|
||||||
nsDeletionErrors := map[string]error{}
|
nsDeletionErrors := map[string]error{}
|
||||||
if TestContext.DeleteNamespace {
|
// Whether to delete namespace is determined by 3 factors: delete-namespace flag, delete-namespace-on-failure flag and the test result
|
||||||
|
// if delete-namespace set to false, namespace will always be preserved.
|
||||||
|
// if delete-namespace is true and delete-namespace-on-failure is false, namespace will be preserved if test failed.
|
||||||
|
if TestContext.DeleteNamespace && (TestContext.DeleteNamespaceOnFailure || !CurrentGinkgoTestDescription().Failed) {
|
||||||
for _, ns := range f.namespacesToDelete {
|
for _, ns := range f.namespacesToDelete {
|
||||||
By(fmt.Sprintf("Destroying namespace %q for this suite.", ns.Name))
|
By(fmt.Sprintf("Destroying namespace %q for this suite.", ns.Name))
|
||||||
timeout := 5 * time.Minute
|
timeout := 5 * time.Minute
|
||||||
@ -332,7 +335,12 @@ func (f *Framework) AfterEach() {
|
|||||||
// Note: this will not cause any failure since we create a new namespace for each test in BeforeEach().
|
// Note: this will not cause any failure since we create a new namespace for each test in BeforeEach().
|
||||||
// f.deleteFederationNs()
|
// f.deleteFederationNs()
|
||||||
} else {
|
} else {
|
||||||
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
|
if TestContext.DeleteNamespace {
|
||||||
|
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
|
||||||
|
} else if TestContext.DeleteNamespaceOnFailure {
|
||||||
|
Logf("Found DeleteNamespaceOnFailure=false, skipping namespace deletion!")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paranoia-- prevent reuse!
|
// Paranoia-- prevent reuse!
|
||||||
|
@ -55,6 +55,7 @@ type TestContextType struct {
|
|||||||
NodeOSDistro string
|
NodeOSDistro string
|
||||||
VerifyServiceAccount bool
|
VerifyServiceAccount bool
|
||||||
DeleteNamespace bool
|
DeleteNamespace bool
|
||||||
|
DeleteNamespaceOnFailure bool
|
||||||
AllowedNotReadyNodes int
|
AllowedNotReadyNodes int
|
||||||
CleanStart bool
|
CleanStart bool
|
||||||
// If set to 'true' or 'all' framework will start a goroutine monitoring resource usage of system add-ons.
|
// If set to 'true' or 'all' framework will start a goroutine monitoring resource usage of system add-ons.
|
||||||
@ -148,6 +149,7 @@ func RegisterCommonFlags() {
|
|||||||
flag.StringVar(&TestContext.OutputPrintType, "output-print-type", "hr", "Comma separated list: 'hr' for human readable summaries 'json' for JSON ones.")
|
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.")
|
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.")
|
||||||
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.")
|
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.")
|
||||||
|
flag.BoolVar(&TestContext.DeleteNamespaceOnFailure, "delete-namespace-on-failure", true, "If true, framework will delete test namespace on failure. Used only during test debugging.")
|
||||||
flag.IntVar(&TestContext.AllowedNotReadyNodes, "allowed-not-ready-nodes", 0, "If non-zero, framework will allow for that many non-ready nodes when checking for all ready nodes.")
|
flag.IntVar(&TestContext.AllowedNotReadyNodes, "allowed-not-ready-nodes", 0, "If non-zero, framework will allow for that many non-ready nodes when checking for all ready nodes.")
|
||||||
flag.StringVar(&TestContext.Host, "host", "http://127.0.0.1:8080", "The host, or apiserver, to connect to")
|
flag.StringVar(&TestContext.Host, "host", "http://127.0.0.1:8080", "The host, or apiserver, to connect to")
|
||||||
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
|
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
|
||||||
|
Loading…
Reference in New Issue
Block a user