Skip to content

Commit b8a3632

Browse files
committed
feat: generate unique namespace names for UDN tests
Fix namespace creation issue in UDN tests by generating unique namespace names instead of reusing existing test namespace. Previously, the CreateNamespaceUDN function would fail with "namespace already exists" errors because it was using the existing test namespace name. Now it generates a unique name using SimpleNameGenerator and sets it as the current namespace before creation. Also made the user-defined network label value empty to match test requirements.
1 parent 8fe50c0 commit b8a3632

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/extended/util/util_otp.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"path/filepath"
1010
"strings"
1111

12+
"k8s.io/apiserver/pkg/storage/names"
1213
e2e "k8s.io/kubernetes/test/e2e/framework"
1314

1415
corev1 "k8s.io/api/core/v1"
@@ -69,12 +70,18 @@ func (c *CLI) WithoutKubeconf() *CLI {
6970
// CreateNamespaceUDN creates a new namespace with required user defined network label during creation time only
7071
// required for testing networking UDN features on 4.17z+
7172
func (c *CLI) CreateNamespaceUDN() {
73+
// Create new namespace name here, because c.Namespace() will get existing test namespace
74+
// namespace Create func will be failed with below error
75+
// namespaces "e2e-test-xxx" already exists
76+
newNsName := names.SimpleNameGenerator.GenerateName(fmt.Sprintf("e2e-test-udn-%s-", c.kubeFramework.BaseName))
77+
c.SetNamespace(newNsName)
78+
7279
labels := map[string]string{
73-
"k8s.ovn.org/primary-user-defined-network": "udn-net",
80+
"k8s.ovn.org/primary-user-defined-network": "",
7481
}
7582
namespace := &corev1.Namespace{
7683
ObjectMeta: metav1.ObjectMeta{
77-
Name: c.Namespace(),
84+
Name: newNsName,
7885
Labels: labels,
7986
},
8087
}

0 commit comments

Comments
 (0)