-
Notifications
You must be signed in to change notification settings - Fork 165
[RFR] Added Pod.pods_per_ready_status + Fix smart management test #4922
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,12 @@ | |
|
||
|
||
from navmazing import NavigateToSibling, NavigateToAttribute | ||
from cfme.base.login import BaseLoggedInPage | ||
from widgetastic_patternfly import SelectorDropdown, Button, Dropdown | ||
from widgetastic.widget import Text | ||
from utils.wait import wait_for | ||
from wrapanapi.utils import eval_strings | ||
|
||
|
||
from cfme.base.login import BaseLoggedInPage | ||
from cfme.common.provider import BaseProvider | ||
from cfme import exceptions | ||
from cfme.fixtures import pytest_selenium as sel | ||
|
@@ -26,6 +26,7 @@ | |
from utils.pretty import Pretty | ||
from utils.varmeth import variable | ||
from utils.log import logger | ||
from utils.wait import wait_for | ||
|
||
|
||
paged_tbl = PagedTable(table_locator="//div[@id='list_grid']//table") | ||
|
@@ -269,6 +270,18 @@ def num_image_registry(self): | |
def num_image_registry_ui(self): | ||
return int(self.get_detail("Relationships", "Image Registries")) | ||
|
||
def pods_per_ready_status(self): | ||
"""Grabing the Container Statuses Summary of the pods from API""" | ||
# TODO: Add later this logic to wrapanapi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (+ @psav ) Indeed, I didn't forgot that, my next step will be to migrate all these functions to wrapanapi (this is not the only one, I have similar TODOS all over the framework) |
||
entities = self.mgmt.api.get('pod')[1]['items'] | ||
out = {} | ||
for entity_j in entities: | ||
out[entity_j['metadata']['name']] = { | ||
condition['type']: eval_strings([condition['status']]).pop() | ||
for condition in entity_j['status'].get('conditions', []) | ||
} | ||
return out | ||
|
||
|
||
@navigator.register(ContainersProvider, 'All') | ||
class All(CFMENavigateStep): | ||
|
@@ -431,6 +444,25 @@ def pretty_id(self): | |
getattr(self.obj, '__name__', str(self.obj)), | ||
self.polarion_id) | ||
|
||
@classmethod | ||
def get_pretty_id(cls, obj): | ||
"""Since sometimes the test object is wrapped within markers, | ||
it's difficult to find get it inside the args tree. | ||
hence we use this to get the object and all pretty_id function. | ||
|
||
Args: | ||
* obj: Either a ContainersTestItem or a marker that include it | ||
returns: | ||
str pretty id | ||
""" | ||
if isinstance(obj, cls): | ||
return obj.pretty_id() | ||
elif hasattr(obj, 'args') and hasattr(obj, '__iter__'): | ||
for arg in obj.args: | ||
pretty_id = cls.get_pretty_id(arg) | ||
if pretty_id: | ||
return pretty_id | ||
|
||
|
||
class Labelable(object): | ||
"""Provide the functionality to set labels""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
import pytest | ||
from wrapanapi.utils import eval_strings | ||
|
||
from cfme.containers.provider import ContainersProvider,\ | ||
ContainersTestItem | ||
from cfme.containers.route import Route | ||
from cfme.containers.project import Project | ||
from cfme.containers.service import Service | ||
from cfme.containers.container import Container | ||
from cfme.containers.node import Node | ||
from cfme.containers.image import Image | ||
from cfme.containers.image_registry import ImageRegistry | ||
|
@@ -17,7 +17,6 @@ | |
from utils import testgen, version | ||
from utils.version import current_version | ||
from utils.soft_get import soft_get | ||
from utils.appliance.implementations.ui import navigate_to | ||
|
||
|
||
pytestmark = [ | ||
|
@@ -32,16 +31,19 @@ | |
|
||
|
||
TEST_ITEMS = [ | ||
pytest.mark.polarion('CMP-9945')( | ||
ContainersTestItem( | ||
Container, | ||
'CMP-9945', | ||
expected_fields=[ | ||
'name', 'state', 'last_state', 'restart_count', | ||
'backing_ref_container_id', 'privileged' | ||
] | ||
) | ||
), | ||
# The next lines have been removed due to bug introduced in CFME 5.8.1 - | ||
# https://bugzilla.redhat.com/show_bug.cgi?id=1467639 | ||
# from cfme.containers.container import Container | ||
# pytest.mark.polarion('CMP-9945')( | ||
# ContainersTestItem( | ||
# Container, | ||
# 'CMP-9945', | ||
# expected_fields=[ | ||
# 'name', 'state', 'last_state', 'restart_count', | ||
# 'backing_ref_container_id', 'privileged' | ||
# ] | ||
# ) | ||
# ), | ||
pytest.mark.polarion('CMP-10430')( | ||
ContainersTestItem( | ||
Project, | ||
|
@@ -133,7 +135,7 @@ | |
|
||
|
||
@pytest.mark.parametrize('test_item', TEST_ITEMS, | ||
ids=[ti.args[1].pretty_id() for ti in TEST_ITEMS]) | ||
ids=[ContainersTestItem.get_pretty_id(ti) for ti in TEST_ITEMS]) | ||
def test_properties(provider, test_item, soft_assert): | ||
|
||
if current_version() < "5.7" and test_item.obj == Template: | ||
|
@@ -143,7 +145,6 @@ def test_properties(provider, test_item, soft_assert): | |
|
||
for instance in instances: | ||
|
||
navigate_to(instance, 'Details') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to navigate anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, The instance.summary below is already do it for us. |
||
if isinstance(test_item.expected_fields, dict): | ||
expected_fields = version.pick(test_item.expected_fields) | ||
else: | ||
|
@@ -156,27 +157,25 @@ def test_properties(provider, test_item, soft_assert): | |
.format(test_item.obj.__name__, instance.name, field)) | ||
|
||
|
||
@pytest.mark.skip(reason="This test is currently skipped due to instability issues. ") | ||
def test_pods_conditions(provider, appliance, soft_assert): | ||
|
||
# TODO: Add later this logic to mgmtsystem | ||
selected_pods_cfme = {pd.name: pd | ||
for pd in Pod.get_random_instances( | ||
provider, count=3, appliance=appliance)} | ||
|
||
selected_pods_ose = {pod["metadata"]["name"]: pod for pod in | ||
provider.mgmt.api.get('pod')[1]['items'] if pod["metadata"]["name"] in | ||
selected_pods_cfme} | ||
|
||
pods_per_ready_status = provider.pods_per_ready_status() | ||
for pod_name in selected_pods_cfme: | ||
cfme_pod = selected_pods_cfme[pod_name] | ||
|
||
ose_pod = selected_pods_ose[pod_name] | ||
|
||
ose_pod_condition = {cond["type"]: cond["status"] for cond in | ||
ose_pod['status']['conditions']} | ||
cfme_pod_condition = {type: getattr(getattr(cfme_pod.summary.conditions, type), "Status") | ||
for type in ose_pod_condition} | ||
|
||
for item in cfme_pod_condition: | ||
soft_assert(ose_pod_condition[item], cfme_pod_condition[item]) | ||
ose_pod_condition = pods_per_ready_status[pod_name] | ||
cfme_pod_condition = {_type: | ||
eval_strings( | ||
[getattr(getattr(cfme_pod.summary.conditions, _type), "Status")] | ||
).pop() | ||
for _type in ose_pod_condition} | ||
|
||
for status in cfme_pod_condition: | ||
soft_assert(ose_pod_condition[status] == cfme_pod_condition[status], | ||
'The Pod {} status mismatch: It is "{}" in openshift while cfme sees "{}".' | ||
.format(status, cfme_pod.name, ose_pod_condition[status], | ||
cfme_pod_condition[status])) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import pytest | ||
|
||
from cfme.containers.provider import ContainersProvider | ||
from cfme.web_ui import toolbar as tb | ||
from utils import testgen, version | ||
from utils.appliance.implementations.ui import navigate_to | ||
|
||
|
||
pytestmark = [ | ||
|
@@ -15,42 +13,10 @@ | |
|
||
|
||
@pytest.mark.polarion('CMP-9878') | ||
@pytest.mark.skip(reason="This test is currently skipped due to instability issues. ") | ||
def test_reload_button_provider(provider): | ||
""" This test verifies the data integrity of the fields in | ||
the Relationships table after clicking the "reload" | ||
button. Fields that are being verified as part of provider.validate.stats(): | ||
Projects, Routes, Container Services, Replicators, Pods, Image Registries, | ||
Containers, and Nodes. | ||
Images are being validated separately, since the total | ||
number of images in CFME 5.7 and CFME 5.8 includes all images from the OSE registry as well | ||
as the images that are being created from the running pods. The images are searched | ||
according to the @sha. | ||
button. | ||
""" | ||
|
||
navigate_to(provider, 'Details') | ||
tb.select('Reload Current Display') | ||
provider.validate_stats(ui=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the refresh done as part of this func call? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
list_img_from_registry = provider.mgmt.list_image() | ||
list_img_from_registry_splitted = [i.id.split( | ||
'@sha256:')[-1] for i in list_img_from_registry] | ||
|
||
list_img_from_openshift = provider.mgmt.list_image_openshift() | ||
list_img_from_openshift_splitted = [d['name'] | ||
for d in list_img_from_openshift] | ||
list_img_from_openshift_parsed = [i[7:].split( | ||
'@sha256:')[-1] for i in list_img_from_openshift_splitted] | ||
list_img_from_registry_splitted_new = set(list_img_from_registry_splitted) | ||
list_img_from_openshift_parsed_new = set(list_img_from_openshift_parsed) | ||
|
||
list_img_from_openshift_parsed_new.update(list_img_from_registry_splitted_new) | ||
|
||
num_img_in_cfme = provider.num_image() | ||
# TODO Fix num_image_ui() | ||
|
||
num_img_cfme_56 = len(provider.mgmt.list_image()) | ||
num_img_cfme_57 = len(list_img_from_openshift_parsed_new) | ||
|
||
assert num_img_in_cfme == version.pick({version.LOWEST: num_img_cfme_56, | ||
'5.7': num_img_cfme_57}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