Skip to content

Commit

Permalink
Get rid of the infamous 10s delay in Core's integration tests (elas…
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Jul 11, 2024
1 parent 526a232 commit a68bea5
Show file tree
Hide file tree
Showing 44 changed files with 21 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ describe('migration from 7.13 to 7.14+ with many failed action_tasks', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

const getCounts = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ describe('migration v2', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

describe('when `discardUnknownObjects` does not match current kibana version', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ describe('migration v2', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('completes the migration even when a full batch would exceed ES http.max_content_length', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ describe('migration v2', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('fails with a descriptive message when maxBatchSizeBytes exceeds ES http.max_content_length', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
createTestServers,
type TestElasticsearchUtils,
} from '@kbn/core-test-helpers-kbn-server';
import { delay } from '../test_utils';

const logFilePath = Path.join(__dirname, 'check_target_mappings.log');

Expand All @@ -33,7 +32,6 @@ describe('migration v2 - CHECK_TARGET_MAPPINGS', () => {
afterEach(async () => {
await root?.shutdown();
await esServer?.stop();
await delay(10);
});

it('is not run for new installations', async () => {
Expand Down Expand Up @@ -80,7 +78,6 @@ describe('migration v2 - CHECK_TARGET_MAPPINGS', () => {

// stop Kibana and remove logs
await root.shutdown();
await delay(10);
await fs.unlink(logFilePath).catch(() => {});

root = createRoot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import JSON5 from 'json5';
import { type TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import { SavedObjectsType } from '@kbn/core-saved-objects-server';
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { getMigrationDocLink, delay } from '../test_utils';
import { getMigrationDocLink } from '../test_utils';
import {
clearLog,
currentVersion,
Expand Down Expand Up @@ -71,7 +71,6 @@ describe('migration v2', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ describe('migration v2 with corrupt saved object documents', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('collects corrupt saved object documents across batches', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ describe('migration v2 with corrupt saved object documents', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it.skip('collects corrupt saved object documents across batches', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ describe.skip('migration v2', () => {

if (esServer) {
await esServer.stop();
await delay(10000);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ describe('migration v2', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('migrates the documents to the highest version', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type {
SavedObjectsType,
SavedObjectUnsanitizedDoc,
} from '@kbn/core-saved-objects-server';
import { delay } from '../test_utils';

import '../jest_matchers';
import {
Expand All @@ -36,7 +35,6 @@ describe('deferred migrations', () => {

afterAll(async () => {
await server?.stop();
await delay(10);
});

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ describe('migrating from 7.3.0-xpack which used v1 migrations', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
};

beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ describe('migration v2', () => {
await removeLogFile();
});

afterAll(async () => {
await new Promise((resolve) => setTimeout(resolve, 10000));
});

afterEach(async () => {
if (root) {
await root.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
createRootWithCorePlugins,
type TestElasticsearchUtils,
} from '@kbn/core-test-helpers-kbn-server';
import { delay } from '../test_utils';
import { startElasticsearch } from '../kibana_migrator_test_kit';

const logFilePath = Path.join(__dirname, 'read_batch_size.log');
Expand All @@ -33,7 +32,6 @@ describe('migration v2 - read batch size', () => {
afterEach(async () => {
await root?.shutdown();
await esServer?.stop();
await delay(10);
});

it('reduces the read batchSize in half if a batch exceeds maxReadBatchSizeBytes', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ describe('migration v2', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('rewrites id deterministically for SO with namespaceType: "multiple" and "multiple-isolated"', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ describe('starting with `migration.skip: true` when indices are up to date', ()
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('starts and display the correct service status', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ describe('migration with waitForCompletion=true', () => {
if (esServer) {
await esServer.stop();
}

await new Promise((resolve) => setTimeout(resolve, 10000));
});

it('waits for another instance to complete the migration', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
readLog,
startElasticsearch,
} from '../kibana_migrator_test_kit';
import { delay, createType } from '../test_utils';
import { createType } from '../test_utils';
import '../jest_matchers';

const logFilePath = Path.join(__dirname, 'v2_md5_to_mv.test.log');
Expand Down Expand Up @@ -270,6 +270,5 @@ describe('V2 algorithm', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SavedObjectsBulkCreateObject } from '@kbn/core-saved-objects-api-server
import { modelVersionToVirtualVersion } from '@kbn/core-saved-objects-base-server-internal';
import '../jest_matchers';
import { getKibanaMigratorTestKit, startElasticsearch } from '../kibana_migrator_test_kit';
import { delay, createType, parseLogFile } from '../test_utils';
import { createType, parseLogFile } from '../test_utils';
import { getBaseMigratorParams } from '../fixtures/zdt_base.fixtures';

const logFilePath = Path.join(__dirname, 'v2_with_mv_same_stack_version.test.log');
Expand All @@ -31,7 +31,6 @@ describe('V2 algorithm - using model versions - upgrade without stack version in

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

const getTestModelVersionType = ({ beforeUpgrade }: { beforeUpgrade: boolean }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SavedObjectsBulkCreateObject } from '@kbn/core-saved-objects-api-server
import { modelVersionToVirtualVersion } from '@kbn/core-saved-objects-base-server-internal';
import '../jest_matchers';
import { getKibanaMigratorTestKit, startElasticsearch } from '../kibana_migrator_test_kit';
import { delay, createType, parseLogFile } from '../test_utils';
import { createType, parseLogFile } from '../test_utils';
import { getBaseMigratorParams } from '../fixtures/zdt_base.fixtures';

const logFilePath = Path.join(__dirname, 'v2_with_mv_stack_version_bump.test.log');
Expand All @@ -31,7 +31,6 @@ describe('V2 algorithm - using model versions - stack version bump scenario', ()

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

const getTestSwitchType = ({ beforeUpgrade }: { beforeUpgrade: boolean }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
getIncompatibleMappingsMigrator,
getNonDeprecatedMappingsMigrator,
} from '../kibana_migrator_test_kit';
import { delay } from '../test_utils';

describe('when upgrading to a new stack version', () => {
let esServer: TestElasticsearchUtils['es'];
Expand All @@ -34,7 +33,6 @@ describe('when upgrading to a new stack version', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

describe('if the mappings match (diffMappings() === false)', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
startElasticsearch,
} from '../kibana_migrator_test_kit';
import { baselineTypes } from './active_delete.fixtures';
import { delay } from '../test_utils';
import { createBaselineArchive } from '../kibana_migrator_archive_utils';

const PARALLEL_MIGRATORS = 6;
Expand Down Expand Up @@ -146,7 +145,6 @@ describe('multiple migrator instances running in parallel', () => {
afterAll(async () => {
// await esClient?.indices.delete({ index: `${kibanaIndex}_${currentVersion}_001` });
await esServer?.stop();
await delay(10);
});

const getAggregatedTypesCount = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
startElasticsearch,
KibanaMigratorTestKit,
} from '../kibana_migrator_test_kit';
import { delay } from '../test_utils';

describe('when migrating to a new version', () => {
let esServer: TestElasticsearchUtils['es'];
Expand Down Expand Up @@ -144,6 +143,5 @@ describe('when migrating to a new version', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { range, sortBy } from 'lodash';
import { SavedObjectsBulkCreateObject } from '@kbn/core-saved-objects-api-server';
import '../../jest_matchers';
import { getKibanaMigratorTestKit } from '../../kibana_migrator_test_kit';
import { delay, parseLogFile } from '../../test_utils';
import { parseLogFile } from '../../test_utils';
import { EsRunner, EsServer } from '../../test_types';
import {
getBaseMigratorParams,
Expand All @@ -35,7 +35,6 @@ export function createBasicDocumentsMigrationTest({

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

const createBaseline = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { range } from 'lodash';
import { SavedObjectsBulkCreateObject } from '@kbn/core-saved-objects-api-server';
import '../../jest_matchers';
import { getKibanaMigratorTestKit } from '../../kibana_migrator_test_kit';
import { delay, parseLogFile } from '../../test_utils';
import { parseLogFile } from '../../test_utils';
import { EsRunner, EsServer } from '../../test_types';
import {
getBaseMigratorParams,
Expand All @@ -36,7 +36,6 @@ export function createStandardWorkflowTest({

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

const createBaseline = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { type TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import { SavedObjectsBulkCreateObject } from '@kbn/core-saved-objects-api-server';
import '../jest_matchers';
import { getKibanaMigratorTestKit, startElasticsearch } from '../kibana_migrator_test_kit';
import { delay, parseLogFile, createType } from '../test_utils';
import { parseLogFile, createType } from '../test_utils';
import { getBaseMigratorParams } from '../fixtures/zdt_base.fixtures';

export const logFilePath = Path.join(__dirname, 'basic_downgrade.test.log');
Expand All @@ -28,7 +28,6 @@ describe('ZDT upgrades - basic downgrade', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

const typeV1 = createType({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { type TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import { SavedObjectsBulkCreateObject } from '@kbn/core-saved-objects-api-server';
import '../jest_matchers';
import { getKibanaMigratorTestKit, startElasticsearch } from '../kibana_migrator_test_kit';
import { delay, parseLogFile } from '../test_utils';
import { parseLogFile } from '../test_utils';
import {
getBaseMigratorParams,
getSampleAType,
Expand All @@ -31,7 +31,6 @@ describe('ZDT upgrades - encountering conversion failures', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import fs from 'fs/promises';
import '../jest_matchers';
import { type TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import { getKibanaMigratorTestKit, startElasticsearch } from '../kibana_migrator_test_kit';
import { delay, parseLogFile } from '../test_utils';
import { parseLogFile } from '../test_utils';
import { getBaseMigratorParams, getFooType, getBarType } from '../fixtures/zdt_base.fixtures';

export const logFilePath = Path.join(__dirname, 'create_index.test.log');
Expand All @@ -26,7 +26,6 @@ describe('ZDT upgrades - running on a fresh cluster', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

it('create the index with the correct mappings and meta', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { SearchResponse } from '@elastic/elasticsearch/lib/api/types';
import { type TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import { SavedObjectsBulkCreateObject } from '@kbn/core-saved-objects-api-server';
import { getKibanaMigratorTestKit, startElasticsearch } from '../kibana_migrator_test_kit';
import { delay } from '../test_utils';
import {
getBaseMigratorParams,
getDeletedType,
Expand All @@ -35,7 +34,6 @@ describe('ZDT upgrades - document cleanup', () => {

afterAll(async () => {
await esServer?.stop();
await delay(10);
});

const createBaseline = async () => {
Expand Down
Loading

0 comments on commit a68bea5

Please sign in to comment.