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

Skip to content

Commit 16ac54c

Browse files
authored
fix: Wait for workspace build to complete before running SSH tests (coder#2671)
This was causing a race shown here: https://github.com/coder/coder/runs/7063713786?check_suite_focus=true
1 parent dac6838 commit 16ac54c

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

cli/ssh_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func setupWorkspaceForSSH(t *testing.T) (*codersdk.Client, codersdk.Workspace, s
5959
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
6060
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
6161
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
62+
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
6263

6364
return client, workspace, agentToken
6465
}
@@ -68,7 +69,6 @@ func TestSSH(t *testing.T) {
6869
t.Run("ImmediateExit", func(t *testing.T) {
6970
t.Parallel()
7071
client, workspace, agentToken := setupWorkspaceForSSH(t)
71-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
7272
cmd, root := clitest.New(t, "ssh", workspace.Name)
7373
clitest.SetupConfig(t, client, root)
7474
pty := ptytest.New(t)
@@ -96,11 +96,9 @@ func TestSSH(t *testing.T) {
9696
t.Run("Stdio", func(t *testing.T) {
9797
t.Parallel()
9898
client, workspace, agentToken := setupWorkspaceForSSH(t)
99-
10099
_, _ = tGoContext(t, func(ctx context.Context) {
101100
// Run this async so the SSH command has to wait for
102101
// the build and agent to connect!
103-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
104102
agentClient := codersdk.New(client.URL)
105103
agentClient.SessionToken = agentToken
106104
agentCloser := agent.New(agentClient.ListenWorkspaceAgent, &agent.Options{
@@ -154,11 +152,9 @@ func TestSSH(t *testing.T) {
154152
t.Parallel()
155153

156154
client, workspace, agentToken := setupWorkspaceForSSH(t)
157-
158155
_, _ = tGoContext(t, func(ctx context.Context) {
159156
// Run this async so the SSH command has to wait for
160157
// the build and agent to connect!
161-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
162158
agentClient := codersdk.New(client.URL)
163159
agentClient.SessionToken = agentToken
164160
agentCloser := agent.New(agentClient.ListenWorkspaceAgent, &agent.Options{

0 commit comments

Comments
 (0)