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

Commit7090227

Browse files
authored
fix: GitSSH test flake on slow CI runs (#1001)
There was a 5s timeout on the context, which was occasionallyhit during slow runs. See:https://github.com/coder/coder/runs/6025622326?check_suite_focus=trueI also removed the AWS authentication, because it added to the testtime for key-generation and such.
1 parentf3f39f3 commit7090227

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

‎cli/gitssh_test.go

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"net"
77
"sync/atomic"
88
"testing"
9-
"time"
109

1110
"github.com/gliderlabs/ssh"
11+
"github.com/google/uuid"
1212
"github.com/spf13/cobra"
1313
"github.com/stretchr/testify/require"
1414
gossh"golang.org/x/crypto/ssh"
@@ -24,34 +24,30 @@ import (
2424
funcTestGitSSH(t*testing.T) {
2525
t.Parallel()
2626
t.Run("Dial",func(t*testing.T) {
27-
ctx,cancel:=context.WithTimeout(context.Background(),time.Second*5)
28-
defercancel()
29-
instanceID:="instanceidentifier"
30-
certificates,metadataClient:=coderdtest.NewAWSInstanceIdentity(t,instanceID)
31-
client:=coderdtest.New(t,&coderdtest.Options{
32-
AWSInstanceIdentity:certificates,
33-
})
27+
client:=coderdtest.New(t,nil)
3428
user:=coderdtest.CreateFirstUser(t,client)
3529

3630
// get user public key
37-
keypair,err:=client.GitSSHKey(ctx,codersdk.Me)
31+
keypair,err:=client.GitSSHKey(context.Background(),codersdk.Me)
3832
require.NoError(t,err)
3933
publicKey,_,_,_,err:=gossh.ParseAuthorizedKey([]byte(keypair.PublicKey))
4034
require.NoError(t,err)
4135

4236
// setup provisioner
37+
agentToken:=uuid.NewString()
4338
coderdtest.NewProvisionerDaemon(t,client)
4439
version:=coderdtest.CreateTemplateVersion(t,client,user.OrganizationID,&echo.Responses{
45-
Parse:echo.ParseComplete,
40+
Parse:echo.ParseComplete,
41+
ProvisionDryRun:echo.ProvisionComplete,
4642
Provision: []*proto.Provision_Response{{
4743
Type:&proto.Provision_Response_Complete{
4844
Complete:&proto.Provision_Complete{
4945
Resources: []*proto.Resource{{
5046
Name:"somename",
5147
Type:"someinstance",
5248
Agents: []*proto.Agent{{
53-
Auth:&proto.Agent_InstanceId{
54-
InstanceId:instanceID,
49+
Auth:&proto.Agent_Token{
50+
Token:agentToken,
5551
},
5652
}},
5753
}},
@@ -65,23 +61,20 @@ func TestGitSSH(t *testing.T) {
6561
coderdtest.AwaitWorkspaceBuildJob(t,client,workspace.LatestBuild.ID)
6662

6763
// start workspace agent
68-
cmd,root:=clitest.New(t,"agent","--auth","aws-instance-identity","--url",client.URL.String())
64+
cmd,root:=clitest.New(t,"agent","--token",agentToken,"--url",client.URL.String())
6965
agentClient:=&*client
7066
clitest.SetupConfig(t,agentClient,root)
7167
ctx,cancelFunc:=context.WithCancel(context.Background())
7268
defercancelFunc()
7369
gofunc() {
74-
// A linting error occurs for weakly typing the context value here,
75-
// but it seems reasonable for a one-off test.
76-
// nolint
77-
ctx=context.WithValue(ctx,"aws-client",metadataClient)
7870
err:=cmd.ExecuteContext(ctx)
7971
require.NoError(t,err)
8072
}()
73+
8174
coderdtest.AwaitWorkspaceAgents(t,client,workspace.LatestBuild.ID)
82-
resources,err:=client.WorkspaceResourcesByBuild(ctx,workspace.LatestBuild.ID)
75+
resources,err:=client.WorkspaceResourcesByBuild(context.Background(),workspace.LatestBuild.ID)
8376
require.NoError(t,err)
84-
dialer,err:=client.DialWorkspaceAgent(ctx,resources[0].Agents[0].ID,nil,nil)
77+
dialer,err:=client.DialWorkspaceAgent(context.Background(),resources[0].Agents[0].ID,nil,nil)
8578
require.NoError(t,err)
8679
deferdialer.Close()
8780
_,err=dialer.Ping()
@@ -113,7 +106,7 @@ func TestGitSSH(t *testing.T) {
113106
cmd,root=clitest.New(t,"gitssh","--global-config="+string(cfgDir),"--",fmt.Sprintf("-p%d",addr.Port),"-o","StrictHostKeyChecking=no","127.0.0.1")
114107
clitest.SetupConfig(t,agentClient,root)
115108

116-
err=cmd.ExecuteContext(ctx)
109+
err=cmd.ExecuteContext(context.Background())
117110
require.NoError(t,err)
118111
require.EqualValues(t,1,inc)
119112
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp