-
Notifications
You must be signed in to change notification settings - Fork 43
chore(integration): update TestLogs to validate that CODER_ASGENT_SUBSYSTEM is set correctly #397
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,10 +123,11 @@ func TestLogs(t *testing.T) { | |
"Dockerfile": fmt.Sprintf(`FROM %s`, testImageUbuntu), | ||
}, | ||
}) | ||
_, err := runEnvbuilder(t, runOpts{env: []string{ | ||
ctrID, err := runEnvbuilder(t, runOpts{env: []string{ | ||
envbuilderEnv("GIT_URL", srv.URL), | ||
"CODER_AGENT_URL=" + logSrv.URL, | ||
"CODER_AGENT_TOKEN=" + token, | ||
"ENVBUILDER_INIT_SCRIPT=env", | ||
}}) | ||
require.NoError(t, err) | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute) | ||
|
@@ -136,6 +137,28 @@ func TestLogs(t *testing.T) { | |
t.Fatal("timed out waiting for logs") | ||
case <-logsDone: | ||
} | ||
|
||
// Wait for the container to exit | ||
client, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) | ||
require.NoError(t, err) | ||
require.Eventually(t, func() bool { | ||
status, err := client.ContainerInspect(ctx, ctrID) | ||
if !assert.NoError(t, err) { | ||
return false | ||
} | ||
return !status.State.Running | ||
}, 10*time.Second, time.Second, "container never exited") | ||
|
||
// Check the expected log output | ||
logReader, err := client.ContainerLogs(ctx, ctrID, container.LogsOptions{ | ||
ShowStdout: true, | ||
ShowStderr: true, | ||
}) | ||
require.NoError(t, err) | ||
logBytes, err := io.ReadAll(logReader) | ||
require.NoError(t, err) | ||
logs := string(logBytes) | ||
require.Contains(t, logs, "CODER_AGENT_SUBSYSTEM=envbuilder") | ||
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. Is this relevant for the logs test, or just something we want to verify in general? Would it make more sense in a more env-targeted test or some other behavior? 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. It only gets set if |
||
} | ||
|
||
func TestInitScriptInitCommand(t *testing.T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could 10 seconds be potentially flaky?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially, but I think it's relatively unlikely that it will take that long to execute
env
and for the container to exit.