Skip to content
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

Bug 1875702: Add test to check network supported models #6525

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,8 @@ export class Wizard {
);
}

async processWizard(data: VMBuilderData) {
const {
name,
description,
template,
provisionSource,
os,
flavor,
workload,
startOnCreation,
cloudInit,
disks,
networks,
} = data;
async processGeneralStep(data: VMBuilderData) {
const { name, description, template, provisionSource, os, flavor, workload } = data;
if (name) {
await this.fillName(name);
} else {
Expand Down Expand Up @@ -248,8 +236,10 @@ export class Wizard {
throw Error('VM Flavor not defined');
}
await this.next();
}

// Networking
async processNetworkStep(data: VMBuilderData) {
const { networks, provisionSource, template } = data;
for (const resource of networks) {
await this.addNIC(resource);
}
Expand All @@ -258,8 +248,10 @@ export class Wizard {
await this.selectBootableNIC(networks[networks.length - 1].name);
}
await this.next();
}

// Storage
async processStorageStep(data: VMBuilderData) {
const { disks, provisionSource } = data;
for (const disk of disks) {
if (await view.tableRow(disk.name).isPresent()) {
await this.editDisk(disk.name, disk);
Expand All @@ -271,8 +263,10 @@ export class Wizard {
}
}
await this.next();
}

// Advanced - Cloud Init
async processAdvanceStep(data: VMBuilderData) {
const { cloudInit, template } = data;
if (cloudInit) {
if (template !== undefined) {
// TODO: wizard.useCloudInit needs to check state of checkboxes before clicking them to ensure desired state is achieved with specified template
Expand All @@ -281,12 +275,22 @@ export class Wizard {
await this.configureCloudInit(cloudInit);
}
await this.next();
}

// Review page
async processReviewStep(data: VMBuilderData) {
const { startOnCreation } = data;
if (startOnCreation) {
await this.startOnCreation();
}
await this.validateReviewTab(data);
}

async processWizard(data: VMBuilderData) {
await this.processGeneralStep(data);
await this.processNetworkStep(data);
await this.processStorageStep(data);
await this.processAdvanceStep(data);
await this.processReviewStep(data);

// Create
await this.confirmAndCreate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ export enum VM_STATUS {
// Network
export enum NIC_MODEL {
VirtIO = 'VirtIO',
e1000 = 'e1000',
e1000e = 'e1000e',
net2kPCI = 'net2kPCI',
pcnet = 'pcnet',
rtl8139 = 'rtl8139',
}

export enum NIC_TYPE {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@console/shared/src/test-utils/utils';
import { VirtualMachineModel } from '@console/kubevirt-plugin/src/models';
import { createNICButton } from '../views/kubevirtUIResource.view';
import { nicType } from '../views/dialogs/networkInterface.view';
import { nicModel, nicType } from '../views/dialogs/networkInterface.view';
import { getInterfaces } from '../../src/selectors/vm/selectors';
import { getVMIDisks } from '../../src/selectors/vmi/basic';
import * as wizardView from '../views/wizard.view';
Expand All @@ -24,14 +24,14 @@ import {
defaultWizardPodNetworkingInterface,
defaultYAMLPodNetworkingInterface,
provisionSources,
flavorConfigs,
} from './mocks/mocks';
import { getBasicVMBuilder } from './mocks/vmBuilderPresets';
import {
getSelectOptions,
getRandomMacAddress,
getRandStr,
createExampleVMViaYAML,
getResourceObject,
selectOptionByText,
} from './utils/utils';
import {
VM_BOOTUP_TIMEOUT_SECS,
Expand All @@ -42,7 +42,7 @@ import { VM_ACTION, NIC_MODEL, NIC_TYPE, networkTabCol } from './utils/constants
import { VirtualMachine } from './models/virtualMachine';
import { Wizard } from './models/wizard';
import { NetworkInterfaceDialog } from './dialogs/networkInterfaceDialog';
import { OperatingSystem, Workload } from './utils/constants/wizard';
import { VMBuilder } from './models/vmBuilder';

describe('Add/remove disks and NICs on respective VM pages', () => {
const testVm = getVMManifest('Container', testName, `vm-disk-nic-${testName}`);
Expand Down Expand Up @@ -123,6 +123,10 @@ describe('Test network type presets and options', () => {
const wizard = new Wizard();
const leakedResources = new Set<string>();

const vm = new VMBuilder(getBasicVMBuilder())
.setProvisionSource(provisionSources.Container)
.build();

beforeAll(async () => {
createResource(multusNAD);
});
Expand All @@ -136,13 +140,7 @@ describe('Test network type presets and options', () => {
await isLoaded();
await wizard.openWizard(VirtualMachineModel);

await wizard.fillName(getRandStr(5));
await wizard.fillDescription(testName);
await wizard.selectProvisionSource(provisionSources.Container);
await wizard.selectOperatingSystem(OperatingSystem.RHEL7);
await wizard.selectFlavor(flavorConfigs.Tiny);
await wizard.selectWorkloadProfile(Workload.DESKTOP);
await wizard.next();
await wizard.processGeneralStep(vm.getData());

// Default type for Pod Networking NIC is masquerade
expect(
Expand All @@ -163,13 +161,13 @@ describe('Test network type presets and options', () => {

it('ID(CNV-4038) Test NIC default type in example VM', async () => {
await createExampleVMViaYAML();
const vm = new VirtualMachine({ name: DEFAULT_YAML_VM_NAME, namespace: testName });
const exampleVM = new VirtualMachine({ name: DEFAULT_YAML_VM_NAME, namespace: testName });
const NICDialog = new NetworkInterfaceDialog();
await withResource(leakedResources, vm.asResource(), async () => {
await vm.navigateToNICs();
await withResource(leakedResources, exampleVM.asResource(), async () => {
await exampleVM.navigateToNICs();

expect(
_.findIndex(await vm.getAttachedNICs(), (x) => {
_.findIndex(await exampleVM.getAttachedNICs(), (x) => {
return _.isMatch(
x,
_.pick(defaultYAMLPodNetworkingInterface, ['name', 'model', 'network']),
Expand All @@ -180,7 +178,36 @@ describe('Test network type presets and options', () => {
await click(createNICButton);
await NICDialog.selectNetwork(multusNAD.metadata.name);
expect((await getSelectOptions(nicType)).sort()).toEqual(nonPodNetworkBindingMethods);
await vm.navigateToListView();
await exampleVM.navigateToListView();
});
});

it('ID(CNV-4781) Test NIC supported models in VM Wizard', async () => {
await browser.get(`${appHost}/k8s/ns/${testName}/virtualization`);
await isLoaded();
await wizard.openWizard(VirtualMachineModel);

await wizard.processGeneralStep(vm.getData());

await click(wizardView.addNICButton);
expect(await getSelectOptions(nicModel)).toEqual([NIC_MODEL.VirtIO, NIC_MODEL.e1000e]);

await click(wizardView.modalCancelButton);
await wizard.closeWizard();
});

it('ID(CNV-4780) NIC model is disabled when sriov is selected in VM Wizard', async () => {
await browser.get(`${appHost}/k8s/ns/${testName}/virtualization`);
await isLoaded();
await wizard.openWizard(VirtualMachineModel);

await wizard.processGeneralStep(vm.getData());

await click(wizardView.addNICButton);
await selectOptionByText(nicType, 'sriov');
expect(nicModel.isEnabled()).toBe(false);

await click(wizardView.modalCancelButton);
await wizard.closeWizard();
});
});