Skip to content

Commit

Permalink
Merge pull request #866 from weaveworks/852-processes
Browse files Browse the repository at this point in the history
Rename Applications -> Process, sort topologies by rank.
  • Loading branch information
paulbellamy committed Feb 2, 2016
2 parents ed56261 + 6f9fdaa commit 1e4b872
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 31 deletions.
13 changes: 9 additions & 4 deletions app/api_topologies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -56,18 +57,19 @@ 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.
{"hide", "Unconnected nodes hidden", true, render.FilterNoop},
}},
},
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": {
Expand All @@ -79,6 +81,7 @@ func init() {
id: "containers",
renderer: render.ContainerWithImageNameRenderer,
Name: "Containers",
Rank: 2,
Options: containerFilters,
},
APITopologyDesc{
Expand All @@ -99,6 +102,7 @@ func init() {
id: "hosts",
renderer: render.HostRenderer,
Name: "Hosts",
Rank: 4,
Options: map[string][]APITopologyOption{},
},
)
Expand All @@ -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"`
Expand Down
10 changes: 5 additions & 5 deletions app/api_topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion client/app/scripts/components/topologies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 4 additions & 4 deletions experimental/_integration/easy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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")
})
}
Expand Down
10 changes: 5 additions & 5 deletions experimental/graphviz/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion render/detailed/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}},
}
)

Expand Down
8 changes: 4 additions & 4 deletions render/detailed/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
Expand Down Expand Up @@ -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{
{
Expand Down

0 comments on commit 1e4b872

Please sign in to comment.