Adding resolved prop to service map node (#959)

* Adding resolved prop to service map node

* fixing tests
This commit is contained in:
Igor Gov 2022-04-03 15:32:21 +03:00 committed by GitHub
parent 59ad8d8fad
commit 6a7fad430c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 24 deletions

View File

@ -101,16 +101,18 @@ func (s *ServiceMapControllerSuite) TestGet() {
// response nodes // response nodes
aNode := servicemap.ServiceMapNode{ aNode := servicemap.ServiceMapNode{
Id: 1, Id: 1,
Name: TCPEntryA.Name, Name: TCPEntryA.Name,
Entry: TCPEntryA, Entry: TCPEntryA,
Count: 1, Resolved: true,
Count: 1,
} }
bNode := servicemap.ServiceMapNode{ bNode := servicemap.ServiceMapNode{
Id: 2, Id: 2,
Name: TCPEntryB.Name, Name: TCPEntryB.Name,
Entry: TCPEntryB, Entry: TCPEntryB,
Count: 1, Resolved: true,
Count: 1,
} }
assert.Contains(response.Nodes, aNode) assert.Contains(response.Nodes, aNode)
assert.Contains(response.Nodes, bNode) assert.Contains(response.Nodes, bNode)

View File

@ -18,10 +18,11 @@ type ServiceMapResponse struct {
} }
type ServiceMapNode struct { type ServiceMapNode struct {
Id int `json:"id"` Id int `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Entry *tapApi.TCP `json:"entry"` Entry *tapApi.TCP `json:"entry"`
Count int `json:"count"` Count int `json:"count"`
Resolved bool `json:"resolved"`
} }
type ServiceMapEdge struct { type ServiceMapEdge struct {

View File

@ -227,10 +227,11 @@ func (s *defaultServiceMap) GetNodes() []ServiceMapNode {
var nodes []ServiceMapNode var nodes []ServiceMapNode
for i, n := range s.graph.Nodes { for i, n := range s.graph.Nodes {
nodes = append(nodes, ServiceMapNode{ nodes = append(nodes, ServiceMapNode{
Id: n.id, Id: n.id,
Name: string(i), Name: string(i),
Entry: n.entry, Resolved: n.entry.Name != UnresolvedNodeName,
Count: n.count, Entry: n.entry,
Count: n.count,
}) })
} }
return nodes return nodes
@ -243,16 +244,18 @@ func (s *defaultServiceMap) GetEdges() []ServiceMapEdge {
for _, p := range s.graph.Edges[u][v].data { for _, p := range s.graph.Edges[u][v].data {
edges = append(edges, ServiceMapEdge{ edges = append(edges, ServiceMapEdge{
Source: ServiceMapNode{ Source: ServiceMapNode{
Id: s.graph.Nodes[u].id, Id: s.graph.Nodes[u].id,
Name: string(u), Name: string(u),
Entry: s.graph.Nodes[u].entry, Entry: s.graph.Nodes[u].entry,
Count: s.graph.Nodes[u].count, Resolved: s.graph.Nodes[u].entry.Name != UnresolvedNodeName,
Count: s.graph.Nodes[u].count,
}, },
Destination: ServiceMapNode{ Destination: ServiceMapNode{
Id: s.graph.Nodes[v].id, Id: s.graph.Nodes[v].id,
Name: string(v), Name: string(v),
Entry: s.graph.Nodes[v].entry, Entry: s.graph.Nodes[v].entry,
Count: s.graph.Nodes[v].count, Resolved: s.graph.Nodes[v].entry.Name != UnresolvedNodeName,
Count: s.graph.Nodes[v].count,
}, },
Count: p.count, Count: p.count,
Protocol: p.protocol, Protocol: p.protocol,