diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 29f136ad2ca..8bd4c931b5b 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -25,6 +25,7 @@ import ( "bufio" "bytes" "fmt" + "math/rand" "os" "strings" "sync" @@ -68,6 +69,11 @@ const ( type Framework struct { BaseName string + // Set together with creating the ClientSet and the namespace. + // Guaranteed to be unique in the cluster even when running the same + // test multiple times in parallel. + UniqueName string + ClientSet clientset.Interface KubemarkExternalClusterClientSet clientset.Interface APIExtensionsClientSet apiextensionsclient.Interface @@ -229,6 +235,10 @@ func (f *Framework) BeforeEach() { } else { Logf("Skipping waiting for service account") } + f.UniqueName = f.Namespace.GetName() + } else { + // not guaranteed to be unique, but very likely + f.UniqueName = fmt.Sprintf("%s-%08x", f.BaseName, rand.Int31()) } if TestContext.GatherKubeSystemResourceUsageData != "false" && TestContext.GatherKubeSystemResourceUsageData != "none" {