Esempio n. 1
0
func TestMakeDetailedHostNode(t *testing.T) {
	renderableNode := render.HostRenderer.Render(fixture.Report)[render.MakeHostID(fixture.ClientHostID)]
	have := render.MakeDetailedNode(fixture.Report, renderableNode)
	want := render.DetailedNode{
		ID:         render.MakeHostID(fixture.ClientHostID),
		LabelMajor: "client",
		LabelMinor: "hostname.com",
		Pseudo:     false,
		Controls:   []render.ControlInstance{},
		Tables: []render.Table{
			{
				Title:   fmt.Sprintf("Host %q", fixture.ClientHostName),
				Numeric: false,
				Rank:    1,
				Rows: []render.Row{
					{
						Key:        "Load",
						ValueMajor: "0.01 0.01 0.01",
						ValueMinor: "",
					},
					{
						Key:        "Operating system",
						ValueMajor: "Linux",
						ValueMinor: "",
					},
				},
			},
			{
				Title:   "Connections",
				Numeric: false,
				Rank:    0,
				Rows: []render.Row{
					{
						Key:        "TCP connections",
						ValueMajor: "3",
						ValueMinor: "",
					},
					{
						Key:        "Client",
						ValueMajor: "Server",
						ValueMinor: "",
						Expandable: true,
					},
					{
						Key:        "10.10.10.20",
						ValueMajor: "192.168.1.1",
						ValueMinor: "",
						Expandable: true,
					},
				},
			},
		},
	}
	if !reflect.DeepEqual(want, have) {
		t.Errorf("%s", test.Diff(want, have))
	}
}
Esempio n. 2
0
// Individual nodes.
func handleNode(rep Reporter, t topologyView, w http.ResponseWriter, r *http.Request) {
	var (
		vars     = mux.Vars(r)
		nodeID   = vars["id"]
		rpt      = rep.Report()
		node, ok = t.renderer.Render(rep.Report())[nodeID]
	)
	if !ok {
		http.NotFound(w, r)
		return
	}
	respondWith(w, http.StatusOK, APINode{Node: render.MakeDetailedNode(rpt, node)})
}
Esempio n. 3
0
func TestMakeDetailedNode(t *testing.T) {
	renderableNode := render.ContainerRenderer.Render(test.Report)[test.ServerContainerID]
	have := render.MakeDetailedNode(test.Report, renderableNode)
	want := render.DetailedNode{
		ID:         test.ServerContainerID,
		LabelMajor: "server",
		LabelMinor: test.ServerHostName,
		Pseudo:     false,
		Tables: []render.Table{
			{
				Title:   "Connections",
				Numeric: true,
				Rank:    100,
				Rows: []render.Row{
					{"Egress packet rate", "75", "packets/sec"},
					{"Egress byte rate", "750", "Bps"},
				},
			},
			{
				Title:   "Origin Container",
				Numeric: false,
				Rank:    3,
				Rows: []render.Row{
					{"ID", test.ServerContainerID, ""},
					{"Name", "server", ""},
					{"Image ID", test.ServerContainerImageID, ""},
				},
			},
			{
				Title:   "Origin Process",
				Numeric: false,
				Rank:    2,
				Rows: []render.Row{
					{"Name (comm)", "apache", ""},
					{"PID", test.ServerPID, ""},
				},
			},
			{
				Title:   "Origin Host",
				Numeric: false,
				Rank:    1,
				Rows: []render.Row{
					{"Host name", test.ServerHostName, ""},
					{"Load", "0.01 0.01 0.01", ""},
					{"Operating system", "Linux", ""},
				},
			},
			{
				Title:   "Connection Details",
				Numeric: false,
				Rows: []render.Row{
					{"Local", "Remote", ""},
					{
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						fmt.Sprintf("%s:%s", test.UnknownClient1IP, test.ClientPort54010),
						"",
					},
					{
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						fmt.Sprintf("%s:%s", test.UnknownClient1IP, test.ClientPort54020),
						"",
					},
					{
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						fmt.Sprintf("%s:%s", test.UnknownClient3IP, test.ClientPort54020),
						"",
					},
					{
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						fmt.Sprintf("%s:%s", test.ClientIP, test.ClientPort54001),
						"",
					},
					{
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						fmt.Sprintf("%s:%s", test.ClientIP, test.ClientPort54002),
						"",
					},
					{
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						fmt.Sprintf("%s:%s", test.RandomClientIP, test.ClientPort12345),
						"",
					},
				},
			},
		},
	}
	if !reflect.DeepEqual(want, have) {
		t.Errorf("%s", test.Diff(want, have))
	}
}
Esempio n. 4
0
func TestMakeDetailedContainerNode(t *testing.T) {
	renderableNode := render.ContainerRenderer.Render(test.Report)[test.ServerContainerID]
	have := render.MakeDetailedNode(test.Report, renderableNode)
	want := render.DetailedNode{
		ID:         test.ServerContainerID,
		LabelMajor: "server",
		LabelMinor: test.ServerHostName,
		Pseudo:     false,
		Tables: []render.Table{
			{
				Title:   `Container Image "image/server"`,
				Numeric: false,
				Rank:    4,
				Rows: []render.Row{
					{"Image ID", test.ServerContainerImageID, "", false},
					{`Label "foo1"`, `bar1`, "", false},
					{`Label "foo2"`, `bar2`, "", false},
				},
			},
			{
				Title:   `Container "server"`,
				Numeric: false,
				Rank:    3,
				Rows: []render.Row{
					{"ID", test.ServerContainerID, "", false},
					{"Image ID", test.ServerContainerImageID, "", false},
					{fmt.Sprintf(`Label %q`, render.AmazonECSContainerNameLabel), `server`, "", false},
					{`Label "foo1"`, `bar1`, "", false},
					{`Label "foo2"`, `bar2`, "", false},
				},
			},
			{
				Title:   fmt.Sprintf(`Process "apache" (%s)`, test.ServerPID),
				Numeric: false,
				Rank:    2,
				Rows:    []render.Row{},
			},
			{
				Title:   fmt.Sprintf("Host %q", test.ServerHostName),
				Numeric: false,
				Rank:    1,
				Rows: []render.Row{
					{"Load", "0.01 0.01 0.01", "", false},
					{"Operating system", "Linux", "", false},
				},
			},
			{
				Title:   "Connections",
				Numeric: false,
				Rank:    0,
				Rows: []render.Row{
					{"Ingress packet rate", "105", "packets/sec", false},
					{"Ingress byte rate", "1.0", "KBps", false},
					{"Client", "Server", "", true},
					{
						fmt.Sprintf("%s:%s", test.UnknownClient1IP, test.UnknownClient1Port),
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						"",
						true,
					},
					{
						fmt.Sprintf("%s:%s", test.UnknownClient2IP, test.UnknownClient2Port),
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						"",
						true,
					},
					{
						fmt.Sprintf("%s:%s", test.UnknownClient3IP, test.UnknownClient3Port),
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						"",
						true,
					},
					{
						fmt.Sprintf("%s:%s", test.ClientIP, test.ClientPort54001),
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						"",
						true,
					},
					{
						fmt.Sprintf("%s:%s", test.ClientIP, test.ClientPort54002),
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						"",
						true,
					},
					{
						fmt.Sprintf("%s:%s", test.RandomClientIP, test.RandomClientPort),
						fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
						"",
						true,
					},
				},
			},
		},
	}
	if !reflect.DeepEqual(want, have) {
		t.Errorf("%s", test.Diff(want, have))
	}
}
Esempio n. 5
0
func TestMakeDetailedContainerNode(t *testing.T) {
	renderableNode := render.ContainerRenderer.Render(fixture.Report)[fixture.ServerContainerID]
	have := render.MakeDetailedNode(fixture.Report, renderableNode)
	want := render.DetailedNode{
		ID:         fixture.ServerContainerID,
		LabelMajor: "server",
		LabelMinor: fixture.ServerHostName,
		Rank:       "imageid456",
		Pseudo:     false,
		Controls:   []render.ControlInstance{},
		Tables: []render.Table{
			{
				Title:   `Container Image "image/server"`,
				Numeric: false,
				Rank:    4,
				Rows: []render.Row{
					{Key: "Image ID", ValueMajor: fixture.ServerContainerImageID},
					{Key: `Label "foo1"`, ValueMajor: `bar1`},
					{Key: `Label "foo2"`, ValueMajor: `bar2`},
				},
			},
			{
				Title:   `Container "server"`,
				Numeric: false,
				Rank:    3,
				Rows: []render.Row{
					{Key: "State", ValueMajor: "running"},
					{Key: "ID", ValueMajor: fixture.ServerContainerID},
					{Key: "Image ID", ValueMajor: fixture.ServerContainerImageID},
					{Key: fmt.Sprintf(`Label %q`, render.AmazonECSContainerNameLabel), ValueMajor: `server`},
					{Key: `Label "foo1"`, ValueMajor: `bar1`},
					{Key: `Label "foo2"`, ValueMajor: `bar2`},
					{Key: `Label "io.kubernetes.pod.name"`, ValueMajor: "ping/pong-b"},
				},
			},
			{
				Title:   fmt.Sprintf(`Process "apache" (%s)`, fixture.ServerPID),
				Numeric: false,
				Rank:    2,
				Rows:    []render.Row{},
			},
			{
				Title:   fmt.Sprintf("Host %q", fixture.ServerHostName),
				Numeric: false,
				Rank:    1,
				Rows: []render.Row{
					{Key: "Load (1m)", ValueMajor: "0.01", Metric: &fixture.LoadMetric, ValueType: "sparkline"},
					{Key: "Load (5m)", ValueMajor: "0.01", Metric: &fixture.LoadMetric, ValueType: "sparkline"},
					{Key: "Load (15m)", ValueMajor: "0.01", Metric: &fixture.LoadMetric, ValueType: "sparkline"},
					{Key: "Operating system", ValueMajor: "Linux"},
				},
			},
			{
				Title:   "Connections",
				Numeric: false,
				Rank:    0,
				Rows: []render.Row{
					{Key: "Ingress packet rate", ValueMajor: "105", ValueMinor: "packets/sec"},
					{Key: "Ingress byte rate", ValueMajor: "1.0", ValueMinor: "KBps"},
					{Key: "Client", ValueMajor: "Server", Expandable: true},
					{
						Key:        fmt.Sprintf("%s:%s", fixture.UnknownClient1IP, fixture.UnknownClient1Port),
						ValueMajor: fmt.Sprintf("%s:%s", fixture.ServerIP, fixture.ServerPort),
						Expandable: true,
					},
					{
						Key:        fmt.Sprintf("%s:%s", fixture.UnknownClient2IP, fixture.UnknownClient2Port),
						ValueMajor: fmt.Sprintf("%s:%s", fixture.ServerIP, fixture.ServerPort),
						Expandable: true,
					},
					{
						Key:        fmt.Sprintf("%s:%s", fixture.UnknownClient3IP, fixture.UnknownClient3Port),
						ValueMajor: fmt.Sprintf("%s:%s", fixture.ServerIP, fixture.ServerPort),
						Expandable: true,
					},
					{
						Key:        fmt.Sprintf("%s:%s", fixture.ClientIP, fixture.ClientPort54001),
						ValueMajor: fmt.Sprintf("%s:%s", fixture.ServerIP, fixture.ServerPort),
						Expandable: true,
					},
					{
						Key:        fmt.Sprintf("%s:%s", fixture.ClientIP, fixture.ClientPort54002),
						ValueMajor: fmt.Sprintf("%s:%s", fixture.ServerIP, fixture.ServerPort),
						Expandable: true,
					},
					{
						Key:        fmt.Sprintf("%s:%s", fixture.RandomClientIP, fixture.RandomClientPort),
						ValueMajor: fmt.Sprintf("%s:%s", fixture.ServerIP, fixture.ServerPort),
						Expandable: true,
					},
				},
			},
		},
	}
	if !reflect.DeepEqual(want, have) {
		t.Errorf("%s", test.Diff(want, have))
	}
}
Esempio n. 6
0
func TestMakeDetailedNode(t *testing.T) {
	renderableNode := render.ContainerRenderer.Render(test.Report)[test.ServerContainerID]
	have := render.MakeDetailedNode(test.Report, renderableNode)
	want := render.DetailedNode{
		ID:         test.ServerContainerID,
		LabelMajor: "server",
		LabelMinor: test.ServerHostName,
		Pseudo:     false,
		Tables: []render.Table{
			{
				Title:   "Connections",
				Numeric: true,
				Rank:    100,
				Rows: []render.Row{
					{"Bytes ingress", "150", ""},
					{"Bytes egress", "1500", ""},
				},
			},
			{
				Title:   "Origin Container",
				Numeric: false,
				Rank:    3,
				Rows: []render.Row{
					{"ID", test.ServerContainerID, ""},
					{"Name", "server", ""},
					{"Image ID", test.ServerContainerImageID, ""},
				},
			},
			{
				Title:   "Origin Process",
				Numeric: false,
				Rank:    2,
				Rows: []render.Row{
					{"Name (comm)", "apache", ""},
					{"PID", test.ServerPID, ""},
				},
			},
			{
				Title:   "Origin Host",
				Numeric: false,
				Rank:    1,
				Rows: []render.Row{
					{"Host name", test.ServerHostName, ""},
					{"Load", "0.01 0.01 0.01", ""},
					{"Operating system", "Linux", ""},
				},
			},
			{
				Title:   "Origin Endpoint",
				Numeric: false,
				Rows: []render.Row{
					{"Endpoint", test.ServerIP, ""},
					{"Port", test.ServerPort, ""},
				},
			},
		},
	}
	if !reflect.DeepEqual(want, have) {
		t.Errorf("%s", test.Diff(want, have))
	}
}