Skip to content

Commit

Permalink
chore: add e2e in cluster testing (#451)
Browse files Browse the repository at this point in the history
Co-authored-by: UncleGedd <42304551+UncleGedd@users.noreply.github.com>
  • Loading branch information
decleaver and UncleGedd authored Oct 22, 2024
1 parent 62fd169 commit 267b611
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: ./.github/actions/setup

- name: smoke-test
run: uds run test:smoke --set DIR=hack/smoke-test
run: uds run test:smoke

- name: Publish
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
type: [unit, e2e, api, local-auth, e2e-reconnect]
type: [unit, e2e, e2e-in-cluster, api, local-auth, e2e-reconnect]
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
Expand All @@ -44,7 +44,7 @@ jobs:
timeout-minutes: 30

- name: Debug Output
if: ${{ matrix.type == 'e2e'}}
if: ${{ matrix.type == 'e2e'|| matrix.type == 'e2e-in-cluster' }}
uses: defenseunicorns/uds-common/.github/actions/debug-output@e3008473beab00b12a94f9fcc7340124338d5c08 # v0.13.1

- name: Save logs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: smoke-test
run: uds run test:smoke --set DIR=hack/smoke-test
run: uds run test:smoke --set DIR=hack/test

- name: Publish
run: |
Expand Down
25 changes: 0 additions & 25 deletions hack/smoke-test/zarf.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions hack/test/e2e-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024 Defense Unicorns
# SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial

sso:
enabled: false

image:
repository: uds-runtime
tag: test
pullPolicy: Always
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

image:
repository: uds-runtime
tag: smoke-test
tag: test
pullPolicy: Always
41 changes: 41 additions & 0 deletions hack/test/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2024 Defense Unicorns
# SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial

kind: ZarfPackageConfig
metadata:
name: uds-runtime
version: test

variables:
- name: DOMAIN
default: "uds.dev"

components:
- name: uds-runtime
required: true
description: smoke test of nightly release of uds-runtime
only:
flavor: smoke
images:
- uds-runtime:test # local copy of uds-runtime
charts:
- name: uds-runtime
localPath: ../../chart
namespace: uds-runtime
version: 0.1.0
valuesFiles:
- smoke-values.yaml
- name: uds-runtime
required: true
description: e2e test of uds-runtime running in cluster
only:
flavor: e2e
images:
- uds-runtime:test # local copy of uds-runtime
charts:
- name: uds-runtime
localPath: ../../chart
namespace: uds-runtime
version: 0.1.0
valuesFiles:
- e2e-values.yaml
33 changes: 28 additions & 5 deletions tasks/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ tasks:
actions:
- cmd: CGO_ENABLED=0 GOARCH=arm64 GOOS=darwin go build -o build/uds-runtime-darwin-arm64 .

- name: api-linux
description: "build the go api server for linux and local architecture"
actions:
- cmd: CGO_ENABLED=0 GOOS=linux go build -o build/uds-runtime-linux-$UDS_ARCH .

- name: api
description: "build the go api server for the local platform"
actions:
Expand Down Expand Up @@ -87,11 +92,29 @@ tasks:
- cmd: ./uds zarf p publish build/zarf-package-uds-runtime-arm64-${REF}.tar.zst oci://ghcr.io/defenseunicorns/packages/uds
dir: ${DIR}

- name: smoke-img-pkg
description: "build docker image and zarf package for nightly smoke test"
- name: smoke-img-pkg-amd
description: "build amd docker image and zarf package for nightly smoke test"
actions:
- task: ui
- task: api-linux-amd64
- cmd: docker build --build-arg TARGETARCH=amd64 -t uds-runtime:smoke-test -f ./Dockerfile .
- cmd: uds zarf package create -o build --confirm
dir: hack/smoke-test
- cmd: docker build --build-arg TARGETARCH=amd64 -t uds-runtime:test -f ./Dockerfile .
- cmd: uds zarf package create -o build/smoke --flavor smoke --confirm
dir: hack/test

- name: smoke-img-pkg-arm
description: "build arm docker image and zarf package for nightly smoke test"
actions:
- task: ui
- task: api-linux-arm64
- cmd: docker build --build-arg TARGETARCH=arm64 -t uds-runtime:test -f ./Dockerfile .
- cmd: uds zarf package create -o build/smoke --flavor smoke --confirm
dir: hack/test

- name: e2e-img-pkg
description: "build docker image and zarf package for e2e in cluster tests based on local arch"
actions:
- task: ui
- task: api-linux
- cmd: docker build --build-arg TARGETARCH=$UDS_ARCH -t uds-runtime:test -f ./Dockerfile .
- cmd: uds zarf package create -o build/e2e --flavor e2e --confirm
dir: hack/test
94 changes: 65 additions & 29 deletions tasks/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,52 @@ tasks:
- cmd: npm run test:install # install playwright
dir: ui
- task: build:api
- task: deploy-runtime-cluster
- task: setup:k3d
- task: deploy-load
- cmd: npm run test:local-auth
dir: ui

- name: deploy-load
description: "deploy some Zarf packages to test against"
actions:
- task: deploy-min-core
- cmd: uds zarf dev deploy
dir: ui/tests/packages/podinfo

- name: deploy-min-core
description: install min resources for UDS Core
actions:
# todo: refactor this with UDS functional layers: https://github.com/defenseunicorns/uds-runtime/issues/172
- task: setup:clone-core
- cmd: npm ci && npx pepr deploy --confirm
description: deploy UDS Core's Pepr module
dir: tmp/uds-core
- cmd: |
helm repo add istio https://istio-release.storage.googleapis.com/charts
helm upgrade -i istio-base istio/base -n istio-system --set defaultRevision=default --create-namespace
description: install Istio CRDs
- cmd: |
helm repo add minio https://charts.min.io/
helm upgrade -i -n uds-dev-stack minio minio/minio --create-namespace --set replicas=1 --set mode=standalone --set persistence.size=1Gi \
--set resources.requests.memory=256Mi --set resources.requests.cpu=100m
description: deploy minio to test PVCs
- name: deploy-podinfo
description: "deploy podinfo to the cluster"
actions:
- cmd: uds zarf package create --confirm
dir: ui/tests/packages/podinfo
- cmd: uds zarf package deploy zarf-package-podinfo-test-$UDS_ARCH-0.0.1.tar.zst --confirm
dir: ui/tests/packages/podinfo
- description: Validate podinfo pod
wait:
cluster:
kind: Pod
name: app.kubernetes.io/name=podinfo
condition: Ready
namespace: podinfo
maxTotalSeconds: 240

- name: e2e
description: "run end-to-end tests (assumes api server is running on port 8080)"
actions:
Expand All @@ -45,6 +87,18 @@ tasks:
- cmd: npm run test:reconnect
dir: ui

- name: e2e-in-cluster
description: "run end-to-end tests against runtime in the cluster"
actions:
- task: build:ui
- cmd: npm run test:install # install playwright
dir: ui
- cmd: uds deploy k3d-core-slim-dev:0.29.0 --confirm
- task: deploy-podinfo
- task: install-runtime-in-cluster
- cmd: npm run test:integration-in-cluster
dir: ui

- name: go-unit
description: "run api server unit tests"
actions:
Expand Down Expand Up @@ -77,38 +131,13 @@ tasks:
description: apply runtime class manually cause KFC is silly
- cmd: go test -failfast -v -timeout 30m ./src/test/e2e/...

- name: deploy-load
description: "deploy some Zarf packages to test against"
actions:
- task: deploy-min-core
- cmd: uds zarf dev deploy
dir: ui/tests/packages/podinfo

- name: deploy-min-core
description: install min resources for UDS Core
actions:
# todo: refactor this with UDS functional layers: https://github.com/defenseunicorns/uds-runtime/issues/172
- task: setup:clone-core
- cmd: npm ci && npx pepr deploy --confirm
description: deploy UDS Core's Pepr module
dir: tmp/uds-core
- cmd: |
helm repo add istio https://istio-release.storage.googleapis.com/charts
helm upgrade -i istio-base istio/base -n istio-system --set defaultRevision=default --create-namespace
description: install Istio CRDs
- cmd: |
helm repo add minio https://charts.min.io/
helm upgrade -i -n uds-dev-stack minio minio/minio --create-namespace --set replicas=1 --set mode=standalone --set persistence.size=1Gi \
--set resources.requests.memory=256Mi --set resources.requests.cpu=100m
description: deploy minio to test PVCs
- name: smoke
description: "runtime nightly smoke tests"
actions:
- task: build:smoke-img-pkg
- task: build:smoke-img-pkg-amd
- task: setup:slim-cluster
- cmd: uds zarf package deploy build/zarf-package-uds-runtime-amd64-smoke-test.tar.zst --confirm
dir: hack/smoke-test
- cmd: uds zarf package deploy build/smoke/zarf-package-uds-runtime-amd64-test.tar.zst --confirm
dir: hack/test
- description: Validate Runtime Pod
wait:
cluster:
Expand Down Expand Up @@ -140,3 +169,10 @@ tasks:
exit 1
;;
esac
- name: install-runtime-in-cluster
description: "Install uds-runtime in the cluster"
actions:
- task: build:e2e-img-pkg
- cmd: uds zarf package deploy build/e2e/zarf-package-uds-runtime-$UDS_ARCH-test.tar.zst --confirm
dir: hack/test
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test:local-auth": "playwright test tests/local-auth.spec.ts --config=playwright.config.local-auth.ts",
"test:reconnect": "playwright test tests/reconnect.spec.ts --config=playwright.reconnect.config.ts",
"test:integration": "playwright test",
"test:integration-in-cluster": "playwright test --config=playwright.config.incluster.ts",
"test:install": "playwright install",
"test:unit": "vitest run"
},
Expand Down
16 changes: 16 additions & 0 deletions ui/playwright.config.incluster.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from '@playwright/test'

const protocol = 'https'
const host = 'runtime.admin.uds.dev'

export default defineConfig({
timeout: 10 * 1000,
testDir: 'tests',
/* Run tests in files in parallel */
fullyParallel: true,
retries: process.env.CI ? 2 : 1,
testMatch: /^(?!.*local-auth|.*reconnect)(.+\.)?(test|spec)\.[jt]s$/,
use: {
baseURL: `${protocol}://${host}/`,
},
})
6 changes: 4 additions & 2 deletions ui/tests/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ test.describe('Navigation', async () => {
await page.getByRole('button', { name: 'Network' }).click()
await page.getByRole('link', { name: 'Network Policies' }).click()

await page.waitForSelector('[data-testid="allow-podinfo-egress-dns-lookup-via-coredns-testid-1"]')

await expect(page.getByTestId('allow-podinfo-egress-dns-lookup-via-coredns-testid-1')).toHaveText(
'allow-podinfo-egress-dns-lookup-via-coredns',
)
Expand Down Expand Up @@ -233,7 +235,7 @@ test.describe('Navigation', async () => {
test('navigates to Nodes page', async ({ page }) => {
await page.getByRole('link', { name: 'Nodes' }).click()

await expect(page.getByTestId('k3d-runtime-server-0-testid-1')).toHaveText('k3d-runtime-server-0')
await expect(page.getByTestId('control-plane, master-testid-3')).toHaveText('control-plane, master')
})

test('navigates to Preferences page', async ({ page }) => {
Expand All @@ -251,6 +253,6 @@ test.describe('Navigation', async () => {
test('navigates to Help page', async ({ page }) => {
await page.getByTestId('global-sidenav-help').click()

await expect(page.getByText('Help')).toBeVisible()
await expect(page.getByText('Help', { exact: true })).toBeVisible()
})
})
Loading

0 comments on commit 267b611

Please sign in to comment.