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

[1LP][RFR] Automate: test_retire_multiple_services #10107

Merged
merged 1 commit into from
May 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cfme/common/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def rename(self, new_vm_name, cancel=False, reset=False):

@property
def rest_api_entity(self):
# This will not work if the VM has retired since we filter using provider
collection = "instances" if self.VM_TYPE == "Instance" else "vms"
try:
return (
Expand Down
3 changes: 2 additions & 1 deletion cfme/fixtures/service_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def catalog_modscope(request, appliance):


@pytest.fixture(scope="function")
def catalog_item(appliance, provider, provisioning, dialog, catalog):
def catalog_item(appliance, provider, provisioning, dialog, catalog, request):
catalog_item = create_catalog_item(appliance, provider, provisioning, dialog, catalog)
request.addfinalizer(catalog_item.delete_if_exists)
return catalog_item


Expand Down
28 changes: 12 additions & 16 deletions cfme/rest/gen_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,22 @@ def dialog(request, appliance):
return service_dialog


def services(request, appliance, provider, service_dialog=None, service_catalog=None):
def services(
request, appliance, provider, service_dialog=None, service_catalog=None, service_template=None
):
"""
The attempt to add the service entities via web
"""
service_template = service_templates_ui(
request,
appliance,
service_dialog=service_dialog,
service_catalog=service_catalog,
provider=provider,
num=1
)
if not service_template:
service_template = service_templates_ui(
request,
appliance,
service_dialog=service_dialog,
service_catalog=service_catalog,
provider=provider,
num=1
)[0]

service_template = service_template[0]
service_catalog = appliance.rest_api.get_entity(
'service_catalogs',
service_template.service_template_catalog_id
Expand Down Expand Up @@ -229,7 +231,6 @@ def service_templates_ui(request, appliance, service_dialog=None, service_catalo
cat_items_col = appliance.collections.catalog_items
catalog_item_type = provider.catalog_item_type if provider else cat_items_col.GENERIC

catalog_items = []
new_names = []
for _ in range(num):
if provider:
Expand Down Expand Up @@ -267,9 +268,6 @@ def service_templates_ui(request, appliance, service_dialog=None, service_catalo
prov_data=provisioning_data
)

for catalog_item in catalog_items:
catalog_item.create()

collection = appliance.rest_api.collections.service_templates

for new_name in new_names:
Expand Down Expand Up @@ -323,8 +321,6 @@ def service_templates_rest(request, appliance, service_dialog=None, service_cata


def service_templates(request, appliance, service_dialog=None, service_catalog=None, num=4):
# TODO: remove, because it copies service_templates_rest for supported versions.
# tmplt = service_templates_ui if appliance.version < '5.8' else service_templates_rest
return service_templates_rest(
request, appliance, service_dialog=service_dialog, service_catalog=service_catalog, num=num)

Expand Down
40 changes: 35 additions & 5 deletions cfme/tests/services/test_myservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from cfme.fixtures.automate import DatastoreImport
from cfme.infrastructure.provider.virtualcenter import VMwareProvider
from cfme.markers.env_markers.provider import ONE_PER_TYPE
from cfme.rest.gen_data import services as _services
from cfme.services.myservice import MyService
from cfme.services.myservice.ui import MyServiceDetailView
from cfme.services.service_catalogs import ServiceCatalogs
Expand Down Expand Up @@ -265,11 +266,31 @@ def test_service_load():
pass


@pytest.mark.meta(coverage=[1722194])
@pytest.mark.manual
@pytest.mark.ignore_stream('5.10')
@pytest.fixture
def services_vms_list(appliance, request, provider, catalog_item):
ui_services, vms = [], []
service_template = appliance.rest_api.collections.service_templates.get(name=catalog_item.name)

for num in range(1, 3):
rest_service = _services(
request, appliance, provider=provider, service_template=service_template
)[0]
ui_services.append(
MyService(appliance, name=rest_service.name, description=rest_service.description)
)
vms.append(
appliance.rest_api.collections.vms.get(
name=f'{catalog_item.prov_data["catalog"]["vm_name"]}000{num}'
)
)

return ui_services, vms


@pytest.mark.meta(automates=[1722194])
@pytest.mark.ignore_stream("5.10")
@pytest.mark.tier(2)
def test_retire_multiple_services():
def test_retire_multiple_services(services_vms_list):
"""
Bugzilla:
1722194
Expand All @@ -289,7 +310,16 @@ def test_retire_multiple_services():
3.
4. Services should retire and vms as well
"""
pass
services, vms = services_vms_list
view = navigate_to(services[0], "All")
[entity.check() for entity in view.entities.get_all(services[0].name)]
view.toolbar.lifecycle.item_select("Retire selected items", handle_alert=True)
wait_for(
lambda: all([service.rest_api_entity.retired for service in services]),
delay=5,
timeout=600,
)
assert all([vm.retired for vm in vms])


@pytest.mark.meta(coverage=[1718102, 1718898, 1741327])
Expand Down