-
Notifications
You must be signed in to change notification settings - Fork 4
E2E tests - run the tests suite on new PRs #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
torchiaf
wants to merge
13
commits into
rancher-sandbox:main
Choose a base branch
from
torchiaf:feature-e2e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c02b4b6
Implement mock agent; add e2e scaffold
torchiaf ad16791
Add Cypress POs and commands
torchiaf 41185a5
Add first e2e test; Add e2e section in the README.md file; implement …
torchiaf 107d3ca
Add CI steps: lint, lint-i18n, node setup, cypress e2e
torchiaf c2965eb
Documenting code
torchiaf 7041d81
Removing unused mock agent deploy from Cypress setupNodeEvents
torchiaf 9002e32
e2e, code refactoring
torchiaf f36c559
CI workflow, code clean-up
torchiaf 333dacb
Rename mock:agent:start -> start
torchiaf 27ef0da
Fix README.md
torchiaf b0d1131
Fix mock-agent - get the correct pid for graceful shutdown
torchiaf f2008dc
Fix setup skip logic; Update README.md
torchiaf 821729a
e2e, add hooks.spec.ts
torchiaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,12 @@ | ||
| name: Run i18n Lint | ||
| description: Run i18n Lint | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Setup env | ||
| uses: ./.github/actions/setup | ||
|
|
||
| - name: Run i18n linters | ||
| shell: bash | ||
| run: yarn lint-l10n |
This file contains hidden or 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,12 @@ | ||
| name: Run Lint | ||
| description: Run Lint | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Setup env | ||
| uses: ./.github/actions/setup | ||
|
|
||
| - name: Run linters | ||
| shell: bash | ||
| run: yarn lint |
This file contains hidden or 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,14 @@ | ||
| name: Setup UI Env | ||
| description: Setup node environment and install packages | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install packages | ||
| shell: bash | ||
| run: yarn install --frozen-lockfile |
This file contains hidden or 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,38 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Helper script to install the AI Agent Helm chart into a Kubernetes cluster | ||
|
|
||
| KUBECONFIG_PATH=$1 | ||
|
|
||
| if [ -z "$KUBECONFIG_PATH" ]; then | ||
| echo "ERROR: kubeconfig path required (arg or KUBECONFIG env)" | ||
| usage | ||
| fi | ||
|
|
||
| if [ ! -f "$KUBECONFIG_PATH" ]; then | ||
| echo "ERROR: kubeconfig not found at $KUBECONFIG_PATH" | ||
| exit 2 | ||
| fi | ||
|
|
||
| export KUBECONFIG="$KUBECONFIG_PATH" | ||
|
|
||
| echo "" | ||
| echo "Cloning rancher-ai-agent chart repository..." | ||
|
|
||
| git clone https://github.com/rancher-sandbox/rancher-ai-agent.git | ||
|
|
||
| echo "" | ||
| echo "Installing ai-agent" | ||
|
|
||
| helm upgrade --install ai-agent ./rancher-ai-agent/chart/agent \ | ||
| --namespace cattle-ai-agent-system \ | ||
| --create-namespace \ | ||
| --set "imagePullSecrets[0].name=gh-secret" \ | ||
| --set llmModel=gemini-2.0-flash \ | ||
| --set googleApiKey=your_token \ | ||
| --set insecureSkipTls=true \ | ||
| --set activeLlm=gemini \ | ||
| --wait --timeout 1m | ||
|
|
||
| kubectl -n cattle-ai-agent-system rollout status deployment/rancher-ai-agent --timeout=1m | ||
| kubectl -n cattle-ai-agent-system wait --for=condition=available --timeout=1m deployment/rancher-ai-agent |
This file contains hidden or 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,77 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Helper script to run Rancher in a Docker container | ||
|
|
||
| VERSION="head" | ||
| CATTLE_SERVER_URL="https://localhost" | ||
| CATTLE_BOOTSTRAP_PASSWORD="asd" | ||
|
|
||
| if [ -n "$1" ]; then | ||
| VERSION=$1 | ||
| fi | ||
|
|
||
| if [ -n "$2" ]; then | ||
| CATTLE_SERVER_URL="$2" | ||
| fi | ||
|
|
||
| if [ -n "$3" ]; then | ||
| CATTLE_BOOTSTRAP_PASSWORD="$3" | ||
| fi | ||
|
|
||
| IMAGE="rancher/rancher:${VERSION}" | ||
|
|
||
| echo "" | ||
| echo "Starting '${IMAGE}' container ..." | ||
|
|
||
| echo "" | ||
| ID=$(docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged -e CATTLE_SERVER_URL=${CATTLE_SERVER_URL} -e CATTLE_BOOTSTRAP_PASSWORD=${CATTLE_BOOTSTRAP_PASSWORD} -e CATTLE_PASSWORD_MIN_LENGTH=3 ${IMAGE}) | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| echo "An error occurred running the Docker container" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "Container Id: ${ID}" | ||
|
|
||
| echo "" | ||
| echo "Waiting for backend to become ready" | ||
|
|
||
| TIME=0 | ||
| while [[ "$(curl --insecure -s -m 5 -o /dev/null -w ''%{http_code}'' ${CATTLE_SERVER_URL})" != "200" ]]; do | ||
| sleep 5; | ||
| TIME=$((TIME + 5)) | ||
| echo "${TIME}s ..." | ||
| done | ||
|
|
||
| echo "" | ||
| echo "Login to Rancher" | ||
|
|
||
| RANCHER_TOKEN=$(curl -vkL \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{"username":"admin","password":"'"$CATTLE_BOOTSTRAP_PASSWORD"'" ,"responseType":"cookie"}' \ | ||
| -X POST \ | ||
| ${CATTLE_SERVER_URL}/v3-public/localProviders/local?action=login 2>&1 | \ | ||
| awk -F'[=;]' '/Set-Cookie/{gsub(" ","",$2);print $2;exit}') | ||
|
|
||
| echo "" | ||
| echo "Get kubeconfig from local cluster" | ||
|
|
||
| HEADER="Cookie: R_SESS=$RANCHER_TOKEN" | ||
| curl -kL \ | ||
| -H 'Content-Type: application/json' \ | ||
| -X POST \ | ||
| -H "$HEADER" \ | ||
| ${CATTLE_SERVER_URL}/v3/clusters/local?action=generateKubeconfig | \ | ||
| yq '.config' > kubeconfig.yaml | ||
|
|
||
| sleep 2; | ||
|
|
||
| echo "" | ||
| kubectl --kubeconfig=kubeconfig.yaml cluster-info | ||
| if [ $? -ne 0 ]; then | ||
| echo "Unable to get Rancher resources" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Done" |
This file contains hidden or 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 hidden or 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 hidden or 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,28 @@ | ||
| # Validation steps required before a build occurs. | ||
| name: Build Test | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| # TODO add unit tests job | ||
|
|
||
| i18n: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run i18n lint | ||
| uses: ./.github/actions/i18n-lint | ||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run lint | ||
| uses: ./.github/actions/lint |
This file contains hidden or 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,104 @@ | ||
| name: Tests | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - 'release-*' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - 'release-*' | ||
|
|
||
| env: | ||
| RANCHER_VERSION: head | ||
| CATTLE_SERVER_URL: https://127.0.0.1 | ||
| CATTLE_BOOTSTRAP_PASSWORD: password | ||
| KUBECONFIG_PATH: ${{ github.workspace }}/kubeconfig.yaml | ||
| DEV_UI_URL: https://localhost:8005 | ||
|
|
||
| jobs: | ||
| e2e: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Setup Node env | ||
| uses: ./.github/actions/setup | ||
|
|
||
| - name: Start Rancher | ||
| run: .github/scripts/install-rancher.sh ${{ env.RANCHER_VERSION }} ${{ env.CATTLE_SERVER_URL }} ${{ env.CATTLE_BOOTSTRAP_PASSWORD }} | ||
|
|
||
| - name: Deploy AI Agent chart | ||
| run: .github/scripts/deploy-ai-agent.sh ${{ env.KUBECONFIG_PATH }} | ||
|
|
||
| - name: Start Mock Agent | ||
| working-directory: ./mock-agent | ||
| run: | | ||
| yarn install --frozen-lockfile | ||
| nohup yarn mock:agent:start > mock-agent.log 2>&1 & echo $! > mock-agent.pid | ||
|
|
||
| - name: Start dev UI | ||
| env: | ||
| API: ${{ env.CATTLE_SERVER_URL }} | ||
| VUE_APP_AGENT_MESSAGES_WS_PATH: ws://localhost:8000/ws/agent | ||
| run: | | ||
| nohup yarn dev > dev.log 2>&1 & echo $! > dev.pid | ||
|
|
||
| - name: Wait for dev UI to be ready | ||
| run: | | ||
| npx wait-on ${{ env.DEV_UI_URL }} | ||
|
|
||
| - name: Run Cypress tests | ||
| id: cypress | ||
| continue-on-error: true | ||
| env: | ||
| TEST_USERNAME: admin | ||
| TEST_PASSWORD: ${{ env.CATTLE_BOOTSTRAP_PASSWORD }} | ||
| CATTLE_BOOTSTRAP_PASSWORD: ${{ env.CATTLE_BOOTSTRAP_PASSWORD }} | ||
| TEST_BASE_URL: ${{ env.DEV_UI_URL }} | ||
| TEST_SKIP: setup | ||
| API: ${{ env.CATTLE_SERVER_URL }} | ||
| run: | | ||
| yarn e2e --browser chrome | ||
|
|
||
| - name: Upload videos on failure | ||
| if: steps.cypress.outcome != 'success' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cypress-videos | ||
| path: cypress/videos | ||
| retention-days: 7 | ||
|
|
||
| - name: Tear down background processes | ||
| if: always() | ||
| run: | | ||
| if [ -f dev.pid ]; then kill $(cat dev.pid) || true; fi | ||
| if [ -f mock-agent.pid ]; then kill $(cat mock-agent.pid) || true; fi | ||
|
|
||
| - name: Check failed tests | ||
| if: steps.cypress.outcome != 'success' | ||
| run: | | ||
| echo "Cypress tests failed" | ||
| exit 1 | ||
|
|
||
| i18n: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run i18n lint | ||
| uses: ./.github/actions/i18n-lint | ||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run tests | ||
| uses: ./.github/actions/lint |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're missing a step. This doesn't launch the cypress dashboard, it starts the dev server. I think we need a line for
➤ TEST_PASSWORD=${ rancher-password } yarn e2e.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks.