From 09b9583b661a55754b35324d72ec2c673f07d721 Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Tue, 16 Jun 2020 21:56:30 +0530 Subject: [PATCH] Automate test_utilization_utilization_graphs Signed-off-by: Gaurav Talreja --- cfme/fixtures/candu.py | 25 ++++++++-- cfme/infrastructure/cluster.py | 2 + cfme/tests/candu/test_candu_manual.py | 68 --------------------------- cfme/tests/candu/test_utilization.py | 51 ++++++++++++++++++++ 4 files changed, 75 insertions(+), 71 deletions(-) create mode 100644 cfme/tests/candu/test_utilization.py diff --git a/cfme/fixtures/candu.py b/cfme/fixtures/candu.py index 6a8b341f6c..30933026cb 100644 --- a/cfme/fixtures/candu.py +++ b/cfme/fixtures/candu.py @@ -68,14 +68,17 @@ def candu_tag_vm(provider, enable_candu_category): @pytest.fixture(scope="module") -def candu_db_restore(temp_appliance_extended_db): +def candu_db_restore(request, temp_appliance_extended_db): app = temp_appliance_extended_db # get DB backup file db_storage_hostname = conf.cfme_data.bottlenecks.hostname db_storage_ssh = SSHClient(hostname=db_storage_hostname, **conf.credentials.bottlenecks) + file_name = getattr(request, 'param', 'candu.db.backup') rand_filename = f"/tmp/db.backup_{fauxfactory.gen_alphanumeric()}" - db_storage_ssh.get_file("{}/candu.db.backup".format( - conf.cfme_data.bottlenecks.backup_path), rand_filename) + db_storage_ssh.get_file( + f"{conf.cfme_data.bottlenecks.backup_path}/{file_name}", + rand_filename + ) app.ssh_client.put_file(rand_filename, "/tmp/evm_db.backup") app.evmserverd.stop() @@ -90,3 +93,19 @@ def candu_db_restore(temp_appliance_extended_db): app.db.fix_auth_dbyml() app.evmserverd.start() app.wait_for_miq_ready() + + +@pytest.fixture(params=["regions", "providers", "clusters", "hosts"]) +def entity_init(temp_appliance_extended_db, request, provider): + appliance = temp_appliance_extended_db + provider.appliance = appliance + if request.param == "regions": + return appliance.collections.regions.instantiate(appliance.region()[-1]) + if request.param == "providers": + return provider + if request.param == "clusters": + return appliance.collections.clusters.instantiate(name=provider.data["clusters"][0], + provider=provider) + if request.param == "hosts": + return appliance.collections.hosts.instantiate(name=provider.data["hosts"][0].name, + provider=provider) diff --git a/cfme/infrastructure/cluster.py b/cfme/infrastructure/cluster.py index d23565ac5c..4eab4cf167 100644 --- a/cfme/infrastructure/cluster.py +++ b/cfme/infrastructure/cluster.py @@ -425,4 +425,6 @@ def step(self, *args, **kwargs): ] if self.appliance.version >= "5.11": path.insert(0, "Enterprise") + self.prerequisite_view.tree.expand_path(*path) + self.prerequisite_view.browser.plugin.ensure_page_safe() self.prerequisite_view.tree.click_path(*path) diff --git a/cfme/tests/candu/test_candu_manual.py b/cfme/tests/candu/test_candu_manual.py index 903aa10720..a74f1d8428 100644 --- a/cfme/tests/candu/test_candu_manual.py +++ b/cfme/tests/candu/test_candu_manual.py @@ -90,74 +90,6 @@ def test_bottleneck_summary_graph(): pass -@pytest.mark.tier(1) -@test_requirements.c_and_u -def test_utilization_utilization_graphs(): - """ - Polarion: - assignee: gtalreja - casecomponent: Optimize - initialEstimate: 1/4h - testSteps: - 1. Enable C&U - 2. Wait until data will be collected - 3. Go to Optimize/Utilization - expectedResults: - 1. - 2. - 3. Verify that all graphs shows correctly - """ - pass - - -@pytest.mark.tier(2) -@test_requirements.c_and_u -def test_utilization_provider(): - """ - Verify гutilication data from providers - - Polarion: - assignee: gtalreja - casecomponent: Optimize - caseimportance: medium - initialEstimate: 1/8h - testtype: functional - """ - pass - - -@pytest.mark.tier(2) -@test_requirements.c_and_u -def test_utilization_cluster(): - """ - Verify гutilication data from cluster - - Polarion: - assignee: gtalreja - casecomponent: Optimize - caseimportance: medium - initialEstimate: 1/8h - testtype: functional - """ - pass - - -@pytest.mark.tier(2) -@test_requirements.c_and_u -def test_utilization_host(): - """ - Verify utilication data from host - - Polarion: - assignee: gtalreja - casecomponent: Optimize - caseimportance: medium - initialEstimate: 1/8h - testtype: functional - """ - pass - - @pytest.mark.tier(3) @test_requirements.c_and_u def test_crosshair_op_cluster_vsphere65(): diff --git a/cfme/tests/candu/test_utilization.py b/cfme/tests/candu/test_utilization.py new file mode 100644 index 0000000000..c9c6f59521 --- /dev/null +++ b/cfme/tests/candu/test_utilization.py @@ -0,0 +1,51 @@ +import pytest + +from cfme import test_requirements +from cfme.cloud.provider.azure import AzureProvider +from cfme.cloud.provider.ec2 import EC2Provider +from cfme.cloud.provider.openstack import OpenStackProvider +from cfme.infrastructure.provider.rhevm import RHEVMProvider +from cfme.infrastructure.provider.virtualcenter import VMwareProvider +from cfme.utils.appliance.implementations.ui import navigate_to + +pytestmark = [ + pytest.mark.tier(1), + test_requirements.c_and_u, + pytest.mark.provider( + [VMwareProvider, RHEVMProvider, EC2Provider, OpenStackProvider, AzureProvider], + required_fields=[(['cap_and_util', 'capandu_vm'], 'cu-24x7')], scope="module") +] + + +@pytest.mark.tier(1) +@pytest.mark.provider([VMwareProvider], scope="module") +@pytest.mark.parametrize("candu_db_restore", ["utilization_db.backup"], ids=["db"], indirect=True) +def test_utilization_trends(temp_appliance_extended_db, candu_db_restore, request, + entity_init): + """ + Test to automate the testing of Overview -> Utilization tab + + Polarion: + assignee: gtalreja + casecomponent: Optimize + initialEstimate: 1/4h + testSteps: + 1. Enable C&U + 2. Wait until data will be collected + 3. Go to Optimize/Utilization + expectedResults: + 1. + 2. + 3. Verify that all graphs shows correctly + """ + with temp_appliance_extended_db: + view = navigate_to(entity_init, "UtilTrendSummary") + + assert view.summary.chart.is_displayed + assert view.details.cpu_chart.is_displayed + assert view.details.memory_chart.is_displayed + if entity_init == "regions": + assert view.details.disk_chart.is_displayed + assert view.report.disk_table.is_displayed + assert view.report.cpu_table.is_displayed + assert view.report.memory_table.is_displayed