Skip to content

Commit

Permalink
WIP: E2E comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyeats committed Oct 4, 2023
1 parent a35e52c commit 4865a65
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 48 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: E2E tests - Cypress
on: [push, pull_request]

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js

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

- name: Install yarn dependencies
run: yarn install
env:
Expand All @@ -22,5 +24,9 @@ jobs:
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- 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:/var/lib/grafana/plugins" grafana/grafana

- name: Run E2E tests
run: yarn run e2e
9 changes: 7 additions & 2 deletions .github/workflows/k6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: E2E tests - k6
on: [push, pull_request]

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

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

- name: Install yarn dependencies
run: yarn install
env:
Expand All @@ -22,14 +24,17 @@ jobs:
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:/var/lib/grafana/plugins" grafana/grafana
- name: Run e2e tests

- name: Run E2E tests
run: k6 run ./e2e/k6/k6.test.js
50 changes: 28 additions & 22 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,34 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install yarn dependencies
run: yarn install
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Build
run: go build -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:/var/lib/grafana/plugins" grafana/grafana
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/checkout@v3

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

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

- name: Build
run: go build -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:/var/lib/grafana/plugins" grafana/grafana

- name: Run Playwright tests
run: yarn playwright test

# - uses: actions/upload-artifact@v3
# if: always()
Expand Down
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
8 changes: 4 additions & 4 deletions e2e/k6/k6.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ export async function addDatasource(page) {

// form inputs
const inputs = {
'Client ID': '',
'Client Secret': '',
'Cluster URL': '',
'Tenant ID': '',
'Client ID': __ENV.E2E_ADX_CLIENT_ID,
'Client Secret': __ENV.E2E_ADX_CLIENT_SECRET,
'Cluster URL': __ENV.E2E_ADX_CLUSTER_URL,
'Tenant ID': __ENV.E2E_ADX_TENANT_ID,
};

// fill in form inputs
Expand Down
35 changes: 22 additions & 13 deletions e2e/playwright/playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getDashboardUid = (url) => {
}
};

test('Login', async ({ page }) => {
async function login(page) {
await page.goto(`http://localhost:3000${selectors.pages.Login.url}`, {
waitUntil: 'networkidle',
});
Expand All @@ -39,9 +39,9 @@ test('Login', async ({ page }) => {
expect(buttons.skip).toBeAttached();

await buttons.skip.click();
});
};

test('Add datasource', async ({ page }) => {
async function addDatasource(page) {
await page.goto(`http://localhost:3000${selectors.pages.AddDataSource.url}`, {
waitUntil: 'networkidle',
});
Expand All @@ -58,10 +58,10 @@ test('Add datasource', async ({ page }) => {

// form inputs
const inputs = {
'Client ID': '',
'Client Secret': '',
'Cluster URL': '',
'Tenant ID': '',
'Client ID': process.env.E2E_ADX_CLIENT_ID,
'Client Secret': process.env.E2E_ADX_CLIENT_SECRET,
'Cluster URL': process.env.E2E_ADX_CLUSTER_URL,
'Tenant ID': process.env.E2E_ADX_TENANT_ID,
};

// fill in form inputs
Expand All @@ -73,9 +73,9 @@ test('Add datasource', async ({ page }) => {

// checks the page for the data source is working message
expect(page.locator('[aria-label="Create a dashboard"]')).toContainText('building a dashboard');
});
};

test('Add dashboard', async ({ page }) => {
async function addDashboard(page) {
await page.goto(`http://localhost:3000${selectors.pages.AddDashboard.url}`, { waitUntil: 'networkidle' });

// checks for the create dashboard button
Expand All @@ -97,9 +97,9 @@ test('Add dashboard', async ({ page }) => {

// checks that the dashboard is created successfully
expect(page.locator('div[data-testid="data-testid Alert success"]')).toBeAttached();
});
};

test('Configure panel', async ({ page }) => {
async function configurePanel(page) {
const dashboardURL = page.url();
await page.goto(`${dashboardURL}`, { waitUntil: 'networkidle' });

Expand Down Expand Up @@ -127,14 +127,15 @@ test('Configure panel', async ({ page }) => {
// run query
const runQueryBtn = page.locator(`[data-testid="data-testid run-query"]`);
await runQueryBtn.click();

// are there results?
const columns = page.locator(`[aria-label="Columns"]`);
await columns.click();

expect(page.locator('[aria-label="Select options menu"]').innerHTML()).toContain('_val1_');
});
};

test('Remove dashboard', async ({ page }) => {
export async function removeDashboard(page) {
const dashboardUID = getDashboardUid(page.url());
await page.goto(`http://localhost:3000/d/${dashboardUID}`, { waitUntil: 'networkidle' });

Expand All @@ -158,4 +159,12 @@ test('Remove dashboard', async ({ page }) => {

// checks for success alert message
expect(page.locator('div[data-testid="data-testid Alert success"]')).toBeAttached();
};

test('Azure Data Explorer dashboard', async ({ page }) => {
await login(page);
await addDatasource(page);
await addDashboard(page);
await configurePanel(page);
await removeDashboard(page);
});
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,5 @@
"resolutions": {
"**/@testing-library/dom": "7.31.2"
},
"packageManager": "yarn@1.22.19",
"volta": {
"node": "18.18.0",
"yarn": "1.22.19"
}
"packageManager": "yarn@1.22.19"
}

0 comments on commit 4865a65

Please sign in to comment.