diff --git a/app/api_listtopology.go b/app/api_topologies.go similarity index 100% rename from app/api_listtopology.go rename to app/api_topologies.go diff --git a/app/api_listtopology_test.go b/app/api_topologies_test.go similarity index 100% rename from app/api_listtopology_test.go rename to app/api_topologies_test.go diff --git a/app/api_topology_test.go b/app/api_topology_test.go index bd0848971..203ddbd58 100644 --- a/app/api_topology_test.go +++ b/app/api_topology_test.go @@ -24,21 +24,22 @@ func TestAPITopologyApplications(t *testing.T) { t.Fatalf("JSON parse error: %s", err) } equals(t, 4, len(topo.Nodes)) - node, ok := topo.Nodes["proc:node-a.local:curl"] + node, ok := topo.Nodes["pid:node-a.local:23128"] if !ok { t.Errorf("missing curl node") } - equals(t, report.NewIDList("proc:node-b.local:apache"), node.Adjacency) + equals(t, 1, len(node.Adjacency)) + equals(t, report.NewIDList("pid:node-b.local:215"), node.Adjacency) equals(t, report.NewIDList("hostA"), node.Origin) equals(t, "curl", node.LabelMajor) - equals(t, "node-a.local", node.LabelMinor) - equals(t, "curl", node.Rank) + equals(t, "node-a.local (23128)", node.LabelMinor) + equals(t, "23128", node.Rank) equals(t, false, node.Pseudo) } { // Node detail - body := getRawJSON(t, ts, "/api/topology/applications/proc:node-a.local:curl") + body := getRawJSON(t, ts, "/api/topology/applications/pid:node-a.local:23128") var node APINode if err := json.Unmarshal(body, &node); err != nil { t.Fatalf("JSON parse error: %s", err) @@ -48,7 +49,7 @@ func TestAPITopologyApplications(t *testing.T) { { // Edge detail - body := getRawJSON(t, ts, "/api/topology/applications/proc:node-a.local:curl/proc:node-b.local:apache") + body := getRawJSON(t, ts, "/api/topology/applications/pid:node-a.local:23128/pid:node-b.local:215") var edge APIEdge if err := json.Unmarshal(body, &edge); err != nil { t.Fatalf("JSON parse error: %s", err) diff --git a/app/router.go b/app/router.go index d6b6b8e7b..d121a7872 100644 --- a/app/router.go +++ b/app/router.go @@ -47,6 +47,6 @@ var topologyRegistry = map[string]struct { hasGrouped bool typ string }{ - "applications": {"Applications", selectProcess, report.ProcessName, true, "Process"}, + "applications": {"Applications", selectProcess, report.ProcessPID, true, "Process"}, "hosts": {"Hosts", selectNetwork, report.NetworkHostname, false, "Network"}, } diff --git a/report/mapping_functions.go b/report/mapping_functions.go index 8074a1753..3cbc93ce9 100644 --- a/report/mapping_functions.go +++ b/report/mapping_functions.go @@ -26,13 +26,14 @@ type MappedNode struct { type MapFunc func(string, NodeMetadata, bool) (MappedNode, bool) // ProcessPID takes a node NodeMetadata from a Process topology, and returns a -// representation based on the process PID. +// representation with the ID based on the process PID and the labels based +// on the process name. func ProcessPID(id string, m NodeMetadata, grouped bool) (MappedNode, bool) { var ( domain = m["domain"] pid = m["pid"] name = m["name"] - minor = fmt.Sprintf("%s (%s)", domain, name) + minor = fmt.Sprintf("%s (%s)", domain, pid) ) if grouped { @@ -42,7 +43,7 @@ func ProcessPID(id string, m NodeMetadata, grouped bool) (MappedNode, bool) { return MappedNode{ ID: fmt.Sprintf("pid:%s:%s", domain, pid), - Major: pid, + Major: name, Minor: minor, Rank: pid, }, pid != "" diff --git a/report/mapping_test.go b/report/mapping_test.go index c9671712f..d72378c53 100644 --- a/report/mapping_test.go +++ b/report/mapping_test.go @@ -73,8 +73,8 @@ func TestMapping(t *testing.T) { }, wantOK: true, wantID: "pid:hosta:42", - wantMajor: "42", - wantMinor: "hosta (curl)", + wantMajor: "curl", + wantMinor: "hosta (42)", wantRank: "42", }, {