Skip to content

Commit

Permalink
Merge branch 'master' into fix/duplicatePercentile
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Feb 27, 2020
2 parents c065efe + 841e64e commit 7763b4a
Show file tree
Hide file tree
Showing 46 changed files with 607 additions and 875 deletions.
318 changes: 156 additions & 162 deletions src/cli/serve/integration_tests/reload_logging_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,180 +84,174 @@ function createConfigManager(configPath: string) {
}

describe('Server logging configuration', function() {
let child: Child.ChildProcess;
let child: undefined | Child.ChildProcess;

beforeEach(() => {
Fs.mkdirSync(tempDir, { recursive: true });
});

afterEach(async () => {
if (child !== undefined) {
child.kill();
// wait for child to be killed otherwise jest complains that process not finished
await new Promise(res => setTimeout(res, 1000));
const exitPromise = new Promise(resolve => child?.once('exit', resolve));
child.kill('SIGKILL');
await exitPromise;
}

Del.sync(tempDir, { force: true });
});

const isWindows = /^win/.test(process.platform);
if (isWindows) {
if (process.platform.startsWith('win')) {
it('SIGHUP is not a feature of Windows.', () => {
// nothing to do for Windows
});
} else {
describe('legacy logging', () => {
it(
'should be reloadable via SIGHUP process signaling',
async function() {
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
Fs.copyFileSync(legacyConfig, configFilePath);

child = Child.spawn(process.execPath, [
kibanaPath,
'--oss',
'--config',
configFilePath,
'--verbose',
]);

const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
map(messages =>
String(messages)
.split('\n')
.filter(Boolean)
)
);

await message$
.pipe(
// We know the sighup handler will be registered before this message logged
filter(messages => messages.some(m => m.includes('setting up root'))),
take(1)
)
.toPromise();

const lastMessage = await message$.pipe(take(1)).toPromise();
expect(containsJsonOnly(lastMessage)).toBe(true);

createConfigManager(configFilePath).modify(oldConfig => {
oldConfig.logging.json = false;
return oldConfig;
});

child.kill('SIGHUP');

await message$
.pipe(
filter(messages => !containsJsonOnly(messages)),
take(1)
)
.toPromise();
},
minute
);

it(
'should recreate file handle on SIGHUP',
async function() {
const logPath = Path.resolve(tempDir, 'kibana.log');
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');

child = Child.spawn(process.execPath, [
kibanaPath,
'--oss',
'--config',
legacyConfig,
'--logging.dest',
logPath,
'--verbose',
]);

await watchFileUntil(logPath, /setting up root/, 30 * second);
// once the server is running, archive the log file and issue SIGHUP
Fs.renameSync(logPath, logPathArchived);
child.kill('SIGHUP');

await watchFileUntil(
logPath,
/Reloaded logging configuration due to SIGHUP/,
30 * second
);
},
minute
);
});

describe('platform logging', () => {
it(
'should be reloadable via SIGHUP process signaling',
async function() {
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
Fs.copyFileSync(configFileLogConsole, configFilePath);

child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);

const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
map(messages =>
String(messages)
.split('\n')
.filter(Boolean)
)
);

await message$
.pipe(
// We know the sighup handler will be registered before this message logged
filter(messages => messages.some(m => m.includes('setting up root'))),
take(1)
)
.toPromise();

const lastMessage = await message$.pipe(take(1)).toPromise();
expect(containsJsonOnly(lastMessage)).toBe(true);

createConfigManager(configFilePath).modify(oldConfig => {
oldConfig.logging.appenders.console.layout.kind = 'pattern';
return oldConfig;
});
child.kill('SIGHUP');

await message$
.pipe(
filter(messages => !containsJsonOnly(messages)),
take(1)
)
.toPromise();
},
30 * second
);
it(
'should recreate file handle on SIGHUP',
async function() {
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
Fs.copyFileSync(configFileLogFile, configFilePath);

const logPath = Path.resolve(tempDir, 'kibana.log');
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');

createConfigManager(configFilePath).modify(oldConfig => {
oldConfig.logging.appenders.file.path = logPath;
return oldConfig;
});

child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);

await watchFileUntil(logPath, /setting up root/, 30 * second);
// once the server is running, archive the log file and issue SIGHUP
Fs.renameSync(logPath, logPathArchived);
child.kill('SIGHUP');

await watchFileUntil(
logPath,
/Reloaded logging configuration due to SIGHUP/,
30 * second
);
},
minute
);
});
return;
}

describe('legacy logging', () => {
it(
'should be reloadable via SIGHUP process signaling',
async function() {
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
Fs.copyFileSync(legacyConfig, configFilePath);

child = Child.spawn(process.execPath, [
kibanaPath,
'--oss',
'--config',
configFilePath,
'--verbose',
]);

const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
map(messages =>
String(messages)
.split('\n')
.filter(Boolean)
)
);

await message$
.pipe(
// We know the sighup handler will be registered before this message logged
filter(messages => messages.some(m => m.includes('setting up root'))),
take(1)
)
.toPromise();

const lastMessage = await message$.pipe(take(1)).toPromise();
expect(containsJsonOnly(lastMessage)).toBe(true);

createConfigManager(configFilePath).modify(oldConfig => {
oldConfig.logging.json = false;
return oldConfig;
});

child.kill('SIGHUP');

await message$
.pipe(
filter(messages => !containsJsonOnly(messages)),
take(1)
)
.toPromise();
},
minute
);

it(
'should recreate file handle on SIGHUP',
async function() {
const logPath = Path.resolve(tempDir, 'kibana.log');
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');

child = Child.spawn(process.execPath, [
kibanaPath,
'--oss',
'--config',
legacyConfig,
'--logging.dest',
logPath,
'--verbose',
]);

await watchFileUntil(logPath, /setting up root/, 30 * second);
// once the server is running, archive the log file and issue SIGHUP
Fs.renameSync(logPath, logPathArchived);
child.kill('SIGHUP');

await watchFileUntil(logPath, /Reloaded logging configuration due to SIGHUP/, 30 * second);
},
minute
);
});

