From: Nizamudeen A Date: Wed, 12 Jun 2024 08:28:17 +0000 (+0530) Subject: mgr/dashboard: multicluster management e2e tests X-Git-Tag: v20.0.0~1543^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=430623015a7eb6beb08cd08e7773156813655e17;p=ceph.git mgr/dashboard: multicluster management e2e tests auth, edit, reconnect and disconnect another cluster Signed-off-by: Nizamudeen A --- diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.e2e-spec.ts new file mode 100644 index 000000000000..74f26df8e564 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.e2e-spec.ts @@ -0,0 +1,54 @@ +import { DashboardPageHelper } from '../ui/dashboard.po'; +import { MultiClusterPageHelper } from './multi-cluster.po'; + +describe('Muti-cluster management page', () => { + const multiCluster = new MultiClusterPageHelper(); + const dashboard = new DashboardPageHelper(); + + const hubName = 'local-cluster'; + const url = Cypress.env('CEPH2_URL'); + const alias = 'ceph2'; + const username = 'admin'; + const password = 'admin'; + + const editedAlias = 'ceph2-edited'; + + beforeEach(() => { + cy.login(); + multiCluster.navigateTo('manage-clusters'); + }); + + it('should authenticate the second cluster', () => { + multiCluster.auth(url, alias, username, password); + multiCluster.existTableCell(alias); + }); + + it('should switch to the second cluster and back to hub', () => { + dashboard.navigateTo(); + cy.get('[data-testid="selected-cluster"]').click(); + cy.get('[data-testid="select-a-cluster"]').contains(alias).click(); + cy.get('[data-testid="selected-cluster"]').contains(alias); + cy.get('cd-dashboard-v3').should('exist'); + + // now switch back to the hub cluster + cy.get('[data-testid="selected-cluster"]').click(); + cy.get('[data-testid="select-a-cluster"]').contains(hubName).click(); + cy.get('[data-testid="selected-cluster"]').contains(hubName); + cy.get('cd-dashboard-v3').should('exist'); + }); + + it('should reconnect the second cluster', () => { + multiCluster.reconnect(alias, password); + multiCluster.existTableCell(alias); + }); + + it('should edit the second cluster', () => { + multiCluster.edit(alias, editedAlias); + multiCluster.existTableCell(editedAlias); + }); + + it('should disconnect the second cluster', () => { + multiCluster.disconnect(editedAlias); + multiCluster.existTableCell(editedAlias, false); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.po.ts new file mode 100644 index 000000000000..08fbe7b843dc --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.po.ts @@ -0,0 +1,55 @@ +import { PageHelper } from '../page-helper.po'; + +const pages = { + index: { url: '#/multi-cluster/overview', id: 'cd-multi-cluster' }, + 'manage-clusters': { url: '#/multi-cluster/manage-clusters', id: 'cd-multi-cluster-list' } +}; + +const WAIT_TIMER = 1000; + +export class MultiClusterPageHelper extends PageHelper { + pages = pages; + + auth(url: string, alias: string, username: string, password: string) { + this.clickActionButton('connect'); + cy.get('cd-multi-cluster-form').should('exist'); + cy.get('cd-modal').within(() => { + cy.get('input[name=remoteClusterUrl]').type(url); + cy.get('input[name=clusterAlias]').type(alias); + cy.get('input[name=username]').type(username); + cy.get('input[name=password]').type(password); + cy.get('cd-submit-button').click(); + }); + cy.wait(WAIT_TIMER); + } + + disconnect(alias: string) { + this.getFirstTableCell(alias).click(); + this.clickActionButton('disconnect'); + cy.get('cd-modal').within(() => { + cy.get('#confirmation').click(); + cy.get('cd-submit-button').click(); + }); + cy.wait(WAIT_TIMER); + } + + reconnect(alias: string, password: string) { + this.getFirstTableCell(alias).click(); + this.clickActionButton('reconnect'); + cy.get('cd-modal').within(() => { + cy.get('input[name=password]').type(password); + cy.get('cd-submit-button').click(); + }); + cy.wait(WAIT_TIMER); + } + + edit(alias: string, newAlias: string) { + this.getFirstTableCell(alias).click(); + this.clickActionButton('edit'); + cy.get('cd-modal').within(() => { + cy.get('input[name=clusterAlias]').clear().type(newAlias); + cy.get('cd-submit-button').click(); + }); + cy.wait(WAIT_TIMER); + } +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html index f238946963d5..f2d5c7f941ac 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html @@ -17,10 +17,12 @@ - + + [class.disabled]="cluster.value.cluster_connection_status === 1" + data-testid="select-a-cluster"> {{ cluster.value.name }} - {{ cluster.value?.cluster_alias }} - {{ cluster.value?.user }} diff --git a/src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh b/src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh index a481a983f40b..8c4c17355968 100755 --- a/src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh +++ b/src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh @@ -33,7 +33,21 @@ start_ceph() { # Set SSL verify to False ceph_all dashboard set-rgw-api-ssl-verify False - CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard) + # Set test_orchestrator as orch backend + ceph mgr module enable test_orchestrator + ceph orch set backend test_orchestrator + + CYPRESS_BASE_URL="" + retry=0 + while [[ -z "${CYPRESS_BASE_URL}" || "${CYPRESS_BASE_URL}" == "null" ]]; do + CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard) + if [ $retry -eq 10 ]; then + echo "ERROR: Could not get the dashboard URL" + stop 1 + fi + retry=$((retry + 1)) + sleep 1 + done CYPRESS_CEPH2_URL=$(ceph2 mgr services | jq -r .dashboard) # start rbd-mirror daemon in the cluster