Skip to content

Commit

Permalink
HARMONY-1538: Move test dB to local directories to
Browse files Browse the repository at this point in the history
fix issues when running tests in parallel
  • Loading branch information
indiejames committed Oct 12, 2023
1 parent 0dacf0b commit 243aa34
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 144 deletions.
3 changes: 2 additions & 1 deletion bin/create-database
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ if [ -f $database ]; then
fi

echo "Creating database $database"
cat db/db.sql | sqlite3 $database
dir=$(dirname "$0")
cat "$dir/../db/db.sql" | sqlite3 $database
3 changes: 2 additions & 1 deletion db/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const migrations = { directory: path.resolve(__dirname, 'migrations') };
const sqliteConfig = {
client: 'sqlite3',
connection: {
filename: path.resolve(__dirname, 'test.sqlite3'),
filename: path.resolve('db', 'test.sqlite3'),
// filename: path.resolve(__dirname, 'test.sqlite3'),
},
useNullAsDefault: true,
migrations,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
"test": "lerna run test",
"test-fast": "lerna run test-fast",
"test-bail": "lerna run test-bail",
"coverage": "lerna run --concurrency 1 coverage",
"coverage": "lerna run coverage",
"lint": "lerna run lint",
"start": "cd services/harmony && NODE_OPTIONS=--max-old-space-size=3096 ts-node -r tsconfig-paths/register app/server.ts",
"start-dev": "cd servcies/harmony && strict-npm-engines && ts-node-dev --no-notify -r tsconfig-paths/register --watch app/views,public/js --respawn app/server",
"start-dev-fast": "cd services/harmony && TS_NODE_TRANSPILE_ONLY=true ts-node-dev --no-notify -r tsconfig-paths/register --respawn --inspect=127.0.0.1:${DEBUG_PORT:-9200} app/server",
"update-dev": "npm install && lerna run build && bin/restart-services",
"watch-debug": "cd servcies/harmony && TS_NODE_TRANSPILE_ONLY=true nodemon --inspect=5858 -e ts,tsx,html --exec node -r tsconfig-paths/register -r ts-node/register app/server.ts",
"postinstall": "if test \"$NODE_ENV\" != \"production\" && test \"$LERNA\" != \"false\" ; then lerna exec -- npm install; fi",
"build": "lerna run build --scope=harmony -- VERSION=${VERSION:-latest}",
"build-all": "lerna exec -- VERSION=${VERSION:-latest} npm run build-m1",
"build": "lerna exec --scope=harmony -- VERSION=${VERSION:-latest} npm run build",
"build-all": "lerna exec --ignore harmony -- VERSION=${VERSION:-latest} npm run build",
"build-all-m1": "lerna exec --ignore harmony -- VERSION=${VERSION:-latest} npm run build-m1",
"push-image-all": "lerna exec --ignore harmony --ignore @harmony/util --concurrency 1 -- ./bin/push-image ${VERSION:-latest}",
"build-notebooks-image": "docker build --platform linux/amd64 -t harmonyservices/notebooks:${VERSION:-latest} -f Dockerfile-notebooks .",
Expand Down
Empty file added services/harmony/db/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions services/harmony/test/helpers/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export async function truncateAll(): Promise<void> {
await Promise.all(tables.map((t) => db(t).truncate()));
}

const createDatabaseCommand = './bin/create-database -o test';
const createDatabaseCommand = '../../bin/create-database -o test';

/**
* Recreates the test database
* Note this is done because database migrations do not work for sqlite
*/
async function recreateDatabase(): Promise<void> {
return exec(createDatabaseCommand, { 'cwd': '../..' });
return exec(createDatabaseCommand);
}

before(async function () {
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion services/work-failer/test/helpers/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function truncateAll(): Promise<void> {
await Promise.all(tables.map((t) => db(t).truncate()));
}

const createDatabaseCommand = './bin/create-database -o test';
const createDatabaseCommand = '../../bin/create-database -o test';

/**
* Recreates the test database
Expand Down
Empty file.
135 changes: 0 additions & 135 deletions services/work-reaper/db/db.sql

This file was deleted.

2 changes: 1 addition & 1 deletion services/work-reaper/test/helpers/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function truncateAll(): Promise<void> {
await Promise.all(tables.map((t) => db(t).truncate()));
}

const createDatabaseCommand = './bin/create-database -o test';
const createDatabaseCommand = '../../bin/create-database -o test';

/**
* Recreates the test database
Expand Down

0 comments on commit 243aa34

Please sign in to comment.