[7.x] [jest] use circus runner for the integration tests (#102782) (#102948)

* [jest] use circus runner for the integration tests (#102782)

* use circus runner for integration tests

* do not use done callback. https://github.com/facebook/jest/issues/10529

* fix type error

* disable reporting for so 100k migration

Co-authored-by: Mikhail Shustov <restrry@gmail.com>
This commit is contained in:
Kibana Machine 2021-06-22 14:54:55 -04:00 committed by GitHub
parent d00d0d2a55
commit be8aea6786
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 27 deletions

View file

@ -13,7 +13,6 @@ module.exports = {
rootDir: '.',
roots: ['<rootDir>/src', '<rootDir>/packages'],
testMatch: ['**/integration_tests**/*.test.{js,mjs,ts,tsx}'],
testRunner: 'jasmine2',
testPathIgnorePatterns: preset.testPathIgnorePatterns.filter(
(pattern) => !pattern.includes('integration_tests')
),

View file

@ -163,24 +163,24 @@ describe('KibanaRequest', () => {
describe('events', () => {
describe('aborted$', () => {
it('emits once and completes when request aborted', async (done) => {
it('emits once and completes when request aborted', async () => {
expect.assertions(1);
const { server: innerServer, createRouter } = await server.setup(setupDeps);
const router = createRouter('/');
const nextSpy = jest.fn();
router.get({ path: '/', validate: false }, async (context, request, res) => {
request.events.aborted$.subscribe({
next: nextSpy,
complete: () => {
expect(nextSpy).toHaveBeenCalledTimes(1);
done();
},
});
// prevents the server to respond
await delay(30000);
return res.ok({ body: 'ok' });
const done = new Promise<void>((resolve) => {
router.get({ path: '/', validate: false }, async (context, request, res) => {
request.events.aborted$.subscribe({
next: nextSpy,
complete: resolve,
});
// prevents the server to respond
await delay(30000);
return res.ok({ body: 'ok' });
});
});
await server.start();
@ -191,6 +191,8 @@ describe('KibanaRequest', () => {
.end();
setTimeout(() => incomingRequest.abort(), 50);
await done;
expect(nextSpy).toHaveBeenCalledTimes(1);
});
it('completes & does not emit when request handled', async () => {
@ -299,25 +301,24 @@ describe('KibanaRequest', () => {
expect(completeSpy).toHaveBeenCalledTimes(1);
});
it('emits once and completes when response is aborted', async (done) => {
it('emits once and completes when response is aborted', async () => {
expect.assertions(2);
const { server: innerServer, createRouter } = await server.setup(setupDeps);
const router = createRouter('/');
const nextSpy = jest.fn();
router.get({ path: '/', validate: false }, async (context, req, res) => {
req.events.completed$.subscribe({
next: nextSpy,
complete: () => {
expect(nextSpy).toHaveBeenCalledTimes(1);
done();
},
});
const done = new Promise<void>((resolve) => {
router.get({ path: '/', validate: false }, async (context, req, res) => {
req.events.completed$.subscribe({
next: nextSpy,
complete: resolve,
});
expect(nextSpy).not.toHaveBeenCalled();
await delay(30000);
return res.ok({ body: 'ok' });
expect(nextSpy).not.toHaveBeenCalled();
await delay(30000);
return res.ok({ body: 'ok' });
});
});
await server.start();
@ -327,6 +328,8 @@ describe('KibanaRequest', () => {
// end required to send request
.end();
setTimeout(() => incomingRequest.abort(), 50);
await done;
expect(nextSpy).toHaveBeenCalledTimes(1);
});
});
});

View file

@ -71,6 +71,12 @@ describe('migration v2', () => {
},
],
},
// reporting loads headless browser, that prevents nodejs process from exiting.
xpack: {
reporting: {
enabled: false,
},
},
},
{
oss,

View file

@ -70,6 +70,12 @@ describe('migration from 7.7.2-xpack with 100k objects', () => {
},
],
},
// reporting loads headless browser, that prevents nodejs process from exiting.
xpack: {
reporting: {
enabled: false,
},
},
},
{
oss,

View file

@ -17,7 +17,7 @@ const kibanaVersion = Env.createDefault(REPO_ROOT, getEnvOptions()).packageInfo.
const savedObjectIndex = `.kibana_${kibanaVersion}_001`;
describe('uiSettings/routes', function () {
jest.setTimeout(10000);
jest.setTimeout(120_000);
beforeAll(startServers);
/* eslint-disable jest/valid-describe */

View file

@ -75,8 +75,10 @@ export function getServices() {
export async function stopServers() {
services = null!;
if (servers) {
if (esServer) {
await esServer.stop();
}
if (kbn) {
await kbn.stop();
}
}