test(site): print agent logs (#9464)

This commit is contained in:
Marcin Tojek
2023-08-31 14:44:44 +02:00
committed by GitHub
parent 22f31e721c
commit 7c4ce62a58
3 changed files with 20 additions and 10 deletions
+15 -9
View File
@@ -314,18 +314,24 @@ export const startAgentWithCommand = async (
...process.env,
CODER_AGENT_URL: "http://localhost:" + port,
CODER_AGENT_TOKEN: token,
CODER_AGENT_PPROF_ADDRESS: "127.0.0.1:2114",
CODER_AGENT_PROMETHEUS_ADDRESS: "127.0.0.1:6061",
},
})
let buffer = Buffer.of()
cp.stderr.on("data", (data: Buffer) => {
buffer = Buffer.concat([buffer, data])
cp.stdout.on("data", (data: Buffer) => {
// eslint-disable-next-line no-console -- Log agent activity
console.log(
`[agent] [stdout] [onData] ${data.toString().replace(/\n$/g, "")}`,
)
})
try {
await page.getByTestId("agent-status-ready").waitFor({ state: "visible" })
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- The error is a string
} catch (ex: any) {
throw new Error(ex.toString() + "\n" + buffer.toString())
}
cp.stderr.on("data", (data: Buffer) => {
// eslint-disable-next-line no-console -- Log agent activity
console.log(
`[agent] [stderr] [onData] ${data.toString().replace(/\n$/g, "")}`,
)
})
await page.getByTestId("agent-status-ready").waitFor({ state: "visible" })
}
const coderMainPath = (): string => {
+1 -1
View File
@@ -36,6 +36,7 @@ export default defineConfig({
video: "retain-on-failure",
},
webServer: {
url: `http://localhost:${port}/api/v2/deployment/config`,
command:
`go run -tags embed ${coderMain} server ` +
`--global-config $(mktemp -d -t e2e-XXXXXXXXXX) ` +
@@ -88,7 +89,6 @@ export default defineConfig({
gitAuth.validatePath,
),
},
port,
reuseExistingServer: false,
},
})
+4
View File
@@ -41,6 +41,10 @@ class CoderReporter implements Reporter {
onTestEnd(test: TestCase, result: TestResult) {
// eslint-disable-next-line no-console -- Helpful for debugging
console.log(`Finished test ${test.title}: ${result.status}`)
if (result.status !== "passed") {
// eslint-disable-next-line no-console -- Helpful for debugging
console.log("errors", result.errors, "attachments", result.attachments)
}
}
onEnd(result: FullResult) {