From 9b1683a10b102421f600ca345169d10eff85b685 Mon Sep 17 00:00:00 2001 From: Dhanush0369 Date: Tue, 21 May 2024 17:16:20 +0530 Subject: [PATCH 1/6] Added Pipeline and edited testcases Signed-off-by: Dhanush0369 --- .../workflows/E2E-chaoscenter-pipeline.yml | 82 +++++++++++++++++++ chaoscenter/cypress.config.js | 6 +- .../cypress/e2e/REST APIs/chaoshub.cy.js | 2 +- chaoscenter/cypress/e2e/REST APIs/login.cy.js | 2 +- chaoscenter/cypress/e2e/UI/chaoshub.cy.js | 4 +- chaoscenter/cypress/e2e/UI/chaosinfra.cy.js | 13 +-- chaoscenter/cypress/e2e/UI/chaosprobes.cy.js | 4 - chaoscenter/cypress/e2e/UI/login.cy.js | 2 +- 8 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/E2E-chaoscenter-pipeline.yml diff --git a/.github/workflows/E2E-chaoscenter-pipeline.yml b/.github/workflows/E2E-chaoscenter-pipeline.yml new file mode 100644 index 000000000..6d4edea94 --- /dev/null +++ b/.github/workflows/E2E-chaoscenter-pipeline.yml @@ -0,0 +1,82 @@ +name: ChaosCenter E2E testing + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Set up Minikube + run: | + sudo apt update && sudo apt install -y curl + curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 + sudo install minikube-linux-amd64 /usr/local/bin/minikube + minikube start + + - name: Install kubectl + run: | + sudo apt update && sudo apt install -y kubectl + + - name: Install helm + run: | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + + run-litmus: + needs: setup + runs-on: ubuntu-latest + steps: + - name: Add litmus Chaos Repository + run: helm repo add litmuschaos https://litmuschaos.github.io/litmus-helm/ + + - name: Start minikube + run: minikube start + + - name: Create litmus namespace + run: kubectl create ns litmus + + - name: Install Litmus + run: | + helm install chaos litmuschaos/litmus \ + --namespace=litmus \ + --set portal.frontend.service.type=NodePort + + - name: Wait for pods to be ready + run: | + sleep 60s + while true; do + if kubectl get pods --namespace litmus | grep -q "1/1"; then + break + fi + sleep 20 + done + + - name: Extract Minikube IP and NodePort + id: extract-urls + run: | + MINIKUBE_IP=$(minikube ip) + NODE_PORT=$(kubectl get svc chaos-litmus-frontend-service -n litmus -o jsonpath='{.spec.ports[0].nodePort}') + echo "MINIKUBE_IP=$MINIKUBE_IP" >> $GITHUB_ENV + echo "NODE_PORT=$NODE_PORT" >> $GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v4 + + - name: Cypress run with env + uses: cypress-io/github-action@v6 + with: + start: npm start + working-directory: chaoscenter + env: + CYPRESS_baseUrl: http://${{ env.MINIKUBE_IP }}:${{ env.NODE_PORT }} + + + + \ No newline at end of file diff --git a/chaoscenter/cypress.config.js b/chaoscenter/cypress.config.js index 4e7378553..0d0878671 100644 --- a/chaoscenter/cypress.config.js +++ b/chaoscenter/cypress.config.js @@ -2,7 +2,11 @@ const { defineConfig } = require("cypress"); module.exports = defineConfig({ e2e: { - baseUrl: 'http://192.168.49.2:30829', + baseUrl: "http://localhost:3000", // default value + setupNodeEvents(on, config) { + config.env.baseUrl = process.env.CYPRESS_baseUrl || config.env.baseUrl; + return config; + }, requestTimeout: 60000, responseTimeout: 60000 }, diff --git a/chaoscenter/cypress/e2e/REST APIs/chaoshub.cy.js b/chaoscenter/cypress/e2e/REST APIs/chaoshub.cy.js index 05ea2680a..60bc50a2c 100644 --- a/chaoscenter/cypress/e2e/REST APIs/chaoshub.cy.js +++ b/chaoscenter/cypress/e2e/REST APIs/chaoshub.cy.js @@ -101,7 +101,7 @@ describe('testing chaoshub', () => { Authorization: `Bearer ${accessToken}` } }).then((response) => { - expect(response.body.errors[0].message).to.equal('Name Already exists'); + expect(response.body.errors[0].message).to.equal('name already exists'); }); }); diff --git a/chaoscenter/cypress/e2e/REST APIs/login.cy.js b/chaoscenter/cypress/e2e/REST APIs/login.cy.js index eb16e1a9e..13adb97a6 100644 --- a/chaoscenter/cypress/e2e/REST APIs/login.cy.js +++ b/chaoscenter/cypress/e2e/REST APIs/login.cy.js @@ -14,7 +14,7 @@ describe('Testing login page of chaoscenter via REST APIs', () => { }, }).then((response) => { expect(response.status).to.equal(400); - expect(response.body.error).to.equal('user does not exist'); + expect(response.body.error).to.equal('invalid_credentials'); }); }) }); \ No newline at end of file diff --git a/chaoscenter/cypress/e2e/UI/chaoshub.cy.js b/chaoscenter/cypress/e2e/UI/chaoshub.cy.js index a9a86f030..863f38a5e 100644 --- a/chaoscenter/cypress/e2e/UI/chaoshub.cy.js +++ b/chaoscenter/cypress/e2e/UI/chaoshub.cy.js @@ -7,7 +7,7 @@ describe('testing chaoshub via UI', () => { cy.visit('/dashboard'); cy.contains('ChaosHubs').click(); cy.contains('Litmus ChaosHub').should('exist'); - cy.contains('Connected').should('exist'); + //cy.contains('Connected').should('exist'); //Add new chaoshub with public repo cy.contains('New ChaosHub').click(); @@ -38,7 +38,7 @@ describe('testing chaoshub via UI', () => { cy.get('input[name="repoBranch"]').type('1'); cy.get('button[aria-label = "Connect Hub"]').click(); cy.on('window:alert', () => { - expect(message).to.equal('Name Already exists'); + expect(message).to.equal('name already exists'); }); }); diff --git a/chaoscenter/cypress/e2e/UI/chaosinfra.cy.js b/chaoscenter/cypress/e2e/UI/chaosinfra.cy.js index aeba8210f..4a3c435f7 100644 --- a/chaoscenter/cypress/e2e/UI/chaosinfra.cy.js +++ b/chaoscenter/cypress/e2e/UI/chaosinfra.cy.js @@ -4,16 +4,11 @@ describe('testing chaosinfra via UI', () => { }); it('Creating chaosinfra', () => { - //create Environment - cy.contains('Environments').click(); - cy.contains('New Environment').click(); - cy.get('input[name="name"]').type('exp1'); - cy.contains('Save').click(); - //create chaosinfra + cy.contains('Environments').click(); cy.get('.TableV2--row').eq(0).click(); cy.contains('Enable Chaos').click(); - cy.get('.bp3-form-content').type('exp1'); + cy.get('.bp3-form-content').type('exp11'); cy.contains('Next').click(); cy.contains('Next').click(); cy.contains('Download').click(); @@ -26,10 +21,10 @@ describe('testing chaosinfra via UI', () => { it('negative test case for environment [Get error when creating environment with same name]', () => { cy.contains('Environments').click(); cy.contains('New Environment').click(); - cy.get('input[name="name"]').type('exp1'); + cy.get('input[name="name"]').type('exp99'); cy.contains('Save').click(); cy.on('alert message', () => { - expect(message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.environment index: environment_id_1 dup key: { environment_id: "exp1" }]'); + expect(message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.environment index: environment_id_1 dup key: { environment_id: "exp99" }]'); }); }); diff --git a/chaoscenter/cypress/e2e/UI/chaosprobes.cy.js b/chaoscenter/cypress/e2e/UI/chaosprobes.cy.js index 92aa460aa..27d91e1a8 100644 --- a/chaoscenter/cypress/e2e/UI/chaosprobes.cy.js +++ b/chaoscenter/cypress/e2e/UI/chaosprobes.cy.js @@ -11,7 +11,6 @@ describe('testing of HTTP chaos probes', () => { cy.contains('Configure Properties').click(); cy.get('input[name="kubernetesHTTPProperties.probeTimeout"]').type('1s'); cy.get('input[name="kubernetesHTTPProperties.interval"]').type('1s'); - cy.get('input[name="kubernetesHTTPProperties.retry"]').type('5'); cy.get('input[name="kubernetesHTTPProperties.attempt"]').type('5'); cy.get('input[name="kubernetesHTTPProperties.probePollingInterval"]').type('1s'); cy.get('input[name="kubernetesHTTPProperties.evaluationTimeout"]').type('1s'); @@ -74,7 +73,6 @@ describe('testing of CMD chaos probes', () => { cy.contains('Configure Properties').click(); cy.get('input[name="kubernetesCMDProperties.probeTimeout"]').type('1s'); cy.get('input[name="kubernetesCMDProperties.interval"]').type('1s'); - cy.get('input[name="kubernetesCMDProperties.retry"]').type('5'); cy.get('input[name="kubernetesCMDProperties.attempt"]').type('5'); cy.get('input[name="kubernetesCMDProperties.probePollingInterval"]').type('1s'); cy.get('input[name="kubernetesCMDProperties.evaluationTimeout"]').type('1s'); @@ -137,7 +135,6 @@ describe('testing of Prometheus chaos probes', () => { cy.contains('Configure Properties').click(); cy.get('input[name="promProperties.probeTimeout"]').type('1s'); cy.get('input[name="promProperties.interval"]').type('1s'); - cy.get('input[name="promProperties.retry"]').type('5'); cy.get('input[name="promProperties.attempt"]').type('5'); cy.get('input[name="promProperties.probePollingInterval"]').type('1s'); cy.get('input[name="promProperties.evaluationTimeout"]').type('1s'); @@ -201,7 +198,6 @@ describe('testing of kubernetes chaos probes', () => { cy.contains('Configure Properties').click(); cy.get('input[name="k8sProperties.probeTimeout"]').type('1s'); cy.get('input[name="k8sProperties.interval"]').type('1s'); - cy.get('input[name="k8sProperties.retry"]').type('5'); cy.get('input[name="k8sProperties.attempt"]').type('5'); cy.get('input[name="k8sProperties.probePollingInterval"]').type('1s'); cy.get('input[name="k8sProperties.evaluationTimeout"]').type('1s'); diff --git a/chaoscenter/cypress/e2e/UI/login.cy.js b/chaoscenter/cypress/e2e/UI/login.cy.js index a485b1308..2c72531b4 100644 --- a/chaoscenter/cypress/e2e/UI/login.cy.js +++ b/chaoscenter/cypress/e2e/UI/login.cy.js @@ -9,7 +9,7 @@ describe('Testing login page of chaoscenter via UI', () => { cy.get('input[name="password"]').type('invalid_password'); cy.get('button[type="submit"]').click(); cy.on('window:alert', (message) => { - expect(message).to.equal('user does not exist'); + expect(message).to.equal('invalid_credentials'); }); }); }); \ No newline at end of file From fa94ebb9799b48646f3ff272edf441a92ad36e64 Mon Sep 17 00:00:00 2001 From: Dhanush0369 Date: Wed, 22 May 2024 14:44:03 +0530 Subject: [PATCH 2/6] Update E2E-chaoscenter workflow and cypress config file Signed-off-by: Dhanush0369 --- chaoscenter/cypress.config.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/chaoscenter/cypress.config.js b/chaoscenter/cypress.config.js index 0d0878671..c1447b71f 100644 --- a/chaoscenter/cypress.config.js +++ b/chaoscenter/cypress.config.js @@ -2,11 +2,7 @@ const { defineConfig } = require("cypress"); module.exports = defineConfig({ e2e: { - baseUrl: "http://localhost:3000", // default value - setupNodeEvents(on, config) { - config.env.baseUrl = process.env.CYPRESS_baseUrl || config.env.baseUrl; - return config; - }, + baseUrl: process.env.CYPRESS_baseUrl || "http://localhost:3000", // default value requestTimeout: 60000, responseTimeout: 60000 }, From 5f7efca4b99a78684b986c12db0227d2da4deb17 Mon Sep 17 00:00:00 2001 From: Dhanush0369 Date: Wed, 22 May 2024 14:44:39 +0530 Subject: [PATCH 3/6] Update E2E-chaoscenter workflow Signed-off-by: Dhanush0369 --- .../workflows/E2E-chaoscenter-pipeline.yml | 33 ++++--------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/.github/workflows/E2E-chaoscenter-pipeline.yml b/.github/workflows/E2E-chaoscenter-pipeline.yml index 6d4edea94..8956ea46e 100644 --- a/.github/workflows/E2E-chaoscenter-pipeline.yml +++ b/.github/workflows/E2E-chaoscenter-pipeline.yml @@ -9,28 +9,7 @@ on: - main jobs: - setup: - runs-on: ubuntu-latest - steps: - - name: Set up Minikube - run: | - sudo apt update && sudo apt install -y curl - curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 - sudo install minikube-linux-amd64 /usr/local/bin/minikube - minikube start - - - name: Install kubectl - run: | - sudo apt update && sudo apt install -y kubectl - - - name: Install helm - run: | - curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 - chmod 700 get_helm.sh - ./get_helm.sh - run-litmus: - needs: setup runs-on: ubuntu-latest steps: - name: Add litmus Chaos Repository @@ -50,13 +29,13 @@ jobs: - name: Wait for pods to be ready run: | - sleep 60s - while true; do - if kubectl get pods --namespace litmus | grep -q "1/1"; then - break - fi - sleep 20 + sleep 30s + while [[ $(kubectl get pods -n litmus --no-headers | grep -v 'Running\|Completed' | wc -l) -gt 0 ]]; do + echo "Waiting for pods to be ready..." + kubectl get pods -n litmus + sleep 10 done + echo "All pods are ready!" - name: Extract Minikube IP and NodePort id: extract-urls From f2c4c6bcfabfcf0b7c73de6010a656f8b72fbc21 Mon Sep 17 00:00:00 2001 From: Dhanush0369 Date: Mon, 27 May 2024 16:11:32 +0530 Subject: [PATCH 4/6] Update E2E-chaoscenter workflow Signed-off-by: Dhanush0369 --- .../workflows/E2E-chaoscenter-pipeline.yml | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/.github/workflows/E2E-chaoscenter-pipeline.yml b/.github/workflows/E2E-chaoscenter-pipeline.yml index 8956ea46e..c9f035d7c 100644 --- a/.github/workflows/E2E-chaoscenter-pipeline.yml +++ b/.github/workflows/E2E-chaoscenter-pipeline.yml @@ -18,24 +18,13 @@ jobs: - name: Start minikube run: minikube start - - name: Create litmus namespace - run: kubectl create ns litmus + - name: Apply Litmus manifest + run: | + kubectl apply -f https://raw.githubusercontent.com/litmuschaos/litmus/master/chaoscenter/manifests/litmus-cluster-scope.yaml - - name: Install Litmus - run: | - helm install chaos litmuschaos/litmus \ - --namespace=litmus \ - --set portal.frontend.service.type=NodePort - - - name: Wait for pods to be ready - run: | - sleep 30s - while [[ $(kubectl get pods -n litmus --no-headers | grep -v 'Running\|Completed' | wc -l) -gt 0 ]]; do - echo "Waiting for pods to be ready..." - kubectl get pods -n litmus - sleep 10 - done - echo "All pods are ready!" + - name: Wait for Litmus pods to be ready + run: | + kubectl wait --for=condition=Ready pods --all --namespace=litmus --timeout=300s - name: Extract Minikube IP and NodePort id: extract-urls From 0ffb65bf8ba08729e9de8011fb4b1d7b8cd60db6 Mon Sep 17 00:00:00 2001 From: Dhanush0369 Date: Mon, 27 May 2024 16:20:21 +0530 Subject: [PATCH 5/6] Update E2E-chaoscenter workflow Signed-off-by: Dhanush0369 --- .github/workflows/E2E-chaoscenter-pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/E2E-chaoscenter-pipeline.yml b/.github/workflows/E2E-chaoscenter-pipeline.yml index c9f035d7c..a5508a74c 100644 --- a/.github/workflows/E2E-chaoscenter-pipeline.yml +++ b/.github/workflows/E2E-chaoscenter-pipeline.yml @@ -24,6 +24,7 @@ jobs: - name: Wait for Litmus pods to be ready run: | + sleep 30 kubectl wait --for=condition=Ready pods --all --namespace=litmus --timeout=300s - name: Extract Minikube IP and NodePort From ce71d5ff3bbbbbc548613df9561c39eb2d4ddb50 Mon Sep 17 00:00:00 2001 From: Dhanush0369 Date: Mon, 3 Jun 2024 22:08:07 +0530 Subject: [PATCH 6/6] Updated E2E-chaoscenter workflow Signed-off-by: Dhanush0369 --- .../workflows/E2E-chaoscenter-pipeline.yml | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/E2E-chaoscenter-pipeline.yml b/.github/workflows/E2E-chaoscenter-pipeline.yml index a5508a74c..0bc79a052 100644 --- a/.github/workflows/E2E-chaoscenter-pipeline.yml +++ b/.github/workflows/E2E-chaoscenter-pipeline.yml @@ -14,18 +14,27 @@ jobs: steps: - name: Add litmus Chaos Repository run: helm repo add litmuschaos https://litmuschaos.github.io/litmus-helm/ - + - name: Start minikube run: minikube start - - - name: Apply Litmus manifest - run: | - kubectl apply -f https://raw.githubusercontent.com/litmuschaos/litmus/master/chaoscenter/manifests/litmus-cluster-scope.yaml - - name: Wait for Litmus pods to be ready - run: | - sleep 30 - kubectl wait --for=condition=Ready pods --all --namespace=litmus --timeout=300s + - name: Create litmus namespace + run: kubectl create ns litmus + + - name: Install Litmus + run: | + helm install chaos litmuschaos/litmus \ + --namespace=litmus \ + --set portal.frontend.service.type=NodePort + - name: Wait for pods to be ready + run: | + sleep 30s + while [[ $(kubectl get pods -n litmus --no-headers | grep -v 'Running\|Completed' | wc -l) -gt 0 ]]; do + echo "Waiting for pods to be ready..." + kubectl get pods -n litmus + sleep 10 + done + echo "All pods are ready!" - name: Extract Minikube IP and NodePort id: extract-urls @@ -44,8 +53,4 @@ jobs: start: npm start working-directory: chaoscenter env: - CYPRESS_baseUrl: http://${{ env.MINIKUBE_IP }}:${{ env.NODE_PORT }} - - - - \ No newline at end of file + CYPRESS_baseUrl: http://${{ env.MINIKUBE_IP }}:${{ env.NODE_PORT }} \ No newline at end of file