testing

package
v0.0.0-...-26d813d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package testing is a generated GoMock package.

Package testing is a generated GoMock package.

Index

Constants

View Source
const FakeHost = "localhost:12345"

Variables

This section is empty.

Functions

func NewFakeCache

func NewFakeCache(runtime container.Runtime) container.Cache

func NewFakeRuntimeCache

func NewFakeRuntimeCache(getter podsGetter) pkgcontainer.RuntimeCache

Types

type FakeOS

type FakeOS struct {
	StatFn     func(string) (os.FileInfo, error)
	ReadDirFn  func(string) ([]os.DirEntry, error)
	MkdirAllFn func(string, os.FileMode) error
	SymlinkFn  func(string, string) error
	GlobFn     func(string, string) bool
	HostName   string
	Removes    []string
	Files      map[string][]*os.FileInfo
}

FakeOS mocks out certain OS calls to avoid perturbing the filesystem If a member of the form `*Fn` is set, that function will be called in place of the real call.

func NewFakeOS

func NewFakeOS() *FakeOS

func (FakeOS) Chmod

func (FakeOS) Chmod(path string, perm os.FileMode) error

Chmod is a fake call that returns nil.

func (FakeOS) Chtimes

func (FakeOS) Chtimes(path string, atime time.Time, mtime time.Time) error

Chtimes is a fake call that returns nil.

func (*FakeOS) Create

func (f *FakeOS) Create(path string) (*os.File, error)

Create is a fake call that creates a virtual file and returns nil.

func (*FakeOS) Glob

func (f *FakeOS) Glob(pattern string) ([]string, error)

Glob is a fake call that returns list of virtual files matching a pattern.

func (*FakeOS) Hostname

func (f *FakeOS) Hostname() (name string, err error)

Hostname is a fake call that returns nil.

func (*FakeOS) MkdirAll

func (f *FakeOS) MkdirAll(path string, perm os.FileMode) error

Mkdir is a fake call that just returns nil.

func (FakeOS) Open

func (FakeOS) Open(name string) (*os.File, error)

Open is a fake call that returns nil.

func (FakeOS) OpenFile

func (FakeOS) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile is a fake call that return nil.

func (FakeOS) Pipe

func (FakeOS) Pipe() (r *os.File, w *os.File, err error)

Pipe is a fake call that returns nil.

func (*FakeOS) ReadDir

func (f *FakeOS) ReadDir(dirname string) ([]os.DirEntry, error)

ReadDir is a fake call that returns the files under the directory.

func (*FakeOS) Remove

func (f *FakeOS) Remove(path string) error

Remove is a fake call that returns nil.

func (*FakeOS) RemoveAll

func (f *FakeOS) RemoveAll(path string) error

RemoveAll is a fake call that just returns nil.

func (FakeOS) Rename

func (FakeOS) Rename(oldpath, newpath string) error

Rename is a fake call that return nil.

func (FakeOS) Stat

func (f FakeOS) Stat(path string) (os.FileInfo, error)

Stat is a fake that returns an error

func (f *FakeOS) Symlink(oldname string, newname string) error

Symlink is a fake call that just returns nil.

type FakePod

type FakePod struct {
	Pod       *pkgcontainer.Pod
	NetnsPath string
}

type FakeRuntime

type FakeRuntime struct {
	sync.Mutex
	CalledFunctions   []string
	PodList           []*FakePod
	AllPodList        []*FakePod
	ImageList         []pkgcontainer.Image
	APIPodStatus      v1.PodStatus
	PodStatus         pkgcontainer.PodStatus
	StartedPods       []string
	KilledPods        []string
	StartedContainers []string
	KilledContainers  []string
	RuntimeStatus     *pkgcontainer.RuntimeStatus
	VersionInfo       string
	APIVersionInfo    string
	RuntimeType       string
	Err               error
	InspectErr        error
	StatusErr         error
	T                 *testing.T
}

FakeRuntime is a fake container runtime for testing.

func (*FakeRuntime) APIVersion

func (f *FakeRuntime) APIVersion() (pkgcontainer.Version, error)

func (*FakeRuntime) AssertCalls

func (f *FakeRuntime) AssertCalls(calls []string) bool

AssertCalls test if the invoked functions are as expected.

func (*FakeRuntime) AssertKilledContainers

func (f *FakeRuntime) AssertKilledContainers(containers []string) bool

func (*FakeRuntime) AssertKilledPods

func (f *FakeRuntime) AssertKilledPods(pods []string) bool

func (*FakeRuntime) AssertStartedContainers

func (f *FakeRuntime) AssertStartedContainers(containers []string) bool

func (*FakeRuntime) AssertStartedPods

func (f *FakeRuntime) AssertStartedPods(pods []string) bool

func (*FakeRuntime) ClearCalls

func (f *FakeRuntime) ClearCalls()

ClearCalls resets the FakeRuntime to the initial state.

func (*FakeRuntime) DeleteContainer

func (f *FakeRuntime) DeleteContainer(ctx context.Context, containerID pkgcontainer.CtrID) error

func (*FakeRuntime) GarbageCollect

func (f *FakeRuntime) GarbageCollect(ctx context.Context, gcPolicy pkgcontainer.GCPolicy, ready bool, evictNonDeletedPods bool) error

func (*FakeRuntime) GetContainerLogs

func (f *FakeRuntime) GetContainerLogs(_ context.Context, pod *v1.Pod, containerID pkgcontainer.CtrID, logOptions *v1.PodLogOptions, stdout, stderr io.Writer) (err error)

func (*FakeRuntime) GetImageRef

func (f *FakeRuntime) GetImageRef(ctx context.Context, image pkgcontainer.ImageSpec) (string, error)

func (*FakeRuntime) GetPodStatus

func (f *FakeRuntime) GetPodStatus(ctx context.Context, uid types.UID, name, namespace string) (*pkgcontainer.PodStatus, error)

func (*FakeRuntime) GetPods

func (f *FakeRuntime) GetPods(ctx context.Context, all bool) ([]*pkgcontainer.Pod, error)

func (*FakeRuntime) ImageStats

func (f *FakeRuntime) ImageStats(ctx context.Context) (*pkgcontainer.ImageStats, error)

func (*FakeRuntime) KillContainerInPod

func (f *FakeRuntime) KillContainerInPod(ctx context.Context, container v1.Container, pod *v1.Pod) error

func (*FakeRuntime) KillPod

func (f *FakeRuntime) KillPod(ctx context.Context, pod *v1.Pod, runningPod pkgcontainer.Pod, gracePeriodOverride *int64) error

func (*FakeRuntime) ListImages

func (f *FakeRuntime) ListImages(ctx context.Context) ([]pkgcontainer.Image, error)

func (*FakeRuntime) PullImage

func (*FakeRuntime) RemoveImage

func (f *FakeRuntime) RemoveImage(ctx context.Context, image pkgcontainer.ImageSpec) error

func (*FakeRuntime) RunContainerInPod

func (f *FakeRuntime) RunContainerInPod(container v1.Container, pod *v1.Pod, volumeMap map[string]volume.VolumePlugin) error

func (*FakeRuntime) Status

func (f *FakeRuntime) Status() (*pkgcontainer.RuntimeStatus, error)

func (*FakeRuntime) SyncPod

func (*FakeRuntime) Type

func (f *FakeRuntime) Type() string

func (*FakeRuntime) UpdatePodCIDR

func (f *FakeRuntime) UpdatePodCIDR(c string) error

UpdatePodCIDR fulfills the cri interface.

func (*FakeRuntime) Version

func (f *FakeRuntime) Version(ctx context.Context) (pkgcontainer.Version, error)

type FakeRuntimeCache

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

func (*FakeRuntimeCache) ForceUpdateIfOlder

func (f *FakeRuntimeCache) ForceUpdateIfOlder(ctx context.Context, t time.Time) error

func (*FakeRuntimeCache) GetPods

func (f *FakeRuntimeCache) GetPods(ctx context.Context) ([]*pkgcontainer.Pod, error)

type FakeRuntimeHelper

type FakeRuntimeHelper struct {
	DNSServers      []string
	DNSSearches     []string
	DNSOptions      []string
	HostName        string
	HostDomain      string
	PodContainerDir string
	Err             error
}

FakeRuntimeHelper implements RuntimeHelper interfaces for testing purposes.

func (*FakeRuntimeHelper) GeneratePodHostNameAndDomain

func (f *FakeRuntimeHelper) GeneratePodHostNameAndDomain(pod *v1.Pod) (string, string, error)

This is not used by docker runtime.

