Skip to content

Commit

Permalink
Merge pull request Kiali-QE#412 from hhovsepy/fix
Browse files Browse the repository at this point in the history
Fixed failing tests.
  • Loading branch information
hhovsepy authored Apr 12, 2021
2 parents f2c1ae4 + 67f80b8 commit 8d682d7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
8 changes: 3 additions & 5 deletions data/resources/istio_objects/destination-rule-cb-broken.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
labels:
version: v2
host: reviews-broken
host: reviews
trafficPolicy:
connectionPool:
tcp:
Expand All @@ -20,10 +20,8 @@ spec:
subsets:
- name: v1
labels:
version: v1
version: v11
- name: v2
labels:
version: v2
- name: v3
labels:
version: v3
- name: v3
8 changes: 4 additions & 4 deletions kiali_qe/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2523,8 +2523,7 @@ def _get_details_selectors(self):
pass
_selectors = self.browser.elements(
parent=self.DETAILS_ROOT,
locator=('//h6[contains(text(), "Selectors")]'
'/../../div[@id="selectors"]//*[contains(@class, "label-pair")]'))
locator=('//div[@id="selectors"]//*[contains(@class, "label-pair")]'))
if _selectors:
for _selector in _selectors:
_label_key = self.browser.element(
Expand Down Expand Up @@ -3002,6 +3001,7 @@ class ListViewIstioConfig(ListViewAbstract):
TABLE_ROOT = './/table[contains(@class, "pf-c-table")]'
CONFIG_INPUT = '//input[@id="{}"]'
CONFIG_DETAILS_ROOT = './/*[contains(@class, "pf-c-form")]'
DETAILS_ROOT = CONFIG_DETAILS_ROOT
CREATE_HANDLER_BUTTON = './/button[text()="Create"]'
UPDATE_HANDLER_BUTTON = './/button[text()="Save"]'

Expand Down Expand Up @@ -3049,7 +3049,7 @@ class TableViewAbstract(ViewAbstract):
OVERVIEW_PROPERTIES = ('.//div[contains(@class, "pf-c-card__body")]//'
'h3[@data-pf-content="true" and contains(text(), "{}")]/..')
HOSTS_PROPERTIES = './/div/h3[contains(text(), "{}")]/..//li'
HOST_PROPERTIES = './/div/h3[contains(text(), "{}")]/../a'
HOST_PROPERTIES = './/div/h3[contains(text(), "{}")]/..'
SERVICES_TAB = '//*[contains(@class, "pf-c-tabs__item")]//button[contains(text(), "{}")]'
ROOT = '//[contains(@class, "tab-pane") and contains(@class, "active") and \
contains(@class, "in")]'
Expand Down Expand Up @@ -3365,7 +3365,7 @@ def _get_dr_overview(self, name):

_host = self.browser.text(
locator=self.HOST_PROPERTIES.format(self.HOST),
parent=self.OVERVIEW_DETAILS_ROOT).replace(self.HOST, '').strip()
parent=self.OVERVIEW_DETAILS_ROOT).replace(self.HOST, '').strip().split(' ')[0]
_status = self._get_overview_status(self.OVERVIEW_DETAILS_ROOT)
_subsets = []

