From 597c9be9269800e734d8061c312c10a99d4759db Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Fri, 26 Apr 2024 16:11:59 +0100 Subject: [PATCH 1/8] WIP --- .github/workflows/temp-test-k3s.yaml | 75 +++++++++++++++++++ .github/workflows/test.yaml | 3 +- package.json | 1 + scripts/e2e-k3s-start | 106 +++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/temp-test-k3s.yaml create mode 100755 scripts/e2e-k3s-start diff --git a/.github/workflows/temp-test-k3s.yaml b/.github/workflows/temp-test-k3s.yaml new file mode 100644 index 0000000000..e09827e3e3 --- /dev/null +++ b/.github/workflows/temp-test-k3s.yaml @@ -0,0 +1,75 @@ +name: temp test +on: + push: + branches: + - e2e-k3s + +env: + TEST_USERNAME: admin + TEST_PASSWORD: password + CATTLE_BOOTSTRAP_PASSWORD: password + TEST_BASE_URL: https://127.0.0.1:8005 + API: https://127.0.0.1 + TEST_PROJECT_ID: rancher-dashboard + CYPRESS_API_URL: http://139.59.134.103:1234/ + TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} + # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) + BUILD_DASHBOARD: false + + E2E_BUILD_DIST_NAME: dist + E2E_BUILD_DIST_DIR: dist + E2E_BUILD_DIST_EMBER_NAME: dist_ember + E2E_BUILD_DIST_EMBER_DIR: dist_ember + +jobs: + e2e-ui-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - uses: actions/setup-node@v3 + with: + node-version: '14.x' + cache: 'yarn' + - name: Install packages + run: yarn install:ci + - name: Build e2e + run: yarn e2e:build + - name: Upload e2e build + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_NAME }} + path: ${{ env.E2E_BUILD_DIST_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 + - name: Upload e2e build ember + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 + test-k3s: + needs: e2e-ui-build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Download e2e build + uses: actions/download-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_NAME }} + path: ${{ env.E2E_BUILD_DIST_DIR }} + - name: Download e2e build ember + uses: actions/download-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} + + - name: Run Rancher + run: yarn e2e:k3s diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e045616f07..c5ccf16395 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -60,6 +60,7 @@ jobs: if-no-files-found: error retention-days: 10 compression-level: 9 + e2e-test: if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" needs: e2e-ui-build @@ -110,7 +111,7 @@ jobs: path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} - name: Run Rancher - run: yarn e2e:docker + run: yarn e2e:k3s - name: Setup Rancher and user run: | diff --git a/package.json b/package.json index 72a9adac4d..62783719f6 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", + "e2e:k3s": "./scripts/e2e-k3s-start", "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start ", "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start new file mode 100755 index 0000000000..26da96b247 --- /dev/null +++ b/scripts/e2e-k3s-start @@ -0,0 +1,106 @@ +#!/usr/bin/env bash + +K3S_VERSION=v1.28.8+k3s1 + +# Image version +# RANCHER_IMG_VERSION=v2.9-c9be13b09329bbee60a5f6419d500198f83c44d1-head +RANCHER_IMG_VERSION=v2.9-head +DASHBOARD_URL=127.0.0.1.sslip.io + +DIR=$(cd $(dirname $0)/..; pwd) + +# See `script/build-e2e`. This is the ui builds we wish to test +DASHBOARD_DIST=${DIR}/dist +EMBER_DIST=${DIR}/dist_ember + +echo "Installing k3s (with kubectl)....." +curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="$K3S_VERSION" sh - +export KUBECONFIG=~/.kube/config +mkdir ~/.kube 2> /dev/null +sudo k3s kubectl config view --raw > "$KUBECONFIG" +chmod 600 "$KUBECONFIG" + +echo "Installing helm....." +curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 +chmod 700 get_helm.sh +./get_helm.sh + +echo "Installing cert-manager....." +kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml +helm repo add jetstack https://charts.jetstack.io +helm repo update +helm install cert-manager jetstack/cert-manager \ + --namespace cert-manager \ + --create-namespace \ + --version v1.7.1 + +echo "Cert manager pods should be up" +kubectl get pods --namespace cert-manager + +echo "Setting up Rancher Repo....." +helm repo add rancher-latest https://releases.rancher.com/server-charts/latest +helm repo update + +# TODO: RC wire in host name to e2e tests + +echo "Installing Rancher....." +kubectl create ns cattle-system +helm install rancher rancher-latest/rancher \ + --namespace cattle-system \ + --set "hostname=$DASHBOARD_URL" \ + --set replicas=1 \ + --set "extraEnv[0].name=CATTLE_AGENT_IMAGE" \ + --set "extraEnv[0].value=rancher/rancher:$RANCHER_IMG_VERSION" \ + --set rancherImage=rancher/rancher \ + --set rancherImageTag=$RANCHER_IMG_VERSION \ + --set rancherImagePullPolicy=Always \ + --set 'extraEnv[0].name=CATTLE_UI_OFFLINE_PREFERRED' \ + --set 'extraEnv[0].value=true' \ + --set 'extraEnv[0].name=CATTLE_BOOTSTRAP_PASSWORD' \ + --set 'extraEnv[0].value=password' \ + --set passwordMinLength=3 + +echo "Waiting for Rancher to come up..." +kubectl -n cattle-system rollout status deploy/rancher + +echo "Waiting for dashboard UI to be reachable (initial 20s wait) ..." + +sleep 20 + +echo "Waiting for dashboard UI to be reachable ..." + +okay=0 + +while [ $okay -lt 20 ]; do + STATUS=$(curl --silent --head -k $DASHBOARD_URL/dashboard/ | awk '/^HTTP/{print $2}') + + echo "Status: $STATUS (Try: $okay)" + + okay=$((okay+1)) + + if [ "$STATUS" == "302" ]; then + okay=100 + else + sleep 5 + fi +done + +if [ "$STATUS" != "302" ]; then + echo "Dashboard did not become available in a reasonable time" + exit 1 +fi + +echo "Updating UI within Rancher container" +POD_NAME=$(kubectl get pods --selector=app=rancher -n cattle-system | tail -n 1 | cut -d ' ' -f1) +echo "POD NAME: $POD_NAME" +if [ "$POD_NAME" == "" ]; then + echo "Failed to find rancher pod" + exit 1 +fi +# Note - these will pick the first container within the pod, so replicas=1 above is important +kubectl cp $DASHBOARD_DIST $POD_NAME:/usr/share/rancher/ui-dashboard/dashboard # TODO: RC probably copies folder INTO target folder +kubectl cp $EMBER_DIST $POD_NAME:/usr/share/rancher/ui # TODO: RC probably copies folder INTO target folder + # -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ + # -v ${EMBER_DIST}:/usr/share/rancher/ui \ + +echo "Dashboard UI is ready" \ No newline at end of file From 1d14f9ba8ede0d9402ce3f0591ee21232c79315a Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 29 Apr 2024 09:56:17 +0100 Subject: [PATCH 2/8] WIP2 --- scripts/e2e-k3s-start | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start index 26da96b247..b686419163 100755 --- a/scripts/e2e-k3s-start +++ b/scripts/e2e-k3s-start @@ -6,6 +6,7 @@ K3S_VERSION=v1.28.8+k3s1 # RANCHER_IMG_VERSION=v2.9-c9be13b09329bbee60a5f6419d500198f83c44d1-head RANCHER_IMG_VERSION=v2.9-head DASHBOARD_URL=127.0.0.1.sslip.io +NAMESPACE=cattle-system DIR=$(cd $(dirname $0)/..; pwd) @@ -44,7 +45,7 @@ helm repo update # TODO: RC wire in host name to e2e tests echo "Installing Rancher....." -kubectl create ns cattle-system +kubectl create ns $NAMESPACE helm install rancher rancher-latest/rancher \ --namespace cattle-system \ --set "hostname=$DASHBOARD_URL" \ @@ -91,15 +92,25 @@ if [ "$STATUS" != "302" ]; then fi echo "Updating UI within Rancher container" -POD_NAME=$(kubectl get pods --selector=app=rancher -n cattle-system | tail -n 1 | cut -d ' ' -f1) +# Note - these will pick the first container within the pod, so replicas=1 above is important +POD_NAME=$(kubectl get pods --selector=app=rancher -n $NAMESPACE | tail -n 1 | cut -d ' ' -f1) echo "POD NAME: $POD_NAME" if [ "$POD_NAME" == "" ]; then echo "Failed to find rancher pod" exit 1 fi -# Note - these will pick the first container within the pod, so replicas=1 above is important -kubectl cp $DASHBOARD_DIST $POD_NAME:/usr/share/rancher/ui-dashboard/dashboard # TODO: RC probably copies folder INTO target folder -kubectl cp $EMBER_DIST $POD_NAME:/usr/share/rancher/ui # TODO: RC probably copies folder INTO target folder + +kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui-dashboard' +kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui' + +mv $DASHBOARD_DIST dashboard +mv $EMBER_DIST ui + +ls -la dashboard +ls -la ui + +kubectl cp dashboard $POD_NAME:/usr/share/rancher/ui-dashboard -n $NAMESPACE +kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE # -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ # -v ${EMBER_DIST}:/usr/share/rancher/ui \ From 6ade8456ea20e3757d6357ad4cbba259f382684a Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 29 Apr 2024 10:53:05 +0100 Subject: [PATCH 3/8] WIP4 --- .github/workflows/temp-test-k3s.yaml | 3 ++- .github/workflows/test.yaml | 28 ++++++++++++++----------- package.json | 2 +- scripts/e2e-k3s-start | 31 +++++++++++++++++----------- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/.github/workflows/temp-test-k3s.yaml b/.github/workflows/temp-test-k3s.yaml index e09827e3e3..5173d2b73f 100644 --- a/.github/workflows/temp-test-k3s.yaml +++ b/.github/workflows/temp-test-k3s.yaml @@ -1,8 +1,9 @@ +# TODO RC Debug (remove) name: temp test on: push: branches: - - e2e-k3s + - e2e-k3saaaaaa env: TEST_USERNAME: admin diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c5ccf16395..a5a1571abd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,6 +4,8 @@ on: branches: - master - 'release-*' + # TODO RC remove + # - e2e-k3s pull_request: branches: - master @@ -14,18 +16,19 @@ on: description: 'Environment to run tests against' type: environment required: true - + env: TEST_USERNAME: admin TEST_PASSWORD: password CATTLE_BOOTSTRAP_PASSWORD: password - TEST_BASE_URL: https://127.0.0.1:8005 - API: https://127.0.0.1 + TEST_BASE_URL: https://127.0.0.1.sslip.io + API: https://127.0.0.1.sslip.io TEST_PROJECT_ID: rancher-dashboard CYPRESS_API_URL: http://139.59.134.103:1234/ TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) - BUILD_DASHBOARD: true + # TODO RC revert + BUILD_DASHBOARD: false E2E_BUILD_DIST_NAME: dist E2E_BUILD_DIST_DIR: dist @@ -66,20 +69,21 @@ jobs: needs: e2e-ui-build strategy: fail-fast: false + # TODO RC revert matrix: role: [ { username: 'admin', tag: '@adminUser' }, - { username: 'standard_user', tag: '@standardUser' } + # { username: 'standard_user', tag: '@standardUser' } ] features: [ - ['@navigation', '@extensions'], - ['@charts'], + # ['@navigation', '@extensions'], + # ['@charts'], ['@explorer'], - ['@fleet'], - ['@generic', '@globalSettings'], - ['@manager'], - ['@userMenu', '@usersAndAuths'], - ['@components'], + # ['@fleet'], + # ['@generic', '@globalSettings'], + # ['@manager'], + # ['@userMenu', '@usersAndAuths'], + # ['@components'], ] runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 62783719f6..b6f6558af7 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", "e2e:k3s": "./scripts/e2e-k3s-start", "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start ", - "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", + "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=$TEST_BASE_URL yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", "build-storybook": "cd storybook && yarn install --no-lockfile && NODE_OPTIONS=--max_old_space_size=4096 yarn build-storybook --quiet", diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start index b686419163..b1a8d32feb 100755 --- a/scripts/e2e-k3s-start +++ b/scripts/e2e-k3s-start @@ -5,7 +5,7 @@ K3S_VERSION=v1.28.8+k3s1 # Image version # RANCHER_IMG_VERSION=v2.9-c9be13b09329bbee60a5f6419d500198f83c44d1-head RANCHER_IMG_VERSION=v2.9-head -DASHBOARD_URL=127.0.0.1.sslip.io +DASHBOARD_URL="${TEST_BASE_URL#https://}" NAMESPACE=cattle-system DIR=$(cd $(dirname $0)/..; pwd) @@ -14,19 +14,19 @@ DIR=$(cd $(dirname $0)/..; pwd) DASHBOARD_DIST=${DIR}/dist EMBER_DIST=${DIR}/dist_ember -echo "Installing k3s (with kubectl)....." +echo "Installing k3s (with kubectl).........." curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="$K3S_VERSION" sh - export KUBECONFIG=~/.kube/config mkdir ~/.kube 2> /dev/null sudo k3s kubectl config view --raw > "$KUBECONFIG" chmod 600 "$KUBECONFIG" -echo "Installing helm....." +echo "Installing helm.........." curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 chmod 700 get_helm.sh ./get_helm.sh -echo "Installing cert-manager....." +echo "Installing cert-manager.........." kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml helm repo add jetstack https://charts.jetstack.io helm repo update @@ -38,13 +38,13 @@ helm install cert-manager jetstack/cert-manager \ echo "Cert manager pods should be up" kubectl get pods --namespace cert-manager -echo "Setting up Rancher Repo....." +echo "Setting up Rancher Repo.........." helm repo add rancher-latest https://releases.rancher.com/server-charts/latest helm repo update # TODO: RC wire in host name to e2e tests -echo "Installing Rancher....." +echo "Installing Rancher.........." kubectl create ns $NAMESPACE helm install rancher rancher-latest/rancher \ --namespace cattle-system \ @@ -61,14 +61,10 @@ helm install rancher rancher-latest/rancher \ --set 'extraEnv[0].value=password' \ --set passwordMinLength=3 -echo "Waiting for Rancher to come up..." +echo "Waiting for Rancher to come up.........." kubectl -n cattle-system rollout status deploy/rancher -echo "Waiting for dashboard UI to be reachable (initial 20s wait) ..." - -sleep 20 - -echo "Waiting for dashboard UI to be reachable ..." +echo "Waiting for dashboard UI to be reachable.........." okay=0 @@ -106,12 +102,23 @@ kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui' mv $DASHBOARD_DIST dashboard mv $EMBER_DIST ui +# TODO RC Debug (remove) ls -la dashboard ls -la ui kubectl cp dashboard $POD_NAME:/usr/share/rancher/ui-dashboard -n $NAMESPACE kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE +# TODO RC Debug (remove) # -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ # -v ${EMBER_DIST}:/usr/share/rancher/ui \ + +STATUS=$(curl --silent --head -k $DASHBOARD_URL/dashboard/ | awk '/^HTTP/{print $2}') +echo "Status: $STATUS (Try: $okay)" + +if [ "$STATUS" != "302" ]; then + echo "After updating dashboard with dev build it is no longer available" + exit 1 +fi + echo "Dashboard UI is ready" \ No newline at end of file From a952821fe625464c22792f6095d7633c28c97b43 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 29 Apr 2024 13:00:53 +0100 Subject: [PATCH 4/8] WIP5 --- scripts/e2e-k3s-start | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start index b1a8d32feb..a40a9854a9 100755 --- a/scripts/e2e-k3s-start +++ b/scripts/e2e-k3s-start @@ -69,20 +69,22 @@ echo "Waiting for dashboard UI to be reachable.........." okay=0 while [ $okay -lt 20 ]; do - STATUS=$(curl --silent --head -k $DASHBOARD_URL/dashboard/ | awk '/^HTTP/{print $2}') + curl --silent --location --head -k $DASHBOARD_URL/dashboard/ + + STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') echo "Status: $STATUS (Try: $okay)" okay=$((okay+1)) - if [ "$STATUS" == "302" ]; then + if [ "$STATUS" == "200" ]; then okay=100 else sleep 5 fi done -if [ "$STATUS" != "302" ]; then +if [ "$STATUS" != "200" ]; then echo "Dashboard did not become available in a reasonable time" exit 1 fi @@ -96,16 +98,16 @@ if [ "$POD_NAME" == "" ]; then exit 1 fi -kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui-dashboard' +# Remove root folders that container UIs +kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui-dashboard/dashboard' kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui' -mv $DASHBOARD_DIST dashboard -mv $EMBER_DIST ui - # TODO RC Debug (remove) ls -la dashboard ls -la ui - +# Copy local builds to root folders that should contain UIs +mv $DASHBOARD_DIST dashboard +mv $EMBER_DIST ui kubectl cp dashboard $POD_NAME:/usr/share/rancher/ui-dashboard -n $NAMESPACE kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE # TODO RC Debug (remove) @@ -113,12 +115,15 @@ kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE # -v ${EMBER_DIST}:/usr/share/rancher/ui \ -STATUS=$(curl --silent --head -k $DASHBOARD_URL/dashboard/ | awk '/^HTTP/{print $2}') +STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') echo "Status: $STATUS (Try: $okay)" -if [ "$STATUS" != "302" ]; then +if [ "$STATUS" != "200" ]; then echo "After updating dashboard with dev build it is no longer available" exit 1 fi +kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard' +kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard/dashboard' + echo "Dashboard UI is ready" \ No newline at end of file From db96dab7331c793f06d2403fefc6b4a01c3c3da5 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 29 Apr 2024 15:22:59 +0100 Subject: [PATCH 5/8] WIP6 --- cypress/support/commands/rancher-api-commands.ts | 2 ++ package.json | 2 +- scripts/e2e-k3s-start | 13 +++++-------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cypress/support/commands/rancher-api-commands.ts b/cypress/support/commands/rancher-api-commands.ts index fadd5a37fb..1db07b6f8a 100644 --- a/cypress/support/commands/rancher-api-commands.ts +++ b/cypress/support/commands/rancher-api-commands.ts @@ -1,5 +1,6 @@ import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po'; import { CreateUserParams } from '@/cypress/globals'; +import cypress from 'cypress'; // This file contains commands which makes API requests to the rancher API. // It includes the `login` command to store the `token` to use @@ -85,6 +86,7 @@ Cypress.Commands.add('createUser', (params: CreateUserParams) => { } }) .then((resp) => { + cy.log(JSON.stringify(resp)); if (resp.status === 422 && resp.body.message === 'Username is already in use.') { cy.log('User already exists. Skipping user creation'); diff --git a/package.json b/package.json index b6f6558af7..1fafeb773c 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", "e2e:k3s": "./scripts/e2e-k3s-start", "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start ", - "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=$TEST_BASE_URL yarn cy:run:sorry", + "e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=$TEST_BASE_URL/dashboard API=$API yarn cy:run:sorry", "coverage": "npx nyc merge coverage coverage/coverage.json", "storybook": "cd storybook && yarn install && yarn storybook", "build-storybook": "cd storybook && yarn install --no-lockfile && NODE_OPTIONS=--max_old_space_size=4096 yarn build-storybook --quiet", diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start index a40a9854a9..1e1ae887a3 100755 --- a/scripts/e2e-k3s-start +++ b/scripts/e2e-k3s-start @@ -102,17 +102,14 @@ fi kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui-dashboard/dashboard' kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui' -# TODO RC Debug (remove) -ls -la dashboard -ls -la ui # Copy local builds to root folders that should contain UIs mv $DASHBOARD_DIST dashboard mv $EMBER_DIST ui +# # TODO RC Debug (remove) +# ls -la dashboard +# ls -la ui kubectl cp dashboard $POD_NAME:/usr/share/rancher/ui-dashboard -n $NAMESPACE kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE -# TODO RC Debug (remove) - # -v ${DASHBOARD_DIST}:/usr/share/rancher/ui-dashboard/dashboard \ - # -v ${EMBER_DIST}:/usr/share/rancher/ui \ STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') @@ -123,7 +120,7 @@ if [ "$STATUS" != "200" ]; then exit 1 fi -kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard' -kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard/dashboard' +# kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard' +# kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard/dashboard' echo "Dashboard UI is ready" \ No newline at end of file From 55ca0566f4280a4d1aadc4a7b97bc19abdd91953 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Tue, 30 Apr 2024 15:25:51 +0100 Subject: [PATCH 6/8] Tidying up --- cypress/support/commands/rancher-api-commands.ts | 1 - scripts/e2e-k3s-start | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cypress/support/commands/rancher-api-commands.ts b/cypress/support/commands/rancher-api-commands.ts index 1db07b6f8a..7c63c0e206 100644 --- a/cypress/support/commands/rancher-api-commands.ts +++ b/cypress/support/commands/rancher-api-commands.ts @@ -1,6 +1,5 @@ import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po'; import { CreateUserParams } from '@/cypress/globals'; -import cypress from 'cypress'; // This file contains commands which makes API requests to the rancher API. // It includes the `login` command to store the `token` to use diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start index 1e1ae887a3..a301c690b5 100755 --- a/scripts/e2e-k3s-start +++ b/scripts/e2e-k3s-start @@ -69,8 +69,6 @@ echo "Waiting for dashboard UI to be reachable.........." okay=0 while [ $okay -lt 20 ]; do - curl --silent --location --head -k $DASHBOARD_URL/dashboard/ - STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') echo "Status: $STATUS (Try: $okay)" @@ -89,7 +87,7 @@ if [ "$STATUS" != "200" ]; then exit 1 fi -echo "Updating UI within Rancher container" +echo "Updating UI within Rancher container.........." # Note - these will pick the first container within the pod, so replicas=1 above is important POD_NAME=$(kubectl get pods --selector=app=rancher -n $NAMESPACE | tail -n 1 | cut -d ' ' -f1) echo "POD NAME: $POD_NAME" @@ -113,7 +111,7 @@ kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') -echo "Status: $STATUS (Try: $okay)" +echo "Status: $STATUS" if [ "$STATUS" != "200" ]; then echo "After updating dashboard with dev build it is no longer available" From 5c9a4a18240f40bb1f7d8bd89b35ecff7bc6bca3 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Wed, 1 May 2024 09:48:39 +0100 Subject: [PATCH 7/8] Fix min length arg --- .../support/commands/rancher-api-commands.ts | 3 ++- scripts/e2e-k3s-start | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cypress/support/commands/rancher-api-commands.ts b/cypress/support/commands/rancher-api-commands.ts index 7c63c0e206..62712c53e3 100644 --- a/cypress/support/commands/rancher-api-commands.ts +++ b/cypress/support/commands/rancher-api-commands.ts @@ -85,12 +85,13 @@ Cypress.Commands.add('createUser', (params: CreateUserParams) => { } }) .then((resp) => { - cy.log(JSON.stringify(resp)); + cy.log(JSON.stringify(resp)); // TODO: RC if (resp.status === 422 && resp.body.message === 'Username is already in use.') { cy.log('User already exists. Skipping user creation'); return ''; } else { + expect(resp.body.message).to.eq('junk'); // TODO: RC expect(resp.status).to.eq(201); const userPrincipalId = resp.body.principalIds[0]; diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start index a301c690b5..a21412e1ef 100755 --- a/scripts/e2e-k3s-start +++ b/scripts/e2e-k3s-start @@ -48,18 +48,19 @@ echo "Installing Rancher.........." kubectl create ns $NAMESPACE helm install rancher rancher-latest/rancher \ --namespace cattle-system \ - --set "hostname=$DASHBOARD_URL" \ - --set replicas=1 \ - --set "extraEnv[0].name=CATTLE_AGENT_IMAGE" \ - --set "extraEnv[0].value=rancher/rancher:$RANCHER_IMG_VERSION" \ - --set rancherImage=rancher/rancher \ - --set rancherImageTag=$RANCHER_IMG_VERSION \ - --set rancherImagePullPolicy=Always \ - --set 'extraEnv[0].name=CATTLE_UI_OFFLINE_PREFERRED' \ - --set 'extraEnv[0].value=true' \ - --set 'extraEnv[0].name=CATTLE_BOOTSTRAP_PASSWORD' \ - --set 'extraEnv[0].value=password' \ - --set passwordMinLength=3 + --set hostname=$DASHBOARD_URL \ + --set replicas="1" \ + --set rancherImage="rancher/rancher" \ + --set rancherImageTag="$RANCHER_IMG_VERSION" \ + --set rancherImagePullPolicy="Always" \ + --set extraEnv\[0\].name="CATTLE_AGENT_IMAGE" \ + --set-string extraEnv\[0\].value="rancher/rancher:$RANCHER_IMG_VERSION" \ + --set extraEnv\[1\].name="CATTLE_UI_OFFLINE_PREFERRED" \ + --set-string extraEnv\[1\].value="true" \ + --set extraEnv\[2\].name="CATTLE_BOOTSTRAP_PASSWORD" \ + --set-string extraEnv\[2\].value="password" \ + --set extraEnv\[3\].name="CATTLE_PASSWORD_MIN_LENGTH" \ + --set-string extraEnv\[3\].value="3" echo "Waiting for Rancher to come up.........." kubectl -n cattle-system rollout status deploy/rancher From 5c881bc5e6da10265c62f36af8464eaabef9bc1b Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Wed, 1 May 2024 12:09:34 +0100 Subject: [PATCH 8/8] Tidying up --- .github/workflows/temp-test-k3s.yaml | 76 ------------------- .github/workflows/test.yaml | 22 +++--- .../support/commands/rancher-api-commands.ts | 2 - scripts/e2e-k3s-start | 8 +- 4 files changed, 10 insertions(+), 98 deletions(-) delete mode 100644 .github/workflows/temp-test-k3s.yaml diff --git a/.github/workflows/temp-test-k3s.yaml b/.github/workflows/temp-test-k3s.yaml deleted file mode 100644 index 5173d2b73f..0000000000 --- a/.github/workflows/temp-test-k3s.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# TODO RC Debug (remove) -name: temp test -on: - push: - branches: - - e2e-k3saaaaaa - -env: - TEST_USERNAME: admin - TEST_PASSWORD: password - CATTLE_BOOTSTRAP_PASSWORD: password - TEST_BASE_URL: https://127.0.0.1:8005 - API: https://127.0.0.1 - TEST_PROJECT_ID: rancher-dashboard - CYPRESS_API_URL: http://139.59.134.103:1234/ - TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} - # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) - BUILD_DASHBOARD: false - - E2E_BUILD_DIST_NAME: dist - E2E_BUILD_DIST_DIR: dist - E2E_BUILD_DIST_EMBER_NAME: dist_ember - E2E_BUILD_DIST_EMBER_DIR: dist_ember - -jobs: - e2e-ui-build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - uses: actions/setup-node@v3 - with: - node-version: '14.x' - cache: 'yarn' - - name: Install packages - run: yarn install:ci - - name: Build e2e - run: yarn e2e:build - - name: Upload e2e build - uses: actions/upload-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_NAME }} - path: ${{ env.E2E_BUILD_DIST_DIR }}/ - if-no-files-found: error - retention-days: 10 - compression-level: 9 - - name: Upload e2e build ember - uses: actions/upload-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} - path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ - if-no-files-found: error - retention-days: 10 - compression-level: 9 - test-k3s: - needs: e2e-ui-build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Download e2e build - uses: actions/download-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_NAME }} - path: ${{ env.E2E_BUILD_DIST_DIR }} - - name: Download e2e build ember - uses: actions/download-artifact@v4 - with: - name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} - path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} - - - name: Run Rancher - run: yarn e2e:k3s diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a5a1571abd..73a641aac9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,8 +4,6 @@ on: branches: - master - 'release-*' - # TODO RC remove - # - e2e-k3s pull_request: branches: - master @@ -27,8 +25,7 @@ env: CYPRESS_API_URL: http://139.59.134.103:1234/ TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} # Build the dashboard to use in tests. When set to false it will grab `latest` from CDN (useful for running e2e tests quickly) - # TODO RC revert - BUILD_DASHBOARD: false + BUILD_DASHBOARD: true E2E_BUILD_DIST_NAME: dist E2E_BUILD_DIST_DIR: dist @@ -69,21 +66,20 @@ jobs: needs: e2e-ui-build strategy: fail-fast: false - # TODO RC revert matrix: role: [ { username: 'admin', tag: '@adminUser' }, - # { username: 'standard_user', tag: '@standardUser' } + { username: 'standard_user', tag: '@standardUser' } ] features: [ - # ['@navigation', '@extensions'], - # ['@charts'], + ['@navigation', '@extensions'], + ['@charts'], ['@explorer'], - # ['@fleet'], - # ['@generic', '@globalSettings'], - # ['@manager'], - # ['@userMenu', '@usersAndAuths'], - # ['@components'], + ['@fleet'], + ['@generic', '@globalSettings'], + ['@manager'], + ['@userMenu', '@usersAndAuths'], + ['@components'], ] runs-on: ubuntu-latest steps: diff --git a/cypress/support/commands/rancher-api-commands.ts b/cypress/support/commands/rancher-api-commands.ts index 62712c53e3..fadd5a37fb 100644 --- a/cypress/support/commands/rancher-api-commands.ts +++ b/cypress/support/commands/rancher-api-commands.ts @@ -85,13 +85,11 @@ Cypress.Commands.add('createUser', (params: CreateUserParams) => { } }) .then((resp) => { - cy.log(JSON.stringify(resp)); // TODO: RC if (resp.status === 422 && resp.body.message === 'Username is already in use.') { cy.log('User already exists. Skipping user creation'); return ''; } else { - expect(resp.body.message).to.eq('junk'); // TODO: RC expect(resp.status).to.eq(201); const userPrincipalId = resp.body.principalIds[0]; diff --git a/scripts/e2e-k3s-start b/scripts/e2e-k3s-start index a21412e1ef..51482aeb11 100755 --- a/scripts/e2e-k3s-start +++ b/scripts/e2e-k3s-start @@ -104,13 +104,10 @@ kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui' # Copy local builds to root folders that should contain UIs mv $DASHBOARD_DIST dashboard mv $EMBER_DIST ui -# # TODO RC Debug (remove) -# ls -la dashboard -# ls -la ui kubectl cp dashboard $POD_NAME:/usr/share/rancher/ui-dashboard -n $NAMESPACE kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE - +# Final validation STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') echo "Status: $STATUS" @@ -119,7 +116,4 @@ if [ "$STATUS" != "200" ]; then exit 1 fi -# kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard' -# kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'ls -la /usr/share/rancher/ui-dashboard/dashboard' - echo "Dashboard UI is ready" \ No newline at end of file