Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Conversation

@gouyang
Copy link

@gouyang gouyang commented Jul 3, 2019

Implementation of Polarion test case:
https://polarion.engineering.redhat.com/polarion/#/project/CNV/workitem?id=CNV-1718
https://polarion.engineering.redhat.com/polarion/#/project/CNV/workitem?id=CNV-1720

Comments for review:

  1. It's using UI to create the test project, it's more convenient than do it via cli.

Signed-off-by: Guohua Ouyang [email protected]

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 3, 2019
@gouyang gouyang changed the title [WIP]add test for non-admin user add test for non-admin user Jul 10, 2019
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 10, 2019
Copy link

@rhrazdil rhrazdil left a comment

Choose a reason for hiding this comment

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

Could you please add links to polarion test plans for the implemented test cases?

Choose a reason for hiding this comment

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

I would prefer moving this logic to login method in utils, the login method should be improved to handle

  1. logging in kubeadmin (in both cases - with and without htpasswd identity provider enabled),
  2. logging in a different non-admin user (atm it's enough to only consider htpasswd)
  3. it must also take into account that when tests are executed with bridge UI, login screen is not displayed (so in that case it shouldn't be waiting for login form to appear)

Copy link
Author

Choose a reason for hiding this comment

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

Put this logic into views/login.view.ts and simply the login function now.

Choose a reason for hiding this comment

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

When running with bridge, there is no logout button, it should be enough to just do oc login with different user and reload page.

Copy link
Author

Choose a reason for hiding this comment

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

oc login with different user and reload page does not work, it's not logging in a different user on UI.

Choose a reason for hiding this comment

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

this could be simplified by a function; e.g. called like this:

withRole(role, name, namespace, () => {
  await browser.get(`${appHost}/k8s/ns/${testName}/virtualmachines`);
  await crudView.isLoaded();
  ...
})

and similarly

withClusterRole(...

Choose a reason for hiding this comment

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

the inside of this method can be a parametrized function of 'Nonadmin user can use vm dialog in its own namespace'

Choose a reason for hiding this comment

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

duplicate implementation

Choose a reason for hiding this comment

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

same here

@atiratree
Copy link

Also, there is other functionality which should be tested for permissions / missing resources.
This functionality could be a nice followup

@gouyang
Copy link
Author

gouyang commented Jul 22, 2019

@suomiy @rhrazdil I made some changes, could you please review again?

Choose a reason for hiding this comment

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

What is the benefit of this to be an inner function?

Copy link
Author

Choose a reason for hiding this comment

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

I see some same usage about the inner function in modal-annotations.scenario.ts, so just try to use the similar thing here. Is it so bad?

Choose a reason for hiding this comment

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

It is not that bad (:, just it would be easier to potentially reuse this function in the future.

Choose a reason for hiding this comment

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

shouldn't we also check the yaml in VM Templates?

Choose a reason for hiding this comment

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

The VM and templates are very similar. Can you please make it generic?

Copy link
Author

Choose a reason for hiding this comment

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

it's checking whether user has permission to use wizard dialog and yaml dialog, VM has 'create from yaml' dialog but VM template doesn't have it.

Choose a reason for hiding this comment

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

VM Template newly received this functionality in https://github.com/openshift/console

Choose a reason for hiding this comment

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

this block would look better extracted into a function

Choose a reason for hiding this comment

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

can you please move the perm arg to the end - it is easier to follow a pattern like this:
f(what, options)

Choose a reason for hiding this comment

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

again, why inside?

Copy link
Author

Choose a reason for hiding this comment

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

Will move the 'perm' arg to the end.

@mareklibra
Copy link

@gouyang , have you considered implementing new tests in openshift-console, please?

There will be no other build of web-ui (except bug-fixes for 2.0.0). And as we have migrated almost all features from here to upstream already, we are moving integration tests is in progress as well these days.

So targeting openshift-console directly sounds more effective to me atm.

Choose a reason for hiding this comment

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

Could we rather wait for some element to appear?

Copy link
Author

Choose a reason for hiding this comment

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

I copied this from login.scenario.ts. It seems no necessary to sleep here as there are await in loginView.login.

Choose a reason for hiding this comment

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

Wouldn't it be better if different permissions were tested in separate specs?
This verifyPermissions method seems too big and has no versatility. If there is a bug in some of the permissions, there is no way to specifically skip it.
This way we have passing something that should fail. It's better to skip a failing test with xit, as it's visible in test report.

Copy link
Author

@gouyang gouyang Aug 7, 2019

Choose a reason for hiding this comment

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

Separate specs means different describe, right?
I can change it like:

describe('Test nonadmin user UI behavior', () => {
describe('Test nonadmin user with roleBinding view UI behavior', () => {
describe('Test nonadmin user with roleBinding edit UI behavior', () => {
describe('Test nonadmin user with clusterRoleBinding view UI behavior', () => {
describe('Test nonadmin user with clusterRoleBinding edit UI behavior', () => {

And it does not need to change verifyPermissions.

Copy link

Choose a reason for hiding this comment

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

No, spec is it block

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 will make changes to the PR in console.

Choose a reason for hiding this comment

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

It would be better to just wait for the 'cannot list resource text' text. Check waitForStringInElement method in utils.ts and how it's used

Copy link
Author

Choose a reason for hiding this comment

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

Change it another way in openshift#2265

Choose a reason for hiding this comment

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

Use Wizard instance for this:

const wizard = new Wizard();
await wizard.openWizard();
await wizard.closeWizard();

I believe there are similar methods in the Yaml class

Copy link
Author

Choose a reason for hiding this comment

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

Updated in openshift#2265

Choose a reason for hiding this comment

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

Here we should rather wait for login screen with kubeadmin/httpass provider selection

Copy link
Author

Choose a reason for hiding this comment

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

It can use that once 1721423 isn't blocking it.

Choose a reason for hiding this comment

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

This I think should be broken down into multiple specs

@gouyang
Copy link
Author

gouyang commented Jul 29, 2019

@gouyang , have you considered implementing new tests in openshift-console, please?

There will be no other build of web-ui (except bug-fixes for 2.0.0). And as we have migrated almost all features from here to upstream already, we are moving integration tests is in progress as well these days.

So targeting openshift-console directly sounds more effective to me atm.

I'm okay to move this to openshift-console, will move it over after address the review comments.

Signed-off-by: Guohua Ouyang <[email protected]>

export function createResource(resource) {
execSync(`echo '${JSON.stringify(resource)}' | kubectl create -f -`);
execSync(`echo '${JSON.stringify(resource)}' | kubectl apply -f -`);
Copy link

Choose a reason for hiding this comment

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

Is this a good idea to mix declarative and imperative approach in creating resources? Wouldn't it be safer to have a new method, i.e applyResource?

Copy link
Author

Choose a reason for hiding this comment

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

Well, the purpose of this change is avoiding to create a new method. Of course it can has another method or maybe just use execSync.

And why do we need createResource for one line code?


export const login = async(providerName: string, username: string, password: string) => {
if (providerName) {
if (await $('a.idp').isPresent()) {
Copy link

Choose a reason for hiding this comment

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

Note that this change probably should not be necessary in openshift/console

Copy link
Author

Choose a reason for hiding this comment

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

Without this change, it can't run test with a cluster without idp.
It's not necessary if the test run with idp always, I know it's not perfect.

I have a PR in console about this: openshift#2016

@gouyang
Copy link
Author

gouyang commented Aug 7, 2019

Moved this to openshift#2265, will close this.

@gouyang gouyang closed this Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants