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

bug 1832371: CNV-4046: Add integration test for vm environment tab #5280

Conversation

irosenzw
Copy link
Contributor

@irosenzw irosenzw commented May 4, 2020

Signed-off-by: Ido Rosenzwig irosenzw@redhat.com

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label May 4, 2020
@openshift-ci-robot openshift-ci-robot added the component/kubevirt Related to kubevirt-plugin label May 4, 2020
ConfigMapKind,
SecretKind,
ServiceAccountKind,
} from '../../../../../public/module/k8s/types';
Copy link

Choose a reason for hiding this comment

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

Could you use @Console instead of relative path please?

await dropDownBtn
.filter(async (elem) => {
const elemText = await elem.getText();
return elemText === 'Select a resource';
Copy link

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 this is a good way to select a dropdown button, if I understand, this doesn't allow to change the selection in the dropdown for the second time, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it allows you to change the selection. this is why I need to select the dropdown which have no value.

createResource(secret);
createResource(configmap);
createResource(serviceAccount);
createExampleVMViaYAML();
Copy link

Choose a reason for hiding this comment

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

there should be await before createExampleVMViaYAML

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

const addVariableButton = element(by.buttonText('Add All From Config Map or Secret'));

export const clickAddSourceButton = async () => {
await browser.wait(until.elementToBeClickable(addVariableButton), PAGE_LOAD_TIMEOUT_SECS);
Copy link

Choose a reason for hiding this comment

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

Instead if this method you can use click method that does the wait until.elementToBeClickable
await click(element(by.buttonText('Add All From Config Map or Secret')))


export const timeout = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

export const startVM = async (vmName: string, ns: string) => {
Copy link

Choose a reason for hiding this comment

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

I think we shouldn't re-implement this, it's better to create a VirtualMachine instance and use it's action method
const vm = new VirtualMachine();
await vm.action(VM_ACTION.Start);

});

it('Verify all the sources are present at the disks tab', async () => {
await browser.get(`${appHost}/k8s/ns/${testName}/virtualmachines/${vmName}/disks`);
Copy link

Choose a reason for hiding this comment

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

With the VirtualMachine instance, this can be substituted with

const disks = await vm.getAttachedDisks();

expect(disks).toContain( <configMapDisk> ); // you need to have configMapDisk in StorageResource type, or you can just search by name


export const successAlert = $('.pf-c-alert.pf-m-inline.pf-m-success.co-alert');
export const errorAlert = $('.pf-c-alert.pf-m-inline.pf-m-danger.co-alert.co-alert--scrollable');

export const startVMChoice = $('[data-test-action="Start Virtual Machine"]');
Copy link

Choose a reason for hiding this comment

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

Unnecessary, we hav VM actions in packages/kubevirt-plugin/integration-tests/tests/utils/consts.ts in VM_ACTION

@@ -51,7 +51,7 @@ export async function createProject(name: string) {
}

export async function createExampleVMViaYAML() {
Copy link

Choose a reason for hiding this comment

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

I think it would be better to refactor createExampleVMViaYAML to return VirtualMachine object instance.
You could then re-use all the VirtualMachine navigation and other useful method (which I refer to comments later)

return new VirtualMachine({ name: DEFAULT_YAML_VM_NAME, namespace: testName });

@irosenzw irosenzw force-pushed the vm-env-disk-integration-tests branch 2 times, most recently from 8c309ed to 5e77c20 Compare May 6, 2020 10:51
});

beforeEach(async () => {
await browser.get(`${appHost}/k8s/ns/${testName}/virtualmachines/${vmName}/environment`);
Copy link

Choose a reason for hiding this comment

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

Please, add Environment tab to packages/kubevirt-plugin/integration-tests/tests/utils/consts.ts
and then you can use await vm.navigateToTab(TAB.Environment)

});

it('Verify vm object was created', () => {
expect(!!vm).toBeTruthy();
Copy link

Choose a reason for hiding this comment

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

I don't think this is necessary, moreover, I'd like the it specs to be feature-related only.
You could put the check to the beforeAll if you want.


// Add Service Account
await browser.wait(until.elementToBeClickable(vmEnv.addVariableButton), PAGE_LOAD_TIMEOUT_SECS);
await click(element(by.buttonText('Add All From Config Map or Secret')));
Copy link

Choose a reason for hiding this comment

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

You can pass the timeout to click function:
await click(element(by.buttonText('Add All From Config Map or Secret')), PAGE_LOAD_TIMEOUT_SECS);

await vmEnv.serialField.get(1).clear();
await vmEnv.serialField.get(1).sendKeys('i', Key.BACK_SPACE); // workaround: for some reason clear() is not enough
await browser.wait(until.elementToBeClickable(vmEnv.saveBtn), PAGE_LOAD_TIMEOUT_SECS);
await vmEnv.saveBtn.click();
Copy link

Choose a reason for hiding this comment

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

you could use await click(vmEnv.saveBtn, PAGE_LOAD_TIMEOUT_SECS);

await browser.wait(until.presenceOf(vmEnv.errorAlert), PAGE_LOAD_TIMEOUT_SECS);
const errorText = await vmEnv.errorAlert.getText();
expect(vmEnv.errorAlert.isDisplayed()).toEqual(true);
expect(errorText.includes(vmEnv.noSerialError)).toEqual(true);
Copy link

Choose a reason for hiding this comment

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

Optional:
expect(errorText.includes(vmEnv.noSerialError)).toEqual(true);
can be written as
expect(errorText).toContain(vmEnv.noSerialError);
which is slightly nicer to read.

const firstSerial = await vmEnv.serialField.get(0).getAttribute('value');
await vmEnv.serialField.get(1).clear();
await vmEnv.serialField.get(1).sendKeys(firstSerial);
await browser.wait(until.elementToBeClickable(vmEnv.saveBtn), PAGE_LOAD_TIMEOUT_SECS);
Copy link

Choose a reason for hiding this comment

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

again, you could use click as mentioned before

await browser.wait(until.presenceOf(vmEnv.errorAlert), PAGE_LOAD_TIMEOUT_SECS);
expect(vmEnv.errorAlert.isDisplayed()).toEqual(true);
const errorText = await vmEnv.errorAlert.getText();
expect(errorText.includes(vmEnv.dupSerialsError)).toEqual(true);
Copy link

Choose a reason for hiding this comment

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

you could use toContain as mentioned before


it('Cannot use the same resource more than once', async () => {
await browser.wait(until.elementToBeClickable(vmEnv.addVariableButton), PAGE_LOAD_TIMEOUT_SECS);
await click(element(by.buttonText('Add All From Config Map or Secret')));
Copy link

Choose a reason for hiding this comment

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

you could use click as mentioned before

@irosenzw irosenzw force-pushed the vm-env-disk-integration-tests branch from 5e77c20 to 100c529 Compare May 6, 2020 13:24
@rhrazdil
Copy link

rhrazdil commented May 6, 2020

Looks good
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 6, 2020
@irosenzw irosenzw force-pushed the vm-env-disk-integration-tests branch from 100c529 to 3cd0ce6 Compare May 6, 2020 14:12
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 6, 2020
@@ -51,14 +53,23 @@ export async function createProject(name: string) {
}
}

export async function createExampleVMViaYAML() {
export async function createExampleVMViaYAML(getVMObj?: boolean): Promise<any> {
Copy link
Contributor

Choose a reason for hiding this comment

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

this returns a VM object not a Promise

Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
@irosenzw irosenzw force-pushed the vm-env-disk-integration-tests branch from 3cd0ce6 to d83d103 Compare May 6, 2020 14:42
@rawagner
Copy link
Contributor

rawagner commented May 6, 2020

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 6, 2020
@irosenzw irosenzw changed the title CNV-4046: Add integration test for vm environment tab bug 1832371: CNV-4046: Add integration test for vm environment tab May 6, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 6, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1832371, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

bug 1832371: CNV-4046: Add integration test for vm environment tab

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@irosenzw
Copy link
Contributor Author

irosenzw commented May 6, 2020

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1832371, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@irosenzw
Copy link
Contributor Author

irosenzw commented May 6, 2020

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1832371, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@irosenzw
Copy link
Contributor Author

irosenzw commented May 6, 2020

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. and removed bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. labels May 6, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1832371, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@rawagner
Copy link
Contributor

rawagner commented May 6, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 6, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irosenzw, rawagner, rhrazdil

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-merge-robot openshift-merge-robot merged commit 353036d into openshift:master May 6, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: All pull requests linked via external trackers have merged: openshift/console#5280. Bugzilla bug 1832371 has been moved to the MODIFIED state.

In response to this:

bug 1832371: CNV-4046: Add integration test for vm environment tab

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.5 milestone May 11, 2020
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. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality component/kubevirt Related to kubevirt-plugin lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants