Skip to content

Commit

Permalink
Merge branch '7.x' into backport/7.x/pr-96097
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Apr 13, 2021
2 parents 9318f81 + 3279e7f commit 8f60d19
Show file tree
Hide file tree
Showing 99 changed files with 1,638 additions and 672 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ readonly links: {
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
Expand All @@ -114,9 +115,10 @@ readonly links: {
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
Expand All @@ -127,6 +129,7 @@ readonly links: {
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
Expand All @@ -143,6 +146,7 @@ readonly links: {
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
updateTransform: string;
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pageLoadAssetSize:
watcher: 43742
runtimeFields: 41752
stackAlerts: 29684
presentationUtil: 28545
presentationUtil: 49767
spacesOss: 18817
indexPatternFieldEditor: 90489
osquery: 107090
Expand Down
16 changes: 13 additions & 3 deletions packages/kbn-test/src/jest/utils/testbed/testbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Side Public License, v 1.
*/

import { ComponentType, ReactWrapper } from 'enzyme';
import { Component as ReactComponent } from 'react';
import { ComponentType, HTMLAttributes, ReactWrapper } from 'enzyme';

import { findTestSubject } from '../find_test_subject';
import { reactRouterMock } from '../router_helpers';
Expand Down Expand Up @@ -250,8 +251,17 @@ export const registerTestBed = <T extends string = string>(
component.update();
};

const getErrorsMessages: TestBed<T>['form']['getErrorsMessages'] = () => {
const errorMessagesWrappers = component.find('.euiFormErrorText');
const getErrorsMessages: TestBed<T>['form']['getErrorsMessages'] = (
wrapper?: T | ReactWrapper
) => {
let errorMessagesWrappers: ReactWrapper<HTMLAttributes, any, ReactComponent>;
if (typeof wrapper === 'string') {
errorMessagesWrappers = find(wrapper).find('.euiFormErrorText');
} else {
errorMessagesWrappers = wrapper
? wrapper.find('.euiFormErrorText')
: component.find('.euiFormErrorText');
}
return errorMessagesWrappers.map((err) => err.text());
};

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test/src/jest/utils/testbed/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export interface TestBed<T = string> {
/**
* Get a list of the form error messages that are visible in the DOM.
*/
getErrorsMessages: () => string[];
getErrorsMessages: (wrapper?: T | ReactWrapper) => string[];
};
table: {
getMetaData: (tableTestSubject: T) => EuiTableMetaData;
Expand Down
57 changes: 54 additions & 3 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class DocLinksService {
top_hits: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-top-hits-aggregation.html`,
},
runtimeFields: {
overview: `${ELASTICSEARCH_DOCS}runtime.html`,
mapping: `${ELASTICSEARCH_DOCS}runtime-mapping-fields.html`,
},
scriptedFields: {
Expand All @@ -130,8 +131,50 @@ export class DocLinksService {
addData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/connect-to-elasticsearch.html`,
kibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index.html`,
elasticsearch: {
docsBase: `${ELASTICSEARCH_DOCS}`,
asyncSearch: `${ELASTICSEARCH_DOCS}async-search-intro.html`,
dataStreams: `${ELASTICSEARCH_DOCS}data-streams.html`,
indexModules: `${ELASTICSEARCH_DOCS}index-modules.html`,
indexSettings: `${ELASTICSEARCH_DOCS}index-modules.html#index-modules-settings`,
indexTemplates: `${ELASTICSEARCH_DOCS}indices-templates.html`,
mapping: `${ELASTICSEARCH_DOCS}mapping.html`,
mappingAnalyzer: `${ELASTICSEARCH_DOCS}analyzer.html`,
mappingBoost: `${ELASTICSEARCH_DOCS}mapping-boost.html`,
mappingCoerce: `${ELASTICSEARCH_DOCS}coerce.html`,
mappingCopyTo: `${ELASTICSEARCH_DOCS}copy-to.html`,
mappingDocValues: `${ELASTICSEARCH_DOCS}doc-values.html`,
mappingDynamic: `${ELASTICSEARCH_DOCS}dynamic.html`,
mappingDynamicFields: `${ELASTICSEARCH_DOCS}dynamic-field-mapping.html`,
mappingDynamicTemplates: `${ELASTICSEARCH_DOCS}dynamic-templates.html`,
mappingEagerGlobalOrdinals: `${ELASTICSEARCH_DOCS}eager-global-ordinals.html`,
mappingEnabled: `${ELASTICSEARCH_DOCS}enabled.html`,
mappingFieldData: `${ELASTICSEARCH_DOCS}text.html#fielddata-mapping-param`,
mappingFieldDataEnable: `${ELASTICSEARCH_DOCS}text.html#before-enabling-fielddata`,
mappingFieldDataFilter: `${ELASTICSEARCH_DOCS}text.html#field-data-filtering`,
mappingFieldDataTypes: `${ELASTICSEARCH_DOCS}mapping-types.html`,
mappingFormat: `${ELASTICSEARCH_DOCS}mapping-date-format.html`,
mappingIgnoreAbove: `${ELASTICSEARCH_DOCS}ignore-above.html`,
mappingIgnoreMalformed: `${ELASTICSEARCH_DOCS}ignore-malformed.html`,
mappingIndex: `${ELASTICSEARCH_DOCS}mapping-index.html`,
mappingIndexOptions: `${ELASTICSEARCH_DOCS}index-options.html`,
mappingIndexPhrases: `${ELASTICSEARCH_DOCS}index-phrases.html`,
mappingIndexPrefixes: `${ELASTICSEARCH_DOCS}index-prefixes.html`,
mappingJoinFieldsPerformance: `${ELASTICSEARCH_DOCS}parent-join.html#_parent_join_and_performance`,
mappingMeta: `${ELASTICSEARCH_DOCS}mapping-field-meta.html`,
mappingMetaFields: `${ELASTICSEARCH_DOCS}mapping-meta-field.html`,
mappingNormalizer: `${ELASTICSEARCH_DOCS}normalizer.html`,
mappingNorms: `${ELASTICSEARCH_DOCS}norms.html`,
mappingNullValue: `${ELASTICSEARCH_DOCS}null-value.html`,
mappingParameters: `${ELASTICSEARCH_DOCS}mapping-params.html`,
mappingPositionIncrementGap: `${ELASTICSEARCH_DOCS}position-increment-gap.html`,
mappingRankFeatureFields: `${ELASTICSEARCH_DOCS}rank-feature.html`,
mappingRouting: `${ELASTICSEARCH_DOCS}mapping-routing-field.html`,
mappingSimilarity: `${ELASTICSEARCH_DOCS}similarity.html`,
mappingSourceFields: `${ELASTICSEARCH_DOCS}mapping-source-field.html`,
mappingSourceFieldsDisable: `${ELASTICSEARCH_DOCS}mapping-source-field.html#disable-source-field`,
mappingStore: `${ELASTICSEARCH_DOCS}mapping-store.html`,
mappingTermVector: `${ELASTICSEARCH_DOCS}term-vector.html`,
mappingTypesRemoval: `${ELASTICSEARCH_DOCS}removal-of-types.html`,
nodeRoles: `${ELASTICSEARCH_DOCS}modules-node.html#node-roles`,
remoteClusters: `${ELASTICSEARCH_DOCS}modules-remote-clusters.html`,
remoteClustersProxy: `${ELASTICSEARCH_DOCS}modules-remote-clusters.html#proxy-mode`,
Expand All @@ -146,18 +189,20 @@ export class DocLinksService {
},
query: {
eql: `${ELASTICSEARCH_DOCS}eql.html`,
kueryQuerySyntax: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kuery-query.html`,
luceneQuerySyntax: `${ELASTICSEARCH_DOCS}query-dsl-query-string-query.html#query-string-syntax`,
percolate: `${ELASTICSEARCH_DOCS}query-dsl-percolate-query.html`,
queryDsl: `${ELASTICSEARCH_DOCS}query-dsl.html`,
kueryQuerySyntax: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kuery-query.html`,
},
date: {
dateMath: `${ELASTICSEARCH_DOCS}common-options.html#date-math`,
dateMathIndexNames: `${ELASTICSEARCH_DOCS}date-math-index-names.html`,
},
management: {
dashboardSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-dashboard-settings`,
indexManagement: `${ELASTICSEARCH_DOCS}index-mgmt.html`,
kibanaGeneralSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-general-settings`,
kibanaSearchSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-search-settings`,
dashboardSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-dashboard-settings`,
visualizationSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-visualization-settings`,
},
ml: {
Expand Down Expand Up @@ -259,6 +304,7 @@ export class DocLinksService {
skippingDisconnectedClusters: `${ELASTICSEARCH_DOCS}modules-cross-cluster-search.html#skip-unavailable-clusters`,
},
apis: {
bulkIndexAlias: `${ELASTICSEARCH_DOCS}indices-aliases.html`,
createIndex: `${ELASTICSEARCH_DOCS}indices-create-index.html`,
createSnapshotLifecyclePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
createRoleMapping: `${ELASTICSEARCH_DOCS}security-api-put-role-mapping.html`,
Expand All @@ -275,6 +321,7 @@ export class DocLinksService {
painlessExecuteAPIContexts: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/painless/${DOC_LINK_VERSION}/painless-execute-api.html#_contexts`,
putComponentTemplateMetadata: `${ELASTICSEARCH_DOCS}indices-component-template.html#component-templates-metadata`,
putEnrichPolicy: `${ELASTICSEARCH_DOCS}put-enrich-policy-api.html`,
putIndexTemplateV1: `${ELASTICSEARCH_DOCS}indices-templates-v1.html`,
putSnapshotLifecyclePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
putWatch: `${ELASTICSEARCH_DOCS}watcher-api-put-watch.html`,
simulatePipeline: `${ELASTICSEARCH_DOCS}simulate-pipeline-api.html`,
Expand Down Expand Up @@ -430,6 +477,7 @@ export interface DocLinksStart {
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
Expand All @@ -456,9 +504,10 @@ export interface DocLinksStart {
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
Expand All @@ -469,6 +518,7 @@ export interface DocLinksStart {
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
Expand All @@ -485,6 +535,7 @@ export interface DocLinksStart {
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
updateTransform: string;
Expand Down
6 changes: 5 additions & 1 deletion src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ export interface DocLinksStart {
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
Expand All @@ -597,9 +598,10 @@ export interface DocLinksStart {
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
Expand All @@ -610,6 +612,7 @@ export interface DocLinksStart {
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
Expand All @@ -626,6 +629,7 @@ export interface DocLinksStart {
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
updateTransform: string;
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/migrationsv2/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ export const removeWriteBlock = (
* yellow at any point in the future. So ultimately data-redundancy is up to
* users to maintain.
*/
const waitForIndexStatusYellow = (
export const waitForIndexStatusYellow = (
client: ElasticsearchClient,
index: string,
timeout: string
timeout = DEFAULT_TIMEOUT
): TaskEither.TaskEither<RetryableEsClientError, {}> => () => {
return client.cluster
.health({ index, wait_for_status: 'yellow', timeout })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
UpdateAndPickupMappingsResponse,
verifyReindex,
removeWriteBlock,
waitForIndexStatusYellow,
} from '../actions';
import * as Either from 'fp-ts/lib/Either';
import * as Option from 'fp-ts/lib/Option';
Expand Down Expand Up @@ -207,6 +208,51 @@ describe('migration actions', () => {
});
});

describe('waitForIndexStatusYellow', () => {
afterAll(async () => {
await client.indices.delete({ index: 'red_then_yellow_index' });
});
it('resolves right after waiting for an index status to be yellow if the index already existed', async () => {
// Create a red index
await client.indices.create(
{
index: 'red_then_yellow_index',
timeout: '5s',
body: {
mappings: { properties: {} },
settings: {
// Allocate 1 replica so that this index stays yellow
number_of_replicas: '1',
// Disable all shard allocation so that the index status is red
index: { routing: { allocation: { enable: 'none' } } },
},
},
},
{ maxRetries: 0 /** handle retry ourselves for now */ }
);

// Start tracking the index status
const indexStatusPromise = waitForIndexStatusYellow(client, 'red_then_yellow_index')();

const redStatusResponse = await client.cluster.health({ index: 'red_then_yellow_index' });
expect(redStatusResponse.body.status).toBe('red');

client.indices.putSettings({
index: 'red_then_yellow_index',
body: {
// Enable all shard allocation so that the index status turns yellow
index: { routing: { allocation: { enable: 'all' } } },
},
});

await indexStatusPromise;
// Assert that the promise didn't resolve before the index became yellow

const yellowStatusResponse = await client.cluster.health({ index: 'red_then_yellow_index' });
expect(yellowStatusResponse.body.status).toBe('yellow');
});
});

describe('cloneIndex', () => {
afterAll(async () => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Side Public License, v 1.
*/

import { join } from 'path';
import Path from 'path';
import Fs from 'fs';
import Util from 'util';
import Semver from 'semver';
import { REPO_ROOT } from '@kbn/dev-utils';
import { Env } from '@kbn/config';
Expand All @@ -19,6 +21,14 @@ import { Root } from '../../../root';

const kibanaVersion = Env.createDefault(REPO_ROOT, getEnvOptions()).packageInfo.version;

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

const asyncUnlink = Util.promisify(Fs.unlink);
async function removeLogFile() {
// ignore errors if it doesn't exist
await asyncUnlink(logFilePath).catch(() => void 0);
}

describe('migration v2', () => {
let esServer: kbnTestServer.TestElasticsearchUtils;
let root: Root;
Expand Down Expand Up @@ -46,7 +56,7 @@ describe('migration v2', () => {
appenders: {
file: {
type: 'file',
fileName: join(__dirname, 'migration_test_kibana.log'),
fileName: logFilePath,
layout: {
type: 'json',
},
Expand Down Expand Up @@ -121,9 +131,10 @@ describe('migration v2', () => {
const migratedIndex = `.kibana_${kibanaVersion}_001`;

beforeAll(async () => {
await removeLogFile();
await startServers({
oss: false,
dataArchive: join(__dirname, 'archives', '7.3.0_xpack_sample_saved_objects.zip'),
dataArchive: Path.join(__dirname, 'archives', '7.3.0_xpack_sample_saved_objects.zip'),
});
});

Expand Down
Loading

0 comments on commit 8f60d19

Please sign in to comment.