openvidu-test-integration: keep the server log of each test in the report artifact

pull/916/head
juancarmore 2026-10-24 14:39:17 +02:00
parent cc01a69a96
commit f614fa534b
2 changed files with 14 additions and 1 deletions

View File

@ -56,7 +56,9 @@ jobs:
if: always()
with:
name: openvidu-integration-tests-report
path: ./openvidu/openvidu-test-integration/test-results.json
path: |
./openvidu/openvidu-test-integration/test-results.json
./openvidu/openvidu-test-integration/logs/
retention-days: 7
- name: Cleanup
if: always()

View File

@ -1,6 +1,9 @@
import { mkdirSync } from "fs";
import { join } from "path";
import { execCommand, sleep } from "./helper";
const LOCAL_DEPLOYMENT_PATH = "../../openvidu-local-deployment/community/docker-compose.yaml";
const LOGS_PATH = "logs";
export class LocalDeployment {
static async start() {
@ -19,9 +22,17 @@ export class LocalDeployment {
static stop() {
console.log("Stopping local deployment...");
LocalDeployment.saveServerLogs();
execCommand(`docker compose -f ${LOCAL_DEPLOYMENT_PATH} down -v`);
}
/** Saves the log of the OpenVidu server in logs/, named after the current test, before the deployment is removed. */
private static saveServerLogs() {
const name = (expect.getState().currentTestName ?? "deployment").replace(/[^\w-]+/g, "-");
mkdirSync(LOGS_PATH, { recursive: true });
execCommand(`docker logs openvidu > ${join(LOGS_PATH, `${name}.log`)} 2>&1 || true`);
}
static startContainer(containerName: string) {
console.log(`Starting container ${containerName}...`);
execCommand(`docker compose -f ${LOCAL_DEPLOYMENT_PATH} start ${containerName}`);