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

Plugin E2E: Add support for testing alert query #779

Merged
merged 23 commits into from
Jun 7, 2024
Merged

Conversation

sunker
Copy link
Contributor

@sunker sunker commented Feb 26, 2024

What this PR does / why we need it:

This PR makes it possible to write e2e tests that verifies that a backend data source plugin can return data frames in a format that is compatible with alerting.

The process for testing alerting compatibility is as follows:

  1. Use alertRuleEditPage fixture to open a new, empty alert rule edit page OR use the gotoAlertRuleEditPage fixture to open an already existing alert rule.
  2. Get query editor row, set data source and fill in the query
  3. Click the Preview button to evaluate the alert query. If successful, the data source is compatible with alerting.

This AlertRuleEditPage model follows the same pattern as all the other page models - it can be instantiated with or without an id. As mentioned above, it's exposed through alertRuleEditPage fixture (new alert rules) and gotoAlertRuleEditPage fixture (existing alert rules). I've also added a readProvisionedAlertRule that makes it possible to read a provisioned alert rule.

In practice, I think this will be useful to check for regressions in backend data source plugins. In the past, it has happened that changes to the backend code and how the data frames are being constructed leads to breakages in alerting. Running e2e tests that checks for breakages should be able to catch these regressions.

Which issue(s) this PR fixes:

Part of #796

Will follow up with a docs PR later.

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @grafana/[email protected]
# or 
yarn add @grafana/[email protected]

@sunker sunker changed the title [wip]: Plugin E2E: Add support for testing alert rule compatibility [wip]: Plugin E2E: Add support for testing alert query Feb 26, 2024
Copy link

github-actions bot commented Feb 29, 2024

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged and will trigger a new minor release.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

@sunker sunker added minor Increment the minor version when merged release Create a release when this pr is merged labels Feb 29, 2024
@sunker sunker force-pushed the plugin-e2e/alerting branch 2 times, most recently from 209773f to e8bb71d Compare April 25, 2024 07:11
@sunker sunker changed the title [wip]: Plugin E2E: Add support for testing alert query Plugin E2E: Add support for testing alert query Apr 25, 2024
@sunker sunker marked this pull request as ready for review April 25, 2024 08:03
@sunker sunker requested a review from a team as a code owner April 25, 2024 08:03
@sunker sunker requested review from mckn and removed request for a team April 25, 2024 08:03
Copy link
Collaborator

@mckn mckn left a comment

Choose a reason for hiding this comment

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

I think this looks great!

I think the flows are a bit different if you are defining the alert rules as Grafana managed and Datasource managed alert rules. But I guess it should be enough to test the datasource via the Grafana managed flow.

@sunker
Copy link
Contributor Author

sunker commented May 21, 2024

@josmperez do you want to have a look at the docs?

Copy link
Contributor

@josmperez josmperez left a comment

Choose a reason for hiding this comment

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

ignore approval (added it to wrong PR). i will review soon.

@josmperez josmperez self-requested a review May 23, 2024 16:19
@CLAassistant
Copy link

CLAassistant commented Jun 5, 2024

CLA assistant check
All committers have signed the CLA.

@sunker
Copy link
Contributor Author

sunker commented Jun 5, 2024

@josmperez can you take a look at the docs?

Copy link
Contributor

@josmperez josmperez 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. LGTM.

@sunker sunker self-assigned this Jun 7, 2024
@sunker sunker merged commit e97e1bd into main Jun 7, 2024
20 checks passed
@sunker sunker deleted the plugin-e2e/alerting branch June 7, 2024 11:41
@grafana-plugins-platform-bot
Copy link

🚀 PR was released in @grafana/[email protected] 🚀

@grafana-plugins-platform-bot grafana-plugins-platform-bot bot added the released This issue/pull request has been released. label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged release Create a release when this pr is merged released This issue/pull request has been released.
Projects
Development

Successfully merging this pull request may close these issues.

4 participants