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

Commit

Permalink
Fix test_ansible_service_linked_vm
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravtalreja1 committed May 6, 2020
1 parent a97c9d7 commit 2f65347
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
37 changes: 33 additions & 4 deletions cfme/fixtures/ansible_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,34 @@ def ansible_catalog_item(appliance, ansible_repository):
cat_item.delete_if_exists()


@pytest.fixture(scope="function")
def ansible_catalog_item_funcscope(appliance, ansible_repository):
collection = appliance.collections.catalog_items
cat_item = collection.create(
collection.ANSIBLE_PLAYBOOK,
fauxfactory.gen_alphanumeric(),
fauxfactory.gen_alphanumeric(),
display_in_catalog=True,
provisioning={
"repository": ansible_repository.name,
"playbook": "dump_all_variables.yml",
"machine_credential": "CFME Default Credential",
"create_new": True,
"provisioning_dialog_name": fauxfactory.gen_alphanumeric(),
"extra_vars": [("some_var", "some_value")]
},
retirement={
"repository": ansible_repository.name,
"playbook": "dump_all_variables.yml",
"machine_credential": "CFME Default Credential",
"extra_vars": [("some_var", "some_value")]
}
)
yield cat_item

cat_item.delete_if_exists()


@pytest.fixture(scope="module")
def ansible_catalog(appliance, ansible_catalog_item):
catalog = appliance.collections.catalogs.create(fauxfactory.gen_alphanumeric(),
Expand All @@ -165,8 +193,9 @@ def ansible_service_catalog(appliance, ansible_catalog_item, ansible_catalog):


@pytest.fixture(scope="function")
def ansible_service_request_funcscope(appliance, ansible_catalog_item):
request_descr = "Provisioning Service [{0}] from [{0}]".format(ansible_catalog_item.name)
def ansible_service_request_funcscope(appliance, ansible_catalog_item_funcscope):
request_descr = (f"Provisioning Service [{ansible_catalog_item_funcscope}]"
"from [{ansible_catalog_item_funcscope}]")
service_request = appliance.collections.requests.instantiate(description=request_descr)
yield service_request

Expand All @@ -176,8 +205,8 @@ def ansible_service_request_funcscope(appliance, ansible_catalog_item):


@pytest.fixture(scope="function")
def ansible_service_funcscope(appliance, ansible_catalog_item):
service = MyService(appliance, ansible_catalog_item.name)
def ansible_service_funcscope(appliance, ansible_catalog_item_funcscope):
service = MyService(appliance, ansible_catalog_item_funcscope.name)
yield service

if service.exists:
Expand Down
18 changes: 9 additions & 9 deletions cfme/tests/ansible/test_embedded_ansible_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ def _finalize():


@pytest.fixture()
def ansible_linked_vm_action(appliance, local_ansible_catalog_item, create_vm):
with update(local_ansible_catalog_item):
local_ansible_catalog_item.provisioning = {"playbook": "add_single_vm_to_service.yml"}
def ansible_linked_vm_action(appliance, ansible_catalog_item_funcscope, create_vm):
with update(ansible_catalog_item_funcscope):
ansible_catalog_item_funcscope.provisioning = {"playbook": "add_single_vm_to_service.yml"}

action_values = {
"run_ansible_playbook": {
"playbook_catalog_item": local_ansible_catalog_item.name,
"playbook_catalog_item": ansible_catalog_item_funcscope.name,
"inventory": {"specific_hosts": True, "hosts": create_vm.ip_address},
}
}
Expand Down Expand Up @@ -858,8 +858,8 @@ def test_ansible_service_linked_vm(
appliance,
create_vm,
ansible_policy_linked_vm,
ansible_service_request,
ansible_service,
ansible_service_request_funcscope,
ansible_service_funcscope,
request,
):
"""Check Whether service has associated VM attached to it.
Expand All @@ -874,10 +874,10 @@ def test_ansible_service_linked_vm(
tags: ansible_embed
"""
create_vm.add_tag()
wait_for(ansible_service_request.exists, num_sec=600)
ansible_service_request.wait_for_request()
wait_for(ansible_service_request_funcscope.exists, num_sec=600)
ansible_service_request_funcscope.wait_for_request()

view = navigate_to(ansible_service, "Details")
view = navigate_to(ansible_service_funcscope, "Details")
assert create_vm.name in view.entities.vms.all_entity_names


Expand Down

0 comments on commit 2f65347

Please sign in to comment.