Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import ClusterManagerCreateRke2AmazonPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/create/cluster-create-rke2-amazon.po';
import ClusterManagerListPagePo from '@/cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po';
import ClusterManagerDetailRke2AmazonEc2PagePo from '@/cypress/e2e/po/detail/provisioning.cattle.io.cluster/cluster-detail-rke2-amazon.po';
import ClusterManagerEditGenericPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/edit/cluster-edit-generic.po';
import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po';
import LoadingPo from '@/cypress/e2e/po/components/loading.po';
import TabbedPo from '@/cypress/e2e/po/components/tabbed.po';
Expand All @@ -16,6 +17,7 @@ describe('Deploy RKE2 cluster using node driver on Amazon EC2', { testIsolation:
let removeCloudCred = false;
let cloudcredentialId = '';
let k8sVersion = '';
let olderK8sVersion = '';
let clusterId = '';

before(() => {
Expand Down Expand Up @@ -83,16 +85,24 @@ describe('Deploy RKE2 cluster using node driver on Amazon EC2', { testIsolation:
createRKE2ClusterPage.nameNsDescription().name().set(this.rke2Ec2ClusterName);
createRKE2ClusterPage.nameNsDescription().description().set(`${ this.rke2Ec2ClusterName }-description`);

// Get latest kubernetes version
// Get kubernetes versions - use an older version for initial creation, then upgrade later
cy.wait('@getRke2Releases').then(({ response }) => {
expect(response.statusCode).to.eq(200);
const length = response.body.data.length - 1;
const index1 = response.body.data.length - 1;

k8sVersion = response.body.data[length].id;
// Store the latest version for upgrade test
k8sVersion = response.body.data[index1].id;
cy.wrap(k8sVersion).as('k8sVersion');

// Use the older version for cluster creation
// This allows us to test the upgrade scenario
const index2 = index1 - 1;

olderK8sVersion = response.body.data[index2].id;
cy.wrap(olderK8sVersion).as('olderK8sVersion');
});

cy.get<string>('@k8sVersion').then((version) => {
cy.get<string>('@olderK8sVersion').then((version) => {
createRKE2ClusterPage.basicsTab().kubernetesVersions().toggle();
createRKE2ClusterPage.basicsTab().kubernetesVersions().clickOptionWithLabel(version);

Expand Down Expand Up @@ -132,7 +142,7 @@ describe('Deploy RKE2 cluster using node driver on Amazon EC2', { testIsolation:

// check k8s version
clusterList.list().version(this.rke2Ec2ClusterName).then((el) => {
expect(el.text().trim()).contains(k8sVersion);
expect(el.text().trim()).contains(olderK8sVersion);
});

// check provider
Expand Down Expand Up @@ -166,6 +176,68 @@ describe('Deploy RKE2 cluster using node driver on Amazon EC2', { testIsolation:
clusterDetails.recentEventsList().checkTableIsEmpty();
});

it('can upgrade Kubernetes version', function() {
ClusterManagerListPagePo.navTo();
clusterList.waitForPage();

// Navigate to edit page
clusterList.list().actionMenu(this.rke2Ec2ClusterName).getMenuItem('Edit Config').click();

const editClusterPage = new ClusterManagerEditGenericPagePo('_', this.rke2Ec2ClusterName);

editClusterPage.waitForPage('mode=edit', 'basic');

// Verify we're starting with the older version
editClusterPage.basicsTab().kubernetesVersions().checkContainsOptionSelected(olderK8sVersion);

// Select the latest version for upgrade
editClusterPage.basicsTab().kubernetesVersions().toggle();
editClusterPage.basicsTab().kubernetesVersions().clickOptionWithLabel(k8sVersion);

cy.intercept('PUT', `/v1/provisioning.cattle.io.clusters/fleet-default/${ this.rke2Ec2ClusterName }`).as('clusterUpdate');
// Save the cluster to upgrade the Kubernetes version
editClusterPage.save().click();

// Wait for the cluster update to complete
cy.wait('@clusterUpdate').then((interception) => {
// If 409 conflict, wait for retry
if (interception.response?.statusCode === 409) {
cy.log('Cluster update failed with 409 error, waiting for retry...');

return cy.wait('@clusterUpdate', MEDIUM_TIMEOUT_OPT);
}

return cy.wrap(interception);
}).then(({ response }: any) => {
expect(response?.statusCode).to.equal(200);
expect(response?.body).to.have.property('kind', 'Cluster');
expect(response?.body.metadata).to.have.property('name', this.rke2Ec2ClusterName);
expect(response?.body.spec).to.have.property('kubernetesVersion').contains(k8sVersion);
});

clusterList.waitForPage();
clusterList.list().state(this.rke2Ec2ClusterName).should('contain.text', 'Updating');
clusterList.list().state(this.rke2Ec2ClusterName).contains('Active', { timeout: 700000 });

// check k8s version
clusterList.list().version(this.rke2Ec2ClusterName).then((el) => {
expect(el.text().trim()).contains(k8sVersion);
});

// Navigate back to edit page to verify older version is disabled in dropdown
clusterList.list().actionMenu(this.rke2Ec2ClusterName).getMenuItem('Edit Config').click();
editClusterPage.waitForPage('mode=edit', 'basic');

// Verify current version is selected
editClusterPage.basicsTab().kubernetesVersions().checkContainsOptionSelected(k8sVersion);

// Open dropdown and verify older version is disabled
editClusterPage.basicsTab().kubernetesVersions().toggle();
editClusterPage.basicsTab().kubernetesVersions().getOptions()
.contains('li', olderK8sVersion)
.should('have.class', 'vs__dropdown-option--disabled');
});

it('can create snapshot', function() {
const clusterDetails = new ClusterManagerDetailRke2AmazonEc2PagePo(undefined, this.rke2Ec2ClusterName);
const tabbedPo = new TabbedPo('[data-testid="tabbed-block"]');
Expand Down