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

fix(Postgres Node): Re-use connection pool across executions #12346

Merged
merged 8 commits into from
Dec 27, 2024
Prev Previous commit
Next Next commit
fixup! add connection pool manager and tests
despairblue committed Dec 23, 2024
commit 7e86426bc5e6292a75ddf5efe3138d70e178bf27
31 changes: 11 additions & 20 deletions packages/nodes-base/utils/__tests__/connection-pool-manager.test.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,19 @@ import { ConnectionPoolManager } from '@utils/connection-pool-manager';
const ttl = 5 * 60 * 1000;
const cleanUpInterval = 60 * 1000;

let cpm: ConnectionPoolManager;

beforeAll(() => {
jest.useFakeTimers();
cpm = ConnectionPoolManager.getInstance();
});

beforeEach(async () => {
await cpm.purgeConnections();
});

afterAll(() => {
cpm.onShutdown();
});

test('getInstance returns a singleton', () => {
@@ -15,16 +26,6 @@ test('getInstance returns a singleton', () => {
});

describe('getConnection', () => {
let cpm: ConnectionPoolManager;

beforeAll(() => {
cpm = ConnectionPoolManager.getInstance();
});

beforeEach(async () => {
await cpm.purgeConnections();
});

test('calls fallBackHandler only once and returns the first value', async () => {
// ARRANGE
const connectionType = {};
@@ -105,16 +106,6 @@ describe('getConnection', () => {
});

describe('onShutdown', () => {
let cpm: ConnectionPoolManager;

beforeAll(() => {
cpm = ConnectionPoolManager.getInstance();
});

beforeEach(async () => {
await cpm.purgeConnections();
});

test('calls all clean up handlers', async () => {
// ARRANGE
const connectionType1 = {};