Skip to content

Commit

Permalink
Merge branch 'main' into 146877-mobile-tables-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
MiriamAparicio authored Apr 25, 2023
2 parents 27f1bf9 + 8de7132 commit 826f1bc
Show file tree
Hide file tree
Showing 58 changed files with 1,002 additions and 322 deletions.
6 changes: 6 additions & 0 deletions fleet_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
"name": "fleet_server",
"version": "1.3.0"
},
{
"name": "profiler_symbolizer",
"version": "8.8.0-preview",
"forceAlignStackVersion": true,
"allowSyncToPrerelease": true
},
{
"name": "synthetics",
"version": "0.12.1"
Expand Down
42 changes: 42 additions & 0 deletions test/functional/services/field_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class FieldEditorService extends FtrService {
private readonly browser = this.ctx.getService('browser');
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly retry = this.ctx.getService('retry');
private readonly find = this.ctx.getService('find');

public async setName(name: string, clearFirst = false, typeCharByChar = false) {
await this.testSubjects.setValue('nameField > input', name, {
Expand Down Expand Up @@ -50,6 +51,47 @@ export class FieldEditorService extends FtrService {
await this.testSubjects.click('fieldSaveButton');
}

async setUrlFieldFormat(template: string) {
const urlTemplateField = await this.find.byCssSelector(
'input[data-test-subj="urlEditorUrlTemplate"]'
);
await urlTemplateField.type(template);
}

public async setStaticLookupFormat(oldValue: string, newValue: string) {
await this.testSubjects.click('staticLookupEditorAddEntry');
await this.testSubjects.setValue('~staticLookupEditorKey', oldValue);
await this.testSubjects.setValue('~staticLookupEditorValue', newValue);
}

public async setColorFormat(value: string, color: string, backgroundColor?: string) {
await this.testSubjects.click('colorEditorAddColor');
await this.testSubjects.setValue('~colorEditorKeyPattern', value);
await this.testSubjects.setValue('~colorEditorColorPicker', color);
if (backgroundColor) {
await this.testSubjects.setValue('~colorEditorBackgroundPicker', backgroundColor);
}
}

public async setStringFormat(transform: string) {
await this.testSubjects.selectValue('stringEditorTransform', transform);
}

public async setTruncateFormatLength(length: string) {
await this.testSubjects.setValue('truncateEditorLength', length);
}

public async setFieldFormat(format: string) {
await this.find.clickByCssSelector(
'select[data-test-subj="editorSelectedFormatId"] > option[value="' + format + '"]'
);
}

public async setFormat(format: string) {
await this.testSubjects.setEuiSwitch('formatRow > toggle', 'check');
await this.setFieldFormat(format);
}

public async confirmSave() {
await this.retry.try(async () => {
await this.testSubjects.setValue('saveModalConfirmText', 'change');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* 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 Path from 'path';

import {
type TestElasticsearchUtils,
type TestKibanaUtils,
createRootWithCorePlugins,
createTestServers,
} from '@kbn/core-test-helpers-kbn-server';

import type { OutputSOAttributes } from '../types';

import { useDockerRegistry, waitForFleetSetup } from './helpers';

const logFilePath = Path.join(__dirname, 'logs.log');

describe('Fleet preconfigured outputs', () => {
let esServer: TestElasticsearchUtils;
let kbnServer: TestKibanaUtils;

const registryUrl = useDockerRegistry();

const startServers = async (outputs: any) => {
const { startES } = createTestServers({
adjustTimeout: (t) => jest.setTimeout(t),
settings: {
es: {
license: 'trial',
},
kbn: {},
},
});

esServer = await startES();
if (kbnServer) {
await kbnServer.stop();
}

const root = createRootWithCorePlugins(
{
xpack: {
fleet: {
outputs,
registryUrl,
},
},
logging: {
appenders: {
file: {
type: 'file',
fileName: logFilePath,
layout: {
type: 'json',
},
},
},
loggers: [
{
name: 'root',
appenders: ['file'],
},
{
name: 'plugins.fleet',
level: 'all',
},
],
},
},
{ oss: false }
);

await root.preboot();
const coreSetup = await root.setup();
const coreStart = await root.start();

kbnServer = {
root,
coreSetup,
coreStart,
stop: async () => await root.shutdown(),
};
await waitForFleetSetup(kbnServer.root);
};

const stopServers = async () => {
if (kbnServer) {
await kbnServer.stop();
}

if (esServer) {
await esServer.stop();
}

await new Promise((res) => setTimeout(res, 10000));
};

describe('Preconfigured outputs', () => {
describe('With a preconfigured monitoring output', () => {
beforeAll(async () => {
await startServers([
{
name: 'Test output',
is_default_monitoring: true,
type: 'elasticsearch',
id: 'output-default-monitoring',
hosts: ['http://elasticsearch-alternative-url:9200'],
},
]);
});

afterAll(async () => {
await stopServers();
});

it('Should create a default output and the default preconfigured output', async () => {
const outputs = await kbnServer.coreStart.savedObjects
.createInternalRepository()
.find<OutputSOAttributes>({
type: 'ingest-outputs',
perPage: 10000,
});

expect(outputs.total).toBe(2);
expect(outputs.saved_objects.filter((so) => so.attributes.is_default)).toHaveLength(1);
expect(
outputs.saved_objects.filter((so) => so.attributes.is_default_monitoring)
).toHaveLength(1);

const defaultDataOutput = outputs.saved_objects.find((so) => so.attributes.is_default);
const defaultMonitoringOutput = outputs.saved_objects.find(
(so) => so.attributes.is_default_monitoring
);
expect(defaultDataOutput!.id).not.toBe(defaultMonitoringOutput!.id);
expect(defaultDataOutput!.attributes.is_default_monitoring).toBeFalsy();
});
});
});
});
3 changes: 1 addition & 2 deletions x-pack/plugins/grokdebugger/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"devTools"
],
"requiredBundles": [
"kibanaReact",
"esUiShared"
"kibanaReact"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiAccordion, EuiCallOut, EuiCodeBlock, EuiFormRow, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { EDITOR } from '../../../common/constants';
import { EuiCodeEditor } from '../../shared_imports';
import { CodeEditor } from '@kbn/kibana-react-plugin/public';

export function CustomPatternsInput({ value, onChange }) {
const sampleCustomPatterns = `POSTFIX_QUEUEID [0-9A-F]{10,11}
Expand Down Expand Up @@ -43,18 +43,18 @@ MSG message-id=<%{GREEDYDATA}>`;
<EuiSpacer size="m" />

<EuiFormRow fullWidth data-test-subj="aceCustomPatternsInput">
<EuiCodeEditor
width="100%"
theme="textmate"
mode="text"
<CodeEditor
languageId="plaintext"
value={value}
onChange={onChange}
setOptions={{
highlightActiveLine: false,
highlightGutterLine: false,
minLines: EDITOR.PATTERN_MIN_LINES,
maxLines: EDITOR.PATTERN_MAX_LINES,
height={200}
options={{
tabSize: 2,
automaticLayout: true,
}}
aria-label={i18n.translate('xpack.grokDebugger.customPatternsInput', {
defaultMessage: 'Code editor for inputting custom patterns',
})}
onChange={onChange}
/>
</EuiFormRow>
</EuiAccordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFormRow } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { EDITOR } from '../../../common/constants';
import { EuiCodeEditor } from '../../shared_imports';
import { CodeEditor } from '@kbn/kibana-react-plugin/public';

export function EventInput({ value, onChange }) {
return (
Expand All @@ -19,20 +18,20 @@ export function EventInput({ value, onChange }) {
<FormattedMessage id="xpack.grokDebugger.sampleDataLabel" defaultMessage="Sample Data" />
}
fullWidth
data-test-subj="aceEventInput"
data-test-subj="eventInput"
>
<EuiCodeEditor
width="100%"
theme="textmate"
mode="text"
<CodeEditor
languageId="plaintext"
value={value}
onChange={onChange}
setOptions={{
highlightActiveLine: false,
highlightGutterLine: false,
minLines: EDITOR.SAMPLE_DATA_MIN_LINES,
maxLines: EDITOR.SAMPLE_DATA_MAX_LINES,
height={200}
options={{
tabSize: 2,
automaticLayout: true,
}}
aria-label={i18n.translate('xpack.grokDebugger.eventInputEditor', {
defaultMessage: 'Code editor for event inputs',
})}
onChange={onChange}
/>
</EuiFormRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
*/

import React from 'react';
import { EuiFormRow } from '@elastic/eui';
import { EuiFormRow, EuiCodeBlock } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { EuiCodeEditor } from '../../shared_imports';

export function EventOutput({ value }) {
return (
<EuiFormRow
Expand All @@ -21,20 +19,15 @@ export function EventOutput({ value }) {
/>
}
fullWidth
data-test-subj="aceEventOutput"
>
<EuiCodeEditor
mode="json"
theme="textmate"
isReadOnly
width="100%"
height="340px"
value={JSON.stringify(value, null, 2)}
setOptions={{
highlightActiveLine: false,
highlightGutterLine: false,
}}
/>
<EuiCodeBlock
paddingSize="m"
language="json"
isCopyable
data-test-subj="eventOutputCodeBlock"
>
{JSON.stringify(value, null, 2)}
</EuiCodeBlock>
</EuiFormRow>
);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { i18n } from '@kbn/i18n';
// eslint-disable-next-line no-restricted-imports
import isEmpty from 'lodash/isEmpty';

import './brace_imports';
import {
EuiForm,
EuiButton,
Expand Down
Loading

0 comments on commit 826f1bc

Please sign in to comment.