Skip to content

Commit

Permalink
* [e2e] [Schedule VM on the Node which is Enable Maintenance Mode] - …
Browse files Browse the repository at this point in the history
…use host.customName to check Volumes VMs; lint fix

Signed-off-by: Francesco Torchia <[email protected]>
  • Loading branch information
torchiaf committed Jun 12, 2024
1 parent 1f2021b commit 6655f11
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
13 changes: 9 additions & 4 deletions cypress/pageobjects/hosts.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ interface ValueInterface {
consoleUrl?: string,
}

export interface Node {
name: string;
customName: string;
}

export class HostsPage extends CruResourcePo {
private hostList = '.host-list';
private actionsDropdown = '.role-multi-action';
Expand Down Expand Up @@ -69,13 +74,13 @@ export class HostsPage extends CruResourcePo {
}
}

enableMaintenance(name:string) {
cy.intercept('POST', `/v1/harvester/${this.realType}s/${name}?action=enableMaintenanceMode`).as('enable');
this.clickAction(name, 'Enable Maintenance Mode');
enableMaintenance(node: Node) {
cy.intercept('POST', `/v1/harvester/${this.realType}s/${node.name}?action=enableMaintenanceMode`).as('enable');
this.clickAction(node.customName || node.name, 'Enable Maintenance Mode');
// Maintenance
cy.get('.card-container').contains('Apply').click();
cy.wait('@enable').then(res => {
expect(res.response?.statusCode, `Enable maintenance ${name}`).to.equal(204);
expect(res.response?.statusCode, `Enable maintenance ${node.name}`).to.equal(204);
})
}

Expand Down
7 changes: 4 additions & 3 deletions cypress/pageobjects/virtualmachine.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,17 @@ export class VmsPage extends CruResourcePo {
}) {
this.clickTab('nodeScheduling');

const rulesRadio = new RadioButtonPo('.radio-group', ':contains("Run VM on node(s) matching scheduling rules")')
const specificRadio = new RadioButtonPo('.radio-group', ':contains("Run VM on specific node")')
const nodeNameSelector = new LabeledSelectPo('.labeled-select', `:contains("Node Name")`)

switch (radio) {
case 'rules':
const rulesRadio = new RadioButtonPo('.radio-group', ':contains("Run VM on node(s) matching scheduling rules")')
rulesRadio.input('Run VM on node(s) matching scheduling rules')
break;
case 'specific':
const specificRadio = new RadioButtonPo('.radio-group', ':contains("Run VM on specific node")')
specificRadio.input('Run VM on specific node')

const nodeNameSelector = new LabeledSelectPo('.labeled-select', `:contains("Node Name")`)
nodeNameSelector.select({
selector: '.vs__dropdown-menu',
option: nodeName,
Expand Down
16 changes: 9 additions & 7 deletions cypress/testcases/virtualmachines/scheduling.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VmsPage } from "@/pageobjects/virtualmachine.po";
import { HostsPage } from "@/pageobjects/hosts.po";
import { HostsPage, Node } from "@/pageobjects/hosts.po";

const vms = new VmsPage();
const hosts = new HostsPage();
Expand All @@ -14,25 +14,27 @@ describe('VM scheduling on Specific node', () => {

it('Schedule VM on the Node which is Enable Maintenance Mode', () => {
const hostList = Cypress.env('host');
const hostNames: string[] = hostList.map((host: any) => host.name);
const maintenanceNode = hostNames[0]
const filterMaintenanceNames = hostNames.filter(name => name !== maintenanceNode);

const hostNames: string[] = hostList.map((node: Node) => node.customName || node.name);

const maintenanceNodeName = hostNames[0]
const filterMaintenanceNodeNames = hostNames.filter(name => name !== maintenanceNodeName);

// Check whether all nodes can be selected
vms.goToCreate();
vms.selectSchedulingType({type: 'specific'});
vms.checkSpecificNodes({includeNodes: hostNames});

hosts.goToList();
hosts.enableMaintenance(hostNames[0]);
hosts.enableMaintenance(hostList[0]);

// Maintenance nodes should not be selected
vms.goToCreate();
vms.selectSchedulingType({type: 'specific'});
vms.checkSpecificNodes({includeNodes: filterMaintenanceNames, excludeNodes: [maintenanceNode]});
vms.checkSpecificNodes({includeNodes: filterMaintenanceNodeNames, excludeNodes: [maintenanceNodeName]});

hosts.goToList();
hosts.clickAction(hostList[0].name, 'Disable Maintenance Mode');
hosts.clickAction(hostNames[0], 'Disable Maintenance Mode');

// Check whether all nodes can be selected
vms.goToCreate();
Expand Down
2 changes: 1 addition & 1 deletion cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function base64Decode(string: string) {
}

export const nodes = {
filterWitnessNode: (hosts: any[]) => {
filterWitnessNode: (hosts: {name: string, witnessNode: boolean}[]) => {
const ret = hosts.filter((host) => !host.witnessNode);

if (!ret.length) {
Expand Down

0 comments on commit 6655f11

Please sign in to comment.