diff --git a/cfme/fixtures/service_fixtures.py b/cfme/fixtures/service_fixtures.py index 8423962a0b..30ac5426d0 100644 --- a/cfme/fixtures/service_fixtures.py +++ b/cfme/fixtures/service_fixtures.py @@ -19,7 +19,6 @@ from cfme.services.myservice import MyService from cfme.services.service_catalogs import ServiceCatalogs from cfme.utils.appliance import ViaUI -from cfme.utils.blockers import BZ from cfme.utils.conf import cfme_data from cfme.utils.ftp import FTPClientWrapper from cfme.utils.generators import random_vm_name @@ -80,7 +79,7 @@ def generic_catalog_item(request, appliance, dialog_modscope, catalog_modscope): def create_catalog_item(appliance, provider, provisioning, dialog, catalog, - console_test=False): + vm_count='1', console_test=False): provision_type, template, host, datastore, iso_file, vlan = map(provisioning.get, ('provision_type', 'template', 'host', 'datastore', 'iso_file', 'vlan')) if console_test: @@ -92,7 +91,8 @@ def create_catalog_item(appliance, provider, provisioning, dialog, catalog, provisioning_data = { 'catalog': {'catalog_name': {'name': catalog_name, 'provider': provider.name}, 'vm_name': random_vm_name('serv'), - 'provision_type': provision_type}, + 'provision_type': provision_type, + 'num_vms': vm_count}, 'environment': {'host_name': {'name': host}, 'datastore_name': {'name': datastore}}, 'network': {'vlan': partial_match(vlan)}, @@ -159,12 +159,16 @@ def create_catalog_item(appliance, provider, provisioning, dialog, catalog, @pytest.fixture def order_service(appliance, provider, provisioning, dialog, catalog, request): + # BZ 1646333 - Delete this request button is not shown in service Request details page + # The above BZ got closed because of INSUFFICIENT_DATA, so I havve reported the same issue + # in BZ 775779. """ Orders service once the catalog item is created""" - if hasattr(request, 'param'): - param = request.param + vm_count = request.param['vm_count'] if 'vm_count' in request.param else '1' + console_test = request.param['console_test'] if 'console_test' in request.param else False + catalog_item = create_catalog_item(appliance, provider, provisioning, dialog, catalog, - console_test=True if 'console_test' in param else None) + vm_count=vm_count, console_test=console_test) else: catalog_item = create_catalog_item(appliance, provider, provisioning, dialog, catalog) service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name) @@ -173,15 +177,17 @@ def order_service(appliance, provider, provisioning, dialog, catalog, request): assert provision_request.is_succeeded() if provision_request.exists(): provision_request.wait_for_request() - if not BZ(1646333, forced_streams=['5.10']).blocks: - provision_request.remove_request() + # Provision request is being removed through REST API because of BZ 775779. + provision_request.remove_request(method='rest') yield catalog_item service = MyService(appliance, catalog_item.name) if service.exists: service.delete() - vm_name = '{}0001'.format(catalog_item.prov_data['catalog']['vm_name']) - vm = appliance.collections.infra_vms.instantiate(vm_name, provider) - vm.cleanup_on_provider() + name = catalog_item.prov_data['catalog']['vm_name'] + for i in range(int(vm_count)): + vm_name = f'{name}000{i+1}' + vm = appliance.collections.infra_vms.instantiate(vm_name, provider) + vm.cleanup_on_provider() @pytest.fixture() diff --git a/cfme/tests/ssui/test_ssui_dashboard.py b/cfme/tests/ssui/test_ssui_dashboard.py index 8bfadac4af..7b2f5fb9c8 100644 --- a/cfme/tests/ssui/test_ssui_dashboard.py +++ b/cfme/tests/ssui/test_ssui_dashboard.py @@ -111,7 +111,7 @@ def verify_vm_uptime(appliance, provider, vmname): def run_service_chargeback_report(provider, appliance, assign_chargeback_rate, order_service): catalog_item = order_service - vmname = '{}0001'.format(catalog_item.prov_data['catalog']["vm_name"]) + vmname = catalog_item.prov_data['catalog']['vm_name'] def verify_records_rollups_table(appliance, provider): # Verify that hourly rollups are present in the metric_rollups table @@ -123,7 +123,8 @@ def verify_records_rollups_table(appliance, provider): result = ( appliance.db.client.session.query(rollups.id) .join(ems, rollups.parent_ems_id == ems.id) - .filter(rollups.capture_interval_name == 'hourly', rollups.resource_name == vmname, + .filter(rollups.capture_interval_name == 'hourly', + rollups.resource_name.contains(vmname), ems.name == provider.name, rollups.timestamp >= date.today()) ) @@ -235,6 +236,26 @@ def test_monthly_charges(appliance, has_no_providers_modscope, setup_provider, c assert monthly_charges != '$0' +@pytest.mark.long_running +@pytest.mark.parametrize('context', [ViaSSUI]) +@pytest.mark.parametrize('order_service', [{'vm_count': '1'}, {'vm_count': '2'}], indirect=True, + ids=['vm-count1', 'vm-count2']) +def test_service_chargeback_multiple_vms(appliance, has_no_providers_modscope, setup_provider, + context, order_service, run_service_chargeback_report): + """Tests chargeback data for a service with multiple VMs + Polarion: + assignee: nachandr + casecomponent: SelfServiceUI + caseimportance: high + initialEstimate: 1/2h + """ + with appliance.context.use(context): + dashboard = Dashboard(appliance) + monthly_charges = dashboard.monthly_charges() + logger.info(f'Monthly charges is {monthly_charges}') + assert monthly_charges != '$0' + + @pytest.mark.parametrize('context', [ViaSSUI]) def test_total_requests(appliance, context): """Tests total requests displayed. diff --git a/cfme/tests/ssui/test_ssui_myservice.py b/cfme/tests/ssui/test_ssui_myservice.py index b794229f9a..78dae96f3f 100644 --- a/cfme/tests/ssui/test_ssui_myservice.py +++ b/cfme/tests/ssui/test_ssui_myservice.py @@ -128,7 +128,7 @@ def _finalize(): @pytest.mark.long_running @pytest.mark.parametrize('context', [ViaSSUI]) -@pytest.mark.parametrize('order_service', [['console_test']], indirect=True) +@pytest.mark.parametrize('order_service', [{'console_test': True}], indirect=True) def test_vm_console(request, appliance, setup_provider, context, configure_websocket, configure_console_vnc, order_service, take_screenshot, console_template, provider):