def _cleanup(appliance=None, provision_request=None, service=None): if not service: last_message = provision_request.get_request_row_from_ui( )['Last Message'].text service_name = last_message.split()[2].strip('[]') myservice = MyService(appliance, service_name) else: myservice = service if myservice.exists: myservice.delete()
def test_download_file(appliance, context, needs_firefox, myservice, filetype): """Tests my service download files Metadata: test_flag: provision """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) myservice.download_file(filetype)
def test_retire_service_ui(appliance, context, myservice): """Tests my service Metadata: test_flag: provision """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) myservice.retire()
def test_no_error_while_fetching_the_service(request, appliance, user_self_service_role, generic_catalog_item): """ Bugzilla: 1677744 Polarion: assignee: nansari startsin: 5.10 casecomponent: SelfServiceUI initialEstimate: 1/6h testSteps: 1. Provision service in regular UI with user that isn't admin 2. Delete user, then go view the service in the SUI and see if it blows up. expectedResults: 1. 2. In SUI click on provisioned service """ user, _ = user_self_service_role # login with user having self service role with user: with appliance.context.use(ViaUI): appliance.server.login(user) # Order service from catalog item serv_cat = ServiceCatalogs( appliance, catalog=generic_catalog_item.catalog, name=generic_catalog_item.name, ) provision_request = serv_cat.order() provision_request.wait_for_request() # Check service with user service = MyService(appliance, generic_catalog_item.dialog.label) assert service.exists @request.addfinalizer def _clear_service(): if service.exists: service.delete() # Delete user # Note: before deleting user need to clean respected user requests provision_request.remove_request(method="rest") user.delete() assert not user.exists # Check service exist without user or not for context in [ViaUI, ViaSSUI]: with appliance.context.use(context): assert service.exists
def test_generic_objects_crud(appliance, context, request): """ Polarion: assignee: jdupuy initialEstimate: 1/4h tags: 5.9 casecomponent: GenericObjects """ with appliance.context.use(context): definition = appliance.collections.generic_object_definitions.create( name='rest_generic_class{}'.format(fauxfactory.gen_alphanumeric()), description='Generic Object Definition', attributes={'addr01': 'string'}, associations={'services': 'Service'}) assert definition.exists request.addfinalizer(definition.delete) with appliance.context.use(ViaREST): myservices = [] for _ in range(2): service_name = 'rest_service_{}'.format( fauxfactory.gen_alphanumeric()) rest_service = appliance.rest_api.collections.services.action.create( name=service_name, display=True) rest_service = rest_service[0] request.addfinalizer(rest_service.action.delete) myservices.append(MyService(appliance, name=service_name)) instance = appliance.collections.generic_objects.create( name='rest_generic_instance{}'.format( fauxfactory.gen_alphanumeric()), definition=definition, attributes={'addr01': 'Test Address'}, associations={'services': [myservices[0]]}) request.addfinalizer(instance.delete) with appliance.context.use(context): if context.name == 'UI': # we need to refresh definition page to update instance count, # as navigation to instance details happens via this page appliance.browser.widgetastic.refresh() assert instance.exists with appliance.context.use(ViaREST): with update(instance): instance.attributes = {'addr01': 'Changed'} instance.associations = {'services': myservices} rest_instance = appliance.rest_api.collections.generic_objects.get( name=instance.name) rest_data = appliance.rest_api.get('{}?associations=services'.format( rest_instance.href)) assert len(rest_data['services']) == 2 assert rest_data['property_attributes']['addr01'] == 'Changed' instance.delete() with appliance.context.use(context): assert not instance.exists
def test_retire_service_ssui(appliance, setup_provider, context, order_service, request): """Test retire service.""" catalog_item = order_service with appliance.context.use(context): my_service = MyService(appliance, catalog_item.name) my_service.retire() @request.addfinalizer def _finalize(): my_service.delete()
def test_myservice_crud(appliance, setup_provider, context, order_catalog_item_in_ops_ui): """Test Myservice crud in SSUI.""" service_name = order_catalog_item_in_ops_ui.name with appliance.context.use(context): my_service = MyService(appliance, service_name) my_service.set_ownership("Administrator", "EvmGroup-approver") my_service.update({'description': '{}_edited'.format(service_name)}) # No tag management in 5.7 if appliance.version > "5.8": my_service.edit_tags("Cost Center", "Cost Center 001") my_service.delete()
def test_retire_service_on_date(appliance, context, myservice): """Tests my service retirement Metadata: test_flag: provision """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) dt = datetime.utcnow() myservice.retire_on_date(dt)
def prov_req_cleanup(appliance, provision_request): provision_request.update() svc_name = wait_for( func=guess_svc_name, func_args=(provision_request,), fail_func=provision_request.update, fail_condition=None, timeout='5m').out myservice = MyService(appliance, name=svc_name) svc_cleanup(myservice)
def generic_object(definition, service, appliance): myservice = MyService(appliance, name=service.name) with appliance.context.use(ViaREST): instance = appliance.collections.generic_objects.create( name='rest_generic_instance{}'.format( fauxfactory.gen_alphanumeric()), definition=definition, attributes={'addr01': 'Test Address'}, associations={'services': [myservice]}) instance.my_service = myservice yield instance instance.delete_if_exists()
def test_service_ansible_service_name(request, appliance, dialog_with_catalog_item): """ After creating the service using ansible playbook type add a new text field to service dialog named "service_name" and then use that service to order the service which will have a different name than the service catalog item. Bugzilla: 1505929 Polarion: assignee: gtalreja casecomponent: Ansible caseimportance: medium initialEstimate: 1/2h tags: ansible_embed """ ele_name = "service_name" # Extracting Ansible Catalog Item and Element name from fixture. ansible_cat_item, ansible_catalog = dialog_with_catalog_item(ele_name) # Navigate to Service Catalog order page. service_catalogs = ServiceCatalogs(appliance, ansible_catalog, ansible_cat_item.name) view = navigate_to(service_catalogs, 'Order') # Fill the different than the dialog name and order service. service_name = fauxfactory.gen_alphanumeric(20, start="diff_service_name") view.fields(ele_name).fill(service_name) time.sleep(5) view.submit_button.click() # Service name is updated so ansible_service_request will not work. request_descr = ( f"Provisioning Service [{ansible_cat_item.name}] from [{ansible_cat_item.name}]" ) service_request = appliance.collections.requests.instantiate( description=request_descr) service_request.wait_for_request() # Tear down for service_request and service with different name. @request.addfinalizer def _revert(): if service_request.exists: service_request.wait_for_request() service_request.remove_request() if service.exists: service.delete() # Go to Ordered service page and assert new name of service. service = MyService(appliance, service_name) assert service.exists
def unassigned_btn_setup(request, appliance, provider, service): if request.param == "Service": obj = MyService(appliance, name=service.name) destinations = [ViaUI, ViaSSUI] else: # only service is different than other custom button object so selecting one i.e. provider obj = provider destinations = [ViaUI] gp = appliance.collections.button_groups.instantiate( text="[Unassigned Buttons]", hover="Unassigned buttons", type=request.param ) yield obj, gp, destinations
def _revert(): with update(local_ansible_catalog_item): local_ansible_catalog_item.provisioning = { "playbook": "dump_all_variables.yml", "cloud_type": "<Choose>", } service = MyService(appliance, local_ansible_catalog_item.name) if service_request.exists(): service_request.wait_for_request() appliance.rest_api.collections.service_requests.action.delete(id=service_id.id) if service.exists: service.delete()
def test_download_file(appliance, context, needs_firefox, myservice, filetype): """Tests my service download files Metadata: test_flag: provision Polarion: assignee: nansari initialEstimate: 1/16h """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) myservice.download_file(filetype)
def test_service_link(appliance, context, myservice): """Tests service link from VM details page(BZ1443772) Polarion: assignee: sshveta initialEstimate: 1/4h """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) view = navigate_to(myservice, 'VMDetails') view.summary('Relationships').click_at('Service') new_view = myservice.create_view(MyServiceDetailView) assert new_view.is_displayed
def test_myservice_crud(appliance, setup_provider, context, order_service): """Test Myservice crud in SSUI. Metadata: test_flag: ssui, services """ catalog_item = order_service with appliance.context.use(context): my_service = MyService(appliance, catalog_item.name) my_service.set_ownership("Administrator", "EvmGroup-approver") my_service.update({'description': '{}_edited'.format(catalog_item.name)}) if appliance.version > "5.8": my_service.edit_tags("Cost Center", "Cost Center 001") my_service.delete()
def test_retire_service_ui(appliance, context, myservice): """Tests my service Metadata: test_flag: provision Polarion: assignee: sshveta initialEstimate: None """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) myservice.retire()
def order_ansible_service_in_ops_ui(appliance, ansible_catalog_item, ansible_service_catalog): """Tests if ansible playbook service provisioning is shown in service requests.""" ansible_service_catalog.order() cat_item_name = ansible_catalog_item.name request_descr = "Provisioning Service [{0}] from [{0}]".format(cat_item_name) service_request = appliance.collections.requests.instantiate(description=request_descr) if service_request.exists(): service_request.wait_for_request() if not BZ(1646333, forced_streams=['5.10']).blocks: service_request.remove_request() yield cat_item_name service = MyService(appliance, cat_item_name) if service.exists: service.delete()
def test_retire_ansible_service(appliance, catalog_item, request): """Tests order catalog item Metadata: test_flag: provision """ 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) cells = {'Description': catalog_item.name} order_request = appliance.collections.requests.instantiate(cells=cells, partial_check=True) order_request.wait_for_request(method='ui') msg = "Request failed with the message {}".format(order_request.row.last_message.text) assert order_request.is_succeeded(method='ui'), msg myservice = MyService(appliance, catalog_item.name) myservice.retire()
def test_reconfigure_service(appliance, service_catalogs, request): """Tests service reconfiguring Metadata: test_flag: provision """ provision_request = service_catalogs.order() provision_request.wait_for_request(method='ui') last_message = provision_request.get_request_row_from_ui( )['Last Message'].text service_name = last_message.split()[2].strip('[]') myservice = MyService(appliance, service_name) request.addfinalizer(lambda: _cleanup(service=myservice)) assert provision_request.is_succeeded() myservice.reconfigure_service()
def test_retire_service_on_date(appliance, context, myservice): """Tests my service retirement Metadata: test_flag: provision Polarion: assignee: sshveta initialEstimate: 1/4h """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) dt = datetime.utcnow() myservice.retire_on_date(dt)
def test_retire_ansible_service(catalog_item, request): """Tests order catalog item Metadata: test_flag: provision """ catalog_item.create() service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name) service_catalogs.order() logger.info('Waiting for cfme provision request for service %s', catalog_item.name) cells = {'Description': catalog_item.name} order_request = Request(cells=cells, partial_check=True) order_request.wait_for_request(method='ui') assert order_request.is_succeeded() myservice = MyService(catalog_item.name) myservice.retire()
def test_crud_set_ownership_and_edit_tags(appliance, context, myservice): """Tests my service crud , edit tags and ownership Metadata: test_flag: provision """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) myservice.set_ownership("Administrator", "EvmGroup-administrator") myservice.add_tag("Cost Center *", "Cost Center 001") with update(myservice): myservice.description = "my edited description" myservice.delete()
def test_retire_service_ui(appliance, context, myservice): """Tests my service Metadata: test_flag: provision Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/4h tags: service """ service_name, vm_name = myservice with appliance.context.use(context): myservice = MyService(appliance, name=service_name, vm_name=vm_name) myservice.retire()
def test_service_state(request, appliance, provider, catalog_item, check): """ Bugzilla: 1678123 Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/16h startsin: 5.11 testSteps: 1. Create catalog and catalog item 2. Order the catalog item 3. Provision the service catalog item or fail the service catalog item 4. Go to My services and check service state expectedResults: 1. 2. 3. 4. Service State should be Provisioned or Failed """ service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name) service = MyService(appliance, catalog_item.name) service_request = service_catalogs.order() @request.addfinalizer def _finalize(): service.delete() if check == "provisioned": expected_state = "Provisioned" service_request.wait_for_request(method="ui", num_sec=200 * 60, delay=120) else: expected_state = "Unprovisioned" # Delete Provider while service is provisioning provider.delete_rest() provider.wait_for_delete() view = navigate_to(service, "Details") wait_for( lambda: view.entities.lifecycle.get_text_of("State") == expected_state, fail_condition=0, num_sec=300, fail_func=view.browser.refresh)
def generic_object(generic_definition, gen_rest_service, appliance): """Generic object associated with service""" myservice = MyService(appliance, name=gen_rest_service.name) with appliance.context.use(ViaREST): instance = appliance.collections.generic_objects.create( name=fauxfactory.gen_numeric_string(20, start="gen_rest_instance", separator="-"), definition=generic_definition, attributes={"addr01": "Test Address"}, associations={"services": [gen_rest_service]}, ) instance.my_service = myservice yield instance instance.delete_if_exists()
def test_services_performance(appliance_with_performance_db): """ Polarion: assignee: jhenner initialEstimate: 1/4h casecomponent: Services Bugzilla: 1688937 1686433 """ app = appliance_with_performance_db assert 50000 == app.rest_api.collections.services.count my_service = MyService(app) # Timeit seems to accept callable as well as string of Python code on cPython. assert timeit(lambda: navigate_to(my_service, 'All', use_resetter=False), number=1) < 180
def test_retire_ansible_service(catalog_item, request): """Tests order catalog item Metadata: test_flag: provision """ catalog_item.create() service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name) service_catalogs.order() logger.info('Waiting for cfme provision request for service %s', catalog_item.name) cells = {'Description': catalog_item.name} row, __ = wait_for(requests.wait_for_request, [cells, True], fail_func=requests.reload, num_sec=1400, delay=20) assert 'Provisioned Successfully' in row.last_message.text myservice = MyService(catalog_item.name) myservice.retire()
def order_ansible_service_in_ops_ui(appliance, ansible_catalog_item, ansible_service_catalog): """Orders an ansible service through the UI Deletes the service request after completion, as well as the service """ ansible_service_catalog.order() cat_item_name = ansible_catalog_item.name request_descr = "Provisioning Service [{0}] from [{0}]".format( cat_item_name) service_request = appliance.collections.requests.instantiate( description=request_descr) if service_request.exists(): service_request.wait_for_request() if not BZ(1646333, forced_streams=['5.10']).blocks: service_request.remove_request() yield cat_item_name service = MyService(appliance, cat_item_name) if service.exists: service.delete()
def test_myservice_crud(appliance, setup_provider, context, order_service): """Test Myservice crud in SSUI. Metadata: test_flag: ssui, services Polarion: assignee: nansari casecomponent: SelfServiceUI initialEstimate: 1/4h tags: ssui """ catalog_item = order_service with appliance.context.use(context): my_service = MyService(appliance, catalog_item.name) my_service.set_ownership("Administrator", "EvmGroup-approver") my_service.update({'description': f'{catalog_item.name}_edited'}) my_service.edit_tags("Cost Center", "Cost Center 002") my_service.delete()