From c0fd9603c6380dae23cbea6804b89e645a48f692 Mon Sep 17 00:00:00 2001 From: Yonas Berhe Date: Tue, 14 Jan 2025 14:00:06 -0800 Subject: [PATCH] automation: add step to ensure aks is enabled --- .../pages/manager/cluster-manager.spec.ts | 31 ++++++++++++++++++- .../support/commands/rancher-api-commands.ts | 4 +-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/tests/pages/manager/cluster-manager.spec.ts b/cypress/e2e/tests/pages/manager/cluster-manager.spec.ts index e68b4adc715..1a678bb191b 100644 --- a/cypress/e2e/tests/pages/manager/cluster-manager.spec.ts +++ b/cypress/e2e/tests/pages/manager/cluster-manager.spec.ts @@ -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'); @@ -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(); @@ -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(); @@ -828,4 +851,10 @@ describe('Cluster Manager', { testIsolation: 'off', tags: ['@manager', '@adminUs }); }); }); + + after(() => { + if (reenableAKS) { + cy.createRancherResource('v3', 'kontainerDrivers/azurekubernetesservice?action=activate', {}); + } + }); }); diff --git a/cypress/support/commands/rancher-api-commands.ts b/cypress/support/commands/rancher-api-commands.ts index 7afc70efa1a..601db0080c1 100644 --- a/cypress/support/commands/rancher-api-commands.ts +++ b/cypress/support/commands/rancher-api-commands.ts @@ -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]); }); });