Skip to content

Commit 6d74158

Browse files
authored
test/ginkgo: ensure admin server port is not selected dynamically (#10406)
1 parent 538482d commit 6d74158

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
changelog:
2+
- type: NON_USER_FACING
3+
issueLink: https://github.com/solo-io/solo-projects/issues/7307
4+
resolvesIssue: false
5+
description: >-
6+
Ensure that tests which are dynamically selecting ports always skip port 9095.
7+
Due to recent changes, when Gloo is running, this port will always be used.
8+
We choose to skip this, as it is the easiest way to avoid issues.

test/ginkgo/parallel/ports.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ func AdvancePort(p *uint32) uint32 {
7575
// AdvancePortSafeListen returns a port that is safe to use in parallel tests
7676
// It relies on pinging the port to see if it is in use
7777
func AdvancePortSafeListen(p *uint32, retryOptions ...retry.Option) uint32 {
78-
return MustAdvancePortSafe(p, portInUseListen, retryOptions...)
78+
errIfPortInUse := func(proposedPort uint32) error {
79+
if err := portInDenyList(proposedPort); err != nil {
80+
return err
81+
}
82+
if err := portInUseListen(proposedPort); err != nil {
83+
return err
84+
}
85+
return nil
86+
}
87+
88+
return MustAdvancePortSafe(p, errIfPortInUse, retryOptions...)
7989
}
8090

8191
func portInUseListen(proposedPort uint32) error {
@@ -88,3 +98,16 @@ func portInUseListen(proposedPort uint32) error {
8898
// Port should available if the listener closes without an error
8999
return ln.Close()
90100
}
101+
102+
var denyListPorts = map[uint32]struct{}{
103+
// See gloo/pkg/servers/admin/server.go
104+
// See https://github.com/solo-io/solo-projects/issues/7307 for more details
105+
9095: {},
106+
}
107+
108+
func portInDenyList(proposedPort uint32) error {
109+
if _, ok := denyListPorts[proposedPort]; ok {
110+
return eris.Errorf("port %d is in deny list", proposedPort)
111+
}
112+
return nil
113+
}

0 commit comments

Comments
 (0)