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

[1LP][RFR] Fix tests #9978

Merged
merged 2 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion cfme/automate/explorer/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def create(
add_page.validate_button.click()
add_page.wait_displayed()
add_page.flash.assert_no_error()
add_page.flash.assert_message('Data validated successfully', wait=3)
add_page.flash.assert_message('Data validated successfully')
if cancel:
add_page.cancel_button.click()
add_page.flash.assert_no_error()
Expand Down
19 changes: 17 additions & 2 deletions cfme/fixtures/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def enable_provider_regions(provider):
def _setup_provider_verbose(request, provider, appliance=None):
if appliance is None:
appliance = store.current_appliance
else:
provider.appliance = appliance
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add comment for this?

try:
if request.config.option.provider_limit > 0:
existing_providers = [
Expand Down Expand Up @@ -147,7 +149,7 @@ def _setup_provider_verbose(request, provider, appliance=None):
return False


def setup_or_skip(request, provider):
def setup_or_skip(request, provider, appliance=None):
""" Sets up given provider or skips the test

Note:
Expand All @@ -158,7 +160,7 @@ def setup_or_skip(request, provider):
skip_msg = "Provider {} had been marked as problematic".format(provider.key)
_artifactor_skip_providers(request, [provider], skip_msg)

if not _setup_provider_verbose(request, provider):
if not _setup_provider_verbose(request, provider, appliance):
_artifactor_skip_providers(
request, [provider], "Unable to setup provider {}".format(provider.key))

Expand Down Expand Up @@ -295,6 +297,19 @@ def setup_provider_clsscope(request, provider):
def setup_provider_funcscope(request, provider):
"""Function-scoped fixture to set up a provider"""
return setup_or_skip(request, provider)


@pytest.fixture
def setup_provider_temp_appliance(request, provider, temp_appliance_preconfig_funcscope):
"""Function-scoped fixture to set up a provider on a temporary appliance"""
return setup_or_skip(request, provider, temp_appliance_preconfig_funcscope)


@pytest.fixture(scope="module")
def setup_provider_temp_appliance_modscope(request, provider, temp_appliance_preconfig_modscope):
"""Module-scoped fixture to set up a provider on a temporary appliance"""
return setup_or_skip(request, provider, temp_appliance_preconfig_modscope)

# -----------------------------------------------


Expand Down
2 changes: 1 addition & 1 deletion cfme/intelligence/reports/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def reset_to_default(self, group):
view.default_button.click()
view.save_button.click()
flash_view = self.create_view(AllReportMenusView)
assert flash_view.flash.assert_message(
flash_view.flash.assert_message(
'Report Menu for role "{}" was saved'.format(group)
)

Expand Down
13 changes: 12 additions & 1 deletion cfme/tests/cloud/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ def test_display_network_topology(appliance, openstack_provider):
topology_col = appliance.collections.network_topology_elements
view = navigate_to(topology_col, 'All')
assert view.is_displayed
view.flash.assert_no_error()


@pytest.mark.provider([CloudProvider], scope='class')
Expand All @@ -842,6 +841,12 @@ def test_cloud_networks_query(self, provider, appliance, from_detail, setup_prov
else:
networks = appliance.rest_api.collections.cloud_networks
assert_response(appliance)
wait_for(
lambda: len(networks) != 0,
fail_func=provider.refresh_provider_relationships,
timeout="40s",
silent_failure=True,
)
assert len(networks) > 0, 'No cloud networks found'
assert networks.name == 'cloud_networks'
assert len(networks.all) == networks.subcount
Expand All @@ -867,6 +872,12 @@ def test_security_groups_query(self, provider, appliance, setup_provider):
caseimportance: low
initialEstimate: 1/4h
"""
wait_for(
lambda: len(provider.rest_api_entity.cloud_networks) != 0,
fail_func=provider.refresh_provider_relationships,
timeout="40s",
silent_failure=True,
)
try:
network = provider.rest_api_entity.cloud_networks[0]
except IndexError:
Expand Down
2 changes: 1 addition & 1 deletion cfme/tests/configure/test_default_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_default_filters_reset(appliance):
node = view.tabs.default_filters.tree.CheckNode(tree_path)
view.tabs.default_filters.tree.fill(node)
view.tabs.default_filters.reset.click()
assert view.flash.assert_message('All changes have been reset')
view.flash.assert_message('All changes have been reset')


def test_cloudimage_defaultfilters(appliance):
Expand Down
2 changes: 1 addition & 1 deletion cfme/tests/infrastructure/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_infra_discovery_screen(appliance):
assert not view.osp_infra.selected

view.start.click()
assert view.flash.assert_message("At least 1 item must be selected for discovery")
view.flash.assert_message("At least 1 item must be selected for discovery")

view.vmware.click()
for ips in discovery_ips:
Expand Down
11 changes: 11 additions & 0 deletions cfme/tests/infrastructure/test_vm_retirement_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from cfme.infrastructure.provider import InfraProvider
from cfme.markers.env_markers.provider import ONE
from cfme.rest.gen_data import vm as _vm
from cfme.utils.blockers import BZ
from cfme.utils.rest import assert_response
from cfme.utils.wait import wait_for

Expand Down Expand Up @@ -64,6 +65,7 @@ def vm_retirement_report(appliance, retire_vm):
@pytest.mark.parametrize(
"from_collection", [True, False], ids=["from_collection", "from_detail"]
)
@pytest.mark.meta(automates=[BZ(1805119)], blockers=[BZ(1805119)])
def test_retire_vm_now(appliance, vm, from_collection):
"""Test retirement of vm

Expand All @@ -81,6 +83,9 @@ def test_retire_vm_now(appliance, vm, from_collection):
Metadata:
test_flag: rest

Bugzilla:
1805119

Polarion:
assignee: pvala
casecomponent: Infra
Expand Down Expand Up @@ -111,6 +116,7 @@ def _finished():
@pytest.mark.parametrize(
"from_collection", [True, False], ids=["from_collection", "from_detail"]
)
@pytest.mark.meta(automates=[BZ(1805119)], blockers=[BZ(1805119)])
def test_retire_vm_future(appliance, vm, from_collection):
"""Test retirement of vm

Expand All @@ -128,6 +134,9 @@ def test_retire_vm_future(appliance, vm, from_collection):
Metadata:
test_flag: rest

Bugzilla:
1805119

Polarion:
assignee: pvala
casecomponent: Infra
Expand Down Expand Up @@ -156,6 +165,7 @@ def _finished():


@pytest.mark.tier(1)
@pytest.mark.meta(automates=[BZ(1805119), BZ(1638502)], blockers=[BZ(1805119)])
def test_check_vm_retirement_requester(
appliance, request, provider, vm_retirement_report
):
Expand All @@ -179,6 +189,7 @@ def test_check_vm_retirement_requester(

Bugzilla:
1638502
1805119
"""
vm_name, report = vm_retirement_report
saved_report = report.queue(wait_for_finish=True)
Expand Down
28 changes: 14 additions & 14 deletions cfme/tests/intelligence/reports/test_canned_corresponds.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

pytestmark = [
pytest.mark.tier(3),
pytest.mark.usefixtures('setup_provider_modscope'),
pytest.mark.provider(classes=[InfraProvider], scope='module'),
pytest.mark.provider(classes=[InfraProvider], scope='function'),
test_requirements.report,
]

Expand All @@ -26,7 +25,7 @@ def compare(db_item, report_item):


@pytest.mark.rhv3
def test_providers_summary(appliance, soft_assert):
def test_providers_summary(appliance, soft_assert, request, setup_provider):
"""Checks some informations about the provider. Does not check memory/frequency as there is
presence of units and rounding.

Expand All @@ -44,6 +43,7 @@ def test_providers_summary(appliance, soft_assert):
subtype="Providers",
menu_name="Providers Summary"
).queue(wait_for_finish=True)
request.addfinalizer(report.delete)
# Skip cloud and network providers as they don't share some attributes with infra providers
# Also skip the embedded ansible provider
skipped_providers = {"ec2", "openstack", "redhat_network", "embedded_ansible_automation"}
Expand All @@ -69,7 +69,7 @@ def test_providers_summary(appliance, soft_assert):


@pytest.mark.rhv3
def test_cluster_relationships(appliance, soft_assert):
def test_cluster_relationships(appliance, request, soft_assert, setup_provider):
"""Tests vm power options from on

Metadata:
Expand All @@ -87,6 +87,8 @@ def test_cluster_relationships(appliance, soft_assert):
subtype="Virtual Machines, Folders, Clusters",
menu_name="Cluster Relationships"
).queue(wait_for_finish=True)
request.addfinalizer(report.delete)

for relation in report.data.rows:
name = relation["Name"]
provider_name = relation["Provider Name"]
Expand Down Expand Up @@ -130,7 +132,9 @@ def test_cluster_relationships(appliance, soft_assert):


@pytest.mark.rhv2
def test_operations_vm_on(soft_assert, temp_appliance_preconfig_funcscope, request):
def test_operations_vm_on(
soft_assert, temp_appliance_preconfig_funcscope, request, setup_provider_temp_appliance
):
"""Tests vm power options from on

Metadata:
Expand All @@ -156,6 +160,7 @@ def test_operations_vm_on(soft_assert, temp_appliance_preconfig_funcscope, reque
subtype="Virtual Machines",
menu_name="Online VMs (Powered On)"
).queue(wait_for_finish=True)
request.addfinalizer(report.delete)

vms_in_db = adb.session.query(
vms.name.label('vm_name'),
Expand All @@ -167,10 +172,6 @@ def test_operations_vm_on(soft_assert, temp_appliance_preconfig_funcscope, reque
storages, vms.storage_id == storages.id).filter(
vms.power_state == 'on').order_by(vms.name).all()

@request.addfinalizer
def _finalize():
report.delete()

assert len(vms_in_db) == len(list(report.data.rows))
vm_names = [vm.vm_name for vm in vms_in_db]
for vm in vms_in_db:
Expand All @@ -189,7 +190,9 @@ def _finalize():


@pytest.mark.rhv3
def test_datastores_summary(soft_assert, temp_appliance_preconfig_funcscope, request):
def test_datastores_summary(
soft_assert, temp_appliance_preconfig_funcscope, request, setup_provider_temp_appliance
):
"""Checks Datastores Summary report with DB data. Checks all data in report, even rounded
storage sizes.

Expand All @@ -213,16 +216,13 @@ def test_datastores_summary(soft_assert, temp_appliance_preconfig_funcscope, req
subtype="Storage",
menu_name="Datastores Summary"
).queue(wait_for_finish=True)
request.addfinalizer(report.delete)

storages_in_db = adb.session.query(storages.store_type, storages.free_space,
storages.total_space, storages.name, storages.id).all()

assert len(storages_in_db) == len(list(report.data.rows))

@request.addfinalizer
def _finalize():
report.delete()

storages_in_db_list = []
report_rows_list = []

Expand Down
2 changes: 1 addition & 1 deletion cfme/tests/intelligence/reports/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def setup_vm(configure_fleecing, appliance, provider):
vm = appliance.collections.infra_vms.instantiate(
name=random_vm_name(context="report", max_length=20),
provider=provider,
template_name="env-rhel7-20-percent-full-disk-tpl",
template_name="env-rhel7-20-percent-full-disk-pvala-tpl",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should come from data yaml than hardcodding. We can include this under template session for provider. I'm marking this optional as just modifying but please raise separate PR for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This template won't be used by any other test case unless you want to provision a VM which has less than 20% disk space, which is why I directly used the template name even though it's weird to look at it. But if you insist, we can move it to data yaml.

Copy link
Contributor

Choose a reason for hiding this comment

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

yup better to take it from yaml... It will help in template maintenance as well.

)
vm.create_on_provider(allow_skip="default", find_in_cfme=True)
vm.smartstate_scan(wait_for_task_result=True)
Expand Down
5 changes: 4 additions & 1 deletion cfme/tests/intelligence/test_download_report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest

from cfme import test_requirements
from cfme.infrastructure.provider import InfraProvider
from cfme.markers.env_markers.provider import ONE

pytestmark = [test_requirements.report]

Expand All @@ -17,7 +19,8 @@ def report(appliance):


@pytest.mark.parametrize("filetype", ["txt", "csv", "pdf"])
def test_download_report(infra_provider, report, filetype):
@pytest.mark.provider([InfraProvider], selector=ONE, scope="module")
def test_download_report(setup_provider_modscope, report, filetype):
"""Download the report as a file.

Polarion:
Expand Down
4 changes: 3 additions & 1 deletion cfme/tests/webui/test_general_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,9 @@ def test_infrastructure_provider_left_panel_titles(
@pytest.mark.ignore_stream("5.10")
@pytest.mark.parametrize("provider", PROVIDERS)
@pytest.mark.meta(automates=[1741030, 1783208])
def test_provider_documentation(temp_appliance_preconfig, provider, request):
def test_provider_documentation(
temp_appliance_preconfig_funcscope, provider, has_no_providers, request
):
"""
Bugzilla:
1741030
Expand Down