Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into nls/ui-filters-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed Feb 2, 2021
2 parents 77bfde8 + 76d6606 commit 9e97e08
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 32 deletions.
10 changes: 5 additions & 5 deletions src/dev/build/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ it('build default and oss dist for current platform, without packages, by defaul
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": false,
"createDockerContexts": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createRpmPackage": false,
"downloadFreshNode": true,
Expand Down Expand Up @@ -79,7 +79,7 @@ it('limits packages if --rpm passed with --all-platforms', () => {
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": false,
"createDockerContexts": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createRpmPackage": true,
"downloadFreshNode": true,
Expand All @@ -103,7 +103,7 @@ it('limits packages if --deb passed with --all-platforms', () => {
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": false,
"createDockerContexts": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createRpmPackage": false,
"downloadFreshNode": true,
Expand All @@ -128,7 +128,7 @@ it('limits packages if --docker passed with --all-platforms', () => {
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": true,
"createDockerContexts": false,
"createDockerContexts": true,
"createDockerUBI": true,
"createRpmPackage": false,
"downloadFreshNode": true,
Expand Down Expand Up @@ -160,7 +160,7 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
"createArchives": true,
"createDebPackage": false,
"createDockerCentOS": true,
"createDockerContexts": false,
"createDockerContexts": true,
"createDockerUBI": false,
"createRpmPackage": false,
"downloadFreshNode": true,
Expand Down
14 changes: 4 additions & 10 deletions src/dev/build/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function readCliArgs(argv: string[]) {
'rpm',
'deb',
'docker-images',
'docker-contexts',
'skip-docker-contexts',
'skip-docker-ubi',
'skip-docker-centos',
'release',
Expand All @@ -45,7 +45,6 @@ export function readCliArgs(argv: string[]) {
rpm: null,
deb: null,
'docker-images': null,
'docker-contexts': null,
oss: null,
'version-qualifier': '',
},
Expand All @@ -72,7 +71,7 @@ export function readCliArgs(argv: string[]) {

// In order to build a docker image we always need
// to generate all the platforms
if (flags['docker-images'] || flags['docker-contexts']) {
if (flags['docker-images']) {
flags['all-platforms'] = true;
}

Expand All @@ -82,12 +81,7 @@ export function readCliArgs(argv: string[]) {
}

// build all if no flags specified
if (
flags.rpm === null &&
flags.deb === null &&
flags['docker-images'] === null &&
flags['docker-contexts'] === null
) {
if (flags.rpm === null && flags.deb === null && flags['docker-images'] === null) {
return true;
}

Expand All @@ -106,7 +100,7 @@ export function readCliArgs(argv: string[]) {
createDockerCentOS:
isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-centos']),
createDockerUBI: isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-ubi']),
createDockerContexts: isOsPackageDesired('docker-contexts'),
createDockerContexts: !Boolean(flags['skip-docker-contexts']),
targetAllPlatforms: Boolean(flags['all-platforms']),
};

Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/build_distributables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
}

if (options.createDockerContexts) {
// control w/ --docker-contexts or --skip-os-packages
// control w/ --skip-docker-contexts
await run(Tasks.CreateDockerContexts);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ describe('Query decorator', () => {
expect(decoratedQuery).toEqual({ query_string: { query: '*', analyze_wildcard: true } });
});

test('should merge in serialized query string options', () => {
const queryStringOptions = '{ "analyze_wildcard": true }';
const decoratedQuery = decorateQuery({ query_string: { query: '*' } }, queryStringOptions);

expect(decoratedQuery).toEqual({ query_string: { query: '*', analyze_wildcard: true } });
});

test('should add a default of a time_zone parameter if one is provided', () => {
const decoratedQuery = decorateQuery(
{ query_string: { query: '*' } },
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/data/common/es_query/es_query/decorate_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ import { DslQuery, isEsQueryString } from './es_query_dsl';

export function decorateQuery(
query: DslQuery,
queryStringOptions: Record<string, any>,
queryStringOptions: Record<string, any> | string,
dateFormatTZ?: string
) {
if (isEsQueryString(query)) {
// NOTE queryStringOptions comes from UI Settings and, in server context, is a serialized string
// https://github.com/elastic/kibana/issues/89902
if (typeof queryStringOptions === 'string') {
queryStringOptions = JSON.parse(queryStringOptions);
}

extend(query.query_string, queryStringOptions);
if (dateFormatTZ) {
defaults(query.query_string, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ describe('AggConfig Filters', () => {
const aggConfigs = getAggConfigs();
const filter = createFilterFilters(aggConfigs.aggs[0] as IBucketAggConfig, 'type:nginx');

expect(filter).toMatchInlineSnapshot(`
Object {
"meta": Object {
"alias": "type:nginx",
"index": "1234",
},
"query": Object {
"bool": Object {
"filter": Array [],
"must": Array [
Object {
"query_string": Object {
"query": "type:nginx",
"time_zone": "dateFormat:tz",
},
},
],
"must_not": Array [],
"should": Array [],
},
},
}
`);

expect(filter!.query.bool.must[0].query_string.query).toBe('type:nginx');
expect(filter!.meta).toHaveProperty('index', '1234');
expect(filter!.meta).toHaveProperty('alias', 'type:nginx');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const mockGetConfig = jest.fn().mockImplementation((key: string) => {
['P1DT', 'YYYY-MM-DD'],
['P1YT', 'YYYY'],
],
'query:queryString:options': {},
};
return config[key] ?? key;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getSections = ({
urlParams: IUrlParams;
}) => {
const hostName = transaction.host?.hostname;
const podId = transaction.kubernetes?.pod.uid;
const podId = transaction.kubernetes?.pod?.uid;
const containerId = transaction.container?.id;

const time = Math.round(transaction.timestamp.us / 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/

export interface Kubernetes {
pod: { uid: string; [key: string]: unknown };
pod?: { uid: string; [key: string]: unknown };
}
7 changes: 2 additions & 5 deletions x-pack/plugins/monitoring/public/services/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function formatCluster(cluster) {
}

let once = false;
let inTransit = false;

export function monitoringClustersProvider($injector) {
return async (clusterUuid, ccs, codePaths) => {
Expand Down Expand Up @@ -88,18 +87,16 @@ export function monitoringClustersProvider($injector) {
}
}

if (!once && !inTransit) {
inTransit = true;
if (!once) {
once = true;
const clusters = await getClusters();
if (clusters.length) {
try {
const [{ data }] = await Promise.all([ensureAlertsEnabled(), ensureMetricbeatEnabled()]);
showAlertsToast(data);
once = true;
} catch (_err) {
// Intentionally swallow the error as this will retry the next page load
}
inTransit = false;
}
return clusters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ interface DisableWatchesResponse {
>;
}

async function callMigrationApi(callCluster: LegacyAPICaller) {
return await callCluster('monitoring.disableWatches');
async function callMigrationApi(callCluster: LegacyAPICaller, logger: Logger) {
try {
return await callCluster('monitoring.disableWatches');
} catch (err) {
logger.warn(
`Unable to call migration api to disable cluster alert watches. Message=${err.message}`
);
return undefined;
}
}

export async function disableWatcherClusterAlerts(callCluster: LegacyAPICaller, logger: Logger) {
const response: DisableWatchesResponse = await callMigrationApi(callCluster);
const response: DisableWatchesResponse = await callMigrationApi(callCluster, logger);
if (!response || response.exporters.length === 0) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { FtrProviderContext } from '../ftr_provider_context';

export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const find = getService('find');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
Expand All @@ -21,7 +22,7 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr
},

async getList() {
const table = await find.byCssSelector('table');
const table = await testSubjects.find('searchSessionsMgmtTable');
const allRows = await table.findAllByTestSubject('searchSessionsRow');

return Promise.all(
Expand All @@ -37,15 +38,18 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr
expires: $.findTestSubject('sessionManagementExpiresCol').text(),
app: $.findTestSubject('sessionManagementAppIcon').attr('data-test-app-id'),
view: async () => {
log.debug('management ui: view the session');
await viewCell.click();
},
reload: async () => {
log.debug('management ui: reload the status');
await actionsCell.click();
await find.clickByCssSelector(
'[data-test-subj="sessionManagementPopoverAction-reload"]'
);
},
cancel: async () => {
log.debug('management ui: cancel the session');
await actionsCell.click();
await find.clickByCssSelector(
'[data-test-subj="sessionManagementPopoverAction-cancel"]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,27 @@ export function SearchSessionsProvider({ getService }: FtrProviderContext) {
}

public async viewSearchSessions() {
log.debug('viewSearchSessions');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorviewSearchSessionsLink');
}

public async save() {
log.debug('save the search session');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorSaveBtn');
await this.ensurePopoverClosed();
}

public async cancel() {
log.debug('cancel the search session');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorCancelBtn');
await this.ensurePopoverClosed();
}

public async refresh() {
log.debug('refresh the status');
await this.ensurePopoverOpened();
await testSubjects.click('searchSessionIndicatorRefreshBtn');
await this.ensurePopoverClosed();
Expand All @@ -85,15 +89,20 @@ export function SearchSessionsProvider({ getService }: FtrProviderContext) {
}

private async ensurePopoverOpened() {
log.debug('ensurePopoverOpened');
const isAlreadyOpen = await testSubjects.exists(SEARCH_SESSIONS_POPOVER_CONTENT_TEST_SUBJ);
if (isAlreadyOpen) return;
if (isAlreadyOpen) {
log.debug('Popover is already open');
return;
}
return retry.waitFor(`searchSessions popover opened`, async () => {
await testSubjects.click(SEARCH_SESSION_INDICATOR_TEST_SUBJ);
return await testSubjects.exists(SEARCH_SESSIONS_POPOVER_CONTENT_TEST_SUBJ);
});
}

private async ensurePopoverClosed() {
log.debug('ensurePopoverClosed');
const isAlreadyClosed = !(await testSubjects.exists(
SEARCH_SESSIONS_POPOVER_CONTENT_TEST_SUBJ
));
Expand All @@ -110,7 +119,7 @@ export function SearchSessionsProvider({ getService }: FtrProviderContext) {
* Alternatively, a test can navigate to `Management > Search Sessions` and use the UI to delete any created tests.
*/
public async deleteAllSearchSessions() {
log.debug('Deleting created searcg sessions');
log.debug('Deleting created search sessions');
// ignores 409 errs and keeps retrying
await retry.tryForTime(10000, async () => {
const { body } = await supertest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const PageObjects = getPageObjects([
'common',
'header',
Expand All @@ -18,20 +19,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
]);
const searchSessions = getService('searchSessions');
const esArchiver = getService('esArchiver');
const retry = getService('retry');
const log = getService('log');

// FLAKY: https://github.com/elastic/kibana/issues/89069
describe.skip('Search search sessions Management UI', () => {
describe.skip('Search sessions Management UI', () => {
describe('New search sessions', () => {
before(async () => {
await PageObjects.common.navigateToApp('dashboard');
log.debug('wait for dashboard landing page');
retry.tryForTime(10000, async () => {
testSubjects.existOrFail('dashboardLandingPage');
});
});

after(async () => {
await searchSessions.deleteAllSearchSessions();
});

it('Saves a session and verifies it in the Management app', async () => {
log.debug('loading the "Not Delayed" dashboard');
await PageObjects.dashboard.loadSavedDashboard('Not Delayed');
await PageObjects.dashboard.waitForRenderComplete();
await searchSessions.expectState('completed');
Expand All @@ -47,6 +53,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

// find there is only one item in the table which is the newly saved session
log.debug('find the newly saved session');
const searchSessionList = await PageObjects.searchSessionsManagement.getList();
expect(searchSessionList.length).to.be(1);
expect(searchSessionList[0].expires).not.to.eql('--');
Expand All @@ -63,6 +70,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await searchSessions.expectState('restored');
});

// NOTE: this test depends on the previous one passing
it('Reloads as new session from management', async () => {
await PageObjects.searchSessionsManagement.goTo();

Expand Down

0 comments on commit 9e97e08

Please sign in to comment.