Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.7] Upgrade Kibana to Elasticsearch 7.0 (#29184) #30501

Closed
wants to merge 1 commit into from
Closed
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
Merge 7.0 into 6.7
  • Loading branch information
chrisdavies committed Feb 8, 2019
commit df347906c6369bb9136667bb4eeb78f482476797
1 change: 1 addition & 0 deletions src/dev/ci_setup/setup.sh
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ fi
export KIBANA_DIR="$dir"
export XPACK_DIR="$KIBANA_DIR/x-pack"
export PARENT_DIR="$(cd "$KIBANA_DIR/.."; pwd)"

echo "-> KIBANA_DIR $KIBANA_DIR"
echo "-> XPACK_DIR $XPACK_DIR"
echo "-> PARENT_DIR $PARENT_DIR"
4 changes: 4 additions & 0 deletions src/es_archiver/lib/indices/create_index_stream.js
Original file line number Diff line number Diff line change
@@ -44,6 +44,9 @@ export function createCreateIndexStream({ client, stats, skipExisting, log, kiba
async function handleIndex(record) {
const { index, settings, mappings } = record.value;

// Determine if the mapping belongs to a pre-7.0 instance, for BWC tests, mainly
const isPre7Mapping = !!mappings && Object.keys(mappings).length > 0 && !mappings.properties;

async function attemptToCreate(attemptNumber = 1) {
try {
if (index.startsWith('.kibana')) {
@@ -53,6 +56,7 @@ export function createCreateIndexStream({ client, stats, skipExisting, log, kiba
await client.indices.create({
method: 'PUT',
index,
include_type_name: isPre7Mapping,
body: { settings, mappings },
});

2 changes: 1 addition & 1 deletion src/es_archiver/lib/indices/kibana_index.js
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ async function getKibanaStatuses({ kibanaUrl }) {
export async function createDefaultSpace({ index, client }) {
await client.index({
index,
type: 'doc',
type: '_doc',
id: 'space:default',
body: {
type: 'space',
1 change: 0 additions & 1 deletion src/server/mappings/index.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@

export {
getTypes,
getRootType,
getProperty,
getRootProperties,
getRootPropertiesObjects,
4 changes: 1 addition & 3 deletions src/server/mappings/lib/get_property.js
Original file line number Diff line number Diff line change
@@ -19,8 +19,6 @@

import toPath from 'lodash/internal/toPath';

import { getRootType } from './get_root_type';

/**
* Recursively read properties from the mapping object of type "object"
* until the `path` is resolved.
@@ -53,7 +51,7 @@ function getPropertyMappingFromObjectMapping(mapping, path) {
*/
export function getProperty(mappings, path) {
return getPropertyMappingFromObjectMapping(
mappings[getRootType(mappings)],
mappings,
toPath(path)
);
}
56 changes: 27 additions & 29 deletions src/server/mappings/lib/get_property.test.js
Original file line number Diff line number Diff line change
@@ -20,26 +20,24 @@
import { getProperty } from './get_property';

const MAPPINGS = {
rootType: {
properties: {
foo: {
properties: {
name: {
type: 'text'
},
description: {
type: 'text'
}
properties: {
foo: {
properties: {
name: {
type: 'text'
},
description: {
type: 'text'
}
},
bar: {
properties: {
baz: {
type: 'text',
fields: {
box: {
type: 'keyword'
}
}
},
bar: {
properties: {
baz: {
type: 'text',
fields: {
box: {
type: 'keyword'
}
}
}
@@ -58,28 +56,28 @@ function runTest(key, mapping) {
describe('getProperty(mappings, path)', () => {
describe('string key', () => {
it('finds root properties', () => {
runTest('foo', MAPPINGS.rootType.properties.foo);
runTest('foo', MAPPINGS.properties.foo);
});
it('finds nested properties', () => {
runTest('foo.name', MAPPINGS.rootType.properties.foo.properties.name);
runTest('foo.description', MAPPINGS.rootType.properties.foo.properties.description);
runTest('bar.baz', MAPPINGS.rootType.properties.bar.properties.baz);
runTest('foo.name', MAPPINGS.properties.foo.properties.name);
runTest('foo.description', MAPPINGS.properties.foo.properties.description);
runTest('bar.baz', MAPPINGS.properties.bar.properties.baz);
});
it('finds nested multi-fields', () => {
runTest('bar.baz.box', MAPPINGS.rootType.properties.bar.properties.baz.fields.box);
runTest('bar.baz.box', MAPPINGS.properties.bar.properties.baz.fields.box);
});
});
describe('array of string keys', () => {
it('finds root properties', () => {
runTest(['foo'], MAPPINGS.rootType.properties.foo);
runTest(['foo'], MAPPINGS.properties.foo);
});
it('finds nested properties', () => {
runTest(['foo', 'name'], MAPPINGS.rootType.properties.foo.properties.name);
runTest(['foo', 'description'], MAPPINGS.rootType.properties.foo.properties.description);
runTest(['bar', 'baz'], MAPPINGS.rootType.properties.bar.properties.baz);
runTest(['foo', 'name'], MAPPINGS.properties.foo.properties.name);
runTest(['foo', 'description'], MAPPINGS.properties.foo.properties.description);
runTest(['bar', 'baz'], MAPPINGS.properties.bar.properties.baz);
});
it('finds nested multi-fields', () => {
runTest(['bar', 'baz', 'box'], MAPPINGS.rootType.properties.bar.properties.baz.fields.box);
runTest(['bar', 'baz', 'box'], MAPPINGS.properties.bar.properties.baz.fields.box);
});
});
});
8 changes: 2 additions & 6 deletions src/server/mappings/lib/get_root_properties.js
Original file line number Diff line number Diff line change
@@ -17,8 +17,6 @@
* under the License.
*/

import { getRootType } from './get_root_type';

/**
* Get the property mappings for the root type in the EsMappingsDsl
*
@@ -34,12 +32,10 @@ import { getRootType } from './get_root_type';
* This data can be found at `{indexName}.mappings.{typeName}.properties`
* in the es indices.get() response.
*
* @param {EsMappingsDsl} mappings
* @param {EsMappingsDsl} mapping
* @return {EsPropertyMappings}
*/
export function getRootProperties(mappings) {
const mapping = mappings[getRootType(mappings)];

export function getRootProperties(mapping) {
if (mapping.type !== 'object' && !mapping.properties) {
throw new TypeError('Unable to get property names non-object root mapping');
}
94 changes: 39 additions & 55 deletions src/server/mappings/lib/get_root_properties_objects.test.js
Original file line number Diff line number Diff line change
@@ -21,11 +21,9 @@ import { getRootPropertiesObjects } from './get_root_properties_objects';

test(`returns single object with properties`, () => {
const mappings = {
rootType: {
properties: {
foo: {
properties: {}
}
properties: {
foo: {
properties: {}
}
}
};
@@ -40,11 +38,9 @@ test(`returns single object with properties`, () => {

test(`returns single object with type === 'object'`, () => {
const mappings = {
rootType: {
properties: {
foo: {
type: 'object'
}
properties: {
foo: {
type: 'object'
}
}
};
@@ -59,14 +55,12 @@ test(`returns single object with type === 'object'`, () => {

test(`returns two objects with properties`, () => {
const mappings = {
rootType: {
properties: {
foo: {
properties: {}
},
bar: {
properties: {}
}
properties: {
foo: {
properties: {}
},
bar: {
properties: {}
}
}
};
@@ -84,14 +78,12 @@ test(`returns two objects with properties`, () => {

test(`returns two objects with type === 'object'`, () => {
const mappings = {
rootType: {
properties: {
foo: {
type: 'object'
},
bar: {
type: 'object'
}
properties: {
foo: {
type: 'object'
},
bar: {
type: 'object'
}
}
};
@@ -109,11 +101,9 @@ test(`returns two objects with type === 'object'`, () => {

test(`excludes objects without properties and type of keyword`, () => {
const mappings = {
rootType: {
properties: {
foo: {
type: 'keyword'
}
properties: {
foo: {
type: 'keyword'
}
}
};
@@ -124,14 +114,12 @@ test(`excludes objects without properties and type of keyword`, () => {

test(`excludes two objects without properties and type of keyword`, () => {
const mappings = {
rootType: {
properties: {
foo: {
type: 'keyword'
},
bar: {
type: 'keyword'
}
properties: {
foo: {
type: 'keyword'
},
bar: {
type: 'keyword'
}
}
};
@@ -142,14 +130,12 @@ test(`excludes two objects without properties and type of keyword`, () => {

test(`includes one object with properties and excludes one object without properties`, () => {
const mappings = {
rootType: {
properties: {
foo: {
properties: {}
},
bar: {
type: 'keyword'
}
properties: {
foo: {
properties: {}
},
bar: {
type: 'keyword'
}
}
};
@@ -164,14 +150,12 @@ test(`includes one object with properties and excludes one object without proper

test(`includes one object with type === 'object' and excludes one object without properties`, () => {
const mappings = {
rootType: {
properties: {
foo: {
type: 'object'
},
bar: {
type: 'keyword'
}
properties: {
foo: {
type: 'object'
},
bar: {
type: 'keyword'
}
}
};
38 changes: 0 additions & 38 deletions src/server/mappings/lib/get_root_type.js

This file was deleted.

1 change: 0 additions & 1 deletion src/server/mappings/lib/index.js
Original file line number Diff line number Diff line change
@@ -19,6 +19,5 @@

export { getProperty } from './get_property';
export { getTypes } from './get_types';
export { getRootType } from './get_root_type';
export { getRootProperties } from './get_root_properties';
export { getRootPropertiesObjects } from './get_root_properties_objects';
4 changes: 1 addition & 3 deletions src/server/sample_data/routes/install.js
Original file line number Diff line number Diff line change
@@ -114,9 +114,7 @@ export const createInstallRoute = () => ({
}
},
mappings: {
_doc: {
properties: dataIndexConfig.fields
}
properties: dataIndexConfig.fields
}
}
};
Loading