Skip to content

Commit

Permalink
Fix the rest of the tests in group2
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoldevila committed Sep 23, 2024
1 parent bb9fe78 commit 04f7bf8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,13 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
corruptDocumentIds: [],
transformErrors: [],
progress: createInitialProgress(),
logs: [
...logs,
{
level: 'info',
message: `REINDEX_SOURCE_TO_TEMP_OPEN_PIT PitId:${res.right.pitId}`,
},
],
};
} else {
throwBadResponse(stateP, res);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { join } from 'path';
import { omit } from 'lodash';
import JSON5 from 'json5';
import type { TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import type { MigrationResult } from '@kbn/core-saved-objects-base-server-internal';

Expand Down Expand Up @@ -105,6 +106,7 @@ describe('v2 migration', () => {
describe('to a newer stack version', () => {
describe('with unknown types', () => {
let unknownTypesKit: KibanaMigratorTestKit;
let logs: string;

beforeAll(async () => {
await clearLog(logFilePath);
Expand All @@ -126,19 +128,20 @@ describe('v2 migration', () => {
To proceed with the migration you can configure Kibana to discard unknown saved objects for this migration.
Please refer to https://www.elastic.co/guide/en/kibana/master/resolve-migrations-failures.html for more information."
`);
const logs = await readLog(logFilePath);
logs = await readLog(logFilePath);
expect(logs).toMatch(
'The flag `migrations.discardUnknownObjects` is defined but does not match the current kibana version; unknown objects will NOT be discarded.'
);
expect(logs).toMatch(
`Unable to complete saved object migrations for the [${defaultKibanaIndex}] index: Migration failed because some documents were found which use unknown saved object types: deprecated`
`[${defaultKibanaIndex}] Migration failed because some documents were found which use unknown saved object types: deprecated`
);
expect(logs).toMatch(`[${defaultKibanaIndex}] CHECK_UNKNOWN_DOCUMENTS -> FATAL.`);
});
});

describe('with transform errors', () => {
let transformErrorsKit: KibanaMigratorTestKit;
let logs: string;

beforeAll(async () => {
await clearLog(logFilePath);
Expand Down Expand Up @@ -167,12 +170,32 @@ describe('v2 migration', () => {
});

it('fails if Kibana is not configured to discard transform errors', async () => {
const logs = await readLog(logFilePath);
logs = await readLog(logFilePath);
expect(logs).toMatch(
`Cannot convert 'complex' objects with values that are multiple of 100`
);
expect(logs).toMatch(`[${defaultKibanaIndex}] REINDEX_SOURCE_TO_TEMP_READ -> FATAL.`);
});

it('closes reindex PIT upon failure', async () => {
const lineWithPit = logs
.split('\n')
.find((line) =>
line.includes(`[${defaultKibanaIndex}] REINDEX_SOURCE_TO_TEMP_OPEN_PIT PitId:`)
);

expect(lineWithPit).toBeTruthy();

const id = JSON5.parse(lineWithPit!).message.split(':')[1];
expect(id).toBeTruthy();

await expect(
transformErrorsKit.client.search({
pit: { id },
})
// throws an exception that cannot search with closed PIT
).rejects.toThrow(/search_phase_execution_exception/);
});
});

describe('configured to discard transform errors and unknown types', () => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ async function createRoot({ logFileName }: CreateRootConfig) {
// suite is very long, the 10mins default can cause timeouts
jest.setTimeout(15 * 60 * 1000);

// FLAKY: https://github.com/elastic/kibana/issues/156117
describe.skip('migration v2', () => {
describe('migration v2', () => {
let esServer: TestElasticsearchUtils;
let rootA: Root;
let rootB: Root;
Expand Down

0 comments on commit 04f7bf8

Please sign in to comment.