Skip to content

Commit

Permalink
automation: add step to ensure aks is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonas Berhe authored and Yonas Berhe committed Jan 18, 2025
1 parent 946fd38 commit c0fd960
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
31 changes: 30 additions & 1 deletion cypress/e2e/tests/pages/manager/cluster-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const clusterNamePartial = `${ runPrefix }-create`;
const rke1CustomName = `${ clusterNamePartial }-rke1-custom`;
const rke2CustomName = `${ clusterNamePartial }-rke2-custom`;
const importGenericName = `${ clusterNamePartial }-import-generic`;
let reenableAKS = false;

const downloadsFolder = Cypress.config('downloadsFolder');

Expand Down Expand Up @@ -91,16 +92,35 @@ describe('Cluster Manager', { testIsolation: 'off', tags: ['@manager', '@adminUs
});

it('deactivating a kontainer driver should hide its card from the cluster creation page', () => {
cy.intercept('GET', '/v3/kontainerdrivers').as('getKontainerDrivers');
cy.intercept('POST', 'v3/kontainerDrivers/azurekubernetesservice?action=deactivate').as('deactivateDriver');
cy.intercept('POST', 'v3/kontainerDrivers/azurekubernetesservice?action=activate').as('activateDriver');

const driversPage = new KontainerDriversPagePo();
const clusterCreatePage = new ClusterManagerCreatePagePo();

// deactivate the AKS driver
KontainerDriversPagePo.navTo();
driversPage.waitForPage();

// assert AKS kontainer driver is in Active state
cy.wait('@getKontainerDrivers').then(({ response }) => {
response.body.data.forEach((item: any) => {
if (item.id === 'azurekubernetesservice') {
const state = item['active'];

expect(state).to.eq(true);
}
});
});

// deactivate the AKS driver
driversPage.list().actionMenu('Azure AKS').getMenuItem('Deactivate').click();
const deactivateDialog = new DeactivateDriverDialogPo();

deactivateDialog.deactivate();
cy.wait('@deactivateDriver').its('response.statusCode').should('eq', 200).then(() => {
reenableAKS = true;
});

// verify that the AKS card is not shown
clusterList.goTo();
Expand All @@ -112,6 +132,9 @@ describe('Cluster Manager', { testIsolation: 'off', tags: ['@manager', '@adminUs
KontainerDriversPagePo.navTo();
driversPage.waitForPage();
driversPage.list().actionMenu('Azure AKS').getMenuItem('Activate').click();
cy.wait('@activateDriver').its('response.statusCode').should('eq', 200).then(() => {
reenableAKS = false;
});

// verify that the AKS card is back
clusterList.goTo();
Expand Down Expand Up @@ -828,4 +851,10 @@ describe('Cluster Manager', { testIsolation: 'off', tags: ['@manager', '@adminUs
});
});
});

after(() => {
if (reenableAKS) {
cy.createRancherResource('v3', 'kontainerDrivers/azurekubernetesservice?action=activate', {});
}
});
});
4 changes: 2 additions & 2 deletions cypress/support/commands/rancher-api-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ Cypress.Commands.add('createRancherResource', (prefix, resourceType, body) => {
body
})
.then((resp) => {
// Expect 201, Created HTTP status code
expect(resp.status).to.eq(201);
// Expect 200 or 201, Created HTTP status code
expect(resp.status).to.be.oneOf([200, 201]);
});
});

Expand Down

0 comments on commit c0fd960

Please sign in to comment.