Skip to content

Commit

Permalink
Merge pull request #4815 from rhrazdil/apply-4.4-regression-fixes
Browse files Browse the repository at this point in the history
 kubevirt integration-tests fixes from 4.4-release
  • Loading branch information
openshift-merge-robot committed Mar 30, 2020
2 parents 25c7b47 + fe61884 commit bf8a0e1
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 105 deletions.
Expand Up @@ -28,6 +28,7 @@ import { Wizard } from './wizard';
import { appHost, testName } from '@console/internal-integration-tests/protractor.conf';
import { KubevirtDetailView } from './kubevirtDetailView';
import { ImportWizard } from './importWizard';
import { VirtualMachineModel } from '../../../src/models/index';

const noConfirmDialogActions: (VM_ACTION | VMI_ACTION)[] = [VM_ACTION.Start, VM_ACTION.Clone];

Expand Down Expand Up @@ -198,7 +199,7 @@ export class VirtualMachine extends KubevirtDetailView {
}: VMConfig) {
const wizard = new Wizard();
await this.navigateToListView();
await wizard.openWizard();
await wizard.openWizard(VirtualMachineModel.labelPlural);
if (template !== undefined) {
await wizard.selectTemplate(template);
} else {
Expand Down Expand Up @@ -265,7 +266,6 @@ export class VirtualMachine extends KubevirtDetailView {
// Review page
await wizard.confirmAndCreate();
await wizard.waitForCreation();

await this.navigateToTab(TAB.Details);
if (startOnCreation === true) {
// If startOnCreation is true, wait for VM to boot up
Expand Down
Expand Up @@ -28,7 +28,7 @@ export class VirtualMachineTemplate extends KubevirtDetailView {

// Basic Settings for VM template
const wizard = new Wizard();
await wizard.openWizard();
await wizard.openWizard('Virtual Machine Templates');

await wizard.selectProvisionSource(provisionSource);
await wizard.selectOperatingSystem(operatingSystem);
Expand Down
Expand Up @@ -15,12 +15,9 @@ import { DiskDialog } from '../dialogs/diskDialog';
import { Flavor } from '../utils/constants/wizard';

export class Wizard {
async openWizard() {
if (
!(await resourceTitle.isPresent()) ||
(await resourceTitle.getText()) !== 'Virtual Machines'
) {
await clickNavLink(['Workloads', 'Virtual Machines']);
async openWizard(kind: string) {
if (!(await resourceTitle.isPresent()) || (await resourceTitle.getText()) !== kind) {
await clickNavLink(['Workloads', kind]);
await isLoaded();
}
await click(createItemButton);
Expand Down
Expand Up @@ -59,7 +59,7 @@ export const KUBEVIRT_STORAGE_CLASS_DEFAULTS = 'kubevirt-storage-class-defaults'
export const KUBEVIRT_PROJECT_NAME = 'openshift-cnv';

export const COMMON_TEMPLATES_VERSION = rhelTinyCommonTemplateName.match(/v\d+\.\d+\.\d+/)[0];
export const INNER_TEMPLATE_VERSION = 'v0.8.2';
export const INNER_TEMPLATE_VERSION = 'v0.9.1';

export const COMMON_TEMPLATES_NAMESPACE = 'openshift';
export const COMMON_TEMPLATES_REVISION = '1';
Expand Down
Expand Up @@ -66,6 +66,8 @@ export const basicVMConfig: BaseVMConfig = {
sourceContainer: 'kubevirt/cirros-registry-disk-demo',
cloudInitScript: `#cloud-config\nuser: cloud-user\npassword: atomic\nchpasswd: {expire: False}\nhostname: vm-${testName}`,
};
Object.freeze(basicVMConfig.flavorConfig);
Object.freeze(basicVMConfig);

export const defaultWizardPodNetworkingInterface = {
name: 'nic0',
Expand All @@ -84,7 +86,7 @@ export const defaultYAMLPodNetworkingInterface = {
};

// Fake windows machine, still cirros in the heart
export const widowsVMConfig: BaseVMConfig = {
export const windowsVMConfig: BaseVMConfig = {
operatingSystem: OperatingSystem.WINDOWS_10,
flavorConfig: { flavor: Flavor.MEDIUM },
workloadProfile: WorkloadProfile.DESKTOP,
Expand Down
Expand Up @@ -59,7 +59,7 @@ spec:
type: ''
resources:
requests:
memory: 1G
memory: 1Gi
evictionStrategy: LiveMigrate
hostname: fake-windows
networks:
Expand Down
Expand Up @@ -13,6 +13,7 @@ import {
removeLeakableResource,
waitForCount,
fillInput,
click,
} from '@console/shared/src/test-utils/utils';
import { getVMManifest } from './utils/mocks';
import { pauseVM } from './utils/utils';
Expand All @@ -26,6 +27,7 @@ import {
VM_STATUS,
} from './utils/consts';
import { VirtualMachine } from './models/virtualMachine';
import { unpauseButton } from '../views/editStatusView';

describe('Test VM actions', () => {
const leakedResources = new Set<string>();
Expand Down Expand Up @@ -131,6 +133,15 @@ describe('Test VM actions', () => {
VM_ACTIONS_TIMEOUT_SECS,
);

it('Unpauses VM via modal dialog', async () => {
await vm.waitForStatus(VM_STATUS.Running);
pauseVM(vmName, testName);
await vm.waitForStatus(VM_STATUS.Paused);
await vm.modalEditStatus();
await click(unpauseButton);
await vm.waitForStatus(VM_STATUS.Running);
});

it('Stops VM', async () => {
await vm.action(VM_ACTION.Stop);
});
Expand Down
Expand Up @@ -10,6 +10,7 @@ import {
selectDropdownOption,
selectDropdownOptionById,
createResource,
removeLeakedResources,
} from '@console/shared/src/test-utils/utils';
import {
consoleTypeSelector,
Expand All @@ -32,7 +33,7 @@ import {
import { VirtualMachine } from './models/virtualMachine';
import { vmConfig, getProvisionConfigs } from './vm.wizard.configs';
import { ProvisionConfigName } from './utils/constants/wizard';
import { widowsVMConfig, multusNAD } from './utils/mocks';
import { windowsVMConfig, multusNAD } from './utils/mocks';
import { getWindowsVM } from './utils/templates/windowsVMForRDPL2';

const VM_IP = '123.123.123.123';
Expand All @@ -58,14 +59,18 @@ describe('KubeVirt VM console - RDP', () => {
provisionConfig.networkResources = [];
provisionConfig.storageResources = [];

afterEach(() => {
removeLeakedResources(leakedResources);
});

it(
'connects via exposed service',
async () => {
const windowsConfig = vmConfig(
configName.toLowerCase(),
testName,
provisionConfig,
widowsVMConfig,
windowsVMConfig,
true, // startOnCreation
);
const vm = new VirtualMachine(windowsConfig);
Expand Down
Expand Up @@ -13,6 +13,7 @@ import {
} from '../views/dashboard.view';
import { getVMManifest, hddDisk, multusNetworkInterface, multusNAD } from './utils/mocks';
import { VirtualMachine } from './models/virtualMachine';
import { waitForStringInElement } from '../../../console-shared/src/test-utils/utils';
import {
VM_STATUS,
VM_BOOTUP_TIMEOUT_SECS,
Expand Down Expand Up @@ -83,7 +84,7 @@ describe('Test VM dashboard', () => {
expect(vmStatus.getText()).toEqual(VM_STATUS.Running);
});

it('BZ(1807865) Details card', async () => {
it('Details card', async () => {
expect(vmDetailsName.getText()).toEqual(vm.name);
expect(vmDetailsNamespace.getText()).toEqual(vm.namespace);
expect(vmDetailsNode.getText()).not.toEqual(NOT_AVAILABLE);
Expand All @@ -92,7 +93,7 @@ describe('Test VM dashboard', () => {
await vm.action(VM_ACTION.Stop, true, VM_STOP_TIMEOUT_SECS);
await vm.navigateToTab(TAB.Overview);

expect(vmDetailsNode.getText()).toEqual(NOT_AVAILABLE);
expect(vmDetailsIPAddress.getText()).toEqual(NOT_AVAILABLE);
await browser.wait(waitForStringInElement(vmDetailsNode, NOT_AVAILABLE));
await browser.wait(waitForStringInElement(vmDetailsIPAddress, NOT_AVAILABLE));
});
});
@@ -1,6 +1,11 @@
import { browser, ExpectedConditions as until } from 'protractor';
import { testName } from '@console/internal-integration-tests/protractor.conf';
import { withResource, fillInput, click } from '@console/shared/src/test-utils/utils';
import {
withResource,
click,
fillInput,
removeLeakedResources,
} 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';
Expand All @@ -20,45 +25,9 @@ describe('KubeVirt VM detail - edit flavor', () => {
provisionConfig.networkResources = [];
provisionConfig.storageResources = [];

it(
'changes tiny to large',
async () => {
const vm1Config = vmConfig(configName.toLowerCase(), testName, provisionConfig);
vm1Config.startOnCreation = false;

const vm = new VirtualMachine(vmConfig(configName.toLowerCase(), testName, provisionConfig));
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 GiB Memory',
),
);
await vm.modalEditFlavor();
expect(await getSelectedOptionText(editFlavorView.flavorDropdown)).toEqual('Tiny');
await selectOptionByText(editFlavorView.flavorDropdown, 'Large');
await click(editFlavorView.saveButton());

await browser.wait(
until.textToBePresentInElement(
virtualMachineView.vmDetailFlavor(vm.namespace, vm.name),
'Large: 2 vCPUs, 8 GiB 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,
);
afterEach(() => {
removeLeakedResources(leakedResources);
});

it(
'changes tiny to custom',
Expand Down
Expand Up @@ -4,16 +4,9 @@ import { resourceTitle } from '@console/internal-integration-tests/views/crud.vi
import { asyncForEach, createResource, deleteResource } from '@console/shared/src/test-utils/utils';
import * as vmView from '../views/virtualMachine.view';
import { getVMManifest, basicVMConfig } from './utils/mocks';
import { exposeServices, pauseVM } from './utils/utils';
import { exposeServices } from './utils/utils';
import { VirtualMachine } from './models/virtualMachine';
import {
TAB,
VM_BOOTUP_TIMEOUT_SECS,
VM_ACTION,
VM_STATUS,
COMMON_TEMPLATES_VERSION,
NOT_AVAILABLE,
} from './utils/consts';
import { TAB, VM_BOOTUP_TIMEOUT_SECS, VM_ACTION, VM_STATUS, NOT_AVAILABLE } from './utils/consts';
import { NodePortService } from './utils/types';

describe('Test VM overview', () => {
Expand Down Expand Up @@ -62,9 +55,9 @@ describe('Test VM overview', () => {
description: testName,
os: basicVMConfig.operatingSystem,
profile: basicVMConfig.workloadProfile,
template: `rhel7-desktop-tiny-${COMMON_TEMPLATES_VERSION}`,
template: NOT_AVAILABLE,
bootOrder: ['rootdisk (Disk)', 'nic0 (NIC)', 'cloudinitdisk (Disk)'],
flavor: 'Tiny: 1 vCPU, 1 GiB Memory',
flavorConfig: 'Tiny: 1 vCPU, 1 GiB Memory',
ip: NOT_AVAILABLE,
pod: NOT_AVAILABLE,
node: NOT_AVAILABLE,
Expand Down Expand Up @@ -122,12 +115,4 @@ describe('Test VM overview', () => {
);
});
});

it('Check unpause VM when VM is running', async () => {
await vm.action(VM_ACTION.Start);
pauseVM(vmName, testName);
expect(await vm.getStatus()).toEqual(VM_STATUS.Paused);
await vm.modalEditStatus();
expect(await vm.getStatus()).toEqual(VM_STATUS.Running);
});
});
Expand Up @@ -43,6 +43,7 @@ import {
import { VirtualMachine } from './models/virtualMachine';
import { Wizard } from './models/wizard';
import { NetworkInterfaceDialog } from './dialogs/networkInterfaceDialog';
import { VirtualMachineModel } from '../../src/models/index';

describe('Add/remove disks and NICs on respective VM pages', () => {
const testVm = getVMManifest('Container', testName, `vm-disk-nic-${testName}`);
Expand Down Expand Up @@ -143,7 +144,7 @@ describe('Test network type presets and options', () => {
it('Test NIC type in VM Wizard', async () => {
await browser.get(`${appHost}/k8s/ns/${testName}/virtualmachines`);
await isLoaded();
await wizard.openWizard();
await wizard.openWizard(VirtualMachineModel.labelPlural);

await wizard.fillName(getRandStr(5));
await wizard.fillDescription(testName);
Expand Down
Expand Up @@ -6,7 +6,7 @@ import { VirtualMachine } from './models/virtualMachine';
import { VM_BOOTUP_TIMEOUT_SECS } from './utils/consts';
import { getProvisionConfigs, vmConfig } from './vm.wizard.configs';
import { ProvisionConfigName } from './utils/constants/wizard';
import { widowsVMConfig } from './utils/mocks';
import { windowsVMConfig } from './utils/mocks';
import { getResourceObject } from './utils/utils';
import { windowsGuestToolsCDElement } from '../views/editCDView';

Expand All @@ -27,7 +27,7 @@ describe('Kubevirt Windows Guest tools', () => {
configName.toLowerCase(),
testName,
provisionConfig,
widowsVMConfig,
windowsVMConfig,
false, // dont startOnCreation
);
const vm = new VirtualMachine(windowsConfig);
Expand Down
Expand Up @@ -16,7 +16,6 @@ import {
CLONED_VM_BOOTUP_TIMEOUT_SECS,
VM_STATUS,
COMMON_TEMPLATES_VERSION,
COMMON_TEMPLATES_NAMESPACE,
COMMON_TEMPLATES_REVISION,
INNER_TEMPLATE_VERSION,
} from './utils/consts';
Expand Down Expand Up @@ -88,6 +87,7 @@ describe('Kubevirt create VM using wizard', () => {
'windows10',
testName,
provisionConfigs.get(ProvisionConfigName.CONTAINER),
_.cloneDeep(basicVMConfig),
);
testVMConfig.networkResources = [];
testVMConfig.operatingSystem = OperatingSystem.WINDOWS_10;
Expand Down Expand Up @@ -115,8 +115,7 @@ describe('Kubevirt create VM using wizard', () => {
[`workload.template.kubevirt.io/${testVMConfig.workloadProfile}`]: 'true',
[`flavor.template.kubevirt.io/${testVMConfig.flavorConfig.flavor}`]: 'true',
[`os.template.kubevirt.io/${osID}`]: 'true',
'vm.kubevirt.io/template': `win2k12r2-${testVMConfig.workloadProfile}-${testVMConfig.flavorConfig.flavor}-${COMMON_TEMPLATES_VERSION}`,
'vm.kubevirt.io/template.namespace': COMMON_TEMPLATES_NAMESPACE,
'vm.kubevirt.io/template': `windows-${testVMConfig.workloadProfile}-${testVMConfig.flavorConfig.flavor}-${COMMON_TEMPLATES_VERSION}`,
'vm.kubevirt.io/template.revision': COMMON_TEMPLATES_REVISION,
'vm.kubevirt.io/template.version': INNER_TEMPLATE_VERSION,
};
Expand Down

0 comments on commit bf8a0e1

Please sign in to comment.