Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Observability] [RAC] Add basic functional tests for observability alerts #109876

Merged
merged 7 commits into from
Sep 1, 2021

Conversation

Kerry350
Copy link
Contributor

@Kerry350 Kerry350 commented Aug 24, 2021

Summary

This implements #108360. The intention is to fail hard and fail fast if the Observability > Alerts page isn't working as expected.

It adds a new archive which contains some alerts data for some logs, metrics, and APM rules. It also enables xpack.observability.unsafe.alertingExperience.enabled=true in the xpack config, same as xpack.observability.unsafe.cases.enabled=true.

With archives and scaffolding in place it will be much easier to add functional tests on top of this.

Notes

These tests are focussed purely on the Observability > Alerts UI aspect.

With regards to writing of data:

It does look, however, like we should expand the Observability feature controls tests to cover alerts. There are tests for cases already: https://github.com/elastic/kibana/blob/master/x-pack/test/functional/apps/observability/feature_controls/observability_security.ts

@Kerry350
Copy link
Contributor Author

@elasticmachine merge upstream

@Kerry350
Copy link
Contributor Author

This is ready for review now. Kerry350@bb9f05c removed the filter check (as we don't have the default filter now), and the archive data has been amended to account for open / closed correctly changing to active / recovered upstream.

@Kerry350 Kerry350 marked this pull request as ready for review August 31, 2021 10:41
@Kerry350 Kerry350 requested a review from a team August 31, 2021 10:41
@Kerry350 Kerry350 self-assigned this Aug 31, 2021
@Kerry350 Kerry350 added Feature:Observability RAC Feature:RAC label obsolete Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.15.0 v8.0.0 labels Aug 31, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)

@Kerry350 Kerry350 added the release_note:skip Skip the PR/issue when compiling release notes label Aug 31, 2021
Copy link
Contributor

@miltonhultgren miltonhultgren left a comment

Choose a reason for hiding this comment

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

Just leaving some questions, mostly for me to learn :)


describe('Alerts table', () => {
it('Renders the table', async () => {
await testSubjects.existOrFail('events-viewer-panel');
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be a good idea to keep a file of subject selector constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should create a custom Observability Alerting provider moving forward. Here's an example one: https://github.com/elastic/kibana/blob/master/x-pack/test/functional/services/logs_ui/log_stream.ts, these services let us create functions to perform little selector shortcuts / common interactions etc. I haven't added it for this first addition, but as we'll be adding a lot more functional tests it can come soon. It would be somewhat related to: #110627

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I sneakily turned the "set up suites with different permission combinations" task we talked about into actually creating a testing framework service. 😇 I like how the ml team set up a substructure for their page objects/services within their provider.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good!


it('Renders the correct number of cells', async () => {
// NOTE: This isn't ideal, but EuiDataGrid doesn't really have the concept of "rows"
const cells = await testSubjects.findAll('dataGridRowCell');
Copy link
Contributor

Choose a reason for hiding this comment

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

Does EUI provide some kind of POM/Facades for their components?

Else we might consider in the future creating something like that for ourself. Using selectors that another team specifies could easily lead to our tests breaking and having some layer in between would make it easier to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so.

I agree using selectors from other teams is generally not a good idea. However, in this case (and I'm not sure if this is clear at first) the testSubjects service hooks into our data-test-subj attributes (as opposed to random classes / IDs etc), this is a well established pattern in Kibana. Generally speaking EUI don't randomly change the top level data-test-subj attributes on their components. I did look at the time to see if the cells could take a custom data-test-subj as a prop, but it didn't seem to be the case (passing this as a prop to EUI components is very often an option). I might have missed the option somewhere, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks for the info!

Copy link
Member

Choose a reason for hiding this comment

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

The other benefit is that if EUI breaks our tests with a PR, they get to fix them :D

const pageObjects = getPageObjects(['common']);
const testSubjects = getService('testSubjects');

before(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this like beforeEach or beforeAll?

I spoke with Dario yesterday and he mentioned that within APM they have a setup that loads one dataset for all of their functional tests (rather than per suite), is that something we want to copy?
The downside is that the tests risk becoming more coupled but the gain is speed due to less data loading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

before could be considered the same as beforeAll, it'll run once for the describe block.

is that something we want to copy?

It's a good question. APM's setup is fairly custom (if this is regarding the tests at test/apm_api_integration) where they have their own config, helpers etc. So we could potentially do something similar, but it wouldn't really follow the expected format of tests at test/functional/apps 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better to stick to conventions then and see how the speed of the test framework may be improved instead.

@mgiota
Copy link
Contributor

mgiota commented Aug 31, 2021

@Kerry350 I was looking at the data.json file you added and I found only alerts where consumer="alerts". Wouldn't it make sense to add a few more alerts where consumer is the respective UI app (apm, logs or infrastructure)?

@Kerry350
Copy link
Contributor Author

Kerry350 commented Sep 1, 2021

@mgiota

I was looking at the data.json file you added and I found only alerts where consumer="alerts". Wouldn't it make sense to add a few more alerts where consumer is the respective UI app (apm, logs or infrastructure)?

It would make sense for the security / privilege centric tests. I can push some data changes.

Copy link
Contributor

@miltonhultgren miltonhultgren left a comment

Choose a reason for hiding this comment

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

LGTM, as mentioned next steps will include creating custom test subjects :)

@Kerry350
Copy link
Contributor Author

Kerry350 commented Sep 1, 2021

I've regenerated the archive data. There's now added variability across consumer / producer and also workflow status. Still a small enough dataset to be able to decompress and inspect if needed though (useful when actually writing tests). I'll merge once green as the only things changed are values to match the new data.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @Kerry350

Kerry350 added a commit that referenced this pull request Sep 1, 2021
…erts (#109876) (#110815)

* Add basic functional tests for observability alerts
Kerry350 added a commit that referenced this pull request Sep 1, 2021
…erts (#109876) (#110816)

* Add basic functional tests for observability alerts
@mgiota
Copy link
Contributor

mgiota commented Sep 20, 2021

@Kerry350 Do you mention somewhere how we run these tests?

@Kerry350
Copy link
Contributor Author

@mgiota You can use the commands here: #111297 (comment), they're just the standard functional test commands (e.g. https://www.elastic.co/guide/en/kibana/current/development-tests.html#development-functional-tests) but with a specific config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Observability RAC Feature:RAC label obsolete release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.15.0 v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants