Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa90888

Browse files
committed
chore: test eviction with used ports
1 parent 7f2e241 commit fa90888

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

agent/agentssh/x11_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,17 @@ func TestServer_X11_EvictionLRU(t *testing.T) {
164164

165165
c := sshClient(t, ln.Addr().String())
166166

167+
// block off one port to test x11Forwarder evicts at highest port, not number of listeners.
168+
externalListener, err := inproc.Listen("tcp",
169+
fmt.Sprintf("localhost:%d", agentssh.X11StartPort+agentssh.X11DefaultDisplayOffset+1))
170+
require.NoError(t, err)
171+
defer externalListener.Close()
172+
167173
// Calculate how many simultaneous X11 sessions we can create given the
168174
// configured port range.
175+
169176
startPort := agentssh.X11StartPort + agentssh.X11DefaultDisplayOffset
170-
maxSessions := agentssh.X11MaxPort - startPort + 1
177+
maxSessions := agentssh.X11MaxPort - startPort + 1 - 1 // -1 for the blocked port
171178
require.Greater(t, maxSessions, 0, "expected a positive maxSessions value")
172179

173180
// shellSession holds references to the session and its standard streams so

0 commit comments

Comments
 (0)