Skip to content

Commit

Permalink
Fix uiSettings tests (#29258)
Browse files Browse the repository at this point in the history
Merge master
Fix uiSettings tests
  • Loading branch information
chrisdavies authored Jan 24, 2019
1 parent 0becc07 commit c4aa278
Show file tree
Hide file tree
Showing 341 changed files with 7,603 additions and 7,778 deletions.
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"xpack.graph": "x-pack/plugins/graph",
"xpack.grokDebugger": "x-pack/plugins/grokdebugger",
"xpack.idxMgmt": "x-pack/plugins/index_management",
"xpack.indexLifecycleMgmt": "x-pack/plugins/index_lifecycle_management",
"xpack.infra": "x-pack/plugins/infra",
"xpack.licenseMgmt": "x-pack/plugins/license_management",
"xpack.ml": "x-pack/plugins/ml",
Expand Down
2 changes: 1 addition & 1 deletion docs/api/dashboard-import/import.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ POST api/kibana/dashboards/import?exclude=index-pattern
"hits": 0,
"description": "",
"panelsJSON": "[{\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"version\":\"7.0.0-alpha1\",\"panelIndex\":\"1\",\"type\":\"visualization\",\"id\":\"80b956f0-b2cd-11e8-ad8e-85441f0c2e5c\",\"embeddableConfig\":{}}]",
"optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}",
"optionsJSON": "{\"useMargins\":true,\"hidePanelTitles\":false}",
"version": 1,
"timeRestore": false,
"kibanaSavedObjectMeta": {
Expand Down
2 changes: 1 addition & 1 deletion docs/api/url_shortening/shorten_url.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ the shortened URL token for the provided request body.
--------------------------------------------------
POST api/shorten_url
{
"url": "/app/kibana#/dashboard?_g=()&_a=(description:'',filters:!(),fullScreenMode:!f,options:(darkTheme:!f,hidePanelTitles:!f,useMargins:!t),panels:!((embeddableConfig:(),gridData:(h:15,i:'1',w:24,x:0,y:0),id:'8f4d0c00-4c86-11e8-b3d7-01146121b73d',panelIndex:'1',type:visualization,version:'7.0.0-alpha1')),query:(language:lucene,query:''),timeRestore:!f,title:'New%20Dashboard',viewMode:edit)",
"url": "/app/kibana#/dashboard?_g=()&_a=(description:'',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),panels:!((embeddableConfig:(),gridData:(h:15,i:'1',w:24,x:0,y:0),id:'8f4d0c00-4c86-11e8-b3d7-01146121b73d',panelIndex:'1',type:visualization,version:'7.0.0-alpha1')),query:(language:lucene,query:''),timeRestore:!f,title:'New%20Dashboard',viewMode:edit)",
}
--------------------------------------------------
// KIBANA
Expand Down
1 change: 0 additions & 1 deletion docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ mentioned use "_default_".
`timepicker:timeDefaults`:: The default time filter selection.
`timepicker:refreshIntervalDefaults`:: The time filter's default refresh interval.
`timepicker:quickRanges`:: The list of ranges to show in the Quick section of the time picker. This should be an array of objects, with each object containing `from`, `to` (see {ref}/common-options.html#date-math[accepted formats]), `display` (the title to be displayed), and `section` (which column to put the option in).
`dashboard:defaultDarkTheme`:: Set this property to `true` to make new dashboards use the dark theme by default.
`filters:pinnedByDefault`:: Set this property to `true` to make filters have a global state by default.
`filterEditor:suggestValues`:: Set this property to `false` to prevent the filter editor from suggesting values for fields.
`notifications:banner`:: You can specify a custom banner to display temporary notices to all users. This field supports
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@
"pug": "^2.0.3",
"querystring-browser": "1.0.4",
"raw-loader": "0.5.1",
"react": "^16.3.0",
"react": "^16.6.0",
"react-addons-shallow-compare": "15.6.2",
"react-anything-sortable": "^1.7.4",
"react-color": "^2.13.8",
"react-dom": "^16.3.0",
"react-dom": "^16.6.0",
"react-grid-layout": "^0.16.2",
"react-input-range": "^1.3.0",
"react-markdown": "^3.1.4",
Expand Down Expand Up @@ -324,9 +324,10 @@
"classnames": "2.2.5",
"dedent": "^0.7.0",
"delete-empty": "^2.0.0",
"enzyme": "3.2.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "3.3.1",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
"enzyme-adapter-utils": "^1.8.1",
"enzyme-to-json": "^3.3.4",
"eslint": "^5.6.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-babel": "^5.2.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/kbn-es/src/cli_commands/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exports.help = (defaults = {}) => {
--version Version of ES to download [default: ${defaults.version}]
--base-path Path containing cache/installations [default: ${basePath}]
--install-path Installation path, defaults to 'source' within base-path
--data-archive Path to zip or tarball containing an ES data directory to seed the cluster with.
--password Sets password for elastic user [default: ${password}]
-E Additional key=value settings to pass to Elasticsearch
--download-only Download the snapshot but don't actually start it
Expand All @@ -49,6 +50,7 @@ exports.run = async (defaults = {}) => {
alias: {
basePath: 'base-path',
installPath: 'install-path',
dataArchive: 'data-archive',
esArgs: 'E',
},

Expand All @@ -62,6 +64,11 @@ exports.run = async (defaults = {}) => {
await cluster.downloadSnapshot(options);
} else {
const { installPath } = await cluster.installSnapshot(options);

if (options.dataArchive) {
await cluster.extractDataDirectory(installPath, options.dataArchive);
}

await cluster.run(installPath, { esArgs: options.esArgs });
}
};
7 changes: 7 additions & 0 deletions packages/kbn-es/src/cli_commands/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exports.help = (defaults = {}) => {
--source-path Path to ES source [default: ${defaults['source-path']}]
--base-path Path containing cache/installations [default: ${basePath}]
--install-path Installation path, defaults to 'source' within base-path
--data-archive Path to zip or tarball containing an ES data directory to seed the cluster with.
--password Sets password for elastic user [default: ${password}]
-E Additional key=value settings to pass to Elasticsearch
Expand All @@ -49,6 +50,7 @@ exports.run = async (defaults = {}) => {
basePath: 'base-path',
installPath: 'install-path',
sourcePath: 'source-path',
dataArchive: 'data-archive',
esArgs: 'E',
},

Expand All @@ -57,5 +59,10 @@ exports.run = async (defaults = {}) => {

const cluster = new Cluster();
const { installPath } = await cluster.installSource(options);

if (options.dataArchive) {
await cluster.extractDataDirectory(installPath, options.dataArchive);
}

await cluster.run(installPath, { esArgs: options.esArgs });
};
25 changes: 24 additions & 1 deletion packages/kbn-es/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

const execa = require('execa');
const chalk = require('chalk');
const path = require('path');
const { downloadSnapshot, installSnapshot, installSource, installArchive } = require('./install');
const { ES_BIN } = require('./paths');
const { log: defaultLog, parseEsLog, extractConfigFiles } = require('./utils');
const { log: defaultLog, parseEsLog, extractConfigFiles, decompress } = require('./utils');
const { createCliError } = require('./errors');
const { promisify } = require('util');
const treeKillAsync = promisify(require('tree-kill'));
Expand Down Expand Up @@ -116,6 +117,28 @@ exports.Cluster = class Cluster {
return { installPath };
}

/**
* Unpakcs a tar or zip file containing the data directory for an
* ES cluster.
*
* @param {String} installPath
* @param {String} archivePath
*/
async extractDataDirectory(installPath, archivePath) {
this._log.info(chalk.bold(`Extracting data directory`));
this._log.indent(4);

// decompress excludes the root directory as that is how our archives are
// structured. This works in our favor as we can explicitly extract into the data dir
const extractPath = path.resolve(installPath, 'data');
this._log.info(`Data archive: ${archivePath}`);
this._log.info(`Extract path: ${extractPath}`);

await decompress(archivePath, extractPath);

this._log.indent(-4);
}

/**
* Starts ES and returns resolved promise once started
*
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-test/src/es/es_test_cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function createEsTestCluster(options = {}) {
log,
basePath = resolve(KIBANA_ROOT, '.es'),
esFrom = esTestConfig.getBuildFrom(),
dataArchive,
} = options;

const randomHash = Math.random()
Expand Down Expand Up @@ -74,6 +75,10 @@ export function createEsTestCluster(options = {}) {
throw new Error(`unknown option esFrom "${esFrom}"`);
}

if (dataArchive) {
await cluster.extractDataDirectory(installPath, dataArchive);
}

await cluster.start(installPath, {
esArgs: [
`cluster.name=${clusterName}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function runElasticsearch({ config, options }) {
log,
basePath: resolve(KIBANA_ROOT, '.es'),
esFrom: esFrom || config.get('esTestCluster.from'),
dataArchive: config.get('esTestCluster.dataArchive'),
});

const esArgs = config.get('esTestCluster.serverArgs');
Expand Down
3 changes: 2 additions & 1 deletion src/dev/register_git_hook/register_git_hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import chalk from 'chalk';
import { chmod, unlink, writeFile } from 'fs';
import dedent from 'dedent';
import normalizePath from 'normalize-path';
import os from 'os';
import { resolve } from 'path';
import { promisify } from 'util';
import SimpleGit from 'simple-git';
Expand Down Expand Up @@ -128,7 +129,7 @@ export async function registerPrecommitGitHook(log) {
await getPrecommitGitHookScriptPath(REPO_ROOT),
getKbnPrecommitGitHookScript(
REPO_ROOT,
normalizePath(process.env.HOME.replace(/'/g, '\'')),
normalizePath(os.homedir()),
process.platform
)
);
Expand Down
1 change: 1 addition & 0 deletions src/functional_test_runner/lib/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const schema = Joi.object().keys({
license: Joi.string().default('oss'),
from: Joi.string().default('snapshot'),
serverArgs: Joi.array(),
dataArchive: Joi.string(),
}).default(),

kbnTestServer: Joi.object().keys({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('plugins/elasticsearch', () => {
beforeEach(function () {
server = {
log: sinon.stub(),
logWithMetadata: sinon.stub(),
plugins: {
elasticsearch: {
getCluster: sinon.stub().withArgs('admin').returns({ callWithInternalUser: sinon.stub() }),
Expand Down Expand Up @@ -120,17 +121,17 @@ describe('plugins/elasticsearch', () => {
it('warns if a node is only off by a patch version', async () => {
setNodes('5.1.1');
await ensureEsVersion(server, KIBANA_VERSION);
sinon.assert.callCount(server.log, 2);
expect(server.log.getCall(0).args[0]).to.contain('debug');
expect(server.log.getCall(1).args[0]).to.contain('warning');
sinon.assert.callCount(server.logWithMetadata, 2);
expect(server.logWithMetadata.getCall(0).args[0]).to.contain('debug');
expect(server.logWithMetadata.getCall(1).args[0]).to.contain('warning');
});

it('warns if a node is off by a patch version and without http publish address', async () => {
setNodeWithoutHTTP('5.1.1');
await ensureEsVersion(server, KIBANA_VERSION);
sinon.assert.callCount(server.log, 2);
expect(server.log.getCall(0).args[0]).to.contain('debug');
expect(server.log.getCall(1).args[0]).to.contain('warning');
sinon.assert.callCount(server.logWithMetadata, 2);
expect(server.logWithMetadata.getCall(0).args[0]).to.contain('debug');
expect(server.logWithMetadata.getCall(1).args[0]).to.contain('warning');
});

it('errors if a node incompatible and without http publish address', async () => {
Expand All @@ -147,28 +148,28 @@ describe('plugins/elasticsearch', () => {
setNodes('5.1.1');

await ensureEsVersion(server, KIBANA_VERSION);
sinon.assert.callCount(server.log, 2);
expect(server.log.getCall(0).args[0]).to.contain('debug');
expect(server.log.getCall(1).args[0]).to.contain('warning');
sinon.assert.callCount(server.logWithMetadata, 2);
expect(server.logWithMetadata.getCall(0).args[0]).to.contain('debug');
expect(server.logWithMetadata.getCall(1).args[0]).to.contain('warning');

await ensureEsVersion(server, KIBANA_VERSION);
sinon.assert.callCount(server.log, 3);
expect(server.log.getCall(2).args[0]).to.contain('debug');
sinon.assert.callCount(server.logWithMetadata, 3);
expect(server.logWithMetadata.getCall(2).args[0]).to.contain('debug');
});

it('warns again if the node list changes', async () => {
setNodes('5.1.1');

await ensureEsVersion(server, KIBANA_VERSION);
sinon.assert.callCount(server.log, 2);
expect(server.log.getCall(0).args[0]).to.contain('debug');
expect(server.log.getCall(1).args[0]).to.contain('warning');
sinon.assert.callCount(server.logWithMetadata, 2);
expect(server.logWithMetadata.getCall(0).args[0]).to.contain('debug');
expect(server.logWithMetadata.getCall(1).args[0]).to.contain('warning');

setNodes('5.1.2');
await ensureEsVersion(server, KIBANA_VERSION);
sinon.assert.callCount(server.log, 4);
expect(server.log.getCall(2).args[0]).to.contain('debug');
expect(server.log.getCall(3).args[0]).to.contain('warning');
sinon.assert.callCount(server.logWithMetadata, 4);
expect(server.logWithMetadata.getCall(2).args[0]).to.contain('debug');
expect(server.logWithMetadata.getCall(3).args[0]).to.contain('warning');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('plugins/elasticsearch', () => {

// Setup the server mock
server = {
log: sinon.stub(),
logWithMetadata: sinon.stub(),
info: { port: 5601 },
config: function () { return { get, set }; },
plugins: {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/elasticsearch/lib/create_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function createProxy(server) {
handler(req, h) {
const { query, payload: body } = req;
return callWithRequest(req, 'transport.request', {
path: `/${req.params.index}/_search`,
path: `/${encodeURIComponent(req.params.index)}/_search`,
method: 'POST',
query,
body
Expand Down
17 changes: 8 additions & 9 deletions src/legacy/core_plugins/elasticsearch/lib/ensure_es_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function ensureEsVersion(server, kibanaVersion) {
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');
const isProd = server.config().get('env.prod');

server.log(['plugin', 'debug'], 'Checking Elasticsearch version');
server.logWithMetadata(['plugin', 'debug'], 'Checking Elasticsearch version');
return callWithInternalUser('nodes.info', {
filterPath: [
'nodes.*.version',
Expand Down Expand Up @@ -92,15 +92,14 @@ export function ensureEsVersion(server, kibanaVersion) {
const warningNodeNames = getHumanizedNodeNames(simplifiedNodes).join(', ');
if (lastWarnedNodesForServer.get(server) !== warningNodeNames) {
lastWarnedNodesForServer.set(server, warningNodeNames);
server.log(['warning'], {
tmpl: (
`You're running Kibana ${kibanaVersion} with some different versions of ` +
server.logWithMetadata(['warning'],
`You're running Kibana ${kibanaVersion} with some different versions of ` +
'Elasticsearch. Update Kibana or Elasticsearch to the same ' +
`version to prevent compatibility issues: ${warningNodeNames}`
),
kibanaVersion,
nodes: simplifiedNodes,
});
`version to prevent compatibility issues: ${warningNodeNames}`,
{
kibanaVersion,
nodes: simplifiedNodes,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const createHeartbeatInstructions = context => ({
defaultMessage: 'Start Heartbeat',
}),
textPre: i18n.translate('kbn.common.tutorials.heartbeatInstructions.start.osxTextPre', {
defaultMessage: 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
defaultMessage: 'The `setup` command loads the Kibana index pattern.',
}),
commands: [
'./heartbeat setup',
Expand All @@ -115,7 +115,7 @@ export const createHeartbeatInstructions = context => ({
defaultMessage: 'Start Heartbeat',
}),
textPre: i18n.translate('kbn.common.tutorials.heartbeatInstructions.start.debTextPre', {
defaultMessage: 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
defaultMessage: 'The `setup` command loads the Kibana index pattern.',
}),
commands: [
'sudo heartbeat setup',
Expand All @@ -127,7 +127,7 @@ export const createHeartbeatInstructions = context => ({
defaultMessage: 'Start Heartbeat',
}),
textPre: i18n.translate('kbn.common.tutorials.heartbeatInstructions.start.rpmTextPre', {
defaultMessage: 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
defaultMessage: 'The `setup` command loads the Kibana index pattern.',
}),
commands: [
'sudo heartbeat setup',
Expand All @@ -139,7 +139,7 @@ export const createHeartbeatInstructions = context => ({
defaultMessage: 'Start Heartbeat',
}),
textPre: i18n.translate('kbn.common.tutorials.heartbeatInstructions.start.windowsTextPre', {
defaultMessage: 'The `setup` command loads the Kibana dashboards. If the dashboards are already set up, omit this command.',
defaultMessage: 'The `setup` command loads the Kibana index pattern.',
}),
commands: [
'.\\heartbeat.exe setup',
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ State communicated to the embeddable.
// TODO:
filters: FilterObject,
timeRange: TimeRangeObject,
darkTheme: boolean,
}
```
Expand Down
Loading

0 comments on commit c4aa278

Please sign in to comment.