testing

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContainerNotExistError = grpc.Errorf(codes.NotFound, "container does not exist")

ContainerNotExistError is the fake error returned when container does not exist.

View Source
var SnapshotNotExistError = grpc.Errorf(codes.NotFound, "snapshot does not exist")

SnapshotNotExistError is the fake error returned when snapshot does not exist.

View Source
var TaskNotExistError = grpc.Errorf(codes.NotFound, "task does not exist")

TaskNotExistError is the fake error returned when task does not exist.

Functions

func NewFakeCNIPlugin

func NewFakeCNIPlugin() ocicni.CNIPlugin

NewFakeCNIPlugin create a FakeCNIPlugin.

Types

type CNIPluginArgument

type CNIPluginArgument struct {
	NetnsPath   string
	Namespace   string
	Name        string
	ContainerID string
}

CNIPluginArgument is arguments used to call CNI related functions.

type CalledDetail

type CalledDetail struct {
	// Name of the function called.
	Name string
	// Argument of the function called.
	Argument interface{}
}

CalledDetail is the struct contains called function name and arguments.

type EventClient

type EventClient struct {
	Events chan *task.Event
	grpc.ClientStream
}

EventClient is a test implementation of execution.Tasks_EventsClient

func (*EventClient) Recv

func (cli *EventClient) Recv() (*task.Event, error)

Recv is a test implementation of Recv

type FakeCNIPlugin

type FakeCNIPlugin struct {
	sync.Mutex

	IPMap map[CNIPluginArgument]string
	// contains filtered or unexported fields
}

FakeCNIPlugin is a fake plugin used for test.

func (*FakeCNIPlugin) ClearErrors

func (f *FakeCNIPlugin) ClearErrors()

ClearErrors clear errors for call

func (*FakeCNIPlugin) GetCalledDetails

func (f *FakeCNIPlugin) GetCalledDetails() []CalledDetail

GetCalledDetails get detail of each call.

func (*FakeCNIPlugin) GetCalledNames

func (f *FakeCNIPlugin) GetCalledNames() []string

GetCalledNames get names of call

func (*FakeCNIPlugin) GetContainerNetworkStatus

func (f *FakeCNIPlugin) GetContainerNetworkStatus(netnsPath string, namespace string, name string, containerID string) (string, error)

GetContainerNetworkStatus get the status of network.

func (*FakeCNIPlugin) InjectError

func (f *FakeCNIPlugin) InjectError(fn string, err error)

InjectError inject error for call

func (*FakeCNIPlugin) InjectErrors

func (f *FakeCNIPlugin) InjectErrors(errs map[string]error)

InjectErrors inject errors for calls

func (*FakeCNIPlugin) Name

func (f *FakeCNIPlugin) Name() string

Name return the name of fake CNI plugin.

func (*FakeCNIPlugin) SetFakePodNetwork

func (f *FakeCNIPlugin) SetFakePodNetwork(netnsPath string, namespace string, name string, containerID string, ip string)

SetFakePodNetwork sets the given IP for given arguments.

func (*FakeCNIPlugin) SetUpPod

func (f *FakeCNIPlugin) SetUpPod(netnsPath string, namespace string, name string, containerID string) error

SetUpPod setup the network of PodSandbox.

func (*FakeCNIPlugin) Status

func (f *FakeCNIPlugin) Status() error

Status get the status of the plugin.

func (*FakeCNIPlugin) TearDownPod

func (f *FakeCNIPlugin) TearDownPod(netnsPath string, namespace string, name string, containerID string) error

TearDownPod teardown the network of PodSandbox.

type FakeContainersClient

type FakeContainersClient struct {
	sync.Mutex

	ContainerList map[string]containers.Container
	// contains filtered or unexported fields
}

FakeContainersClient is a simple fake containers client, so that cri-containerd can be run for testing without requiring a real containerd setup.

func NewFakeContainersClient

func NewFakeContainersClient() *FakeContainersClient

NewFakeContainersClient creates a FakeContainersClient

func (*FakeContainersClient) ClearCalls

func (f *FakeContainersClient) ClearCalls()

ClearCalls clear all call detail.

func (*FakeContainersClient) ClearErrors

func (f *FakeContainersClient) ClearErrors()

ClearErrors clear errors for call

func (*FakeContainersClient) Create

Create is a test implementation of containers.Create.

func (*FakeContainersClient) Delete

Delete is a test implementation of containers.Delete

func (*FakeContainersClient) Get

Get is a test implementation of containers.Get

