nic-6443 commented on code in PR #2845:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2845#discussion_r3764498851


##########
test/e2e/gatewayapi/status.go:
##########
@@ -154,6 +154,12 @@ spec:
                        Expect(err).NotTo(HaveOccurred(), "getting service 
yaml")
                        err = yaml.Unmarshal([]byte(serviceYaml), &k8sservice)
                        Expect(err).NotTo(HaveOccurred(), "unmarshalling 
service")
+                       // Switching to ExternalName released the allocated 
node ports, and a service
+                       // in a parallel test namespace may have taken them 
since. Ask for fresh ones
+                       // instead of the old numbers, which would fail with 
"already allocated".
+                       for i := range oldSpec.Ports {
+                               oldSpec.Ports[i].NodePort = 0
+                       }

Review Comment:
   Fair point, but I'd rather not. The three-line loop is only a small piece of 
a ~30-line capture-and-restore block that's duplicated between the two files — 
get the svc yaml, unmarshal, flip to ExternalName, assert SyncFailed, restore, 
assert Accepted. Extracting just the NodePort clearing into a cross-package 
helper wouldn't meaningfully reduce that duplication, it'd just move three 
lines behind an import.
   
   Factoring out the whole block would be worth doing, but that's a refactor of 
two test suites and I'd keep it out of a flake fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to