diff --git a/kiali_qe/components/__init__.py b/kiali_qe/components/__init__.py index a615f65f..78cd8e90 100644 --- a/kiali_qe/components/__init__.py +++ b/kiali_qe/components/__init__.py @@ -2840,6 +2840,8 @@ def get_details(self, load_only=False): _card_view_pods = CardViewWorkloadPods(self.parent, self.locator, self.logger) + _card_view_apps = CardViewApplications(self.parent, self.locator, self.logger) + _card_view_services = CardViewServices(self.parent, self.locator, self.logger) _card_view_istio_config = CardViewIstioConfig(self.parent, self.locator, self.logger) @@ -2866,6 +2868,7 @@ def get_details(self, load_only=False): icon=self._get_additional_details_icon(), pods=_card_view_pods.all_items, services=_card_view_services.all_items, + applications=_card_view_apps.all_items, istio_configs=_card_view_istio_config.all_items, labels=self._get_details_labels(), traffic_tab=_traffic_tab, @@ -2959,7 +2962,7 @@ def get_details(self, load_only=False): selectors=self._get_details_selectors(), istio_configs=self.card_view_istio_config.all_items, workloads=_card_view_wl.all_items, - applictions=_card_view_apps.all_items, + applications=_card_view_apps.all_items, traffic_tab=_traffic_tab, inbound_metrics=_inbound_metrics, traces_tab=_traces_tab) @@ -3122,8 +3125,7 @@ def all_items(self): class CardViewAppWorkloads(CardViewAbstract): - WORKLOADS_TEXT = 'Workloads' - ROWS = '//h5[contains(text(), "{}")]/../ul/li'.format(WORKLOADS_TEXT) + ROWS = '//ul[contains(@id, "workload-list")]//li' @property def items(self): @@ -3287,8 +3289,7 @@ def items(self): class CardViewApplications(CardViewAbstract): - APPLICATIONS_TEXT = 'Applications' - ROWS = '//h5[contains(text(), "{}")]/../ul/li'.format(APPLICATIONS_TEXT) + ROWS = '//ul[contains(@id, "app-list")]//li' @property def items(self): @@ -3302,8 +3303,7 @@ def items(self): class CardViewWorkloads(CardViewAbstract): - WORKLOADS_TEXT = 'Workloads' - ROWS = '//h5[contains(text(), "{}")]/../div//ul//li'.format(WORKLOADS_TEXT) + ROWS = '//ul[contains(@id, "workload-list")]//li' @property def items(self): @@ -3317,8 +3317,7 @@ def items(self): class CardViewServices(CardViewAbstract): - SERVICES_TEXT = 'Services' - ROWS = '//h5[contains(text(), "{}")]/../ul/li'.format(SERVICES_TEXT) + ROWS = '//ul[contains(@id, "service-list")]//li' @property def items(self): diff --git a/kiali_qe/entities/service.py b/kiali_qe/entities/service.py index 170a863d..a631c8d0 100644 --- a/kiali_qe/entities/service.py +++ b/kiali_qe/entities/service.py @@ -161,6 +161,8 @@ def __init__(self, name, created_at, service_type, if 'destination_rules' in kwargs else None self.workloads = kwargs['workloads']\ if 'workloads' in kwargs else None + self.applications = kwargs['applications']\ + if 'applications' in kwargs else None self.traffic_tab = kwargs['traffic_tab']\ if 'traffic_tab' in kwargs else None self.inbound_metrics = kwargs['inbound_metrics']\ diff --git a/kiali_qe/entities/workload.py b/kiali_qe/entities/workload.py index edd02891..869fb313 100644 --- a/kiali_qe/entities/workload.py +++ b/kiali_qe/entities/workload.py @@ -87,6 +87,8 @@ def __init__(self, name, workload_type, created_at, resource_version, if 'unavailableReplicas' in kwargs else None self.services = kwargs['services']\ if 'services' in kwargs else None + self.applications = kwargs['applications']\ + if 'applications' in kwargs else None self.traffic_tab = kwargs['traffic_tab']\ if 'traffic_tab' in kwargs else None self.logs_tab = kwargs['logs_tab']\ diff --git a/kiali_qe/rest/kiali_api.py b/kiali_qe/rest/kiali_api.py index 8acfb047..51c90cbc 100644 --- a/kiali_qe/rest/kiali_api.py +++ b/kiali_qe/rest/kiali_api.py @@ -562,6 +562,9 @@ def service_details(self, namespace, service_name): if _service_data['endpoints']: for _endpoint in _service_data['endpoints'][0]['addresses']: endpoints.append(_endpoint['ip']) + _labels = self.get_labels(_service_data['service']) + _applications = set([_a.name for _a in self.application_list(namespaces=[namespace]) + if _labels['app'] == _a.name]) _validations = [] if _service_data['validations'] \ and len(_service_data['validations']['service']) > 0: @@ -582,12 +585,13 @@ def service_details(self, namespace, service_name): endpoints=endpoints, validations=_validations, ports=_ports.strip(), - labels=self.get_labels(_service_data['service']), + labels=_labels, selectors=self.get_selectors(_service_data['service']), health=_service_health.is_healthy() if _service_health else None, service_status=_service_health, icon=self.get_icon_type(_service_data), workloads=workloads, + applications=_applications, traffic=source_workloads, virtual_services=virtual_services, destination_rules=destination_rules, @@ -643,6 +647,8 @@ def workload_details(self, namespace, workload_name, workload_type): workload_name=_workload_data['name']) _labels = self.get_labels(_workload_data) + _applications = set([_a.name for _a in self.application_list(namespaces=[namespace]) + if _labels['app'] == _a.name]) _config_list = self.istio_config_list( namespaces=[namespace], config_names=[], params={'workloadSelector': dict_to_params(_labels)}) @@ -660,6 +666,7 @@ def workload_details(self, namespace, workload_name, workload_type): traffic=_destination_services, pods=_all_pods, services=_services, + applications=_applications, istio_configs=_config_list) return _workload diff --git a/kiali_qe/tests/__init__.py b/kiali_qe/tests/__init__.py index d0bd10d5..447b02be 100644 --- a/kiali_qe/tests/__init__.py +++ b/kiali_qe/tests/__init__.py @@ -1271,6 +1271,10 @@ def assert_details(self, name, namespace, workload_type, check_metrics=False, workload_details_ui.workload_status.is_healthy(), workload_details_ui.health, workload_details_ui.name) + assert is_equal(workload_details_ui.applications, + workload_details_rest.applications) + assert is_equal(workload_details_ui.services, + workload_details_rest.services) all_pods = [] for pod_ui in workload_details_ui.pods: all_pods.append(pod_ui.name) @@ -1570,6 +1574,8 @@ def assert_details(self, name, namespace, check_metrics=False, advanced_check=False), \ 'Service UI {} not equal to OC {}'\ .format(service_details_ui, service_details_oc) + assert is_equal(service_details_ui.applications, + service_details_rest.applications) assert len(service_details_ui.workloads)\ == len(service_details_rest.workloads) assert len(service_details_ui.istio_configs)\