Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] - Check STDOUT of provisioned ansible service #10289

Merged
merged 1 commit into from
Aug 19, 2020

Conversation

dgaikwad
Copy link
Contributor

@dgaikwad dgaikwad commented Aug 10, 2020

  • Added test to check provisioned service's standard output of particular user
  • Fixed standard_output locator of service
  • Written view for "Set Ownership" for ansible catalog item.
  • test_appliance_console_logfile_config_reboot moved test to manual only because need large effort to automate it.

{{pytest: cfme/tests/configure/test_access_control.py::test_ansible_playbook_stdout cfme/tests/ansible/test_embedded_ansible_services.py::test_ansible_group_id_in_payload cfme/tests/ansible/test_embedded_ansible_services.py::test_service_ansible_playbook_pass_extra_vars --long-running -v}}

@dgaikwad dgaikwad force-pushed the test_ansible_playbook_stdout branch 3 times, most recently from 41bc916 to d810b05 Compare August 12, 2020 15:17
@dgaikwad dgaikwad changed the title [WIP]Check STDOUT of provisioned service [WIPTEST]Check STDOUT of provisioned service Aug 12, 2020
@dgaikwad dgaikwad force-pushed the test_ansible_playbook_stdout branch from d810b05 to 7f93ef5 Compare August 12, 2020 15:32
@dgaikwad dgaikwad changed the title [WIPTEST]Check STDOUT of provisioned service [RFR] - Check STDOUT of provisioned ansible service Aug 12, 2020
Copy link
Contributor

@valaparthvi valaparthvi left a comment

Choose a reason for hiding this comment

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

This test is good but there are few things that could be made better.


@property
def is_displayed(self):
return self.form.select_an_owner.is_displayed and self.form.select_group.is_displayed
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional - You might want to add other checks such as self.submit.is_displayed and self.cancel.is_enabled and self.reset.is_enabled.

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

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, Can't add is_display for reset button before changing the state.

@@ -144,7 +144,7 @@ class provisioning(View): # noqa
'normalize-space(.)="Plays"]]')
details = SummaryTable(title='Details')
credentials = SummaryTable(title='Credentials')
standart_output = Text('.//div[@id="provisioning"]//pre')
standart_output = Text('.//div[@id="provisioning"]/ansible-raw-stdout')
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't break anything else, does it?

Copy link
Member

Choose a reason for hiding this comment

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

At this point we're only supporting 5.11 and upstream with the master branch, so I'm not concerned with the potential for this to break the locator in older versions.

@@ -826,3 +827,26 @@ class EditTags(CFMENavigateStep):

def step(self, *args, **kwargs):
self.prerequisite_view.policy.item_select('Edit Tags')


class SetOwnershipView(ServicesCatalogView):
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if you could move this view with other views in the top part of this file.

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

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

