Skip to content

Commit

Permalink
Add Grafana Bench action (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyeats authored Oct 29, 2024
1 parent e8ff1eb commit 8819846
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 8 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ jobs:
compose-file: './docker-compose.yml'

- name: Wait for Grafana to start
uses: nev7n/wait_for_response@v1
with:
url: 'http://localhost:3000/'
responseCode: 200
timeout: 60000
interval: 500
run: |
curl http://localhost:3000
#RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000)
#echo $response
#if [ $RESPONSE -ne 200 ]; then
# sleep 5;
# echo "Grafana is not accessible"
# exit 1
#fi
- name: Run Playwright tests
run: yarn playwright test
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/grafana-bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Grafana Bench
on:
push:
# Only run on push to the main branch
branches: [main, master]

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

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Build backend
uses: magefile/mage-action@v3
with:
args: buildAll
version: latest

- name: Install frontend dependencies
run: yarn install --frozen-lockfile

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

- name: Install and run Docker Compose
uses: hoverkraft-tech/[email protected]
with:
compose-file: './docker-compose.yml'

- name: Wait for Grafana to start
run: |
curl http://localhost:3000
#RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000)
#echo $response
#if [ $RESPONSE -ne 200 ]; then
# sleep 5;
# echo "Grafana is not accessible"
# exit 1
#fi
- name: Run Grafana Bench tests
run: |
docker run --rm \
--network=host \
--volume="./:/home/bench/tests/" \
us-docker.pkg.dev/grafanalabs-global/docker-grafana-bench-prod/grafana-bench:v0.3.0-rc3 test \
--grafana-admin-password "admin" \
--grafana-admin-user "admin" \
--grafana-url "http://localhost:3000" \
--log-level DEBUG \
--pw-execute-cmd "yarn e2e" \
--pw-prepare-cmd "yarn install --frozen-lockfile && yarn playwright install" \
--test-env-vars "CI=true" \
--test-runner "playwright" \
--test-suite-base "/home/bench/tests/"
8 changes: 6 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ export default defineConfig<PluginOptions>({
/* 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:${process.env.PORT || 3000}`,
baseURL: process.env.GRAFANA_URL || `http://localhost:${process.env.PORT || 3000}`,

launchOptions: {
executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
},

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'on'
video: 'on',
},

/* Configure projects for major browsers */
Expand Down

0 comments on commit 8819846

Please sign in to comment.