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

Commit

Permalink
[RFR] SUI:Automate chargeback test for service with multiple VMs (#9648)
Browse files Browse the repository at this point in the history
* SUI:Automate chargeback test for service with multiple VMs

* SUI:Automate chargeback test for service with multiple VMs

* SUI:Automate chargeback test for service with multiple VMs

* SUI:Automate chargeback test for service with multiple VMs

* SUI:Automate chargeback test for service with multiple VMs

* SUI:Automate chargeback test for service with multiple VMs

* SUI:Automate chargeback test for service with multiple VMs

* SUI:Automate chargeback test for service with multiple VMs
  • Loading branch information
nachandr authored and mshriver committed Dec 4, 2019
1 parent e992445 commit 730c7a4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
28 changes: 17 additions & 11 deletions cfme/fixtures/service_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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)},
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
25 changes: 23 additions & 2 deletions cfme/tests/ssui/test_ssui_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
)

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cfme/tests/ssui/test_ssui_myservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 730c7a4

Please sign in to comment.