mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 11:20:36 +08:00
Remove unnecessary stops of httpd in tests
This commit is contained in:
@@ -27,6 +27,6 @@ export const testFixture = test.extend<TestFixtures>({
|
||||
await peer.startHttpd();
|
||||
const api = new HttpdClient(peer.httpdBaseUrl);
|
||||
await use({ api, peer });
|
||||
await peer.stopHttpd();
|
||||
await peer.shutdown();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,8 +20,6 @@ test("node metadata", async ({ page, peerManager }) => {
|
||||
page.getByText(`${shortNodeRemote}@seed.radicle.test:8123`),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText("1.0.0-rc.8-")).toBeVisible();
|
||||
await peer.stopHttpd();
|
||||
await peer.stopNode();
|
||||
});
|
||||
|
||||
test("node projects", async ({ page }) => {
|
||||
|
||||
@@ -172,7 +172,6 @@ export class RadiclePeer {
|
||||
#listenSocketAddr?: string;
|
||||
#httpdBaseUrl?: BaseUrl;
|
||||
#nodeProcess?: ExecaChildProcess;
|
||||
#httpdProcess?: ExecaChildProcess;
|
||||
// Name for easy identification. Used on file system and in logs.
|
||||
#name: string;
|
||||
#childProcesses: ExecaChildProcess[] = [];
|
||||
@@ -266,7 +265,7 @@ export class RadiclePeer {
|
||||
port,
|
||||
scheme: "http",
|
||||
};
|
||||
this.#httpdProcess = this.spawn("radicle-httpd", [
|
||||
void this.spawn("radicle-httpd", [
|
||||
"--listen",
|
||||
`${this.#httpdBaseUrl.hostname}:${this.#httpdBaseUrl.port}`,
|
||||
]);
|
||||
@@ -279,23 +278,6 @@ export class RadiclePeer {
|
||||
});
|
||||
}
|
||||
|
||||
public async stopHttpd() {
|
||||
if (!this.#httpdBaseUrl || !this.#httpdProcess) {
|
||||
return;
|
||||
}
|
||||
this.#httpdProcess.kill("SIGTERM");
|
||||
|
||||
await waitOn({
|
||||
resources: [
|
||||
`tcp:${this.#httpdBaseUrl.hostname}:${this.#httpdBaseUrl.port}`,
|
||||
],
|
||||
reverse: true,
|
||||
timeout: 2000,
|
||||
});
|
||||
|
||||
this.#httpdBaseUrl = undefined;
|
||||
}
|
||||
|
||||
public async startNode(nodeParams: Partial<NodeConfig["node"]> = {}) {
|
||||
const listenPort = await getPort();
|
||||
this.#listenSocketAddr = `0.0.0.0:${listenPort}`;
|
||||
@@ -355,14 +337,13 @@ export class RadiclePeer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill all child processes created with `spawn()`, the node process and the
|
||||
* HTTP API process.
|
||||
* Kill all child processes created with `spawn()`, including the node and
|
||||
* httpd processes.
|
||||
*/
|
||||
public async shutdown() {
|
||||
// We don’t care about proper cleanup. We just want to make sure that no
|
||||
// processes are running anymore.
|
||||
this.#childProcesses.forEach(p => p.kill("SIGKILL"));
|
||||
await Promise.all([this.stopNode(), this.stopHttpd()]);
|
||||
}
|
||||
|
||||
public get address(): string {
|
||||
|
||||
Reference in New Issue
Block a user