-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Observability] [RAC] Add basic functional tests for observability alerts #109876
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
Changes from all commits
4af2c08
9ab2fbf
ce21a13
bb9f05c
02f965c
ff106fd
3cabd63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import expect from '@kbn/expect'; | ||
| import querystring from 'querystring'; | ||
| import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
|
||
| // Based on the x-pack/test/functional/es_archives/observability/alerts archive. | ||
| const DATE_WITH_DATA = { | ||
| rangeFrom: '2021-08-31T13:36:22.109Z', | ||
| rangeTo: '2021-09-01T13:36:22.109Z', | ||
| }; | ||
|
|
||
| export default ({ getPageObjects, getService }: FtrProviderContext) => { | ||
| const esArchiver = getService('esArchiver'); | ||
|
|
||
| describe('Observability alerts', function () { | ||
| this.tags('includeFirefox'); | ||
|
|
||
| const pageObjects = getPageObjects(['common']); | ||
| const testSubjects = getService('testSubjects'); | ||
|
|
||
| before(async () => { | ||
| await esArchiver.load('x-pack/test/functional/es_archives/observability/alerts'); | ||
| await pageObjects.common.navigateToUrlWithBrowserHistory( | ||
| 'observability', | ||
| '/alerts', | ||
| `?${querystring.stringify(DATE_WITH_DATA)}` | ||
| ); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| await esArchiver.unload('x-pack/test/functional/es_archives/observability/alerts'); | ||
| }); | ||
|
|
||
| describe('Alerts table', () => { | ||
| it('Renders the table', async () => { | ||
| await testSubjects.existOrFail('events-viewer-panel'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, thanks for the info!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| expect(cells.length).to.be(54); | ||
| }); | ||
| }); | ||
| }); | ||
| }; | ||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beforecould be considered the same asbeforeAll, it'll run once for thedescribeblock.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 attest/functional/apps🤔There was a problem hiding this comment.
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.