From edc2ba820620747f984f5a9612232097880be865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Tainon?= Date: Fri, 1 Dec 2023 18:40:18 +0100 Subject: [PATCH] Cleanup tests --- .circleci/config.yml | 2 +- features/steps/server_steps.ts | 9 +++++++++ features/support/hooks.ts | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 90b45f8..5b8f8d8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,7 +25,7 @@ jobs: TEST_MODE_PLATFORM_NAME: codecast-test TEST_MODE_USER_ID: 1 GRADER_QUEUE_DEBUG_PASSWORD: test - CODECAST_DEBUGGERS_URL: ws://127.0.0.1:9997/remote-execution + CODECAST_DEBUGGERS_URL: ws://127.0.0.1:9003 steps: - checkout - node/install-packages: diff --git a/features/steps/server_steps.ts b/features/steps/server_steps.ts index 1356626..2dcc558 100644 --- a/features/steps/server_steps.ts +++ b/features/steps/server_steps.ts @@ -83,6 +83,15 @@ interface WebSocketData { const openServers: {[key: string]: WebSocketData} = {}; const activeConnections: {[serverName: string]: ws.WebSocket} = {}; +export function closeOpenServers(): void { + for (const server of Object.values(openServers)) { + server.wss.close(); + } + for (const activeConnection of Object.values(activeConnections)) { + activeConnection.close(); + } +} + When(/^I connect to the "([^"]*)" WS server$/, async function (this: ServerStepsContext, serverName: string) { const newWebSocket = new ws.WebSocket(`ws://127.0.0.1:${openServers[serverName].port}`); diff --git a/features/support/hooks.ts b/features/support/hooks.ts index 2340563..bad7e33 100644 --- a/features/support/hooks.ts +++ b/features/support/hooks.ts @@ -8,6 +8,7 @@ import {init} from '../../src/server'; import chai from 'chai'; import chaiSubset from 'chai-subset'; import {setRandomIdGenerator} from '../../src/util'; +import {closeOpenServers} from '../steps/server_steps'; chai.use(chaiSubset); let testServer: Server; @@ -51,6 +52,7 @@ Before(async function () { AfterAll(async function () { await testServer.stop({timeout: 0}); await Db.closePool(); + closeOpenServers(); }); async function cleanDatabase(): Promise {