mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 19:21:46 +00:00
Merge pull request #866 from weaveworks/852-processes
Rename Applications -> Process, sort topologies by rank.
This commit is contained in:
@@ -22,6 +22,7 @@ var (
|
||||
id: "pods",
|
||||
renderer: render.PodRenderer,
|
||||
Name: "Pods",
|
||||
Rank: 3,
|
||||
Options: map[string][]APITopologyOption{"system": {
|
||||
{"show", "System pods shown", false, render.FilterNoop},
|
||||
{"hide", "System pods hidden", true, render.FilterSystem},
|
||||
@@ -56,9 +57,10 @@ func init() {
|
||||
// be the verb to get to that state
|
||||
topologyRegistry.add(
|
||||
APITopologyDesc{
|
||||
id: "applications",
|
||||
id: "processes",
|
||||
renderer: render.FilterUnconnected(render.ProcessWithContainerNameRenderer),
|
||||
Name: "Applications",
|
||||
Name: "Processes",
|
||||
Rank: 1,
|
||||
Options: map[string][]APITopologyOption{"unconnected": {
|
||||
// Show the user why there are filtered nodes in this view.
|
||||
// Don't give them the option to show those nodes.
|
||||
@@ -66,8 +68,8 @@ func init() {
|
||||
}},
|
||||
},
|
||||
APITopologyDesc{
|
||||
id: "applications-by-name",
|
||||
parent: "applications",
|
||||
id: "processes-by-name",
|
||||
parent: "processes",
|
||||
renderer: render.FilterUnconnected(render.ProcessNameRenderer),
|
||||
Name: "by name",
|
||||
Options: map[string][]APITopologyOption{"unconnected": {
|
||||
@@ -79,6 +81,7 @@ func init() {
|
||||
id: "containers",
|
||||
renderer: render.ContainerWithImageNameRenderer,
|
||||
Name: "Containers",
|
||||
Rank: 2,
|
||||
Options: containerFilters,
|
||||
},
|
||||
APITopologyDesc{
|
||||
@@ -99,6 +102,7 @@ func init() {
|
||||
id: "hosts",
|
||||
renderer: render.HostRenderer,
|
||||
Name: "Hosts",
|
||||
Rank: 4,
|
||||
Options: map[string][]APITopologyOption{},
|
||||
},
|
||||
)
|
||||
@@ -117,6 +121,7 @@ type APITopologyDesc struct {
|
||||
renderer render.Renderer
|
||||
|
||||
Name string `json:"name"`
|
||||
Rank int `json:"rank"`
|
||||
Options map[string][]APITopologyOption `json:"options"`
|
||||
|
||||
URL string `json:"url"`
|
||||
|
||||
@@ -71,12 +71,12 @@ func TestAPITopologyContainers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAPITopologyApplications(t *testing.T) {
|
||||
func TestAPITopologyProcesses(t *testing.T) {
|
||||
ts := topologyServer()
|
||||
defer ts.Close()
|
||||
is404(t, ts, "/api/topology/applications/foobar")
|
||||
is404(t, ts, "/api/topology/processes/foobar")
|
||||
{
|
||||
body := getRawJSON(t, ts, "/api/topology/applications/"+expected.ServerProcessID)
|
||||
body := getRawJSON(t, ts, "/api/topology/processes/"+expected.ServerProcessID)
|
||||
var node app.APINode
|
||||
if err := json.Unmarshal(body, &node); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -88,7 +88,7 @@ func TestAPITopologyApplications(t *testing.T) {
|
||||
}
|
||||
|
||||
{
|
||||
body := getRawJSON(t, ts, "/api/topology/applications-by-name/"+
|
||||
body := getRawJSON(t, ts, "/api/topology/processes-by-name/"+
|
||||
url.QueryEscape(fixture.Client1Name))
|
||||
var node app.APINode
|
||||
if err := json.Unmarshal(body, &node); err != nil {
|
||||
@@ -133,7 +133,7 @@ func TestAPITopologyHosts(t *testing.T) {
|
||||
func TestAPITopologyWebsocket(t *testing.T) {
|
||||
ts := topologyServer()
|
||||
defer ts.Close()
|
||||
url := "/api/topology/applications/ws"
|
||||
url := "/api/topology/processes/ws"
|
||||
|
||||
// Not a websocket request
|
||||
res, _ := checkGet(t, ts, url)
|
||||
|
||||
@@ -58,7 +58,7 @@ export default class Topologies extends React.Component {
|
||||
|
||||
render() {
|
||||
const topologies = _.sortBy(this.props.topologies, function(topology) {
|
||||
return topology.name;
|
||||
return topology.rank;
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@@ -26,12 +26,12 @@ func TestComponentsAreAvailable(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplications(t *testing.T) {
|
||||
func TestProcesses(t *testing.T) {
|
||||
withContext(t, oneProbe, func() {
|
||||
topo := parseTopology(t, httpGet(t, fmt.Sprintf("http://localhost:%d/api/topology/applications", appPort)))
|
||||
topo := parseTopology(t, httpGet(t, fmt.Sprintf("http://localhost:%d/api/topology/processes", appPort)))
|
||||
assertAdjacent(t, topo["proc:node-1.2.3.4:apache"], "theinternet", "proc:node-192.168.1.1:wget")
|
||||
want := map[string]interface{}{"max_conn_count_tcp": float64(19)}
|
||||
have := parseEdge(t, httpGet(t, fmt.Sprintf("http://localhost:%d/api/topology/applications/%s/%s", appPort, "proc:node-192.168.1.1:wget", "theinternet")))
|
||||
have := parseEdge(t, httpGet(t, fmt.Sprintf("http://localhost:%d/api/topology/processes/%s/%s", appPort, "proc:node-192.168.1.1:wget", "theinternet")))
|
||||
if !reflect.DeepEqual(have, want) {
|
||||
t.Errorf("have: %#v, want %#v", have, want)
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func TestHosts(t *testing.T) {
|
||||
|
||||
func TestMultipleProbes(t *testing.T) {
|
||||
withContext(t, twoProbes, func() {
|
||||
topo := parseTopology(t, httpGet(t, fmt.Sprintf("http://localhost:%d/api/topology/applications", appPort)))
|
||||
topo := parseTopology(t, httpGet(t, fmt.Sprintf("http://localhost:%d/api/topology/processes", appPort)))
|
||||
assertAdjacent(t, topo["proc:node-1.2.3.4:apache"], "theinternet", "proc:node-192.168.1.1:wget", "proc:node-192.168.1.1:curl")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
|
||||
func renderTo(rpt report.Report, topology string) (render.RenderableNodes, error) {
|
||||
renderer, ok := map[string]render.Renderer{
|
||||
"applications": render.FilterUnconnected(render.ProcessWithContainerNameRenderer),
|
||||
"applications-by-name": render.FilterUnconnected(render.ProcessNameRenderer),
|
||||
"containers": render.ContainerWithImageNameRenderer,
|
||||
"containers-by-image": render.ContainerImageRenderer,
|
||||
"hosts": render.HostRenderer,
|
||||
"processes": render.FilterUnconnected(render.ProcessWithContainerNameRenderer),
|
||||
"processes-by-name": render.FilterUnconnected(render.ProcessNameRenderer),
|
||||
"containers": render.ContainerWithImageNameRenderer,
|
||||
"containers-by-image": render.ContainerImageRenderer,
|
||||
"hosts": render.HostRenderer,
|
||||
}[topology]
|
||||
if !ok {
|
||||
return render.RenderableNodes{}, fmt.Errorf("unknown topology %v", topology)
|
||||
|
||||
@@ -12,10 +12,10 @@ weave_on $HOST1 run -dti --name client alpine /bin/sh -c "while true; do \
|
||||
sleep 1; \
|
||||
done"
|
||||
|
||||
wait_for applications $HOST1 60 "nginx: worker process" nc
|
||||
wait_for processes $HOST1 60 "nginx: worker process" nc
|
||||
|
||||
has applications $HOST1 "nginx: worker process"
|
||||
has applications $HOST1 nc
|
||||
has_connection applications $HOST1 nc "nginx: worker process"
|
||||
has processes $HOST1 "nginx: worker process"
|
||||
has processes $HOST1 nc
|
||||
has_connection processes $HOST1 nc "nginx: worker process"
|
||||
|
||||
scope_end_suite
|
||||
@@ -19,9 +19,9 @@ done"
|
||||
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
|
||||
|
||||
check() {
|
||||
has applications $1 "nginx: worker process"
|
||||
has applications $1 nc
|
||||
has_connection applications $1 nc "nginx: worker process"
|
||||
has processes $1 "nginx: worker process"
|
||||
has processes $1 nc
|
||||
has_connection processes $1 nc "nginx: worker process"
|
||||
}
|
||||
|
||||
check $HOST1
|
||||
@@ -95,7 +95,7 @@ var (
|
||||
{report.Pod, NodeSummaryGroup{TopologyID: "pods", Label: "Pods", Columns: []string{}}},
|
||||
{report.ContainerImage, NodeSummaryGroup{TopologyID: "containers-by-image", Label: "Container Images", Columns: []string{}}},
|
||||
{report.Container, NodeSummaryGroup{TopologyID: "containers", Label: "Containers", Columns: []string{docker.CPUTotalUsage, docker.MemoryUsage}}},
|
||||
{report.Process, NodeSummaryGroup{TopologyID: "applications", Label: "Applications", Columns: []string{process.PID, process.CPUUsage, process.MemoryUsage}}},
|
||||
{report.Process, NodeSummaryGroup{TopologyID: "processes", Label: "Processes", Columns: []string{process.PID, process.CPUUsage, process.MemoryUsage}}},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@ func TestMakeDetailedHostNode(t *testing.T) {
|
||||
Nodes: []detailed.NodeSummary{containerNodeSummary},
|
||||
},
|
||||
{
|
||||
Label: "Applications",
|
||||
TopologyID: "applications",
|
||||
Label: "Processes",
|
||||
TopologyID: "processes",
|
||||
Columns: []string{process.PID, process.CPUUsage, process.MemoryUsage},
|
||||
Nodes: []detailed.NodeSummary{process1NodeSummary, process2NodeSummary},
|
||||
},
|
||||
@@ -156,8 +156,8 @@ func TestMakeDetailedContainerNode(t *testing.T) {
|
||||
Controls: []detailed.ControlInstance{},
|
||||
Children: []detailed.NodeSummaryGroup{
|
||||
{
|
||||
Label: "Applications",
|
||||
TopologyID: "applications",
|
||||
Label: "Processes",
|
||||
TopologyID: "processes",
|
||||
Columns: []string{process.PID, process.CPUUsage, process.MemoryUsage},
|
||||
Nodes: []detailed.NodeSummary{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user