Skip to content

Commit

Permalink
e2e: Add metadata input field to createAmazonRke2Cluster; Check fleet…
Browse files Browse the repository at this point in the history
… clusters labels

Signed-off-by: Francesco Torchia <[email protected]>
  • Loading branch information
torchiaf committed Jan 28, 2025
1 parent df1aab5 commit d11320a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 4 additions & 0 deletions cypress/e2e/po/lists/fleet/fleet.cattle.io.cluster.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ export default class FleetClusterList extends BaseResourceList {
details(name: string, index: number) {
return this.resourceTable().sortableTable().rowWithName(name).column(index);
}

subRows() {
return this.resourceTable().sortableTable().subRows();
}
}
5 changes: 4 additions & 1 deletion cypress/e2e/tests/pages/fleet/fleet-clusters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ describe('Fleet Clusters', { tags: ['@fleet', '@adminUser'] }, () => {
rke2ClusterAmazon: {
clusterName: name,
namespace,
}
},
metadata: { labels: { foo: 'bar' } }
}).then(() => {
removeCluster = true;
});
Expand Down Expand Up @@ -123,6 +124,8 @@ describe('Fleet Clusters', { tags: ['@fleet', '@adminUser'] }, () => {
fleetClusterListPage.clusterList().details(clusterName, 4).should('have.text', '1');
// check resources: testing https://github.com/rancher/dashboard/issues/11154
fleetClusterListPage.clusterList().details(clusterName, 5).contains( ' 1 ', MEDIUM_TIMEOUT_OPT);
// check cluster labels
fleetClusterListPage.clusterList().subRows().should('contain.text', 'foo=bar');

const fleetClusterDetailsPage = new FleetClusterDetailsPo(namespace, clusterName);

Expand Down
8 changes: 6 additions & 2 deletions cypress/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type CreateAmazonRke2ClusterParams = {
type: string,
clusterName: string,
namespace: string
},
},
cloudCredentialsAmazon: {
workspace: string,
name: string,
Expand All @@ -40,7 +40,11 @@ export type CreateAmazonRke2ClusterParams = {
rke2ClusterAmazon: {
clusterName: string,
namespace: string,
}
},
metadata?: {
labels?: { [key: string]: string },
annotations?: { [key: string]: string },
},
}
export type CreateAmazonRke2ClusterWithoutMachineConfigParams = {
cloudCredentialsAmazon: {
Expand Down
12 changes: 9 additions & 3 deletions cypress/support/commands/rancher-api-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ Cypress.Commands.add('deleteNodeTemplate', (nodeTemplateId, timeout = 30000, fai
* Create RKE2 cluster with Amazon EC2 cloud provider
*/
Cypress.Commands.add('createAmazonRke2Cluster', (params: CreateAmazonRke2ClusterParams) => {
const { machineConfig, rke2ClusterAmazon, cloudCredentialsAmazon } = params;
const {
machineConfig, rke2ClusterAmazon, cloudCredentialsAmazon, metadata
} = params;

return cy.createAwsCloudCredentials(cloudCredentialsAmazon.workspace, cloudCredentialsAmazon.name, cloudCredentialsAmazon.region, cloudCredentialsAmazon.accessKey, cloudCredentialsAmazon.secretKey)
.then((resp: Cypress.Response<any>) => {
Expand All @@ -625,8 +627,12 @@ Cypress.Commands.add('createAmazonRke2Cluster', (params: CreateAmazonRke2Cluster
type: 'provisioning.cattle.io.cluster',
metadata: {
namespace: rke2ClusterAmazon.namespace,
annotations: { 'field.cattle.io/description': `${ rke2ClusterAmazon.clusterName }-description` },
name: rke2ClusterAmazon.clusterName
annotations: {
'field.cattle.io/description': `${ rke2ClusterAmazon.clusterName }-description`,
...(metadata?.annotations || {}),
},
labels: metadata?.labels || {},
name: rke2ClusterAmazon.clusterName
},
spec: {
rkeConfig: {
Expand Down

0 comments on commit d11320a

Please sign in to comment.