Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to reliability of e2e tests #274

Merged
merged 15 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
name: playwright-report
path: ./e2e/playwright-report/
retention-days: 30
- uses: actions/upload-artifact@v4
if: always()
with:
name: server-logs
path: ./e2e/logs/server-logs.log
retention-days: 30
plugin-ci:
uses: mattermost/actions-workflows/.github/workflows/plugin-ci.yml@main
with:
Expand Down
1 change: 1 addition & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
/playwright-report/
/blob-report/
/playwright/.cache/
logs
31 changes: 24 additions & 7 deletions e2e/helpers/mmcontainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultUsername = "admin";
const defaultPassword = "admin";
const defaultTeamName = "test";
const defaultTeamDisplayName = "Test";
const defaultMattermostImage = "mattermost/mattermost-enterprise-edition";
const defaultMattermostImage = "mattermost/mattermost-enterprise-edition:latest";

// MattermostContainer represents the mattermost container type used in the module
export default class MattermostContainer {
Expand All @@ -24,6 +24,7 @@ export default class MattermostContainer {
command: string[];
configFile: any[];
plugins: any[];
private logStream: any;

url(): string {
const containerPort = this.container.getMappedPort(8065)
Expand Down Expand Up @@ -53,6 +54,9 @@ export default class MattermostContainer {
}

stop = async () => {
if (this.logStream) {
this.logStream.end();
}
await this.pgContainer.stop()
await this.container.stop()
await this.network.stop()
Expand Down Expand Up @@ -145,6 +149,7 @@ export default class MattermostContainer {
"MM_LOGSETTINGS_FILELEVEL": "DEBUG",
"MM_SERVICESETTINGS_ENABLEDEVELOPER": "true",
"MM_SERVICESETTINGS_ENABLETESTING": "true",
"MM_PLUGINSETTINGS_AUTOMATICPREPACKAGEDPLUGINS": "false",
};
this.email = defaultEmail;
this.username = defaultUsername;
Expand Down Expand Up @@ -176,12 +181,24 @@ export default class MattermostContainer {
.withWaitStrategy(Wait.forLogMessage("Server is listening on"))
.withCopyFilesToContainer(this.configFile)
.withLogConsumer((stream) => {
stream.on('data', (data: string) => {
if (data.includes('"plugin_id":"mattermost-ai"')) {
console.log(data)
}
})
})
// Create log file with timestamp
const fs = require('fs');
const logDir = 'logs';
if (!fs.existsSync(logDir)){
fs.mkdirSync(logDir);
}
this.logStream = fs.createWriteStream(`${logDir}/server-logs.log`, {flags: 'a'});

stream.on('data', (data: string) => {
// Write all logs to file
this.logStream.write(data + '\n');

// Still maintain special console logging for AI plugin
if (data.includes('"plugin_id":"mattermost-ai"')) {
console.log(data);
}
});
})
.start()


Expand Down
135 changes: 67 additions & 68 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"devDependencies": {
"@mattermost/client": "10.0.0",
"@mattermost/types": "10.0.0",
"@playwright/test": "1.48.0",
"@testcontainers/postgresql": "10.13.2",
"@types/node": "22.7.5",
"pg": "8.13.0",
"testcontainers": "10.13.2"
"@playwright/test": "1.49.1",
"@testcontainers/postgresql": "10.16.0",
"@types/node": "22.10.5",
"pg": "8.13.1",
"testcontainers": "10.16.0"
}
}
Loading
Loading