describe('platform logging', () => {
it(
'should be reloadable via SIGHUP process signaling',
async function() {
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
Fs.copyFileSync(configFileLogConsole, configFilePath);

child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);

const message$ = Rx.fromEvent(child.stdout, 'data').pipe(
map(messages =>
String(messages)
.split('\n')
.filter(Boolean)
)
);

await message$
.pipe(
// We know the sighup handler will be registered before this message logged
filter(messages => messages.some(m => m.includes('setting up root'))),
take(1)
)
.toPromise();

const lastMessage = await message$.pipe(take(1)).toPromise();
expect(containsJsonOnly(lastMessage)).toBe(true);

createConfigManager(configFilePath).modify(oldConfig => {
oldConfig.logging.appenders.console.layout.kind = 'pattern';
return oldConfig;
});
child.kill('SIGHUP');

await message$
.pipe(
filter(messages => !containsJsonOnly(messages)),
take(1)
)
.toPromise();
},
30 * second
);
it(
'should recreate file handle on SIGHUP',
async function() {
const configFilePath = Path.resolve(tempDir, 'kibana.yml');
Fs.copyFileSync(configFileLogFile, configFilePath);

const logPath = Path.resolve(tempDir, 'kibana.log');
const logPathArchived = Path.resolve(tempDir, 'kibana_archive.log');

createConfigManager(configFilePath).modify(oldConfig => {
oldConfig.logging.appenders.file.path = logPath;
return oldConfig;
});

child = Child.spawn(process.execPath, [kibanaPath, '--oss', '--config', configFilePath]);

await watchFileUntil(logPath, /setting up root/, 30 * second);
// once the server is running, archive the log file and issue SIGHUP
Fs.renameSync(logPath, logPathArchived);
child.kill('SIGHUP');

await watchFileUntil(logPath, /Reloaded logging configuration due to SIGHUP/, 30 * second);
},
minute
);
});
});
2 changes: 1 addition & 1 deletion src/dev/npm/integration_tests/installed_packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('src/dev/npm/installed_packages', () => {
includeDev: true,
}),
]);
}, 60 * 1000);
}, 360 * 1000);

it('reads all installed packages of a module', () => {
expect(fixture1Packages).toEqual([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
import { buildTabularInspectorData } from './build_tabular_inspector_data';
import { calculateObjectHash } from '../../../../visualizations/public';
import { tabifyAggResponse } from '../../../../../core_plugins/data/public';
import { PersistedState } from '../../../../../ui/public/persisted_state';
import { PersistedState } from '../../../../../../plugins/visualizations/public';
import { Adapters } from '../../../../../../plugins/inspector/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getQueryService, getIndexPatterns } from '../../../../../../plugins/data/public/services';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export { State } from 'ui/state_management/state';
export { GlobalStateProvider } from 'ui/state_management/global_state';
// @ts-ignore
export { StateManagementConfigProvider } from 'ui/state_management/config_provider';
export { PersistedState } from 'ui/persisted_state';

export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { PersistedState } from '../../../legacy_imports';
import { PersistedState } from '../../../../../../../../plugins/visualizations/public';
import { ReduxLikeStateContainer } from '../../../../../../../../plugins/kibana_utils/public';
import { VisualizeAppState, VisualizeAppStateTransitions } from '../../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

import { TimeRange, Query, Filter, DataPublicPluginStart } from 'src/plugins/data/public';
import { IEmbeddableStart } from 'src/plugins/embeddable/public';
import { PersistedState } from 'src/plugins/visualizations/public';
import { LegacyCoreStart } from 'kibana/public';
import { Vis } from 'src/legacy/core_plugins/visualizations/public';
import { VisSavedObject, PersistedState } from '../legacy_imports';
import { VisSavedObject } from '../legacy_imports';

export type PureVisState = ReturnType<Vis['getCurrentState']>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import React, { useMemo, useState, useCallback, KeyboardEventHandler, useEffect
import { get, isEqual } from 'lodash';
import { i18n } from '@kbn/i18n';
import { keyCodes, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';

import { Vis } from 'src/legacy/core_plugins/visualizations/public';
import { PersistedState, AggGroupNames } from '../../legacy_imports';
import { AggGroupNames } from '../../legacy_imports';
import { DefaultEditorNavBar, OptionTab } from './navbar';
import { DefaultEditorControls } from './controls';
import { setStateParamValue, useEditorReducer, useEditorFormState, discardChanges } from './state';
import { DefaultEditorAggCommonProps } from '../agg_common_props';
import { PersistedState } from '../../../../../../plugins/visualizations/public';

interface DefaultEditorSideBarProps {
isCollapsed: boolean;
Expand Down
Loading

0 comments on commit 7763b4a

Please sign in to comment.