Unverified Commit 2142bff9 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #62606 from smarterclayton/defer_delete

Automatic merge from submit-queue (batch tested with PRs 61962, 58972, 62509, 62606). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Allow a test suite reusing framework to register namespaces to delete If the suite bypasses CreateNamespace (because it wants to create more specialized namespaces) it has no way to register deletes. @liggitt this was something that came up in an older rebase and was missed (for things creating projects)
parents e9374411 565f97bf
...@@ -399,10 +399,7 @@ func (f *Framework) CreateNamespace(baseName string, labels map[string]string) ( ...@@ -399,10 +399,7 @@ func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (
ns, err := createTestingNS(baseName, f.ClientSet, labels) ns, err := createTestingNS(baseName, f.ClientSet, labels)
// check ns instead of err to see if it's nil as we may // check ns instead of err to see if it's nil as we may
// fail to create serviceAccount in it. // fail to create serviceAccount in it.
// In this case, we should not forget to delete the namespace. f.AddNamespacesToDelete(ns)
if ns != nil {
f.namespacesToDelete = append(f.namespacesToDelete, ns)
}
if err == nil && !f.SkipPrivilegedPSPBinding { if err == nil && !f.SkipPrivilegedPSPBinding {
CreatePrivilegedPSPBinding(f, ns.Name) CreatePrivilegedPSPBinding(f, ns.Name)
...@@ -411,6 +408,18 @@ func (f *Framework) CreateNamespace(baseName string, labels map[string]string) ( ...@@ -411,6 +408,18 @@ func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (
return ns, err return ns, err
} }
// AddNamespacesToDelete adds one or more namespaces to be deleted when the test
// completes.
func (f *Framework) AddNamespacesToDelete(namespaces ...*v1.Namespace) {
for _, ns := range namespaces {
if ns == nil {
continue
}
f.namespacesToDelete = append(f.namespacesToDelete, ns)
}
}
// WaitForPodTerminated waits for the pod to be terminated with the given reason. // WaitForPodTerminated waits for the pod to be terminated with the given reason.
func (f *Framework) WaitForPodTerminated(podName, reason string) error { func (f *Framework) WaitForPodTerminated(podName, reason string) error {
return waitForPodTerminatedInNamespace(f.ClientSet, podName, reason, f.Namespace.Name) return waitForPodTerminatedInNamespace(f.ClientSet, podName, reason, f.Namespace.Name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment