testing

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

TODO: credits (based on fake_image_service.go from k8s)

Index

Constants

This section is empty.

Variables

View Source
var (
	FakeRuntimeName  = "fakeRuntime"
	FakePodSandboxIP = "192.168.192.168"
)

Functions

func BuildContainerName

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

func BuildSandboxName

func BuildSandboxName(metadata *runtimeapi.PodSandboxMetadata) string

Types

type FakeContainer

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

	// the sandbox id of this container
	SandboxID string
}

type FakeCriServer

type FakeCriServer struct {
	*FakeRuntimeServer
	*FakeImageServer
	// contains filtered or unexported fields
}

func NewFakeCriServer

func NewFakeCriServer(journal Journal) *FakeCriServer

func (*FakeCriServer) Serve

func (s *FakeCriServer) Serve(addr string, readyCh chan struct{}) error

func (*FakeCriServer) Stop

func (s *FakeCriServer) Stop()

type FakeImageServer

type FakeImageServer struct {
	sync.Mutex

	FakeImageSize uint64
	Images        map[string]*runtimeapi.Image
	// contains filtered or unexported fields
}

func NewFakeImageServer

func NewFakeImageServer(journal Journal) *FakeImageServer

func (*FakeImageServer) ImageFsInfo added in v0.8.0

func (*FakeImageServer) ImageStatus

func (*FakeImageServer) ListImages

func (*FakeImageServer) PullImage

func (*FakeImageServer) RemoveImage

func (*FakeImageServer) SetFakeImageSize

func (r *FakeImageServer) SetFakeImageSize(size uint64)

func (*FakeImageServer) SetFakeImages

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

type FakePodSandbox

type FakePodSandbox struct {
	// PodSandboxStatus contains the runtime information for a sandbox.
	runtimeapi.PodSandboxStatus
}

type FakeRuntimeServer

type FakeRuntimeServer struct {
	sync.Mutex

	CurrentTime int64

	FakeStatus *runtimeapi.RuntimeStatus
	Containers map[string]*FakeContainer
	Sandboxes  map[string]*FakePodSandbox
	// contains filtered or unexported fields
}

func NewFakeRuntimeServer

func NewFakeRuntimeServer(journal Journal) *FakeRuntimeServer

func (*FakeRuntimeServer) Attach

func (*FakeRuntimeServer) ContainerStats added in v0.8.0

func (*FakeRuntimeServer) Exec

func (*FakeRuntimeServer) ExecSync

func (*FakeRuntimeServer) ListContainerStats added in v0.8.0

func (*FakeRuntimeServer) PortForward

func (*FakeRuntimeServer) RunPodSandbox

func (*FakeRuntimeServer) SetFakeContainers

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

func (*FakeRuntimeServer) SetFakeSandboxes

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

func (*FakeRuntimeServer) Status

func (*FakeRuntimeServer) StopContainer

func (*FakeRuntimeServer) Version

type Journal

type Journal interface {
	// Record saves the specified item in the journal
	Record(item string)
}

Journal records a series of events (items) represented as strings in a thread-safe way

type PrefixJournal

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

PrefixJournal is an implementation of Journal interface that prefixes every item passed to it with the specified prefix before passing it on to the underlying Journal

func NewPrefixJournal

func NewPrefixJournal(journal Journal, prefix string) *PrefixJournal

NewPrefixJournal creates an instance of PrefixJournal with the specified underlying journal and prefix

func (*PrefixJournal) Record

func (j *PrefixJournal) Record(item string)

Record implements Record method of Journal interface

type SimpleJournal

type SimpleJournal struct {
	sync.Mutex
	Items []string
}

SimpleJournal is an implementation of Journal that has methods for waiting for particular events and verifying journal contents

func NewSimpleJournal

func NewSimpleJournal() *SimpleJournal

NewSimpleJournal creates an instance of SimpleJournal

func (*SimpleJournal) Record

func (j *SimpleJournal) Record(item string)

Record implements Record method of Journal interface

func (*SimpleJournal) Verify

func (j *SimpleJournal) Verify(expectedItems []string) error

Verify verifies that the current contents of the journal is expectedItems, returns nil if so or an error otherwise

func (*SimpleJournal) VerifyUnordered

func (j *SimpleJournal) VerifyUnordered(expectedItems []string) error

VerifyUnordered verifies that the current contents of the journal contains the same items as expectedItems slice but in any order. It returns nil if so or an error otherwise

Jump to

Keyboard shortcuts

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