-
Notifications
You must be signed in to change notification settings - Fork 32
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
Docs: Plugin E2E - Add Setup Resources article #748
Conversation
Hello! 👋 This repository uses Auto for releasing packages using PR labels. ✨ This PR can be merged. It will not be considered when calculating future versions of the npm packages and will not appear in the changelogs. |
|
||
# Introduction | ||
|
||
In many cases, you'll need certain resources to be configured in Grafana before you can run your e2e tests. This guide covers how to setup the resources that you need. |
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.
In many cases, you'll need certain resources to be configured in Grafana before you can run your e2e tests. This guide covers how to setup the resources that you need. | |
In many cases, you'll need certain resources to be configured in Grafana before you can run your e2e tests. For example, to test how a panel plugin displays data, you'll need a data source configured to query and return that data. This guide covers how to setup the resources that you need through [provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/). |
|
||
You may use [provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) to configure resources such as dashboards and data sources. | ||
|
||
> If running e2e tests in CI requires provisioning, you may need to remove the `provisioning` folder from your plugin's `.gitignore` file. Be careful not to commit secrets to public repositories. Use [environment variable](https://grafana.com/docs/grafana/latest/administration/provisioning/#using-environment-variables) interpolation for sensitive data. |
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.
These feel like separate points. Displaying them is awkward
> If running e2e tests in CI requires provisioning, you may need to remove the `provisioning` folder from your plugin's `.gitignore` file. Be careful not to commit secrets to public repositories. Use [environment variable](https://grafana.com/docs/grafana/latest/administration/provisioning/#using-environment-variables) interpolation for sensitive data. | |
:::note | |
If running e2e tests in CI requires provisioning, you may need to remove the `provisioning` folder from your plugin's `.gitignore` file. | |
::: | |
:::danger | |
Be careful not to commit secrets to public repositories. Use [environment variable](https://grafana.com/docs/grafana/latest/administration/provisioning/#using-environment-variables) interpolation for sensitive data. | |
::: |
These read like separate points of differing levels of concern. A slightly awkward display, but generally we dont use > quote blocks
|
||
`@grafana/plugin-e2e` provides fixtures that enables you to read files that you have placed in the `provisioning` folder. | ||
|
||
### `readProvisionedDataSource` fixture |
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.
code styling always looks weird in headers/bold in general. Not sure if @jackw has a suggestion here, but a simple suggestion would be to drop "fixture"
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.
looks slightly better now that it's and h4 instead of h3.
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.
My suggestion would be to not use it. Headings using multiple fonts always look jarring to me.
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.
Okay - I'll make sure code styling is not used in headings. 👍
Co-authored-by: David Harris <david.harris@grafana.com>
Co-authored-by: David Harris <david.harris@grafana.com>
Co-authored-by: David Harris <david.harris@grafana.com>
Co-authored-by: David Harris <david.harris@grafana.com>
Co-authored-by: David Harris <david.harris@grafana.com>
aea0030
to
3c9ad0f
Compare
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.
Left a question more for my own understanding than anything else. 🚀
|
||
```ts title="configEditor.spec.ts" | ||
const datasource = readProvisionedDataSource<JsonData, SecureJsonData>({ fileName: 'datasources.yml' }); | ||
await page.getByLabel('API Key').fill(datasource.secureJsonData.apiKey); |
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.
Above we claim it's dangerous to commit secrets to public repos and to use env vars for sensitive data but here we grab an API key from a datasources.yml file. Am I wrong or is this example contradicting the advice above?
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.
As long as secrets are being defined with environment variables in the provisioned file it should be fine. Look at this example for the google-sheets datasource:
datasources:
- editable: true
enabled: true
jsonData:
authType: jwt
name: Google Sheets Service Account
secureJsonData:
jwt: ${GOOGLE_JWT_FILE}
type: grafana-googlesheets-datasource
version: 1
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
What this PR does / why we need it:
This PR adds a new article that walks through how to set up the resources you'll need for e2e testing. See this epic for better understanding of how this article fits into the bigger picture.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: