本文整理汇总了Golang中github.com/weaveworks/scope/report.MakeNodeMetadata函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeNodeMetadata函数的具体用法?Golang MakeNodeMetadata怎么用?Golang MakeNodeMetadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeNodeMetadata函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:28,代码来源:collector_test.go
示例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)
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:7,代码来源:mapping_test.go
示例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))
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:35,代码来源:renderable_node_test.go
示例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)
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:16,代码来源:render_test.go
示例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)
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:8,代码来源:mapping_test.go
示例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)
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:8,代码来源:mapping_test.go
示例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
}
开发者ID:barravi,项目名称:scope,代码行数:8,代码来源:topologies_test.go
示例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)
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:8,代码来源:mapping_test.go
示例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")
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:10,代码来源:tag_report_test.go
示例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(),
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:11,代码来源:renderable_node.go
示例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)
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:11,代码来源:mapping_test.go
示例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(),
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:12,代码来源:renderable_node.go
示例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(),
}
}
开发者ID:barravi,项目名称:scope,代码行数:12,代码来源:renderable_node.go
示例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))
}
}
开发者ID:cgvarela,项目名称:scope,代码行数:14,代码来源:labels_test.go
示例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))
}
}
开发者ID:barravi,项目名称:scope,代码行数:15,代码来源:theinternet_test.go
示例16: processTopology
func (r *Reporter) processTopology() (report.Topology, error) {
t := report.MakeTopology()
err := r.walker.Walk(func(p Process) {
pidstr := strconv.Itoa(p.PID)
nodeID := report.MakeProcessNodeID(r.scope, pidstr)
t.NodeMetadatas[nodeID] = report.MakeNodeMetadata()
for _, tuple := range []struct{ key, value string }{
{PID, pidstr},
{Comm, p.Comm},
{Cmdline, p.Cmdline},
{Threads, strconv.Itoa(p.Threads)},
} {
if tuple.value != "" {
t.NodeMetadatas[nodeID].Metadata[tuple.key] = tuple.value
}
}
if p.PPID > 0 {
t.NodeMetadatas[nodeID].Metadata[PPID] = strconv.Itoa(p.PPID)
}
})
return t, err
}
开发者ID:cgvarela,项目名称:scope,代码行数:23,代码来源:reporter.go
示例17:
"github.com/weaveworks/scope/render"
"github.com/weaveworks/scope/report"
"github.com/weaveworks/scope/test"
)
// Exported for testing.
var (
uncontainedServerID = render.MakePseudoNodeID(render.UncontainedID, test.ServerHostName)
unknownPseudoNode1ID = render.MakePseudoNodeID("10.10.10.10", test.ServerIP, "80")
unknownPseudoNode2ID = render.MakePseudoNodeID("10.10.10.11", test.ServerIP, "80")
unknownPseudoNode1 = func(adjacency report.IDList) render.RenderableNode {
return render.RenderableNode{
ID: unknownPseudoNode1ID,
LabelMajor: "10.10.10.10",
Pseudo: true,
NodeMetadata: report.MakeNodeMetadata(),
EdgeMetadata: report.EdgeMetadata{
EgressPacketCount: newu64(70),
EgressByteCount: newu64(700),
},
Adjacency: adjacency,
Origins: report.MakeIDList(
test.UnknownClient1NodeID,
test.UnknownClient2NodeID,
),
}
}
unknownPseudoNode2 = func(adjacency report.IDList) render.RenderableNode {
return render.RenderableNode{
ID: unknownPseudoNode2ID,
LabelMajor: "10.10.10.11",
开发者ID:cgvarela,项目名称:scope,代码行数:31,代码来源:expected.go
示例18: TestMerge
func TestMerge(t *testing.T) {
var (
hostID = "xyz"
src = newMockSource([]byte{}, nil)
on = time.Millisecond
off = time.Millisecond
rpt = report.MakeReport()
p = sniff.Packet{
SrcIP: "1.0.0.0",
SrcPort: "1000",
DstIP: "2.0.0.0",
DstPort: "2000",
Network: 512,
Transport: 256,
}
_, ipnet, _ = net.ParseCIDR(p.SrcIP + "/24") // ;)
localNets = report.Networks([]*net.IPNet{ipnet})
)
sniff.New(hostID, localNets, src, on, off).Merge(p, rpt)
var (
srcEndpointNodeID = report.MakeEndpointNodeID(hostID, p.SrcIP, p.SrcPort)
dstEndpointNodeID = report.MakeEndpointNodeID(hostID, p.DstIP, p.DstPort)
)
if want, have := (report.Topology{
Adjacency: report.Adjacency{
report.MakeAdjacencyID(srcEndpointNodeID): report.MakeIDList(
dstEndpointNodeID,
),
},
EdgeMetadatas: report.EdgeMetadatas{
report.MakeEdgeID(srcEndpointNodeID, dstEndpointNodeID): report.EdgeMetadata{
EgressPacketCount: newu64(1),
EgressByteCount: newu64(256),
},
},
NodeMetadatas: report.NodeMetadatas{
srcEndpointNodeID: report.MakeNodeMetadata(),
},
}), rpt.Endpoint; !reflect.DeepEqual(want, have) {
t.Errorf("%s", test.Diff(want, have))
}
var (
srcAddressNodeID = report.MakeAddressNodeID(hostID, p.SrcIP)
dstAddressNodeID = report.MakeAddressNodeID(hostID, p.DstIP)
)
if want, have := (report.Topology{
Adjacency: report.Adjacency{
report.MakeAdjacencyID(srcAddressNodeID): report.MakeIDList(
dstAddressNodeID,
),
},
EdgeMetadatas: report.EdgeMetadatas{
report.MakeEdgeID(srcAddressNodeID, dstAddressNodeID): report.EdgeMetadata{
EgressPacketCount: newu64(1),
EgressByteCount: newu64(512),
},
},
NodeMetadatas: report.NodeMetadatas{
srcAddressNodeID: report.MakeNodeMetadata(),
},
}), rpt.Address; !reflect.DeepEqual(want, have) {
t.Errorf("%s", test.Diff(want, have))
}
}
开发者ID:barravi,项目名称:scope,代码行数:67,代码来源:sniffer_test.go
注:本文中的github.com/weaveworks/scope/report.MakeNodeMetadata函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论