Attach synapse logs to failed Playwright test runs (#12027)

* Attach synapse logs to failed Playwright test runs

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update playwright/plugins/homeserver/index.ts

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2023-12-14 13:49:35 +00:00 committed by GitHub
parent 18f11b8024
commit d5a211c774
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 5 deletions

View file

@ -81,7 +81,7 @@ export class Dendrite extends Synapse implements Homeserver, HomeserverInstance
return this;
}
public async stop(): Promise<void> {
public async stop(): Promise<string[]> {
if (!this.config) throw new Error("Missing existing dendrite instance, did you call stop() before start()?");
const dendriteLogsPath = path.join("playwright", "dendritelogs", this.config.serverId);
@ -97,6 +97,8 @@ export class Dendrite extends Synapse implements Homeserver, HomeserverInstance
await fse.remove(this.config.configDir);
console.log(`Stopped dendrite id ${this.config.serverId}.`);
return [path.join(dendriteLogsPath, "stdout.log"), path.join(dendriteLogsPath, "stderr.log")];
}
}

View file

@ -53,7 +53,12 @@ export interface StartHomeserverOpts {
export interface Homeserver {
start(opts: StartHomeserverOpts): Promise<HomeserverInstance>;
stop(): Promise<void>;
/**
* Stop this test homeserver instance.
*
* @returns A list of paths relative to the cwd for logfiles generated during this test run.
*/
stop(): Promise<string[]>;
}
export interface Credentials {

View file

@ -150,7 +150,7 @@ export class Synapse implements Homeserver, HomeserverInstance {
return this;
}
public async stop(): Promise<void> {
public async stop(): Promise<string[]> {
if (!this.config) throw new Error("Missing existing synapse instance, did you call stop() before start()?");
const id = this.config.serverId;
const synapseLogsPath = path.join("playwright", "synapselogs", id);
@ -162,6 +162,8 @@ export class Synapse implements Homeserver, HomeserverInstance {
await this.docker.stop();
await fse.remove(this.config.configDir);
console.log(`Stopped synapse id ${id}.`);
return [path.join(synapseLogsPath, "stdout.log"), path.join(synapseLogsPath, "stderr.log")];
}
public async registerUser(username: string, password: string, displayName?: string): Promise<Credentials> {