From 6d741582fd61e8bedaa2319ecedb2383da1bc562 Mon Sep 17 00:00:00 2001 From: Sam Heilbron Date: Tue, 26 Nov 2024 14:42:41 -0700 Subject: [PATCH] test/ginkgo: ensure admin server port is not selected dynamically (#10406) --- changelog/v1.18.0-rc3/safe-ports-e2e.yaml | 8 ++++++++ test/ginkgo/parallel/ports.go | 25 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 changelog/v1.18.0-rc3/safe-ports-e2e.yaml diff --git a/changelog/v1.18.0-rc3/safe-ports-e2e.yaml b/changelog/v1.18.0-rc3/safe-ports-e2e.yaml new file mode 100644 index 00000000000..85fcd3dc8ce --- /dev/null +++ b/changelog/v1.18.0-rc3/safe-ports-e2e.yaml @@ -0,0 +1,8 @@ +changelog: + - type: NON_USER_FACING + issueLink: https://github.com/solo-io/solo-projects/issues/7307 + resolvesIssue: false + description: >- + Ensure that tests which are dynamically selecting ports always skip port 9095. + Due to recent changes, when Gloo is running, this port will always be used. + We choose to skip this, as it is the easiest way to avoid issues. \ No newline at end of file diff --git a/test/ginkgo/parallel/ports.go b/test/ginkgo/parallel/ports.go index 1d1bcc6f65c..9f13611c203 100644 --- a/test/ginkgo/parallel/ports.go +++ b/test/ginkgo/parallel/ports.go @@ -75,7 +75,17 @@ func AdvancePort(p *uint32) uint32 { // AdvancePortSafeListen returns a port that is safe to use in parallel tests // It relies on pinging the port to see if it is in use func AdvancePortSafeListen(p *uint32, retryOptions ...retry.Option) uint32 { - return MustAdvancePortSafe(p, portInUseListen, retryOptions...) + errIfPortInUse := func(proposedPort uint32) error { + if err := portInDenyList(proposedPort); err != nil { + return err + } + if err := portInUseListen(proposedPort); err != nil { + return err + } + return nil + } + + return MustAdvancePortSafe(p, errIfPortInUse, retryOptions...) } func portInUseListen(proposedPort uint32) error { @@ -88,3 +98,16 @@ func portInUseListen(proposedPort uint32) error { // Port should available if the listener closes without an error return ln.Close() } + +var denyListPorts = map[uint32]struct{}{ + // See gloo/pkg/servers/admin/server.go + // See https://github.com/solo-io/solo-projects/issues/7307 for more details + 9095: {}, +} + +func portInDenyList(proposedPort uint32) error { + if _, ok := denyListPorts[proposedPort]; ok { + return eris.Errorf("port %d is in deny list", proposedPort) + } + return nil +}