testing

package
v0.30.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 8 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
	Pinned        map[string]bool

	FakeFilesystemUsage          []*runtimeapi.FilesystemUsage
	FakeContainerFilesystemUsage []*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

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

func (*FakeImageService) ImageStatus

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(_ context.Context, 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(_ context.Context, 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(_ context.Context, image *runtimeapi.ImageSpec) error

RemoveImage removes image from the FakeImageService.

func (*FakeImageService) SetFakeContainerFilesystemUsage added in v0.29.0

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

SetFakeFilesystemUsage sets the FilesystemUsage for FakeImageService.

func (*FakeImageService) SetFakeFilesystemUsage

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

SetFakeFilesystemUsage sets the FilesystemUsage for FakeImageService.

func (*FakeImageService) SetFakeImagePinned added in v0.25.14

func (r *FakeImageService) SetFakeImagePinned(image string, pinned bool)

SetFakeImagePinned sets the image Pinned field for one image.

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
	FakePodSandboxStats    map[string]*runtimeapi.PodSandboxStats
	FakePodSandboxMetrics  map[string]*runtimeapi.PodSandboxMetrics
	FakeMetricDescriptors  map[string]*runtimeapi.MetricDescriptor
	FakeContainerMetrics   map[string]*runtimeapi.ContainerMetrics
	FakeLinuxConfiguration *runtimeapi.LinuxRuntimeConfiguration

	ErrorOnSandboxCreate bool
}

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) CheckpointContainer added in v0.25.0

func (r *FakeRuntimeService) CheckpointContainer(_ context.Context, options *runtimeapi.CheckpointContainerRequest) error

CheckpointContainer emulates call to checkpoint a container in the FakeRuntimeService.

func (*FakeRuntimeService) ContainerStats

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

ContainerStats returns the container stats in the FakeRuntimeService.

func (*FakeRuntimeService) ContainerStatus

func (r *FakeRuntimeService) ContainerStatus(_ context.Context, containerID string, verbose bool) (*runtimeapi.ContainerStatusResponse, error)

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

func (*FakeRuntimeService) CreateContainer

func (r *FakeRuntimeService) CreateContainer(_ context.Context, 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(_ context.Context, 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) GetContainerEvents added in v0.25.0

func (f *FakeRuntimeService) GetContainerEvents(containerEventsCh chan *runtimeapi.ContainerEventResponse) error

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

ListContainers returns the list of containers in the FakeRuntimeService.

func (*FakeRuntimeService) ListMetricDescriptors added in v0.26.0

func (r *FakeRuntimeService) ListMetricDescriptors(_ context.Context) ([]*runtimeapi.MetricDescriptor, error)

ListMetricDescriptors gets the descriptors for the metrics that will be returned in ListPodSandboxMetrics.

func (*FakeRuntimeService) ListPodSandbox

ListPodSandbox returns the list of pod sandboxes in the FakeRuntimeService.

func (*FakeRuntimeService) ListPodSandboxMetrics added in v0.26.0

func (r *FakeRuntimeService) ListPodSandboxMetrics(_ context.Context) ([]*runtimeapi.PodSandboxMetrics, error)

ListPodSandboxMetrics returns the list of all pod sandbox metrics in the FakeRuntimeService.

func (*FakeRuntimeService) ListPodSandboxStats added in v0.23.0

ListPodSandboxStats returns the list of all pod sandbox stats given the filter in the FakeRuntimeService.

func (*FakeRuntimeService) PodSandboxStats added in v0.23.0

func (r *FakeRuntimeService) PodSandboxStats(_ context.Context, podSandboxID string) (*runtimeapi.PodSandboxStats, error)

PodSandboxStats returns the sandbox stats in the FakeRuntimeService.

func (*FakeRuntimeService) PodSandboxStatus

func (r *FakeRuntimeService) PodSandboxStatus(_ context.Context, podSandboxID string, verbose bool) (*runtimeapi.PodSandboxStatusResponse, 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(_ context.Context, containerID string) error

RemoveContainer emulates remove of a container in the FakeRuntimeService.

func (*FakeRuntimeService) RemovePodSandbox

func (r *FakeRuntimeService) RemovePodSandbox(_ context.Context, podSandboxID string) error

RemovePodSandbox emulates removal of the pod sadbox in the FakeRuntimeService.

func (*FakeRuntimeService) ReopenContainerLog

func (r *FakeRuntimeService) ReopenContainerLog(_ context.Context, containerID string) error

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

func (*FakeRuntimeService) RunPodSandbox

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

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

func (*FakeRuntimeService) RuntimeConfig added in v0.28.0

RuntimeConfig returns runtime configuration of 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) SetFakeMetricDescriptors added in v0.26.0

func (r *FakeRuntimeService) SetFakeMetricDescriptors(descs []*runtimeapi.MetricDescriptor)

SetFakeMetricDescriptors sets the fake metrics descriptors in the FakeRuntimeService.

func (*FakeRuntimeService) SetFakePodSandboxMetrics added in v0.26.0

func (r *FakeRuntimeService) SetFakePodSandboxMetrics(podStats []*runtimeapi.PodSandboxMetrics)

SetFakePodSandboxMetrics sets the fake pod sandbox metrics in the FakeRuntimeService.

func (*FakeRuntimeService) SetFakePodSandboxStats added in v0.23.0

func (r *FakeRuntimeService) SetFakePodSandboxStats(podStats []*runtimeapi.PodSandboxStats)

SetFakePodSandboxStats sets the fake pod sandbox stats in 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(_ context.Context, 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(_ context.Context, containerID string, timeout int64) error

StopContainer emulates stop of a container in the FakeRuntimeService.

func (*FakeRuntimeService) StopPodSandbox

func (r *FakeRuntimeService) StopPodSandbox(_ context.Context, podSandboxID string) error

StopPodSandbox emulates the stop of pod sandbox in the FakeRuntimeService.

func (*FakeRuntimeService) UpdateContainerResources

UpdateContainerResources returns the container resource in the FakeRuntimeService.

func (*FakeRuntimeService) UpdateRuntimeConfig

func (r *FakeRuntimeService) UpdateRuntimeConfig(_ context.Context, runtimeCOnfig *runtimeapi.RuntimeConfig) error

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

func (*FakeRuntimeService) Version

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