Skip to content

Commit

Permalink
MGMT-15054: FCP devices (multipath) do not show correct size (openshi…
Browse files Browse the repository at this point in the history
…ft-assisted#2286)

* Do not include disks with holders in the total storage size calculations

* Total disk storage calculation tests

* Simplify storage host inventory fixtures

---------

Co-authored-by: Jonathan Kilzi <[email protected]>
  • Loading branch information
2 people authored and rawagner committed Sep 13, 2023
1 parent bbbc1f6 commit 1428400
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 57 deletions.
6 changes: 3 additions & 3 deletions libs/ui-lib-tests/cypress/fixtures/storage/host-inventory.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`, () => {
Expand Down Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
3 changes: 0 additions & 3 deletions libs/ui-lib-tests/cypress/support/variables/test-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
65 changes: 25 additions & 40 deletions libs/ui-lib-tests/cypress/views/hostsTableSection.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,71 @@
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 {
expect(hostRole).to.contain('Worker');
}
});
},
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 {
expect(hostCpuCores).to.contain(Cypress.env('workerCPU'));
}
});
},
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 {
expect(hostMemory).to.contain(Cypress.env('workerMemory'));
}
});
},
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) => {
Expand Down
3 changes: 2 additions & 1 deletion libs/ui-lib/lib/common/components/hosts/hardwareInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down

0 comments on commit 1428400

Please sign in to comment.