testing

package
v0.20.12-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FakeVersion is a version of a fake runtime.
	FakeVersion = "0.1.0"

	// FakeRuntimeName is the name of the fake runtime.
	FakeRuntimeName = "fakeRuntime"

	// FakePodSandboxIPs is an IP address of the fake runtime.
	FakePodSandboxIPs = []string{"192.168.192.168"}
)

Functions

func BuildContainerName

func BuildContainerName(metadata *runtimeapi.ContainerMetadata, sandboxID string) string

BuildContainerName creates a unique container name string.

func BuildSandboxName

func BuildSandboxName(metadata *runtimeapi.PodSandboxMetadata) string

BuildSandboxName creates a unique sandbox name string.

Types

type FakeContainer

type FakeContainer struct {
	// ContainerStatus contains the runtime information for a container.
	runtimeapi.ContainerStatus

	// LinuxResources contains the resources specific to linux containers.
	LinuxResources *runtimeapi.LinuxContainerResources

	// the sandbox id of this container
	SandboxID string
}

FakeContainer is a fake container.

type FakeImageService

type FakeImageService struct {
	sync.Mutex

	FakeImageSize uint64
	Called        []string
	Errors        map[string][]error
	Images        map[string]*runtimeapi.Image

	FakeFilesystemUsage []*runtimeapi.FilesystemUsage
	// contains filtered or unexported fields
}

FakeImageService fakes the image service.

func NewFakeImageService

func NewFakeImageService() *FakeImageService

NewFakeImageService creates a new FakeImageService.

func (*FakeImageService) AssertImagePulledWithAuth

func (r *FakeImageService) AssertImagePulledWithAuth(t *testing.T, image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, failMsg string)

AssertImagePulledWithAuth validates whether the image was pulled with auth and asserts if it wasn't.

func (*FakeImageService) ImageFsInfo

func (r *FakeImageService) ImageFsInfo() ([]*runtimeapi.FilesystemUsage, error)

ImageFsInfo returns information of the filesystem that is used to store images.

func (*FakeImageService) ImageStatus

func (r *FakeImageService) ImageStatus(image *runtimeapi.ImageSpec) (*runtimeapi.Image, error)

ImageStatus returns the status of the image from the FakeImageService.

func (*FakeImageService) InjectError added in v0.18.0

func (r *FakeImageService) InjectError(f string, err error)

InjectError sets the error message for the FakeImageService.

func (*FakeImageService) ListImages

func (r *FakeImageService) ListImages(filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error)

ListImages returns the list of images from FakeImageService or error if it was previously set.

func (*FakeImageService) PullImage

func (r *FakeImageService) PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error)

PullImage emulate pulling the image from the FakeImageService.

func (*FakeImageService) RemoveImage

func (r *FakeImageService) RemoveImage(image *runtimeapi.ImageSpec) error

RemoveImage removes image from the FakeImageService.

func (*FakeImageService) SetFakeFilesystemUsage

func (r *FakeImageService) SetFakeFilesystemUsage(usage []*runtimeapi.FilesystemUsage)

SetFakeFilesystemUsage sets the FilesystemUsage for FakeImageService.

func (*FakeImageService) SetFakeImageSize

func (r *FakeImageService) SetFakeImageSize(size uint64)

SetFakeImageSize sets the image size for the FakeImageService.

func (*FakeImageService) SetFakeImages

func (r *FakeImageService) SetFakeImages(images []string)

SetFakeImages sets the list of fake images for the FakeImageService.

func (*FakeImageService) SetFakeImagesWithAnnotations added in v0.19.0

func (r *FakeImageService) SetFakeImagesWithAnnotations(imageSpecs []*runtimeapi.ImageSpec)

SetFakeImagesWithAnnotations sets the list of fake images for the FakeImageService with annotations.

type FakePodSandbox

type FakePodSandbox struct {
	// PodSandboxStatus contains the runtime information for a sandbox.
	runtimeapi.PodSandboxStatus
	// RuntimeHandler is the runtime handler that was issued with the RunPodSandbox request.
	RuntimeHandler string
}

FakePodSandbox is the fake implementation of runtimeapi.PodSandboxStatus.

type FakeRuntimeService

type FakeRuntimeService struct {
	sync.Mutex

	Called []string
	Errors map[string][]error

	FakeStatus         *runtimeapi.RuntimeStatus
	Containers         map[string]*FakeContainer
	Sandboxes          map[string]*FakePodSandbox
	FakeContainerStats map[string]*runtimeapi.ContainerStats
}

FakeRuntimeService is a fake runetime service.

func NewFakeRuntimeService

func NewFakeRuntimeService() *FakeRuntimeService

NewFakeRuntimeService creates a new FakeRuntimeService.

func (*FakeRuntimeService) AssertCalls

func (r *FakeRuntimeService) AssertCalls(calls []string) error

AssertCalls validates whether specified calls were made to the FakeRuntimeService.

func (*FakeRuntimeService) Attach

Attach emulates the attach request in the FakeRuntimeService.

func (*FakeRuntimeService) ContainerStats

