plugin-tools icon indicating copy to clipboard operation
plugin-tools copied to clipboard

Plugin E2E: Add support for testing alert query

Open sunker opened this issue 1 year ago • 1 comments

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 https://github.com/grafana/plugin-tools/issues/796

Will follow up with a docs PR later.

📦 Published PR as canary version: Canary Versions

:sparkles: Test out this PR locally via:

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

sunker avatar Feb 26 '24 18:02 sunker

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.

github-actions[bot] avatar Feb 29 '24 08:02 github-actions[bot]

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

sunker avatar May 21 '24 07:05 sunker

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 05 '24 06:06 CLAassistant

@josmperez can you take a look at the docs?

sunker avatar Jun 05 '24 07:06 sunker

:rocket: PR was released in @grafana/[email protected] :rocket: