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

[1LP][RFR] Automate: test_quota_with_reconfigure_resize_disks #9891

Merged
merged 2 commits into from
Jan 30, 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
12 changes: 6 additions & 6 deletions cfme/configure/access_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,14 +1435,14 @@ def quota(self):
'num_vms': 'Allocated Number of Virtual Machines',
'templates': 'Allocated Number of Templates'
}

# This table does not work normally because of colspan, this is workaround for that problem.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table widget colspan implementation should support this, we need to take a look at what's happening here. Please open an issue against wt.core so we can debug.

for field in quotas:
item = view.table.row(name=quotas[field])
item = view.table.row((0, quotas[field]))
quotas[field] = {
'total': item.total_quota.text,
'in_use': item.in_use.text,
'allocated': item.allocated.text,
'available': item.available.text
'total': item[item.total_quota.position - 1].text,
'in_use': item[item.in_use.position - 1].text,
'allocated': item[item.allocated.position - 1].text,
'available': item[item.available.position - 1].text
}

return quotas
Expand Down
28 changes: 0 additions & 28 deletions cfme/tests/cloud_infra_common/test_quota_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,31 +205,3 @@ def test_orphaned_archived_vms_get_excluded_from_used_quota_counts():
1515979
"""
pass


@pytest.mark.tier(1)
@pytest.mark.ignore_stream("5.10")
@pytest.mark.meta(coverage=[1533263])
def test_quota_with_reconfigure_resize_disks():
"""Test that Quota gets checked against the resize of the disk of VMs.

Polarion:
assignee: ghubale
casecomponent: Infra
initialEstimate: 1/6h
testSteps:
1. Add VMware provider
2. Provision a VM
3. Set tenant quota limit for storage
4. Resize the disk of the VM over quota limit
expectedResults:
1.
2.
3.
4. VM reconfiguration request for resizing the disk should be denied with reason quota
exceeded.

Bugzilla:
1533263
"""
pass
51 changes: 51 additions & 0 deletions cfme/tests/infrastructure/test_tenant_quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

from cfme import test_requirements
from cfme.base.credential import Credential
from cfme.infrastructure.provider import InfraProvider
from cfme.infrastructure.provider.rhevm import RHEVMProvider
from cfme.infrastructure.provider.virtualcenter import VMwareProvider
from cfme.markers.env_markers.provider import ONE
from cfme.markers.env_markers.provider import ONE_PER_CATEGORY
from cfme.markers.env_markers.provider import ONE_PER_TYPE
from cfme.provisioning import do_vm_provisioning
from cfme.services.service_catalogs import ServiceCatalogs
Expand Down Expand Up @@ -147,6 +149,17 @@ def check_hosts(small_vm, provider):
pytest.skip("There is only one host in the provider")


@pytest.fixture
def quota_limit(roottenant):
in_use_storage = int(float(roottenant.quota["storage"]["in_use"].strip(" GB")))
# set storage quota limit to something more than the in_use_storage space
roottenant.set_quota(**{"storage_cb": True, "storage": in_use_storage + 3})
ganeshhubale marked this conversation as resolved.
Show resolved Hide resolved

yield int(float(roottenant.quota["storage"]["available"].strip(" GB")))

roottenant.set_quota(**{"storage_cb": False})

ganeshhubale marked this conversation as resolved.
Show resolved Hide resolved

@pytest.mark.rhv2
# first arg of parametrize is the list of fixtures or parameters,
# second arg is a list of lists, with each one a test is to be generated
Expand Down Expand Up @@ -713,3 +726,41 @@ def test_simultaneous_tenant_quota(request, appliance, context, new_project, new
provision_request.wait_for_request(method='ui')
request.addfinalizer(provision_request.remove_request)
assert provision_request.row.reason.text == "Quota Exceeded"


@pytest.mark.tier(1)
@pytest.mark.ignore_stream("5.10")
@pytest.mark.meta(automates=[1533263])
@pytest.mark.provider([InfraProvider], selector=ONE_PER_CATEGORY, scope="module")
def test_quota_with_reconfigure_resize_disks(setup_provider_modscope, small_vm, quota_limit):
"""Test that Quota gets checked against the resize of the disk of VMs.

Polarion:
assignee: ghubale
casecomponent: Infra
initialEstimate: 1/6h
setup:
1. Add an infra provider
2. Provision a VM
3. Note the storage space in use and set the quota limit to something more than
the current in_use_storage space.
testSteps:
1. Resize the disk of the VM over quota limit.
expectedResults:
1. VM reconfiguration request for resizing the disk should be denied with reason quota
exceeded.

Bugzilla:
1533263
"""
config = small_vm.configuration.copy()
disk = config.disks[0]

# set the resize value to a little more than the quota limit
resize_value = disk.size + quota_limit + 3
config.resize_disk(resize_value, disk.filename)

request = small_vm.reconfigure(config)
request.wait_for_request(method="ui")
assert request.status == "Denied"
assert request.row.reason.text == "Quota Exceeded"