Skip to content

Commit

Permalink
Merge branch 'main' into lens-donut
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc authored Jan 9, 2023
2 parents 1ce2b7d + 14f8e87 commit 7479091
Show file tree
Hide file tree
Showing 25 changed files with 309 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,4 @@ fleet-server.yml
/packages/kbn-package-map/package-map.json
/packages/kbn-synthetic-package-map/
**/.synthetics/
**/.journeys/
4 changes: 3 additions & 1 deletion docs/management/cases/manage-cases.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ When you subsequently add assignees to cases, they receive an email.
=== Manage cases

In *Management > {stack-manage-app} > Cases*, you can search cases and filter
them by severity, status, tags, and assignees.
them by attributes such as assignees, severity, status, and tags. You can also
select multiple cases and use bulk actions to delete cases or change their
attributes.

To view a case, click on its name. You can then:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ async function createRoot({ logFileName }: CreateRootConfig) {
// suite is very long, the 10mins default can cause timeouts
jest.setTimeout(15 * 60 * 1000);

// FLAKY: https://github.com/elastic/kibana/issues/148263
describe.skip('migration v2', () => {
describe('migration v2', () => {
let esServer: TestElasticsearchUtils;
let rootA: Root;
let rootB: Root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ export function filterDeletedFiles({ attrPrefix }: { attrPrefix: string }): Kuer

export function filterArgsToKuery({
extension,
mimeType,
kind,
meta,
name,
status,
user,
attrPrefix = '',
}: Omit<FindFileArgs, 'page' | 'perPage'> & { attrPrefix?: string }): KueryNode {
const kueryExpressions: KueryNode[] = [filterDeletedFiles({ attrPrefix })];

const addFilters = (
fieldName: keyof FileMetadata,
fieldName: keyof FileMetadata | string,
values: string[] = [],
isWildcard = false
): void => {
Expand All @@ -52,6 +54,8 @@ export function filterArgsToKuery({
addFilters('FileKind', kind);
addFilters('Status', status);
addFilters('extension', extension);
addFilters('mime_type', mimeType);
addFilters('user.id', user);

if (meta) {
const addMetaFilters = pipe(
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/files/server/file_service/file_action_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,18 @@ export interface FindFileArgs extends Pagination {
* File extension(s).
*/
extension?: string[];
/**
* File mime type(s).
*/
mimeType?: string[];
/**
* File status(es).
*/
status?: string[];
/**
* ID of user who created the file.
*/
user?: string[];
/**
* File metadata values. These values are governed by the consumer.
*/
Expand Down
52 changes: 52 additions & 0 deletions src/plugins/files/server/integration_tests/file_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,58 @@ describe('FileService', () => {
}
});

it('filters files by mime type', async () => {
await Promise.all([
createDisposableFile({ fileKind, name: 'My pic', mime: 'image/png' }),
createDisposableFile({ fileKind, name: 'Vern payslip', mime: 'application/pdf' }),
]);

const result1 = await fileService.find({
kind: [fileKind],
mimeType: ['image/png'],
});

expect(result1.files.length).toBe(1);
expect(result1.files[0].name).toBe('My pic');

const result2 = await fileService.find({
kind: [fileKind],
mimeType: ['application/pdf'],
});

expect(result2.files.length).toBe(1);
expect(result2.files[0].name).toBe('Vern payslip');
});

it('filters files by user ID', async () => {
await Promise.all([
createDisposableFile({ fileKind, name: "Johnny's file", user: { id: '123' } }),
createDisposableFile({ fileKind, name: "Marry's file", user: { id: '456' } }),
]);

const result1 = await fileService.find({
kind: [fileKind],
user: ['123'],
});

expect(result1.files.length).toBe(1);
expect(result1.files[0].name).toBe("Johnny's file");

const result2 = await fileService.find({
kind: [fileKind],
user: ['456'],
});

expect(result2.files.length).toBe(1);
expect(result2.files[0].name).toBe("Marry's file");

const result3 = await fileService.find({
user: ['456', '123'],
});

expect(result3.files.length).toBe(2);
});

it('deletes files', async () => {
const file = await fileService.create({ fileKind, name: 'test' });
const result = await fileService.find({ kind: [fileKind] });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export const javascriptClientEmbedSteps = (analyticsDNSUrl: string) => [
)}
</p>
<EuiCodeBlock language="javascript" isCopyable>
{`// track a page view in React
{`import { useEffect } from 'react';
// track a page view in React
const SearchPage = (props) => {
useEffect(() => {
Expand Down Expand Up @@ -173,11 +175,9 @@ const ProductDetailPage = (props) => {
label: "product_id",
value: "123"
})
}} />
}}>Add to Basket</input>
}} value="Add to Basket"/>
</div>
)
}
)
}`}
</EuiCodeBlock>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export const LabelInput = ({
dataTestSubj?: string;
compressed?: boolean;
}) => {
const { inputValue, handleInputChange } = useDebouncedValue({ value, onChange });
const { inputValue, handleInputChange } = useDebouncedValue(
{ value, onChange },
{ allowFalsyValue: true }
);
const localKeyHold = useRef(false);

return (
Expand Down
15 changes: 12 additions & 3 deletions x-pack/plugins/observability/e2e/synthetics_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { run as syntheticsRun } from '@elastic/synthetics';
import { PromiseType } from 'utility-types';
import { createApmUsers } from '@kbn/apm-plugin/server/test_helpers/create_apm_users/create_apm_users';

import { EsArchiver } from '@kbn/es-archiver';
import { esArchiverUnload } from './tasks/es_archiver';
import { TestReporter } from './test_reporter';

Expand Down Expand Up @@ -59,9 +60,17 @@ export class SyntheticsRunner {
try {
console.log('Loading esArchiver...');

const esArchiver = this.getService('esArchiver');

const promises = dataArchives.map((archive) => esArchiver.loadIfNeeded(e2eDir + archive));
const esArchiver: EsArchiver = this.getService('esArchiver');

const promises = dataArchives.map((archive) => {
if (archive === 'synthetics_data') {
return esArchiver.load(e2eDir + archive, {
docsOnly: true,
skipExisting: true,
});
}
return esArchiver.load(e2eDir + archive, { skipExisting: true });
});

await Promise.all([...promises]);
} catch (e) {
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/observability/e2e/test_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ export class TestReporter implements Reporter {
);

successfulJourneys.forEach(([journeyName, steps]) => {
// fs.unlinkSync('.journeys/videos/' + journeyName + '.webm');
try {
fs.unlinkSync('.journeys/videos/' + journeyName + '.webm');
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
}
});

const { failed, succeeded, skipped } = this.metrics;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/observability/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"kbn_references": [
"@kbn/apm-plugin",
"@kbn/test",
"@kbn/es-archiver",
]
}
Binary file not shown.
7 changes: 5 additions & 2 deletions x-pack/plugins/synthetics/e2e/helpers/record_video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ const SYNTHETICS_RUNNER = Symbol.for('SYNTHETICS_RUNNER');
// @ts-ignore
export const runner: Runner = global[SYNTHETICS_RUNNER];

export const recordVideo = (page: Page) => {
export const recordVideo = (page: Page, postfix = '') => {
after(async () => {
try {
const videoFilePath = await page.video()?.path();
const pathToVideo = videoFilePath?.replace('.journeys/videos/', '').replace('.webm', '');
const newVideoPath = videoFilePath?.replace(pathToVideo!, runner.currentJourney!.name);
const newVideoPath = videoFilePath?.replace(
pathToVideo!,
runner.currentJourney!.name + `-${postfix}`
);
fs.renameSync(videoFilePath!, newVideoPath!);
} catch (e) {
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ journey(`DefaultStatusAlert`, async ({ page, params }) => {
});
await retry.tryForTime(2 * 60 * 1000, async () => {
await page.click(byTestId('querySubmitButton'));
const text = await page.textContent(`${byTestId('dataGridRowCell')} .euiLink`, {
timeout: 5 * 1000,
});
expect(
await page.isVisible(`text=1 Alert`, {
timeout: 10 * 1000,
})
).toBe(true);

const text = await page.textContent(`${byTestId('dataGridRowCell')} .euiLink`);

expect(text).toBe(reasonMessage);
expect(await page.isVisible(`text=1 Alert`)).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { journey, step, expect, Page } from '@elastic/synthetics';
import { assertText, byTestId } from '@kbn/observability-plugin/e2e/utils';
import { RetryService } from '@kbn/ftr-common-functional-services';
import { recordVideo } from '../../helpers/record_video';
import { syntheticsAppPageProvider } from '../../page_objects/synthetics/synthetics_app';

let page1: Page;
journey(`DataRetentionPage`, async ({ page, params }) => {
page.setDefaultTimeout(60 * 1000);
recordVideo(page);
const syntheticsApp = syntheticsAppPageProvider({ page, kibanaUrl: params.kibanaUrl });

const getService = params.getService;
const retry: RetryService = getService('retry');

step('Go to monitor-management', async () => {
await syntheticsApp.navigateToMonitorManagement(true);
});

step('validate data retention tab', async () => {
await page.click('text=Settings');
expect(page.url()).toBe('http://localhost:5620/app/synthetics/settings/alerting');
await page.click('text=Data retention');
expect(page.url()).toBe('http://localhost:5620/app/synthetics/settings/data-retention');
await page.click('text=Synthetics data is configured by managed index lifecycle policies');

await page.click('text=0 Bytes');
await page.click('text=365 days + rollover');
await page.click('text=14 days + rollover');
await page.click(':nth-match(:text("14 days + rollover"), 2)');
await page.click(':nth-match(:text("365 days + rollover"), 2)');
await page.click(':nth-match(:text("365 days + rollover"), 3)');
await page.click(':nth-match(:text("365 days + rollover"), 4)');
await page.click('tbody div:has-text("synthetics(opens in a new tab or window)")');
});

step('validate data sizes', async () => {
const allChecks = await page.textContent(`tr:has-text("All Checks") span:has-text("KB")`);
const browserChecks = await page.textContent(
`tr:has-text("Browser Checks") span:has-text("KB")`
);
const networkChecks = await page.textContent(
`tr:has-text("Browser Network Requests") span:has-text("KB")`
);
const screenshotChecks = await page.textContent(
`tr:has-text("Browser Screenshots") span:has-text("KB")`
);
expect(Number(allChecks?.split('KB')[0])).toBeGreaterThan(450);
expect(Number(browserChecks?.split('KB')[0])).toBeGreaterThan(50);
expect(Number(networkChecks?.split('KB')[0])).toBeGreaterThan(300);
expect(Number(screenshotChecks?.split('KB')[0])).toBeGreaterThan(25);
});

step('it can click through for policy', async () => {
[page1] = await Promise.all([
page.waitForEvent('popup'),
page.click(
'tbody div:has-text("synthetics-synthetics.browser-default_policy(opens in a new tab or window)")'
),
]);
recordVideo(page1, 'data_retention_policy_change');
await page1.setDefaultTimeout(60 * 1000);
await page1.click('text=Edit policy synthetics-synthetics.browser-default_policy');
await page1.click('text=Save as new policy');
});

step('newly created policy is reflected in settings', async () => {
await page1.fill(
byTestId('policyNameField'),
'synthetics-synthetics.browser-default_policy-copy'
);
await page1.fill(byTestId('delete-selectedMinimumAge'), '10000');

await page1.click(byTestId('savePolicyButton'));

await page1.click('text=Include managed system policies');

await page1.fill(byTestId('ilmSearchBar'), 'copy');

await retry.tryForTime(30 * 1000, async () => {
await page1.click(byTestId('addPolicyToTemplate'), { clickCount: 2, timeout: 5000 });
expect(await page1.isVisible(byTestId('confirmModalConfirmButton'), { timeout: 5000 })).toBe(
true
);
});

await page1.click(byTestId('comboBoxToggleListButton'));
await page1.fill(byTestId('comboBoxSearchInput'), 'synthetics-browser');

await page1.click('button[title="synthetics-browser"]');

await page1.click(byTestId('confirmModalConfirmButton'));

await page.reload();

await page.click('tbody div:has-text("synthetics(opens in a new tab or window)")');
await page1.close();

await assertText({ page, text: '10000 days + rollover' });
});
});
1 change: 1 addition & 0 deletions x-pack/plugins/synthetics/e2e/journeys/synthetics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './alerting_default.journey';
export * from './global_parameters.journey';
export * from './detail_flyout';
export * from './alert_rules/default_status_alert.journey';
export * from './data_retention.journey';
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ journey('StatusFlyoutInAlertingApp', async ({ page, params }) => {
await assertText({ page, text: 'browser' });
await assertText({ page, text: 'http' });

const suggestionItem = await page.$(byTestId('autoCompleteSuggestionText'));
expect(await suggestionItem?.textContent()).toBe('"browser" ');
await retry.tryForTime(30 * 1000, async () => {
const suggestionItem = await page.$(byTestId('autoCompleteSuggestionText'));
expect(await suggestionItem?.textContent()).toBe('"browser" ');
});

await page.click(byTestId('euiFlyoutCloseButton'));
await page.click(byTestId('confirmModalConfirmButton'));
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/synthetics/e2e/synthetics_run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ async function runE2ETests({ readConfigFile }: FtrConfigProviderContext) {
await syntheticsRunner.setup();
const fixturesDir = path.join(__dirname, '../e2e/fixtures/es_archiver/');

await syntheticsRunner.loadTestData(fixturesDir, ['full_heartbeat', 'browser']);
await syntheticsRunner.loadTestData(fixturesDir, [
'synthetics_data',
'full_heartbeat',
'browser',
]);

await syntheticsRunner.loadTestFiles(async () => {
require('./journeys');
Expand Down
Loading

0 comments on commit 7479091

Please sign in to comment.