当前位置: 首页>>代码示例>>Golang>>正文


Golang testing.FakeRuntimeService类代码示例

本文整理汇总了Golang中k8s/io/kubernetes/pkg/kubelet/api/testing.FakeRuntimeService的典型用法代码示例。如果您正苦于以下问题:Golang FakeRuntimeService类的具体用法?Golang FakeRuntimeService怎么用?Golang FakeRuntimeService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: makeAndSetFakePod

// makeAndSetFakePod is a helper function to create and set one fake sandbox for a pod and
// one fake container for each of its container.
func makeAndSetFakePod(t *testing.T, m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService,
	pod *v1.Pod) (*apitest.FakePodSandbox, []*apitest.FakeContainer) {
	sandbox := makeFakePodSandbox(t, m, sandboxTemplate{
		pod:       pod,
		createdAt: fakeCreatedAt,
		state:     runtimeApi.PodSandboxState_SANDBOX_READY,
	})

	var containers []*apitest.FakeContainer
	newTemplate := func(c *v1.Container) containerTemplate {
		return containerTemplate{
			pod:       pod,
			container: c,
			createdAt: fakeCreatedAt,
			state:     runtimeApi.ContainerState_CONTAINER_RUNNING,
		}
	}
	for i := range pod.Spec.Containers {
		containers = append(containers, makeFakeContainer(t, m, newTemplate(&pod.Spec.Containers[i])))
	}
	for i := range pod.Spec.InitContainers {
		containers = append(containers, makeFakeContainer(t, m, newTemplate(&pod.Spec.InitContainers[i])))
	}

	fakeRuntime.SetFakeSandboxes([]*apitest.FakePodSandbox{sandbox})
	fakeRuntime.SetFakeContainers(containers)
	return sandbox, containers
}
开发者ID:paralin,项目名称:kubernetes,代码行数:30,代码来源:kuberuntime_manager_test.go

示例2: makeAndSetFakeEvictablePod

func makeAndSetFakeEvictablePod(m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService, pods []*apiPodWithCreatedAt) error {
	sandboxes := make([]*apitest.FakePodSandbox, 0)
	containers := make([]*apitest.FakeContainer, 0)
	for _, pod := range pods {
		fakePodSandbox, err := makeFakePodSandbox(m, pod.apiPod, pod.createdAt)
		if err != nil {
			return err
		}

		fakeContainers, err := makeFakeContainers(m, pod.apiPod, pod.apiPod.Spec.Containers, pod.createdAt, runtimeApi.ContainerState_EXITED)
		if err != nil {
			return err
		}

		// Set sandbox to not ready state
		sandboxNotReady := runtimeApi.PodSandBoxState_NOTREADY
		fakePodSandbox.State = &sandboxNotReady
		sandboxes = append(sandboxes, fakePodSandbox)

		// Set containers to exited state
		containerExited := runtimeApi.ContainerState_EXITED
		for _, c := range fakeContainers {
			c.State = &containerExited
			containers = append(containers, c)
		}

	}

	fakeRuntime.SetFakeSandboxes(sandboxes)
	fakeRuntime.SetFakeContainers(containers)
	return nil
}
开发者ID:ncdc,项目名称:kubernetes,代码行数:32,代码来源:kuberuntime_gc_test.go

示例3: makeAndSetFakePod

func makeAndSetFakePod(m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService, pod *api.Pod) (*apitest.FakePodSandbox, []*apitest.FakeContainer, error) {
	fakePodSandbox, err := makeFakePodSandbox(m, pod)
	if err != nil {
		return nil, nil, err
	}

	fakeContainers, err := makeFakeContainers(m, pod, pod.Spec.Containers)
	if err != nil {
		return nil, nil, err
	}

	fakeRuntime.SetFakeSandboxes([]*apitest.FakePodSandbox{fakePodSandbox})
	fakeRuntime.SetFakeContainers(fakeContainers)
	return fakePodSandbox, fakeContainers, nil
}
开发者ID:astropuffin,项目名称:kubernetes,代码行数:15,代码来源:kuberuntime_manager_test.go

示例4: makeAndSetFakePod

func makeAndSetFakePod(m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService, pod *api.Pod) (*apitest.FakePodSandbox, []*apitest.FakeContainer, error) {
	fakePodSandbox, err := makeFakePodSandbox(m, pod, fakeCreatedAt)
	if err != nil {
		return nil, nil, err
	}

	fakeContainers, err := makeFakeContainers(m, pod, pod.Spec.Containers, fakeCreatedAt, runtimeApi.ContainerState_RUNNING)
	if err != nil {
		return nil, nil, err
	}

	fakeInitContainers, err := makeFakeContainers(m, pod, pod.Spec.InitContainers, fakeCreatedAt, runtimeApi.ContainerState_EXITED)
	if err != nil {
		return nil, nil, err
	}

	fakeContainers = append(fakeContainers, fakeInitContainers...)
	fakeRuntime.SetFakeSandboxes([]*apitest.FakePodSandbox{fakePodSandbox})
	fakeRuntime.SetFakeContainers(fakeContainers)
	return fakePodSandbox, fakeContainers, nil
}
开发者ID:ncdc,项目名称:kubernetes,代码行数:21,代码来源:kuberuntime_manager_test.go


注:本文中的k8s/io/kubernetes/pkg/kubelet/api/testing.FakeRuntimeService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。