-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
291 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: E2E tests | ||
on: | ||
pull_request: | ||
schedule: | ||
- cron: '0 11 * * *' #once a day at 11 UTC | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
jobs: | ||
resolve-versions: | ||
name: Resolve Grafana images | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 3 | ||
outputs: | ||
matrix: ${{ steps.resolve-versions.outputs.matrix }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Resolve Grafana E2E versions | ||
id: resolve-versions | ||
uses: grafana/plugin-actions/e2e-version@main | ||
with: | ||
version-resolver-type: version-support-policy | ||
|
||
playwright-tests: | ||
needs: resolve-versions | ||
timeout-minutes: 60 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
GRAFANA_IMAGE: ${{fromJson(needs.resolve-versions.outputs.matrix)}} | ||
name: e2e ${{ matrix.GRAFANA_IMAGE.name }}@${{ matrix.GRAFANA_IMAGE.VERSION }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .nvmrc | ||
|
||
- name: Install yarn dependencies | ||
run: yarn install | ||
|
||
- name: Install Mage | ||
uses: magefile/mage-action@v3 | ||
with: | ||
install-only: true | ||
|
||
- name: Build binaries | ||
run: mage -v build:linux | ||
|
||
- name: Build frontend | ||
run: yarn build | ||
|
||
- name: Install Playwright Browsers | ||
run: yarn playwright install --with-deps | ||
|
||
- name: Start Grafana | ||
run: | | ||
docker compose pull | ||
GRAFANA_VERSION=${{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=${{ matrix.GRAFANA_IMAGE.NAME }} docker compose up -d --wait --wait-timeout 60 | ||
- name: Run Playwright tests | ||
id: run-tests | ||
run: yarn playwright test | ||
|
||
# Uncomment this step to upload the Playwright report to Github artifacts. | ||
# If your repository is public, the report will be public on the Internet so beware not to expose sensitive information. | ||
# - name: Upload artifacts | ||
# uses: actions/upload-artifact@v4 | ||
# if: ${{ (always() && steps.run-tests.outcome == 'success') || (failure() && steps.run-tests.outcome == 'failure') }} | ||
# with: | ||
# name: playwright-report-${{ matrix.GRAFANA_IMAGE.NAME }}-v${{ matrix.GRAFANA_IMAGE.VERSION }}-${{github.run_id}} | ||
# path: playwright-report/ | ||
# retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { dirname } from 'path'; | ||
import { defineConfig, devices } from '@playwright/test'; | ||
import type { PluginOptions } from '@grafana/plugin-e2e'; | ||
|
||
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig<PluginOptions>({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: 'http://localhost:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'auth', | ||
testDir: pluginE2eAuth, | ||
testMatch: [/.*\.js/], | ||
}, | ||
{ | ||
name: 'run-tests', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
// @grafana/plugin-e2e writes the auth state to this file, | ||
// the path should not be modified | ||
storageState: 'playwright/.auth/admin.json', | ||
}, | ||
dependencies: ['auth'], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: 1 | ||
|
||
deleteDatasources: | ||
- name: AWS OpenSearch | ||
orgId: 1 | ||
|
||
datasources: | ||
- name: AWS OpenSearch | ||
type: grafana-opensearch-datasource | ||
access: proxy | ||
url: http://localhost:9200/ | ||
basicAuth: true | ||
basicAuthUser: 'admin' | ||
jsonData: | ||
flavor: 'opensearch' | ||
maxConcurrentShardRequests: 5 | ||
pplEnabled: true | ||
serverless: false | ||
timeField: '@timestamp' | ||
tlsAuth: false | ||
tlsSkipVerify: true | ||
version: '2.18.0' | ||
versionLabel: 'OpenSearch 2.18.0' | ||
secureJsonData: | ||
basicAuthPassword: 'my_%New%_passW0rd!@#' # password is set in docker-compose.yaml with the `OPENSEARCH_INITIAL_ADMIN_PASSWORD` env var |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { expect, test } from '@grafana/plugin-e2e'; | ||
|
||
test('should render annotations editor', async ({ annotationEditPage, page, selectors }) => { | ||
await annotationEditPage.datasource.set('AWS OpenSearch'); | ||
await expect(page.getByTestId(selectors.components.QueryField.container)).toBeVisible(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { test, expect } from '@grafana/plugin-e2e'; | ||
|
||
test('should render config editor', async ({ createDataSourceConfigPage, readProvisionedDataSource, page }) => { | ||
const ds = await readProvisionedDataSource({ fileName: 'aws-opensearch.yaml', name: 'AWS OpenSearch' }); | ||
await createDataSourceConfigPage({ type: ds.type }); | ||
await expect(page.getByText('OpenSearch details')).toBeVisible(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { test, expect } from '@grafana/plugin-e2e'; | ||
|
||
test('should render query editor', async ({ panelEditPage, selectors }) => { | ||
await panelEditPage.datasource.set('AWS OpenSearch'); | ||
await expect( | ||
panelEditPage.getQueryEditorRow('A').getByTestId(selectors.components.QueryField.container) | ||
).toBeVisible(); | ||
}); |
Oops, something went wrong.