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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file added cfme/rest/abc.py
Empty file.
36 changes: 36 additions & 0 deletions cfme/services/catalogs/catalog_items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from widgetastic_manageiq import FileInput
from widgetastic_manageiq import FonticonPicker
from widgetastic_manageiq import ManageIQTree
from widgetastic_manageiq import ReactSelect
from widgetastic_manageiq import SummaryForm
from widgetastic_manageiq import SummaryFormItem
from widgetastic_manageiq import SummaryTable
Expand Down Expand Up @@ -520,6 +521,32 @@ def set_additional_tenants(view, tenants):
else:
return False

def set_ownership(self, owner, group):
view = navigate_to(self, "SetOwnership")
view.form.select_an_owner.fill(owner)
view.form.select_group.fill(group)
view.submit.click()


class SetOwnershipView(ServicesCatalogView):
submit = Button("Submit")
reset = Button("Reset")
cancel = Button("Cancel")

@View.nested
class form(View):
select_an_owner = ReactSelect("user_name")
select_group = ReactSelect("group_name")

@property
def is_displayed(self):
return (
self.form.select_an_owner.is_displayed
and self.form.select_group.is_displayed
and self.submit.is_displayed
and self.cancel.is_enabled
)


@attr.s
class CloudInfraCatalogItem(BaseCatalogItem):
Expand Down Expand Up @@ -826,3 +853,12 @@ class EditTags(CFMENavigateStep):

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


@navigator.register(BaseCatalogItem, "SetOwnership")
class CatalogItemSetOwnership(CFMENavigateStep):
VIEW = SetOwnershipView
prerequisite = NavigateToSibling("Details")

def step(self, *args, **kwargs):
self.prerequisite_view.configuration.item_select("Set Ownership")
2 changes: 1 addition & 1 deletion cfme/services/myservice/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.


@View.nested
class retirement(View): # noqa
Expand Down
4 changes: 3 additions & 1 deletion cfme/tests/ansible/test_embedded_ansible_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,10 @@ def test_ansible_group_id_in_payload(
ansible_service_catalog.order()
ansible_service_request.wait_for_request()
view = navigate_to(ansible_service, "Details")
view.provisioning_tab.click()
assert view.provisioning.standart_output.is_displayed
wait_for(lambda: view.provisioning.standart_output.text != "Loading...", timeout=30)
stdout = view.provisioning.standart_output
wait_for(lambda: stdout.is_displayed, timeout=10)
pre = stdout.text
json_str = pre.split("--------------------------------")
# Standard output has several sections splitted by --------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cfme/tests/cli/test_appliance_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,8 +1746,8 @@ def test_appliance_overwrite_ssl_ipa(unconfigured_appliance, freeipa_provider):


@pytest.mark.tier(0)
@pytest.mark.manual
@pytest.mark.meta(coverage=[1720223])
@pytest.mark.manual("manualonly")
def test_appliance_console_logfile_config_reboot():
"""
test to verify logfiles disk
Expand Down
64 changes: 59 additions & 5 deletions cfme/tests/configure/test_access_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
from cfme.markers.env_markers.provider import ONE
from cfme.markers.env_markers.provider import ONE_PER_TYPE
from cfme.markers.env_markers.provider import SECOND
from cfme.rest.gen_data import users as _users
from cfme.roles import FEATURES_510
from cfme.roles import FEATURES_511
from cfme.services.myservice import MyService
from cfme.services.service_catalogs import ServiceCatalogs
from cfme.tests.integration.test_cfme_auth import retrieve_group
from cfme.utils.appliance import ViaSSUI
from cfme.utils.appliance.implementations.ui import navigate_to
from cfme.utils.auth import auth_user_data
from cfme.utils.blockers import BZ
Expand All @@ -29,6 +32,7 @@
from cfme.utils.update import update
from cfme.utils.version import LOWEST
from cfme.utils.version import VersionPicker
from cfme.utils.wait import wait_for


pytestmark = [
Expand Down Expand Up @@ -242,6 +246,25 @@ def tenant_custom_role(appliance, request, provider):
tenant_role.delete_if_exists()


@pytest.fixture()
def user_catalog(appliance, request, ansible_catalog_item):
user, user_data = _users(request, appliance, group="EvmGroup-user_self_service")

user_inst = appliance.collections.users.instantiate(
name=user[0].name,
credential=Credential(principal=user_data[0]["userid"], secret=user_data[0]["password"]),
)
ansible_catalog_item.set_ownership("Administrator", "EvmGroup-user_self_service")

ansible_catalog = appliance.collections.catalogs.create(
mshriver marked this conversation as resolved.
Show resolved Hide resolved
fauxfactory.gen_alphanumeric(),
description="my ansible catalog",
items=[ansible_catalog_item.name],
)

yield user_inst, ansible_catalog
ansible_catalog.delete_if_exists()

# User test cases
@pytest.mark.sauce
@pytest.mark.tier(2)
Expand Down Expand Up @@ -2985,9 +3008,11 @@ def test_chargeback_report():

@pytest.mark.customer_scenario
@pytest.mark.tier(2)
@pytest.mark.meta(coverage=[1836125])
def test_ansible_playbook_stdout():
""" Test standard output of ansible playbook of particular user
@pytest.mark.meta(automates=[1836125])
def test_ansible_playbook_stdout(
appliance, ansible_catalog_item, ansible_service_request, user_catalog, request
):
""" Test standard output of ansible playbook service using particular user
Bugzilla:
1836125
Polarion:
Expand All @@ -3009,7 +3034,7 @@ def test_ansible_playbook_stdout():
5. add service to shopping card
6. order service
7. log in main UI using newly created user
8. navigate Services->My Servcies>Service>
8. navigate Services->My Services>Service>
9. Under "Active catalog" click on ordered service
10. check stdout of service
expectedResults:
Expand All @@ -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.

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.

def _finalize():
if ansible_service_request.exists():
ansible_service_request.remove_request()
if ansible_service.exists:
ansible_service.delete()

with user:
with appliance.context.use(ViaSSUI):
appliance.server.login(user)
service_catalog.add_to_shopping_cart()
service_catalog.order()

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.

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):
ansible_service_request.wait_for_request()
view = navigate_to(ansible_service, "Details")
view.provisioning_tab.click()
assert view.provisioning.standart_output.is_displayed
wait_for(lambda: view.provisioning.standart_output.text != "Loading...", timeout=30)
assert "Hello World" in view.provisioning.standart_output.text