Skip to content

Commit b9584cc

Browse files
authored
Merge pull request ceph#57989 from rhcs-dashboard/multicluster-e2e
mgr/dashboard: multicluster management e2e tests Reviewed-by: Ankush Behl <[email protected]>
2 parents 91d4896 + 4306230 commit b9584cc

File tree

4 files changed

+128
-3
lines changed

4 files changed

+128
-3
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { DashboardPageHelper } from '../ui/dashboard.po';
2+
import { MultiClusterPageHelper } from './multi-cluster.po';
3+
4+
describe('Muti-cluster management page', () => {
5+
const multiCluster = new MultiClusterPageHelper();
6+
const dashboard = new DashboardPageHelper();
7+
8+
const hubName = 'local-cluster';
9+
const url = Cypress.env('CEPH2_URL');
10+
const alias = 'ceph2';
11+
const username = 'admin';
12+
const password = 'admin';
13+
14+
const editedAlias = 'ceph2-edited';
15+
16+
beforeEach(() => {
17+
cy.login();
18+
multiCluster.navigateTo('manage-clusters');
19+
});
20+
21+
it('should authenticate the second cluster', () => {
22+
multiCluster.auth(url, alias, username, password);
23+
multiCluster.existTableCell(alias);
24+
});
25+
26+
it('should switch to the second cluster and back to hub', () => {
27+
dashboard.navigateTo();
28+
cy.get('[data-testid="selected-cluster"]').click();
29+
cy.get('[data-testid="select-a-cluster"]').contains(alias).click();
30+
cy.get('[data-testid="selected-cluster"]').contains(alias);
31+
cy.get('cd-dashboard-v3').should('exist');
32+
33+
// now switch back to the hub cluster
34+
cy.get('[data-testid="selected-cluster"]').click();
35+
cy.get('[data-testid="select-a-cluster"]').contains(hubName).click();
36+
cy.get('[data-testid="selected-cluster"]').contains(hubName);
37+
cy.get('cd-dashboard-v3').should('exist');
38+
});
39+
40+
it('should reconnect the second cluster', () => {
41+
multiCluster.reconnect(alias, password);
42+
multiCluster.existTableCell(alias);
43+
});
44+
45+
it('should edit the second cluster', () => {
46+
multiCluster.edit(alias, editedAlias);
47+
multiCluster.existTableCell(editedAlias);
48+
});
49+
50+
it('should disconnect the second cluster', () => {
51+
multiCluster.disconnect(editedAlias);
52+
multiCluster.existTableCell(editedAlias, false);
53+
});
54+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { PageHelper } from '../page-helper.po';
2+
3+
const pages = {
4+
index: { url: '#/multi-cluster/overview', id: 'cd-multi-cluster' },
5+
'manage-clusters': { url: '#/multi-cluster/manage-clusters', id: 'cd-multi-cluster-list' }
6+
};
7+
8+
const WAIT_TIMER = 1000;
9+
10+
export class MultiClusterPageHelper extends PageHelper {
11+
pages = pages;
12+
13+
auth(url: string, alias: string, username: string, password: string) {
14+
this.clickActionButton('connect');
15+
cy.get('cd-multi-cluster-form').should('exist');
16+
cy.get('cd-modal').within(() => {
17+
cy.get('input[name=remoteClusterUrl]').type(url);
18+
cy.get('input[name=clusterAlias]').type(alias);
19+
cy.get('input[name=username]').type(username);
20+
cy.get('input[name=password]').type(password);
21+
cy.get('cd-submit-button').click();
22+
});
23+
cy.wait(WAIT_TIMER);
24+
}
25+
26+
disconnect(alias: string) {
27+
this.getFirstTableCell(alias).click();
28+
this.clickActionButton('disconnect');
29+
cy.get('cd-modal').within(() => {
30+
cy.get('#confirmation').click();
31+
cy.get('cd-submit-button').click();
32+
});
33+
cy.wait(WAIT_TIMER);
34+
}
35+
36+
reconnect(alias: string, password: string) {
37+
this.getFirstTableCell(alias).click();
38+
this.clickActionButton('reconnect');
39+
cy.get('cd-modal').within(() => {
40+
cy.get('input[name=password]').type(password);
41+
cy.get('cd-submit-button').click();
42+
});
43+
cy.wait(WAIT_TIMER);
44+
}
45+
46+
edit(alias: string, newAlias: string) {
47+
this.getFirstTableCell(alias).click();
48+
this.clickActionButton('edit');
49+
cy.get('cd-modal').within(() => {
50+
cy.get('input[name=clusterAlias]').clear().type(newAlias);
51+
cy.get('cd-submit-button').click();
52+
});
53+
cy.wait(WAIT_TIMER);
54+
}
55+
}

src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
<!-- ************************* -->
1818
<cds-header-navigation class="cluster-switcher"
1919
*ngIf="clustersMap?.size > 1">
20-
<cds-header-menu [title]="currentClusterName">
20+
<cds-header-menu [title]="currentClusterName"
21+
data-testid="selected-cluster">
2122
<ng-container *ngFor="let cluster of clustersMap | keyvalue; trackBy:trackByFn ">
2223
<cds-header-item (click)="onClusterSelection(cluster.value)"
23-
[class.disabled]="cluster.value.cluster_connection_status === 1">
24+
[class.disabled]="cluster.value.cluster_connection_status === 1"
25+
data-testid="select-a-cluster">
2426
{{ cluster.value.name }} - {{ cluster.value?.cluster_alias }} - {{ cluster.value?.user }}
2527
</cds-header-item>
2628
</ng-container>

src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,21 @@ start_ceph() {
3333
# Set SSL verify to False
3434
ceph_all dashboard set-rgw-api-ssl-verify False
3535

36-
CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard)
36+
# Set test_orchestrator as orch backend
37+
ceph mgr module enable test_orchestrator
38+
ceph orch set backend test_orchestrator
39+
40+
CYPRESS_BASE_URL=""
41+
retry=0
42+
while [[ -z "${CYPRESS_BASE_URL}" || "${CYPRESS_BASE_URL}" == "null" ]]; do
43+
CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard)
44+
if [ $retry -eq 10 ]; then
45+
echo "ERROR: Could not get the dashboard URL"
46+
stop 1
47+
fi
48+
retry=$((retry + 1))
49+
sleep 1
50+
done
3751
CYPRESS_CEPH2_URL=$(ceph2 mgr services | jq -r .dashboard)
3852

3953
# start rbd-mirror daemon in the cluster

0 commit comments

Comments
 (0)