diff --git a/cucumber.js b/cucumber.js index 2008e25c..82ec9847 100644 --- a/cucumber.js +++ b/cucumber.js @@ -11,7 +11,6 @@ const config = [ '--format @cucumber/pretty-formatter', '--format html:.test-reports/integration/report.html', '--format json:.test-reports/integration/report.json', - '--publish', ].join(' ') module.exports = { diff --git a/src/app/worker.ts b/src/app/worker.ts index b5cce811..1693595a 100644 --- a/src/app/worker.ts +++ b/src/app/worker.ts @@ -1,6 +1,7 @@ import { IRunnable } from '../@types/base' import { IWebSocketServerAdapter } from '../@types/adapters' +import { closeCacheClient } from '../cache/client' import { createLogger } from '../factories/logger-factory' import { FSWatcher } from 'fs' import { SettingsStatic } from '../utils/settings' @@ -57,7 +58,10 @@ export class AppWorker implements IRunnable { watcher.close() } } - this.adapter.close(callback) + this.adapter.close(async () => { + await closeCacheClient() + callback?.() + }) debug('closed') } } diff --git a/src/cache/client.ts b/src/cache/client.ts index 8c743753..3d3ce584 100644 --- a/src/cache/client.ts +++ b/src/cache/client.ts @@ -23,3 +23,10 @@ export const getCacheClient = (): CacheClient => { return instance } + +export const closeCacheClient = async (): Promise => { + if (instance?.isOpen) { + await instance.disconnect() + instance = undefined + } +} diff --git a/test/integration/features/shared.ts b/test/integration/features/shared.ts index d515d00f..768e77cb 100644 --- a/test/integration/features/shared.ts +++ b/test/integration/features/shared.ts @@ -16,10 +16,8 @@ import Sinon from 'sinon' import { connect, createIdentity, createSubscription, sendEvent } from './helpers' import { getMasterDbClient, getReadReplicaDbClient } from '../../../src/database/client' import { AppWorker } from '../../../src/app/worker' -import { CacheClient } from '../../../src/@types/cache' import { DatabaseClient } from '../../../src/@types/base' import { Event } from '../../../src/@types/event' -import { getCacheClient } from '../../../src/cache/client' import { SettingsStatic } from '../../../src/utils/settings' import { workerFactory } from '../../../src/factories/worker-factory' @@ -29,7 +27,6 @@ let worker: AppWorker let dbClient: DatabaseClient let rrDbClient: DatabaseClient -let cacheClient: CacheClient export const streams = new WeakMap>() @@ -38,7 +35,6 @@ BeforeAll({ timeout: 1000 }, async function () { process.env.SECRET = Math.random().toString().repeat(6) dbClient = getMasterDbClient() rrDbClient = getReadReplicaDbClient() - cacheClient = getCacheClient() await dbClient.raw('SELECT 1=1') await rrDbClient.raw('SELECT 1=1') Sinon.stub(SettingsStatic, 'watchSettings') @@ -57,13 +53,12 @@ BeforeAll({ timeout: 1000 }, async function () { worker.run() }) -AfterAll(async function() { - worker.close(async () => { - await Promise.all([ - dbClient.destroy(), - rrDbClient.destroy(), - cacheClient.disconnect(), - ]) +AfterAll({ timeout: 30000 }, async function() { + await new Promise((resolve) => { + worker.close(async () => { + await Promise.all([dbClient.destroy(), rrDbClient.destroy()]) + resolve() + }) }) })