func (r *FakeRuntimeService) ContainerStats(containerID string) (*runtimeapi.ContainerStats, error)

ContainerStats returns the container stats in the FakeRuntimeService.

func (*FakeRuntimeService) ContainerStatus

func (r *FakeRuntimeService) ContainerStatus(containerID string) (*runtimeapi.ContainerStatus, error)

ContainerStatus returns the container status given the container ID in FakeRuntimeService.

func (*FakeRuntimeService) CreateContainer

func (r *FakeRuntimeService) CreateContainer(podSandboxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error)

CreateContainer emulates container creation in the FakeRuntimeService.

func (*FakeRuntimeService) Exec

Exec emulates the execution of a command in a container in the FakeRuntimeService.

func (*FakeRuntimeService) ExecSync

func (r *FakeRuntimeService) ExecSync(containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error)

ExecSync emulates the sync execution of a command in a container in the FakeRuntimeService.

func (*FakeRuntimeService) GetCalls

func (r *FakeRuntimeService) GetCalls() []string

GetCalls returns the list of calls made to the FakeRuntimeService.

func (*FakeRuntimeService) GetContainerID

func (r *FakeRuntimeService) GetContainerID(sandboxID, name string, attempt uint32) (string, error)

GetContainerID returns the unique container ID from the FakeRuntimeService.

func (*FakeRuntimeService) InjectError

func (r *FakeRuntimeService) InjectError(f string, err error)

InjectError inject the error to the next call to the FakeRuntimeService.

func (*FakeRuntimeService) ListContainerStats

ListContainerStats returns the list of all container stats given the filter in the FakeRuntimeService.

func (*FakeRuntimeService) ListContainers

func (r *FakeRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error)

ListContainers returns the list of containers in the FakeRuntimeService.

func (*FakeRuntimeService) ListPodSandbox

func (r *FakeRuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error)

ListPodSandbox returns the list of pod sandboxes in the FakeRuntimeService.

func (*FakeRuntimeService) PodSandboxStatus

func (r *FakeRuntimeService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodSandboxStatus, error)

PodSandboxStatus returns pod sandbox status from the FakeRuntimeService.

func (*FakeRuntimeService) PortForward

PortForward emulates the set up of port forward in the FakeRuntimeService.

func (*FakeRuntimeService) RemoveContainer

func (r *FakeRuntimeService) RemoveContainer(containerID string) error

RemoveContainer emulates remove of a container in the FakeRuntimeService.

func (*FakeRuntimeService) RemovePodSandbox

func (r *FakeRuntimeService) RemovePodSandbox(podSandboxID string) error

RemovePodSandbox emulates removal of the pod sadbox in the FakeRuntimeService.

func (*FakeRuntimeService) ReopenContainerLog

func (r *FakeRuntimeService) ReopenContainerLog(containerID string) error

ReopenContainerLog emulates call to the reopen container log in the FakeRuntimeService.

func (*FakeRuntimeService) RunPodSandbox

func (r *FakeRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string) (string, error)

RunPodSandbox emulates the run of the pod sandbox in the FakeRuntimeService.

func (*FakeRuntimeService) SetFakeContainerStats

func (r *FakeRuntimeService) SetFakeContainerStats(containerStats []*runtimeapi.ContainerStats)

SetFakeContainerStats sets the fake container stats in the FakeRuntimeService.

func (*FakeRuntimeService) SetFakeContainers

func (r *FakeRuntimeService) SetFakeContainers(containers []*FakeContainer)

SetFakeContainers sets fake containers for the FakeRuntimeService.

func (*FakeRuntimeService) SetFakeSandboxes

func (r *FakeRuntimeService) SetFakeSandboxes(sandboxes []*FakePodSandbox)

SetFakeSandboxes sets the fake sandboxes for the FakeRuntimeService.

func (*FakeRuntimeService) StartContainer

func (r *FakeRuntimeService) StartContainer(containerID string) error

StartContainer emulates start of a container in the FakeRuntimeService.

func (*FakeRuntimeService) Status

Status returns runtime status of the FakeRuntimeService.

func (*FakeRuntimeService) StopContainer

func (r *FakeRuntimeService) StopContainer(containerID string, timeout int64) error

StopContainer emulates stop of a container in the FakeRuntimeService.

func (*FakeRuntimeService) StopPodSandbox

func (r *FakeRuntimeService) StopPodSandbox(podSandboxID string) error

StopPodSandbox emulates the stop of pod sandbox in the FakeRuntimeService.

func (*FakeRuntimeService) UpdateContainerResources

func (r *FakeRuntimeService) UpdateContainerResources(string, *runtimeapi.LinuxContainerResources) error

UpdateContainerResources returns the container resource in the FakeRuntimeService.

func (*FakeRuntimeService) UpdateRuntimeConfig

func (r *FakeRuntimeService) UpdateRuntimeConfig(runtimeCOnfig *runtimeapi.RuntimeConfig) error

UpdateRuntimeConfig emulates the update of a runtime config for the FakeRuntimeService.

func (*FakeRuntimeService) Version

func (r *FakeRuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse, error)

Version returns version information from the FakeRuntimeService.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL