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

[1LP][RFR] Adding test automation for bz1755070 #9463

Merged
merged 1 commit into from
Oct 11, 2019
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
18 changes: 18 additions & 0 deletions cfme/infrastructure/virtual_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ class InfraVmSummaryView(VMDetailsEntities):
datastore_usage = SummaryTable(title="Datastore Actual Usage Summary")


class InfraVmContainerView(VMDetailsEntities):
basic_information = SummaryTable(title="Basic Information")
device = SummaryTable(title="Devices")

@property
def is_displayed(self):
return self.basic_information.is_displayed and self.device.is_displayed
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 it is worth checking the title but optional



class InfraVmDetailsView(InfraVmView):
title = Text('#explorer_title_text')
toolbar = ConditionalSwitchableView(reference='entities.title')
Expand Down Expand Up @@ -1455,6 +1464,15 @@ def resetter(self, *args, **kwargs):
self.view.toolbar.reload.click()


@navigator.register(InfraVm, 'VmContainer')
class VmContainer(CFMENavigateStep):
VIEW = InfraVmContainerView
prerequisite = NavigateToSibling('Details')

def step(self):
self.prerequisite_view.entities.summary('Properties').click_at('Container')


@navigator.register(InfraVm, 'SnapshotsAll')
class VmSnapshotsAll(CFMENavigateStep):
VIEW = InfraVmSnapshotView
Expand Down
74 changes: 57 additions & 17 deletions cfme/tests/infrastructure/test_vmware_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
from cfme import test_requirements
from cfme.infrastructure.host import Host
from cfme.infrastructure.provider.virtualcenter import VMwareProvider
from cfme.markers.env_markers.provider import ONE_PER_TYPE
from cfme.markers.env_markers.provider import ONE
from cfme.utils import conf
from cfme.utils.appliance.implementations.ui import navigate_to
from cfme.utils.blockers import BZ
from cfme.utils.log import logger
from cfme.utils.wait import wait_for


filter_fields = [['provisioning', 'template'],
['provisioning', 'host'],
['provisioning', 'datastore']]

pytestmark = [
test_requirements.vmware,
pytest.mark.meta(server_roles="+automate"),
pytest.mark.usefixtures('setup_provider', 'uses_infra_providers'),
pytest.mark.provider([VMwareProvider],
required_fields=[['provisioning', 'template'],
['provisioning', 'host'],
['provisioning', 'datastore'],
(["cap_and_util", "capandu_vm"], "cu-24x7")],
scope="module")
pytest.mark.provider([VMwareProvider], required_fields=filter_fields, scope="module")
]


@pytest.mark.tier(3)
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE, override=True)
def test_vmware_provider_filters(appliance, provider, soft_assert):
"""
N-3 filters for esx provider.
Expand Down Expand Up @@ -64,7 +64,7 @@ def test_vmware_provider_filters(appliance, provider, soft_assert):
@pytest.mark.tier(3)
@pytest.mark.long_running
@pytest.mark.ignore_stream("upstream")
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE, override=True)
def test_appliance_scsi_control_vmware(request, appliance):
"""
Appliance cfme-vsphere-paravirtual-*.ova has SCSI controller as Para
Expand Down Expand Up @@ -106,7 +106,7 @@ def _cleanup():


@pytest.mark.tier(1)
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE, override=True)
def test_vmware_vds_ui_display(soft_assert, appliance, provider):
"""
Virtual Distributed Switch port groups are displayed for VMs assigned
Expand Down Expand Up @@ -140,7 +140,9 @@ def test_vmware_vds_ui_display(soft_assert, appliance, provider):

@pytest.mark.tier(1)
@pytest.mark.meta(blockers=[BZ(1650441, forced_streams=['5.10', '5.11'])])
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider],
required_fields=filter_fields + [(['cap_and_util', 'capandu_vm'], 'cu-24x7')],
selector=ONE, override=True)
def test_vmware_reconfigure_vm_controller_type(appliance, provider):
"""
Edit any VM which is provisioned for vSphere and select "Reconfigure this VM" option.
Expand Down Expand Up @@ -179,7 +181,7 @@ def test_vmware_reconfigure_vm_controller_type(appliance, provider):


@pytest.mark.tier(1)
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE, override=True)
def test_vmware_vds_ui_tagging(appliance, provider, soft_assert):
"""
Virtual Distributed Switch port groups are displayed for VMs assigned
Expand Down Expand Up @@ -243,8 +245,10 @@ def test_vmware_inaccessible_datastore():


@pytest.mark.tier(1)
@pytest.mark.meta(blockers=[BZ(1689369, forced_streams=['5.10', '5.11'])])
john-dupuy marked this conversation as resolved.
Show resolved Hide resolved
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE,
required_fields=filter_fields + [(['cap_and_util', 'capandu_vm'], 'cu-24x7')],
override=True)
@pytest.mark.meta(automates=[1689369])
def test_vmware_cdrom_dropdown_not_blank(appliance, provider):
"""
Test CD/DVD Drives dropdown lists ISO files, dropdown is not blank
Expand Down Expand Up @@ -380,7 +384,7 @@ def test_vmware_provisioned_vm_host_relationship(request, appliance, provider):


@pytest.mark.tier(1)
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE, override=True)
def test_esxi_reboot_not_orphan_vms(appliance, provider):
"""
By mimicking ESXi reboot effect on VMs in CFME, make sure they are not getting marked orphaned.
Expand Down Expand Up @@ -428,7 +432,7 @@ def test_esxi_reboot_not_orphan_vms(appliance, provider):


@pytest.mark.tier(1)
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE, override=True)
@pytest.mark.meta(automates=[1688900])
def test_switches_class_present_ems(appliance, provider):
"""
Expand Down Expand Up @@ -473,7 +477,7 @@ def test_switches_class_present_ems(appliance, provider):


@pytest.mark.tier(1)
@pytest.mark.provider([VMwareProvider], selector=ONE_PER_TYPE, override=True)
@pytest.mark.provider([VMwareProvider], selector=ONE, override=True)
@pytest.mark.meta(automates=[1719399])
def test_rebuilt_vcenter_duplicate_hosts(appliance, provider):
"""
Expand Down Expand Up @@ -514,3 +518,39 @@ def test_rebuilt_vcenter_duplicate_hosts(appliance, provider):
# Using appliance.rest_api as hosts.all() do not return archived hosts, I need those too
hosts_after = len(appliance.rest_api.collections.hosts.all)
assert hosts_before == hosts_after


@pytest.mark.tier(1)
@pytest.mark.provider([VMwareProvider], selector=ONE,
required_fields=filter_fields + [(['cap_and_util', 'capandu_vm'], 'cu-24x7')],
override=True)
@pytest.mark.meta(automates=[1755070])
def test_vm_notes_ui(appliance, provider):
"""
Check if the VM Notes are shown in the CFME UI for VMs on VMware.

Bugzilla:
1755070

Polarion:
assignee: kkulkarn
casecomponent: Infra
caseimportance: medium
initialEstimate: 1/2h
testtype: functional
testSteps:
1.Add VMware provider to CFME
2.Navigate to Compute->Infrastructure->Virtual Machines
3.Select a VM to view details and click on "Container" in the "Basic Information" table
4.Check if Notes field exists and Notes are shown
"""
vms_collections = appliance.collections.infra_vms
vm = vms_collections.instantiate(name='cu-24x7', provider=provider)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than hard-coding this vm name, I recommend doing

    collection = provider.appliance.provider_based_collection(provider)
    vm = collection.all()[0]

Or since you're wanting to read the notes for this specific VM, you can use

pytest.mark.provider([VMwareProvider, RHEVMProvider], selector=ONE_PER_TYPE,
                         required_fields=[(['cap_and_util', 'capandu_vm'], 'cu-24x7')])

To ensure that the vm is on the provider from the yamls.

Copy link
Contributor Author

@kedark3 kedark3 Oct 9, 2019

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing that out!

Copy link
Member

Choose a reason for hiding this comment

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

That link isn't working anymore because of commit re-writing, but I'm guessing you were linking to the module marker?

Override markers don't add to the provider filter, they define the provider filter for the local scope.

This needs to be fetched from yamls, and include the same required_fields filter applied at the module level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mshriver updated the PR please check.

view = navigate_to(vm, 'VmContainer')
assert view.basic_information.get_field('Notes').is_displayed
# all cu-24x7 do have notes on them hence following check would work
# TODO: Once the following issue https://github.com/ManageIQ/wrapanapi/issues/422
# is fixed, update test to compare Notes found via API
# to check it against what's displayed in the UI.
assert view.basic_information.read()['Notes'] != '', ("VM notes field is empty in CFME or"
"VM does not have any notes")
2 changes: 1 addition & 1 deletion widgetastic_manageiq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ class SummaryTable(VanillaTable):
title: Title of the table (eg. ``Properties``)
"""

BASELOC = './/table[./thead/tr/th[contains(@align, "left") and normalize-space(.)={}]]'
BASELOC = ".//table[./thead/tr/th[normalize-space(.)={}]]"
Image = namedtuple("Image", ["alt", "title", "src"])

def __init__(self, parent, title, *args, **kwargs):
Expand Down