Skip to content

[Streams] upgrade tests#249617

Merged
CoenWarmer merged 20 commits intoelastic:mainfrom
CoenWarmer:streams-upgrade-tests
Jan 23, 2026
Merged

[Streams] upgrade tests#249617
CoenWarmer merged 20 commits intoelastic:mainfrom
CoenWarmer:streams-upgrade-tests

Conversation

@CoenWarmer
Copy link
Copy Markdown
Contributor

@CoenWarmer CoenWarmer commented Jan 19, 2026

Summary

This updates Streams App Scout tests.

Details

  • Adds Scout API tests for relevant areas
  • Removes Scout UI tests for areas now more reliably covered by API tests
  • Attempts to address low hanging fruit with regards to flaky UI tests for Streams App

UI Tests:

Category Before After Reduction
Data Retention 13 tests (8 files) 8 tests (7 files) -5 tests, -1 file
Data Routing ~24 tests ~24 tests Added comments only
Data Processing ~11 tests ~9 tests -2 tests
Total ~48 tests ~41 tests ~15% reduction

API Tests:

  • lifecycle_retention.spec.ts - 16 tests covering DSL retention, inheritance, switching
  • routing_fork_stream.spec.ts - 24 tests covering all condition types (eq, neq, and, or, not, etc.)
  • processing_simulate.spec.ts - 28 tests covering all processor types (grok, dissect, date, rename, etc.)
  • schema_field_mapping.spec.ts - 27 tests covering field type simulation

@CoenWarmer CoenWarmer requested review from a team as code owners January 19, 2026 16:44
@CoenWarmer CoenWarmer added backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Jan 19, 2026
@CoenWarmer CoenWarmer changed the title Streams upgrade tests [Streams] upgrade tests Jan 19, 2026
Copy link
Copy Markdown
Contributor

@Kerry350 Kerry350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👏

Just a question about the location: for the API tests should they still live in the streams_app plugin, or should those move to the streams plugin since that's where the server side code lives?

@CoenWarmer
Copy link
Copy Markdown
Contributor Author

Nice work 👏
ty :)

Just a question about the location: for the API tests should they still live in the streams_app plugin, or should those move to the streams plugin since that's where the server side code lives?

Good question. I think it probably makes more sense to move them to streams plugin as the tests will be closest to their implementations.

@CoenWarmer CoenWarmer enabled auto-merge (squash) January 23, 2026 09:13
@CoenWarmer CoenWarmer requested a review from a team as a code owner January 23, 2026 11:45
Comment on lines +43 to +47
// Wait for the data view switcher to be available before selecting
await page.locator('[data-test-subj*="dataView-switch-link"]').waitFor({
state: 'visible',
timeout: 30_000,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for this element is already handled inside pageObjects.discover.selectDataView:

const currentValue = await this.page.testSubj.innerText('*dataView-switch-link');

will wait for 10 sec (default) to locate the element.

What I used in other tests, was these 2 methods:

      await pageObjects.discover.waitUntilSearchingHasFinished();
      await pageObjects.discover.waitForHistogramRendered();

you can use both or at least wait for histogram to render before selecting data view.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dmlemeshko, that's very helpful

Comment on lines +52 to +56
// Wait for the data grid to be fully rendered
await page.locator('[data-test-subj="discoverDocTable"]').waitFor({
state: 'visible',
timeout: 30_000,
});
Copy link
Copy Markdown
Contributor

@dmlemeshko dmlemeshko Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already done with await pageObjects.discover.waitForDocTableRendered()

Comment on lines +117 to +121
// Wait for the data grid to be fully rendered
await page.locator('[data-test-subj="discoverDocTable"]').waitFor({
state: 'visible',
timeout: 30_000,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await pageObjects.discover.waitForDocTableRendered()

// Verify the doc viewer flyout is open
await expect(page.getByTestId('kbnDocViewer')).toBeVisible();
// Verify the doc viewer flyout is open (with extended timeout for flyout animation)
await expect(page.getByTestId('kbnDocViewer')).toBeVisible({ timeout: 30_000 });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 99 to 103
await page.getByTestId('streamsAppContentAddFieldButton').click();

// Wait `/fields_metadata` so that we are sure the ECS/Otel mapping recommendations are available
await page.waitForResponse(
(response) => response.url().includes('/fields_metadata') && response.ok()
);

// Add an Otel field that should have type recommendation (IP type)
const ecsFieldName = 'resource.attributes.host.ip';
await pageObjects.streams.typeFieldName(ecsFieldName);
Copy link
Copy Markdown
Contributor

@dmlemeshko dmlemeshko Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need any extra wait between clicking Add field and start typing to replace removed logic? We saw in the past event handler not being attached fast enough and Kibana acting weird.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't hurt

Comment on lines +27 to +39
try {
await esClient.index({
index: 'logs',
document: {
'@timestamp': new Date().toISOString(),
message: 'Test document for streams API tests',
},
refresh: true,
});
log.debug('[setup] Test document indexed successfully');
} catch (error) {
log.debug(`[setup] Failed to index test document: ${error}`);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is it ok to proceed with tests run even if indexing failed? The same question is related to enabling streams

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to mark that as a failure.

Comment on lines +13 to +21
try {
await kbnClient.request({
method: 'POST',
path: '/api/streams/_enable',
});
log.debug('[setup] Streams enabled successfully');
} catch (error) {
log.debug(`[setup] Streams may already be enabled: ${error}`);
}
Copy link
Copy Markdown
Contributor

@dmlemeshko dmlemeshko Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik we don't need try/catch as it won't throw error if Streams've been already enabled.

We already have this code working:

await kbnClient.request({
method: 'POST',
path: `${basePath}/api/streams/_enable`,
});

Comment on lines +16 to +29
api/
├── playwright.config.ts # Scout API test configuration
├── constants.ts # Common headers and constants
├── fixtures/
│ ├── index.ts # Test fixtures extending apiTest
│ └── constants.ts # User roles and API headers
├── services/
│ └── streams_api_service.ts # Streams API helper service
└── tests/
├── global.setup.ts # Global setup (enables Streams)
├── processing_simulate.spec.ts
├── routing_fork_stream.spec.ts
├── schema_field_mapping.spec.ts
└── lifecycle_retention.spec.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy the day has come :) After UI tests count crossed 200 I was hoping someone will change the pattern and add API tests for Streams. Thank you @CoenWarmer 👏

Copy link
Copy Markdown
Contributor

@dmlemeshko dmlemeshko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.buildkite/scout_ci_config.yml changes LGTM, I left a few minor comments.

@CoenWarmer
Copy link
Copy Markdown
Contributor Author

Thanks for the review @dmlemeshko, very helpful!

@CoenWarmer CoenWarmer merged commit 40ae3b8 into elastic:main Jan 23, 2026
15 of 16 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Scout: [ platform / fleet ] plugin / Create Integration is not accessible when user is basic
  • [job] [logs] Scout: [ platform / fleet ] plugin / stateful - User with basic license should hit License Paywall - Create Integration is not accessible when user is basic

Metrics [docs]

✅ unchanged

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants