Exemplo n.º 1
0
Arquivo: node.go Projeto: rnd-ua/scope
func containerParent(n report.Node) Parent {
	label, _ := render.GetRenderableContainerName(n)
	return Parent{
		ID:         render.MakeContainerID(n.Metadata[docker.ContainerID]),
		Label:      label,
		TopologyID: "containers",
	}
}
Exemplo n.º 2
0
func containerParent(n report.Node) Parent {
	label, _ := render.GetRenderableContainerName(n)
	containerID, _ := n.Latest.Lookup(docker.ContainerID)
	return Parent{
		ID:         render.MakeContainerID(containerID),
		Label:      label,
		TopologyID: "containers",
	}
}
Exemplo n.º 3
0
func containerNodeSummary(nmd report.Node) NodeSummary {
	label, _ := render.GetRenderableContainerName(nmd)
	return NodeSummary{
		ID:       render.MakeContainerID(nmd.Metadata[docker.ContainerID]),
		Label:    label,
		Linkable: true,
		Metadata: containerNodeMetadata(nmd),
		Metrics:  containerNodeMetrics(nmd),
	}
}
			Nodes: report.Nodes{
				serverHostNodeID: report.MakeNodeWith(map[string]string{
					report.HostNodeID: serverHostNodeID,
				}).WithSets(report.EmptySets.
					Add(host.LocalNetworks, report.MakeStringSet("192.168.0.0/16")),
				).WithID(serverHostNodeID).WithTopology(report.Host),
			},
		},
	}

	want = (render.RenderableNodes{
		render.TheInternetID: {
			ID:         render.TheInternetID,
			LabelMajor: render.TheInternetMajor,
			Pseudo:     true,
			Node:       report.MakeNode().WithAdjacent(render.MakeContainerID(containerID)),
		},
		render.MakeContainerID(containerID): {
			ID:          render.MakeContainerID(containerID),
			LabelMajor:  containerName,
			LabelMinor:  serverHostID,
			Rank:        "",
			Pseudo:      false,
			Node:        report.MakeNode(),
			ControlNode: containerNodeID,
		},
	}).Prune()
)

func TestShortLivedInternetNodeConnections(t *testing.T) {
	have := (render.ContainerWithImageNameRenderer.Render(rpt)).Prune()
Exemplo n.º 5
0
func TestMakeDetailedContainerNode(t *testing.T) {
	id := render.MakeContainerID(fixture.ServerContainerID)
	renderableNode, ok := render.ContainerRenderer.Render(fixture.Report)[id]
	if !ok {
		t.Fatalf("Node not found: %s", id)
	}
	have := detailed.MakeNode(fixture.Report, renderableNode)
	want := detailed.Node{
		NodeSummary: detailed.NodeSummary{
			ID:       id,
			Label:    "server",
			Linkable: true,
			Metadata: []detailed.MetadataRow{
				{ID: "docker_container_id", Value: fixture.ServerContainerID, Prime: true},
				{ID: "docker_container_state", Value: "running", Prime: true},
				{ID: "docker_image_id", Value: fixture.ServerContainerImageID},
			},
			DockerLabels: []detailed.MetadataRow{
				{ID: "label_" + render.AmazonECSContainerNameLabel, Value: `server`},
				{ID: "label_foo1", Value: `bar1`},
				{ID: "label_foo2", Value: `bar2`},
				{ID: "label_io.kubernetes.pod.name", Value: "ping/pong-b"},
			},
			Metrics: []detailed.MetricRow{
				{
					ID:     docker.CPUTotalUsage,
					Format: "percent",
					Value:  0.05,
					Metric: &fixture.ServerContainerCPUMetric,
				},
				{
					ID:     docker.MemoryUsage,
					Format: "filesize",
					Value:  0.06,
					Metric: &fixture.ServerContainerMemoryMetric,
				},
			},
		},
		Rank:     "imageid456",
		Pseudo:   false,
		Controls: []detailed.ControlInstance{},
		Children: []detailed.NodeSummaryGroup{
			{
				Label:      "Processes",
				TopologyID: "processes",
				Columns:    []detailed.Column{process.PID, process.CPUUsage, process.MemoryUsage},
				Nodes: []detailed.NodeSummary{
					{
						ID:       fmt.Sprintf("process:%s:%s", "server.hostname.com", fixture.ServerPID),
						Label:    "apache",
						Linkable: true,
						Metadata: []detailed.MetadataRow{
							{ID: process.PID, Value: fixture.ServerPID, Prime: true},
						},
						Metrics: []detailed.MetricRow{},
					},
				},
			},
		},
		Parents: []detailed.Parent{
			{
				ID:         render.MakeContainerImageID(fixture.ServerContainerImageName),
				Label:      fixture.ServerContainerImageName,
				TopologyID: "containers-by-image",
			},
			{
				ID:         render.MakeHostID(fixture.ServerHostName),
				Label:      fixture.ServerHostName,
				TopologyID: "hosts",
			},
		},
	}
	if !reflect.DeepEqual(want, have) {
		t.Errorf("%s", test.Diff(want, have))
	}
}
Exemplo n.º 6
0
			LabelMajor: fixture.NonContainerName,
			LabelMinor: "1 process",
			Rank:       fixture.NonContainerName,
			Pseudo:     false,
			Children: report.MakeNodeSet(
				fixture.Report.Process.Nodes[fixture.NonContainerProcessNodeID],
			),
			Node:         report.MakeNode().WithAdjacent(render.TheInternetID),
			EdgeMetadata: report.EdgeMetadata{},
		},
		unknownPseudoNode1ID: unknownPseudoNode1(fixture.ServerName),
		unknownPseudoNode2ID: unknownPseudoNode2(fixture.ServerName),
		render.TheInternetID: theInternetNode(fixture.ServerName),
	}).Prune()

	ServerContainerRenderedID = render.MakeContainerID(fixture.ServerContainerID)
	ClientContainerRenderedID = render.MakeContainerID(fixture.ClientContainerID)

	RenderedContainers = (render.RenderableNodes{
		ClientContainerRenderedID: {
			ID:         ClientContainerRenderedID,
			LabelMajor: "client",
			LabelMinor: fixture.ClientHostName,
			Rank:       fixture.ClientContainerImageName,
			Pseudo:     false,
			Children: report.MakeNodeSet(
				fixture.Report.Process.Nodes[fixture.ClientProcess1NodeID],
				fixture.Report.Process.Nodes[fixture.ClientProcess2NodeID],
			),
			Node: report.MakeNode().WithAdjacent(ServerContainerRenderedID),
			EdgeMetadata: report.EdgeMetadata{
Exemplo n.º 7
0
func containerNodeSummary(nmd report.Node) NodeSummary {
	label, _ := render.GetRenderableContainerName(nmd)
	containerID, _ := nmd.Latest.Lookup(docker.ContainerID)
	return baseNodeSummary(render.MakeContainerID(containerID), label, true, nmd)
}