From 0e862993958ea212f6ffd1d3d44d64924e66fb3d Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Thu, 16 Nov 2023 09:58:02 +0530 Subject: [PATCH] chore: add check summary in topology tree --- models/components.go | 4 +- query/topology.go | 5 +- .../expectations/topology_child_tree.json | 146 ++--- .../topology_cluster_component_tree.json | 368 +++++------ .../topology_depth_1_child_tree.json | 99 +-- .../topology_depth_1_root_tree.json | 168 ++--- .../topology_depth_2_root_tree.json | 302 ++++----- .../expectations/topology_root_tree.json | 587 ++++++++++-------- .../topology_tree_with_agent_id.json | 50 +- ...pology_tree_with_id_and_status_filter.json | 133 ++-- .../topology_tree_with_label_filter.json | 100 +-- .../topology_tree_with_owner_filter.json | 133 ++-- .../topology_tree_with_status_filter.json | 227 ++++--- .../topology_tree_with_type_filter.json | 80 +-- tests/topology_test.go | 18 + types/component.go | 8 + 16 files changed, 1300 insertions(+), 1128 deletions(-) diff --git a/models/components.go b/models/components.go index a745b8a7..ee313b44 100644 --- a/models/components.go +++ b/models/components.go @@ -101,6 +101,7 @@ func (c *Component) Summarize() types.Summary { var s types.Summary s.Incidents = c.Summary.Incidents s.Insights = c.Summary.Insights + s.Checks = c.Summary.Checks if c.Components == nil { switch c.Status { @@ -113,8 +114,7 @@ func (c *Component) Summarize() types.Summary { case types.ComponentStatusInfo: s.Info++ } - s.Incidents = c.Summary.Incidents - s.Insights = c.Summary.Insights + s.SetProcessed(true) return s } diff --git a/query/topology.go b/query/topology.go index 0e8e5b59..3f1ac548 100644 --- a/query/topology.go +++ b/query/topology.go @@ -309,8 +309,9 @@ func createComponentTree(params TopologyOptions, components models.Components) [ // TODO: Try https://stackoverflow.com/questions/30101603/merging-concatenating-jsonb-columns-in-query c.Summary.Incidents = c.Incidents c.Summary.Insights = c.Analysis - c.Analysis = nil - c.Incidents = nil + c.Summary.Checks = c.Checks + + c.Analysis, c.Incidents, c.Checks = nil, nil, nil if c.ParentId != nil { if _, exists := compChildrenMap[c.ParentId.String()]; exists { diff --git a/tests/fixtures/expectations/topology_child_tree.json b/tests/fixtures/expectations/topology_child_tree.json index 8d39384a..f5618b67 100644 --- a/tests/fixtures/expectations/topology_child_tree.json +++ b/tests/fixtures/expectations/topology_child_tree.json @@ -1,73 +1,79 @@ { - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "children": [ - "018681ff-80ed-d10d-21ef-c74f152b085b", - "018681ff-b6c1-a14d-2fd4-8c7dac94cddd" - ], - "components": [ + "components": [ { - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics-api-574dc95b5d-mp64w", - "icon": "icon-kubernetes-pod", - "id": "018681ff-80ed-d10d-21ef-c74f152b085b", - "is_leaf": false, - "name": "logistics-api-574dc95b5d-mp64w", - "parent_id": "018681ff-559f-7183-19d1-7d898b4e1413", - "parents": [ - "018681fe-f5aa-37e9-83f7-47b5b0232d5e" - ], - "path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "tooltip": "Logistic API Pod", - "type": "KubernetesPod" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics-ui-676b85b87c-tjjcp", - "icon": "icon-kubernetes-pod", - "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", - "is_leaf": false, - "name": "logistics-ui-676b85b87c-tjjcp", - "parent_id": "018681ff-559f-7183-19d1-7d898b4e1413", - "parents": [ - "018681fe-f5aa-37e9-83f7-47b5b0232d5e" - ], - "path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "tooltip": "Logistic UI Pod", - "type": "KubernetesPod" + "id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/node-a", + "parent_id": "018681fe-b27e-7627-72c2-ad18e93f72f4", + "name": "node-a", + "status": "healthy", + "tooltip": "Node A", + "icon": "icon-kubernetes-node", + "type": "KubernetesNode", + "path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681fe-b27e-7627-72c2-ad18e93f72f4", + "summary": { + "healthy": 2 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681ff-80ed-d10d-21ef-c74f152b085b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics-api-574dc95b5d-mp64w", + "parent_id": "018681ff-559f-7183-19d1-7d898b4e1413", + "name": "logistics-api-574dc95b5d-mp64w", + "status": "healthy", + "tooltip": "Logistic API Pod", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "parents": [ + "018681fe-f5aa-37e9-83f7-47b5b0232d5e" + ] + }, + { + "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics-ui-676b85b87c-tjjcp", + "parent_id": "018681ff-559f-7183-19d1-7d898b4e1413", + "name": "logistics-ui-676b85b87c-tjjcp", + "status": "healthy", + "tooltip": "Logistic UI Pod", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "parents": [ + "018681fe-f5aa-37e9-83f7-47b5b0232d5e" + ] + } + ], + "children": [ + "018681ff-80ed-d10d-21ef-c74f152b085b", + "018681ff-b6c1-a14d-2fd4-8c7dac94cddd" + ] } - ], - "external_id": "dummy/node-a", - "icon": "icon-kubernetes-node", - "id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e", - "is_leaf": false, - "name": "node-a", - "parent_id": "018681fe-b27e-7627-72c2-ad18e93f72f4", - "path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681fe-b27e-7627-72c2-ad18e93f72f4", - "status": "healthy", - "summary": { - "healthy": 2 - }, - "tooltip": "Node A", - "type": "KubernetesNode" - } - ], - "healthStatuses": [ - "healthy" - ], - "tags": null, - "teams": [], - "types": [ - "KubernetesNode", - "KubernetesPod" - ] -} + ], + "healthStatuses": [ + "healthy" + ], + "teams": [], + "tags": null, + "types": [ + "KubernetesNode", + "KubernetesPod" + ] +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_cluster_component_tree.json b/tests/fixtures/expectations/topology_cluster_component_tree.json index b0681814..bca4a049 100644 --- a/tests/fixtures/expectations/topology_cluster_component_tree.json +++ b/tests/fixtures/expectations/topology_cluster_component_tree.json @@ -1,183 +1,205 @@ { - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ + "components": [ { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-e578-a926-e366-d2dc0646eafa", - "is_leaf": false, - "name": "logistics-worker-79cb67d8f5-lr66n", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" - } - ], - "icon": "icon-kubernetes-node", - "id": "018681ff-227e-4d71-b38e-0693cc862213", - "is_leaf": false, - "name": "node-b", - "status": "healthy", - "summary": { - "healthy": 1, + "id": "018681fe-8156-4b91-d178-caf8b3c2818c", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/cluster", + "name": "cluster", + "status": "healthy", + "tooltip": "Kubernetes Cluster", + "icon": "icon-cluster", + "type": "KubernetesCluster", + "summary": { + "healthy": 2, "insights": { - "security": { - "critical": 1 - } + "security": { + "critical": 1 + } } - }, - "type": "KubernetesNode" }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-80ed-d10d-21ef-c74f152b085b", - "is_leaf": false, - "name": "logistics-api-574dc95b5d-mp64w", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" + "id": "018681fe-b27e-7627-72c2-ad18e93f72f4", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/nodes", + "parent_id": "018681fe-8156-4b91-d178-caf8b3c2818c", + "name": "Nodes", + "status": "healthy", + "tooltip": "Kubernetes Nodes", + "icon": "icon-kubernetes-node", + "type": "KubernetesNodes", + "path": "018681fe-8156-4b91-d178-caf8b3c2818c", + "summary": { + "healthy": 2, + "insights": { + "security": { + "critical": 1 + } + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681ff-227e-4d71-b38e-0693cc862213", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "node-b", + "status": "healthy", + "icon": "icon-kubernetes-node", + "type": "KubernetesNode", + "summary": { + "healthy": 1, + "insights": { + "security": { + "critical": 1 + } + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681ff-e578-a926-e366-d2dc0646eafa", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-worker-79cb67d8f5-lr66n", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] + }, + { + "id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "node-a", + "status": "healthy", + "icon": "icon-kubernetes-node", + "type": "KubernetesNode", + "summary": { + "healthy": 2 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681ff-80ed-d10d-21ef-c74f152b085b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-api-574dc95b5d-mp64w", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-ui-676b85b87c-tjjcp", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] + } + ] }, { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", - "is_leaf": false, - "name": "logistics-ui-676b85b87c-tjjcp", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" + "id": "018681ff-559f-7183-19d1-7d898b4e1413", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/pods", + "parent_id": "018681fe-8156-4b91-d178-caf8b3c2818c", + "name": "Pods", + "status": "healthy", + "tooltip": "Kubernetes Pods", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPods", + "path": "018681fe-8156-4b91-d178-caf8b3c2818c", + "summary": { + "healthy": 3 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681ff-80ed-d10d-21ef-c74f152b085b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-api-574dc95b5d-mp64w", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-ui-676b85b87c-tjjcp", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681ff-e578-a926-e366-d2dc0646eafa", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-worker-79cb67d8f5-lr66n", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] } - ], - "icon": "icon-kubernetes-node", - "id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e", - "is_leaf": false, - "name": "node-a", - "status": "healthy", - "summary": { - "healthy": 2 - }, - "type": "KubernetesNode" - } - ], - "external_id": "dummy/nodes", - "icon": "icon-kubernetes-node", - "id": "018681fe-b27e-7627-72c2-ad18e93f72f4", - "is_leaf": false, - "name": "Nodes", - "parent_id": "018681fe-8156-4b91-d178-caf8b3c2818c", - "path": "018681fe-8156-4b91-d178-caf8b3c2818c", - "status": "healthy", - "summary": { - "healthy": 2, - "insights": { - "security": { - "critical": 1 - } - } - }, - "tooltip": "Kubernetes Nodes", - "type": "KubernetesNodes" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-80ed-d10d-21ef-c74f152b085b", - "is_leaf": false, - "name": "logistics-api-574dc95b5d-mp64w", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", - "is_leaf": false, - "name": "logistics-ui-676b85b87c-tjjcp", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-e578-a926-e366-d2dc0646eafa", - "is_leaf": false, - "name": "logistics-worker-79cb67d8f5-lr66n", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" - } - ], - "external_id": "dummy/pods", - "icon": "icon-kubernetes-pod", - "id": "018681ff-559f-7183-19d1-7d898b4e1413", - "is_leaf": false, - "name": "Pods", - "parent_id": "018681fe-8156-4b91-d178-caf8b3c2818c", - "path": "018681fe-8156-4b91-d178-caf8b3c2818c", - "status": "healthy", - "summary": { - "healthy": 3 - }, - "tooltip": "Kubernetes Pods", - "type": "KubernetesPods" - } - ], - "external_id": "dummy/cluster", - "icon": "icon-cluster", - "id": "018681fe-8156-4b91-d178-caf8b3c2818c", - "is_leaf": false, - "name": "cluster", - "status": "healthy", - "summary": { - "healthy": 2, - "insights": { - "security": { - "critical": 1 - } + ] } - }, - "tooltip": "Kubernetes Cluster", - "type": "KubernetesCluster" - } - ], - "healthStatuses": [ - "healthy" - ], - "tags": null, - "teams": [], - "types": [ - "KubernetesCluster", - "KubernetesNode", - "KubernetesNodes", - "KubernetesPod", - "KubernetesPods" - ] -} + ], + "healthStatuses": [ + "healthy" + ], + "teams": [], + "tags": null, + "types": [ + "KubernetesCluster", + "KubernetesNode", + "KubernetesNodes", + "KubernetesPod", + "KubernetesPods" + ] +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_depth_1_child_tree.json b/tests/fixtures/expectations/topology_depth_1_child_tree.json index b0882d7c..bb6733ea 100644 --- a/tests/fixtures/expectations/topology_depth_1_child_tree.json +++ b/tests/fixtures/expectations/topology_depth_1_child_tree.json @@ -1,52 +1,53 @@ { - "components": [ - { - "id": "018681fd-5770-336f-227c-259435d7fc6b", - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics-api", - "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "name": "logistics-api", - "labels": { - "telemetry": "enabled" - }, - "status": "warning", - "type": "Application", - "owner": "logistics-team", - "path": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "summary": { - "healthy": 1, - "unhealthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } - }, - "insights": { - "security": { - "critical": 1 - } + "components": [ + { + "id": "018681fd-5770-336f-227c-259435d7fc6b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics-api", + "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "name": "logistics-api", + "labels": { + "telemetry": "enabled" + }, + "status": "warning", + "type": "Application", + "owner": "logistics-team", + "path": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "summary": { + "healthy": 1, + "unhealthy": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "healthy": 2, + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" } - }, - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30", - "checks": { - "healthy": 2 - } - } - ], - "healthStatuses": [ - "healthy", - "unhealthy" - ], - "teams": [], - "tags": { - "telemetry": [ - "enabled" + ], + "healthStatuses": [ + "healthy", + "unhealthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] + }, + "types": [ + "Application", + "Database" ] - }, - "types": [ - "Application", - "Database" - ] -} +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_depth_1_root_tree.json b/tests/fixtures/expectations/topology_depth_1_root_tree.json index b7c43a1c..811a20ca 100644 --- a/tests/fixtures/expectations/topology_depth_1_root_tree.json +++ b/tests/fixtures/expectations/topology_depth_1_root_tree.json @@ -1,88 +1,92 @@ { - "components": [ - { - "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics", - "name": "logistics", - "labels": { - "telemetry": "enabled" - }, - "status": "warning", - "type": "Entity", - "owner": "logistics-team", - "summary": { - "healthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } + "components": [ + { + "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics", + "name": "logistics", + "labels": { + "telemetry": "enabled" + }, + "status": "warning", + "type": "Entity", + "owner": "logistics-team", + "summary": { + "healthy": 1, + "warning": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "healthy": 2, + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" }, - "insights": { - "security": { - "critical": 1 - } + { + "id": "018681fe-8156-4b91-d178-caf8b3c2818c", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/cluster", + "name": "cluster", + "status": "healthy", + "tooltip": "Kubernetes Cluster", + "icon": "icon-cluster", + "type": "KubernetesCluster", + "summary": { + "healthy": 2, + "insights": { + "security": { + "critical": 1 + } + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" }, - "warning": 1 - }, - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30" - }, - { - "id": "018681fe-8156-4b91-d178-caf8b3c2818c", - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/cluster", - "name": "cluster", - "status": "healthy", - "type": "KubernetesCluster", - "summary": { - "healthy": 2, - "insights": { - "security": { - "critical": 1 - } + { + "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", + "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", + "external_id": "dummy/payments-api", + "name": "payments-api", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" } - }, - "icon": "icon-cluster", - "tooltip": "Kubernetes Cluster", - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30" + ], + "healthStatuses": [ + "healthy", + "unhealthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] }, - { - "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", - "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", - "external_id": "dummy/payments-api", - "name": "payments-api", - "status": "healthy", - "type": "Application", - "summary": { - "healthy": 1 - }, - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30" - } - ], - "healthStatuses": [ - "healthy", - "unhealthy" - ], - "teams": [], - "tags": { - "telemetry": [ - "enabled" + "types": [ + "Application", + "Database", + "Entity", + "KubernetesCluster", + "KubernetesNode", + "KubernetesNodes", + "KubernetesPod", + "KubernetesPods" ] - }, - "types": [ - "Application", - "Database", - "Entity", - "KubernetesCluster", - "KubernetesNode", - "KubernetesNodes", - "KubernetesPod", - "KubernetesPods" - ] -} +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_depth_2_root_tree.json b/tests/fixtures/expectations/topology_depth_2_root_tree.json index db9e9d37..ac87f215 100644 --- a/tests/fixtures/expectations/topology_depth_2_root_tree.json +++ b/tests/fixtures/expectations/topology_depth_2_root_tree.json @@ -1,151 +1,173 @@ { - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ + "components": [ { - "agent_id": "00000000-0000-0000-0000-000000000000", - "id": "018681fd-5770-336f-227c-259435d7fc6b", - "is_leaf": false, - "labels": { - "telemetry": "enabled" - }, - "name": "logistics-api", - "status": "warning", - "summary": { - "healthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } + "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics", + "name": "logistics", + "labels": { + "telemetry": "enabled" }, - "insights": { - "security": { - "critical": 1 - } + "status": "warning", + "type": "Entity", + "owner": "logistics-team", + "summary": { + "healthy": 1, + "warning": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "healthy": 2, + "unhealthy": 1 + } }, - "unhealthy": 1 - }, - "type": "Application" + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681fd-5770-336f-227c-259435d7fc6b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-api", + "labels": { + "telemetry": "enabled" + }, + "status": "warning", + "type": "Application", + "summary": { + "healthy": 1, + "unhealthy": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "healthy": 2, + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681fd-c1ff-16ee-dff0-8c8796e4263e", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-ui", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] }, { - "agent_id": "00000000-0000-0000-0000-000000000000", - "id": "018681fd-c1ff-16ee-dff0-8c8796e4263e", - "is_leaf": false, - "name": "logistics-ui", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "Application" - } - ], - "external_id": "dummy/logistics", - "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "is_leaf": false, - "labels": { - "telemetry": "enabled" - }, - "name": "logistics", - "owner": "logistics-team", - "status": "warning", - "summary": { - "healthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } - }, - "insights": { - "security": { - "critical": 1 - } - }, - "warning": 1 - }, - "type": "Entity" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-node", - "id": "018681fe-b27e-7627-72c2-ad18e93f72f4", - "is_leaf": false, - "name": "Nodes", - "status": "healthy", - "summary": { - "healthy": 2, - "insights": { - "security": { - "critical": 1 - } - } - }, - "type": "KubernetesNodes" + "id": "018681fe-8156-4b91-d178-caf8b3c2818c", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/cluster", + "name": "cluster", + "status": "healthy", + "tooltip": "Kubernetes Cluster", + "icon": "icon-cluster", + "type": "KubernetesCluster", + "summary": { + "healthy": 2, + "insights": { + "security": { + "critical": 1 + } + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681fe-b27e-7627-72c2-ad18e93f72f4", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "Nodes", + "status": "healthy", + "icon": "icon-kubernetes-node", + "type": "KubernetesNodes", + "summary": { + "healthy": 2, + "insights": { + "security": { + "critical": 1 + } + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681ff-559f-7183-19d1-7d898b4e1413", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "Pods", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPods", + "summary": { + "healthy": 3 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] }, { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-559f-7183-19d1-7d898b4e1413", - "is_leaf": false, - "name": "Pods", - "status": "healthy", - "summary": { - "healthy": 3 - }, - "type": "KubernetesPods" - } - ], - "external_id": "dummy/cluster", - "icon": "icon-cluster", - "id": "018681fe-8156-4b91-d178-caf8b3c2818c", - "is_leaf": false, - "name": "cluster", - "status": "healthy", - "summary": { - "healthy": 2, - "insights": { - "security": { - "critical": 1 - } + "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", + "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", + "external_id": "dummy/payments-api", + "name": "payments-api", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" } - }, - "tooltip": "Kubernetes Cluster", - "type": "KubernetesCluster" + ], + "healthStatuses": [ + "healthy", + "unhealthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] }, - { - "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", - "external_id": "dummy/payments-api", - "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", - "is_leaf": false, - "name": "payments-api", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "Application" - } - ], - "healthStatuses": [ - "healthy", - "unhealthy" - ], - "tags": { - "telemetry": [ - "enabled" + "types": [ + "Application", + "Database", + "Entity", + "KubernetesCluster", + "KubernetesNode", + "KubernetesNodes", + "KubernetesPod", + "KubernetesPods" ] - }, - "teams": [], - "types": [ - "Application", - "Database", - "Entity", - "KubernetesCluster", - "KubernetesNode", - "KubernetesNodes", - "KubernetesPod", - "KubernetesPods" - ] -} +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_root_tree.json b/tests/fixtures/expectations/topology_root_tree.json index badef8d1..5764ffb4 100644 --- a/tests/fixtures/expectations/topology_root_tree.json +++ b/tests/fixtures/expectations/topology_root_tree.json @@ -1,295 +1,340 @@ { - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ + "components": [ { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "id": "018681fe-010a-6647-74ad-58b3a136dfe4", - "is_leaf": false, - "name": "logistics-worker", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "Application" + "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics", + "name": "logistics", + "labels": { + "telemetry": "enabled" }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "id": "018681fe-4529-c50f-26fd-530fa9c57319", - "is_leaf": false, - "name": "logistics-db", - "status": "unhealthy", - "status_reason": "database not accepting connections", - "summary": { + "status": "warning", + "type": "Entity", + "owner": "logistics-team", + "summary": { + "healthy": 1, + "warning": 1, "incidents": { - "availability": { - "Blocker": 1 - } + "availability": { + "Blocker": 1 + } }, "insights": { - "security": { - "critical": 1 - } + "security": { + "critical": 1 + } }, - "unhealthy": 1 - }, - "type": "Database" - } - ], - "id": "018681fd-5770-336f-227c-259435d7fc6b", - "is_leaf": false, - "labels": { - "telemetry": "enabled" - }, - "name": "logistics-api", - "status": "warning", - "summary": { - "healthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } - }, - "insights": { - "security": { - "critical": 1 - } + "checks": { + "healthy": 2, + "unhealthy": 1 + } }, - "unhealthy": 1 - }, - "type": "Application" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "id": "018681fd-c1ff-16ee-dff0-8c8796e4263e", - "is_leaf": false, - "name": "logistics-ui", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "Application" - } - ], - "external_id": "dummy/logistics", - "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "is_leaf": false, - "labels": { - "telemetry": "enabled" - }, - "name": "logistics", - "owner": "logistics-team", - "status": "warning", - "summary": { - "healthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } - }, - "insights": { - "security": { - "critical": 1 - } - }, - "warning": 1 - }, - "type": "Entity" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681fd-5770-336f-227c-259435d7fc6b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-api", + "labels": { + "telemetry": "enabled" + }, + "status": "warning", + "type": "Application", + "summary": { + "healthy": 1, + "unhealthy": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "healthy": 2, + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681fe-010a-6647-74ad-58b3a136dfe4", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-worker", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681fe-4529-c50f-26fd-530fa9c57319", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-db", + "status": "unhealthy", + "status_reason": "database not accepting connections", + "type": "Database", + "summary": { + "unhealthy": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] + }, { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-e578-a926-e366-d2dc0646eafa", - "is_leaf": false, - "name": "logistics-worker-79cb67d8f5-lr66n", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" + "id": "018681fd-c1ff-16ee-dff0-8c8796e4263e", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-ui", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" } - ], - "icon": "icon-kubernetes-node", - "id": "018681ff-227e-4d71-b38e-0693cc862213", - "is_leaf": false, - "name": "node-b", - "status": "healthy", - "summary": { - "healthy": 1, + ] + }, + { + "id": "018681fe-8156-4b91-d178-caf8b3c2818c", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/cluster", + "name": "cluster", + "status": "healthy", + "tooltip": "Kubernetes Cluster", + "icon": "icon-cluster", + "type": "KubernetesCluster", + "summary": { + "healthy": 2, "insights": { - "security": { - "critical": 1 - } + "security": { + "critical": 1 + } } - }, - "type": "KubernetesNode" }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-80ed-d10d-21ef-c74f152b085b", - "is_leaf": false, - "name": "logistics-api-574dc95b5d-mp64w", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" + "id": "018681fe-b27e-7627-72c2-ad18e93f72f4", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "Nodes", + "status": "healthy", + "icon": "icon-kubernetes-node", + "type": "KubernetesNodes", + "summary": { + "healthy": 2, + "insights": { + "security": { + "critical": 1 + } + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681ff-227e-4d71-b38e-0693cc862213", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "node-b", + "status": "healthy", + "icon": "icon-kubernetes-node", + "type": "KubernetesNode", + "summary": { + "healthy": 1, + "insights": { + "security": { + "critical": 1 + } + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681ff-e578-a926-e366-d2dc0646eafa", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-worker-79cb67d8f5-lr66n", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] + }, + { + "id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "node-a", + "status": "healthy", + "icon": "icon-kubernetes-node", + "type": "KubernetesNode", + "summary": { + "healthy": 2 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681ff-80ed-d10d-21ef-c74f152b085b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-api-574dc95b5d-mp64w", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-ui-676b85b87c-tjjcp", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] + } + ] }, { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", - "is_leaf": false, - "name": "logistics-ui-676b85b87c-tjjcp", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" + "id": "018681ff-559f-7183-19d1-7d898b4e1413", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "Pods", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPods", + "summary": { + "healthy": 3 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681ff-80ed-d10d-21ef-c74f152b085b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-api-574dc95b5d-mp64w", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-ui-676b85b87c-tjjcp", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681ff-e578-a926-e366-d2dc0646eafa", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-worker-79cb67d8f5-lr66n", + "status": "healthy", + "icon": "icon-kubernetes-pod", + "type": "KubernetesPod", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] } - ], - "icon": "icon-kubernetes-node", - "id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e", - "is_leaf": false, - "name": "node-a", - "status": "healthy", - "summary": { - "healthy": 2 - }, - "type": "KubernetesNode" - } - ], - "icon": "icon-kubernetes-node", - "id": "018681fe-b27e-7627-72c2-ad18e93f72f4", - "is_leaf": false, - "name": "Nodes", - "status": "healthy", - "summary": { - "healthy": 2, - "insights": { - "security": { - "critical": 1 - } - } - }, - "type": "KubernetesNodes" + ] }, { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-80ed-d10d-21ef-c74f152b085b", - "is_leaf": false, - "name": "logistics-api-574dc95b5d-mp64w", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" - }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd", - "is_leaf": false, - "name": "logistics-ui-676b85b87c-tjjcp", - "status": "healthy", - "summary": { + "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", + "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", + "external_id": "dummy/payments-api", + "name": "payments-api", + "status": "healthy", + "type": "Application", + "summary": { "healthy": 1 - }, - "type": "KubernetesPod" }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "icon": "icon-kubernetes-pod", - "id": "018681ff-e578-a926-e366-d2dc0646eafa", - "is_leaf": false, - "name": "logistics-worker-79cb67d8f5-lr66n", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "KubernetesPod" - } - ], - "icon": "icon-kubernetes-pod", - "id": "018681ff-559f-7183-19d1-7d898b4e1413", - "is_leaf": false, - "name": "Pods", - "status": "healthy", - "summary": { - "healthy": 3 - }, - "type": "KubernetesPods" - } - ], - "external_id": "dummy/cluster", - "icon": "icon-cluster", - "id": "018681fe-8156-4b91-d178-caf8b3c2818c", - "is_leaf": false, - "name": "cluster", - "status": "healthy", - "summary": { - "healthy": 2, - "insights": { - "security": { - "critical": 1 - } + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" } - }, - "tooltip": "Kubernetes Cluster", - "type": "KubernetesCluster" + ], + "healthStatuses": [ + "healthy", + "unhealthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] }, - { - "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", - "external_id": "dummy/payments-api", - "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", - "is_leaf": false, - "name": "payments-api", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "Application" - } - ], - "healthStatuses": [ - "healthy", - "unhealthy" - ], - "tags": { - "telemetry": [ - "enabled" + "types": [ + "Application", + "Database", + "Entity", + "KubernetesCluster", + "KubernetesNode", + "KubernetesNodes", + "KubernetesPod", + "KubernetesPods" ] - }, - "teams": [], - "types": [ - "Application", - "Database", - "Entity", - "KubernetesCluster", - "KubernetesNode", - "KubernetesNodes", - "KubernetesPod", - "KubernetesPods" - ] -} +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_tree_with_agent_id.json b/tests/fixtures/expectations/topology_tree_with_agent_id.json index 53f9904a..291913d0 100644 --- a/tests/fixtures/expectations/topology_tree_with_agent_id.json +++ b/tests/fixtures/expectations/topology_tree_with_agent_id.json @@ -1,25 +1,27 @@ { - "components": [ - { - "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", - "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", - "external_id": "dummy/payments-api", - "name": "payments-api", - "status": "healthy", - "type": "Application", - "summary": { - "healthy": 1 - }, - "is_leaf": false - } - ], - "healthStatuses": [ - "healthy" - ], - "teams": [], - "tags": null, - "types": [ - "Application", - "KubernetesPod" - ] -} + "components": [ + { + "id": "4643e4de-6215-4c71-9600-9cf69b2cbbee", + "agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1", + "external_id": "dummy/payments-api", + "name": "payments-api", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" + } + ], + "healthStatuses": [ + "healthy" + ], + "teams": [], + "tags": null, + "types": [ + "Application", + "KubernetesPod" + ] +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_tree_with_id_and_status_filter.json b/tests/fixtures/expectations/topology_tree_with_id_and_status_filter.json index 45134bd9..7372f654 100644 --- a/tests/fixtures/expectations/topology_tree_with_id_and_status_filter.json +++ b/tests/fixtures/expectations/topology_tree_with_id_and_status_filter.json @@ -1,70 +1,71 @@ { - "components": [ - { - "id": "018681fd-5770-336f-227c-259435d7fc6b", - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics-api", - "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "name": "logistics-api", - "labels": { - "telemetry": "enabled" - }, - "status": "warning", - "type": "Application", - "owner": "logistics-team", - "path": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "summary": { - "healthy": 1, - "unhealthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } - }, - "insights": { - "security": { - "critical": 1 - } - } - }, - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30", - "checks": { - "healthy": 2 - }, - "components": [ + "components": [ { - "id": "018681fe-010a-6647-74ad-58b3a136dfe4", - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics-worker", - "parent_id": "018681fd-5770-336f-227c-259435d7fc6b", - "name": "logistics-worker", - "status": "healthy", - "type": "Application", - "path": "018681fc-e54f-bd4f-42be-068a9a69eeb5.018681fd-5770-336f-227c-259435d7fc6b", - "summary": { - "healthy": 1 - }, - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30" + "id": "018681fd-5770-336f-227c-259435d7fc6b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics-api", + "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "name": "logistics-api", + "labels": { + "telemetry": "enabled" + }, + "status": "warning", + "type": "Application", + "owner": "logistics-team", + "path": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "summary": { + "healthy": 1, + "unhealthy": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "healthy": 2, + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681fe-010a-6647-74ad-58b3a136dfe4", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics-worker", + "parent_id": "018681fd-5770-336f-227c-259435d7fc6b", + "name": "logistics-worker", + "status": "healthy", + "type": "Application", + "path": "018681fc-e54f-bd4f-42be-068a9a69eeb5.018681fd-5770-336f-227c-259435d7fc6b", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" + } + ] } - ] - } - ], - "healthStatuses": [ - "healthy", - "unhealthy" - ], - "teams": [], - "tags": { - "telemetry": [ - "enabled" + ], + "healthStatuses": [ + "healthy", + "unhealthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] + }, + "types": [ + "Application", + "Database" ] - }, - "types": [ - "Application", - "Database" - ] -} +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_tree_with_label_filter.json b/tests/fixtures/expectations/topology_tree_with_label_filter.json index c3d661f0..bba8a29b 100644 --- a/tests/fixtures/expectations/topology_tree_with_label_filter.json +++ b/tests/fixtures/expectations/topology_tree_with_label_filter.json @@ -1,46 +1,60 @@ { - "components": [ - { - "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "components": [ + "components": [ { - "id": "018681fd-5770-336f-227c-259435d7fc6b", - "checks": { - "healthy": 2 - }, - "agent_id": "00000000-0000-0000-0000-000000000000", - "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "name": "logistics-api", - "labels": { - "telemetry": "enabled" - }, - "status": "healthy", - "type": "Application", - "summary": { - "healthy": 1 - }, - "is_leaf": false + "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics", + "name": "logistics", + "labels": { + "telemetry": "enabled" + }, + "status": "healthy", + "type": "Entity", + "owner": "logistics-team", + "summary": { + "healthy": 1, + "checks": { + "healthy": 2 + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681fd-5770-336f-227c-259435d7fc6b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "name": "logistics-api", + "labels": { + "telemetry": "enabled" + }, + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1, + "checks": { + "healthy": 2 + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] } - ], - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics", - "name": "logistics", - "labels": { - "telemetry": "enabled" - }, - "status": "healthy", - "type": "Entity", - "owner": "logistics-team", - "summary": { - "healthy": 1 - }, - "is_leaf": false - } - ], - "healthStatuses": ["healthy"], - "teams": [], - "tags": { - "telemetry": ["enabled"] - }, - "types": ["Application", "Entity"] -} + ], + "healthStatuses": [ + "healthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] + }, + "types": [ + "Application", + "Entity" + ] +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_tree_with_owner_filter.json b/tests/fixtures/expectations/topology_tree_with_owner_filter.json index d503e9ad..192418d0 100644 --- a/tests/fixtures/expectations/topology_tree_with_owner_filter.json +++ b/tests/fixtures/expectations/topology_tree_with_owner_filter.json @@ -1,67 +1,74 @@ { - "components": [ - { - "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics", - "name": "logistics", - "labels": { - "telemetry": "enabled" - }, - "status": "healthy", - "type": "Entity", - "owner": "logistics-team", - "summary": { - "healthy": 2 - }, - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30", - "components": [ + "components": [ { - "id": "018681fd-5770-336f-227c-259435d7fc6b", - "agent_id": "00000000-0000-0000-0000-000000000000", - "checks": { - "healthy": 2 - }, - "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "name": "logistics-api", - "labels": { - "telemetry": "enabled" - }, - "status": "healthy", - "type": "Application", - "summary": { - "healthy": 1 - }, - "is_leaf": false - }, - { - "id": "018681fd-c1ff-16ee-dff0-8c8796e4263e", - "agent_id": "00000000-0000-0000-0000-000000000000", - "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "name": "logistics-ui", - "status": "healthy", - "type": "Application", - "summary": { - "healthy": 1 - }, - "is_leaf": false + "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics", + "name": "logistics", + "labels": { + "telemetry": "enabled" + }, + "status": "healthy", + "type": "Entity", + "owner": "logistics-team", + "summary": { + "healthy": 2, + "checks": { + "healthy": 2 + } + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681fd-5770-336f-227c-259435d7fc6b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "name": "logistics-api", + "labels": { + "telemetry": "enabled" + }, + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1, + "checks": { + "healthy": 2 + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681fd-c1ff-16ee-dff0-8c8796e4263e", + "agent_id": "00000000-0000-0000-0000-000000000000", + "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "name": "logistics-ui", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] } - ] - } - ], - "healthStatuses": [ - "healthy" - ], - "teams": [], - "tags": { - "telemetry": [ - "enabled" + ], + "healthStatuses": [ + "healthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] + }, + "types": [ + "Application", + "Entity" ] - }, - "types": [ - "Application", - "Entity" - ] -} +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_tree_with_status_filter.json b/tests/fixtures/expectations/topology_tree_with_status_filter.json index c8ace2e2..9637d387 100644 --- a/tests/fixtures/expectations/topology_tree_with_status_filter.json +++ b/tests/fixtures/expectations/topology_tree_with_status_filter.json @@ -1,112 +1,133 @@ { - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "components": [ + "components": [ { - "agent_id": "00000000-0000-0000-0000-000000000000", - "checks": { - "healthy": 2 - }, - "components": [ - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "id": "018681fe-010a-6647-74ad-58b3a136dfe4", - "is_leaf": false, - "name": "logistics-worker", - "status": "healthy", - "summary": { - "healthy": 1 - }, - "type": "Application" + "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics", + "name": "logistics", + "labels": { + "telemetry": "enabled" }, - { - "agent_id": "00000000-0000-0000-0000-000000000000", - "id": "018681fe-4529-c50f-26fd-530fa9c57319", - "is_leaf": false, - "name": "logistics-db", - "status": "unhealthy", - "status_reason": "database not accepting connections", - "summary": { + "status": "warning", + "type": "Entity", + "owner": "logistics-team", + "summary": { + "healthy": 1, + "warning": 1, "incidents": { - "availability": { - "Blocker": 1 - } + "availability": { + "Blocker": 1 + } }, "insights": { - "security": { - "critical": 1 - } + "security": { + "critical": 1 + } }, - "unhealthy": 1 - }, - "type": "Database" - } - ], - "id": "018681fd-5770-336f-227c-259435d7fc6b", - "is_leaf": false, - "labels": { - "telemetry": "enabled" - }, - "name": "logistics-api", - "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "status": "warning", - "summary": { - "healthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } + "checks": { + "healthy": 2, + "unhealthy": 1 + } }, - "insights": { - "security": { - "critical": 1 - } - }, - "unhealthy": 1 - }, - "type": "Application" + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30", + "components": [ + { + "id": "018681fd-5770-336f-227c-259435d7fc6b", + "agent_id": "00000000-0000-0000-0000-000000000000", + "parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "name": "logistics-api", + "labels": { + "telemetry": "enabled" + }, + "status": "warning", + "type": "Application", + "summary": { + "healthy": 1, + "unhealthy": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "healthy": 2, + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z", + "components": [ + { + "id": "018681fe-010a-6647-74ad-58b3a136dfe4", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-worker", + "status": "healthy", + "type": "Application", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + }, + { + "id": "018681fe-4529-c50f-26fd-530fa9c57319", + "agent_id": "00000000-0000-0000-0000-000000000000", + "name": "logistics-db", + "status": "unhealthy", + "status_reason": "database not accepting connections", + "type": "Database", + "summary": { + "unhealthy": 1, + "incidents": { + "availability": { + "Blocker": 1 + } + }, + "insights": { + "security": { + "critical": 1 + } + }, + "checks": { + "unhealthy": 1 + } + }, + "is_leaf": false, + "created_at": "0001-01-01T00:00:00Z", + "updated_at": "0001-01-01T00:00:00Z" + } + ] + } + ] } - ], - "external_id": "dummy/logistics", - "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "is_leaf": false, - "labels": { - "telemetry": "enabled" - }, - "name": "logistics", - "owner": "logistics-team", - "status": "warning", - "summary": { - "healthy": 1, - "incidents": { - "availability": { - "Blocker": 1 - } - }, - "insights": { - "security": { - "critical": 1 - } - }, - "warning": 1 - }, - "type": "Entity" - } - ], - "healthStatuses": ["healthy", "unhealthy"], - "teams": [], - "tags": { - "telemetry": ["enabled"] - }, - "types": [ - "Application", - "Database", - "Entity", - "KubernetesCluster", - "KubernetesNode", - "KubernetesNodes", - "KubernetesPod", - "KubernetesPods" - ] -} + ], + "healthStatuses": [ + "healthy", + "unhealthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] + }, + "types": [ + "Application", + "Database", + "Entity", + "KubernetesCluster", + "KubernetesNode", + "KubernetesNodes", + "KubernetesPod", + "KubernetesPods" + ] +} \ No newline at end of file diff --git a/tests/fixtures/expectations/topology_tree_with_type_filter.json b/tests/fixtures/expectations/topology_tree_with_type_filter.json index 99265a8e..743d7372 100644 --- a/tests/fixtures/expectations/topology_tree_with_type_filter.json +++ b/tests/fixtures/expectations/topology_tree_with_type_filter.json @@ -1,42 +1,42 @@ { - "components": [ - { - "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", - "agent_id": "00000000-0000-0000-0000-000000000000", - "external_id": "dummy/logistics", - "name": "logistics", - "labels": { - "telemetry": "enabled" - }, - "status": "healthy", - "type": "Entity", - "owner": "logistics-team", - "summary": { - "healthy": 1 - }, - "is_leaf": false, - "created_at": "2023-01-01T05:29:00+05:30", - "updated_at": "2023-01-01T05:29:00+05:30" - } - ], - "healthStatuses": [ - "healthy", - "unhealthy" - ], - "teams": [], - "tags": { - "telemetry": [ - "enabled" + "components": [ + { + "id": "018681fc-e54f-bd4f-42be-068a9a69eeb5", + "agent_id": "00000000-0000-0000-0000-000000000000", + "external_id": "dummy/logistics", + "name": "logistics", + "labels": { + "telemetry": "enabled" + }, + "status": "healthy", + "type": "Entity", + "owner": "logistics-team", + "summary": { + "healthy": 1 + }, + "is_leaf": false, + "created_at": "2023-01-01T05:29:00+05:30", + "updated_at": "2023-01-01T05:29:00+05:30" + } + ], + "healthStatuses": [ + "healthy", + "unhealthy" + ], + "teams": [], + "tags": { + "telemetry": [ + "enabled" + ] + }, + "types": [ + "Application", + "Database", + "Entity", + "KubernetesCluster", + "KubernetesNode", + "KubernetesNodes", + "KubernetesPod", + "KubernetesPods" ] - }, - "types": [ - "Application", - "Database", - "Entity", - "KubernetesCluster", - "KubernetesNode", - "KubernetesNodes", - "KubernetesPod", - "KubernetesPods" - ] -} +} \ No newline at end of file diff --git a/tests/topology_test.go b/tests/topology_test.go index 50acd3e4..0441aa18 100644 --- a/tests/topology_test.go +++ b/tests/topology_test.go @@ -1,7 +1,9 @@ package tests import ( + "encoding/json" "fmt" + "os" "github.com/flanksource/duty/models" "github.com/flanksource/duty/query" @@ -31,9 +33,25 @@ func prettytree(mytree []*models.Component) { } } +// For debugging +// nolint +func writeJSONToFile(filepath string, data any) error { + b, err := json.MarshalIndent(data, "", " ") + if err != nil { + return err + } + + err = os.WriteFile(filepath, b, 0644) + if err != nil { + return err + } + return nil +} + func testTopologyJSON(opts query.TopologyOptions, path string) { tree, err := query.Topology(testutils.DefaultContext, opts) Expect(err).ToNot(HaveOccurred()) + matcher.MatchFixture(path, tree, `del(.. | .created_at?, .updated_at?)`) } diff --git a/types/component.go b/types/component.go index 815a8b7a..5c0a702a 100644 --- a/types/component.go +++ b/types/component.go @@ -28,6 +28,7 @@ type Summary struct { Info int `json:"info,omitempty"` Incidents map[string]map[string]int `json:"incidents,omitempty"` Insights map[string]map[string]int `json:"insights,omitempty"` + Checks map[string]int `json:"checks,omitempty"` // processed is used to prevent from being caluclated twice processed bool @@ -96,6 +97,13 @@ func (s Summary) Add(b Summary, n string) Summary { } } + if s.Checks == nil { + s.Checks = make(map[string]int) + } + for status, count := range b.Checks { + s.Checks[status] += count + } + return s }