Expand Down
8 changes: 4 additions & 4 deletions kiali_qe/entities/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def is_equal(self, other, advanced_check=True):
return False
if self.name != other.name:
return False
if self.created_at != other.created_at:
if self.created_at and other.created_at and self.created_at != other.created_at:
return False
if self.created_at_ui != other.created_at_ui:
return False
Expand Down Expand Up @@ -283,7 +283,7 @@ def is_equal(self, other, advanced_check=True):
return False
if self.name != other.name:
return False
if self.created_at != other.created_at:
if self.created_at and other.created_at and self.created_at != other.created_at:
return False
if self.created_at_ui != other.created_at_ui:
return False
Expand Down Expand Up @@ -618,7 +618,7 @@ def is_equal(self, other, advanced_check=True):
return False
if self.host != other.host:
return False
if self.created_at != other.created_at:
if self.created_at and other.created_at and self.created_at != other.created_at:
return False
if self.created_at_ui != other.created_at_ui:
return False
Expand Down Expand Up @@ -688,7 +688,7 @@ def is_equal(self, other, advanced_check=True):
return False
if self.type != other.type:
return False
if self.created_at != other.created_at:
if self.created_at and other.created_at and self.created_at != other.created_at:
return False
if self.created_at_ui != other.created_at_ui:
return False
Expand Down
4 changes: 2 additions & 2 deletions kiali_qe/entities/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def is_equal(self, other, advanced_check=True):
return False
if self.workload_type != other.workload_type:
return False
if self.created_at != other.created_at:
if self.created_at and other.created_at and self.created_at != other.created_at:
return False
if self.created_at_ui != other.created_at_ui:
return False
Expand Down Expand Up @@ -206,7 +206,7 @@ def is_equal(self, other, advanced_check=True):
return False
if self.name != other.name:
return False
if self.created_at != other.created_at:
if self.created_at and other.created_at and self.created_at != other.created_at:
return False
if self.created_at_ui != other.created_at_ui:
return False
Expand Down
12 changes: 8 additions & 4 deletions kiali_qe/rest/openshift_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,25 +623,29 @@ def get_service_configs(self, namespace, service_name):
resource_type=CONFIG_TYPES[IstioConfigObjectType.VIRTUAL_SERVICE.text],
namespaces=[namespace])
for _vs_item in _all_vs_list:
if 'host {} '.format(service_name) in to_linear_string(
if self._is_host_in_config(namespace, service_name, to_linear_string(
self.istio_config_details(
namespace=namespace,
object_name=_vs_item.name,
object_type=IstioConfigObjectType.VIRTUAL_SERVICE.text).text):
object_type=IstioConfigObjectType.VIRTUAL_SERVICE.text).text)):
istio_configs.append(_vs_item)
_all_dr_list = self._resource_list(
attribute_name=CONFIG_TYPES[IstioConfigObjectType.DESTINATION_RULE.text],
resource_type=CONFIG_TYPES[IstioConfigObjectType.DESTINATION_RULE.text],
namespaces=[namespace])
for _dr_item in _all_dr_list:
if 'host {} '.format(service_name) in to_linear_string(
if self._is_host_in_config(namespace, service_name, to_linear_string(
self.istio_config_details(
namespace=namespace,
object_name=_dr_item.name,
object_type=IstioConfigObjectType.DESTINATION_RULE.text).text):
object_type=IstioConfigObjectType.DESTINATION_RULE.text).text)):
istio_configs.append(_dr_item)
return istio_configs

def _is_host_in_config(self, namespace, service_name, config):
return 'host {} '.format(service_name) in config or \
'host {}.{}.svc.cluster.local '.format(service_name, namespace) in config

def workload_details(self, namespace, workload_name, workload_type):
""" Returns the details of Workload
Args:
Expand Down
1 change: 1 addition & 0 deletions kiali_qe/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ def load_details_page(self, name, namespace, force_refresh, load_only=False):
self.open(name, namespace, force_refresh)
self.browser.wait_for_element(locator='//button[contains(., "YAML")]',
parent='//*[contains(@class, "pf-c-page__main-section")]')
wait_to_spinner_disappear(self.browser)
return self.page.content.get_details(name, load_only)

def assert_all_items(self, namespaces=[], filters=[], sort_options=[], force_clear_all=True):
Expand Down
8 changes: 5 additions & 3 deletions kiali_qe/tests/test_istio_objects_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from kiali_qe.components.error_codes import (
KIA0202,
KIA0201,
KIA0203,
KIA0209,
KIA1106,
KIA1107,
KIA0101,
Expand Down Expand Up @@ -107,8 +109,8 @@ def test_destination_rule_broken(kiali_client, openshift_client, browser):
kind='DestinationRule',
api_version='networking.istio.io/v1alpha3',
service_name=DETAILS,
error_messages=[KIA0202],
check_service_details=True)
error_messages=[KIA0203, KIA0209],
check_service_details=False)


@pytest.mark.p_crud_resource
Expand Down Expand Up @@ -474,7 +476,7 @@ def test_authpolicy_rules_deny_disabled(kiali_client, openshift_client, browser,


@pytest.mark.p_crud_resource
@pytest.mark.p_crud_group9
@pytest.mark.p_crud_group3
def test_peerauth_create(kiali_client, openshift_client, browser, pick_namespace):
namespace = pick_namespace(BOOKINFO_2)
name = 'peerauthtocreate'
Expand Down

0 comments on commit 8d682d7

Please sign in to comment.