This repository was archived by the owner on Mar 1, 2024. It is now read-only.
forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 10
Added tests for vm list/detail vm view actions (start, stop, restart, delete) #163
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* eslint-disable no-undef */ | ||
| import { testName } from '../../protractor.conf'; | ||
|
|
||
| const testLabel = 'automatedTestName'; | ||
|
|
||
| export const testVM = { | ||
| apiVersion: 'kubevirt.io/v1alpha2', | ||
| kind: 'VirtualMachine', | ||
| metadata: { | ||
| name: `vm-${testName}`, | ||
| namespace: testName, | ||
| labels: {[testLabel]: testName}, | ||
| }, | ||
| spec: { | ||
| running: false, | ||
| template: { | ||
| spec: { | ||
| domain: { | ||
| cpu: { | ||
| cores: 1, | ||
| }, | ||
| devices: { | ||
| disks: [ | ||
| { | ||
| bootOrder: 1, | ||
| disk: { | ||
| bus: 'virtio', | ||
| }, | ||
| name: 'rootdisk', | ||
| volumeName: 'rootdisk', | ||
| }, | ||
| ], | ||
| interfaces: [ | ||
| { | ||
| bridge: {}, | ||
| name: 'eth0', | ||
| }, | ||
| ], | ||
| }, | ||
| resources: { | ||
| requests: { | ||
| memory: '1G', | ||
| }, | ||
| }, | ||
| }, | ||
| networks: [ | ||
| { | ||
| name: 'eth0', | ||
| pod: {}, | ||
| }, | ||
| ], | ||
| volumes: [ | ||
| { | ||
| containerDisk: { | ||
| image: 'kubevirt/cirros-registry-disk-demo:latest', | ||
| }, | ||
| name: 'rootdisk', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export const testNAD = { | ||
| apiVersion: 'k8s.cni.cncf.io/v1', | ||
| kind: 'NetworkAttachmentDefinition', | ||
| metadata: { | ||
| name: `ovs-net-1${testName}-${testName}`, | ||
| namespace: testName, | ||
| labels: {[testLabel]: testName}, | ||
| }, | ||
| spec: { | ||
| config: '{ "cniVersion": "0.3.1", "type": "ovs", "bridge": "br0" }', | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* eslint-disable no-undef */ | ||
| import { execSync } from 'child_process'; | ||
|
|
||
| export function removeLeakedResources(leakedResources: Set<string>){ | ||
| const leakedArray: Array<string> = [...leakedResources]; | ||
| if (leakedArray.length > 0) { | ||
| console.error(`Leaked ${leakedArray.join()}`); | ||
| leakedArray.map(r => JSON.parse(r) as {name: string, namespace: string, kind: string}) | ||
| .forEach(({name, namespace, kind}) => { | ||
| try { | ||
| execSync(`kubectl delete -n ${namespace} --cascade ${kind} ${name}`); | ||
| } catch (error) { | ||
| console.error(`Failed to delete ${kind} ${name}:\n${error}`); | ||
| } | ||
| }); | ||
| } | ||
| } |
96 changes: 96 additions & 0 deletions
96
frontend/integration-tests/tests/kubevirt/vm.actions.scenario.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* eslint-disable no-undef */ | ||
|
|
||
| import { execSync } from 'child_process'; | ||
| import { browser, ExpectedConditions as until } from 'protractor'; | ||
|
|
||
| import { appHost, testName } from '../../protractor.conf'; | ||
| import { resourceRowsPresent, filterForName, isLoaded } from '../../views/crud.view'; | ||
| import { testVM } from './mocks'; | ||
| import { removeLeakedResources } from './utils'; | ||
| import {detailViewAction, detailViewVMmStatus, listViewAction, listViewVMmStatus} from '../../views/kubevirt/vm.actions.view'; | ||
|
|
||
| const VM_BOOTUP_TIMEOUT = 60000; | ||
| const VM_ACTIONS_TIMEOUT = 90000; | ||
|
|
||
| describe('Test VM actions', () => { | ||
| const leakedResources = new Set<string>(); | ||
| afterAll(async() => { | ||
| removeLeakedResources(leakedResources); | ||
| }); | ||
|
|
||
| describe('Test VM list view kebab actions', () => { | ||
| const vmName = `vm-list-view-actions-${testName}`; | ||
| beforeAll(async() => { | ||
| testVM.metadata.name = vmName; | ||
| execSync(`echo '${JSON.stringify(testVM)}' | kubectl create -f -`); | ||
| leakedResources.add(JSON.stringify({name: vmName, namespace: testName, kind: 'vm'})); | ||
| }); | ||
|
|
||
| // Workaround for https://github.com/kubevirt/web-ui/issues/177, remove when resolved | ||
| afterEach(async() => await browser.sleep(1000)); | ||
|
|
||
| it('Navigates to VMs', async() => { | ||
| await browser.get(`${appHost}/k8s/all-namespaces/virtualmachines`); | ||
| await isLoaded(); | ||
| await filterForName(vmName); | ||
| await resourceRowsPresent(); | ||
| }); | ||
|
|
||
| it('Starts VM', async() => { | ||
| await listViewAction(vmName)('Start'); | ||
| await browser.wait(until.textToBePresentInElement(listViewVMmStatus(vmName), 'Running'), VM_BOOTUP_TIMEOUT); | ||
| }); | ||
|
|
||
| it('Restarts VM', async() => { | ||
| await listViewAction(vmName)('Restart'); | ||
| await browser.wait(until.textToBePresentInElement(listViewVMmStatus(vmName), 'Starting'), VM_BOOTUP_TIMEOUT); | ||
| await browser.wait(until.textToBePresentInElement(listViewVMmStatus(vmName), 'Running'), VM_BOOTUP_TIMEOUT); | ||
| }, VM_ACTIONS_TIMEOUT); | ||
|
|
||
| it('Stops VM', async() => { | ||
| await listViewAction(vmName)('Stop'); | ||
| await browser.wait(until.textToBePresentInElement(listViewVMmStatus(vmName), 'Off'), 10000); | ||
| }); | ||
|
|
||
| it('Deletes VM', async() => { | ||
| await listViewAction(vmName)('Delete'); | ||
| await browser.wait(until.not(until.presenceOf(listViewVMmStatus(vmName)))); | ||
| leakedResources.delete(JSON.stringify({name: vmName, namespace: testName, kind: 'vm'})); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Test VM detail view kebab actions', () => { | ||
| const vmName = `vm-detail-view-actions-${testName}`; | ||
| beforeAll(async() => { | ||
| testVM.metadata.name = vmName; | ||
| execSync(`echo '${JSON.stringify(testVM)}' | kubectl create -f -`); | ||
| leakedResources.add(JSON.stringify({name: vmName, namespace: testName, kind: 'vm'})); | ||
| }); | ||
|
|
||
| it('Navigates to VMs detail page', async() => { | ||
| await browser.get(`${appHost}/k8s/all-namespaces/virtualmachines/${vmName}`); | ||
| await isLoaded(); | ||
| }); | ||
|
|
||
| it('Starts VM', async() => { | ||
| await detailViewAction('Start'); | ||
| await browser.wait(until.textToBePresentInElement(detailViewVMmStatus, 'Running'), VM_BOOTUP_TIMEOUT); | ||
| }); | ||
|
|
||
| it('Restarts VM', async() => { | ||
| await detailViewAction('Restart'); | ||
| await browser.wait(until.textToBePresentInElement(detailViewVMmStatus, 'Starting'), VM_BOOTUP_TIMEOUT); | ||
| await browser.wait(until.textToBePresentInElement(detailViewVMmStatus, 'Running'), VM_BOOTUP_TIMEOUT); | ||
| }, VM_ACTIONS_TIMEOUT); | ||
|
|
||
| it('Stops VM', async() => { | ||
| await detailViewAction('Stop'); | ||
| await browser.wait(until.textToBePresentInElement(detailViewVMmStatus, 'Off'), 10000); | ||
| }); | ||
|
|
||
| it('Deletes VM', async() => { | ||
| await detailViewAction('Delete'); | ||
| leakedResources.delete(JSON.stringify({name: vmName, namespace: testName, kind: 'vm'})); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.