Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ import {
getReindexingMigratorTestKit,
getUpToDateMigratorTestKit,
} from '../kibana_migrator_test_kit.fixtures';
import { delay } from '../test_utils';
import { delay, getDocVersion } from '../test_utils';
import { expectDocumentsMigratedToHighestVersion } from '../kibana_migrator_test_kit.expect';

const logFilePath = join(__dirname, 'v2_migration.log');
const docVersion = getDocVersion();

describe('v2 migration', () => {
let esServer: TestElasticsearchUtils;
Expand Down Expand Up @@ -127,7 +128,7 @@ describe('v2 migration', () => {
await expect(unknownTypesKit.runMigrations()).rejects.toThrowErrorMatchingInlineSnapshot(`
"Unable to complete saved object migrations for the [.kibana_migrator] index: Migration failed because some documents were found which use unknown saved object types: deprecated
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."
Please refer to https://www.elastic.co/guide/en/kibana/${docVersion}/resolve-migrations-failures.html for more information."
`);
logs = await readLog(logFilePath);
expect(logs).toMatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ import {
createBulkIndexOperationTuple,
checkClusterRoutingAllocationEnabled,
} from '@kbn/core-saved-objects-migration-server-internal';
import { BASELINE_TEST_ARCHIVE_1K } from '../../kibana_migrator_archive_utils';
import { defaultKibanaIndex } from '../../kibana_migrator_test_kit';

const { startES } = createTestServers({
adjustTimeout: (t: number) => jest.setTimeout(t),
settings: {
es: {
dataArchive: BASELINE_TEST_ARCHIVE_1K,
license: 'basic',
esArgs: ['http.max_content_length=10Kb'],
},
Expand Down Expand Up @@ -1090,13 +1093,13 @@ describe.skip('migration actions', () => {
it('resolves left wait_for_task_completion_timeout when the task does not finish within the timeout', async () => {
await waitForIndexStatus({
client,
index: '.kibana_1',
index: defaultKibanaIndex,
status: 'yellow',
})();

const res = (await reindex({
client,
sourceIndex: '.kibana_1',
sourceIndex: defaultKibanaIndex,
targetIndex: 'reindex_target',
reindexScript: Option.none,
requireAlias: false,
Expand Down Expand Up @@ -1433,7 +1436,7 @@ describe.skip('migration actions', () => {
it('resolves left wait_for_task_completion_timeout when the task does not complete within the timeout', async () => {
const res = (await pickupUpdatedMappings(
client,
'.kibana_1',
defaultKibanaIndex,
1000
)()) as Either.Right<UpdateByQueryResponse>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,36 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import Path from 'path';
import type { TestElasticsearchUtils } from '@kbn/core-test-helpers-kbn-server';
import {
clearLog,
startElasticsearch,
getKibanaMigratorTestKit,
nextMinor,
defaultKibanaIndex,
defaultKibanaTaskIndex,
currentVersion,
} from '../kibana_migrator_test_kit';
import '../jest_matchers';
import { delay, parseLogFile } from '../test_utils';
import { baselineTypes as types } from '../kibana_migrator_test_kit.fixtures';

export const logFilePath = Path.join(__dirname, 'fail_on_rollback.test.log');
import { delay } from '../test_utils';
import { getUpToDateMigratorTestKit } from '../kibana_migrator_test_kit.fixtures';
import { BASELINE_TEST_ARCHIVE_1K } from '../kibana_migrator_archive_utils';

// Failing: See https://github.com/elastic/kibana/issues/193756
describe.skip('when rolling back to an older version', () => {
let esServer: TestElasticsearchUtils['es'];

beforeAll(async () => {
esServer = await startElasticsearch();
esServer = await startElasticsearch({ dataArchive: BASELINE_TEST_ARCHIVE_1K });
});

beforeEach(async () => {});

it('kibana should detect that a later version alias exists, and abort', async () => {
// create a current version baseline
const { runMigrations: createBaseline } = await getKibanaMigratorTestKit({
types,
logFilePath,
});
await createBaseline();

// migrate to next minor
const { runMigrations: upgrade } = await getKibanaMigratorTestKit({
kibanaVersion: nextMinor,
types,
logFilePath,
});
const { runMigrations: upgrade } = await getUpToDateMigratorTestKit();
await upgrade();

// run migrations for the current version again (simulate rollback)
const { runMigrations: rollback } = await getKibanaMigratorTestKit({ types, logFilePath });

await clearLog(logFilePath);
const { runMigrations: rollback } = await getUpToDateMigratorTestKit({
kibanaVersion: currentVersion,
});

try {
await rollback();
Expand All @@ -63,9 +47,6 @@ describe.skip('when rolling back to an older version', () => {
`Unable to complete saved object migrations for the [${defaultKibanaTaskIndex}] index: The ${defaultKibanaTaskIndex}_${nextMinor} alias refers to a newer version of Kibana: v${nextMinor}`,
]).toContain(error.message);
}

const logs = await parseLogFile(logFilePath);
expect(logs).toContainLogEntry(`[${defaultKibanaIndex}] INIT -> FATAL.`);
});

afterAll(async () => {
Expand Down