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

Commit73f91e4

Browse files
ammariokylecarbs
andauthored
ci: use big runners (#4990)
* chore: Close idle connections on test cleanupIt's possible that this was the source of a leak on Windows...* ci: use big runners* fix: Improve tailnet connections by reducing timeoutsThis awaits connection ping before running a dial. Before,we were hitting the TCP retransmission and handshake timeouts,which could intermittently add 1 or 5 seconds to a connectionbeing initialized.* Add logging to Startupscript test* Add better logging* Write startup script logs to fs dir* Fix startup script test* Fix startup script test* Reduce test timeout* Use central tmp dir in agent* Adjust output* Skip startup script test on WindowsCo-authored-by: Kyle Carberry <kyle@carberry.com>
1 parent9578ce9 commit73f91e4

File tree

5 files changed

+43
-31
lines changed

5 files changed

+43
-31
lines changed

‎.github/workflows/coder.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
style-lint-golangci:
9090
name:style/lint/golangci
9191
timeout-minutes:5
92-
runs-on:${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
92+
runs-on:${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
9393
steps:
9494
-uses:actions/checkout@v3
9595
-uses:actions/setup-go@v3
@@ -171,7 +171,7 @@ jobs:
171171
gen:
172172
name:"style/gen"
173173
timeout-minutes:8
174-
runs-on:${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
174+
runs-on:${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
175175
needs:changes
176176
if:needs.changes.outputs.docs-only == 'false'
177177
steps:
@@ -276,7 +276,7 @@ jobs:
276276
277277
test-go:
278278
name:"test/go"
279-
runs-on:${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204'|| matrix.os }}
279+
runs-on:${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }}
280280
timeout-minutes:20
281281
strategy:
282282
matrix:
@@ -336,11 +336,7 @@ jobs:
336336
echo ::set-output name=cover::false
337337
fi
338338
set -x
339-
test_timeout=5m
340-
if [[ "${{ matrix.os }}" == windows* ]]; then
341-
test_timeout=10m
342-
fi
343-
gotestsum --junitfile="gotests.xml" --packages="./..." -- -parallel=8 -timeout=$test_timeout -short -failfast $COVERAGE_FLAGS
339+
gotestsum --junitfile="gotests.xml" --packages="./..." -- -parallel=8 -timeout=3m -short -failfast $COVERAGE_FLAGS
344340
345341
-uses:codecov/codecov-action@v3
346342
# This action has a tendency to error out unexpectedly, it has
@@ -356,7 +352,7 @@ jobs:
356352

357353
test-go-postgres:
358354
name:"test/go/postgres"
359-
runs-on:${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
355+
runs-on:${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
360356
# This timeout must be greater than the timeout set by `go test` in
361357
# `make test-postgres` to ensure we receive a trace of running
362358
# goroutines. Setting this to the timeout +5m should work quite well
@@ -417,7 +413,7 @@ jobs:
417413

418414
deploy:
419415
name:"deploy"
420-
runs-on:${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
416+
runs-on:${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
421417
timeout-minutes:30
422418
needs:changes
423419
if:|
@@ -514,7 +510,7 @@ jobs:
514510

515511
test-js:
516512
name:"test/js"
517-
runs-on:ubuntu-latest
513+
runs-on:${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
518514
timeout-minutes:20
519515
steps:
520516
-uses:actions/checkout@v3

‎.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ env:
2828

2929
jobs:
3030
release:
31-
runs-on:${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
31+
runs-on:${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
3232
env:
3333
# Necessary for Docker manifest
3434
DOCKER_CLI_EXPERIMENTAL:"enabled"

‎Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,11 @@ test: test-clean
463463
# When updating -timeout for this test, keep in sync with
464464
# test-go-postgres (.github/workflows/coder.yaml).
465465
test-postgres: test-clean test-postgres-docker
466+
# The postgres test is prone to failure, so we limit parallelism for
467+
# more consistent execution.
466468
DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." --\
467469
-covermode=atomic -coverprofile="gotests.coverage" -timeout=20m\
470+
-parallel=4\
468471
-coverpkg=./...\
469472
-count=1 -race -failfast
470473
.PHONY: test-postgres

‎agent/agent.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const (
5656

5757
typeOptionsstruct {
5858
Filesystem afero.Fs
59+
TempDirstring
5960
ExchangeTokenfunc(ctx context.Context) (string,error)
6061
ClientClient
6162
ReconnectingPTYTimeout time.Duration
@@ -78,6 +79,9 @@ func New(options Options) io.Closer {
7879
ifoptions.Filesystem==nil {
7980
options.Filesystem=afero.NewOsFs()
8081
}
82+
ifoptions.TempDir=="" {
83+
options.TempDir=os.TempDir()
84+
}
8185
ifoptions.ExchangeToken==nil {
8286
options.ExchangeToken=func(ctx context.Context) (string,error) {
8387
return"",nil
@@ -93,6 +97,7 @@ func New(options Options) io.Closer {
9397
client:options.Client,
9498
exchangeToken:options.ExchangeToken,
9599
filesystem:options.Filesystem,
100+
tempDir:options.TempDir,
96101
stats:&Stats{},
97102
}
98103
server.init(ctx)
@@ -104,6 +109,7 @@ type agent struct {
104109
clientClient
105110
exchangeTokenfunc(ctx context.Context) (string,error)
106111
filesystem afero.Fs
112+
tempDirstring
107113

108114
reconnectingPTYs sync.Map
109115
reconnectingPTYTimeout time.Duration
@@ -375,14 +381,14 @@ func (a *agent) runStartupScript(ctx context.Context, script string) error {
375381
returnnil
376382
}
377383

378-
writer,err:=os.OpenFile(filepath.Join(os.TempDir(),"coder-startup-script.log"),os.O_CREATE|os.O_RDWR,0o600)
384+
a.logger.Info(ctx,"running startup script",slog.F("script",script))
385+
writer,err:=a.filesystem.OpenFile(filepath.Join(a.tempDir,"coder-startup-script.log"),os.O_CREATE|os.O_RDWR,0o600)
379386
iferr!=nil {
380387
returnxerrors.Errorf("open startup script log file: %w",err)
381388
}
382389
deferfunc() {
383390
_=writer.Close()
384391
}()
385-
386392
cmd,err:=a.createCommand(ctx,script,nil)
387393
iferr!=nil {
388394
returnxerrors.Errorf("create command: %w",err)

‎agent/agent_test.go

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestAgent(t *testing.T) {
6161
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
6262
defercancel()
6363

64-
conn,stats:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
64+
conn,stats,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
6565

6666
sshClient,err:=conn.SSHClient(ctx)
6767
require.NoError(t,err)
@@ -81,7 +81,7 @@ func TestAgent(t *testing.T) {
8181
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
8282
defercancel()
8383

84-
conn,stats:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
84+
conn,stats,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
8585

8686
ptyConn,err:=conn.ReconnectingPTY(ctx,uuid.NewString(),128,128,"/bin/bash")
8787
require.NoError(t,err)
@@ -231,7 +231,7 @@ func TestAgent(t *testing.T) {
231231
ifruntime.GOOS=="windows" {
232232
home="/"+strings.ReplaceAll(home,"\\","/")
233233
}
234-
conn,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
234+
conn,_,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
235235
sshClient,err:=conn.SSHClient(ctx)
236236
require.NoError(t,err)
237237
defersshClient.Close()
@@ -261,7 +261,7 @@ func TestAgent(t *testing.T) {
261261
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
262262
defercancel()
263263

264-
conn,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
264+
conn,_,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
265265
sshClient,err:=conn.SSHClient(ctx)
266266
require.NoError(t,err)
267267
defersshClient.Close()
@@ -360,19 +360,23 @@ func TestAgent(t *testing.T) {
360360

361361
t.Run("StartupScript",func(t*testing.T) {
362362
t.Parallel()
363-
tempPath:=filepath.Join(t.TempDir(),"content.txt")
364-
content:="somethingnice"
365-
setupAgent(t, codersdk.WorkspaceAgentMetadata{
366-
StartupScript:fmt.Sprintf("echo %s > %s",content,tempPath),
363+
ifruntime.GOOS=="windows" {
364+
t.Skip("This test doesn't work on Windows for some reason...")
365+
}
366+
content:="output"
367+
_,_,fs:=setupAgent(t, codersdk.WorkspaceAgentMetadata{
368+
StartupScript:"echo "+content,
367369
},0)
368-
369370
vargotContentstring
370371
require.Eventually(t,func()bool {
371-
content,err:=os.ReadFile(tempPath)
372+
outputPath:=filepath.Join(os.TempDir(),"coder-startup-script.log")
373+
content,err:=afero.ReadFile(fs,outputPath)
372374
iferr!=nil {
375+
t.Logf("read file %q: %s",outputPath,err)
373376
returnfalse
374377
}
375378
iflen(content)==0 {
379+
t.Logf("no content in %q",outputPath)
376380
returnfalse
377381
}
378382
ifruntime.GOOS=="windows" {
@@ -384,7 +388,7 @@ func TestAgent(t *testing.T) {
384388
}
385389
gotContent=string(content)
386390
returntrue
387-
},testutil.WaitMedium,testutil.IntervalMedium)
391+
},testutil.WaitShort,testutil.IntervalMedium)
388392
require.Equal(t,content,strings.TrimSpace(gotContent))
389393
})
390394

@@ -400,7 +404,7 @@ func TestAgent(t *testing.T) {
400404
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
401405
defercancel()
402406

403-
conn,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
407+
conn,_,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
404408
id:=uuid.NewString()
405409
netConn,err:=conn.ReconnectingPTY(ctx,id,100,100,"/bin/bash")
406410
require.NoError(t,err)
@@ -497,7 +501,7 @@ func TestAgent(t *testing.T) {
497501
}
498502
}()
499503

500-
conn,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
504+
conn,_,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
501505
require.True(t,conn.AwaitReachable(context.Background()))
502506
conn1,err:=conn.DialContext(context.Background(),l.Addr().Network(),l.Addr().String())
503507
require.NoError(t,err)
@@ -518,7 +522,7 @@ func TestAgent(t *testing.T) {
518522
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
519523
defercancel()
520524
derpMap:=tailnettest.RunDERPAndSTUN(t)
521-
conn,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{
525+
conn,_,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{
522526
DERPMap:derpMap,
523527
},0)
524528
deferconn.Close()
@@ -601,7 +605,7 @@ func TestAgent(t *testing.T) {
601605
}
602606

603607
funcsetupSSHCommand(t*testing.T,beforeArgs []string,afterArgs []string)*exec.Cmd {
604-
agentConn,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
608+
agentConn,_,_:=setupAgent(t, codersdk.WorkspaceAgentMetadata{},0)
605609
listener,err:=net.Listen("tcp","127.0.0.1:0")
606610
require.NoError(t,err)
607611
waitGroup:= sync.WaitGroup{}
@@ -644,7 +648,7 @@ func setupSSHCommand(t *testing.T, beforeArgs []string, afterArgs []string) *exe
644648
funcsetupSSHSession(t*testing.T,options codersdk.WorkspaceAgentMetadata)*ssh.Session {
645649
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
646650
defercancel()
647-
conn,_:=setupAgent(t,options,0)
651+
conn,_,_:=setupAgent(t,options,0)
648652
sshClient,err:=conn.SSHClient(ctx)
649653
require.NoError(t,err)
650654
t.Cleanup(func() {
@@ -664,13 +668,15 @@ func (c closeFunc) Close() error {
664668
funcsetupAgent(t*testing.T,metadata codersdk.WorkspaceAgentMetadata,ptyTimeout time.Duration) (
665669
*codersdk.AgentConn,
666670
<-chan*codersdk.AgentStats,
671+
afero.Fs,
667672
) {
668673
ifmetadata.DERPMap==nil {
669674
metadata.DERPMap=tailnettest.RunDERPAndSTUN(t)
670675
}
671676
coordinator:=tailnet.NewCoordinator()
672677
agentID:=uuid.New()
673678
statsCh:=make(chan*codersdk.AgentStats)
679+
fs:=afero.NewMemMapFs()
674680
closer:=agent.New(agent.Options{
675681
Client:&client{
676682
t:t,
@@ -679,6 +685,7 @@ func setupAgent(t *testing.T, metadata codersdk.WorkspaceAgentMetadata, ptyTimeo
679685
statsChan:statsCh,
680686
coordinator:coordinator,
681687
},
688+
Filesystem:fs,
682689
Logger:slogtest.Make(t,nil).Leveled(slog.LevelDebug),
683690
ReconnectingPTYTimeout:ptyTimeout,
684691
})
@@ -704,7 +711,7 @@ func setupAgent(t *testing.T, metadata codersdk.WorkspaceAgentMetadata, ptyTimeo
704711
conn.SetNodeCallback(sendNode)
705712
return&codersdk.AgentConn{
706713
Conn:conn,
707-
},statsCh
714+
},statsCh,fs
708715
}
709716

710717
vardialTestPayload= []byte("dean-was-here123")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp