Fix hardcoded doclinks in SO migration integ tests (#137414) (#137452)

* fix hardcoded doc links in SO migration IT

* unskip tests

* fix link value

(cherry picked from commit a8e5bf4c9f)

Co-authored-by: Pierre Gayvallet <pierre.gayvallet@elastic.co>
This commit is contained in:
Kibana Machine 2022-07-28 10:32:35 -04:00 committed by GitHub
parent e800c11425
commit 75253af029
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 15 deletions

View file

@ -16,7 +16,9 @@ import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
import { Root } from '../../../root';
import { SearchTotalHits } from '@elastic/elasticsearch/lib/api/types';
import { getMigrationDocLink } from './test_utils';
const migrationDocLink = getMigrationDocLink().resolveMigrationFailures;
const logFilePath = Path.join(__dirname, '7_13_corrupt_transform_failures.log');
const asyncUnlink = Util.promisify(Fs.unlink);
@ -26,8 +28,7 @@ async function removeLogFile() {
await asyncUnlink(logFilePath).catch(() => void 0);
}
// FAILING ON 8.4: https://github.com/elastic/kibana/issues/137329
describe.skip('migration v2', () => {
describe('migration v2', () => {
let esServer: kbnTestServer.TestElasticsearchUtils;
let root: Root;
@ -87,7 +88,7 @@ describe.skip('migration v2', () => {
To allow migrations to proceed, please delete or fix these documents.
Note that you can configure Kibana to automatically discard corrupt documents and transform errors for this migration.
Please refer to https://www.elastic.co/guide/en/kibana/master/resolve-migrations-failures.html for more information."
Please refer to ${migrationDocLink} for more information."
`);
return;
}

View file

@ -12,7 +12,9 @@ import Util from 'util';
import JSON5 from 'json5';
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
import type { Root } from '../../../root';
import { getMigrationDocLink } from './test_utils';
const migrationDocLink = getMigrationDocLink().resolveMigrationFailures;
const logFilePath = Path.join(__dirname, 'cleanup.log');
const asyncUnlink = Util.promisify(Fs.unlink);
@ -54,8 +56,7 @@ function createRoot() {
);
}
// FAILING ON 8.4: https://github.com/elastic/kibana/issues/137331
describe.skip('migration v2', () => {
describe('migration v2', () => {
let esServer: kbnTestServer.TestElasticsearchUtils;
let root: Root;
@ -119,7 +120,7 @@ describe.skip('migration v2', () => {
To allow migrations to proceed, please delete or fix these documents.
Note that you can configure Kibana to automatically discard corrupt documents and transform errors for this migration.
Please refer to https://www.elastic.co/guide/en/kibana/master/resolve-migrations-failures.html for more information."
Please refer to ${migrationDocLink} for more information."
`);
const logFileContent = await asyncReadFile(logFilePath, 'utf-8');

View file

@ -11,7 +11,9 @@ import Fs from 'fs';
import Util from 'util';
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
import { Root } from '../../../root';
import { getMigrationDocLink } from './test_utils';
const migrationDocLink = getMigrationDocLink().resolveMigrationFailures;
const logFilePath = Path.join(__dirname, 'collects_corrupt_docs.log');
const asyncUnlink = Util.promisify(Fs.unlink);
@ -21,8 +23,7 @@ async function removeLogFile() {
await asyncUnlink(logFilePath).catch(() => void 0);
}
// FAILING ON 8.4: https://github.com/elastic/kibana/issues/137330
describe.skip('migration v2 with corrupt saved object documents', () => {
describe('migration v2 with corrupt saved object documents', () => {
let esServer: kbnTestServer.TestElasticsearchUtils;
let root: Root;
@ -106,7 +107,7 @@ describe.skip('migration v2 with corrupt saved object documents', () => {
To allow migrations to proceed, please delete or fix these documents.
Note that you can configure Kibana to automatically discard corrupt documents and transform errors for this migration.
Please refer to https://www.elastic.co/guide/en/kibana/master/resolve-migrations-failures.html for more information."
Please refer to ${migrationDocLink} for more information."
`);
expectMatchOrder(errorLines, [

View file

@ -9,19 +9,15 @@
import Path from 'path';
import fs from 'fs/promises';
import JSON5 from 'json5';
import { REPO_ROOT } from '@kbn/utils';
import { Env } from '@kbn/config';
import { getDocLinksMeta } from '@kbn/doc-links';
import { getEnvOptions } from '@kbn/config-mocks';
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
import { Root } from '../../../root';
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import { LogRecord } from '@kbn/logging';
import { getDocVersion } from './test_utils';
import { retryAsync } from '../../../saved_objects/migrations/test_helpers/retry_async';
const logFilePath = Path.join(__dirname, 'incompatible_cluster_routing_allocation.log');
const env = Env.createDefault(REPO_ROOT, getEnvOptions());
const docVersion = getDocLinksMeta({ kibanaBranch: env.packageInfo.branch }).version;
const docVersion = getDocVersion();
async function removeLogFile() {
// ignore errors if it doesn't exist

View file

@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { Env } from '@kbn/config';
import { getDocLinksMeta, getDocLinks } from '@kbn/doc-links';
import { REPO_ROOT } from '@kbn/utils';
import { getEnvOptions } from '@kbn/config-mocks';
export const getDocVersion = () => {
const env = Env.createDefault(REPO_ROOT, getEnvOptions());
return getDocLinksMeta({ kibanaBranch: env.packageInfo.branch }).version;
};
export const getMigrationDocLink = () => {
const env = Env.createDefault(REPO_ROOT, getEnvOptions());
const docLinks = getDocLinks({ kibanaBranch: env.packageInfo.branch });
return docLinks.kibanaUpgradeSavedObjects;
};