Skip to content

Commit

Permalink
fix bug in executing multiple testcases with postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
MIYASHITA, Akihiro committed Jun 7, 2024
1 parent e07c7c6 commit ce6fb78
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
23 changes: 11 additions & 12 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class PostgreSQLCasette {
});
}

async function connect() {
async function startServer() {
return new Promise((_res, _rej) => {
let done = false;
const res = (...args) => {
Expand Down Expand Up @@ -178,19 +178,18 @@ class PostgreSQLCasette {
});
}

for (let retries = 5; retries > 0; retries--) {
if (fs.existsSync('/var/lib/postgresql/data/postmaster.pid')) {
fs.unlinkSync('/var/lib/postgresql/data/postmaster.pid');
}
try {
await connect();
break;
} catch (e) {
if (options.verbose) {
console.error(e);
if (!fs.existsSync('/var/run/postgresql/.s.PGSQL.5432')) {
for (let retries = 5; retries > 0; retries--) {
try {
await startServer();
break;
} catch (e) {
if (options.verbose) {
console.error(e);
}
}
await sleep(1000);
}
await sleep(1000);
}

for (let retries = 20; retries > 0; retries--) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "track-db-test-library",
"version": "2.5.0-rc3",
"version": "2.5.0-rc4",
"description": "Test utility for Track database challenges",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ce6fb78

Please sign in to comment.