本文整理汇总了Golang中github.com/weaveworks/scope/report.MakeNodeMetadata函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeNodeMetadata函数的具体用法?Golang MakeNodeMetadata怎么用?Golang MakeNodeMetadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeNodeMetadata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestCollector
func TestCollector(t *testing.T) {
window := time.Millisecond
c := xfer.NewCollector(window)
r1 := report.MakeReport()
r1.Endpoint.NodeMetadatas["foo"] = report.MakeNodeMetadata()
r2 := report.MakeReport()
r2.Endpoint.NodeMetadatas["bar"] = report.MakeNodeMetadata()
if want, have := report.MakeReport(), c.Report(); !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
c.Add(r1)
if want, have := r1, c.Report(); !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
c.Add(r2)
merged := report.MakeReport()
merged = merged.Merge(r1)
merged = merged.Merge(r2)
if want, have := merged, c.Report(); !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
示例2: TestMapHostIdentity
func TestMapHostIdentity(t *testing.T) {
for _, input := range []testcase{
{report.MakeNodeMetadata(), true}, // TODO it's questionable if this is actually correct
} {
testMap(t, render.MapHostIdentity, input)
}
}
示例3: TestMergeRenderableNode
func TestMergeRenderableNode(t *testing.T) {
node1 := render.RenderableNode{
ID: "foo",
LabelMajor: "",
LabelMinor: "minor",
Rank: "",
Pseudo: false,
Adjacency: report.MakeIDList("a1"),
Origins: report.MakeIDList("o1"),
}
node2 := render.RenderableNode{
ID: "foo",
LabelMajor: "major",
LabelMinor: "",
Rank: "rank",
Pseudo: false,
Adjacency: report.MakeIDList("a2"),
Origins: report.MakeIDList("o2"),
}
want := render.RenderableNode{
ID: "foo",
LabelMajor: "major",
LabelMinor: "minor",
Rank: "rank",
Pseudo: false,
Adjacency: report.MakeIDList("a1", "a2"),
Origins: report.MakeIDList("o1", "o2"),
NodeMetadata: report.MakeNodeMetadata(),
EdgeMetadata: report.EdgeMetadata{},
}
node1.Merge(node2)
if have := node1; !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
示例4: TestFilterRender
func TestFilterRender(t *testing.T) {
renderer := render.FilterUnconnected(
mockRenderer{RenderableNodes: render.RenderableNodes{
"foo": {ID: "foo", Adjacency: report.MakeIDList("bar"), NodeMetadata: report.MakeNodeMetadata()},
"bar": {ID: "bar", Adjacency: report.MakeIDList("foo"), NodeMetadata: report.MakeNodeMetadata()},
"baz": {ID: "baz", Adjacency: report.MakeIDList(), NodeMetadata: report.MakeNodeMetadata()},
}})
want := render.RenderableNodes{
"foo": {ID: "foo", Adjacency: report.MakeIDList("bar"), NodeMetadata: report.MakeNodeMetadata()},
"bar": {ID: "bar", Adjacency: report.MakeIDList("foo"), NodeMetadata: report.MakeNodeMetadata()},
}
have := sterilize(renderer.Render(report.MakeReport()), true)
if !reflect.DeepEqual(want, have) {
t.Errorf("want %+v, have %+v", want, have)
}
}
示例5: TestMapContainerImageIdentity
func TestMapContainerImageIdentity(t *testing.T) {
for _, input := range []testcase{
{report.MakeNodeMetadata(), false},
{report.MakeNodeMetadataWith(map[string]string{docker.ImageID: "a1b2c3"}), true},
} {
testMap(t, render.MapContainerImageIdentity, input)
}
}
示例6: TestMapAddressIdentity
func TestMapAddressIdentity(t *testing.T) {
for _, input := range []testcase{
{report.MakeNodeMetadata(), false},
{report.MakeNodeMetadataWith(map[string]string{endpoint.Addr: "192.168.1.1"}), true},
} {
testMap(t, render.MapAddressIdentity, input)
}
}
示例7: trimNodeMetadata
func trimNodeMetadata(rns render.RenderableNodes) render.RenderableNodes {
result := render.RenderableNodes{}
for id, rn := range rns {
rn.NodeMetadata = report.MakeNodeMetadata()
result[id] = rn
}
return result
}
示例8: TestMapProcessIdentity
func TestMapProcessIdentity(t *testing.T) {
for _, input := range []testcase{
{report.MakeNodeMetadata(), false},
{report.MakeNodeMetadataWith(map[string]string{process.PID: "201"}), true},
} {
testMap(t, render.MapProcessIdentity, input)
}
}
示例9: TestTagMissingID
func TestTagMissingID(t *testing.T) {
const nodeID = "not-found"
r := report.MakeReport()
want := report.MakeNodeMetadata()
rpt, _ := newTopologyTagger().Tag(r)
have := rpt.Endpoint.NodeMetadatas[nodeID].Copy()
if !reflect.DeepEqual(want, have) {
t.Error("TopologyTagger erroneously tagged a missing node ID")
}
}
示例10: newPseudoNode
func newPseudoNode(id, major, minor string) RenderableNode {
return RenderableNode{
ID: id,
LabelMajor: major,
LabelMinor: minor,
Rank: "",
Pseudo: true,
EdgeMetadata: report.EdgeMetadata{},
NodeMetadata: report.MakeNodeMetadata(),
}
}
示例11: TestMapEndpointIdentity
func TestMapEndpointIdentity(t *testing.T) {
for _, input := range []testcase{
{report.MakeNodeMetadata(), false},
{report.MakeNodeMetadataWith(map[string]string{endpoint.Addr: "1.2.3.4"}), false},
{report.MakeNodeMetadataWith(map[string]string{endpoint.Port: "1234"}), false},
{report.MakeNodeMetadataWith(map[string]string{endpoint.Addr: "1.2.3.4", endpoint.Port: "1234"}), true},
{report.MakeNodeMetadataWith(map[string]string{report.HostNodeID: report.MakeHostNodeID("foo"), endpoint.Addr: "10.0.0.1", endpoint.Port: "20001"}), true},
} {
testMap(t, render.MapEndpointIdentity, input)
}
}
示例12: newDerivedNode
func newDerivedNode(id string, node RenderableNode) RenderableNode {
return RenderableNode{
ID: id,
LabelMajor: "",
LabelMinor: "",
Rank: "",
Pseudo: node.Pseudo,
Origins: node.Origins.Copy(),
EdgeMetadata: node.EdgeMetadata.Copy(),
NodeMetadata: report.MakeNodeMetadata(),
}
}
示例13: newDerivedPseudoNode
func newDerivedPseudoNode(id, major string, node RenderableNode) RenderableNode {
return RenderableNode{
ID: id,
LabelMajor: major,
LabelMinor: "",
Rank: "",
Pseudo: true,
EdgeMetadata: node.EdgeMetadata,
Origins: node.Origins,
NodeMetadata: report.MakeNodeMetadata(),
}
}
示例14: TestLabels
func TestLabels(t *testing.T) {
want := map[string]string{
"foo1": "bar1",
"foo2": "bar2",
}
nmd := report.MakeNodeMetadata()
docker.AddLabels(nmd, want)
have := docker.ExtractLabels(nmd)
if !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
示例15: TestReportLocalNetworks
func TestReportLocalNetworks(t *testing.T) {
r := report.MakeReport()
r.Merge(report.Report{Host: report.Topology{NodeMetadatas: report.NodeMetadatas{
"nonets": report.MakeNodeMetadata(),
"foo": report.MakeNodeMetadataWith(map[string]string{host.LocalNetworks: "10.0.0.1/8 192.168.1.1/24 10.0.0.1/8 badnet/33"}),
}}})
want := report.Networks([]*net.IPNet{
mustParseCIDR("10.0.0.1/8"),
mustParseCIDR("192.168.1.1/24"),
})
have := render.LocalNetworks(r)
if !reflect.DeepEqual(want, have) {
t.Errorf("%s", test.Diff(want, have))
}
}