• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang test.GenerateRandomContainerInfo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/google/cadvisor/info/v1/test.GenerateRandomContainerInfo函数的典型用法代码示例。如果您正苦于以下问题:Golang GenerateRandomContainerInfo函数的具体用法?Golang GenerateRandomContainerInfo怎么用?Golang GenerateRandomContainerInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GenerateRandomContainerInfo函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestHTTPContainerInfoGetterGetRootInfoWithError

func TestHTTPContainerInfoGetterGetRootInfoWithError(t *testing.T) {
	req := &cadvisorApi.ContainerInfoRequest{
		NumStats: 10,
	}
	cinfo := cadvisorApiTest.GenerateRandomContainerInfo(
		"dockerIDWhichWillNotBeChecked", // docker ID
		2, // Number of cores
		req,
		1*time.Second,
	)
	testHTTPContainerInfoGetter(req, cinfo, "", "", http.StatusNotFound, t)
}
开发者ID:qingyuancloud,项目名称:qingyuan,代码行数:12,代码来源:containerinfo_test.go


示例2: TestHTTPContainerInfoGetterGetContainerInfoSuccessfully

func TestHTTPContainerInfoGetterGetContainerInfoSuccessfully(t *testing.T) {
	req := &cadvisorApi.ContainerInfoRequest{
		NumStats: 10,
	}
	cinfo := cadvisorApiTest.GenerateRandomContainerInfo(
		"dockerIDWhichWillNotBeChecked", // docker ID
		2, // Number of cores
		req,
		1*time.Second,
	)
	testHTTPContainerInfoGetter(req, cinfo, "somePodID", "containerNameInK8S", 0, t)
}
开发者ID:qingyuancloud,项目名称:qingyuan,代码行数:12,代码来源:containerinfo_test.go


示例3: TestGetSubcontainersInfo

func TestGetSubcontainersInfo(t *testing.T) {
	query := &info.ContainerInfoRequest{
		NumStats: 3,
	}
	containerName := "/some/container"
	cinfo := itest.GenerateRandomContainerInfo(containerName, 4, query, 1*time.Second)
	cinfo1 := itest.GenerateRandomContainerInfo(path.Join(containerName, "sub1"), 4, query, 1*time.Second)
	cinfo2 := itest.GenerateRandomContainerInfo(path.Join(containerName, "sub2"), 4, query, 1*time.Second)
	response := []info.ContainerInfo{
		*cinfo,
		*cinfo1,
		*cinfo2,
	}
	client, server, err := cadvisorTestClient(fmt.Sprintf("/api/v1.3/subcontainers%v", containerName), query, response, t)
	if err != nil {
		t.Fatalf("unable to get a client %v", err)
	}
	defer server.Close()
	returned, err := client.SubcontainersInfo(containerName, query)
	if err != nil {
		t.Fatal(err)
	}

	if len(returned) != 3 {
		t.Errorf("unexpected number of results: got %d, expected 3", len(returned))
	}
	if !returned[0].Eq(cinfo) {
		t.Error("received unexpected ContainerInfo")
	}
	if !returned[1].Eq(cinfo1) {
		t.Error("received unexpected ContainerInfo")
	}
	if !returned[2].Eq(cinfo2) {
		t.Error("received unexpected ContainerInfo")
	}
}
开发者ID:normanjoyner,项目名称:cadvisor,代码行数:36,代码来源:client_test.go


示例4: expectManagerWithContainers

// Expect a manager with the specified containers and query. Returns the manager, map of ContainerInfo objects,
// and map of MockContainerHandler objects.}
func expectManagerWithContainers(containers []string, query *info.ContainerInfoRequest, t *testing.T) (*manager, map[string]*info.ContainerInfo, map[string]*container.MockContainerHandler) {
	infosMap := make(map[string]*info.ContainerInfo, len(containers))
	handlerMap := make(map[string]*container.MockContainerHandler, len(containers))

	for _, container := range containers {
		infosMap[container] = itest.GenerateRandomContainerInfo(container, 4, query, 1*time.Second)
	}

	memoryStorage := memory.New(query.NumStats, nil)
	sysfs := &fakesysfs.FakeSysFs{}
	m := createManagerAndAddContainers(
		memoryStorage,
		sysfs,
		containers,
		func(h *container.MockContainerHandler) {
			cinfo := infosMap[h.Name]
			ref, err := h.ContainerReference()
			if err != nil {
				t.Error(err)
			}
			for _, stat := range cinfo.Stats {
				err = memoryStorage.AddStats(ref, stat)
				if err != nil {
					t.Error(err)
				}
			}
			spec := cinfo.Spec

			h.On("ListContainers", container.ListSelf).Return(
				[]info.ContainerReference(nil),
				nil,
			)
			h.On("GetSpec").Return(
				spec,
				nil,
			)
			handlerMap[h.Name] = h
		},
		t,
	)

	return m, infosMap, handlerMap
}
开发者ID:vrosnet,项目名称:kubernetes,代码行数:45,代码来源:manager_test.go


示例5: TestGetContainerInfo

// TestGetContainerInfo generates a random container information object
// and then checks that ContainerInfo returns the expected result.
func TestGetContainerInfo(t *testing.T) {
	query := &info.ContainerInfoRequest{
		NumStats: 3,
	}
	containerName := "/some/container"
	cinfo := itest.GenerateRandomContainerInfo(containerName, 4, query, 1*time.Second)
	client, server, err := cadvisorTestClient(fmt.Sprintf("/api/v1.3/containers%v", containerName), query, cinfo, t)
	if err != nil {
		t.Fatalf("unable to get a client %v", err)
	}
	defer server.Close()
	returned, err := client.ContainerInfo(containerName, query)
	if err != nil {
		t.Fatal(err)
	}

	if !returned.Eq(cinfo) {
		t.Error("received unexpected ContainerInfo")
	}
}
开发者ID:normanjoyner,项目名称:cadvisor,代码行数:22,代码来源:client_test.go



注:本文中的github.com/google/cadvisor/info/v1/test.GenerateRandomContainerInfo函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang test.GenerateRandomContainerSpec函数代码示例发布时间:2022-05-23
下一篇:
Golang v1.PerDiskStats类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap