From 6655f119edad75ffee5123ff156438903243fbd8 Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Wed, 12 Jun 2024 14:23:20 +0200 Subject: [PATCH] * [e2e] [Schedule VM on the Node which is Enable Maintenance Mode] - use host.customName to check Volumes VMs; lint fix Signed-off-by: Francesco Torchia --- cypress/pageobjects/hosts.po.ts | 13 +++++++++---- cypress/pageobjects/virtualmachine.po.ts | 7 ++++--- .../testcases/virtualmachines/scheduling.spec.ts | 16 +++++++++------- cypress/utils/utils.ts | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/cypress/pageobjects/hosts.po.ts b/cypress/pageobjects/hosts.po.ts index b372acd97..cc74626da 100644 --- a/cypress/pageobjects/hosts.po.ts +++ b/cypress/pageobjects/hosts.po.ts @@ -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'; @@ -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); }) } diff --git a/cypress/pageobjects/virtualmachine.po.ts b/cypress/pageobjects/virtualmachine.po.ts index 385bb8c2d..a33ae689e 100755 --- a/cypress/pageobjects/virtualmachine.po.ts +++ b/cypress/pageobjects/virtualmachine.po.ts @@ -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, diff --git a/cypress/testcases/virtualmachines/scheduling.spec.ts b/cypress/testcases/virtualmachines/scheduling.spec.ts index 4a82ba7a9..873144403 100644 --- a/cypress/testcases/virtualmachines/scheduling.spec.ts +++ b/cypress/testcases/virtualmachines/scheduling.spec.ts @@ -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(); @@ -14,9 +14,11 @@ 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(); @@ -24,15 +26,15 @@ describe('VM scheduling on Specific node', () => { 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(); diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 373a35992..abc014ea0 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -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) {