Skip to content

Commit

Permalink
test: [M3-9023] - Add coverage for Kube version upgrades in landing p…
Browse files Browse the repository at this point in the history
…age (#11478)

## Description 📝
Add coverage for checking that there is no upgrade chip when there is no new kube version available and move kube version landing page e2e tests from `lke-update.spec.ts` to `lke-landing-page.spec.ts`

## How to test 🧪

```
yarn cy:run -s "cypress/e2e/core/kubernetes/lke-landing-page.spec.ts"
```

---------

Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
  • Loading branch information
hana-akamai and mjac0bs authored Jan 7, 2025
1 parent 2e4dabf commit 47ddb5b
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 134 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11478-tests-1736180178602.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add coverage for Kube version upgrades in landing page ([#11478](https://github.com/linode/manager/pull/11478))
186 changes: 186 additions & 0 deletions packages/manager/cypress/e2e/core/kubernetes/lke-landing-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import {
mockGetClusters,
mockGetClusterPools,
mockGetKubeconfig,
mockGetKubernetesVersions,
mockGetTieredKubernetesVersions,
mockRecycleAllNodes,
mockUpdateCluster,
} from 'support/intercepts/lke';
import {
accountFactory,
Expand Down Expand Up @@ -165,4 +169,186 @@ describe('LKE landing page', () => {
cy.wait('@getKubeconfig');
readDownload(mockKubeconfigFilename).should('eq', mockKubeconfigContents);
});

it('does not show an Upgrade chip when there is no new kubernetes standard version', () => {
const oldVersion = '1.25';
const newVersion = '1.26';

const cluster = kubernetesClusterFactory.build({
k8s_version: newVersion,
});

mockGetClusters([cluster]).as('getClusters');
mockGetKubernetesVersions([newVersion, oldVersion]).as('getVersions');

cy.visitWithLogin(`/kubernetes/clusters`);

cy.wait(['@getClusters', '@getVersions']);

cy.findByText(newVersion).should('be.visible');

cy.findByText('UPGRADE').should('not.exist');
});

it('does not show an Upgrade chip when there is no new kubernetes enterprise version', () => {
const oldVersion = '1.31.1+lke1';
const newVersion = '1.32.1+lke2';

mockGetAccount(
accountFactory.build({
capabilities: ['Kubernetes Enterprise'],
})
).as('getAccount');

// TODO LKE-E: Remove once feature is in GA
mockAppendFeatureFlags({
lkeEnterprise: { enabled: true, la: true },
});

const cluster = kubernetesClusterFactory.build({
k8s_version: newVersion,
tier: 'enterprise',
});

mockGetClusters([cluster]).as('getClusters');
mockGetTieredKubernetesVersions('enterprise', [
{ id: newVersion, tier: 'enterprise' },
{ id: oldVersion, tier: 'enterprise' },
]).as('getTieredVersions');

cy.visitWithLogin(`/kubernetes/clusters`);

cy.wait(['@getAccount', '@getClusters', '@getTieredVersions']);

cy.findByText(newVersion).should('be.visible');

cy.findByText('UPGRADE').should('not.exist');
});

it('can upgrade the standard kubernetes version from the landing page', () => {
const oldVersion = '1.25';
const newVersion = '1.26';

const cluster = kubernetesClusterFactory.build({
k8s_version: oldVersion,
});

const updatedCluster = { ...cluster, k8s_version: newVersion };

mockGetClusters([cluster]).as('getClusters');
mockGetKubernetesVersions([newVersion, oldVersion]).as('getVersions');
mockUpdateCluster(cluster.id, updatedCluster).as('updateCluster');
mockRecycleAllNodes(cluster.id).as('recycleAllNodes');

cy.visitWithLogin(`/kubernetes/clusters`);

cy.wait(['@getClusters', '@getVersions']);

cy.findByText(oldVersion).should('be.visible');

cy.findByText('UPGRADE').should('be.visible').should('be.enabled').click();

ui.dialog
.findByTitle(
`Step 1: Upgrade ${cluster.label} to Kubernetes ${newVersion}`
)
.should('be.visible');

mockGetClusters([updatedCluster]).as('getClusters');

ui.button
.findByTitle('Upgrade Version')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait(['@updateCluster', '@getClusters']);

ui.dialog
.findByTitle('Step 2: Recycle All Cluster Nodes')
.should('be.visible');

ui.button
.findByTitle('Recycle All Nodes')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait('@recycleAllNodes');

ui.toast.assertMessage('Recycle started successfully.');

cy.findByText(newVersion).should('be.visible');
});

it('can upgrade the enterprise kubernetes version from the landing page', () => {
const oldVersion = '1.31.1+lke1';
const newVersion = '1.32.1+lke2';

mockGetAccount(
accountFactory.build({
capabilities: ['Kubernetes Enterprise'],
})
).as('getAccount');

// TODO LKE-E: Remove once feature is in GA
mockAppendFeatureFlags({
lkeEnterprise: { enabled: true, la: true },
});

const cluster = kubernetesClusterFactory.build({
k8s_version: oldVersion,
tier: 'enterprise',
});

const updatedCluster = { ...cluster, k8s_version: newVersion };

mockGetClusters([cluster]).as('getClusters');
mockGetTieredKubernetesVersions('enterprise', [
{ id: newVersion, tier: 'enterprise' },
{ id: oldVersion, tier: 'enterprise' },
]).as('getTieredVersions');
mockUpdateCluster(cluster.id, updatedCluster).as('updateCluster');
mockRecycleAllNodes(cluster.id).as('recycleAllNodes');

cy.visitWithLogin(`/kubernetes/clusters`);

cy.wait(['@getAccount', '@getClusters', '@getTieredVersions']);

cy.findByText(oldVersion).should('be.visible');

cy.findByText('UPGRADE').should('be.visible').should('be.enabled').click();

ui.dialog
.findByTitle(
`Step 1: Upgrade ${cluster.label} to Kubernetes ${newVersion}`
)
.should('be.visible');

mockGetClusters([updatedCluster]).as('getClusters');

ui.button
.findByTitle('Upgrade Version')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait(['@updateCluster', '@getClusters']);

ui.dialog
.findByTitle('Step 2: Recycle All Cluster Nodes')
.should('be.visible');

ui.button
.findByTitle('Recycle All Nodes')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait('@recycleAllNodes');

ui.toast.assertMessage('Recycle started successfully.');

cy.findByText(newVersion).should('be.visible');
});
});
134 changes: 0 additions & 134 deletions packages/manager/cypress/e2e/core/kubernetes/lke-update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
mockRecycleAllNodes,
mockGetDashboardUrl,
mockGetApiEndpoints,
mockGetClusters,
mockUpdateControlPlaneACL,
mockGetControlPlaneACL,
mockUpdateControlPlaneACLError,
Expand Down Expand Up @@ -238,65 +237,6 @@ describe('LKE cluster updates', () => {
ui.toast.findByMessage('Recycle started successfully.');
});

it('can upgrade the standard kubernetes version from the landing page', () => {
const oldVersion = '1.25';
const newVersion = '1.26';

const cluster = kubernetesClusterFactory.build({
k8s_version: oldVersion,
});

const updatedCluster = { ...cluster, k8s_version: newVersion };

mockGetClusters([cluster]).as('getClusters');
mockGetKubernetesVersions([newVersion, oldVersion]).as('getVersions');
mockUpdateCluster(cluster.id, updatedCluster).as('updateCluster');
mockRecycleAllNodes(cluster.id).as('recycleAllNodes');

cy.visitWithLogin(`/kubernetes/clusters`);

cy.wait(['@getClusters', '@getVersions']);

cy.findByText(oldVersion).should('be.visible');

cy.findByText('UPGRADE')
.should('be.visible')
.should('be.enabled')
.click();

ui.dialog
.findByTitle(
`Step 1: Upgrade ${cluster.label} to Kubernetes ${newVersion}`
)
.should('be.visible');

mockGetClusters([updatedCluster]).as('getClusters');

ui.button
.findByTitle('Upgrade Version')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait(['@updateCluster', '@getClusters']);

ui.dialog
.findByTitle('Step 2: Recycle All Cluster Nodes')
.should('be.visible');

ui.button
.findByTitle('Recycle All Nodes')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait('@recycleAllNodes');

ui.toast.assertMessage('Recycle started successfully.');

cy.findByText(newVersion).should('be.visible');
});

/*
* - Confirms UI flow of upgrading Kubernetes enterprise version using mocked API requests.
* - Confirms that Kubernetes upgrade prompt is shown when not up-to-date.
Expand Down Expand Up @@ -425,80 +365,6 @@ describe('LKE cluster updates', () => {
ui.toast.findByMessage('Recycle started successfully.');
});

it('can upgrade the enterprise kubernetes version from the landing page', () => {
const oldVersion = '1.31.1+lke1';
const newVersion = '1.32.1+lke2';

mockGetAccount(
accountFactory.build({
capabilities: ['Kubernetes Enterprise'],
})
).as('getAccount');

// TODO LKE-E: Remove once feature is in GA
mockAppendFeatureFlags({
lkeEnterprise: { enabled: true, la: true },
});

const cluster = kubernetesClusterFactory.build({
k8s_version: oldVersion,
tier: 'enterprise',
});

const updatedCluster = { ...cluster, k8s_version: newVersion };

mockGetClusters([cluster]).as('getClusters');
mockGetTieredKubernetesVersions('enterprise', [
{ id: newVersion, tier: 'enterprise' },
{ id: oldVersion, tier: 'enterprise' },
]).as('getTieredVersions');
mockUpdateCluster(cluster.id, updatedCluster).as('updateCluster');
mockRecycleAllNodes(cluster.id).as('recycleAllNodes');

cy.visitWithLogin(`/kubernetes/clusters`);

cy.wait(['@getAccount', '@getClusters', '@getTieredVersions']);

cy.findByText(oldVersion).should('be.visible');

cy.findByText('UPGRADE')
.should('be.visible')
.should('be.enabled')
.click();

ui.dialog
.findByTitle(
`Step 1: Upgrade ${cluster.label} to Kubernetes ${newVersion}`
)
.should('be.visible');

mockGetClusters([updatedCluster]).as('getClusters');

ui.button
.findByTitle('Upgrade Version')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait(['@updateCluster', '@getClusters']);

ui.dialog
.findByTitle('Step 2: Recycle All Cluster Nodes')
.should('be.visible');

ui.button
.findByTitle('Recycle All Nodes')
.should('be.visible')
.should('be.enabled')
.click();

cy.wait('@recycleAllNodes');

ui.toast.assertMessage('Recycle started successfully.');

cy.findByText(newVersion).should('be.visible');
});

/*
* - Confirms node, node pool, and cluster recycling UI flow using mocked API data.
* - Confirms that user is warned that recycling recreates nodes and may take a while.
Expand Down

0 comments on commit 47ddb5b

Please sign in to comment.