-
Notifications
You must be signed in to change notification settings - Fork 670
Add VM Template test cases for Kubevirt plugin #2066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
yaacov:kubevirt-vmtemplate-integration-tests
Oct 7, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
92 changes: 92 additions & 0 deletions
92
frontend/packages/kubevirt-plugin/integration-tests/tests/models/virtualMachineTemplate.ts
This file contains hidden or 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,92 @@ | ||
| /* eslint-disable no-unused-vars, no-undef, no-await-in-loop, no-console */ | ||
| import { browser } from 'protractor'; | ||
| import { testName } from '../../../../../integration-tests/protractor.conf'; | ||
| import { | ||
| errorMessage, | ||
| filterForName, | ||
| resourceRowsPresent, | ||
| } from '../../../../../integration-tests/views/crud.view'; | ||
| import { VMTemplateConfig } from '../utils/types'; | ||
| import { WIZARD_CREATE_TEMPLATE_ERROR, WIZARD_TABLE_FIRST_ROW } from '../utils/consts'; | ||
| import { Wizard } from './wizard'; | ||
| import { KubevirtDetailView } from './kubevirtDetailView'; | ||
|
|
||
| export class VirtualMachineTemplate extends KubevirtDetailView { | ||
| constructor(templateConfig) { | ||
| super({ ...templateConfig, kind: 'vmtemplates' }); | ||
| } | ||
|
|
||
| async create({ | ||
| name, | ||
| namespace, | ||
| description, | ||
| provisionSource, | ||
| operatingSystem, | ||
| flavor, | ||
| workloadProfile, | ||
| cloudInit, | ||
| storageResources, | ||
| networkResources, | ||
| }: VMTemplateConfig) { | ||
| await this.navigateToListView(); | ||
|
|
||
| // Basic Settings for VM template | ||
| const wizard = new Wizard(); | ||
| await wizard.openWizard(); | ||
| await wizard.fillName(name); | ||
| await wizard.fillDescription(description); | ||
| if (!(await browser.getCurrentUrl()).includes(`${testName}/${this.kind}`)) { | ||
| await wizard.selectNamespace(namespace); | ||
| } | ||
| await wizard.selectProvisionSource(provisionSource); | ||
| await wizard.selectOperatingSystem(operatingSystem); | ||
| await wizard.selectFlavor(flavor); | ||
| await wizard.selectWorkloadProfile(workloadProfile); | ||
| if (cloudInit.useCloudInit) { | ||
| await wizard.useCloudInit(cloudInit); | ||
| } | ||
| await wizard.next(); | ||
|
|
||
| // Networking | ||
| for (const resource of networkResources) { | ||
| await wizard.addNIC(resource); | ||
| } | ||
| await wizard.next(); | ||
|
|
||
| // Storage | ||
| for (const resource of storageResources) { | ||
| if (resource.name === 'rootdisk' && provisionSource.method === 'URL') { | ||
| // Rootdisk is present by default, only edit specific properties | ||
| await wizard.editDiskAttribute(WIZARD_TABLE_FIRST_ROW, 'size', resource.size); | ||
| await wizard.editDiskAttribute(WIZARD_TABLE_FIRST_ROW, 'storage', resource.storageClass); | ||
| } else { | ||
| await wizard.addDisk(resource); | ||
| } | ||
| } | ||
|
|
||
| // Create VM template | ||
| await wizard.next(); | ||
| await wizard.waitForCreation(); | ||
|
|
||
| // Check for errors and close wizard | ||
| if (await errorMessage.isPresent()) { | ||
| console.error(await errorMessage.getText()); | ||
| throw new Error(WIZARD_CREATE_TEMPLATE_ERROR); | ||
| } | ||
| await wizard.next(); | ||
|
|
||
| // Verify VM template is created | ||
| await filterForName(name); | ||
| await resourceRowsPresent(); | ||
| } | ||
|
|
||
| asResource() { | ||
| return { | ||
| kind: 'template', | ||
| metadata: { | ||
| namespace: this.namespace, | ||
| name: this.name, | ||
| }, | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
112 changes: 112 additions & 0 deletions
112
frontend/packages/kubevirt-plugin/integration-tests/tests/vm.template.wizard.scenario.ts
This file contains hidden or 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,112 @@ | ||
| /* eslint-disable no-undef, max-nested-callbacks */ | ||
| import { OrderedMap } from 'immutable'; | ||
| import { testName } from '../../../../integration-tests/protractor.conf'; | ||
| import { | ||
| removeLeakedResources, | ||
| createResources, | ||
| deleteResources, | ||
| addLeakableResource, | ||
| } from '../../../console-shared/src/test-utils/utils'; | ||
| import { NetworkResource, StorageResource, ProvisionOption } from './utils/types'; | ||
| import { VM_BOOTUP_TIMEOUT_SECS } from './utils/consts'; | ||
| import { basicVMConfig, rootDisk, networkInterface, multusNAD, hddDisk } from './utils/mocks'; | ||
| import { getTestDataVolume } from './vm.wizard.configs'; | ||
| import { VirtualMachine } from './models/virtualMachine'; | ||
| import { VirtualMachineTemplate } from './models/virtualMachineTemplate'; | ||
|
|
||
| describe('Kubevirt create VM Template using wizard', () => { | ||
| const leakedResources = new Set<string>(); | ||
| const testDataVolume = getTestDataVolume(testName); | ||
| const commonSettings = { | ||
| cloudInit: { | ||
| useCloudInit: false, | ||
| }, | ||
| namespace: testName, | ||
| description: `Default description ${testName}`, | ||
| flavor: basicVMConfig.flavor, | ||
| operatingSystem: basicVMConfig.operatingSystem, | ||
| workloadProfile: basicVMConfig.workloadProfile, | ||
| }; | ||
| const vmTemplateConfig = (name, provisionConfig) => { | ||
| return { | ||
| ...commonSettings, | ||
| name: `${name}-${testName}`, | ||
| provisionSource: provisionConfig.provision, | ||
| storageResources: provisionConfig.storageResources, | ||
| networkResources: provisionConfig.networkResources, | ||
| }; | ||
| }; | ||
| const vmConfig = (name, templateConfig) => { | ||
| return { | ||
| ...commonSettings, | ||
| startOnCreation: true, | ||
| name: `${name}-${testName}`, | ||
| template: templateConfig.name, | ||
| storageResources: [], | ||
| networkResources: [], | ||
| }; | ||
| }; | ||
|
|
||
| const provisionConfigs = OrderedMap< | ||
| string, | ||
| { | ||
| provision: ProvisionOption; | ||
| networkResources: NetworkResource[]; | ||
| storageResources: StorageResource[]; | ||
| } | ||
| >() | ||
| .set('URL', { | ||
| provision: { | ||
| method: 'URL', | ||
| source: basicVMConfig.sourceURL, | ||
| }, | ||
| networkResources: [networkInterface], | ||
| storageResources: [rootDisk], | ||
| }) | ||
| .set('Container', { | ||
| provision: { | ||
| method: 'Container', | ||
| source: basicVMConfig.sourceContainer, | ||
| }, | ||
| networkResources: [networkInterface], | ||
| storageResources: [hddDisk], | ||
| }) | ||
| .set('PXE', { | ||
| provision: { | ||
| method: 'PXE', | ||
| }, | ||
| networkResources: [networkInterface], | ||
| storageResources: [rootDisk], | ||
| }); | ||
|
|
||
| beforeAll(async () => { | ||
| createResources([multusNAD, testDataVolume]); | ||
| }); | ||
|
|
||
| afterAll(async () => { | ||
| deleteResources([multusNAD, testDataVolume]); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| removeLeakedResources(leakedResources); | ||
| }); | ||
|
|
||
| provisionConfigs.forEach((provisionConfig, configName) => { | ||
| it( | ||
| `Create VM Template using ${configName}.`, | ||
| async () => { | ||
| const vmTemplate = new VirtualMachineTemplate( | ||
| vmTemplateConfig(configName.toLowerCase(), provisionConfig), | ||
| ); | ||
| const vm = new VirtualMachine(vmConfig(configName.toLowerCase(), vmTemplate)); | ||
|
|
||
| addLeakableResource(leakedResources, vmTemplate.asResource()); | ||
| addLeakableResource(leakedResources, vm.asResource()); | ||
|
|
||
| await vmTemplate.create(vmTemplateConfig(configName.toLowerCase(), provisionConfig)); | ||
| await vm.create(vmConfig(configName.toLowerCase(), vmTemplate)); | ||
| }, | ||
| VM_BOOTUP_TIMEOUT_SECS * 2, | ||
| ); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add this verification even to the
models/virtualMachine.tsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added to the vm test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed from
virtualMachine.tsbecause (in the meentime) another PR added a similar check (L178) that checks that the VM is acctually created in cases when we do not check that it is running.