@pytest.fixture()
def custom_user(appliance):
group = appliance.collections.groups.instantiate("EvmGroup-user_self_service")
user = appliance.collections.users.create(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you use REST API to create the user? It would make this thing faster.

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

Comment on lines 3050 to 3053
view = navigate_to(ansible_catalog_item, "SetOwnership")
view.form.select_an_owner.fill("Administrator")
view.form.select_group.fill(group.description)
view.submit.click()
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on adding a method called set_ownership to BaseCatalogItem?

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

fauxfactory.gen_alphanumeric(),
description="my ansible catalog",
items=[ansible_catalog_item.name],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Everything until here seems like a part of the setup, thoughts on moving this to a fixture, maybe renaming custom_user and putting everything there?

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


with user:
with appliance.context.use(ViaSSUI):
appliance.server.login(user)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're using with user you probably don't need to manually login.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried but it was not working without this login()

Comment on lines 3065 to 3068
view = ssui_nav(service_catalog, "Details")
view.add_to_shopping_cart.click()
view = ssui_nav(service_catalog, "ShoppingCart")
view.order.click()
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 you can directly do service_catalog.order() to order it and since you're using the SSUI context, it will order it via SSUI.

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

Comment on lines 3076 to 3077
if ansible_catalog.exists:
ansible_catalog.delete()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ansible_catalog.exists:
ansible_catalog.delete()
ansible_catalog.delete_if_exists()

@valaparthvi valaparthvi changed the title [RFR] - Check STDOUT of provisioned ansible service [WIPTEST] - Check STDOUT of provisioned ansible service Aug 13, 2020
@valaparthvi valaparthvi added enhancement test-automation To be applied on PR's which are automating existing manual cases labels Aug 13, 2020
@dgaikwad dgaikwad force-pushed the test_ansible_playbook_stdout branch 2 times, most recently from bd49003 to 18ec2db Compare August 13, 2020 17:00
@dgaikwad dgaikwad changed the title [WIPTEST] - Check STDOUT of provisioned ansible service [RFR] - Check STDOUT of provisioned ansible service Aug 17, 2020
cfme/tests/configure/test_access_control.py Show resolved Hide resolved
@pytest.mark.meta(coverage=[1836125])
def test_ansible_playbook_stdout():
""" Test standard output of ansible playbook of particular user
@pytest.mark.meta(automate=[1836125])
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: automates

ansible_service.delete()
ansible_catalog.delete_if_exists()

with user:
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried putting everything under with user block?

with user:
    with appliance.context.use(ViaSSUI):
            appliance.server.login(user)
            ...
            ...
    error_message = (
            "MIQ(Api::TasksController.api_error) Api::NotFoundError: Couldn't find MiqTask with"
        )
        with LogValidator(
                "/var/www/miq/vmdb/log/api.log", failure_patterns=[error_message],
        ).waiting(timeout=120):
            ...
            ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because context is different.

Comment on lines 3061 to 3063
view = ssui_nav(service_catalog, "Details")
view.add_to_shopping_cart.click()
service_catalog.order()
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to navigate to details page and click on shopping cart, you can just do service_catalog.order().

Suggested change
view = ssui_nav(service_catalog, "Details")
view.add_to_shopping_cart.click()
service_catalog.order()
service_catalog.order()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to explicitly add service in the catalog service_catalog.order() don't add

@@ -242,6 +247,26 @@ def tenant_custom_role(appliance, request, provider):
tenant_role.delete_if_exists()


@pytest.fixture()
def user_catalog(appliance, request, ansible_catalog_item):
group = appliance.rest_api.collections.groups.get(description="EvmGroup-user_self_service")
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional - You can just assign group description to a variable instead of instantiating the group since you're only using group description.

@valaparthvi valaparthvi changed the title [RFR] - Check STDOUT of provisioned ansible service [WIPTEST - Check STDOUT of provisioned ansible service Aug 17, 2020
@valaparthvi valaparthvi changed the title [WIPTEST - Check STDOUT of provisioned ansible service [WIPTEST] - Check STDOUT of provisioned ansible service Aug 17, 2020
@dgaikwad dgaikwad force-pushed the test_ansible_playbook_stdout branch from 18ec2db to d5f695f Compare August 17, 2020 10:33
@dgaikwad dgaikwad changed the title [WIPTEST] - Check STDOUT of provisioned ansible service RFR] - Check STDOUT of provisioned ansible service Aug 17, 2020
@dgaikwad dgaikwad changed the title RFR] - Check STDOUT of provisioned ansible service [RFR] - Check STDOUT of provisioned ansible service Aug 17, 2020
@dgaikwad dgaikwad changed the title [RFR] - Check STDOUT of provisioned ansible service [WIPTEST] - Check STDOUT of provisioned ansible service Aug 17, 2020
@dgaikwad dgaikwad force-pushed the test_ansible_playbook_stdout branch from d5f695f to eba58b3 Compare August 17, 2020 11:53
@dajoRH
Copy link
Contributor

dajoRH commented Aug 17, 2020

I detected some fixture changes in commit eba58b3

The local fixture user_catalog is used in the following files:

  • cfme/tests/configure/test_access_control.py

Please, consider creating a PRT run to make sure your fixture changes do not break existing usage 😃

@dgaikwad dgaikwad changed the title [WIPTEST] - Check STDOUT of provisioned ansible service [RFR] - Check STDOUT of provisioned ansible service Aug 17, 2020
@valaparthvi valaparthvi changed the title [RFR] - Check STDOUT of provisioned ansible service [1LP][RFR] - Check STDOUT of provisioned ansible service Aug 17, 2020
@mshriver
Copy link
Member

mshriver commented Aug 17, 2020

Updated pytest options in description to include cfme/tests/ansible/test_embedded_ansible_services.py::test_service_ansible_playbook_pass_extra_vars, which is using the widget with the modified locator. This should help validating that the locator modification will not impact existing tests.

@dgaikwad I saw some failures in PRT after including that test, blocking verification of the widget behavior.

Check out #10299, where I moved all ansible service requests to use the function scoped fixture.

service_catalog = ServiceCatalogs(appliance, ansible_catalog, ansible_catalog_item.name)
ansible_service = MyService(appliance, ansible_catalog_item.name)

@request.addfinalizer
Copy link
Member

Choose a reason for hiding this comment

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

If you rebase this onto 10299, this finalizer will no longer be necessary.

@@ -3024,4 +3049,33 @@ def test_ansible_playbook_stdout():
9.
10. able to see standard output
"""
pass
user, ansible_catalog = user_catalog
service_catalog = ServiceCatalogs(appliance, ansible_catalog, ansible_catalog_item.name)
Copy link
Member

Choose a reason for hiding this comment

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

There are fixtures to provide for and cleanup both of these instances.

Copy link
Member

@mshriver mshriver left a comment

Choose a reason for hiding this comment

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

#10299 should follow this, I'll end up changing some things that you have here, but the test content and the new view is good!

@mshriver mshriver merged commit 2a89956 into ManageIQ:master Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement test-automation To be applied on PR's which are automating existing manual cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants