-
Notifications
You must be signed in to change notification settings - Fork 667
Adding test cases for VM actions #2125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,12 @@ | ||
| /* eslint-disable no-await-in-loop */ | ||
| import { selectDropdownOption, click } from '../../../../console-shared/src/test-utils/utils'; | ||
| import { browser, ExpectedConditions as until } from 'protractor'; | ||
| import { | ||
| selectDropdownOption, | ||
| click, | ||
| waitForCount, | ||
| } from '../../../../console-shared/src/test-utils/utils'; | ||
| import { isLoaded, resourceRows } from '../../../../../integration-tests/views/crud.view'; | ||
| import { TABS, diskTabCol, networkTabCol } from '../utils/consts'; | ||
| import { TABS, diskTabCol, networkTabCol, PAGE_LOAD_TIMEOUT_SECS } from '../utils/consts'; | ||
| import { StorageResource, NetworkResource } from '../utils/types'; | ||
| import { fillInput } from '../utils/utils'; | ||
| import * as kubevirtDetailView from '../../views/kubevirtDetailView.view'; | ||
|
|
@@ -11,31 +16,29 @@ import { DetailView } from './detailView'; | |
| export class KubevirtDetailView extends DetailView { | ||
| async getAttachedDisks(): Promise<StorageResource[]> { | ||
| await this.navigateToTab(TABS.DISKS); | ||
| const resources = []; | ||
| for (const row of await resourceRows) { | ||
| const cells = row.$$('div'); | ||
| resources.push({ | ||
| name: await cells.get(diskTabCol.name).getText(), | ||
| size: (await cells.get(diskTabCol.size).getText()).match(/^\d*/)[0], | ||
| storageClass: await cells.get(diskTabCol.storageClass).getText(), | ||
| }); | ||
| } | ||
| return resources; | ||
| const rows = await kubevirtDetailView.tableRows(); | ||
| return rows.map((line) => { | ||
| const cols = line.split(/\s+/); | ||
|
||
| return { | ||
| name: cols[diskTabCol.name], | ||
| size: cols[diskTabCol.size].slice(0, -2), | ||
| storageClass: cols[diskTabCol.storageClass], | ||
| }; | ||
| }); | ||
| } | ||
|
|
||
| async getAttachedNICs(): Promise<NetworkResource[]> { | ||
| await this.navigateToTab(TABS.NICS); | ||
| const resources = []; | ||
| for (const row of await resourceRows) { | ||
| const cells = row.$$('div'); | ||
| resources.push({ | ||
| name: await cells.get(networkTabCol.name).getText(), | ||
| mac: await cells.get(networkTabCol.mac).getText(), | ||
| networkDefinition: await cells.get(networkTabCol.networkDefinition).getText(), | ||
| binding: await cells.get(networkTabCol.binding).getText(), | ||
| }); | ||
| } | ||
| return resources; | ||
| const rows = await kubevirtDetailView.tableRows(); | ||
| return rows.map((line) => { | ||
| const cols = line.split(/\s+/); | ||
| return { | ||
| name: cols[networkTabCol.name], | ||
| mac: cols[networkTabCol.mac], | ||
| networkDefinition: cols[networkTabCol.networkDefinition], | ||
| binding: cols[networkTabCol.binding], | ||
| }; | ||
| }); | ||
| } | ||
|
|
||
| async addDisk(disk: StorageResource) { | ||
|
|
@@ -50,8 +53,10 @@ export class KubevirtDetailView extends DetailView { | |
|
|
||
| async removeDisk(name: string) { | ||
| await this.navigateToTab(TABS.DISKS); | ||
| const count = await resourceRows.count(); | ||
| await kubevirtDetailView.selectKebabOption(name, 'Delete'); | ||
| await confirmAction(); | ||
| await browser.wait(until.and(waitForCount(resourceRows, count - 1)), PAGE_LOAD_TIMEOUT_SECS); | ||
| } | ||
|
|
||
| async addNIC(nic: NetworkResource) { | ||
|
|
@@ -67,7 +72,9 @@ export class KubevirtDetailView extends DetailView { | |
|
|
||
| async removeNIC(name: string) { | ||
| await this.navigateToTab(TABS.NICS); | ||
| const count = await resourceRows.count(); | ||
| await kubevirtDetailView.selectKebabOption(name, 'Delete'); | ||
| await confirmAction(); | ||
| await browser.wait(until.and(waitForCount(resourceRows, count - 1)), PAGE_LOAD_TIMEOUT_SECS); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* eslint-disable no-unused-vars, no-undef, no-await-in-loop, no-console */ | ||
| import { volumeRows } from '../../views/virtualMachineInstance.view'; | ||
| import { DetailView } from './detailView'; | ||
|
|
||
| export class VirtualMachineInstance extends DetailView { | ||
| constructor(vmiConfig) { | ||
| super({ ...vmiConfig, kind: 'pods' }); | ||
| } | ||
|
|
||
| async getVolumes() { | ||
| const disks = []; | ||
| for (const row of await volumeRows) { | ||
| disks.push( | ||
| await row | ||
| .$$('td') | ||
| .first() | ||
| .getText(), | ||
| ); | ||
| } | ||
| return disks; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is an old PR that's already merged, but this isn't the way we should test for content in the resources. Instead, we should
-o jsonThe
searchYAMLapproach is bad because it can result in incorrect failures due to different quoting styles in the YAML or it can result in false positives where the string is matched somewhere else in the document.Can we look at removing this utility and replacing its usage? At the very least, I'd like to move this out of console-shared to discourage its use elsewhere.
@rhrazdil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's currently only used in old kubevirt tests, I'll update those and remove this method from console-shared