func (*FakeRuntimeHelper) GenerateRunContainerOptions

func (f *FakeRuntimeHelper) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string, podIPs []string) (*pkgcontainer.RunContainerOptions, func(), error)

func (*FakeRuntimeHelper) GetExtraSupplementalGroupsForPod

func (f *FakeRuntimeHelper) GetExtraSupplementalGroupsForPod(pod *v1.Pod) []int64

func (*FakeRuntimeHelper) GetPodCgroupParent

func (f *FakeRuntimeHelper) GetPodCgroupParent(pod *v1.Pod) string

func (*FakeRuntimeHelper) GetPodDNS

func (f *FakeRuntimeHelper) GetPodDNS(pod *v1.Pod) (*runtimeapi.DNSConfig, error)

func (*FakeRuntimeHelper) GetPodDir

func (f *FakeRuntimeHelper) GetPodDir(podUID kubetypes.UID) string

type FakeStreamingRuntime

type FakeStreamingRuntime struct {
	*FakeRuntime
}

type FakeVersion

type FakeVersion struct {
	Version string
}

func (*FakeVersion) Compare

func (fv *FakeVersion) Compare(other string) (int, error)

func (*FakeVersion) String

func (fv *FakeVersion) String() string

type MockDirEntry

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

MockDirEntry is a mock of DirEntry interface.

func NewMockDirEntry

func NewMockDirEntry(ctrl *gomock.Controller) *MockDirEntry

NewMockDirEntry creates a new mock instance.

func (*MockDirEntry) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDirEntry) Info

func (m *MockDirEntry) Info() (fs.FileInfo, error)

Info mocks base method.

func (*MockDirEntry) IsDir

func (m *MockDirEntry) IsDir() bool

IsDir mocks base method.

func (*MockDirEntry) Name

func (m *MockDirEntry) Name() string

Name mocks base method.

func (*MockDirEntry) Type

func (m *MockDirEntry) Type() fs.FileMode

Type mocks base method.

type MockDirEntryMockRecorder

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

MockDirEntryMockRecorder is the mock recorder for MockDirEntry.

func (*MockDirEntryMockRecorder) Info

func (mr *MockDirEntryMockRecorder) Info() *gomock.Call

Info indicates an expected call of Info.

func (*MockDirEntryMockRecorder) IsDir

func (mr *MockDirEntryMockRecorder) IsDir() *gomock.Call

IsDir indicates an expected call of IsDir.

func (*MockDirEntryMockRecorder) Name

func (mr *MockDirEntryMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

func (*MockDirEntryMockRecorder) Type

func (mr *MockDirEntryMockRecorder) Type() *gomock.Call

Type indicates an expected call of Type.

type MockImageService

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

MockImageService is a mock of ImageService interface.

func NewMockImageService

func NewMockImageService(ctrl *gomock.Controller) *MockImageService

NewMockImageService creates a new mock instance.

func (*MockImageService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockImageService) GetImageRef

func (m *MockImageService) GetImageRef(ctx context.Context, image container.ImageSpec) (string, error)

GetImageRef mocks base method.

func (*MockImageService) ImageStats

func (m *MockImageService) ImageStats(ctx context.Context) (*container.ImageStats, error)

ImageStats mocks base method.

func (*MockImageService) ListImages

func (m *MockImageService) ListImages() ([]container.Image, error)

ListImages mocks base method.

func (*MockImageService) PullImage

func (m *MockImageService) PullImage(image container.ImageSpec, auth *credentialprovider.AuthConfig, podSandboxConfig *v10.PodSandboxConfig) (string, error)

PullImage mocks base method.

func (*MockImageService) RemoveImage

func (m *MockImageService) RemoveImage(image container.ImageSpec) error

RemoveImage mocks base method.

type MockImageServiceMockRecorder

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

MockImageServiceMockRecorder is the mock recorder for MockImageService.

func (*MockImageServiceMockRecorder) GetImageRef

func (mr *MockImageServiceMockRecorder) GetImageRef(image interface{}) *gomock.Call

GetImageRef indicates an expected call of GetImageRef.

func (*MockImageServiceMockRecorder) ImageStats

func (mr *MockImageServiceMockRecorder) ImageStats() *gomock.Call

ImageStats indicates an expected call of ImageStats.

func (*MockImageServiceMockRecorder) ListImages

func (mr *MockImageServiceMockRecorder) ListImages() *gomock.Call

ListImages indicates an expected call of ListImages.

func (*MockImageServiceMockRecorder) PullImage

func (mr *MockImageServiceMockRecorder) PullImage(image, auth, podSandboxConfig interface{}) *gomock.Call

PullImage indicates an expected call of PullImage.

func (*MockImageServiceMockRecorder) RemoveImage

func (mr *MockImageServiceMockRecorder) RemoveImage(image interface{}) *gomock.Call

RemoveImage indicates an expected call of RemoveImage.

type MockRuntime

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

MockRuntime is a mock of Runtime interface.

func NewMockRuntime

func NewMockRuntime(ctrl *gomock.Controller) *MockRuntime

NewMockRuntime creates a new mock instance.

func (*MockRuntime) EXPECT

func (m *MockRuntime) EXPECT() *MockRuntimeMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRuntime) GarbageCollect

