Skip to content

Commit

Permalink
Fixed Details page's cards Workloads, Applications and Services lists…
Browse files Browse the repository at this point in the history
… reading.
  • Loading branch information
hhovsepy committed May 10, 2021
1 parent 7090a78 commit b7ee781
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
17 changes: 8 additions & 9 deletions kiali_qe/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions kiali_qe/entities/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']\
Expand Down
2 changes: 2 additions & 0 deletions kiali_qe/entities/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']\
Expand Down
9 changes: 8 additions & 1 deletion kiali_qe/rest/kiali_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down Expand Up @@ -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)})
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions kiali_qe/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)\
Expand Down

0 comments on commit b7ee781

Please sign in to comment.