Skip to content

Commit 7c4ce62

Browse files
authored
test(site): print agent logs (#9464)
1 parent 22f31e7 commit 7c4ce62

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

site/e2e/helpers.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,24 @@ export const startAgentWithCommand = async (
314314
...process.env,
315315
CODER_AGENT_URL: "http://localhost:" + port,
316316
CODER_AGENT_TOKEN: token,
317+
CODER_AGENT_PPROF_ADDRESS: "127.0.0.1:2114",
318+
CODER_AGENT_PROMETHEUS_ADDRESS: "127.0.0.1:6061",
317319
},
318320
})
319-
let buffer = Buffer.of()
321+
cp.stdout.on("data", (data: Buffer) => {
322+
// eslint-disable-next-line no-console -- Log agent activity
323+
console.log(
324+
`[agent] [stdout] [onData] ${data.toString().replace(/\n$/g, "")}`,
325+
)
326+
})
320327
cp.stderr.on("data", (data: Buffer) => {
321-
buffer = Buffer.concat([buffer, data])
328+
// eslint-disable-next-line no-console -- Log agent activity
329+
console.log(
330+
`[agent] [stderr] [onData] ${data.toString().replace(/\n$/g, "")}`,
331+
)
322332
})
323-
try {
324-
await page.getByTestId("agent-status-ready").waitFor({ state: "visible" })
325-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- The error is a string
326-
} catch (ex: any) {
327-
throw new Error(ex.toString() + "\n" + buffer.toString())
328-
}
333+
334+
await page.getByTestId("agent-status-ready").waitFor({ state: "visible" })
329335
}
330336

331337
const coderMainPath = (): string => {

site/e2e/playwright.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default defineConfig({
3636
video: "retain-on-failure",
3737
},
3838
webServer: {
39+
url: `http://localhost:${port}/api/v2/deployment/config`,
3940
command:
4041
`go run -tags embed ${coderMain} server ` +
4142
`--global-config $(mktemp -d -t e2e-XXXXXXXXXX) ` +
@@ -88,7 +89,6 @@ export default defineConfig({
8889
gitAuth.validatePath,
8990
),
9091
},
91-
port,
9292
reuseExistingServer: false,
9393
},
9494
})

site/e2e/reporter.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class CoderReporter implements Reporter {
4141
onTestEnd(test: TestCase, result: TestResult) {
4242
// eslint-disable-next-line no-console -- Helpful for debugging
4343
console.log(`Finished test ${test.title}: ${result.status}`)
44+
if (result.status !== "passed") {
45+
// eslint-disable-next-line no-console -- Helpful for debugging
46+
console.log("errors", result.errors, "attachments", result.attachments)
47+
}
4448
}
4549

4650
onEnd(result: FullResult) {

0 commit comments

Comments
 (0)