-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add e2e playwright tests for grafana (#844)
## Description Adds e2e testing structure and specific e2e test for Grafana using playwright. This test: - Validates existence and successful connection to datasources (Loki and Prometheus) - Validates two custom dashboards exist and dropdowns populate for ns selection (resources and loki quicksearch) - Validates SSO login success ## Related Issue Fixes #764 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md) followed
- Loading branch information
Showing
25 changed files
with
526 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Lint Codespell configurations | ||
[codespell] | ||
skip = .codespellrc,.git,node_modules,build,dist,*.zst,CHANGELOG.md | ||
ignore-words-list = NotIn,AKS,LICENS | ||
enable-colors = | ||
ignore-words-list = NotIn,AKS,LICENS,aks | ||
enable-colors = |
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 |
---|---|---|
|
@@ -191,4 +191,4 @@ variable "db_name" { | |
description = "The name to give the database" | ||
type = string | ||
default = "grafana" | ||
} | ||
} |
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,32 @@ | ||
/** | ||
* Copyright 2024 Defense Unicorns | ||
* SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial | ||
*/ | ||
|
||
import { expect, test as setup } from "@playwright/test"; | ||
import { authFile } from "./playwright.config"; | ||
import { domain } from "./uds.config"; | ||
|
||
const baseURL = `https://sso.${domain}`; | ||
|
||
setup("authenticate", async ({ page, context }) => { | ||
await page.goto(baseURL); | ||
|
||
await page.getByLabel("Username or email").fill("doug"); | ||
await page.getByLabel("Password").fill("unicorn123!@#UN"); | ||
await page.getByRole("button", { name: "Log In" }).click(); | ||
|
||
await page.waitForURL(`${baseURL}/realms/uds/account`); // successful redirect | ||
|
||
// ensure auth cookies were set | ||
const cookies = await context.cookies(); | ||
const keycloakCookie = cookies.find( | ||
(cookie) => cookie.name === "KEYCLOAK_SESSION", | ||
); | ||
|
||
expect(keycloakCookie).toBeDefined(); | ||
expect(keycloakCookie?.value).not.toBe(""); | ||
expect(keycloakCookie?.domain).toContain("sso."); | ||
|
||
await page.context().storageState({ path: authFile }); | ||
}); |
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,54 @@ | ||
/** | ||
* Copyright 2024 Defense Unicorns | ||
* SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial | ||
*/ | ||
|
||
import { expect, test } from "@playwright/test"; | ||
import { domain, fullCore } from "./uds.config"; | ||
|
||
test.use({ baseURL: `https://grafana.admin.${domain}` }); | ||
test.describe.configure({ mode: 'serial' }); | ||
|
||
test("validate loki datasource", async ({ page }) => { | ||
test.skip(!fullCore, "Loki is only present on full core deploys"); | ||
await test.step("check loki", async () => { | ||
await page.goto(`/connections/datasources`); | ||
await page.getByRole('link', { name: 'Loki' }).click(); | ||
await page.click('text=Save & test'); | ||
// Allow 40 second timeout for datasource validation | ||
await expect(page.locator('[data-testid="data-testid Alert success"]')).toBeVisible({ timeout: 40000 }); | ||
}); | ||
}); | ||
|
||
test("validate prometheus datasource", async ({ page }) => { | ||
await test.step("check prometheus", async () => { | ||
await page.goto(`/connections/datasources`); | ||
await page.getByRole('link', { name: 'Prometheus' }).click(); | ||
await page.click('text=Save & test'); | ||
// Allow 20 second timeout for datasource validation | ||
await expect(page.locator('[data-testid="data-testid Alert success"]')).toBeVisible({ timeout: 20000 }); | ||
}); | ||
}); | ||
|
||
// This dashboard is added by the upstream kube-prometheus-stack | ||
test("validate namespace dashboard", async ({ page }) => { | ||
await test.step("check dashboard", async () => { | ||
await page.goto(`/dashboards`); | ||
await page.click('text="Kubernetes / Compute Resources / Namespace (Pods)"'); | ||
await page.getByTestId('data-testid Dashboard template variables Variable Value DropDown value link text authservice').click(); | ||
await page.getByRole('checkbox', { name: 'grafana' }).click(); | ||
}); | ||
}); | ||
|
||
// This dashboard is deployed "custom" by our uds config chart | ||
test("validate loki dashboard", async ({ page }) => { | ||
test.skip(!fullCore, "Loki is only present on full core deploys"); | ||
await test.step("check dashboard", async () => { | ||
await page.goto(`/dashboards`); | ||
await page.getByPlaceholder('Search for dashboards and folders').fill('Loki'); | ||
await page.click('text="Loki Dashboard quick search"'); | ||
await page.getByTestId('data-testid Dashboard template variables Variable Value DropDown value link text authservice').click(); | ||
await page.getByRole('checkbox', { name: 'grafana' }).click(); | ||
await expect(page.getByTestId('data-testid Panel header Logs Panel').getByTestId('data-testid panel content')).toBeVisible(); | ||
}); | ||
}); |
Oops, something went wrong.