mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Synthetics] Process processors in kibana as yaml (#162812)
This commit is contained in:
parent
fbfd3ed0dd
commit
41e5df703a
13 changed files with 342 additions and 146 deletions
|
@ -25,6 +25,8 @@ import {
|
|||
UNINSTALL_TOKENS_SAVED_OBJECT_TYPE,
|
||||
} from '../constants';
|
||||
|
||||
import { migrateSyntheticsPackagePolicyToV8100 } from './migrations/synthetics/to_v8_10_0';
|
||||
|
||||
import { migratePackagePolicyEvictionsFromV8100 } from './migrations/security_solution/to_v8_10_0';
|
||||
|
||||
import {
|
||||
|
@ -281,6 +283,10 @@ const getSavedObjectTypes = (): { [key: string]: SavedObjectsType } => ({
|
|||
type: 'data_backfill',
|
||||
backfillFn: migratePackagePolicyToV8100,
|
||||
},
|
||||
{
|
||||
type: 'data_backfill',
|
||||
backfillFn: migrateSyntheticsPackagePolicyToV8100,
|
||||
},
|
||||
],
|
||||
schemas: {
|
||||
forwardCompatibility: migratePackagePolicyEvictionsFromV8100,
|
||||
|
|
|
@ -826,7 +826,12 @@ export const icmpPolicy = {
|
|||
typeMigrationVersion: '8.7.0',
|
||||
} as unknown as SavedObjectUnsanitizedDoc<PackagePolicy>;
|
||||
|
||||
export const getBrowserPolicy = (throttling = '5d/3u/20l') =>
|
||||
export const getBrowserPolicy = (
|
||||
throttling = '5d/3u/20l',
|
||||
project: string | null = null,
|
||||
testRunId?: string,
|
||||
runOnce = false
|
||||
) =>
|
||||
({
|
||||
type: 'ingest-package-policies',
|
||||
id: '420754e9-40f2-486c-bc2e-265bafd735c5-fe200580-dee2-11ed-933e-0f85f8c5dd40-default',
|
||||
|
@ -948,7 +953,7 @@ export const getBrowserPolicy = (throttling = '5d/3u/20l') =>
|
|||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
run_once: { value: runOnce, type: 'bool' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
|
@ -1012,10 +1017,11 @@ export const getBrowserPolicy = (throttling = '5d/3u/20l') =>
|
|||
location_name: { value: 'A private location', type: 'text' },
|
||||
id: { value: '420754e9-40f2-486c-bc2e-265bafd735c5', type: 'text' },
|
||||
config_id: { value: '420754e9-40f2-486c-bc2e-265bafd735c5', type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
run_once: { value: runOnce, type: 'bool' },
|
||||
origin: { value: 'ui', type: 'text' },
|
||||
'monitor.project.id': { value: null, type: 'text' },
|
||||
'monitor.project.name': { value: null, type: 'text' },
|
||||
'monitor.project.id': { value: project, type: 'text' },
|
||||
'monitor.project.name': { value: project, type: 'text' },
|
||||
...(testRunId ? { test_run_id: { value: testRunId, type: 'text' } } : {}),
|
||||
},
|
||||
id: 'synthetics/browser-browser-420754e9-40f2-486c-bc2e-265bafd735c5-fe200580-dee2-11ed-933e-0f85f8c5dd40-default',
|
||||
compiled_stream: {
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* 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 type { SavedObjectModelTransformationContext } from '@kbn/core-saved-objects-server';
|
||||
|
||||
import { getBrowserPolicy } from './fixtures/8.7.0';
|
||||
|
||||
import { migrateSyntheticsPackagePolicyToV8100 as migration } from './to_v8_10_0';
|
||||
|
||||
describe('8.10.0 Synthetics Package Policy migration', () => {
|
||||
describe('processors migration', () => {
|
||||
it('handles processors field for empty values', () => {
|
||||
const actual = migration(
|
||||
getBrowserPolicy('false'),
|
||||
{} as SavedObjectModelTransformationContext
|
||||
);
|
||||
expect(actual.attributes?.inputs?.[3]?.streams[0]?.vars?.processors?.value).toEqual(
|
||||
'[{"add_fields":{"fields":{"monitor.fleet_managed":true,"config_id":"420754e9-40f2-486c-bc2e-265bafd735c5"},"target":""}}]'
|
||||
);
|
||||
expect(actual.attributes?.inputs?.[3]?.streams[0]?.compiled_stream?.processors).toEqual(
|
||||
'[{"add_fields":{"fields":{"monitor.fleet_managed":true,"config_id":"420754e9-40f2-486c-bc2e-265bafd735c5"},"target":""}}]'
|
||||
);
|
||||
});
|
||||
|
||||
it('handles processors field for project monitor', () => {
|
||||
const actual = migration(
|
||||
getBrowserPolicy('', 'test-project'),
|
||||
{} as SavedObjectModelTransformationContext
|
||||
);
|
||||
expect(actual.attributes?.inputs?.[3]?.streams[0]?.vars?.processors?.value).toEqual(
|
||||
JSON.stringify([
|
||||
{
|
||||
add_fields: {
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
|
||||
'monitor.project.name': 'test-project',
|
||||
'monitor.project.id': 'test-project',
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
])
|
||||
);
|
||||
expect(actual.attributes?.inputs?.[3]?.streams[0]?.compiled_stream.processors).toEqual(
|
||||
JSON.stringify([
|
||||
{
|
||||
add_fields: {
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
|
||||
'monitor.project.name': 'test-project',
|
||||
'monitor.project.id': 'test-project',
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('handles processors field for test now fields', () => {
|
||||
const actual = migration(
|
||||
getBrowserPolicy('', 'test-project', 'test-run-id', true),
|
||||
{} as SavedObjectModelTransformationContext
|
||||
);
|
||||
expect(actual.attributes?.inputs?.[3]?.streams[0]?.vars?.processors?.value).toEqual(
|
||||
JSON.stringify([
|
||||
{
|
||||
add_fields: {
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
test_run_id: 'test-run-id',
|
||||
run_once: true,
|
||||
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
|
||||
'monitor.project.name': 'test-project',
|
||||
'monitor.project.id': 'test-project',
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
])
|
||||
);
|
||||
expect(actual.attributes?.inputs?.[3]?.streams[0]?.compiled_stream.processors).toEqual(
|
||||
JSON.stringify([
|
||||
{
|
||||
add_fields: {
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
test_run_id: 'test-run-id',
|
||||
run_once: true,
|
||||
config_id: '420754e9-40f2-486c-bc2e-265bafd735c5',
|
||||
'monitor.project.name': 'test-project',
|
||||
'monitor.project.id': 'test-project',
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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 type { SavedObjectModelDataBackfillFn } from '@kbn/core-saved-objects-server';
|
||||
|
||||
import type { PackagePolicy, PackagePolicyConfigRecord } from '../../../../common';
|
||||
|
||||
export const migrateSyntheticsPackagePolicyToV8100: SavedObjectModelDataBackfillFn<
|
||||
PackagePolicy,
|
||||
PackagePolicy
|
||||
> = (packagePolicyDoc) => {
|
||||
if (
|
||||
packagePolicyDoc.attributes.package?.name !== 'synthetics' ||
|
||||
!packagePolicyDoc.attributes.is_managed
|
||||
) {
|
||||
return packagePolicyDoc;
|
||||
}
|
||||
const updatedAttributes = packagePolicyDoc.attributes;
|
||||
|
||||
const enabledInput = updatedAttributes.inputs.find((input) => input.enabled === true);
|
||||
const enabledStream = enabledInput?.streams.find((stream) => {
|
||||
return ['browser', 'http', 'icmp', 'tcp'].includes(stream.data_stream.dataset);
|
||||
});
|
||||
if (!enabledStream) {
|
||||
return {
|
||||
attributes: updatedAttributes,
|
||||
};
|
||||
}
|
||||
|
||||
if (enabledStream.vars) {
|
||||
const processors = processorsFormatter(enabledStream.vars);
|
||||
enabledStream.vars.processors = { value: processors, type: 'yaml' };
|
||||
enabledStream.compiled_stream.processors = processors;
|
||||
}
|
||||
|
||||
return {
|
||||
attributes: updatedAttributes,
|
||||
};
|
||||
};
|
||||
|
||||
type Fields = Record<string, string | boolean>;
|
||||
|
||||
interface FieldProcessor {
|
||||
add_fields: {
|
||||
target: string;
|
||||
fields: Fields;
|
||||
};
|
||||
}
|
||||
|
||||
export const processorsFormatter = (vars: PackagePolicyConfigRecord) => {
|
||||
const fields: Fields = {
|
||||
'monitor.fleet_managed': true,
|
||||
};
|
||||
if (vars.test_run_id?.value) {
|
||||
fields.test_run_id = vars.test_run_id.value;
|
||||
}
|
||||
if (vars.run_once?.value) {
|
||||
fields.run_once = vars.run_once.value;
|
||||
}
|
||||
if (vars.config_id?.value) {
|
||||
fields.config_id = vars.config_id.value;
|
||||
}
|
||||
const projName = vars['monitor.project.name']?.value;
|
||||
if (projName) {
|
||||
fields['monitor.project.name'] = projName;
|
||||
}
|
||||
const projId = vars['monitor.project.id']?.value;
|
||||
if (projId) {
|
||||
fields['monitor.project.id'] = projId;
|
||||
}
|
||||
const monId = vars['monitor.id']?.value;
|
||||
if (monId) {
|
||||
fields['monitor.id'] = monId;
|
||||
}
|
||||
const processors: FieldProcessor[] = [
|
||||
{
|
||||
add_fields: {
|
||||
fields,
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return JSON.stringify(processors);
|
||||
};
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { NewPackagePolicy } from '@kbn/fleet-plugin/common';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { processorsFormatter } from './processors_formatter';
|
||||
import { LegacyConfigKey } from '../../../../common/constants/monitor_management';
|
||||
import { ConfigKey, DataStream, MonitorFields } from '../../../../common/runtime_types';
|
||||
import { throttlingFormatter } from './browser_formatters';
|
||||
|
@ -14,20 +15,20 @@ import { replaceStringWithParams } from '../formatting_utils';
|
|||
import { syntheticsPolicyFormatters } from './formatters';
|
||||
import { PARAMS_KEYS_TO_SKIP } from '../common';
|
||||
|
||||
export interface ProcessorFields {
|
||||
location_name: string;
|
||||
location_id: string;
|
||||
'monitor.project.name': string;
|
||||
'monitor.project.id': string;
|
||||
'monitor.id': string;
|
||||
test_run_id: string;
|
||||
run_once: boolean;
|
||||
}
|
||||
|
||||
export const formatSyntheticsPolicy = (
|
||||
newPolicy: NewPackagePolicy,
|
||||
monitorType: DataStream,
|
||||
config: Partial<
|
||||
MonitorFields & {
|
||||
location_name: string;
|
||||
location_id: string;
|
||||
'monitor.project.name': string;
|
||||
'monitor.project.id': string;
|
||||
'monitor.id': string;
|
||||
test_run_id: string;
|
||||
run_once: boolean;
|
||||
}
|
||||
>,
|
||||
config: Partial<MonitorFields & ProcessorFields>,
|
||||
params: Record<string, string>,
|
||||
isLegacy?: boolean
|
||||
) => {
|
||||
|
@ -67,6 +68,11 @@ export const formatSyntheticsPolicy = (
|
|||
}
|
||||
});
|
||||
|
||||
const processorItem = dataStream?.vars?.processors;
|
||||
if (processorItem) {
|
||||
processorItem.value = processorsFormatter(config);
|
||||
}
|
||||
|
||||
// TODO: remove this once we remove legacy support
|
||||
const throttling = dataStream?.vars?.[LegacyConfigKey.THROTTLING_CONFIG];
|
||||
if (throttling) {
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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 { ProcessorFields } from './format_synthetics_policy';
|
||||
import { MonitorFields } from '../../../../common/runtime_types';
|
||||
|
||||
type Fields = Record<string, string | boolean>;
|
||||
|
||||
interface FieldProcessor {
|
||||
add_fields: {
|
||||
target: string;
|
||||
fields: Fields;
|
||||
};
|
||||
}
|
||||
|
||||
export const processorsFormatter = (config: Partial<MonitorFields & ProcessorFields>) => {
|
||||
const fields: Fields = {
|
||||
'monitor.fleet_managed': true,
|
||||
};
|
||||
if (config.test_run_id) {
|
||||
fields.test_run_id = config.test_run_id;
|
||||
}
|
||||
if (config.run_once) {
|
||||
fields.run_once = config.run_once;
|
||||
}
|
||||
if (config.config_id) {
|
||||
fields.config_id = config.config_id;
|
||||
}
|
||||
if (config['monitor.project.name']) {
|
||||
fields['monitor.project.name'] = config['monitor.project.name'];
|
||||
}
|
||||
if (config['monitor.project.id']) {
|
||||
fields['monitor.project.id'] = config['monitor.project.id'];
|
||||
}
|
||||
if (config['monitor.id']) {
|
||||
fields['monitor.id'] = config['monitor.id'];
|
||||
}
|
||||
const processors: FieldProcessor[] = [
|
||||
{
|
||||
add_fields: {
|
||||
fields,
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return JSON.stringify(processors);
|
||||
};
|
|
@ -102,12 +102,10 @@ export class SyntheticsPrivateLocation {
|
|||
config_id: config.fields?.config_id,
|
||||
location_name: stringifyString(privateLocation.label),
|
||||
location_id: privateLocation.id,
|
||||
'monitor.project.id': stringifyString(
|
||||
config.fields?.['monitor.project.id'] ?? config[ConfigKey.PROJECT_ID]
|
||||
),
|
||||
'monitor.project.name': stringifyString(
|
||||
config.fields?.['monitor.project.name'] ?? config[ConfigKey.PROJECT_ID]
|
||||
),
|
||||
'monitor.project.id':
|
||||
config.fields?.['monitor.project.id'] ?? config[ConfigKey.PROJECT_ID],
|
||||
'monitor.project.name':
|
||||
config.fields?.['monitor.project.name'] ?? config[ConfigKey.PROJECT_ID],
|
||||
...(testRunId
|
||||
? {
|
||||
test_run_id: testRunId,
|
||||
|
|
|
@ -12,7 +12,7 @@ import { EuiButton, EuiCallOut } from '@elastic/eui';
|
|||
import type { PackagePolicyEditExtensionComponentProps } from '@kbn/fleet-plugin/public';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { useEditMonitorLocator } from './use_edit_monitor_locator';
|
||||
import { ConfigKey, DataStream } from '../../../../common/runtime_types';
|
||||
import { DataStream } from '../../../../common/runtime_types';
|
||||
import { DeprecateNoticeModal } from './deprecate_notice_modal';
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,12 @@ export const SyntheticsPolicyEditExtensionWrapper = memo<PackagePolicyEditExtens
|
|||
Object.values(DataStream).includes(stream.data_stream.dataset as DataStream)
|
||||
)?.vars;
|
||||
|
||||
const configId: string = vars?.[ConfigKey.CONFIG_ID]?.value as DataStream;
|
||||
let configId: string = '';
|
||||
try {
|
||||
configId = JSON.parse(vars?.processors.value)[0].add_fields.fields.config_id;
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
const url = useEditMonitorLocator({ configId, locators });
|
||||
|
||||
|
|
|
@ -537,7 +537,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
|
||||
);
|
||||
|
||||
expect(packagePolicy.package.version).eql('1.0.3');
|
||||
expect(packagePolicy.package.version).eql('1.0.4');
|
||||
|
||||
await supertestAPI.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200);
|
||||
const policyResponseAfterUpgrade = await supertestAPI.get(
|
||||
|
@ -547,7 +547,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
(pkgPolicy: PackagePolicy) =>
|
||||
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
|
||||
);
|
||||
expect(semver.gte(packagePolicyAfterUpgrade.package.version, '1.0.3')).eql(true);
|
||||
expect(semver.gte(packagePolicyAfterUpgrade.package.version, '1.0.4')).eql(true);
|
||||
} finally {
|
||||
await supertestAPI
|
||||
.delete(SYNTHETICS_API_URLS.SYNTHETICS_MONITORS + '/' + monitorId)
|
||||
|
|
|
@ -29,7 +29,7 @@ export const getTestSyntheticsPolicy = (props: PolicyProps): PackagePolicy => {
|
|||
version: 'WzE2MjYsMV0=',
|
||||
name: 'test-monitor-name-Test private location 0-default',
|
||||
namespace: namespace ?? 'testnamespace',
|
||||
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.3' },
|
||||
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.4' },
|
||||
enabled: true,
|
||||
policy_id: '5347cd10-0368-11ed-8df7-a7424c6f5167',
|
||||
inputs: [
|
||||
|
@ -55,6 +55,7 @@ export const getTestSyntheticsPolicy = (props: PolicyProps): PackagePolicy => {
|
|||
'service.name': { type: 'text' },
|
||||
timeout: { type: 'text' },
|
||||
proxy_url: { type: 'text' },
|
||||
processors: { type: 'yaml' },
|
||||
proxy_use_local_resolver: { value: false, type: 'bool' },
|
||||
tags: { type: 'yaml' },
|
||||
'check.send': { type: 'text' },
|
||||
|
@ -67,12 +68,7 @@ export const getTestSyntheticsPolicy = (props: PolicyProps): PackagePolicy => {
|
|||
'ssl.supported_protocols': { type: 'yaml' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -105,13 +101,7 @@ export const getTestSyntheticsPolicy = (props: PolicyProps): PackagePolicy => {
|
|||
tags: { type: 'yaml' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
test_run_id: { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -152,6 +142,7 @@ export const getHttpInput = ({
|
|||
timeout: { type: 'text' },
|
||||
max_redirects: { type: 'integer' },
|
||||
proxy_url: { type: 'text' },
|
||||
processors: { type: 'yaml' },
|
||||
proxy_headers: { type: 'yaml' },
|
||||
tags: { type: 'yaml' },
|
||||
username: { type: 'text' },
|
||||
|
@ -176,13 +167,7 @@ export const getHttpInput = ({
|
|||
location_id: { value: 'fleet_managed', type: 'text' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -201,6 +186,22 @@ export const getHttpInput = ({
|
|||
'service.name': { value: null, type: 'text' },
|
||||
timeout: { value: '3ms', type: 'text' },
|
||||
max_redirects: { value: '3', type: 'integer' },
|
||||
processors: {
|
||||
type: 'yaml',
|
||||
value: JSON.stringify([
|
||||
{
|
||||
add_fields: {
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
config_id: id,
|
||||
'monitor.project.name': projectId,
|
||||
'monitor.project.id': projectId,
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
]),
|
||||
},
|
||||
proxy_url: { value: proxyUrl ?? '"http://proxy.com"', type: 'text' },
|
||||
proxy_headers: { value: null, type: 'yaml' },
|
||||
tags: { value: '["tag1","tag2"]', type: 'yaml' },
|
||||
|
@ -241,13 +242,7 @@ export const getHttpInput = ({
|
|||
type: 'text',
|
||||
},
|
||||
id: { value: JSON.stringify(id), type: 'text' },
|
||||
config_id: { value: id, type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { value: projectId ? 'project' : 'ui', type: 'text' },
|
||||
'monitor.project.id': { type: 'text', value: projectId ?? null },
|
||||
'monitor.project.name': { type: 'text', value: projectId ?? null },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text', value: 'any' },
|
||||
|
@ -298,6 +293,9 @@ export const getHttpInput = ({
|
|||
fields: {
|
||||
config_id: id,
|
||||
'monitor.fleet_managed': true,
|
||||
...(projectId
|
||||
? { 'monitor.project.id': projectId, 'monitor.project.name': projectId }
|
||||
: {}),
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
|
@ -428,13 +426,7 @@ export const getBrowserInput = ({ id, params, isBrowser, projectId }: PolicyProp
|
|||
},
|
||||
location_name: { value: 'Test private location 0', type: 'text' },
|
||||
id: { value: id, type: 'text' },
|
||||
config_id: { value: id, type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { value: 'ui', type: 'text' },
|
||||
'monitor.project.id': { value: projectId ?? null, type: 'text' },
|
||||
'monitor.project.name': { value: projectId ?? null, type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
}
|
||||
: {
|
||||
__ui: { type: 'yaml' },
|
||||
|
@ -469,13 +461,7 @@ export const getBrowserInput = ({ id, params, isBrowser, projectId }: PolicyProp
|
|||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
location_id: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -37,7 +37,7 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
version: 'WzEzMDksMV0=',
|
||||
name: `4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-Test private location 0`,
|
||||
namespace: 'default',
|
||||
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.3' },
|
||||
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.4' },
|
||||
enabled: true,
|
||||
policy_id: '46034710-0ba6-11ed-ba04-5f123b9faa8b',
|
||||
inputs: [
|
||||
|
@ -94,10 +94,6 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
type: 'yaml',
|
||||
value: '["200"]',
|
||||
},
|
||||
config_id: {
|
||||
type: 'text',
|
||||
value: configId,
|
||||
},
|
||||
enabled: {
|
||||
type: 'bool',
|
||||
value: false,
|
||||
|
@ -130,18 +126,6 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
type: 'text',
|
||||
value: 'any',
|
||||
},
|
||||
test_run_id: { type: 'text' },
|
||||
'monitor.project.id': {
|
||||
type: 'text',
|
||||
value: JSON.stringify(projectId),
|
||||
},
|
||||
'monitor.project.name': {
|
||||
type: 'text',
|
||||
value: JSON.stringify(projectId),
|
||||
},
|
||||
'monitor.id': {
|
||||
type: 'text',
|
||||
},
|
||||
name: {
|
||||
type: 'text',
|
||||
value: JSON.stringify(name),
|
||||
|
@ -154,6 +138,22 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
type: 'password',
|
||||
value: null,
|
||||
},
|
||||
processors: {
|
||||
type: 'yaml',
|
||||
value: JSON.stringify([
|
||||
{
|
||||
add_fields: {
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
config_id: configId,
|
||||
'monitor.project.name': projectId,
|
||||
'monitor.project.id': projectId,
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
]),
|
||||
},
|
||||
proxy_headers: {
|
||||
type: 'yaml',
|
||||
value: null,
|
||||
|
@ -174,10 +174,6 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
type: 'bool',
|
||||
value: false,
|
||||
},
|
||||
run_once: {
|
||||
type: 'bool',
|
||||
value: false,
|
||||
},
|
||||
schedule: {
|
||||
type: 'text',
|
||||
value: '"@every 60m"',
|
||||
|
@ -270,13 +266,13 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
processors: [
|
||||
{
|
||||
add_fields: {
|
||||
target: '',
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
config_id: configId,
|
||||
'monitor.project.name': projectId,
|
||||
'monitor.fleet_managed': true,
|
||||
'monitor.project.id': projectId,
|
||||
'monitor.project.name': projectId,
|
||||
},
|
||||
target: '',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -319,13 +315,7 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
location_id: { value: 'fleet_managed', type: 'text' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -359,13 +349,7 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
location_id: { value: 'fleet_managed', type: 'text' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -433,13 +417,7 @@ export const getTestProjectSyntheticsPolicyLightweight = (
|
|||
location_id: { value: 'fleet_managed', type: 'text' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
...inputs,
|
||||
},
|
||||
id: `synthetics/browser-browser-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
|
||||
|
@ -542,7 +520,7 @@ export const getTestProjectSyntheticsPolicy = (
|
|||
version: 'WzEzMDksMV0=',
|
||||
name: `4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-Test private location 0`,
|
||||
namespace: 'default',
|
||||
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.3' },
|
||||
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.4' },
|
||||
enabled: true,
|
||||
policy_id: '46034710-0ba6-11ed-ba04-5f123b9faa8b',
|
||||
inputs: [
|
||||
|
@ -568,6 +546,7 @@ export const getTestProjectSyntheticsPolicy = (
|
|||
timeout: { type: 'text' },
|
||||
max_redirects: { type: 'integer' },
|
||||
proxy_url: { type: 'text' },
|
||||
processors: { type: 'yaml' },
|
||||
proxy_headers: { type: 'yaml' },
|
||||
tags: { type: 'yaml' },
|
||||
username: { type: 'text' },
|
||||
|
@ -592,13 +571,7 @@ export const getTestProjectSyntheticsPolicy = (
|
|||
location_id: { value: 'fleet_managed', type: 'text' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -640,13 +613,7 @@ export const getTestProjectSyntheticsPolicy = (
|
|||
'ssl.supported_protocols': { type: 'yaml' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -679,13 +646,7 @@ export const getTestProjectSyntheticsPolicy = (
|
|||
tags: { type: 'yaml' },
|
||||
location_name: { value: 'Fleet managed', type: 'text' },
|
||||
id: { type: 'text' },
|
||||
config_id: { type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { type: 'text' },
|
||||
'monitor.project.id': { type: 'text' },
|
||||
'monitor.project.name': { type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
ipv4: { type: 'bool', value: true },
|
||||
ipv6: { type: 'bool', value: true },
|
||||
mode: { type: 'text' },
|
||||
|
@ -760,13 +721,7 @@ export const getTestProjectSyntheticsPolicy = (
|
|||
location_name: { value: 'Test private location 0', type: 'text' },
|
||||
location_id: { value: 'fleet_managed', type: 'text' },
|
||||
id: { value: id, type: 'text' },
|
||||
config_id: { value: configId, type: 'text' },
|
||||
run_once: { value: false, type: 'bool' },
|
||||
test_run_id: { type: 'text' },
|
||||
origin: { value: 'project', type: 'text' },
|
||||
'monitor.project.id': { value: JSON.stringify(projectId), type: 'text' },
|
||||
'monitor.project.name': { value: JSON.stringify(projectId), type: 'text' },
|
||||
'monitor.id': { type: 'text' },
|
||||
...inputs,
|
||||
},
|
||||
id: `synthetics/browser-browser-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
|
||||
|
@ -793,19 +748,6 @@ export const getTestProjectSyntheticsPolicy = (
|
|||
testGlobalParam: 'testGlobalParamValue',
|
||||
testGlobalParam2: 'testGlobalParamValue2',
|
||||
},
|
||||
processors: [
|
||||
{
|
||||
add_fields: {
|
||||
target: '',
|
||||
fields: {
|
||||
'monitor.fleet_managed': true,
|
||||
config_id: configId,
|
||||
'monitor.project.name': projectId,
|
||||
'monitor.project.id': projectId,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
...Object.keys(inputs).reduce((acc: Record<string, unknown>, key) => {
|
||||
acc[key] = inputs[key].value;
|
||||
return acc;
|
||||
|
|
|
@ -22,12 +22,12 @@ export class PrivateLocationTestService {
|
|||
async installSyntheticsPackage() {
|
||||
await this.supertest.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200);
|
||||
const response = await this.supertest
|
||||
.get('/api/fleet/epm/packages/synthetics/1.0.3')
|
||||
.get('/api/fleet/epm/packages/synthetics/1.0.4')
|
||||
.set('kbn-xsrf', 'true')
|
||||
.expect(200);
|
||||
if (response.body.item.status !== 'installed') {
|
||||
await this.supertest
|
||||
.post('/api/fleet/epm/packages/synthetics/1.0.3')
|
||||
.post('/api/fleet/epm/packages/synthetics/1.0.4')
|
||||
.set('kbn-xsrf', 'true')
|
||||
.send({ force: true })
|
||||
.expect(200);
|
||||
|
|
|
@ -22,8 +22,7 @@ import { PrivateLocationTestService } from './services/private_location_test_ser
|
|||
import { comparePolicies, getTestSyntheticsPolicy } from './sample_data/test_policy';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
// Failing: See https://github.com/elastic/kibana/issues/162594
|
||||
describe.skip('SyncGlobalParams', function () {
|
||||
describe('SyncGlobalParams', function () {
|
||||
this.tags('skipCloud');
|
||||
const supertestAPI = getService('supertest');
|
||||
const kServer = getService('kibanaServer');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue