diff --git a/.circleci/config.yml b/.circleci/config.yml index a40aec57e..bbbf9d12d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,6 +3,16 @@ version: 2.1 workflows: build-and-test-multi-arch: jobs: + - kubernetes-test: + name: "K8s test - Playwright Connect Autoscaling Grid" + platforms: linux/arm64 + machine-type: ubuntu2204arm64large + k8s-version: 'v1.25.16' + test-strategy: playwright_connect_grid + cluster: 'minikube' + helm-version: 'v3.10.3' + docker-version: '24.0.9' + test-upgrade: true - kubernetes-test: name: "K8s test - Autoscaling disabled" platforms: linux/arm64 @@ -10,7 +20,8 @@ workflows: k8s-version: 'v1.26.15' test-strategy: disabled cluster: 'minikube' - helm-version: 'v3.10.3' + helm-version: 'v3.11.3' + docker-version: '24.0.9' test-upgrade: true - kubernetes-test: name: "K8s test - Autoscaling Jobs" @@ -19,43 +30,48 @@ workflows: k8s-version: 'v1.27.16' test-strategy: job cluster: 'minikube' - helm-version: 'v3.11.3' + helm-version: 'v3.12.3' + docker-version: '24.0.9' test-upgrade: true - kubernetes-test: name: "K8s test - Autoscaling Deployments" platforms: linux/arm64 machine-type: ubuntu2204arm64large - k8s-version: 'v1.28.13' + k8s-version: 'v1.28.14' test-strategy: deployment cluster: 'minikube' - helm-version: 'v3.12.3' + helm-version: 'v3.13.3' + docker-version: '24.0.9' test-upgrade: true - kubernetes-test: name: "K8s test - Autoscaling Jobs - HTTPS" platforms: linux/arm64 machine-type: ubuntu2204arm64large - k8s-version: 'v1.29.8' + k8s-version: 'v1.29.9' test-strategy: job_https cluster: 'minikube' - helm-version: 'v3.13.3' + helm-version: 'v3.14.3' + docker-version: '25.0.5' test-upgrade: true - kubernetes-test: name: "K8s test - Autoscaling Jobs - Ingress hostname" platforms: linux/arm64 machine-type: ubuntu2204arm64large - k8s-version: 'v1.30.4' + k8s-version: 'v1.30.5' test-strategy: job_hostname cluster: 'minikube' - helm-version: 'v3.14.4' + helm-version: 'v3.15.4' + docker-version: '26.1.4' test-upgrade: true - kubernetes-test: name: "K8s test - Autoscaling Deployments - HTTPS" platforms: linux/arm64 machine-type: ubuntu2204arm64large - k8s-version: 'v1.31.0' + k8s-version: 'v1.31.1' test-strategy: deployment_https cluster: 'minikube' - helm-version: 'v3.15.4' + helm-version: 'v3.16.1' + docker-version: '27.2.0' test-upgrade: true - docker-test: name: "Docker test - Use random user (true)" @@ -206,6 +222,8 @@ jobs: type: string helm-version: type: string + docker-version: + type: string test-upgrade: type: boolean executor: << parameters.machine-type >> @@ -217,6 +235,7 @@ jobs: CLUSTER: << parameters.cluster >> KUBERNETES_VERSION: << parameters.k8s-version >> HELM_VERSION: << parameters.helm-version >> + DOCKER_VERSION: << parameters.docker-version >> TEST_UPGRADE_CHART: << parameters.test-upgrade >> steps: - run: @@ -266,6 +285,10 @@ jobs: name: "Test Selenium Grid on Kubernetes" no_output_timeout: 30m command: | + if [ "${TEST_STRATEGY}" == "playwright_connect_grid" ]; then + PLATFORMS=${PLATFORMS} NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} TEST_UPGRADE_CHART=false make chart_test_autoscaling_${TEST_STRATEGY} && make test_video_integrity + exit $? + fi N=3 while [ $N -gt 0 ]; do output=$(eval "PLATFORMS=${PLATFORMS} NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} TEST_UPGRADE_CHART=false make chart_test_autoscaling_${TEST_STRATEGY} && make test_video_integrity") diff --git a/.github/workflows/helm-chart-test.yml b/.github/workflows/helm-chart-test.yml index 80d268eb6..603579f28 100644 --- a/.github/workflows/helm-chart-test.yml +++ b/.github/workflows/helm-chart-test.yml @@ -34,40 +34,46 @@ jobs: fail-fast: false matrix: include: + - k8s-version: 'v1.25.16' + test-strategy: playwright_connect_grid + cluster: 'minikube' + helm-version: 'v3.10.3' + docker-version: '24.0.9' + test-upgrade: true - k8s-version: 'v1.26.15' test-strategy: disabled cluster: 'minikube' - helm-version: 'v3.10.3' + helm-version: 'v3.11.3' docker-version: '24.0.9' test-upgrade: true - k8s-version: 'v1.27.16' test-strategy: job cluster: 'minikube' - helm-version: 'v3.11.3' + helm-version: 'v3.12.3' docker-version: '24.0.9' test-upgrade: true - - k8s-version: 'v1.28.13' + - k8s-version: 'v1.28.14' test-strategy: deployment cluster: 'minikube' - helm-version: 'v3.12.3' + helm-version: 'v3.13.3' docker-version: '24.0.9' test-upgrade: true - - k8s-version: 'v1.29.8' + - k8s-version: 'v1.29.9' test-strategy: job_https cluster: 'minikube' - helm-version: 'v3.13.3' + helm-version: 'v3.14.3' docker-version: '25.0.5' test-upgrade: true - - k8s-version: 'v1.30.4' + - k8s-version: 'v1.30.5' test-strategy: job_hostname cluster: 'minikube' - helm-version: 'v3.14.4' + helm-version: 'v3.15.4' docker-version: '26.1.4' test-upgrade: true - - k8s-version: 'v1.31.0' + - k8s-version: 'v1.31.1' test-strategy: deployment_https cluster: 'minikube' - helm-version: 'v3.15.4' + helm-version: 'v3.16.1' docker-version: '27.2.0' test-upgrade: true env: diff --git a/Makefile b/Makefile index 60495ac95..e1d68af87 100644 --- a/Makefile +++ b/Makefile @@ -948,12 +948,12 @@ chart_test_autoscaling_job: TEMPLATE_OUTPUT_FILENAME="k8s_fullDistributed_secureIngress_externalCerts_ingressHostName_ingressTLSInline_autoScaling_scaledJob_existingKEDA_prefixSelenium_nodeChromium_enableTracing.yaml" \ ./tests/charts/make/chart_test.sh JobAutoscaling -chart_test_language_bindings: - PLATFORMS=$(PLATFORMS) \ - SELENIUM_GRID_HOST=$$(hostname -i) \ - SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=1 \ +chart_test_autoscaling_playwright_connect_grid: + PLATFORMS=$(PLATFORMS) CHART_ENABLE_TRACING=true CHART_ENABLE_BASIC_AUTH=true MATRIX_TESTS=CDPTests \ + SECURE_INGRESS_ONLY_DEFAULT=true SECURE_USE_EXTERNAL_CERT=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=$$(hostname -i) SELENIUM_GRID_PORT=443 \ VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) \ - ./tests/charts/make/chart_test.sh DeploymentAutoscaling + TEMPLATE_OUTPUT_FILENAME="k8s_playwright_connect_grid_basicAuth_secureIngress_ingressPublicIP_autoScaling.yaml" \ + ./tests/charts/make/chart_test.sh JobAutoscaling chart_test_delete: helm del test -n selenium || true diff --git a/tests/CDPTests/.gitignore b/tests/CDPTests/.gitignore new file mode 100644 index 000000000..972787bdc --- /dev/null +++ b/tests/CDPTests/.gitignore @@ -0,0 +1,8 @@ +node_modules/ +/test-results/ +/playwright-report/ +/playwright/.cache/ +.idea/ +.vscode/ +jsonReports/ +package-lock.json diff --git a/tests/CDPTests/bootstrap.sh b/tests/CDPTests/bootstrap.sh new file mode 100755 index 000000000..2e72a8382 --- /dev/null +++ b/tests/CDPTests/bootstrap.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +cd tests/CDPTests || true + +npm install +npx playwright install --force chromium + +BROWSER=${1:-"chrome"} + +SELENIUM_REMOTE_URL="${SELENIUM_GRID_PROTOCOL}://${SELENIUM_GRID_HOST}:${SELENIUM_GRID_PORT}" +echo "SELENIUM_REMOTE_URL=${SELENIUM_REMOTE_URL}" > .env + +if [ -n ${SELENIUM_GRID_USERNAME} ] && [ -n ${SELENIUM_GRID_PASSWORD} ]; then + BASIC_AUTH="$(echo -n "${SELENIUM_GRID_USERNAME}:${SELENIUM_GRID_PASSWORD}" | base64)" + echo "SELENIUM_REMOTE_HEADERS={\"Authorization\": \"Basic ${BASIC_AUTH}\"}" >> .env +fi + +echo "SELENIUM_REMOTE_CAPABILITIES={\"browserName\": \"${BROWSER}\"}" >> .env +echo "NODE_EXTRA_CA_CERTS=${CHART_CERT_PATH}" >> .env + +until [ "$(curl --noproxy "*" -sk -H "Authorization: Basic ${BASIC_AUTH}" -o /dev/null -w "%{http_code}" "${SELENIUM_REMOTE_URL}/status")" = "200" ]; do + echo "Waiting for Grid to be ready..." + sleep 1 +done + +npx playwright test diff --git a/tests/CDPTests/package.json b/tests/CDPTests/package.json new file mode 100644 index 000000000..d41cfa24c --- /dev/null +++ b/tests/CDPTests/package.json @@ -0,0 +1,21 @@ +{ + "name": "CDPTests", + "version": "1.47.2", + "main": "index.js", + "scripts": {}, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@playwright/test": "^1.47.2" + }, + "directories": { + "test": "tests" + }, + "dependencies": { + "dotenv": "^16.3.1", + "express": "^4.18.2", + "playwright-core": "^1.47.2" + }, + "description": "" +} diff --git a/tests/CDPTests/playwright.config.ts b/tests/CDPTests/playwright.config.ts new file mode 100644 index 000000000..3940c7c14 --- /dev/null +++ b/tests/CDPTests/playwright.config.ts @@ -0,0 +1,22 @@ +import type {PlaywrightTestConfig} from '@playwright/test'; +import * as dotenv from 'dotenv'; + +dotenv.config(); + +const config: PlaywrightTestConfig = { + timeout: 1500000, + testMatch: ["tests/*.ts"], + use: { + headless: false, + screenshot: "on", + video: "on" + }, + reporter: [["dot"], ["json", { + outputFile: "jsonReports/jsonReport.json" + }], ["html", { + open: "never" + }]], + workers: 5 +}; + +export default config; diff --git a/tests/CDPTests/tests/Tests.ts b/tests/CDPTests/tests/Tests.ts new file mode 100644 index 000000000..6949be355 --- /dev/null +++ b/tests/CDPTests/tests/Tests.ts @@ -0,0 +1,50 @@ +const {test, expect} = require('@playwright/test'); +const path = require('path'); + +function sleep(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +test.describe.parallel('Parallel tests connect to autoscaling Grid', () => { + test('test_title', async ({page}) => { + await page.goto('https://the-internet.herokuapp.com'); + await expect(page).toHaveTitle('The Internet'); + await sleep(2); + }); + + test('test_with_frames', async ({page}) => { + await page.goto('http://the-internet.herokuapp.com/nested_frames'); + const frame = page.frameLocator('frame[name="frame-top"]').frameLocator('frame[name="frame-middle"]'); + await expect(frame.locator('#content')).toHaveText('MIDDLE'); + await sleep(2); + }); + + test('test_select_from_a_dropdown', async ({page}) => { + await page.goto('http://the-internet.herokuapp.com/dropdown'); + const dropdown = await page.locator('#dropdown'); + await dropdown.selectOption({label: 'Option 1'}); + const selectedOption = await dropdown.inputValue(); + expect(selectedOption).toBe('1'); + await sleep(2); + }); + + test('test_visit_basic_auth_secured_page', async ({page}) => { + await page.goto('http://admin:admin@the-internet.herokuapp.com/basic_auth'); + const pageMessage = await page.locator('.example p').textContent(); + expect(pageMessage.trim()).toBe('Congratulations! You must have the proper credentials.'); + await sleep(2); + }); + + test('test_download_file', async ({page}) => { + await page.goto('https://the-internet.herokuapp.com/download'); + const fileLink = page.locator('a', {hasText: 'some-file.txt'}); + await fileLink.scrollIntoViewIfNeeded(); + const [download] = await Promise.all([ + page.waitForEvent('download'), + fileLink.click() + ]); + const fileName = download.suggestedFilename(); + expect(fileName).toBe('some-file.txt'); + await sleep(2); + }); +}); diff --git a/tests/charts/make/chart_setup_env.sh b/tests/charts/make/chart_setup_env.sh index 4d4aa162e..dc6cd54aa 100755 --- a/tests/charts/make/chart_setup_env.sh +++ b/tests/charts/make/chart_setup_env.sh @@ -161,8 +161,9 @@ rm -rf ct.tar.gz ct version echo "===============================" echo "Installing helm-docs for AMD64 / ARM64" -go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest -$HOME/go/bin/helm-docs -h +mkdir -p $HOME/go/bin +GOBIN=$HOME/go/bin go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest +$HOME/go/bin/helm-docs -h || true echo "===============================" echo "Installing envsubst for AMD64 / ARM64" ENVSUBST_VERSION="v1.4.2" @@ -172,3 +173,12 @@ chmod +x envsubst sudo mv envsubst /usr/local/bin sudo ln -sf /usr/local/bin/envsubst /usr/bin/envsubst echo "===============================" +echo "Installing Node for AMD64 / ARM64" +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +source $HOME/.bashrc +nvm install --lts +node --version +npm --version diff --git a/tests/charts/make/chart_test.sh b/tests/charts/make/chart_test.sh index c12a56cf5..a8a708d8e 100755 --- a/tests/charts/make/chart_test.sh +++ b/tests/charts/make/chart_test.sh @@ -411,6 +411,9 @@ if [ "${MATRIX_BROWSER}" = "NoAutoscaling" ]; then else ./tests/bootstrap.sh NodeChromium fi +elif [ "${MATRIX_TESTS}" = "CDPTests" ]; then + ./tests/CDPTests/bootstrap.sh "chrome" + ./tests/CDPTests/bootstrap.sh "MicrosoftEdge" else ./tests/bootstrap.sh ${MATRIX_BROWSER} fi