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
bug 1832371: CNV-4046: Add integration test for vm environment tab #5280
Conversation
ConfigMapKind, | ||
SecretKind, | ||
ServiceAccountKind, | ||
} from '../../../../../public/module/k8s/types'; |
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 use @Console instead of relative path please?
await dropDownBtn | ||
.filter(async (elem) => { | ||
const elemText = await elem.getText(); | ||
return elemText === 'Select a resource'; |
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 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?
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.
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(); |
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 should be await before createExampleVMViaYAML
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.
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); |
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.
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) => { |
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 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`); |
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.
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"]'); |
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.
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() { |
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 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 });
8c309ed
to
5e77c20
Compare
}); | ||
|
||
beforeEach(async () => { | ||
await browser.get(`${appHost}/k8s/ns/${testName}/virtualmachines/${vmName}/environment`); |
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.
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(); |
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 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'))); |
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.
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(); |
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.
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); |
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.
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); |
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.
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); |
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.
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'))); |
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.
you could use click as mentioned before
5e77c20
to
100c529
Compare
Looks good |
100c529
to
3cd0ce6
Compare
@@ -51,14 +53,23 @@ export async function createProject(name: string) { | |||
} | |||
} | |||
|
|||
export async function createExampleVMViaYAML() { | |||
export async function createExampleVMViaYAML(getVMObj?: boolean): Promise<any> { |
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 returns a VM object not a Promise
Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
3cd0ce6
to
d83d103
Compare
/approve |
@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
In response to this:
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. |
/bugzilla refresh |
@irosenzw: This pull request references Bugzilla bug 1832371, which is valid. 3 validation(s) were run on this bug
In response to this:
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. |
/bugzilla refresh |
@irosenzw: This pull request references Bugzilla bug 1832371, which is valid. 3 validation(s) were run on this bug
In response to this:
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. |
/bugzilla refresh |
@irosenzw: This pull request references Bugzilla bug 1832371, which is valid. 3 validation(s) were run on this bug
In response to this:
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. |
/lgtm |
[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 |
@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:
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. |
Signed-off-by: Ido Rosenzwig irosenzw@redhat.com