func (m *MockRuntime) GarbageCollect(ctx context.Context, gcPolicy container.GCPolicy, allSourcesReady, evictNonDeletedPods bool) error

GarbageCollect mocks base method.

func (*MockRuntime) GetImageRef

func (m *MockRuntime) GetImageRef(ctx context.Context, image container.ImageSpec) (string, error)

GetImageRef mocks base method.

func (*MockRuntime) GetPodStatus

func (m *MockRuntime) GetPodStatus(ctx context.Context, uid types.UID, name, namespace string) (*container.PodStatus, error)

GetPodStatus mocks base method.

func (*MockRuntime) GetPods

func (m *MockRuntime) GetPods(ctx context.Context, all bool) ([]*container.Pod, error)

GetPods mocks base method.

func (*MockRuntime) ImageStats

func (m *MockRuntime) ImageStats(ctx context.Context) (*container.ImageStats, error)

ImageStats mocks base method.

func (*MockRuntime) KillPod

func (m *MockRuntime) KillPod(ctx context.Context, pod *v1.Pod, runningPod container.Pod, gracePeriodOverride *int64) error

KillPod mocks base method.

func (*MockRuntime) ListImages

func (m *MockRuntime) ListImages(ctx context.Context) ([]container.Image, error)

ListImages mocks base method.

func (*MockRuntime) PullImage

func (m *MockRuntime) PullImage(ctx context.Context, image container.ImageSpec, auth *credentialprovider.AuthConfig, podSandboxConfig *v10.PodSandboxConfig) (string, error)

PullImage mocks base method.

func (*MockRuntime) RemoveImage

func (m *MockRuntime) RemoveImage(ctx context.Context, image container.ImageSpec) error

RemoveImage mocks base method.

func (*MockRuntime) SyncPod

SyncPod mocks base method.

func (*MockRuntime) Type

func (m *MockRuntime) Type() string

Type mocks base method.

func (*MockRuntime) Version

func (m *MockRuntime) Version(ctx context.Context) (container.Version, error)

Version mocks base method.

type MockRuntimeCache

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

MockRuntimeCache is a mock of RuntimeCache interface.

func NewMockRuntimeCache

func NewMockRuntimeCache(ctrl *gomock.Controller) *MockRuntimeCache

NewMockRuntimeCache creates a new mock instance.

func (*MockRuntimeCache) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRuntimeCache) ForceUpdateIfOlder

func (m *MockRuntimeCache) ForceUpdateIfOlder(arg0 time.Time) error

ForceUpdateIfOlder mocks base method.

func (*MockRuntimeCache) GetPods

func (m *MockRuntimeCache) GetPods() ([]*container.Pod, error)

GetPods mocks base method.

type MockRuntimeCacheMockRecorder

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

MockRuntimeCacheMockRecorder is the mock recorder for MockRuntimeCache.

func (*MockRuntimeCacheMockRecorder) ForceUpdateIfOlder

func (mr *MockRuntimeCacheMockRecorder) ForceUpdateIfOlder(arg0 interface{}) *gomock.Call

ForceUpdateIfOlder indicates an expected call of ForceUpdateIfOlder.

func (*MockRuntimeCacheMockRecorder) GetPods

func (mr *MockRuntimeCacheMockRecorder) GetPods() *gomock.Call

GetPods indicates an expected call of GetPods.

type MockRuntimeMockRecorder

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

MockRuntimeMockRecorder is the mock recorder for MockRuntime.

