Skip to content

Commit

Permalink
Add Playwright and k6 E2E tests for comparison (#637)
Browse files Browse the repository at this point in the history
* WIP: E2E comparison

* WIP: E2E comparison

* Test e2e image for cypress

* Use known good version

* Add nvm init command

* Set user

* Login shell

* Copy init file instead

* Readd user

* Use runner user

* Fix git issue with dir owner

* Test with package updates

* Add Playwright and k6

* Fix cspell error

---------

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
  • Loading branch information
adamyeats and aangelisc authored Nov 6, 2023
1 parent 30b9265 commit 095a2fb
Show file tree
Hide file tree
Showing 11 changed files with 828 additions and 318 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/k6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: E2E tests - k6
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Install Mage
uses: magefile/mage-action@v3
with:
install-only: true

- name: Install yarn dependencies
run: yarn install
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Build binaries
run: mage -v

- name: Build frontend
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Setup k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Start Grafana
run: docker run --rm -d -p 3000:3000 --name=grafana --env GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-azure-data-explorer-datasource --volume "$PWD/dist:/var/lib/grafana/plugins/azure-data-explorer-datasource" grafana/grafana; sleep 30

- name: Run E2E tests
run: k6 run ./e2e/k6/k6.spec.js
env:
E2E_ADX_CLIENT_ID: ${{ secrets.E2E_ADX_CLIENT_ID }}
E2E_ADX_CLIENT_SECRET: ${{ secrets.E2E_ADX_CLIENT_SECRET }}
E2E_ADX_CLUSTER_URL: ${{ secrets.E2E_ADX_CLUSTER_URL }}
E2E_ADX_TENANT_ID: ${{ secrets.E2E_ADX_TENANT_ID }}

58 changes: 58 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: E2E tests - Playwright
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Install Mage
uses: magefile/mage-action@v3
with:
install-only: true

- name: Install yarn dependencies
run: yarn install
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Build binaries
run: mage -v

- name: Build frontend
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Install Playwright Browsers
run: yarn playwright install --with-deps

- name: Start Grafana
run: docker run --rm -d -p 3000:3000 --name=grafana --env GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-azure-data-explorer-datasource --volume "$PWD/dist:/var/lib/grafana/plugins/grafana-azure-data-explorer-datasource" grafana/grafana; sleep 30

- name: Run Playwright tests
run: yarn playwright test
env:
E2E_ADX_CLIENT_ID: ${{ secrets.E2E_ADX_CLIENT_ID }}
E2E_ADX_CLIENT_SECRET: ${{ secrets.E2E_ADX_CLIENT_SECRET }}
E2E_ADX_CLUSTER_URL: ${{ secrets.E2E_ADX_CLUSTER_URL }}
E2E_ADX_TENANT_ID: ${{ secrets.E2E_ADX_TENANT_ID }}

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

2 changes: 2 additions & 0 deletions .github/workflows/pull-request-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
with:
issue-number: ${{ github.event.number }}
body-includes: Use the following command to run this PR with Docker

- name: Update comment on PR
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
Expand All @@ -118,6 +119,7 @@ jobs:
```
docker run --rm -p 3000:3000 grafana/plugin-builds:${{ github.event.pull_request.head.sha }}pre
```
- name: Add comment to PR
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ yarn.lock
.idea
pkg/__debug_bin
provisioning
/test-results/
/playwright-report/
/playwright/.cache/
Loading

0 comments on commit 095a2fb

Please sign in to comment.