Skip to content

Commit

Permalink
Refactor installApp & update chart
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Pinjani <chandan.pinjani@suse.com>
  • Loading branch information
cpinjani committed Feb 3, 2025
1 parent 13dc7cc commit 893d65b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Import CAPA EKS', { tags: '@full' }, () => {
cy.contains(clusterName).click();

// Install App
cy.installApp('Monitoring', 'cattle-monitoring');
cy.checkApp('Install', 'Monitoring', 'cattle-monitoring');
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Import CAPA RKE2', { tags: '@full' }, () => {
cy.contains(clusterName).click();

// Install App
cy.installApp('Monitoring', 'cattle-monitoring');
cy.checkApp('Install', 'Monitoring', 'cattle-monitoring');
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Import CAPD Kubeadm', { tags: '@short' }, () => {
// Click on imported CAPD cluster
cy.contains(clusterName).click();
// Install App
cy.installApp('Monitoring', 'cattle-monitoring');
cy.checkApp('Install', 'Monitoring', 'cattle-monitoring');
})
);

Expand Down
14 changes: 13 additions & 1 deletion tests/cypress/latest/e2e/unit_tests/capd_rke2_cluster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('Import CAPD RKE2', { tags: '@short' }, () => {
const basePath = '/tests/assets/rancher-turtles-fleet-example/'
const pathNames = ['rke2_namespace_autoimport', 'rke2_clusterclass_autoimport']
const branch = 'main'
const questions = [{ menuEntry: 'Rancher Turtles Features Settings', inputBoxTitle: 'Kubectl Image', inputBoxValue: 'registry.k8s.io/kubernetes/kubectl:v1.31.0' }];

beforeEach(() => {
cy.login();
Expand Down Expand Up @@ -81,7 +82,7 @@ describe('Import CAPD RKE2', { tags: '@short' }, () => {
cy.contains(clusterName).click();

// Install App
cy.installApp('Monitoring', 'cattle-monitoring');
cy.checkApp('Install', 'Monitoring', 'cattle-monitoring');
})
);

Expand All @@ -107,6 +108,17 @@ describe('Import CAPD RKE2', { tags: '@short' }, () => {
cy.checkCAPIClusterProvisioned(clusterName);
})
);

qase(41,
it('Update chart and check cluster status', () => {
cy.contains('local').click();
cy.checkApp('Update', 'Rancher Turtles', 'rancher-turtles-system', '', questions);

// Check cluster is Active
cy.searchCluster(clusterName);
cy.contains(new RegExp('Active.*' + clusterName), { timeout: timeout });
})
);
}

qase(9,
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/latest/e2e/unit_tests/capg_cluster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Import CAPG GKE', { tags: '@full' }, () => {
cy.contains(clusterName).click();

// Install App
cy.installApp('Monitoring', 'cattle-monitoring');
cy.checkApp('Install', 'Monitoring', 'cattle-monitoring');
})
);

Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/latest/e2e/unit_tests/capz_cluster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('Import CAPZ', { tags: '@full' }, () => {
cy.contains(clusterName).click();

// Install App
cy.installApp('Monitoring', 'cattle-monitoring');
cy.checkApp('Install', 'Monitoring', 'cattle-monitoring');
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Install Turtles Operator', { tags: '@install' }, () => {
turtlesVersion = ""
}

cy.installApp('Rancher Turtles', 'rancher-turtles-system', turtlesVersion, questions);
cy.checkApp('Install', 'Rancher Turtles', 'rancher-turtles-system', turtlesVersion, questions);
})
);
});
24 changes: 14 additions & 10 deletions tests/cypress/latest/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,29 +217,33 @@ Cypress.Commands.add('addCloudCredsAzure', (name: string, clientID: string, clie
cy.contains(name).should('be.visible');
});

// Command to Install App from Charts menu
// Command to Install or Update App from Charts menu
// Opration types: Install, Update
// You can optionally provide an array of questions and answer them before the installation starts
// Example1: cy.installApp('Alerting', 'default', [{ menuEntry: '(None)', checkbox: 'Enable Microsoft Teams' }]);
// Example2: cy.installApp('Rancher Turtles', 'rancher-turtles-system', [{ menuEntry: 'Rancher Turtles Features Settings', checkbox: 'Seamless integration with Fleet and CAPI'},{ menuEntry: 'Rancher webhook cleanup settings', inputBoxTitle: 'Webhook Cleanup Image', inputBoxValue: 'registry.k8s.io/kubernetes/kubectl:v1.28.0'}]);
Cypress.Commands.add('installApp', (appName, namespace, version, questions) => {
// Example1: cy.checkApp('Alerting', 'default', [{ menuEntry: '(None)', checkbox: 'Enable Microsoft Teams' }]);
// Example2: cy.checkApp('Rancher Turtles', 'rancher-turtles-system', [{ menuEntry: 'Rancher Turtles Features Settings', checkbox: 'Seamless integration with Fleet and CAPI'},{ menuEntry: 'Rancher webhook cleanup settings', inputBoxTitle: 'Webhook Cleanup Image', inputBoxValue: 'registry.k8s.io/kubernetes/kubectl:v1.28.0'}]);
Cypress.Commands.add('checkApp', (operation, chartName, namespace, version, questions) => {
cy.get('.nav').contains('Apps').click();
cy.contains('Featured Charts').should('be.visible');
cy.contains(appName, { timeout: 60000 }).click();
cy.contains('Charts: ' + appName);
cy.contains(chartName, { timeout: 60000 }).click();
cy.contains('Charts: ' + chartName);

if (version != undefined && version != "") {
cy.contains(version).click();
cy.url().should("contain", version)
}
cy.clickButton('Install');
cy.contains('.outer-container > .header', appName);
cy.clickButton(operation);
// During update, chart name changes to App name
if (operation == "Install") {
cy.contains('.outer-container > .header', chartName);
}
cy.clickButton('Next');

// Used for entering questions and answering them
if (questions != undefined) {
// Some apps like Alerting show questions page directly so no further action needed here
// Some other apps like Turtles have a 'Customize install settings' checkbox or its variant which needs to be clicked
if (appName == 'Rancher Turtles') {
if (chartName == 'Rancher Turtles' && operation == "Install") {
cy.contains('Customize install settings').should('be.visible').click();
}

Expand All @@ -254,7 +258,7 @@ Cypress.Commands.add('installApp', (appName, namespace, version, questions) => {
});
}

cy.clickButton('Install');
cy.clickButton(operation);

// Close the shell to avoid conflict
cy.get('.closer').click();
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/latest/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare global {
forceUpdateFleetGitRepo(repoName: string, workspace?: string): Chainable<Element>;
checkFleetGitRepo(repoName: string, workspace?: string): Chainable<Element>;
accesMenuSelection(firstAccessMenu: string, secondAccessMenu?: string): Chainable<Element>;
installApp(appName: string, namespace: string, version: string, questions?: any): Chainable<Element>;
checkApp(operation: string, chartName: string, namespace: string, version?: string, questions?: any): Chainable<Element>;
deleteCluster(clusterName: string): Chainable<Element>;
searchCluster(clusterName: string): Chainable<Element>;
createNamespace(namespace: string): Chainable<Element>;
Expand Down

0 comments on commit 893d65b

Please sign in to comment.