Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import {
vmDetailCdEditButton,
vmDetailBootOrderEditButton,
vmDetailDedicatedResourcesEditButton,
vmDetailStatusEditButton,
} from '../../views/virtualMachine.view';
import * as editCD from '../../views/editCDView';
import * as editBootOrder from '../../views/editBootOrderView';
import * as editDedicatedResourcesView from '../../views/editDedicatedResourcesView';
import * as editStatusView from '../../views/editStatusView';
import { NetworkInterfaceDialog } from '../dialogs/networkInterfaceDialog';
import { DiskDialog } from '../dialogs/diskDialog';
import { DetailView } from './detailView';
Expand Down Expand Up @@ -103,4 +105,9 @@ export class KubevirtDetailView extends DetailView {
await click(vmDetailDedicatedResourcesEditButton(this.namespace, this.name));
await browser.wait(until.presenceOf(editDedicatedResourcesView.guaranteedPolicyCheckbox));
}

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 @@ -147,6 +147,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 @@ -89,6 +89,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 @@ -99,6 +100,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 @@ -164,3 +164,7 @@ export const waitFor = async (element, text, count = 1) => {
await browser.sleep(5 * SEC);
}
};

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 Down Expand Up @@ -71,6 +71,15 @@ describe('Test VM actions', () => {
VM_ACTIONS_TIMEOUT_SECS,
);

it(
'Unpauses VM',
async () => {
pauseVM(vmName, testName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the pause action immediate? Shouldn't we wait for Paused status?

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 { 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 } from './utils/utils';
import { exposeServices, pauseVM } from './utils/utils';
import { VirtualMachine } from './models/virtualMachine';
import {
TAB,
Expand Down Expand Up @@ -122,4 +122,12 @@ describe('Test VM overview', () => {
);
});
});

it('Check unpause VM when VM is running', async () => {
await vm.action(VM_ACTION.Start);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this deserves a docstring. I don't understand why opening a modal window unpauses the VM

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'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to call it unpauseButton?

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const vmDetailDedicatedResources = (namespace, vmName) =>
$(vmDetailItemId(namespace, vmName, 'dedicated-resources'));
export const vmDetailDedicatedResourcesEditButton = (namespace, vmName) =>
$(vmDetailItemId(namespace, vmName, 'dedicated-resources-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