-
Notifications
You must be signed in to change notification settings - Fork 605
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
Adding test cases for VM actions #2125
Adding test cases for VM actions #2125
Conversation
/test e2e-aws |
/test e2e-aws-console-olm |
b57cbc5
to
375a3c8
Compare
9a31e50
to
740ba14
Compare
/test e2e-aws-console |
740ba14
to
9ae25c4
Compare
9ae25c4
to
7defeb1
Compare
7defeb1
to
2bf53ac
Compare
2bf53ac
to
7f5db6d
Compare
/test e2e-aws-console-olm |
/test e2e-aws-console |
* @returns {boolean} True if found, false otherwise. | ||
*/ | ||
export function searchYAML(needle: string, name: string, namespace: string, kind: string): boolean { | ||
const result = execSync(`oc get -o yaml -n ${namespace} ${kind} ${name}`).toString(); |
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 understand the power of a function like that but I am a little bit worried about this dependency on the oc
tool.
It requires extra configuration step which should be documented.
At least path to it should be configurable (env variable?).
Anyway, I think it would be better to rely on existing API connection, i.e. via k8sGet()
function. Wdyt?
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'm not sure if it's necessary to use API because openshift core integration-tests use kubectl
quite often. But I agree we should use kubectl
rather than oc
here.
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.
ok, makes sense. As long as we don't need specifics of the oc
, the kubectl
is better option. I see it used in the core tests now, so we would not introduce new dependency this way.
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 am a little bit worried about this dependency on the
oc
tool.
openshift core integration-tests use
kubectl
quite often.
@mareklibra @rhrazdil @jelkosz @spadgett
Console integration tests should use kubectl
instead of oc
- this reflects the expectation that Console should work without issues on vanilla k8s clusters. (Console's primary target is OpenShift, but we want to keep compatibility with vanilla k8s as well.)
AFAIK, when you install oc
it also creates a link to kubectl
so the same tests should work for both vanilla k8s and OpenShift.
As long as we don't need specifics of the
oc
, thekubectl
is better option.
👍
@@ -25,12 +25,15 @@ export class DetailView { | |||
await browser.get(`${appHost}/k8s/ns/${this.namespace}/${this.kind}/${this.name}`); | |||
await isLoaded(); | |||
} | |||
await clickHorizontalTab(tabName); | |||
await isLoaded(); | |||
if ((await $('.co-m-horizontal-nav-item--active').getText()) !== tabName) { |
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.
This can be wrapped by a view
function, like the rest of the code is doing.
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.
Done.
await kubevirtDetailView.selectKebabOption(name, 'Delete'); | ||
await confirmAction(); | ||
do { | ||
await browser.sleep(50); |
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.
Why 50? Can we find a more reliable check than just a delay?
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.
Fixed.
}); | ||
}); | ||
|
||
describe('Test VM Migration', () => { |
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.
This should go either under Test VM actions
scenario or be moved in a separate file (which is preferred, imo).
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.
Done.
); | ||
}); | ||
|
||
describe('Add/remove disks and NICs on respective VM pages', () => { |
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.
likewise
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.
Done.
VM_ACTIONS_TIMEOUT_SECS * 2, | ||
); | ||
|
||
xit( |
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.
??
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.
xit
skips a spec and highlights it in the test report as skipped.
It's skipped due to the opened BZ
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.
If possible, please link to the BZ blocking this test case via comment.
Edit: nevermind, it's part of test description 😄 my bad.
// Verify the NIC is added in VM Manifest | ||
const resource = getResourceObject(vm.name, vm.namespace, vm.kind); | ||
const nic = _.find( | ||
_.get(resource, 'spec.template.spec.domain.devices.interfaces', []), |
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 believe we have a selector for this. If not, can we add?
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.
Could you point to the selectors? I don't know what you mean
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.
https://github.com/openshift/console/tree/master/frontend/packages/kubevirt-plugin/src/selectors
In particular, this one seems to be relevant:
export const getInterfaces = (vm: VMKind) => |
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.
Either that or console-shared
selectors, might check out that one as well.
vmi = await vm.navigateToVmi(TABS.OVERVIEW); | ||
expect((await vmi.getVolumes()).includes(hddDisk.name)).toBe(false); | ||
}, | ||
VM_ACTIONS_TIMEOUT_SECS * 2, |
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.
Just to understand: why * 2
?
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.
VM is restarted twice
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.
VM_ACTIONS_TIMEOUT_SECS * 2, // VM is restarted twice
|
||
// Try to add the NIC again | ||
await click(createNic, 1000); | ||
await browser.sleep(1000).then(() => browser.wait(until.presenceOf($(networkTypeDropdownId)))); |
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 have hard time to understand this flow without spending time on trying it. Can you please briefly describe these 2 lines (like what is the starting point and what is being tested here) ?
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.
We test that it's not possible to add 2 NICs that use the same network (net-attach-def)
.$$('a') | ||
await tableRowForName(name) | ||
.$('.dropdown-menu-right') | ||
.$$('button') |
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 think this function is used in other tests as well or at least in other pending PRs.
Can you please make sure that existing tests are not affected? Is this "new" structure generic for a kebab
or comes from the just considered scenario?
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.
This is generic, all other PRs need to use this implementation.
const resources: StorageResource[] = []; | ||
const rows = await kubevirtDetailView.tableRows(); | ||
rows.forEach((line) => { | ||
const cols = line.split(/\s+/); |
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.
can you please explain how is the table text and rows are resolved? How come we get the columns just by splitting it by spaces?
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.
Well calling getText()
on the table returns string in the following format
attr00 attr01 ... attr0n\n
attr10 attr11 ... attr1n\n
So forEach
iterates over lines and thus I can split the columns by spaces.
const cells = row.$$('div'); | ||
const resources: StorageResource[] = []; | ||
const rows = await kubevirtDetailView.tableRows(); | ||
rows.forEach((line) => { |
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.
we can use a map function now
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 find forEach easier to read
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.
Okay I used map
after all.
await kubevirtDetailView.selectKebabOption(name, 'Delete'); | ||
await confirmAction(); | ||
do { | ||
await browser.sleep(50); | ||
} while ((await resourceRows.count()) !== count - 1); |
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.
is there some timeout which would trigger failure if this action fails to remove the disk?
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.
Yes, the timeout of the spec that executes this, but I have changed it to adress Marek's review, so this is no longer relevant
until.presenceOf(statusIcon(statusIcons.error)), | ||
), | ||
); | ||
await browser.wait( |
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.
why is the running -> error -> running
flow ok? Shouldn't we check against that?
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 have noticed that sometimes container VM ends up briefly in error
state during restart and since container VM boots quite quickly and the status is not updated so often, the VM goes from error
straight to running
, which broke the automation because it was waiting for starting
phase.
it( | ||
'Starts VM', | ||
async () => { | ||
await listViewAction(vmName)('Start', true); |
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.
can the detail actions be reused here?
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.
Done.
7f5db6d
to
764a0b0
Compare
c63dd25
to
743049a
Compare
/test e2e-aws-console |
/lgtm |
/assign @kyoto |
|
||
export class VirtualMachine extends KubevirtDetailView { | ||
constructor(config) { | ||
super({ ...config, kind: 'virtualmachines' }); | ||
} | ||
|
||
async navigateToVmi(vmiTab: string): Promise<VirtualMachineInstance> { |
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.
Nit: should be navigateToVMI
.
743049a
to
3cb0e8f
Compare
Change diff looks OK, thanks for addressing all review comments. /lgtm |
3cb0e8f
to
7b16958
Compare
/lgtm We missed some lint issues, it's fixed now. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mareklibra, rhrazdil, suomiy, vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
* @param {string} kind Kind of the resource. | ||
* @returns {boolean} True if found, false otherwise. | ||
*/ | ||
export function searchYAML(needle: string, name: string, namespace: string, kind: string): boolean { |
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
- Get the JSON with
-o json
- Parse the JSON
- Check the specific property we're interested in
The searchYAML
approach 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.
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
Adding test cases for VM actions
This PR depends on #2053.
Currently, there are the following bugs that are blocking these test from passing:
https://bugzilla.redhat.com/show_bug.cgi?id=1731480 - fix merged
https://bugzilla.redhat.com/show_bug.cgi?id=1731340 - fix merged