diff --git a/pkg/test/context.go b/pkg/test/context.go index 66d115d9ed5..7f6cde521f3 100644 --- a/pkg/test/context.go +++ b/pkg/test/context.go @@ -46,8 +46,7 @@ func (f *Framework) NewTestCtx(t *testing.T) TestCtx { id := prefix + "-" + strconv.FormatInt(time.Now().Unix(), 10) return TestCtx{ - ID: id, - Namespace: *f.Namespace, + ID: id, } } diff --git a/pkg/test/resource_creator.go b/pkg/test/resource_creator.go index 5ef8b7d079e..f597bf5705c 100644 --- a/pkg/test/resource_creator.go +++ b/pkg/test/resource_creator.go @@ -53,7 +53,9 @@ func (ctx *TestCtx) GetNamespace() (string, error) { } namespaceObj := &core.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ctx.Namespace}} _, err := Global.KubeClient.CoreV1().Namespaces().Create(namespaceObj) - if err != nil { + if apierrors.IsAlreadyExists(err) { + return ctx.Namespace, nil + } else if err != nil { return "", err } ctx.AddFinalizerFn(func() error {