diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.test.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.test.ts index 23d7462872c39..6bd316095c5fd 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.test.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.test.ts @@ -114,7 +114,7 @@ describe('8.8.0 Synthetics Package Policy migration', () => { }); describe('throttling migration', () => { - it('handles throtling config for throttling: false', () => { + it('handles throttling config for throttling: false', () => { const actual = migration(getBrowserPolicy('false'), {} as SavedObjectMigrationContext); expect(actual.attributes?.inputs[3]?.streams[0]?.vars?.['throttling.config']?.value).toEqual( 'false' @@ -164,4 +164,16 @@ describe('8.8.0 Synthetics Package Policy migration', () => { }); }); }); + + describe('location id migration', () => { + it('set run from id as agent policy id', () => { + const actual = migration(httpPolicy, {} as SavedObjectMigrationContext); + expect(actual.attributes?.inputs[0]?.streams[0]?.vars?.location_id?.value).toEqual( + 'fa2e69b0-dec6-11ed-8746-c5b1a1a12ec1' + ); + expect(actual.attributes?.inputs[0]?.streams[0]?.compiled_stream?.location_id).toEqual( + 'fa2e69b0-dec6-11ed-8746-c5b1a1a12ec1' + ); + }); + }); }); diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.ts index 872313471ae9b..26a94d7865af7 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/synthetics/to_v8_8_0.ts @@ -25,10 +25,15 @@ export const ALLOWED_SCHEDULES_IN_MINUTES = [ export const migratePackagePolicyToV880: SavedObjectMigrationFn = ( packagePolicyDoc ) => { - if (packagePolicyDoc.attributes.package?.name !== 'synthetics') { + if ( + packagePolicyDoc.attributes.package?.name !== 'synthetics' || + !packagePolicyDoc.attributes.is_managed + ) { return packagePolicyDoc; } + const agentPolicyId = packagePolicyDoc.attributes.policy_id; + const updatedPackagePolicyDoc: SavedObjectUnsanitizedDoc = packagePolicyDoc; const enabledInput = updatedPackagePolicyDoc.attributes.inputs.find( @@ -66,6 +71,12 @@ export const migratePackagePolicyToV880: SavedObjectMigrationFn), config_id: config.fields?.config_id, location_name: privateLocation.label, + location_id: privateLocation.id, 'monitor.project.id': config.fields?.['monitor.project.name'], 'monitor.project.name': config.fields?.['monitor.project.name'], },