]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: multicluster management e2e tests
authorNizamudeen A <nia@redhat.com>
Wed, 12 Jun 2024 08:28:17 +0000 (13:58 +0530)
committerNizamudeen A <nia@redhat.com>
Thu, 11 Jul 2024 06:41:01 +0000 (12:11 +0530)
auth, edit, reconnect and disconnect another cluster

Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.e2e-spec.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/cypress/e2e/multi-cluster/multi-cluster.po.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html
src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh

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 (file)
index 0000000..74f26df
--- /dev/null
@@ -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 (file)
index 0000000..08fbe7b
--- /dev/null
@@ -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);
+  }
+}
index f238946963d5825003e2d3e3ef4384b41813af49..f2d5c7f941ac11da2449cdc4fe725e8bede81f15 100644 (file)
     <!-- ************************* -->
     <cds-header-navigation class="cluster-switcher"
                            *ngIf="clustersMap?.size > 1">
-      <cds-header-menu [title]="currentClusterName">
+      <cds-header-menu [title]="currentClusterName"
+                       data-testid="selected-cluster">
         <ng-container *ngFor="let cluster of clustersMap | keyvalue; trackBy:trackByFn ">
           <cds-header-item (click)="onClusterSelection(cluster.value)"
-                           [class.disabled]="cluster.value.cluster_connection_status === 1">
+                           [class.disabled]="cluster.value.cluster_connection_status === 1"
+                           data-testid="select-a-cluster">
               {{ cluster.value.name }} - {{ cluster.value?.cluster_alias }} - {{ cluster.value?.user }}
           </cds-header-item>
         </ng-container>
index a481a983f40bb0f74a6f1c47ea40742eb377d92f..8c4c17355968a06de9a172e3bdcf385093e2e79d 100755 (executable)
@@ -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