Skip to content
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

Merged

Conversation

rhrazdil
Copy link

@rhrazdil rhrazdil commented Jul 23, 2019

Adding test cases for VM actions

  • start, stop, restart, delete
  • migration
  • adding/removing disks on Disks tab
  • adding/removing nics on Netwok interfaces tab

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

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 23, 2019
@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 23, 2019
@rhrazdil
Copy link
Author

/test e2e-aws
/test e2e-aws-console-olm
/test e2e-aws-console

@rhrazdil
Copy link
Author

/test e2e-aws-console-olm

@openshift-ci-robot openshift-ci-robot added the component/kubevirt Related to kubevirt-plugin label Aug 5, 2019
@rhrazdil rhrazdil force-pushed the console-vmactions-tests branch 3 times, most recently from 9a31e50 to 740ba14 Compare August 5, 2019 12:10
@rhrazdil
Copy link
Author

rhrazdil commented Aug 6, 2019

/test e2e-aws-console
/test e2e-aws

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 14, 2019
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. component/shared Related to console-shared and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 2, 2019
@rhrazdil rhrazdil changed the title [WIP] Adding test cases for VM actions Adding test cases for VM actions Sep 3, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 3, 2019
@droslean
Copy link
Member

droslean commented Sep 3, 2019

/test e2e-aws-console-olm

@droslean
Copy link
Member

droslean commented Sep 3, 2019

/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();
Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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, the kubectl 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) {
Copy link
Contributor

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.

Copy link
Author

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);
Copy link
Contributor

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?

Copy link
Author

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', () => {
Copy link
Contributor

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).

Copy link
Author

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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

likewise

Copy link
Author

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(
Copy link
Contributor

Choose a reason for hiding this comment

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

??

Copy link
Author

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

Copy link
Contributor

@vojtechszocs vojtechszocs Sep 5, 2019

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', []),
Copy link
Contributor

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?

Copy link
Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

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,
Copy link
Contributor

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 ?

Copy link
Author

Choose a reason for hiding this comment

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

VM is restarted twice

Copy link
Contributor

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))));
Copy link
Contributor

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) ?

Copy link
Author

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')
Copy link
Contributor

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?

Copy link
Author

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+/);
Copy link
Member

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?

Copy link
Author

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) => {
Copy link
Member

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

Copy link
Author

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

Copy link
Author

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);
Copy link
Member

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?

Copy link
Author

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(
Copy link
Member

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?

Copy link
Author

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);
Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@rhrazdil rhrazdil force-pushed the console-vmactions-tests branch 3 times, most recently from c63dd25 to 743049a Compare September 4, 2019 13:30
@rhrazdil
Copy link
Author

rhrazdil commented Sep 4, 2019

/test e2e-aws-console

@mareklibra
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 5, 2019
@mareklibra
Copy link
Contributor

/assign @kyoto


export class VirtualMachine extends KubevirtDetailView {
constructor(config) {
super({ ...config, kind: 'virtualmachines' });
}

async navigateToVmi(vmiTab: string): Promise<VirtualMachineInstance> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: should be navigateToVMI.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 5, 2019
@vojtechszocs
Copy link
Contributor

Change diff looks OK, thanks for addressing all review comments.

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 5, 2019
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 5, 2019
@vojtechszocs
Copy link
Contributor

/lgtm

We missed some lint issues, it's fixed now.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 5, 2019
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 0680813 into openshift:master Sep 6, 2019
@spadgett spadgett added this to the v4.2 milestone Sep 6, 2019
* @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 {
Copy link
Member

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

  1. Get the JSON with -o json
  2. Parse the JSON
  3. 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.

@rhrazdil

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/kubevirt Related to kubevirt-plugin component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants