- Notifications
You must be signed in to change notification settings - Fork927
feat: convert rest of CLI to clibase#6491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
0dbcd12
18d31bf
ec8e626
e54d393
518b51d
c9820fb
32a1759
5af1142
5613d3b
b713372
7884f32
a58d15e
c8c9e51
274c84d
6fb72b5
eeb9500
e8959cf
799ace7
25682f6
88a64fc
c0a77cc
6757d66
6c0b64a
d028e1e
a678576
c4e8925
46f0339
d242a84
0706c19
6757d84
113ad13
855e97d
04977de
d183ce3
ee6b65b
d19cae5
a57639b
a571e0c
2b02e65
2884aa6
71f2c32
c6621bb
be7f957
2f99f87
aac0fc0
bfbd0f5
7d12d64
d5228c3
6f3575e
029bd27
74e5819
42d8011
781d700
94823df
c2fdc2c
aee0627
f1d9c22
eca5625
be8dcc8
2500af8
e776504
d6adedf
4f21d52
1e5d223
ad810f6
4f52669
303f0ab
51c132e
6c697f6
7ab0710
fc4342b
0b1ed6f
b759071
412f054
466c3dc
d3dab44
bf93f2b
f5e2611
64a28b8
3292af9
039ef66
df1e20a
746f27d
e8d6a47
9852f0b
36212f7
1cd34ef
8216640
6dc4578
97233c2
2065ddc
f9cd94e
8f0b0fa
65e9dc3
527e7ef
6ec84aa
95508bd
695b56d
980768b
452ffdf
371e34d
888292c
f5fcc2c
8e04d8b
1b6062b
71e5700
59a53b4
2acc7f0
faa3515
1b281af
1cba181
1e29b7a
ba9443a
981bf55
e7d7d8a
8da9ed3
e176250
813a30e
b74c576
17cdcfc
9958d26
4f4c66c
ff3b858
1f7eef1
79a66c5
2781b7c
dc60ac8
e21d488
4e6e434
22a6978
d4ae272
7bf9b21
3611907
ed700b8
0671e00
7d03079
218f57e
c075ee2
c6e7689
4435212
79d4130
dcf5b50
03d8a19
e122a9c
c72050b
c33954c
a774c0e
3cb50b3
e33da7a
1b81037
e96d155
81c4543
4338598
359923b
8e420dd
bbdcb7e
cc0a998
8dbf57c
3495efc
de08cde
0544597
7bc2f82
7c1acbf
796b527
2413718
da716cf
ca9ccba
9865ba8
38110ba
0cf7654
0bfcbee
ac60ecb
6255ddd
9ebd6e9
85e252b
40a6914
5f1e374
3a01d94
fb4eb88
6cb6ef6
919f768
e6fa741
44fcba5
dcc5943
ed49ce5
d5af663
cdda9fe
0c5a778
f9679b8
9b798ed
907e26e
9dca6f2
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Diff view
Diff view
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -16,7 +16,7 @@ import ( | ||
"github.com/coder/coder/coderd/coderdtest" | ||
"github.com/coder/coder/provisioner/echo" | ||
"github.com/coder/coder/provisionersdk/proto" | ||
"github.com/coder/coder/pty/ptytest" | ||
) | ||
func TestWorkspaceAgent(t *testing.T) { | ||
@@ -40,24 +40,20 @@ func TestWorkspaceAgent(t *testing.T) { | ||
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) | ||
logDir := t.TempDir() | ||
inv, _ := clitest.New(t, | ||
"agent", | ||
"--auth", "token", | ||
"--agent-token", authToken, | ||
"--agent-url", client.URL.String(), | ||
"--log-dir", logDir, | ||
) | ||
pty := ptytest.New(t).Attach(inv) | ||
clitest.Start(t, inv) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is a bit of a lossy migration. We used to wait for the command to exit before checking the logs. In theory there's a chance the logs haven't been flushed to disk yet when we check their size. In practice I doubt it will happen here, but this is a use-case we'll need to support going forward. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. True. Fixed with an ExpectMatch. | ||
pty.ExpectMatch("starting agent") | ||
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID) | ||
info, err := os.Stat(filepath.Join(logDir, "coder-agent.log")) | ||
require.NoError(t, err) | ||
@@ -96,16 +92,14 @@ func TestWorkspaceAgent(t *testing.T) { | ||
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) | ||
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) | ||
inv, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String()) | ||
inv = inv.WithContext( | ||
//nolint:revive,staticcheck | ||
context.WithValue(inv.Context(), "azure-client", metadataClient), | ||
) | ||
ctx, cancelFunc := context.WithCancel(context.Background()) | ||
defer cancelFunc() | ||
clitest.Start(t, inv) | ||
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID) | ||
workspace, err := client.Workspace(ctx, workspace.ID) | ||
require.NoError(t, err) | ||
@@ -117,9 +111,6 @@ func TestWorkspaceAgent(t *testing.T) { | ||
require.NoError(t, err) | ||
defer dialer.Close() | ||
require.True(t, dialer.AwaitReachable(context.Background())) | ||
}) | ||
t.Run("AWS", func(t *testing.T) { | ||
@@ -154,36 +145,29 @@ func TestWorkspaceAgent(t *testing.T) { | ||
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) | ||
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) | ||
inv, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String()) | ||
inv = inv.WithContext( | ||
//nolint:revive,staticcheck | ||
context.WithValue(inv.Context(), "aws-client", metadataClient), | ||
) | ||
clitest.Start(t, inv) | ||
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID) | ||
workspace, err := client.Workspace(inv.Context(), workspace.ID) | ||
require.NoError(t, err) | ||
resources := workspace.LatestBuild.Resources | ||
if assert.NotEmpty(t, resources) && assert.NotEmpty(t, resources[0].Agents) { | ||
assert.NotEmpty(t, resources[0].Agents[0].Version) | ||
} | ||
dialer, err := client.DialWorkspaceAgent(inv.Context(), resources[0].Agents[0].ID, nil) | ||
require.NoError(t, err) | ||
defer dialer.Close() | ||
require.True(t, dialer.AwaitReachable(context.Background())) | ||
}) | ||
t.Run("GoogleCloud", func(t *testing.T) { | ||
t.Parallel() | ||
instanceID := "instanceidentifier" | ||
validator,metadataClient := coderdtest.NewGoogleInstanceIdentity(t, instanceID, false) | ||
client := coderdtest.New(t, &coderdtest.Options{ | ||
GoogleTokenValidator: validator, | ||
IncludeProvisionerDaemon: true, | ||
@@ -212,16 +196,18 @@ func TestWorkspaceAgent(t *testing.T) { | ||
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) | ||
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) | ||
inv, cfg := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String()) | ||
ptytest.New(t).Attach(inv) | ||
clitest.SetupConfig(t, client, cfg) | ||
clitest.Start(t, | ||
inv.WithContext( | ||
//nolint:revive,staticcheck | ||
context.WithValue(context.Background(), "gcp-client", metadataClient), | ||
), | ||
) | ||
ctx := inv.Context() | ||
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID) | ||
workspace, err := client.Workspace(ctx, workspace.ID) | ||
require.NoError(t, err) | ||
@@ -248,9 +234,5 @@ func TestWorkspaceAgent(t *testing.T) { | ||
require.NoError(t, err) | ||
_, err = uuid.Parse(strings.TrimSpace(string(token))) | ||
require.NoError(t, err) | ||
}) | ||
} |
Uh oh!
There was an error while loading.Please reload this page.