Skip to content

Commit

Permalink
test/ginkgo: ensure admin server port is not selected dynamically (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-heilbron authored Nov 26, 2024
1 parent 538482d commit 6d74158
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions changelog/v1.18.0-rc3/safe-ports-e2e.yaml
Original file line number Diff line number Diff line change
@@ -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.
25 changes: 24 additions & 1 deletion test/ginkgo/parallel/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

0 comments on commit 6d74158

Please sign in to comment.