func (*MockRuntimeMockRecorder) GarbageCollect

func (mr *MockRuntimeMockRecorder) GarbageCollect(gcPolicy, allSourcesReady, evictNonDeletedPods interface{}) *gomock.Call

GarbageCollect indicates an expected call of GarbageCollect.

func (*MockRuntimeMockRecorder) GetImageRef

func (mr *MockRuntimeMockRecorder) GetImageRef(image interface{}) *gomock.Call

GetImageRef indicates an expected call of GetImageRef.

func (*MockRuntimeMockRecorder) GetPodStatus

func (mr *MockRuntimeMockRecorder) GetPodStatus(uid, name, namespace interface{}) *gomock.Call

GetPodStatus indicates an expected call of GetPodStatus.

func (*MockRuntimeMockRecorder) GetPods

func (mr *MockRuntimeMockRecorder) GetPods(all interface{}) *gomock.Call

GetPods indicates an expected call of GetPods.

func (*MockRuntimeMockRecorder) ImageStats

func (mr *MockRuntimeMockRecorder) ImageStats() *gomock.Call

ImageStats indicates an expected call of ImageStats.

func (*MockRuntimeMockRecorder) KillPod

func (mr *MockRuntimeMockRecorder) KillPod(ctx context.Context, pod, runningPod, gracePeriodOverride interface{}) *gomock.Call

KillPod indicates an expected call of KillPod.

func (*MockRuntimeMockRecorder) ListImages

func (mr *MockRuntimeMockRecorder) ListImages() *gomock.Call

ListImages indicates an expected call of ListImages.

func (*MockRuntimeMockRecorder) PullImage

func (mr *MockRuntimeMockRecorder) PullImage(image, auth, podSandboxConfig interface{}) *gomock.Call

PullImage indicates an expected call of PullImage.

func (*MockRuntimeMockRecorder) RemoveImage

func (mr *MockRuntimeMockRecorder) RemoveImage(image interface{}) *gomock.Call

RemoveImage indicates an expected call of RemoveImage.

func (*MockRuntimeMockRecorder) SyncPod

func (mr *MockRuntimeMockRecorder) SyncPod(pod, podStatus, auth, backOff interface{}) *gomock.Call

SyncPod indicates an expected call of SyncPod.

func (*MockRuntimeMockRecorder) Type

func (mr *MockRuntimeMockRecorder) Type() *gomock.Call

Type indicates an expected call of Type.

func (*MockRuntimeMockRecorder) Version

func (mr *MockRuntimeMockRecorder) Version() *gomock.Call

Version indicates an expected call of Version.

type MockVersion

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

MockVersion is a mock of Version interface.

func NewMockVersion

func NewMockVersion(ctrl *gomock.Controller) *MockVersion

NewMockVersion creates a new mock instance.

func (*MockVersion) Compare

func (m *MockVersion) Compare(other string) (int, error)

Compare mocks base method.

func (*MockVersion) EXPECT

func (m *MockVersion) EXPECT() *MockVersionMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockVersion) String

func (m *MockVersion) String() string

String mocks base method.

type MockVersionMockRecorder

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

MockVersionMockRecorder is the mock recorder for MockVersion.

func (*MockVersionMockRecorder) Compare

func (mr *MockVersionMockRecorder) Compare(other interface{}) *gomock.Call

Compare indicates an expected call of Compare.

func (*MockVersionMockRecorder) String

func (mr *MockVersionMockRecorder) String() *gomock.Call

String indicates an expected call of String.

type MockpodsGetter

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

MockpodsGetter is a mock of podsGetter interface.

func NewMockpodsGetter

func NewMockpodsGetter(ctrl *gomock.Controller) *MockpodsGetter

NewMockpodsGetter creates a new mock instance.

func (*MockpodsGetter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockpodsGetter) GetPods

func (m *MockpodsGetter) GetPods(arg0 bool) ([]*container.Pod, error)

GetPods mocks base method.

type MockpodsGetterMockRecorder

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

MockpodsGetterMockRecorder is the mock recorder for MockpodsGetter.

func (*MockpodsGetterMockRecorder) GetPods

func (mr *MockpodsGetterMockRecorder) GetPods(arg0 interface{}) *gomock.Call

GetPods indicates an expected call of GetPods.

Jump to

Keyboard shortcuts

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