本文整理汇总了Golang中github.com/google/cadvisor/info/v1/test.GenerateRandomContainerSpec函数的典型用法代码示例。如果您正苦于以下问题:Golang GenerateRandomContainerSpec函数的具体用法?Golang GenerateRandomContainerSpec怎么用?Golang GenerateRandomContainerSpec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GenerateRandomContainerSpec函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestUpdateSpec
func TestUpdateSpec(t *testing.T) {
spec := itest.GenerateRandomContainerSpec(4)
cd, mockHandler, _ := newTestContainerData(t)
mockHandler.On("GetSpec").Return(
spec,
nil,
)
err := cd.updateSpec()
if err != nil {
t.Fatal(err)
}
mockHandler.AssertExpectations(t)
}
开发者ID:chrisdo,项目名称:cadvisor,代码行数:15,代码来源:container_test.go
示例2: TestGetInfo
func TestGetInfo(t *testing.T) {
spec := itest.GenerateRandomContainerSpec(4)
subcontainers := []info.ContainerReference{
{Name: "/container/ee0103"},
{Name: "/container/abcd"},
{Name: "/container/something"},
}
cd, mockHandler, _ := setupContainerData(t, spec)
mockHandler.On("ListContainers", container.ListSelf).Return(
subcontainers,
nil,
)
mockHandler.Aliases = []string{"a1", "a2"}
info, err := cd.GetInfo()
if err != nil {
t.Fatal(err)
}
mockHandler.AssertExpectations(t)
if len(info.Subcontainers) != len(subcontainers) {
t.Errorf("Received %v subcontainers, should be %v", len(info.Subcontainers), len(subcontainers))
}
for _, sub := range info.Subcontainers {
found := false
for _, sub2 := range subcontainers {
if sub.Name == sub2.Name {
found = true
}
}
if !found {
t.Errorf("Received unknown sub container %v", sub)
}
}
if !reflect.DeepEqual(spec, info.Spec) {
t.Errorf("received wrong container spec")
}
if info.Name != mockHandler.Name {
t.Errorf("received wrong container name: received %v; should be %v", info.Name, mockHandler.Name)
}
}
开发者ID:chrisdo,项目名称:cadvisor,代码行数:45,代码来源:container_test.go
示例3: createManagerAndAddContainers
func createManagerAndAddContainers(
memoryStorage *memory.InMemoryStorage,
sysfs *fakesysfs.FakeSysFs,
containers []string,
f func(*container.MockContainerHandler),
t *testing.T,
) *manager {
container.ClearContainerHandlerFactories()
mif := &manager{
containers: make(map[namespacedContainerName]*containerData),
quitChannels: make([]chan error, 0, 2),
memoryStorage: memoryStorage,
}
for _, name := range containers {
mockHandler := container.NewMockContainerHandler(name)
spec := itest.GenerateRandomContainerSpec(4)
mockHandler.On("GetSpec").Return(
spec,
nil,
).Once()
cont, err := newContainerData(name, memoryStorage, mockHandler, nil, false)
if err != nil {
t.Fatal(err)
}
mif.containers[namespacedContainerName{
Name: name,
}] = cont
// Add Docker containers under their namespace.
if strings.HasPrefix(name, "/docker") {
mif.containers[namespacedContainerName{
Namespace: docker.DockerNamespace,
Name: strings.TrimPrefix(name, "/docker/"),
}] = cont
}
f(mockHandler)
}
return mif
}
开发者ID:vrosnet,项目名称:kubernetes,代码行数:38,代码来源:manager_test.go
示例4: newTestContainerData
// Create a containerData instance for a test and add a default GetSpec mock.
func newTestContainerData(t *testing.T) (*containerData, *container.MockContainerHandler, *memory.InMemoryCache) {
spec := itest.GenerateRandomContainerSpec(4)
ret, mockHandler, memoryCache := setupContainerData(t, spec)
return ret, mockHandler, memoryCache
}
开发者ID:chrisdo,项目名称:cadvisor,代码行数:6,代码来源:container_test.go
注:本文中的github.com/google/cadvisor/info/v1/test.GenerateRandomContainerSpec函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论