mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 11:56:39 +00:00
use constants for the topology names in Parents/metadata/metrics
This commit is contained in:
@@ -334,7 +334,7 @@ func (c *container) GetNode(hostID string, localAddrs []net.IP) report.Node {
|
||||
).WithMetrics(
|
||||
c.metrics(),
|
||||
).WithParents(report.Sets{
|
||||
"container_image": report.MakeStringSet(report.MakeContainerImageNodeID(c.container.Image)),
|
||||
report.ContainerImage: report.MakeStringSet(report.MakeContainerImageNodeID(c.container.Image)),
|
||||
})
|
||||
|
||||
if c.container.State.Paused {
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestContainer(t *testing.T) {
|
||||
"cpu_total_usage": report.MakeMetric(),
|
||||
"memory_usage": report.MakeMetric().Add(now, 12345),
|
||||
}).WithParents(report.Sets{
|
||||
"container_image": report.MakeStringSet(report.MakeContainerImageNodeID("baz")),
|
||||
report.ContainerImage: report.MakeStringSet(report.MakeContainerImageNodeID("baz")),
|
||||
})
|
||||
test.Poll(t, 100*time.Millisecond, want, func() interface{} {
|
||||
node := c.GetNode("scope", []net.IP{})
|
||||
|
||||
@@ -85,8 +85,8 @@ func (t *Tagger) tag(tree process.Tree, topology *report.Topology) {
|
||||
topology.AddNode(nodeID, report.MakeNodeWith(map[string]string{
|
||||
ContainerID: c.ID(),
|
||||
}).WithParents(report.Sets{
|
||||
"container": report.MakeStringSet(report.MakeContainerNodeID(c.ID())),
|
||||
"container_image": report.MakeStringSet(report.MakeContainerImageNodeID(c.Image())),
|
||||
report.Container: report.MakeStringSet(report.MakeContainerNodeID(c.ID())),
|
||||
report.ContainerImage: report.MakeStringSet(report.MakeContainerImageNodeID(c.Image())),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ func TestTagger(t *testing.T) {
|
||||
wantNode = report.MakeNodeWith(map[string]string{
|
||||
docker.ContainerID: "ping",
|
||||
}).WithParents(report.Sets{
|
||||
"container": report.MakeStringSet(report.MakeContainerNodeID("ping")),
|
||||
"container_image": report.MakeStringSet(report.MakeContainerImageNodeID("baz")),
|
||||
report.Container: report.MakeStringSet(report.MakeContainerNodeID("ping")),
|
||||
report.ContainerImage: report.MakeStringSet(report.MakeContainerImageNodeID("baz")),
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func (t Tagger) Tag(r report.Report) (report.Report, error) {
|
||||
report.ProbeID: t.probeID,
|
||||
}
|
||||
parents = report.Sets{
|
||||
"host": report.MakeStringSet(t.hostNodeID),
|
||||
report.Host: report.MakeStringSet(t.hostNodeID),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestTagger(t *testing.T) {
|
||||
report.HostNodeID: report.MakeHostNodeID(hostID),
|
||||
report.ProbeID: probeID,
|
||||
}).WithParents(report.Sets{
|
||||
"host": report.MakeStringSet(report.MakeHostNodeID(hostID)),
|
||||
report.Host: report.MakeStringSet(report.MakeHostNodeID(hostID)),
|
||||
}))
|
||||
rpt, _ := host.NewTagger(hostID, probeID).Tag(r)
|
||||
have := rpt.Process.Nodes[endpointNodeID].Copy()
|
||||
|
||||
@@ -90,7 +90,7 @@ func (p *pod) GetNode() report.Node {
|
||||
continue
|
||||
}
|
||||
n = n.WithParents(report.Sets{
|
||||
"service": report.MakeStringSet(report.MakeServiceNodeID(p.Namespace(), segments[1])),
|
||||
report.Service: report.MakeStringSet(report.MakeServiceNodeID(p.Namespace(), segments[1])),
|
||||
})
|
||||
}
|
||||
return n
|
||||
|
||||
@@ -65,7 +65,7 @@ func (r *Reporter) podTopology(services []Service) (report.Topology, report.Topo
|
||||
PodID: p.ID(),
|
||||
Namespace: p.Namespace(),
|
||||
}).WithParents(report.Sets{
|
||||
"pod": report.MakeStringSet(nodeID),
|
||||
report.Pod: report.MakeStringSet(nodeID),
|
||||
})
|
||||
for _, containerID := range p.ContainerIDs() {
|
||||
containers.AddNode(report.MakeContainerNodeID(containerID), container)
|
||||
|
||||
@@ -120,7 +120,7 @@ func TestReporter(t *testing.T) {
|
||||
kubernetes.PodContainerIDs: "container1 container2",
|
||||
kubernetes.ServiceIDs: "ping/pongservice",
|
||||
}).WithParents(report.Sets{
|
||||
"service": report.MakeStringSet(serviceID),
|
||||
report.Service: report.MakeStringSet(serviceID),
|
||||
})).AddNode(pod2ID, report.MakeNodeWith(map[string]string{
|
||||
kubernetes.PodID: "ping/pong-b",
|
||||
kubernetes.PodName: "pong-b",
|
||||
@@ -129,7 +129,7 @@ func TestReporter(t *testing.T) {
|
||||
kubernetes.PodContainerIDs: "container3 container4",
|
||||
kubernetes.ServiceIDs: "ping/pongservice",
|
||||
}).WithParents(report.Sets{
|
||||
"service": report.MakeStringSet(serviceID),
|
||||
report.Service: report.MakeStringSet(serviceID),
|
||||
}))
|
||||
want.Service = report.MakeTopology().AddNode(serviceID, report.MakeNodeWith(map[string]string{
|
||||
kubernetes.ServiceID: "ping/pongservice",
|
||||
@@ -141,22 +141,22 @@ func TestReporter(t *testing.T) {
|
||||
kubernetes.PodID: "ping/pong-a",
|
||||
kubernetes.Namespace: "ping",
|
||||
}).WithParents(report.Sets{
|
||||
"pod": report.MakeStringSet(pod1ID),
|
||||
report.Pod: report.MakeStringSet(pod1ID),
|
||||
})).AddNode(report.MakeContainerNodeID("container2"), report.MakeNodeWith(map[string]string{
|
||||
kubernetes.PodID: "ping/pong-a",
|
||||
kubernetes.Namespace: "ping",
|
||||
}).WithParents(report.Sets{
|
||||
"pod": report.MakeStringSet(pod1ID),
|
||||
report.Pod: report.MakeStringSet(pod1ID),
|
||||
})).AddNode(report.MakeContainerNodeID("container3"), report.MakeNodeWith(map[string]string{
|
||||
kubernetes.PodID: "ping/pong-b",
|
||||
kubernetes.Namespace: "ping",
|
||||
}).WithParents(report.Sets{
|
||||
"pod": report.MakeStringSet(pod2ID),
|
||||
report.Pod: report.MakeStringSet(pod2ID),
|
||||
})).AddNode(report.MakeContainerNodeID("container4"), report.MakeNodeWith(map[string]string{
|
||||
kubernetes.PodID: "ping/pong-b",
|
||||
kubernetes.Namespace: "ping",
|
||||
}).WithParents(report.Sets{
|
||||
"pod": report.MakeStringSet(pod2ID),
|
||||
report.Pod: report.MakeStringSet(pod2ID),
|
||||
}))
|
||||
|
||||
reporter := kubernetes.NewReporter(mockClientInstance)
|
||||
|
||||
@@ -33,8 +33,8 @@ func TestApply(t *testing.T) {
|
||||
from report.Topology
|
||||
via string
|
||||
}{
|
||||
{endpointNode.Merge(report.MakeNode().WithID("c").WithTopology("endpoint")), r.Endpoint, endpointNodeID},
|
||||
{addressNode.Merge(report.MakeNode().WithID("d").WithTopology("address")), r.Address, addressNodeID},
|
||||
{endpointNode.Merge(report.MakeNode().WithID("c").WithTopology(report.Endpoint)), r.Endpoint, endpointNodeID},
|
||||
{addressNode.Merge(report.MakeNode().WithID("d").WithTopology(report.Address)), r.Address, addressNodeID},
|
||||
} {
|
||||
if want, have := tuple.want, tuple.from.Nodes[tuple.via]; !reflect.DeepEqual(want, have) {
|
||||
t.Errorf("want %+v, have %+v", want, have)
|
||||
|
||||
@@ -17,15 +17,15 @@ func (topologyTagger) Name() string { return "Topology" }
|
||||
// Tag implements Tagger
|
||||
func (topologyTagger) Tag(r report.Report) (report.Report, error) {
|
||||
for name, t := range map[string]*report.Topology{
|
||||
"endpoint": &(r.Endpoint),
|
||||
"address": &(r.Address),
|
||||
"process": &(r.Process),
|
||||
"container": &(r.Container),
|
||||
"container_image": &(r.ContainerImage),
|
||||
"pod": &(r.Pod),
|
||||
"service": &(r.Service),
|
||||
"host": &(r.Host),
|
||||
"overlay": &(r.Overlay),
|
||||
report.Endpoint: &(r.Endpoint),
|
||||
report.Address: &(r.Address),
|
||||
report.Process: &(r.Process),
|
||||
report.Container: &(r.Container),
|
||||
report.ContainerImage: &(r.ContainerImage),
|
||||
report.Pod: &(r.Pod),
|
||||
report.Service: &(r.Service),
|
||||
report.Host: &(r.Host),
|
||||
report.Overlay: &(r.Overlay),
|
||||
} {
|
||||
for id, node := range t.Nodes {
|
||||
t.AddNode(id, node.WithID(id).WithTopology(name))
|
||||
|
||||
Reference in New Issue
Block a user