Skip to content

Commit a300b15

Browse files
authored
Migrate E2E tests to Playwright (#346)
1 parent d329ea5 commit a300b15

20 files changed

+545
-2589
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ updates:
2121
schedule:
2222
interval: 'weekly'
2323
ignore:
24-
- dependency-name: '@grafana/e2e*'
2524
- dependency-name: 'react'
26-
update-types: ["version-update:semver-major"]
25+
update-types: ['version-update:semver-major']
2726
- dependency-name: 'react-dom'
28-
update-types: ["version-update:semver-major"]
27+
update-types: ['version-update:semver-major']
2928
groups:
3029
all-node-dependencies:
3130
patterns:

.github/workflows/e2e-tests.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: E2E tests
2+
on:
3+
pull_request:
4+
schedule:
5+
- cron: '0 11 * * *' #Run e2e tests once a day at 11 UTC
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
resolve-versions:
13+
name: Resolve Grafana images
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 3
16+
outputs:
17+
matrix: ${{ steps.resolve-versions.outputs.matrix }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Resolve Grafana E2E versions
22+
id: resolve-versions
23+
uses: grafana/plugin-actions/e2e-version@main
24+
with:
25+
version-resolver-type: version-support-policy
26+
27+
playwright-tests:
28+
needs: resolve-versions
29+
timeout-minutes: 60
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
GRAFANA_IMAGE: ${{fromJson(needs.resolve-versions.outputs.matrix)}}
34+
name: e2e ${{ matrix.GRAFANA_IMAGE.name }}@${{ matrix.GRAFANA_IMAGE.VERSION }}
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Setup Node.js environment
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version-file: .nvmrc
43+
44+
- name: Install yarn dependencies
45+
run: yarn install
46+
47+
- name: Install Mage
48+
uses: magefile/mage-action@v3
49+
with:
50+
install-only: true
51+
52+
- name: Build binaries
53+
run: mage -v build:linux
54+
55+
- name: Build frontend
56+
run: yarn build
57+
58+
- name: Install Playwright Browsers
59+
run: yarn playwright install --with-deps
60+
61+
- name: Get secrets from vault
62+
id: get-secrets
63+
uses: grafana/shared-workflows/actions/get-vault-secrets@main
64+
with:
65+
repo_secrets: |
66+
ACCESS_KEY=e2e:accessKey
67+
SECRET_KEY=e2e:secretKey
68+
69+
- name: Start Grafana
70+
run: |
71+
docker compose pull
72+
GRAFANA_VERSION=${{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=${{ matrix.GRAFANA_IMAGE.NAME }} ACCESS_KEY=${{env.ACCESS_KEY}} SECRET_KEY=${{env.SECRET_KEY}} docker compose up -d
73+
74+
- name: Wait for grafana server
75+
uses: grafana/plugin-actions/wait-for-grafana@main
76+
77+
- name: Run Playwright tests
78+
id: run-tests
79+
run: yarn playwright test
80+
81+
# Uncomment this step to upload the Playwright report to Github artifacts.
82+
# If your repository is public, the report will be public on the Internet so beware not to expose sensitive information.
83+
# - name: Upload artifacts
84+
# uses: actions/upload-artifact@v4
85+
# if: ${{ (always() && steps.run-tests.outcome == 'success') || (failure() && steps.run-tests.outcome == 'failure') }}
86+
# with:
87+
# name: playwright-report-${{ matrix.GRAFANA_IMAGE.NAME }}-v${{ matrix.GRAFANA_IMAGE.VERSION }}-${{github.run_id}}
88+
# path: playwright-report/
89+
# retention-days: 30

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ __debug_bin
99
# Test binary, built with `go test -c`
1010
*.test
1111

12-
provisioning
13-
1412
# Logs
1513
logs
1614
*.log
@@ -48,9 +46,12 @@ e2e-results/
4846

4947
# End to End tests
5048
provisioning/
51-
cypress/report.json
52-
cypress/screenshots/actual
53-
cypress/videos/
49+
!provisioning/datasources/aws-redshift-e2e.yaml
50+
/test-results/
51+
/playwright-report/
52+
/blob-report/
53+
/playwright/.cache/
54+
/playwright/.auth/
5455

5556
# OS
5657
*.DS_Store

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ From https://go.dev/blog/get-familiar-with-workspaces:
7070

7171
If you build Grafana locally, you can for example symlink `redshift-datasource` to your clone of `github.com/grafana/grafana`'s `data/plugins` directory, e.g. `cd <path to your Grafana repo>/github.com/grafana/grafana/data/plugins && ln -s <path to your workspaces>/redshift_workspace/redshift-datasource redshift-datasource`
7272

73+
## E2E Tests
74+
75+
1. `yarn playwright install --with-deps`
76+
1. `yarn server`
77+
1. `yarn e2e`
78+
7379
## Build a release for the Redshift data source plugin
7480

7581
You need to have commit rights to the GitHub repository to publish a release.

cspell.config.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
".github/**",
44
"node_modules/**",
55
"dist/**",
6-
"cypress/**",
6+
"playwright*/**",
77
"provisioning/**",
88
"src/dashboards/**",
99
"yarn.lock",
@@ -102,6 +102,11 @@
102102
"eslintcache",
103103
"gofmt",
104104
"pids",
105-
"lefthook"
105+
"lefthook",
106+
"seccomp",
107+
"dataproxy",
108+
"redshiftqueryeditor",
109+
"saletime",
110+
"catname"
106111
]
107112
}

cypress/integration/smoke.spec.ts

Lines changed: 0 additions & 81 deletions
This file was deleted.

cypress/screenshots/blank.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

cypress/tsconfig.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

docker-compose.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
version: '3.0'
2-
31
services:
42
grafana:
3+
user: root
54
container_name: 'grafana-redshift-datasource'
5+
66
build:
77
context: ./.config
88
args:
9-
grafana_version: ${GRAFANA_VERSION:-10.0.0}
9+
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
10+
grafana_version: ${GRAFANA_VERSION:-latest}
1011
ports:
1112
- 3000:3000/tcp
1213
volumes:
1314
- ./dist:/var/lib/grafana/plugins/grafana-redshift-datasource
1415
- ./provisioning:/etc/grafana/provisioning
16+
17+
environment:
18+
ACCESS_KEY: ${ACCESS_KEY}
19+
SECRET_KEY: ${SECRET_KEY}

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"scripts": {
66
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
77
"dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development",
8-
"e2e": "yarn exec cypress install && yarn exec grafana-e2e run",
9-
"e2e:open": "grafana-e2e open",
10-
"e2e:update": "yarn exec cypress install && yarn exec grafana-e2e run --update-screenshots",
8+
"e2e": "playwright test",
119
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
1210
"lint:fix": "yarn run lint --fix",
1311
"server": "docker compose up --build",
@@ -40,10 +38,10 @@
4038
"devDependencies": {
4139
"@babel/core": "^7.26.0",
4240
"@grafana/aws-sdk": "0.6.0",
43-
"@grafana/e2e": "10.2.0",
44-
"@grafana/e2e-selectors": "10.0.0",
4541
"@grafana/eslint-config": "^8.0.0",
42+
"@grafana/plugin-e2e": "^1.16.0",
4643
"@grafana/tsconfig": "^2.0.0",
44+
"@playwright/test": "^1.49.1",
4745
"@stylistic/eslint-plugin-ts": "^2.13.0",
4846
"@swc/core": "^1.10.8",
4947
"@swc/helpers": "^0.5.15",
@@ -55,13 +53,13 @@
5553
"@types/jest": "^29.5.14",
5654
"@types/lodash": "^4.17.14",
5755
"@types/node": "^22.10.7",
56+
"@types/semver": "^7.5.8",
5857
"@types/testing-library__jest-dom": "6.0.0",
5958
"@typescript-eslint/eslint-plugin": "^8.20.0",
6059
"@typescript-eslint/parser": "^8.20.0",
6160
"copy-webpack-plugin": "^12.0.2",
6261
"cspell": "8.17.2",
6362
"css-loader": "^7.1.2",
64-
"cypress": "14.0.0",
6563
"eslint": "^9.18.0",
6664
"eslint-config-prettier": "^10.0.1",
6765
"eslint-plugin-deprecation": "^3.0.0",

0 commit comments

Comments
 (0)