From 010f5859962e50f7df53fcfd0aa0359975fce370 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Wed, 20 Sep 2023 18:15:18 +0200 Subject: [PATCH] [Synthetics] Update package to 1.0.7 (#166822) --- .../add_monitor_private_location.ts | 9 ++- .../apis/synthetics/inspect_monitor.ts | 1 + .../synthetics/sample_data/test_policy.ts | 47 +++++++--------- .../test_project_monitor_policy.ts | 55 +++++++++---------- .../services/private_location_test_service.ts | 6 +- 5 files changed, 56 insertions(+), 62 deletions(-) diff --git a/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts b/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts index e1e730376482d3..79a2267cbadef4 100644 --- a/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts +++ b/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts @@ -17,7 +17,10 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; import { getFixtureJson } from './helper/get_fixture_json'; import { comparePolicies, getTestSyntheticsPolicy } from './sample_data/test_policy'; -import { PrivateLocationTestService } from './services/private_location_test_service'; +import { + INSTALLED_VERSION, + PrivateLocationTestService, +} from './services/private_location_test_service'; export default function ({ getService }: FtrProviderContext) { describe('PrivateLocationAddMonitor', function () { @@ -537,7 +540,7 @@ export default function ({ getService }: FtrProviderContext) { pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default` ); - expect(packagePolicy.package.version).eql('1.0.4'); + expect(packagePolicy.package.version).eql(INSTALLED_VERSION); await supertestAPI.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200); const policyResponseAfterUpgrade = await supertestAPI.get( @@ -547,7 +550,7 @@ export default function ({ getService }: FtrProviderContext) { (pkgPolicy: PackagePolicy) => pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default` ); - expect(semver.gte(packagePolicyAfterUpgrade.package.version, '1.0.4')).eql(true); + expect(semver.gte(packagePolicyAfterUpgrade.package.version, INSTALLED_VERSION)).eql(true); } finally { await supertestAPI .delete(SYNTHETICS_API_URLS.SYNTHETICS_MONITORS + '/' + monitorId) diff --git a/x-pack/test/api_integration/apis/synthetics/inspect_monitor.ts b/x-pack/test/api_integration/apis/synthetics/inspect_monitor.ts index 4b9346adadc2a2..59130c700ede72 100644 --- a/x-pack/test/api_integration/apis/synthetics/inspect_monitor.ts +++ b/x-pack/test/api_integration/apis/synthetics/inspect_monitor.ts @@ -201,6 +201,7 @@ export default function ({ getService }: FtrProviderContext) { schedule: '@every 5m', timeout: '3ms', max_redirects: 3, + max_attempts: 2, proxy_url: 'http://proxy.com', tags: ['tag1', 'tag2'], username: 'test-username', diff --git a/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts b/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts index 5914b116f909aa..efbeca6161d56d 100644 --- a/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts +++ b/x-pack/test/api_integration/apis/synthetics/sample_data/test_policy.ts @@ -8,6 +8,8 @@ import { omit, sortBy } from 'lodash'; import expect from '@kbn/expect'; import { PackagePolicy, PackagePolicyConfigRecord } from '@kbn/fleet-plugin/common'; +import { INSTALLED_VERSION } from '../services/private_location_test_service'; +import { commonVars } from './test_project_monitor_policy'; interface PolicyProps { name?: string; @@ -29,7 +31,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.4' }, + package: { name: 'synthetics', title: 'Elastic Synthetics', version: INSTALLED_VERSION }, enabled: true, policy_id: '5347cd10-0368-11ed-8df7-a7424c6f5167', inputs: [ @@ -166,6 +168,7 @@ export const getHttpInput = ({ 'ssl.supported_protocols': { type: 'yaml' }, location_id: { value: 'fleet_managed', type: 'text' }, location_name: { value: 'Fleet managed', type: 'text' }, + ...commonVars, id: { type: 'text' }, origin: { type: 'text' }, ipv4: { type: 'bool', value: true }, @@ -241,6 +244,7 @@ export const getHttpInput = ({ value: JSON.stringify(location.name) ?? '"Test private location 0"', type: 'text', }, + ...commonVars, id: { value: JSON.stringify(id), type: 'text' }, origin: { value: projectId ? 'project' : 'ui', type: 'text' }, ipv4: { type: 'bool', value: true }, @@ -261,6 +265,7 @@ export const getHttpInput = ({ schedule: '@every 5m', timeout: '3ms', max_redirects: 3, + max_attempts: 2, proxy_url: proxyUrl ?? 'http://proxy.com', tags: ['tag1', 'tag2'], username: 'test-username', @@ -471,30 +476,14 @@ export const getBrowserInput = ({ id, params, isBrowser, projectId }: PolicyProp streams: [ { enabled: true, - data_stream: { - type: 'synthetics', - dataset: 'browser', - elasticsearch: { - privileges: { - indices: ['auto_configure', 'create_doc', 'read'], - }, - }, - }, + data_stream: getDataStream('browser'), vars: browserVars, id: 'synthetics/browser-browser-2bfd7da0-22ed-11ed-8c6b-09a2d21dfbc3-27337270-22ed-11ed-8c6b-09a2d21dfbc3-default', compiled_stream: compiledBrowser, }, { enabled: true, - data_stream: { - type: 'synthetics', - dataset: 'browser.network', - elasticsearch: { - privileges: { - indices: ['auto_configure', 'create_doc', 'read'], - }, - }, - }, + data_stream: getDataStream('browser.network'), id: 'synthetics/browser-browser.network-2bfd7da0-22ed-11ed-8c6b-09a2d21dfbc3-27337270-22ed-11ed-8c6b-09a2d21dfbc3-default', compiled_stream: { processors: [{ add_fields: { target: '', fields: { 'monitor.fleet_managed': true } } }], @@ -502,15 +491,7 @@ export const getBrowserInput = ({ id, params, isBrowser, projectId }: PolicyProp }, { enabled: true, - data_stream: { - type: 'synthetics', - dataset: 'browser.screenshot', - elasticsearch: { - privileges: { - indices: ['auto_configure', 'create_doc', 'read'], - }, - }, - }, + data_stream: getDataStream('browser.screenshot'), id: 'synthetics/browser-browser.screenshot-2bfd7da0-22ed-11ed-8c6b-09a2d21dfbc3-27337270-22ed-11ed-8c6b-09a2d21dfbc3-default', compiled_stream: { processors: [{ add_fields: { target: '', fields: { 'monitor.fleet_managed': true } } }], @@ -520,6 +501,16 @@ export const getBrowserInput = ({ id, params, isBrowser, projectId }: PolicyProp }; }; +export const getDataStream = (dataset: string) => ({ + dataset, + type: 'synthetics', + elasticsearch: { + privileges: { + indices: ['auto_configure', 'create_doc', 'read'], + }, + }, +}); + export const omitIds = (policy: PackagePolicy) => { policy.inputs = sortBy(policy.inputs, 'type'); diff --git a/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts b/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts index 779e13d5b6cfe8..73171abe244357 100644 --- a/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts +++ b/x-pack/test/api_integration/apis/synthetics/sample_data/test_project_monitor_policy.ts @@ -6,6 +6,15 @@ */ import { PackagePolicy } from '@kbn/fleet-plugin/common'; +import { INSTALLED_VERSION } from '../services/private_location_test_service'; +import { getDataStream } from './test_policy'; + +export const commonVars = { + max_attempts: { + type: 'integer', + value: 2, + }, +}; export const getTestProjectSyntheticsPolicyLightweight = ( { @@ -37,7 +46,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.4' }, + package: { name: 'synthetics', title: 'Elastic Synthetics', version: INSTALLED_VERSION }, enabled: true, policy_id: '46034710-0ba6-11ed-ba04-5f123b9faa8b', inputs: [ @@ -122,6 +131,7 @@ export const getTestProjectSyntheticsPolicyLightweight = ( type: 'integer', value: '0', }, + ...commonVars, mode: { type: 'text', value: 'any', @@ -240,6 +250,7 @@ export const getTestProjectSyntheticsPolicyLightweight = ( schedule: '@every 60m', timeout: '80s', max_redirects: 0, + max_attempts: 2, tags: ['tag2', 'tag2'], proxy_url: 'testGlobalParamOverwrite', 'run_from.geo.name': locationName ?? 'Test private location 0', @@ -314,6 +325,7 @@ export const getTestProjectSyntheticsPolicyLightweight = ( 'ssl.supported_protocols': { type: 'yaml' }, location_id: { value: 'fleet_managed', type: 'text' }, location_name: { value: 'Fleet managed', type: 'text' }, + ...commonVars, id: { type: 'text' }, origin: { type: 'text' }, ipv4: { type: 'bool', value: true }, @@ -348,6 +360,7 @@ export const getTestProjectSyntheticsPolicyLightweight = ( tags: { type: 'yaml' }, location_id: { value: 'fleet_managed', type: 'text' }, location_name: { value: 'Fleet managed', type: 'text' }, + ...commonVars, id: { type: 'text' }, origin: { type: 'text' }, ipv4: { type: 'bool', value: true }, @@ -416,6 +429,7 @@ export const getTestProjectSyntheticsPolicyLightweight = ( 'source.zip_url.proxy_url': { type: 'text' }, location_id: { value: 'fleet_managed', type: 'text' }, location_name: { value: 'Fleet managed', type: 'text' }, + ...commonVars, id: { type: 'text' }, origin: { type: 'text' }, ...inputs, @@ -520,7 +534,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.4' }, + package: { name: 'synthetics', title: 'Elastic Synthetics', version: INSTALLED_VERSION }, enabled: true, policy_id: '46034710-0ba6-11ed-ba04-5f123b9faa8b', inputs: [ @@ -570,6 +584,7 @@ export const getTestProjectSyntheticsPolicy = ( 'ssl.supported_protocols': { type: 'yaml' }, location_id: { value: 'fleet_managed', type: 'text' }, location_name: { value: 'Fleet managed', type: 'text' }, + ...commonVars, id: { type: 'text' }, origin: { type: 'text' }, ipv4: { type: 'bool', value: true }, @@ -612,6 +627,7 @@ export const getTestProjectSyntheticsPolicy = ( 'ssl.verification_mode': { type: 'text' }, 'ssl.supported_protocols': { type: 'yaml' }, location_name: { value: 'Fleet managed', type: 'text' }, + ...commonVars, id: { type: 'text' }, origin: { type: 'text' }, ipv4: { type: 'bool', value: true }, @@ -645,6 +661,10 @@ export const getTestProjectSyntheticsPolicy = ( timeout: { type: 'text' }, tags: { type: 'yaml' }, location_name: { value: 'Fleet managed', type: 'text' }, + max_attempts: { + type: 'integer', + value: 2, + }, id: { type: 'text' }, origin: { type: 'text' }, ipv4: { type: 'bool', value: true }, @@ -662,15 +682,7 @@ export const getTestProjectSyntheticsPolicy = ( streams: [ { enabled: true, - data_stream: { - type: 'synthetics', - dataset: 'browser', - elasticsearch: { - privileges: { - indices: ['auto_configure', 'create_doc', 'read'], - }, - }, - }, + data_stream: getDataStream('browser'), vars: { __ui: { value: '{"script_source":{"is_generated_script":false,"file_name":""}}', @@ -719,6 +731,7 @@ export const getTestProjectSyntheticsPolicy = ( 'source.zip_url.ssl.supported_protocols': { type: 'yaml' }, 'source.zip_url.proxy_url': { type: 'text' }, location_name: { value: 'Test private location 0', type: 'text' }, + ...commonVars, location_id: { value: 'fleet_managed', type: 'text' }, id: { value: id, type: 'text' }, origin: { value: 'project', type: 'text' }, @@ -756,15 +769,7 @@ export const getTestProjectSyntheticsPolicy = ( }, { enabled: true, - data_stream: { - type: 'synthetics', - dataset: 'browser.network', - elasticsearch: { - privileges: { - indices: ['auto_configure', 'create_doc', 'read'], - }, - }, - }, + data_stream: getDataStream('browser.network'), id: `synthetics/browser-browser.network-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`, compiled_stream: { processors: [{ add_fields: { target: '', fields: { 'monitor.fleet_managed': true } } }], @@ -772,15 +777,7 @@ export const getTestProjectSyntheticsPolicy = ( }, { enabled: true, - data_stream: { - type: 'synthetics', - dataset: 'browser.screenshot', - elasticsearch: { - privileges: { - indices: ['auto_configure', 'create_doc', 'read'], - }, - }, - }, + data_stream: getDataStream('browser.screenshot'), id: `synthetics/browser-browser.screenshot-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`, compiled_stream: { processors: [{ add_fields: { target: '', fields: { 'monitor.fleet_managed': true } } }], diff --git a/x-pack/test/api_integration/apis/synthetics/services/private_location_test_service.ts b/x-pack/test/api_integration/apis/synthetics/services/private_location_test_service.ts index 6846f16e190b6e..60ee844e11ab8b 100644 --- a/x-pack/test/api_integration/apis/synthetics/services/private_location_test_service.ts +++ b/x-pack/test/api_integration/apis/synthetics/services/private_location_test_service.ts @@ -10,6 +10,8 @@ import { privateLocationsSavedObjectId } from '@kbn/synthetics-plugin/server/sav import { FtrProviderContext } from '../../../ftr_provider_context'; import { KibanaSupertestProvider } from '../../../../../../test/api_integration/services/supertest'; +export const INSTALLED_VERSION = '1.0.7'; + export class PrivateLocationTestService { private supertest: ReturnType; private readonly getService: FtrProviderContext['getService']; @@ -22,12 +24,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.4') + .get(`/api/fleet/epm/packages/synthetics/${INSTALLED_VERSION}`) .set('kbn-xsrf', 'true') .expect(200); if (response.body.item.status !== 'installed') { await this.supertest - .post('/api/fleet/epm/packages/synthetics/1.0.4') + .post(`/api/fleet/epm/packages/synthetics/${INSTALLED_VERSION}`) .set('kbn-xsrf', 'true') .send({ force: true }) .expect(200);