From 3fb1b63c2214676edce47351f07aed0100c6a5f8 Mon Sep 17 00:00:00 2001 From: Jacob Tanenbaum Date: Thu, 12 Dec 2024 15:22:19 -0500 Subject: [PATCH] use the framework to create the UDN testing namespaces using the framework to create the namespaces will ensure that the pods get correctly added to the git event repo on failure. Signed-off-by: Jacob Tanenbaum --- .../networking/network_segmentation.go | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/test/extended/networking/network_segmentation.go b/test/extended/networking/network_segmentation.go index 9d77bf0c742f..ffbddfb4a1a2 100644 --- a/test/extended/networking/network_segmentation.go +++ b/test/extended/networking/network_segmentation.go @@ -372,32 +372,17 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User red := "red" blue := "blue" - - namespaceRed := f.Namespace.Name + "-" + red - namespaceBlue := f.Namespace.Name + "-" + blue + namespaceRed, err := f.CreateNamespace(context.Background(), red, nil) + Expect(err).NotTo(HaveOccurred()) + namespaceBlue, err := f.CreateNamespace(context.Background(), blue, nil) + Expect(err).NotTo(HaveOccurred()) netConfig := networkAttachmentConfigParams{ topology: topology, cidr: correctCIDRFamily(oc, userDefinedv4Subnet, userDefinedv6Subnet), role: "primary", } - for _, namespace := range []string{namespaceRed, namespaceBlue} { - By("Creating namespace " + namespace) - _, err := cs.CoreV1().Namespaces().Create(context.Background(), &v1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: namespace, - }, - }, metav1.CreateOptions{}) - Expect(err).NotTo(HaveOccurred()) - defer func() { - Expect(cs.CoreV1().Namespaces().Delete( - context.Background(), - namespace, - metav1.DeleteOptions{}, - )).To(Succeed()) - }() - } - networkNamespaceMap := map[string]string{namespaceRed: red, namespaceBlue: blue} + networkNamespaceMap := map[string]string{namespaceRed.Name: red, namespaceBlue.Name: blue} for namespace, network := range networkNamespaceMap { By("creating the network " + network + " in namespace " + namespace) netConfig.namespace = namespace @@ -481,7 +466,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User By("Deleting pods in network blue except " + fmt.Sprintf("%s-pod-%d", blue, numberOfPods-1)) for i := 0; i < numberOfPods-1; i++ { - err := cs.CoreV1().Pods(namespaceBlue).Delete( + err := cs.CoreV1().Pods(namespaceBlue.Name).Delete( context.Background(), fmt.Sprintf("%s-pod-%d", blue, i), metav1.DeleteOptions{}, @@ -491,9 +476,9 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User podIP, err := podIPsForUserDefinedPrimaryNetwork( cs, - namespaceBlue, + namespaceBlue.Name, fmt.Sprintf("%s-pod-%d", blue, numberOfPods-1), - namespacedName(namespaceBlue, blue), + namespacedName(namespaceBlue.Name, blue), 0, ) Expect(err).NotTo(HaveOccurred()) @@ -505,7 +490,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User continue } _, err := e2ekubectl.RunKubectl( - namespaceBlue, + namespaceBlue.Name, "exec", fmt.Sprintf("%s-pod-%d", blue, numberOfPods-1), "--",