Skip to content

Commit

Permalink
Add unpause VM tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcbailey committed Feb 13, 2020
1 parent 232fb60 commit d221880
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import {
vmDetailFlavorEditButton,
vmDetailCdEditButton,
vmDetailBootOrderEditButton,
vmDetailStatusEditButton,
} from '../../views/virtualMachine.view';
import * as editCD from '../../views/editCDView';
import * as editBootOrder from '../../views/editBootOrderView';
import * as editStatusView from '../../views/editStatusView';
import { NetworkInterfaceDialog } from '../dialogs/networkInterfaceDialog';
import { DiskDialog } from '../dialogs/diskDialog';
import { DetailView } from './detailView';
Expand Down Expand Up @@ -96,4 +98,9 @@ export class KubevirtDetailView extends DetailView {
await click(vmDetailBootOrderEditButton(this.namespace, this.name));
await browser.wait(until.presenceOf(editBootOrder.bootOrderDialog));
}

async modalEditStatus() {
await click(vmDetailStatusEditButton(this.namespace, this.name));
await browser.wait(until.presenceOf(editStatusView.unpauseVMDialog));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ export class VirtualMachine extends KubevirtDetailView {
resolveTimeout(timeout, PAGE_LOAD_TIMEOUT_SECS),
);
break;
case VM_ACTION.Unpause:
await this.waitForStatus(
VM_STATUS.Running,
resolveTimeout(timeout, VM_ACTIONS_TIMEOUT_SECS),
);
break;
default:
throw Error(UNEXPECTED_ACTION_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export enum VM_ACTION {
Restart = 'Restart Virtual Machine',
Start = 'Start Virtual Machine',
Stop = 'Stop Virtual Machine',
Unpause = 'Unpause Virtual Machine',
}

export enum VM_STATUS {
Expand All @@ -94,6 +95,7 @@ export enum VM_STATUS {
Pending = 'Pending',
Importing = 'Importing',
Migrating = 'Migrating',
Paused = 'Paused',
}

export enum DISK_SOURCE {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,7 @@ export function resolveStorageDataAttribute(configMap: any, attribute: string):
}
return _.get(configMap, ['data', attribute]);
}

export function pauseVM(name: string, namespace: string): void {
execSync(`virtctl pause vmi ${name} -n ${namespace}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
waitForCount,
} from '@console/shared/src/test-utils/utils';
import { getVMManifest } from './utils/mocks';
import { fillInput } from './utils/utils';
import { fillInput, pauseVM } from './utils/utils';
import {
VM_BOOTUP_TIMEOUT_SECS,
VM_ACTIONS_TIMEOUT_SECS,
Expand All @@ -28,7 +28,7 @@ import { VirtualMachine } from './models/virtualMachine';

describe('Test VM actions', () => {
const leakedResources = new Set<string>();
const testVM = getVMManifest('URL', testName);
const testVM = getVMManifest('Container', testName);

afterAll(async () => {
removeLeakedResources(leakedResources);
Expand Down Expand Up @@ -71,6 +71,15 @@ describe('Test VM actions', () => {
VM_ACTIONS_TIMEOUT_SECS,
);

it(
'Unpauses VM',
async () => {
pauseVM(vmName, testName);
await vm.listViewAction(VM_ACTION.Unpause);
},
VM_ACTIONS_TIMEOUT_SECS,
);

it('Stops VM', async () => {
await vm.listViewAction(VM_ACTION.Stop);
});
Expand Down Expand Up @@ -112,6 +121,15 @@ describe('Test VM actions', () => {
VM_ACTIONS_TIMEOUT_SECS,
);

it(
'Unpauses VM',
async () => {
pauseVM(vmName, testName);
await vm.action(VM_ACTION.Unpause);
},
VM_ACTIONS_TIMEOUT_SECS,
);

it('Stops VM', async () => {
await vm.action(VM_ACTION.Stop);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isLoaded, resourceTitle } from '@console/internal-integration-tests/vie
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 } from './utils/utils';
import { exposeServices, pauseVM } from './utils/utils';
import { VirtualMachine } from './models/virtualMachine';
import {
TAB,
Expand Down Expand Up @@ -123,4 +123,12 @@ 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);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { $, by } from 'protractor';

export const unpauseVMDialog = $(`[aria-label="Edit pause state"]`);
export const saveButton = unpauseVMDialog.element(by.buttonText('Unpause'));
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const vmDetailBootOrder = (namespace, vmName) =>
$(vmDetailItemId(namespace, vmName, 'boot-order')).$$('li');
export const vmDetailBootOrderEditButton = (namespace, vmName) =>
$(vmDetailItemId(namespace, vmName, 'boot-order-edit'));
export const vmDetailStatusEditButton = (namespace, vmName) =>
$(vmDetailItemId(namespace, vmName, 'status-edit'));
export const vmDetailLabelValue = async (labelKey) => {
const filteredLabel = $$('.co-m-label').filter((elem) =>
elem
Expand Down

0 comments on commit d221880

Please sign in to comment.