ydb-sdk
Version:
Node.js bindings for working with YDB API over gRPC
43 lines (42 loc) • 2.01 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
if (process.env.TEST_ENVIRONMENT === 'dev')
require('dotenv').config();
const http_1 = __importDefault(require("http"));
const utils_1 = require("../../../utils");
const test_1 = require("../../../utils/test");
const SHUTDOWN_URL = process.env.YDB_SHUTDOWN_URL || 'http://localhost:8765/actors/kqp_proxy?force_shutdown=all';
if (process.env.TEST_ENVIRONMENT === 'dev')
require('dotenv').config();
describe('Graceful session close', () => {
// TODO: Fix and enable test nce issue will be resolved https://github.com/ydb-platform/ydb/issues/2981
// TODO: Make the same test for query service
let driver;
afterAll(async () => await (0, test_1.destroyDriver)(driver));
xit('All sessions should be closed from the server side and be deleted upon return to the pool', async () => {
const PREALLOCATED_SESSIONS = 10;
driver = await (0, test_1.initDriver)({ poolSettings: {
maxLimit: PREALLOCATED_SESSIONS,
minLimit: PREALLOCATED_SESSIONS
} });
// give time for the asynchronous session creation to finish before shutting down all existing sessions
await (0, utils_1.sleep)(100);
await http_1.default.get(SHUTDOWN_URL); // TODO: !!! Seems was broken
let sessionsToClose = 0;
const promises = [];
for (let i = 0; i < 200; i++) {
const promise = driver.tableClient.withSessionRetry(async (session) => {
await session.executeQuery('SELECT Random(1);');
if (session.isClosing()) {
sessionsToClose++;
}
});
promises.push(promise);
}
await Promise.all(promises);
expect(sessionsToClose).toBeGreaterThanOrEqual(PREALLOCATED_SESSIONS);
});
});