Skip to content

Commit

Permalink
Added Pipeline and edited testcases (#408)
Browse files Browse the repository at this point in the history
* Added Pipeline and edited testcases

Signed-off-by: Dhanush0369 <[email protected]>

* Update E2E-chaoscenter workflow and cypress config file

Signed-off-by: Dhanush0369 <[email protected]>

* Update E2E-chaoscenter workflow

Signed-off-by: Dhanush0369 <[email protected]>

* Update E2E-chaoscenter workflow

Signed-off-by: Dhanush0369 <[email protected]>

* Update E2E-chaoscenter workflow

Signed-off-by: Dhanush0369 <[email protected]>

* Updated E2E-chaoscenter workflow

Signed-off-by: Dhanush0369 <[email protected]>

---------

Signed-off-by: Dhanush0369 <[email protected]>
  • Loading branch information
Dhanush0369 authored Jun 10, 2024
1 parent a08a934 commit cf0ef5c
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 19 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/E2E-chaoscenter-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ChaosCenter E2E testing

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
run-litmus:
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 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
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 }}
2 changes: 1 addition & 1 deletion chaoscenter/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
baseUrl: 'http://192.168.49.2:30829',
baseUrl: process.env.CYPRESS_baseUrl || "http://localhost:3000", // default value
requestTimeout: 60000,
responseTimeout: 60000
},
Expand Down
2 changes: 1 addition & 1 deletion chaoscenter/cypress/e2e/REST APIs/chaoshub.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

Expand Down
2 changes: 1 addition & 1 deletion chaoscenter/cypress/e2e/REST APIs/login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
})
});
4 changes: 2 additions & 2 deletions chaoscenter/cypress/e2e/UI/chaoshub.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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');
});
});

Expand Down
13 changes: 4 additions & 9 deletions chaoscenter/cypress/e2e/UI/chaosinfra.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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" }]');
});
});

Expand Down
4 changes: 0 additions & 4 deletions chaoscenter/cypress/e2e/UI/chaosprobes.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion chaoscenter/cypress/e2e/UI/login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});

0 comments on commit cf0ef5c

Please sign in to comment.