Skip to content

Commit

Permalink
Merge pull request #8014 from gouyang/improve_cdi_filter_details
Browse files Browse the repository at this point in the history
Bug 1923911: improve test for vm filter and details page
  • Loading branch information
openshift-merge-robot committed Feb 4, 2021
2 parents 459c839 + 53ec371 commit 7779e97
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
FEDORA_IMAGE,
RHEL7_IMAGE,
WIN10_IMAGE,
VM_IMPORT_TIMEOUT_SECS,
} from './utils/constants/common';
import {
GOLDEN_OS_IMAGES_NS,
Expand All @@ -30,6 +31,7 @@ import {
RHEL7_PVC,
WIN10_PVC,
} from './utils/constants/pvc';
import { VM_STATUS } from './utils/constants/vm';
import { TemplateByName } from './utils/constants/wizard';
import { PVCData } from './types/pvc';
import { UploadForm } from './models/pvcUploadForm';
Expand Down Expand Up @@ -170,6 +172,7 @@ describe('KubeVirt Auto Clone', () => {
const fedora = new VMBuilder(getBasicVMBuilder())
.setSelectTemplateName(TemplateByName.FEDORA)
.generateNameForPrefix('auto-clone-vm-with-pvc-deleted')
.setStartOnCreation(false)
.build();

await withResources(
Expand All @@ -178,7 +181,7 @@ describe('KubeVirt Auto Clone', () => {
async () => {
await fedoraPVC.create();
await fedora.create();
await fedora.stop();
await fedora.waitForStatus(VM_STATUS.Off, VM_IMPORT_TIMEOUT_SECS);
await fedoraPVC.delete();
await fedora.start();
await fedora.navigateToDetail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const VM_MIGRATION_TIMEOUT_SECS = 260 * SEC;
export const VM_STOP_TIMEOUT_SECS = 220 * SEC;
export const VM_DELETE_TIMEOUT_SECS = 220 * SEC;
export const VM_IP_ASSIGNMENT_TIMEOUT_SECS = 180 * SEC;
export const VM_IMPORT_TIMEOUT_SECS = 160 * SEC;
export const VM_IMPORT_TIMEOUT_SECS = 300 * SEC;
export const WINDOWS_IMPORT_TIMEOUT_SECS = 150 * SEC;
export const VM_CREATE_AND_EDIT_TIMEOUT_SECS = 200 * SEC;
export const VM_CREATE_AND_EDIT_AND_CLOUDINIT_TIMEOUT_SECS = 15 * 60 * SEC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ export const WIN10_PVC: PVCData = {
};

export enum PVC_ACTION {
Delete = 'Delete Persistent Volume Claim',
Delete = 'Delete PersistentVolumeClaim',
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,11 @@ export function uploadOSImage(
`virtctl image-upload dv ${dv} --image-path=${imagePath} --size=1Gi --storage-class=${STORAGE_CLASS} --access-mode=${accessMode} --block-volume=${volumeMode} -n ${ns} --insecure`,
);
}

export function getCommonTemplateName(os: string): string {
return execSync(
`kubectl get template -n openshift -l template.kubevirt.io/default-os-variant | grep ${os} | awk -F ' ' '{print $1}'`,
)
.toString()
.trim();
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import * as _ from 'lodash';
import { testName } from '@console/internal-integration-tests/protractor.conf';
import { resourceTitle } from '@console/internal-integration-tests/views/crud.view';
import { asyncForEach, createResource, deleteResource } from '@console/shared/src/test-utils/utils';
import { asyncForEach, deleteResource } from '@console/shared/src/test-utils/utils';
import * as vmView from '../views/virtualMachine.view';
import { getVMManifest } from './mocks/mocks';
import { exposeServices } from './utils/utils';
import { VirtualMachine } from './models/virtualMachine';
import { VM_BOOTUP_TIMEOUT_SECS, NOT_AVAILABLE } from './utils/constants/common';
import { exposeServices, getCommonTemplateName } from './utils/utils';
import {
VM_BOOTUP_TIMEOUT_SECS,
VM_ACTIONS_TIMEOUT_SECS,
NOT_AVAILABLE,
} from './utils/constants/common';
import { VM_STATUS } from './utils/constants/vm';
import { NodePortService } from './types/types';
import { OperatingSystem, Workload } from './utils/constants/wizard';
import { ProvisionSource } from './utils/constants/enums/provisionSource';
import { VMBuilder } from './models/vmBuilder';
import { getBasicVMBuilder } from './mocks/vmBuilderPresets';

describe('Kubevirt VM details tab', () => {
const vmName = `vm-${testName}`;
const cloudInit = `#cloud-config\nuser: cloud-user\npassword: atomic\nchpasswd: {expire: False}`;
const vm = new VMBuilder(getBasicVMBuilder())
.setProvisionSource(ProvisionSource.CONTAINER)
.setName(vmName)
.setDescription(testName)
.setStartOnCreation(false)
.build();
const serviceCommon = { name: vmName, kind: 'vm', type: 'NodePort', namespace: testName };
const testVM = getVMManifest(ProvisionSource.CONTAINER, testName, vmName, cloudInit);
const vm = new VirtualMachine(testVM.metadata);
const nodePortServices = new Set<NodePortService>();
nodePortServices.add({
...serviceCommon,
Expand All @@ -38,29 +45,31 @@ describe('Kubevirt VM details tab', () => {
targetPort: '20080',
});

beforeAll(() => {
createResource(testVM);
beforeAll(async () => {
await vm.create();
await vm.waitForStatus(VM_STATUS.Off, VM_ACTIONS_TIMEOUT_SECS);
exposeServices(nodePortServices);
});

afterAll(() => {
deleteResource(testVM);
afterAll(async () => {
deleteResource(vm.asResource());
});

beforeEach(async () => {
await vm.navigateToDetail();
});

it('ID(CNV-763) Check VM details when VM is off', async () => {
const templateName = getCommonTemplateName('rhel7');
const expectation = {
name: vmName,
status: VM_STATUS.Off,
description: testName,
description: NOT_AVAILABLE,
os: OperatingSystem.RHEL7,
profile: Workload.DESKTOP.toLowerCase(),
template: NOT_AVAILABLE,
bootOrder: ['rootdisk (Disk)', 'nic-0 (NIC)', 'cloudinitdisk (Disk)'],
flavorConfig: 'Tiny: 1 CPU | 1 GiB Memory',
profile: Workload.SERVER.toLowerCase(),
template: templateName,
bootOrder: [`${vmName} (Disk)`],
flavorConfig: 'Small: 1 CPU | 2 GiB Memory',
ip: NOT_AVAILABLE,
pod: NOT_AVAILABLE,
node: NOT_AVAILABLE,
Expand All @@ -72,7 +81,7 @@ describe('Kubevirt VM details tab', () => {
description: await vmView.vmDetailDesc(testName, vmName).getText(),
os: await vmView.vmDetailOS(testName, vmName).getText(),
profile: await vmView.vmDetailWorkloadProfile(testName, vmName).getText(),
template: await vmView.vmDetailTemplate(testName, vmName).getText(),
template: await vmView.vmDetailTemplateByTestID(templateName).getText(),
bootOrder: await vmView.vmDetailBootOrder(testName, vmName).getText(),
flavorConfig: await vmView.vmDetailFlavor(testName, vmName).getText(),
ip: await vmView.vmDetailIP(testName, vmName).getText(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { testName } from '@console/internal-integration-tests/protractor.conf';
import { createResource, deleteResource } from '@console/shared/src/test-utils/utils';
import { getVMManifest } from './mocks/mocks';
import { PAGE_LOAD_TIMEOUT_SECS } from './utils/constants/common';
import { VM_ACTION, VM_STATUS } from './utils/constants/vm';
import { VM_IMPORT_TIMEOUT_SECS } from './utils/constants/common';
import { VM_STATUS } from './utils/constants/vm';
import { VirtualMachine } from './models/virtualMachine';
import { filterCount } from '../views/vms.list.view';
import { browser } from 'protractor';
import { waitForFilterCount } from './utils/utils';
import { ProvisionSource } from './utils/constants/enums/provisionSource';

describe('Test List View Filtering', () => {
Expand All @@ -21,17 +19,14 @@ describe('Test List View Filtering', () => {
deleteResource(testVM);
});

it('ID(CNV-3614) Displays correct count of Pending VMs', async () => {
it('ID(CNV-3614) Displays correct count of importing VMs', async () => {
await vm.navigateToListView();
await vm.action(VM_ACTION.Start, false);
await browser.wait(waitForFilterCount(VM_STATUS.Pending, 1), PAGE_LOAD_TIMEOUT_SECS);
const importingCount = await filterCount(VM_STATUS.Pending);
const importingCount = await filterCount(VM_STATUS.Importing);
expect(importingCount).toEqual(1);
await vm.waitForStatus(VM_STATUS.Running);
});

it('ID(CNV-3615) Displays correct count of Off VMs', async () => {
await vm.stop();
await vm.waitForStatus(VM_STATUS.Off, VM_IMPORT_TIMEOUT_SECS);
await vm.navigateToListView();
const offCount = await filterCount(VM_STATUS.Off);
expect(offCount).toEqual(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const vmDetailWorkloadProfile = (namespace, vmName) =>
$(vmDetailItemId(namespace, vmName, 'workload-profile'));
export const vmDetailTemplate = (namespace, vmName) =>
$(`${vmDetailItemId(namespace, vmName, 'template')}`);
export const vmDetailTemplateByTestID = (templateName) => $(`[data-test-id="${templateName}"]`);
export const vmDetailNamespace = (namespace, vmName) =>
$(vmDetailItemId(namespace, vmName, 'namespace'));
export const vmDetailPod = (namespace, vmName) => $(vmDetailItemId(namespace, vmName, 'pod'));
Expand Down

0 comments on commit 7779e97

Please sign in to comment.