( page: Page, token: string, command: string, ...args: string[] )
| 514 | }; |
| 515 | |
| 516 | export const startAgentWithCommand = async ( |
| 517 | page: Page, |
| 518 | token: string, |
| 519 | command: string, |
| 520 | ...args: string[] |
| 521 | ): Promise<ChildProcess> => { |
| 522 | const cp = spawn(command, [...args, "agent", "--no-reap"], { |
| 523 | env: { |
| 524 | ...process.env, |
| 525 | CODER_AGENT_URL: `http://localhost:${coderPort}`, |
| 526 | CODER_AGENT_TOKEN: token, |
| 527 | CODER_AGENT_PPROF_ADDRESS: `127.0.0.1:${agentPProfPort}`, |
| 528 | CODER_AGENT_PROMETHEUS_ADDRESS: `127.0.0.1:${prometheusPort}`, |
| 529 | }, |
| 530 | }); |
| 531 | cp.stdout.on("data", (data: Buffer) => { |
| 532 | console.info(`[agent][stdout] ${data.toString().replace(/\n$/g, "")}`); |
| 533 | }); |
| 534 | cp.stderr.on("data", (data: Buffer) => { |
| 535 | console.info(`[agent][stderr] ${data.toString().replace(/\n$/g, "")}`); |
| 536 | }); |
| 537 | |
| 538 | await page |
| 539 | .getByTestId("agent-status-ready") |
| 540 | .waitFor({ state: "visible", timeout: 15_000 }); |
| 541 | return cp; |
| 542 | }; |
| 543 | |
| 544 | export const stopAgent = async (cp: ChildProcess) => { |
| 545 | // The command `kill` is used to terminate an agent started as a standalone binary. |
no test coverage detected