diff --git a/cfme/fixtures/service_fixtures.py b/cfme/fixtures/service_fixtures.py index 390e31ba15..98bb4d9d38 100644 --- a/cfme/fixtures/service_fixtures.py +++ b/cfme/fixtures/service_fixtures.py @@ -184,7 +184,7 @@ def service_vm(appliance, provider, catalog_item): collection = provider.appliance.provider_based_collection(provider) vm_name = "{}0001".format(catalog_item.prov_data["catalog"]["vm_name"]) - vm = collection.instantiate("{}0001".format(vm_name), provider) + vm = collection.instantiate("{}".format(vm_name), provider) service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name) provision_request = service_catalogs.order() diff --git a/cfme/tests/services/test_myservice.py b/cfme/tests/services/test_myservice.py index e5f9b1735a..444875f224 100644 --- a/cfme/tests/services/test_myservice.py +++ b/cfme/tests/services/test_myservice.py @@ -6,16 +6,15 @@ from cfme import test_requirements from cfme.infrastructure.provider.virtualcenter import VMwareProvider from cfme.markers.env_markers.provider import ONE_PER_TYPE -from cfme.services.myservice import MyService from cfme.services.myservice.ui import MyServiceDetailView -from cfme.services.service_catalogs import ServiceCatalogs from cfme.utils import browser from cfme.utils.appliance import ViaUI from cfme.utils.appliance.implementations.ui import navigate_to +from cfme.utils.blockers import BZ from cfme.utils.browser import ensure_browser_open -from cfme.utils.log import logger from cfme.utils.update import update from cfme.utils.version import appliance_is_downstream +from cfme.utils.wait import wait_for pytestmark = [ pytest.mark.usefixtures('setup_provider', 'catalog_item'), @@ -38,31 +37,8 @@ def needs_firefox(): pytest.skip(msg="This test needs firefox to run") -@pytest.fixture(scope='function') -def myservice(appliance, provider, catalog_item, request): - """Tests my service - - Metadata: - test_flag: provision - """ - vm_name = catalog_item.prov_data["catalog"]["vm_name"] + '0001' - service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name) - service_catalogs.order() - logger.info('Waiting for cfme provision request for service %s', catalog_item.name) - request_description = catalog_item.name - service_request = appliance.collections.requests.instantiate(request_description, - partial_check=True) - service_request.wait_for_request() - assert service_request.is_succeeded(),\ - ("Request failed with the message {}".format(service_request.rest.message)) - - yield catalog_item.name, vm_name - - appliance.collections.infra_vms.instantiate(vm_name, provider).cleanup_on_provider() - - @pytest.mark.parametrize('context', [ViaUI]) -def test_retire_service_ui(appliance, context, myservice): +def test_retire_service_ui(appliance, context, service_vm): """Tests my service Metadata: @@ -74,14 +50,13 @@ def test_retire_service_ui(appliance, context, myservice): initialEstimate: 1/4h tags: service """ - service_name, vm_name = myservice + service, _ = service_vm with appliance.context.use(context): - myservice = MyService(appliance, name=service_name, vm_name=vm_name) - myservice.retire() + service.retire() @pytest.mark.parametrize('context', [ViaUI]) -def test_retire_service_on_date(appliance, context, myservice): +def test_retire_service_on_date(appliance, context, service_vm): """Tests my service retirement Metadata: @@ -93,15 +68,14 @@ def test_retire_service_on_date(appliance, context, myservice): initialEstimate: 1/4h tags: service """ - service_name, vm_name = myservice + service, _ = service_vm with appliance.context.use(context): - myservice = MyService(appliance, name=service_name, vm_name=vm_name) dt = datetime.utcnow() - myservice.retire_on_date(dt) + service.retire_on_date(dt) @pytest.mark.parametrize('context', [ViaUI]) -def test_crud_set_ownership_and_edit_tags(appliance, context, myservice): +def test_crud_set_ownership_and_edit_tags(appliance, context, service_vm): """Tests my service crud , edit tags and ownership Metadata: @@ -114,21 +88,20 @@ def test_crud_set_ownership_and_edit_tags(appliance, context, myservice): tags: service """ - service_name, vm_name = myservice + service, _ = service_vm with appliance.context.use(context): - myservice = MyService(appliance, name=service_name, vm_name=vm_name) - myservice.set_ownership("Administrator", "EvmGroup-administrator") - myservice.add_tag() - with update(myservice): - myservice.description = "my edited description" - myservice.delete() + service.set_ownership("Administrator", "EvmGroup-administrator") + service.add_tag() + with update(service): + service.description = "my edited description" + service.delete() @pytest.mark.parametrize('context', [ViaUI]) @pytest.mark.parametrize("filetype", ["Text", "CSV", "PDF"]) # PDF not present on upstream @pytest.mark.uncollectif(lambda filetype: filetype == 'PDF' and not appliance_is_downstream()) -def test_download_file(appliance, context, needs_firefox, myservice, filetype): +def test_download_file(appliance, context, needs_firefox, service_vm, filetype): """Tests my service download files Metadata: @@ -140,14 +113,13 @@ def test_download_file(appliance, context, needs_firefox, myservice, filetype): initialEstimate: 1/16h tags: service """ - service_name, vm_name = myservice + service, _ = service_vm with appliance.context.use(context): - myservice = MyService(appliance, name=service_name, vm_name=vm_name) - myservice.download_file(filetype) + service.download_file(filetype) @pytest.mark.parametrize('context', [ViaUI]) -def test_service_link(appliance, context, myservice, provider): +def test_service_link(appliance, context, service_vm): """Tests service link from VM details page(BZ1443772) Polarion: @@ -156,20 +128,46 @@ def test_service_link(appliance, context, myservice, provider): initialEstimate: 1/4h tags: service """ - service_name, vm_name = myservice + service, vm = service_vm with appliance.context.use(context): # TODO: Update to nav to MyService first to click entity link when widget exists - myservice = MyService(appliance, name=service_name, vm_name=vm_name) - vm = appliance.provider_based_collection(coll_type='vms', provider=provider).instantiate( - name=myservice.vm_name, - provider=provider - ) view = navigate_to(vm, 'Details') view.entities.summary('Relationships').click_at('Service') - new_view = myservice.create_view(MyServiceDetailView) + new_view = service.create_view(MyServiceDetailView) assert new_view.wait_displayed() +@pytest.mark.parametrize('context', [ViaUI]) +@pytest.mark.meta(automates=[BZ(1720338)]) +def test_retire_service_with_retired_vm(appliance, context, service_vm): + """Tests retire service with an already retired vm. + + Metadata: + test_flag: provision + + Polarion: + assignee: nansari + casecomponent: Services + initialEstimate: 1/4h + tags: service + + Bugzilla: + 1720338 + """ + service, vm = service_vm + vm.retire() + # using rest entity to check if the VM has retired since it is a lot faster + retire_vm = appliance.rest_api.collections.vms.get(name=vm.name) + wait_for( + lambda: (hasattr(retire_vm, "retired") and retire_vm.retired), + timeout=1000, + delay=5, + fail_func=retire_vm.reload, + ) + with appliance.context.use(context): + service.retire() + + @pytest.mark.manual @pytest.mark.tier(3) def test_retire_on_date_for_multiple_service():