From 67f80b808da2ae0e34f8fe36f4fb58423b55f78d Mon Sep 17 00:00:00 2001 From: Hayk Hovsepyan Date: Wed, 31 Mar 2021 16:33:10 +0200 Subject: [PATCH] Fixed failing tests. --- .../istio_objects/destination-rule-cb-broken.yaml | 8 +++----- kiali_qe/components/__init__.py | 8 ++++---- kiali_qe/entities/service.py | 8 ++++---- kiali_qe/entities/workload.py | 4 ++-- kiali_qe/rest/openshift_api.py | 12 ++++++++---- kiali_qe/tests/__init__.py | 1 + kiali_qe/tests/test_istio_objects_crud.py | 8 +++++--- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/data/resources/istio_objects/destination-rule-cb-broken.yaml b/data/resources/istio_objects/destination-rule-cb-broken.yaml index f0235232..01f30275 100644 --- a/data/resources/istio_objects/destination-rule-cb-broken.yaml +++ b/data/resources/istio_objects/destination-rule-cb-broken.yaml @@ -5,7 +5,7 @@ metadata: spec: labels: version: v2 - host: reviews-broken + host: reviews trafficPolicy: connectionPool: tcp: @@ -20,10 +20,8 @@ spec: subsets: - name: v1 labels: - version: v1 + version: v11 - name: v2 labels: version: v2 - - name: v3 - labels: - version: v3 \ No newline at end of file + - name: v3 \ No newline at end of file diff --git a/kiali_qe/components/__init__.py b/kiali_qe/components/__init__.py index e2007d1b..980758e1 100644 --- a/kiali_qe/components/__init__.py +++ b/kiali_qe/components/__init__.py @@ -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( @@ -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"]' @@ -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")]' @@ -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 = [] diff --git a/kiali_qe/entities/service.py b/kiali_qe/entities/service.py index 4c94781d..18cda16d 100644 --- a/kiali_qe/entities/service.py +++ b/kiali_qe/entities/service.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/kiali_qe/entities/workload.py b/kiali_qe/entities/workload.py index 90f6aa46..cc378d1d 100644 --- a/kiali_qe/entities/workload.py +++ b/kiali_qe/entities/workload.py @@ -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 @@ -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 diff --git a/kiali_qe/rest/openshift_api.py b/kiali_qe/rest/openshift_api.py index cd6bf257..e70b2ebb 100644 --- a/kiali_qe/rest/openshift_api.py +++ b/kiali_qe/rest/openshift_api.py @@ -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: diff --git a/kiali_qe/tests/__init__.py b/kiali_qe/tests/__init__.py index 06668c64..ccf3e414 100644 --- a/kiali_qe/tests/__init__.py +++ b/kiali_qe/tests/__init__.py @@ -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): diff --git a/kiali_qe/tests/test_istio_objects_crud.py b/kiali_qe/tests/test_istio_objects_crud.py index 9b6e55fe..f2a36fe8 100644 --- a/kiali_qe/tests/test_istio_objects_crud.py +++ b/kiali_qe/tests/test_istio_objects_crud.py @@ -16,6 +16,8 @@ from kiali_qe.components.error_codes import ( KIA0202, KIA0201, + KIA0203, + KIA0209, KIA1106, KIA1107, KIA0101, @@ -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 @@ -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'