Commit c218f31
committed
[profiling] fix failing profiling tests due to [fleet-agent-policies/policy-elastic-agent-on-cloud] not found (#268428)
## Summary
Closes #268400
Closes #268399
Profiling's `setupResources` POST takes the cloud branch (Scout's
stateful Kibana runs with `xpack.cloud.id` set), so it tries to create
the `profiler_collector` and `profiler_symbolizer` Fleet package
policies on the `policy-elastic-agent-on-cloud` agent policy, which only
`has_no_setup.spec.ts` provisions via
`profilingHelper.installPolicies()`.
When the UX Scout tests ran first, the worker order/state shifted just
enough that `has_setup_apm_not_installed.spec.ts`'s `beforeAll` reached
`setupResources` before `has_no_setup.spec.ts` had created the agent
policy, so Fleet's `packagePolicyClient.create` blew up with `Saved
object [fleet-agent-policies/policy-elastic-agent-on-cloud] not found`,
which the route surfaced as the opaque 500.
The fix makes each spec self-provision the agent policy instead of
relying on test ordering.
Tested locally:
```
# start servers
node scripts/scout start-server --arch stateful --domain classic
# run ux tests first
npx playwright test --project local --grep @local-stateful-classic --config x-pack/solutions/observability/plugins/ux/test/scout/ui/playwright.config.ts
# run profiling tests
npx playwright test --project local --grep @local-stateful-classic --config x-pack/solutions/observability/plugins/profiling/test/scout/api/playwright.config.ts
```
Before the fix the following error occured:
```
proc [kibana] [2026-05-08T14:05:35.889+02:00][ERROR][plugins.profiling] Error: Saved object [fleet-agent-policies/policy-elastic-agent-on-cloud] not found
proc [kibana] at SavedObjectsErrorHelpers.createGenericNotFoundError (saved_objects_error_helpers.ts:284:28)
proc [kibana] at agent_policy.ts:752:40
proc [kibana] at processTicksAndRejections (node:internal/process/task_queues:104:5)
proc [kibana] at AgentPolicyService.get (agent_policy.ts:747:27)
proc [kibana] at PackagePolicyClientImpl.create (package_policy.ts:547:27)
proc [kibana] at createCollectorPackagePolicy (fleet_policies.ts:89:3)
proc [kibana] at async Promise.all (index 0)
proc [kibana] at setupCloud (setup_cloud.ts:36:3)
proc [kibana] at route.ts:139:11
proc [kibana] at handle (route.ts:161:26)
proc [kibana] at handler (route.ts:78:14)
proc [kibana] at Router.handle (router.ts:209:30)
proc [kibana] at exports.Manager.execute (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
proc [kibana] at Object.internals.handler (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/handler.js:46:20)
proc [kibana] at exports.execute (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/handler.js:31:20)
proc [kibana] at Request._lifecycle (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/request.js:384:32)
proc [kibana] at Request._execute (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/request.js:294:9) {"service":{"version":"9.5.0","type":"kibana","state":"available","node":{"roles":["background_tasks","ui"]},"id":"_jN54-qzRc2aypW_5PVHdw"}}
```
(cherry picked from commit 40f2b94)1 parent c1592a5 commit c218f31
3 files changed
Lines changed: 43 additions & 14 deletions
File tree
- x-pack/solutions/observability
- packages/kbn-scout-oblt/src/playwright/fixtures/worker/profiling
- plugins/profiling/test/scout/api/tests
Lines changed: 27 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | | - | |
53 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
| |||
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
100 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
101 | 114 | | |
102 | | - | |
103 | | - | |
| 115 | + | |
104 | 116 | | |
105 | | - | |
106 | | - | |
107 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
108 | 121 | | |
109 | 122 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
114 | 129 | | |
115 | 130 | | |
116 | 131 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| |||
0 commit comments