Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4cba83b

Browse files
authored
test: apptest was accidently choosing ports in use (#12580)
Apptest requires a port without a listening server to test failurecases. This port was chosen and had a chance of actually beingprovisioned. To prevent this accident, a port <1k is chosen,since those will never be allocated.
1 parent14130de commit4cba83b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

‎coderd/workspaceapps/apptest/setup.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,31 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
309309
},
310310
},workspaceMutators...)
311311

312+
// Intentionally going to choose a port that will never be chosen.
313+
// Ports <1k will never be selected. 396 is for some old OS over IP.
314+
// It will never likely be provisioned. Using quick timeout since
315+
// it's all localhost
316+
fakeAppURL:="http://127.1.0.1:396"
317+
conn,err:=net.DialTimeout("tcp",fakeAppURL,time.Millisecond*100)
318+
iferr==nil {
319+
// In the absolute rare case someone hits this. Writing code to find a free port
320+
// seems like a waste of time to program and run.
321+
_=conn.Close()
322+
t.Errorf("an unused port is required for the fake app. "+
323+
"The url %q happens to be an active port. If you hit this, then this test"+
324+
"will need to be modified to run on your system. Or you can stop serving an"+
325+
"app on that port.",fakeAppURL)
326+
t.FailNow()
327+
}
328+
312329
appURL:=fmt.Sprintf("%s://127.0.0.1:%d?%s",scheme,port,proxyTestAppQuery)
313330
protoApps:= []*proto.App{
314331
{
315332
Slug:proxyTestAppNameFake,
316333
DisplayName:proxyTestAppNameFake,
317334
SharingLevel:proto.AppSharingLevel_OWNER,
318-
// Hopefully this IP and port doesn't exist.
319-
Url:"http://127.1.0.1:65535",
320-
Subdomain:true,
335+
Url:fakeAppURL,
336+
Subdomain:true,
321337
},
322338
{
323339
Slug:proxyTestAppNameOwner,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp