Skip to content

Commit 537c45c

Browse files
authored
Automate test cluster Fleet-22 (#302)
* Automate test cluster Fleet-22 Signed-off-by: Satyajit Bulage <[email protected]> * Updated test according to suggestions Signed-off-by: Satyajit Bulage <[email protected]> * Removed Force Update causing cluster change state Signed-off-by: Satyajit Bulage <[email protected]> * Updated navigation to Clusters page Signed-off-by: Satyajit Bulage <[email protected]> * Added Force Update for 2.9 and 2.10 versions --------- Signed-off-by: Satyajit Bulage <[email protected]>
1 parent 5d3770e commit 537c45c

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- clusterSelector:
2+
matchLabels:
3+
key_third_cluster: value_third_cluster

tests/cypress/e2e/unit_tests/p1_2_fleet.spec.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,89 @@ describe("Test Application deployment based on 'clusterSelector'", { tags: '@p1_
591591
)
592592
})
593593
)
594+
595+
qase(22,
596+
it("Fleet-22: Test install app to new set of clusters from old set of clusters", { tags: '@fleet-22' }, () => {
597+
const repoName = 'default-multiple-apps-cluster-selector'
598+
const new_key = 'key_third_cluster'
599+
const new_value = 'value_third_cluster'
600+
601+
gitRepoFile = 'assets/git-repo-multiple-app-cluster-selector.yaml'
602+
603+
cy.accesMenuSelection('Continuous Delivery', 'Clusters');
604+
cy.contains('.title', 'Clusters').should('be.visible');
605+
606+
// Assign label to the clusters
607+
dsFirstTwoClusterList.forEach(
608+
(dsCluster) => {
609+
cy.assignClusterLabel(dsCluster, key, value);
610+
}
611+
)
612+
613+
// Create a GitRepo targeting cluster selector created from YAML.
614+
cy.clickNavMenu(['Git Repos']);
615+
cy.wait(500);
616+
cy.clickButton('Add Repository');
617+
cy.contains('Git Repo:').should('be.visible');
618+
cy.clickButton('Edit as YAML');
619+
cy.addYamlFile(gitRepoFile);
620+
cy.clickButton('Create');
621+
cy.checkGitRepoStatus('default-multiple-apps-cluster-selector', '2 / 2');
622+
623+
// Check first application status on both clusters.
624+
dsFirstTwoClusterList.forEach((dsCluster) => {
625+
cy.checkApplicationStatus(appName, dsCluster, 'All Namespaces');
626+
})
627+
628+
// Add label to the third cluster
629+
cy.accesMenuSelection('Continuous Delivery', 'Clusters');
630+
cy.contains('.title', 'Clusters').should('be.visible');
631+
cy.assignClusterLabel(dsThirdClusterName, new_key, new_value);
632+
633+
// Update GitRepo with newly created clusterGroup.
634+
cy.addFleetGitRepo({ repoName, deployToTarget: "Advanced", fleetNamespace: 'fleet-default', editConfig: true });
635+
cy.clickButton('Save');
636+
cy.checkGitRepoStatus(repoName, '2 / 2');
637+
638+
// Check application is present on third cluster i.e. imported-2
639+
cy.checkApplicationStatus(appName, dsThirdClusterName, 'All Namespaces');
640+
641+
// Applying Force Update in 2.9 and 2.10 versions only as it doesn't have cluster sync logic
642+
if (/\/2\.10/.test(Cypress.env('rancher_version')) || /\/2\.9/.test(Cypress.env('rancher_version'))) {
643+
cy.accesMenuSelection('Continuous Delivery', 'Clusters');
644+
cy.contains('.title', 'Clusters').should('be.visible');
645+
dsFirstTwoClusterList.forEach(
646+
(dsCluster) => {
647+
cy.filterInSearchBox(dsCluster);
648+
cy.open3dotsMenu(dsCluster, 'Force Update');
649+
cy.wait(2000); // It take some time to Update.
650+
cy.verifyTableRow(0, 'Active');
651+
}
652+
)
653+
}
654+
655+
// Check application status on first 2 clusters i.e. imported-0 and imported-1
656+
// Application should be removed from first 2 clusters i.e. imported-0 and imported-1
657+
dsFirstTwoClusterList.forEach(
658+
(dsCluster) => {
659+
cy.checkApplicationStatus(appName, dsCluster, 'All Namespaces', false);
660+
}
661+
)
662+
663+
// Remove labels from the clusters i.e. imported-0 and imported-1
664+
dsFirstTwoClusterList.forEach(
665+
(dsCluster) => {
666+
// Adding wait to load page correctly to avoid interference with hamburger-menu.
667+
cy.wait(500);
668+
cy.removeClusterLabels(dsCluster, key, value);
669+
}
670+
)
671+
672+
// Remove labels from third cluster i.e. imported-2
673+
cy.removeClusterLabels(dsThirdClusterName, new_key, new_value);
674+
})
675+
)
676+
594677
});
595678

596679
describe("Test Application deployment based on 'clusterGroupSelector'", { tags: '@p1_2'}, () => {

tests/cypress/support/commands.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ Cypress.Commands.add('deployToClusterOrClusterGroup', (deployToTarget) => {
248248
cy.get('div.labeled-select.create.hoverable, div.labeled-select.edit.hoverable, [data-testid="fleet-gitrepo-target-cluster"]').first().should('be.visible');
249249
cy.get('div.labeled-select.create.hoverable, div.labeled-select.edit.hoverable, [data-testid="fleet-gitrepo-target-cluster"]').first().click({ force: true });
250250
cy.get('ul.vs__dropdown-menu > li').contains(deployToTarget).should("exist").click();
251+
252+
// TODO: Update this in future with better logic
253+
// This is specific to Fleet-22 test cases
254+
if (deployToTarget == "Advanced") {
255+
cy.get('body').then((body) => {
256+
if (body.find("div.yaml-editor")) {
257+
cy.addYamlFile('assets/cluster_selector_with_new_labels.yaml')
258+
}
259+
})
260+
}
251261
});
252262

253263
// 3 dots menu selection

0 commit comments

Comments
 (0)