-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: support probe e2e tests (#509)
* feat: move to single setup file * feat: make e2e folder independent * feat: move e2e tests * feat: move .mocharc e2e file inside e2e folder * feat: rename mocharc * feat: use ralative paths in e2e tests * fix: sync workers * feat: await all workers in other utils * feat: use src logger * feat: use src client * feat: calculate number of responses dynamically * feat: remove adopted-probe.ts dependency * feat: pass number of processes to api * feat: small updates * feat: move .mocharc.e2e.cjs back to the root folder * feat: add blacklist e2e tests * fix: fix comment docker command
- Loading branch information
1 parent
b5afcf8
commit 0b478c6
Showing
21 changed files
with
221 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
'exit': true, | ||
'timeout': 20000, | ||
'check-leaks': true, | ||
'file': [ | ||
path.join(__dirname, 'test/e2e/setup.ts'), | ||
], | ||
'spec': [ | ||
path.join(__dirname, 'test/e2e/cases/**/*.test.ts'), | ||
], | ||
'node-option': [ | ||
'experimental-specifier-resolution=node', | ||
'loader=ts-node/esm', | ||
], | ||
'globals': [ | ||
'__extends', | ||
'__assign', | ||
'__rest', | ||
'__decorate', | ||
'__param', | ||
'__metadata', | ||
'__awaiter', | ||
'__generator', | ||
'__exportStar', | ||
'__createBinding', | ||
'__values', | ||
'__read', | ||
'__spread', | ||
'__spreadArrays', | ||
'__spreadArray', | ||
'__await', | ||
'__asyncGenerator', | ||
'__asyncDelegator', | ||
'__asyncValues', | ||
'__makeTemplateObject', | ||
'__importStar', | ||
'__importDefault', | ||
'__classPrivateFieldGet', | ||
'__classPrivateFieldSet', | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
test/tests/e2e/cases/adopted-probes.test.ts → test/e2e/cases/adopted-probes.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import config from 'config'; | ||
import Bluebird from 'bluebird'; | ||
import type { Knex } from 'knex'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import chai from 'chai'; | ||
import { createClient } from 'redis'; | ||
|
||
import { waitProbeToConnect } from './utils.js'; | ||
import chaiOas from '../plugins/oas/index.js'; | ||
import { docker } from './docker.js'; | ||
import { client as sql } from '../../src/lib/sql/client.js'; | ||
|
||
before(async () => { | ||
chai.use(await chaiOas({ specPath: path.join(fileURLToPath(new URL('.', import.meta.url)), '../../public/v1/spec.yaml') })); | ||
|
||
await docker.removeProbeContainer(); | ||
await docker.removeApiContainer(); | ||
|
||
await flushRedis(); | ||
|
||
await dropAllTables(sql); | ||
await sql.migrate.latest(); | ||
await sql.seed.run(); | ||
|
||
await docker.createApiContainer(); | ||
await docker.createProbeContainer(); | ||
|
||
await waitProbeToConnect(); | ||
}); | ||
|
||
after(async () => { | ||
await docker.removeProbeContainer(); | ||
await docker.removeApiContainer(); | ||
}); | ||
|
||
const dropAllTables = async (sql: Knex) => { | ||
const allTables = (await sql('information_schema.tables') | ||
.whereRaw(`table_schema = database()`) | ||
.select(`table_name as table`) | ||
).map(({ table }: { table: string }) => table); | ||
await Bluebird.map(allTables, table => sql.schema.raw(`drop table \`${table}\``)); | ||
}; | ||
|
||
const flushRedis = async () => { | ||
const dbs = [ 0, 1, 2 ]; | ||
await Promise.all(dbs.map(async (database) => { | ||
const client = createClient({ | ||
...config.util.toObject(config.get('redis')), | ||
database, | ||
}); | ||
await client.connect(); | ||
await client.flushDb(); | ||
})); | ||
}; |
Oops, something went wrong.