Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2517 from mareklibra/editVmFlavor.tests
kubevirt: Add edit VM flavor integration test
- Loading branch information
Showing
13 changed files
with
291 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
frontend/packages/kubevirt-plugin/integration-tests/tests/models/editFlavorView.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { $ } from 'protractor'; | ||
|
||
export const flavorDropdownId = '#vm-flavor-modal-flavor-dropdown'; | ||
|
||
export const modalTitle = () => $('.modal-title'); | ||
export const flavorDropdownText = () => | ||
$('.kubevirt-vm-flavor-modal__dropdown .pf-c-dropdown__toggle-text'); | ||
export const saveButton = () => $('#confirm-action'); | ||
export const cpusInput = () => $('#vm-flavor-modal-cpu'); | ||
export const memoryInput = () => $('#vm-flavor-modal-memory'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
frontend/packages/kubevirt-plugin/integration-tests/tests/vm.detail.flavor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { browser, ExpectedConditions as until } from 'protractor'; | ||
import { testName } from '../../../../integration-tests/protractor.conf'; | ||
import { | ||
withResource, | ||
selectDropdownOptionById, | ||
click, | ||
} from '../../../console-shared/src/test-utils/utils'; | ||
import * as virtualMachineView from '../views/virtualMachine.view'; | ||
import { VM_CREATE_AND_EDIT_TIMEOUT_SECS } from './utils/consts'; | ||
import { VirtualMachine } from './models/virtualMachine'; | ||
import { vmConfig, getProvisionConfigs, CONFIG_NAME_CONTAINER } from './vm.wizard.configs'; | ||
import * as editFlavorView from './models/editFlavorView'; | ||
import { fillInput } from './utils/utils'; | ||
|
||
describe('KubeVirt VM detail - edit flavor', () => { | ||
const leakedResources = new Set<string>(); | ||
const provisionConfigs = getProvisionConfigs(testName); | ||
|
||
const configName = CONFIG_NAME_CONTAINER; | ||
const provisionConfig = provisionConfigs.get(configName); | ||
|
||
// not needed for testing flavor | ||
provisionConfig.networkResources = []; | ||
provisionConfig.storageResources = []; | ||
|
||
it( | ||
'changes tiny to large', | ||
async () => { | ||
const vm1Config = vmConfig(configName.toLowerCase(), provisionConfig, testName); | ||
vm1Config.startOnCreation = false; | ||
|
||
const vm = new VirtualMachine(vmConfig(configName.toLowerCase(), provisionConfig, testName)); | ||
await withResource(leakedResources, vm.asResource(), async () => { | ||
await vm.create(vm1Config); | ||
await vm.navigateToDetail(); | ||
await browser.wait( | ||
until.textToBePresentInElement( | ||
virtualMachineView.vmDetailFlavor(vm.namespace, vm.name), | ||
'Tiny: 1 vCPU, 1 GB Memory', | ||
), | ||
); | ||
await vm.modalEditFlavor(); | ||
await browser.wait( | ||
until.textToBePresentInElement(editFlavorView.flavorDropdownText(), 'Tiny'), | ||
); | ||
await selectDropdownOptionById(editFlavorView.flavorDropdownId, 'large-link'); | ||
await browser.wait( | ||
until.textToBePresentInElement(editFlavorView.flavorDropdownText(), 'Large'), | ||
); | ||
await click(editFlavorView.saveButton()); | ||
|
||
await browser.wait( | ||
until.textToBePresentInElement( | ||
virtualMachineView.vmDetailFlavor(vm.namespace, vm.name), | ||
'Large: 2 vCPUs, 6 GB Memory', | ||
), | ||
); | ||
expect( | ||
await virtualMachineView.vmDetailLabelValue('flavor.template.kubevirt.io/large'), | ||
).toBe('true'); | ||
expect( | ||
(await virtualMachineView.vmDetailLabelValue('vm.kubevirt.io/template')).startsWith( | ||
'rhel7-desktop-tiny-', // template is not changed (might be in the future) | ||
), | ||
).toBeTruthy(); | ||
}); | ||
}, | ||
VM_CREATE_AND_EDIT_TIMEOUT_SECS, | ||
); | ||
|
||
it( | ||
'changes tiny to custom', | ||
async () => { | ||
const vm1Config = vmConfig(configName.toLowerCase(), provisionConfig, testName); | ||
vm1Config.startOnCreation = false; | ||
|
||
const vm = new VirtualMachine(vmConfig(configName.toLowerCase(), provisionConfig, testName)); | ||
await withResource(leakedResources, vm.asResource(), async () => { | ||
await vm.create(vm1Config); | ||
await vm.navigateToDetail(); | ||
await browser.wait( | ||
until.textToBePresentInElement( | ||
virtualMachineView.vmDetailFlavor(vm.namespace, vm.name), | ||
'Tiny: 1 vCPU, 1 GB Memory', | ||
), | ||
); | ||
await vm.modalEditFlavor(); | ||
|
||
await browser.wait( | ||
until.textToBePresentInElement(editFlavorView.flavorDropdownText(), 'Tiny'), | ||
); | ||
await selectDropdownOptionById(editFlavorView.flavorDropdownId, 'Custom-link'); | ||
await browser.wait( | ||
until.textToBePresentInElement(editFlavorView.flavorDropdownText(), 'Custom'), | ||
); | ||
await fillInput(editFlavorView.cpusInput(), '2'); | ||
await fillInput(editFlavorView.memoryInput(), '356'); | ||
await click(editFlavorView.saveButton()); | ||
|
||
await browser.wait( | ||
until.textToBePresentInElement( | ||
virtualMachineView.vmDetailFlavor(vm.namespace, vm.name), | ||
'Custom: 2 vCPUs, 356 MB Memory', | ||
), | ||
); | ||
|
||
expect( | ||
await virtualMachineView.vmDetailLabelValue('flavor.template.kubevirt.io/Custom'), | ||
).toBe('true'); | ||
expect( | ||
(await virtualMachineView.vmDetailLabelValue('vm.kubevirt.io/template')).startsWith( | ||
'rhel7-desktop-tiny-', // template is not changed (might be in the future) | ||
), | ||
).toBeTruthy(); | ||
}); | ||
}, | ||
VM_CREATE_AND_EDIT_TIMEOUT_SECS, | ||
); | ||
}); |
86 changes: 86 additions & 0 deletions
86
frontend/packages/kubevirt-plugin/integration-tests/tests/vm.wizard.configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { OrderedMap } from 'immutable'; | ||
import { | ||
basicVmConfig, | ||
networkInterface, | ||
rootDisk, | ||
hddDisk, | ||
dataVolumeManifest, | ||
} from './utils/mocks'; | ||
import { StorageResource, ProvisionConfig } from './utils/types'; | ||
|
||
export const vmConfig = (name: string, provisionConfig, testName: string) => { | ||
const commonSettings = { | ||
startOnCreation: true, | ||
cloudInit: { | ||
useCloudInit: false, | ||
}, | ||
namespace: testName, | ||
description: `Default description ${testName}`, | ||
flavor: basicVmConfig.flavor, | ||
operatingSystem: basicVmConfig.operatingSystem, | ||
workloadProfile: basicVmConfig.workloadProfile, | ||
}; | ||
|
||
return { | ||
...commonSettings, | ||
name: `${name}-${testName}`, | ||
provisionSource: provisionConfig.provision, | ||
storageResources: provisionConfig.storageResources, | ||
networkResources: provisionConfig.networkResources, | ||
}; | ||
}; | ||
|
||
export const getTestDataVolume = (testName: string) => | ||
dataVolumeManifest({ | ||
name: `toclone-${testName}`, | ||
namespace: testName, | ||
sourceURL: basicVmConfig.sourceURL, | ||
}); | ||
|
||
const getDiskToCloneFrom = (testName: string): StorageResource => { | ||
const testDV = getTestDataVolume(testName); | ||
return { | ||
name: testDV.metadata.name, | ||
size: '1', | ||
storageClass: testDV.spec.pvc.storageClassName, | ||
attached: true, | ||
}; | ||
}; | ||
|
||
export const CONFIG_NAME_URL = 'URL'; | ||
export const CONFIG_NAME_CONTAINER = 'Container'; | ||
export const CONFIG_NAME_PXE = 'PXE'; | ||
export const CONFIG_NAME_CLONED_DISK = 'ClonedDisk'; | ||
|
||
export const getProvisionConfigs = (testName: string) => | ||
OrderedMap<string, ProvisionConfig>() | ||
.set(CONFIG_NAME_URL, { | ||
provision: { | ||
method: CONFIG_NAME_URL, | ||
source: basicVmConfig.sourceURL, | ||
}, | ||
networkResources: [networkInterface], | ||
storageResources: [rootDisk], | ||
}) | ||
.set(CONFIG_NAME_CONTAINER, { | ||
provision: { | ||
method: CONFIG_NAME_CONTAINER, | ||
source: basicVmConfig.sourceContainer, | ||
}, | ||
networkResources: [networkInterface], | ||
storageResources: [hddDisk], | ||
}) | ||
.set(CONFIG_NAME_PXE, { | ||
provision: { | ||
method: CONFIG_NAME_PXE, | ||
}, | ||
networkResources: [networkInterface], | ||
storageResources: [rootDisk], | ||
}) | ||
.set(CONFIG_NAME_CLONED_DISK, { | ||
provision: { | ||
method: 'Cloned Disk', // mind the space | ||
}, | ||
networkResources: [networkInterface], | ||
storageResources: [getDiskToCloneFrom(testName)], | ||
}); |
Oops, something went wrong.