func (*FakeContainersClient) GetCalledDetails

func (f *FakeContainersClient) GetCalledDetails() []CalledDetail

GetCalledDetails get detail of each call.

func (*FakeContainersClient) GetCalledNames

func (f *FakeContainersClient) GetCalledNames() []string

GetCalledNames get names of call

func (*FakeContainersClient) InjectError

func (f *FakeContainersClient) InjectError(fn string, err error)

InjectError inject error for call

func (*FakeContainersClient) InjectErrors

func (f *FakeContainersClient) InjectErrors(errs map[string]error)

InjectErrors inject errors for calls

func (*FakeContainersClient) List

List is a test implementation of containers.List

func (*FakeContainersClient) Update

Update is a test implementation of containers.Update

type FakeExecutionClient

type FakeExecutionClient struct {
	sync.Mutex

	TaskList map[string]task.Task
	// contains filtered or unexported fields
}

FakeExecutionClient is a simple fake execution client, so that cri-containerd can be run for testing without requiring a real containerd setup.

func NewFakeExecutionClient

func NewFakeExecutionClient() *FakeExecutionClient

NewFakeExecutionClient creates a FakeExecutionClient

func (*FakeExecutionClient) Checkpoint

Checkpoint is a test implementation of execution.Checkpoint

func (*FakeExecutionClient) ClearCalls

func (f *FakeExecutionClient) ClearCalls()

ClearCalls clear all call detail.

func (*FakeExecutionClient) ClearErrors

func (f *FakeExecutionClient) ClearErrors()

ClearErrors clear errors for call

func (*FakeExecutionClient) CloseStdin

func (f *FakeExecutionClient) CloseStdin(ctx context.Context, closeStdinOpts *execution.CloseStdinRequest, opts ...grpc.CallOption) (*googleprotobuf.Empty, error)

CloseStdin is a test implementation of execution.CloseStdin

func (*FakeExecutionClient) Create

Create is a test implementation of execution.Create.

func (*FakeExecutionClient) Delete

Delete is a test implementation of execution.Delete

func (*FakeExecutionClient) DeleteProcess

DeleteProcess is a test implementation of execution.DeleteProcess

func (*FakeExecutionClient) Events

Events is a test implementation of execution.Events

func (*FakeExecutionClient) Exec

Exec is a test implementation of execution.Exec

func (*FakeExecutionClient) GetCalledDetails

func (f *FakeExecutionClient) GetCalledDetails() []CalledDetail

GetCalledDetails get detail of each call.

func (*FakeExecutionClient) GetCalledNames

func (f *FakeExecutionClient) GetCalledNames() []string

GetCalledNames get names of call

func (*FakeExecutionClient) Info

Info is a test implementation of execution.Info

func (*FakeExecutionClient) InjectError

func (f *FakeExecutionClient) InjectError(fn string, err error)

InjectError inject error for call

func (*FakeExecutionClient) InjectErrors

func (f *FakeExecutionClient) InjectErrors(errs map[string]error)

InjectErrors inject errors for calls

func (*FakeExecutionClient) Kill

Kill is a test implementation of execution.Kill

func (*FakeExecutionClient) List

List is a test implementation of execution.List

func (*FakeExecutionClient) Pause

Pause is a test implementation of execution.Pause

func (*FakeExecutionClient) Processes

Processes is a test implementation of execution.Processes

func (*FakeExecutionClient) Pty

Pty is a test implementation of execution.Pty

func (*FakeExecutionClient) Resume

Resume is a test implementation of execution.Resume

func (*FakeExecutionClient) SetFakeTasks

func (f *FakeExecutionClient) SetFakeTasks(tasks []task.Task)

SetFakeTasks injects fake tasks.

func (*FakeExecutionClient) Start

Start is a test implementation of execution.Start

func (*FakeExecutionClient) Stop

func (f *FakeExecutionClient) Stop()

Stop the fake execution service. Needed when event is enabled.

func (*FakeExecutionClient) WithEvents

func (f *FakeExecutionClient) WithEvents() *FakeExecutionClient

WithEvents setup events publisher for FakeExecutionClient

type FakeImagesClient

type FakeImagesClient struct {
	sync.Mutex

	ImageList map[string]images.Image
	// contains filtered or unexported fields
}

FakeImagesClient is a simple fake images client, so that cri-containerd can be run for testing without requiring a real containerd setup.

func NewFakeImagesClient

func NewFakeImagesClient() *FakeImagesClient

NewFakeImagesClient creates a FakeImagesClient

func (*FakeImagesClient) ClearErrors

func (f *FakeImagesClient) ClearErrors()

ClearErrors clear errors for call

func (*FakeImagesClient) Delete

func (f *FakeImagesClient) Delete(ctx context.Context, deleteOpts *images.DeleteRequest, opts ...grpc.CallOption) (*googleprotobuf.Empty, error)

Delete is a test implementation of images.Delete

func (*FakeImagesClient) Get

Get is a test implementation of images.Get

func (*FakeImagesClient) GetCalledNames

func (f *FakeImagesClient) GetCalledNames() []string

GetCalledNames get names of call

func (*FakeImagesClient) InjectError

func (f *FakeImagesClient) InjectError(fn string, err error)

InjectError inject error for call

func (*FakeImagesClient) InjectErrors

func (f *FakeImagesClient) InjectErrors(errs map[string]error)

InjectErrors inject errors for calls

func (*FakeImagesClient) List

List is a test implementation of images.List

func (*FakeImagesClient) Put

Put is a test implementation of images.Put

func (*FakeImagesClient) SetFakeImages

func (f *FakeImagesClient) SetFakeImages(images []images.Image)

SetFakeImages injects fake images.

type FakeSnapshotClient

type FakeSnapshotClient struct {
	sync.Mutex

	MountList map[string][]*mount.Mount
	// contains filtered or unexported fields
}

FakeSnapshotClient is a simple fake snapshot client, so that cri-containerd can be run for testing without requiring a real containerd setup.

func NewFakeSnapshotClient

func NewFakeSnapshotClient() *FakeSnapshotClient

NewFakeSnapshotClient creates a FakeSnapshotClient

func (*FakeSnapshotClient) ClearErrors

func (f *FakeSnapshotClient) ClearErrors()

ClearErrors clear errors for call

func (*FakeSnapshotClient) Commit

Commit is a test implementation of snapshot.Commit

func (*FakeSnapshotClient) GetCalledDetails

func (f *FakeSnapshotClient) GetCalledDetails() []CalledDetail

GetCalledDetails get detail of each call.

func (*FakeSnapshotClient) GetCalledNames

func (f *FakeSnapshotClient) GetCalledNames() []string

GetCalledNames get names of call

func (*FakeSnapshotClient) InjectError

func (f *FakeSnapshotClient) InjectError(fn string, err error)

InjectError inject error for call

func (*FakeSnapshotClient) InjectErrors

func (f *FakeSnapshotClient) InjectErrors(errs map[string]error)

InjectErrors inject errors for calls

func (*FakeSnapshotClient) List

List is a test implementation of snapshot.List

func (*FakeSnapshotClient) ListMounts

func (f *FakeSnapshotClient) ListMounts() [][]*mount.Mount

ListMounts lists all the fake mounts.

func (*FakeSnapshotClient) Mounts

Mounts is a test implementation of snapshot.Mounts

func (*FakeSnapshotClient) Prepare

Prepare is a test implementation of snapshot.Prepare

func (*FakeSnapshotClient) Remove

Remove is a test implementation of snapshot.Remove

func (*FakeSnapshotClient) SetFakeMounts

func (f *FakeSnapshotClient) SetFakeMounts(name string, mounts []*mount.Mount)

SetFakeMounts injects fake mounts.

func (*FakeSnapshotClient) Stat

Stat is a test implementation of snapshot.Stat

func (*FakeSnapshotClient) Usage

Usage is a test implementation of snapshot.Usage

func (*FakeSnapshotClient) View

View is a test implementation of snapshot.View

type MockHealthClient

type MockHealthClient struct {
	// contains filtered or unexported fields
}

Mock of HealthClient interface

func NewMockHealthClient

func NewMockHealthClient(ctrl *gomock.Controller) *MockHealthClient

func (*MockHealthClient) Check

func (*MockHealthClient) EXPECT

func (_m *MockHealthClient) EXPECT() *_MockHealthClientRecorder

type MockVersionClient

type MockVersionClient struct {
	// contains filtered or unexported fields
}

Mock of VersionClient interface

func NewMockVersionClient

func NewMockVersionClient(ctrl *gomock.Controller) *MockVersionClient

func (*MockVersionClient) EXPECT

func (_m *MockVersionClient) EXPECT() *_MockVersionClientRecorder

func (*MockVersionClient) Version

func (_m *MockVersionClient) Version(_param0 context.Context, _param1 *empty.Empty, _param2 ...grpc.CallOption) (*version.VersionResponse, error)

Jump to

Keyboard shortcuts

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