Skip to content

Commit 799f6f1

Browse files
[APM][Scout] Stabilize service map embeddable test panel time range (#268459)
## Summary Fixes the flaky **Service map embeddable** Scout test by removing the implicit dependency on wall-clock drift between global setup and test execution. ### Why it was flaky - Global setup ingests \`serviceMapMultiEnv\` synthtrace data at \`now-15m..now\` (anchored to the moment global setup runs). - The Service Map embeddable factory hard-codes a panel-level default \`time_range: { from: 'now-15m', to: 'now' }\` that overrides the dashboard's range, and that range **cannot be configured from the editor flyout** at panel creation time. - For the panel's window to contain the synth window, the entire parallel suite (global setup + everything that runs before this spec) has to complete in well under ~15 minutes. Once the cumulative \`testNow - setupNow\` drift exceeds the 15-minute panel window, the synth data slides fully outside the panel's range and \`service-map-test\`: - disappears from the \`/internal/apm/suggestions\` response → the \`apmServiceMapEditorServiceNameComboBox\` option never appears → \`selectSingleOption\` times out (the original failure in #265639), or - is still selectable but the rendered service map shows "No services available" → the \`serviceMapNode-service-service-map-test\` visibility assertion times out. ### Why we have to use the edit flow The editor flyout exposes only \`service_name\`, \`environment\` and \`kuery\`; it has no UI for \`time_range\`. The factory always seeds the new panel with the 15-minute default, so the only way to widen the panel's queried window is the dashboard-level **Customize panel** flow *after* the panel exists. To make that widened window actually take effect for the suggestions endpoint, we then have to re-open the editor in **edit** mode — \`onEdit\` passes \`timeRangeManager.api.timeRange\$.getValue()\` (now 24h) into the flyout, so the combo boxes' suggestions are resolved in the wider window. We can't apply the filters first and widen later, because the first \`selectSingleOption\` is exactly what was failing. ### What changed \`x-pack/solutions/observability/plugins/apm/test/scout/ui/parallel_tests/service_map/service_map_embeddable.spec.ts\`: 1. Add the Service Map panel **without filters** (just save the empty editor) → panel exists with the factory's default 15-minute custom range and the \`CUSTOM_TIME_RANGE_BADGE\` is asserted. 2. Open the **Customize panel** flyout, ensure the custom time range toggle is on, set the panel's range to **Last 24 hours** via the panel-scoped \`superDatePicker\` quick menu, save. 3. Re-open the editor in **edit** mode via \`embeddablePanelAction-editPanel\` and apply \`service_name\` / \`environment\` / \`kuery\`. With the 24h panel range, the \`apmServiceMapEditorServiceNameComboBox\` reliably resolves \`service-map-test\` even with realistic setup-to-test delay. 4. The remaining assertions (visibility, popover, maximize, fills, disable-custom-time-range, View full service map) run against the 24h panel range, so they no longer depend on the 15-minute synth window aligning with wall-clock \"now\". \`global.setup.ts\` is unchanged — synth still ingests at \`now-15m..now\`. 24h easily covers any realistic delay between global setup and this spec running. ## References Closes #265639 ## Test plan - [ ] CI green - [ ] Local run: \`npx playwright test --config x-pack/solutions/observability/plugins/apm/test/scout/ui/parallel.playwright.config.ts --project local --grep stateful-classic x-pack/solutions/observability/plugins/apm/test/scout/ui/parallel_tests/service_map/service_map_embeddable.spec.ts\` - [ ] Repeat-each smoke (\`--repeat-each=10\`) to confirm flake is gone Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2051ced commit 799f6f1

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

x-pack/solutions/observability/plugins/apm/test/scout/ui/parallel_tests/service_map/service_map_embeddable.spec.ts

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ test.describe(
6161
await pageObjects.dashboard.openAddPanelFlyout();
6262
});
6363

64-
await test.step('add Service map panel with filters', async () => {
64+
await test.step('add Service map panel without filters', async () => {
65+
// Add the panel first with no filters. The Service Map embeddable
66+
// factory always initializes panels with a custom
67+
// `time_range: { from: 'now-15m', to: 'now' }` and that range cannot
68+
// be configured from the editor flyout, so we need the panel to
69+
// exist before we can widen its time range via the Customize panel
70+
// flow below.
6571
await expect(page.getByRole('heading', { name: 'Add to Dashboard' })).toBeVisible();
6672
const serviceMapMenuItem = page.getByRole('menuitem', {
6773
name: 'Service map',
@@ -73,6 +79,41 @@ test.describe(
7379
await expect(
7480
page.getByRole('heading', { name: 'Create service map panel', level: 2 })
7581
).toBeVisible();
82+
await page.testSubj.locator('apmServiceMapEditorSaveButton').click();
83+
});
84+
85+
await test.step('verify panel was added with the default custom time range', async () => {
86+
await pageObjects.dashboard.waitForPanelsToLoad(1);
87+
expect(await pageObjects.dashboard.getPanelCount()).toBe(1);
88+
await expect(page.testSubj.locator('apmServiceMapEmbeddable')).toBeVisible();
89+
await pageObjects.dashboard.expectTimeRangeBadgeExists();
90+
});
91+
92+
await test.step('widen the panel custom time range to last 24 hours', async () => {
93+
// Bump the panel's custom time range from the default 15 minutes to
94+
// 24 hours so it (and the suggestions endpoint when we re-open the
95+
// editor below) covers the synth window even with significant delay
96+
// between global setup and this test running.
97+
await pageObjects.dashboard.openCustomizePanel();
98+
await pageObjects.dashboard.enableCustomTimeRange();
99+
await page.testSubj
100+
.locator('customizePanelTimeRangeDatePicker > superDatePickerToggleQuickMenuButton')
101+
.click();
102+
await pageObjects.dashboard.clickCommonlyUsedTimeRange('Last_24 hours');
103+
await pageObjects.dashboard.saveCustomizePanel();
104+
await pageObjects.dashboard.expectTimeRangeBadgeExists();
105+
});
106+
107+
await test.step('edit Service map panel and apply filters', async () => {
108+
// Re-open the editor in edit mode. The factory passes the panel's
109+
// current `time_range` (now 24 hours) into the suggestions endpoint
110+
// so the service / environment combo boxes can resolve
111+
// `service-map-test` reliably.
112+
await pageObjects.dashboard.clickPanelAction('embeddablePanelAction-editPanel');
113+
await expect(
114+
page.getByRole('heading', { name: 'Edit service map', level: 2 })
115+
).toBeVisible();
116+
76117
// wait for combobox `isLoading` to finish
77118
// before interaction (see `euiLoadingSpinner` + `state: 'hidden'`).
78119
const serviceNameCombo = page.testSubj.locator('apmServiceMapEditorServiceNameComboBox');
@@ -114,9 +155,6 @@ test.describe(
114155
});
115156

116157
await test.step('verify embeddable panel renders service map with connected nodes', async () => {
117-
await pageObjects.dashboard.waitForPanelsToLoad(1);
118-
expect(await pageObjects.dashboard.getPanelCount()).toBe(1);
119-
await expect(page.testSubj.locator('apmServiceMapEmbeddable')).toBeVisible();
120158
await expect(
121159
page.testSubj.locator(
122160
`serviceMapNodeContextHighlightFrame > serviceMapNode-service-${SERVICE_MAP_TEST_SERVICE}`

0 commit comments

Comments
 (0)