dbgate/integration-tests/wait.js

30 lines
914 B
JavaScript
Raw Normal View History

2021-05-27 07:26:37 +00:00
const requireEngineDriver = require('dbgate-api/src/utility/requireEngineDriver');
const engines = require('./engines');
2021-05-27 11:07:58 +00:00
const { extractConnection } = require('./tools');
2021-05-27 07:26:37 +00:00
global.DBGATE_TOOLS = require('dbgate-tools');
2021-05-27 10:26:20 +00:00
async function connectEngine(engine) {
2021-05-27 11:07:58 +00:00
const connection = extractConnection(engine);
const driver = requireEngineDriver(connection);
2021-05-27 10:26:20 +00:00
for (;;) {
try {
2021-05-27 11:07:58 +00:00
const conn = await driver.connect(connection);
2021-05-27 10:26:20 +00:00
await driver.getVersion(conn);
console.log(`Connect to ${engine.label} - OK`);
await driver.close(conn);
return;
} catch (err) {
console.log(`Waiting for ${engine.label}, error: ${err.message}`);
await new Promise(resolve => setTimeout(resolve, 2500));
continue;
2021-05-27 07:26:37 +00:00
}
}
2021-05-27 07:12:21 +00:00
}
2021-05-27 10:26:20 +00:00
async function run() {
await new Promise(resolve => setTimeout(resolve, 10000));
await Promise.all(engines.map(engine => connectEngine(engine)));
}
2021-05-27 07:12:21 +00:00
run();