diff --git a/libs/ui-lib-tests/cypress/fixtures/storage/host-inventory.ts b/libs/ui-lib-tests/cypress/fixtures/storage/host-inventory.ts index 15b38170a6..8f56359627 100644 --- a/libs/ui-lib-tests/cypress/fixtures/storage/host-inventory.ts +++ b/libs/ui-lib-tests/cypress/fixtures/storage/host-inventory.ts @@ -1,4 +1,4 @@ -const createHostInventory = (id: number, memory: number, diskSpace: number) => { +const createHostInventory = (id: number, memory: number, diskSpace: number = 0) => { const hostSeqId = id * 10; // To differentiate disks of each hosts return { bmc_address: '0.0.0.0', @@ -370,8 +370,8 @@ const disksWithHolders = [ }, ]; -const createHostInventoryWithDiskHolders = (id: number, memory: number, diskSpace: number) => ({ - ...createHostInventory(id, memory, diskSpace), +const createHostInventoryWithDiskHolders = (id: number, memory: number) => ({ + ...createHostInventory(id, memory), disks: disksWithHolders, }); diff --git a/libs/ui-lib-tests/cypress/fixtures/storage/storage-hosts.ts b/libs/ui-lib-tests/cypress/fixtures/storage/storage-hosts.ts index de34eae383..005c34da04 100644 --- a/libs/ui-lib-tests/cypress/fixtures/storage/storage-hosts.ts +++ b/libs/ui-lib-tests/cypress/fixtures/storage/storage-hosts.ts @@ -382,7 +382,6 @@ const hostsWithDiskHolders = hosts.map((host, index) => ({ createHostInventoryWithDiskHolders( index, host['role'] === 'master' ? masterMemory : workerMemory, - host['role'] === 'master' ? masterDisk : workerDisk, ), ), installation_disk_id: installationDiskIds[index], diff --git a/libs/ui-lib-tests/cypress/integration/create-multinode/1-host-discovery.cy.ts b/libs/ui-lib-tests/cypress/integration/create-multinode/1-host-discovery.cy.ts index 05cca6ebbe..d22c97e997 100644 --- a/libs/ui-lib-tests/cypress/integration/create-multinode/1-host-discovery.cy.ts +++ b/libs/ui-lib-tests/cypress/integration/create-multinode/1-host-discovery.cy.ts @@ -9,12 +9,11 @@ import * as utils from '../../support/utils'; const validateHostTableDetails = () => { Cypress.env('masterCPU', '8'); Cypress.env('masterMemory', '33.20 GiB'); - Cypress.env('masterDiskTotalSize', '12.88 GB'); - hostsTableSection.validateHostCpuCores(3, 0); - hostsTableSection.validateHostDiskSize(3, 0); - hostsTableSection.validateHostMemory(3, 0); - hostsTableSection.validateHostRoles(3, 0); + hostsTableSection.validateHostCpuCores(); + hostsTableSection.validateHostDiskSize(12.88, 0); + hostsTableSection.validateHostMemory(); + hostsTableSection.validateHostRoles(); }; describe(`Assisted Installer Multinode Host discovery`, () => { @@ -75,7 +74,7 @@ describe(`Assisted Installer Multinode Host discovery`, () => { cy.wait(['@rename-host-1', '@rename-host-2', '@rename-host-3']).then(() => { utils.setLastWizardSignal('HOST_RENAMED_3'); hostsTableSection.waitForHardwareStatus('Ready'); - hostsTableSection.validateHostNames(3, 0, [ + hostsTableSection.validateHostNames([ `${hostPrefix}-1`, `${hostPrefix}-2`, `${hostPrefix}-3`, diff --git a/libs/ui-lib-tests/cypress/integration/storage/storage-step-disk-holders.cy.ts b/libs/ui-lib-tests/cypress/integration/storage/storage-step-disk-holders.cy.ts index 46c56a2dfb..e8f5f9163f 100644 --- a/libs/ui-lib-tests/cypress/integration/storage/storage-step-disk-holders.cy.ts +++ b/libs/ui-lib-tests/cypress/integration/storage/storage-step-disk-holders.cy.ts @@ -59,6 +59,10 @@ describe(`Assisted Installer Storage Step`, () => { ); }); + it('Should calculate the total storage size correctly', () => { + hostsTableSection.validateHostDiskSize(51.52, 51.52); + }); + it('Should display the correct warning for LVM', () => { disks[1].warning = true; diff --git a/libs/ui-lib-tests/cypress/integration/storage/storage-step.cy.ts b/libs/ui-lib-tests/cypress/integration/storage/storage-step.cy.ts index d2048bdf55..3f74309fe0 100644 --- a/libs/ui-lib-tests/cypress/integration/storage/storage-step.cy.ts +++ b/libs/ui-lib-tests/cypress/integration/storage/storage-step.cy.ts @@ -46,11 +46,9 @@ describe(`Assisted Installer Storage Step`, () => { }); it('Should display the existing hosts storage details', () => { - Cypress.env('masterDiskTotalSize', '35.59 GB'); - Cypress.env('workerDiskTotalSize', '20.95 GB'); hostsTableSection.waitForHardwareStatus('Ready'); hostsTableSection.validateHostRoles(); - hostsTableSection.validateHostDiskSize(); + hostsTableSection.validateHostDiskSize(35.59, 20.95); storagePage.validateNumberOfDisks(); }); diff --git a/libs/ui-lib-tests/cypress/support/variables/test-constants.ts b/libs/ui-lib-tests/cypress/support/variables/test-constants.ts index ea4e13d572..da68cf300c 100644 --- a/libs/ui-lib-tests/cypress/support/variables/test-constants.ts +++ b/libs/ui-lib-tests/cypress/support/variables/test-constants.ts @@ -6,6 +6,3 @@ Cypress.env('START_INSTALLATION_TIMEOUT', 2.5 * 60 * 1000); Cypress.env('GENERATE_ISO_TIMEOUT', 2 * 60 * 1000); Cypress.env('HOST_STATUS_INSUFFICIENT_TIMEOUT', 300000); Cypress.env('DNS_RESOLUTION_ALERT_MESSAGE_TIMEOUT', 900000); -// Deployment -Cypress.env('NUM_MASTERS', parseInt(Cypress.env('NUM_MASTERS'))); -Cypress.env('NUM_WORKERS', parseInt(Cypress.env('NUM_WORKERS'))); diff --git a/libs/ui-lib-tests/cypress/views/hostsTableSection.ts b/libs/ui-lib-tests/cypress/views/hostsTableSection.ts index 6d0056ec51..561c91d863 100644 --- a/libs/ui-lib-tests/cypress/views/hostsTableSection.ts +++ b/libs/ui-lib-tests/cypress/views/hostsTableSection.ts @@ -1,25 +1,21 @@ export type ValidateDiskHoldersParams = { name: string; indented?: boolean; warning?: boolean }[]; +const numMasters = (): number => Cypress.env('NUM_MASTERS'); +const numWorkers = (): number => Cypress.env('NUM_WORKERS'); + export const hostsTableSection = { - validateHostNames: ( - numMasters: number = Cypress.env('NUM_MASTERS'), - numWorkers: number = Cypress.env('NUM_WORKERS'), - hostNames = Cypress.env('requestedHostnames'), - ) => { + validateHostNames: (hostNames = Cypress.env('requestedHostnames')) => { cy.get('[data-testid=host-name]') - .should('have.length', numMasters + numWorkers) + .should('have.length', numMasters() + numWorkers()) .each((hostName, idx) => { expect(hostName).to.contain(hostNames[idx]); }); }, - validateHostRoles: ( - numMasters: number = Cypress.env('NUM_MASTERS'), - numWorkers: number = Cypress.env('NUM_WORKERS'), - ) => { + validateHostRoles: () => { cy.get('td[data-testid="host-role"]') - .should('have.length', numMasters + numWorkers) + .should('have.length', numMasters() + numWorkers()) .each((hostRole, idx) => { - const isMaster = idx <= numMasters - 1; + const isMaster = idx <= numMasters() - 1; if (isMaster) { expect(hostRole).to.contain('Control plane node'); } else { @@ -27,14 +23,11 @@ export const hostsTableSection = { } }); }, - validateHostCpuCores: ( - numMasters: number = Cypress.env('NUM_MASTERS'), - numWorkers: number = Cypress.env('NUM_WORKERS'), - ) => { + validateHostCpuCores: () => { cy.get('td[data-label="CPU Cores"]') - .should('have.length', numMasters + numWorkers) + .should('have.length', numMasters() + numWorkers()) .each((hostCpuCores, idx) => { - const isMaster = idx <= numMasters - 1; + const isMaster = idx <= numMasters() - 1; if (isMaster) { expect(hostCpuCores).to.contain(Cypress.env('masterCPU')); } else { @@ -42,14 +35,11 @@ export const hostsTableSection = { } }); }, - validateHostMemory: ( - numMasters: number = Cypress.env('NUM_MASTERS'), - numWorkers: number = Cypress.env('NUM_WORKERS'), - ) => { + validateHostMemory: () => { cy.get('td[data-label="Memory"]') - .should('have.length', numMasters + numWorkers) + .should('have.length', numMasters() + numWorkers()) .each((hostMemory, idx) => { - const isMaster = idx <= numMasters - 1; + const isMaster = idx <= numMasters() - 1; if (isMaster) { expect(hostMemory).to.contain(Cypress.env('masterMemory')); } else { @@ -57,30 +47,25 @@ export const hostsTableSection = { } }); }, - validateHostDiskSize: ( - numMasters: number = Cypress.env('NUM_MASTERS'), - numWorkers: number = Cypress.env('NUM_WORKERS'), - ) => { + validateHostDiskSize: (masterDiskTotalSize: number, workerDiskTotalSize: number) => { cy.get('td[data-label="Total storage"]') - .should('have.length', numMasters + numWorkers) + .should('have.length', numMasters() + numWorkers()) .each((hostDisk, idx) => { - const isMaster = idx <= numMasters - 1; + const isMaster = idx <= numMasters() - 1; if (isMaster) { - expect(hostDisk).to.contain(Cypress.env('masterDiskTotalSize')); + expect(hostDisk).to.contain(`${masterDiskTotalSize} GB`); } else { - expect(hostDisk).to.contain(Cypress.env('workerDiskTotalSize')); + expect(hostDisk).to.contain(`${workerDiskTotalSize} GB`); } }); }, - waitForHardwareStatus: ( - status, - numMasters: number = Cypress.env('NUM_MASTERS'), - numWorkers: number = Cypress.env('NUM_WORKERS'), - timeout = Cypress.env('HOST_READY_TIMEOUT'), - ) => { + waitForHardwareStatus: (status: string) => { // Start at index 2 here because of selector - for (let i = 2; i <= numMasters + numWorkers + 1; i++) { - cy.hostDetailSelector(i, 'Status', timeout).should('contain.text', status); + for (let i = 2; i <= numMasters() + numWorkers() + 1; i++) { + cy.hostDetailSelector(i, 'Status', Cypress.env('HOST_READY_TIMEOUT')).should( + 'contain.text', + status, + ); } }, getHostDisksExpander: (hostIndex: number) => { diff --git a/libs/ui-lib/lib/common/components/hosts/hardwareInfo.ts b/libs/ui-lib/lib/common/components/hosts/hardwareInfo.ts index 236c2b1cda..74841cb435 100644 --- a/libs/ui-lib/lib/common/components/hosts/hardwareInfo.ts +++ b/libs/ui-lib/lib/common/components/hosts/hardwareInfo.ts @@ -20,9 +20,10 @@ export type SimpleHardwareInfo = { export const getMemoryCapacity = (inventory: Inventory): number => inventory.memory?.physicalBytes || 0; + export const getDiskCapacity = (inventory: Inventory): number => inventory.disks - ?.filter((disk) => disk.driveType !== OpticalDiskDriveType) + ?.filter((disk) => disk.driveType !== OpticalDiskDriveType && !disk.holders) .reduce((diskSize: number, disk: Disk) => diskSize + (disk.sizeBytes || 0), 0) || 0; export const getHumanizedCpuClockSpeed = (inventory: Inventory) =>