Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into lens/color-palettes
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Jul 6, 2020
2 parents c13a2a6 + 564e91f commit 611d4b5
Show file tree
Hide file tree
Showing 82 changed files with 1,930 additions and 559 deletions.
1 change: 1 addition & 0 deletions .ci/end2end.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pipeline {
HOME = "${env.WORKSPACE}"
E2E_DIR = 'x-pack/plugins/apm/e2e'
PIPELINE_LOG_LEVEL = 'DEBUG'
KBN_OPTIMIZER_THEMES = 'v7light'
}
options {
timeout(time: 1, unit: 'HOURS')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"@babel/plugin-transform-modules-commonjs": "^7.10.1",
"@babel/register": "^7.10.1",
"@elastic/apm-rum": "^5.2.0",
"@elastic/charts": "19.6.3",
"@elastic/charts": "19.7.0",
"@elastic/datemath": "5.0.3",
"@elastic/ems-client": "7.9.3",
"@elastic/eui": "24.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ afterAll(async () => {
await del(TMP_DIR);
});

it('builds expected bundles, saves bundle counts to metadata', async () => {
// FLAKY: https://github.com/elastic/kibana/issues/70762
it.skip('builds expected bundles, saves bundle counts to metadata', async () => {
const config = OptimizerConfig.create({
repoRoot: MOCK_REPO_DIR,
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
Expand Down Expand Up @@ -167,7 +168,8 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
`);
});

it('uses cache on second run and exist cleanly', async () => {
// FLAKY: https://github.com/elastic/kibana/issues/70764
it.skip('uses cache on second run and exist cleanly', async () => {
const config = OptimizerConfig.create({
repoRoot: MOCK_REPO_DIR,
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"kbn:watch": "node scripts/build --dev --watch"
},
"dependencies": {
"@elastic/charts": "19.6.3",
"@elastic/charts": "19.7.0",
"@elastic/eui": "24.1.0",
"@elastic/numeral": "^2.5.0",
"@kbn/i18n": "1.0.0",
Expand Down
1 change: 1 addition & 0 deletions test/functional/apps/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function ({ getService, loadTestFile }) {
after(unloadCurrentData);

loadTestFile(require.resolve('./empty_dashboard'));
loadTestFile(require.resolve('./url_field_formatter'));
loadTestFile(require.resolve('./embeddable_rendering'));
loadTestFile(require.resolve('./create_and_add_embeddables'));
loadTestFile(require.resolve('./edit_embeddable_redirects'));
Expand Down
91 changes: 91 additions & 0 deletions test/functional/apps/dashboard/url_field_formatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';
import { WebElementWrapper } from 'test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const { common, dashboard, settings, timePicker, visChart } = getPageObjects([
'common',
'dashboard',
'settings',
'timePicker',
'visChart',
]);
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const browser = getService('browser');
const fieldName = 'clientip';

const clickFieldAndCheckUrl = async (fieldLink: WebElementWrapper) => {
const fieldValue = await fieldLink.getVisibleText();
await fieldLink.click();
const windowHandlers = await browser.getAllWindowHandles();
expect(windowHandlers.length).to.equal(2);
await browser.switchToWindow(windowHandlers[1]);
const currentUrl = await browser.getCurrentUrl();
const fieldUrl = common.getHostPort() + '/app/' + fieldValue;
expect(currentUrl).to.equal(fieldUrl);
};

describe('Changing field formatter to Url', () => {
before(async function () {
await esArchiver.load('dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await common.navigateToApp('settings');
await settings.clickKibanaIndexPatterns();
await settings.clickIndexPatternLogstash();
await settings.filterField(fieldName);
await settings.openControlsByName(fieldName);
await settings.setFieldFormat('url');
await settings.controlChangeSave();
});

it('applied on dashboard', async () => {
await common.navigateToApp('dashboard');
await dashboard.loadSavedDashboard('dashboard with everything');
await dashboard.waitForRenderComplete();
const fieldLink = await visChart.getFieldLinkInVisTable(`${fieldName}: Descending`, 1);
await clickFieldAndCheckUrl(fieldLink);
});

it('applied on discover', async () => {
await common.navigateToApp('discover');
await timePicker.setAbsoluteRange(
'Sep 19, 2017 @ 06:31:44.000',
'Sep 23, 2018 @ 18:31:44.000'
);
await testSubjects.click('docTableExpandToggleColumn');
const fieldLink = await testSubjects.find(`tableDocViewRow-${fieldName}-value`);
await clickFieldAndCheckUrl(fieldLink);
});

afterEach(async function () {
const windowHandlers = await browser.getAllWindowHandles();
if (windowHandlers.length > 1) {
await browser.closeCurrentWindow();
await browser.switchToWindow(windowHandlers[0]);
}
});
});
}
14 changes: 14 additions & 0 deletions test/functional/page_objects/visualize_chart_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,20 @@ export function VisualizeChartPageProvider({ getService, getPageObjects }: FtrPr
return element.getVisibleText();
}

public async getFieldLinkInVisTable(fieldName: string, rowIndex: number = 1) {
const tableVis = await testSubjects.find('tableVis');
const $ = await tableVis.parseDomContent();
const headers = $('span[ng-bind="::col.title"]')
.toArray()
.map((header: any) => $(header).text());
const fieldColumnIndex = headers.indexOf(fieldName);
return await find.byCssSelector(
`[data-test-subj="paginated-table-body"] tr:nth-of-type(${rowIndex}) td:nth-of-type(${
fieldColumnIndex + 1
}) a`
);
}

/**
* If you are writing new tests, you should rather look into getTableVisContent method instead.
* @deprecated Use getTableVisContent instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './log_entry_categories';
export * from './log_entry_category_datasets';
export * from './log_entry_category_examples';
export * from './log_entry_rate';
export * from './log_entry_rate_examples';
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ export type GetLogEntryRateRequestPayload = rt.TypeOf<typeof getLogEntryRateRequ
*/

export const logEntryRateAnomalyRT = rt.type({
id: rt.string,
actualLogEntryRate: rt.number,
anomalyScore: rt.number,
duration: rt.number,
startTime: rt.number,
typicalLogEntryRate: rt.number,
});

export type LogEntryRateAnomaly = rt.TypeOf<typeof logEntryRateAnomalyRT>;

export const logEntryRatePartitionRT = rt.type({
analysisBucketCount: rt.number,
anomalies: rt.array(logEntryRateAnomalyRT),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as rt from 'io-ts';

import {
badRequestErrorRT,
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../shared';

export const LOG_ANALYSIS_GET_LOG_ENTRY_RATE_EXAMPLES_PATH =
'/api/infra/log_analysis/results/log_entry_rate_examples';

/**
* request
*/

export const getLogEntryRateExamplesRequestPayloadRT = rt.type({
data: rt.type({
// the dataset to fetch the log rate examples from
dataset: rt.string,
// the number of examples to fetch
exampleCount: rt.number,
// the id of the source configuration
sourceId: rt.string,
// the time range to fetch the log rate examples from
timeRange: timeRangeRT,
}),
});

export type GetLogEntryRateExamplesRequestPayload = rt.TypeOf<
typeof getLogEntryRateExamplesRequestPayloadRT
>;

/**
* response
*/

const logEntryRateExampleRT = rt.type({
id: rt.string,
dataset: rt.string,
message: rt.string,
timestamp: rt.number,
tiebreaker: rt.number,
});

export type LogEntryRateExample = rt.TypeOf<typeof logEntryRateExampleRT>;

export const getLogEntryRateExamplesSuccessReponsePayloadRT = rt.intersection([
rt.type({
data: rt.type({
examples: rt.array(logEntryRateExampleRT),
}),
}),
rt.partial({
timing: routeTimingMetadataRT,
}),
]);

export type GetLogEntryRateExamplesSuccessReponsePayload = rt.TypeOf<
typeof getLogEntryRateExamplesSuccessReponsePayloadRT
>;

export const getLogEntryRateExamplesResponsePayloadRT = rt.union([
getLogEntryRateExamplesSuccessReponsePayloadRT,
badRequestErrorRT,
forbiddenErrorRT,
]);

export type GetLogEntryRateExamplesResponsePayload = rt.TypeOf<
typeof getLogEntryRateExamplesResponsePayloadRT
>;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
formatAnomalyScore,
getSeverityCategoryForScore,
ML_SEVERITY_COLORS,
} from '../../../../../../common/log_analysis';
} from '../../../../common/log_analysis';

export const AnomalySeverityIndicator: React.FunctionComponent<{
anomalyScore: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';

import { euiStyled } from '../../../../../observability/public';
import { LogEntryExampleMessagesEmptyIndicator } from './log_entry_examples_empty_indicator';
import { LogEntryExampleMessagesFailureIndicator } from './log_entry_examples_failure_indicator';
import { LogEntryExampleMessagesLoadingIndicator } from './log_entry_examples_loading_indicator';

interface Props {
isLoading: boolean;
hasFailedLoading: boolean;
hasResults: boolean;
exampleCount: number;
onReload: () => void;
}
export const LogEntryExampleMessages: React.FunctionComponent<Props> = ({
isLoading,
hasFailedLoading,
exampleCount,
hasResults,
onReload,
children,
}) => {
return (
<Wrapper>
{isLoading ? (
<LogEntryExampleMessagesLoadingIndicator exampleCount={exampleCount} />
) : hasFailedLoading ? (
<LogEntryExampleMessagesFailureIndicator onRetry={onReload} />
) : !hasResults ? (
<LogEntryExampleMessagesEmptyIndicator onReload={onReload} />
) : (
children
)}
</Wrapper>
);
};

const Wrapper = euiStyled.div`
align-items: stretch;
flex-direction: column;
flex: 1 0 0%;
overflow: hidden;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';

export const CategoryExampleMessagesEmptyIndicator: React.FunctionComponent<{
export const LogEntryExampleMessagesEmptyIndicator: React.FunctionComponent<{
onReload: () => void;
}> = ({ onReload }) => (
<EuiFlexGroup alignItems="center" justifyContent="center">
<EuiFlexItem grow={false} className="eui-textNoWrap">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleEmptyDescription"
id="xpack.infra.logs.logEntryExamples.exampleEmptyDescription"
defaultMessage="No examples found within the selected time range. Increase the log entry retention period to improve message sample availability."
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton onClick={onReload} size="s">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleEmptyReloadButtonLabel"
id="xpack.infra.logs.logEntryExamples.exampleEmptyReloadButtonLabel"
defaultMessage="Reload"
/>
</EuiButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiTextColor } from '@elastic/eui
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';

export const CategoryExampleMessagesFailureIndicator: React.FunctionComponent<{
export const LogEntryExampleMessagesFailureIndicator: React.FunctionComponent<{
onRetry: () => void;
}> = ({ onRetry }) => (
<EuiFlexGroup alignItems="center" justifyContent="center">
<EuiFlexItem grow={false} className="eui-textNoWrap">
<EuiTextColor color="danger">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleLoadingFailureDescription"
defaultMessage="Failed to load category examples."
id="xpack.infra.logs.logEntryExamples.exampleLoadingFailureDescription"
defaultMessage="Failed to load examples."
/>
</EuiTextColor>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton onClick={onRetry} size="s">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleLoadingFailureRetryButtonLabel"
id="xpack.infra.logs.logEntryExamples.exampleLoadingFailureRetryButtonLabel"
defaultMessage="Retry"
/>
</EuiButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { EuiLoadingContent } from '@elastic/eui';
import React from 'react';

export const CategoryExampleMessagesLoadingIndicator: React.FunctionComponent<{
export const LogEntryExampleMessagesLoadingIndicator: React.FunctionComponent<{
exampleCount: number;
}> = ({ exampleCount }) => (
<>
Expand Down
Loading

0 comments on commit 611d4b5

Please sign in to comment.