Documentation ¶
Index ¶
- Constants
- Variables
- func Fatal(err error)
- func GetDefaultGenerator() (*generate.Generator, error)
- func GetRuntimeToolsNamespace(ns string) string
- func PrepareBundle() (string, error)
- func RuntimeInsideValidate(g *generate.Generator, t *tap.T, f PreFunc) (err error)
- func RuntimeLifecycleValidate(config LifecycleConfig) error
- func RuntimeOutsideValidate(g *generate.Generator, t *tap.T, f AfterFunc) error
- func Skip(message string, diagnostic interface{})
- func SpecErrorOK(t *tap.T, expected bool, specErr error, detailedErr error)
- func ValidateLinuxResourcesBlockIO(config *rspec.Spec, t *tap.T, state *rspec.State) error
- func ValidateLinuxResourcesCPU(config *rspec.Spec, t *tap.T, state *rspec.State) error
- func ValidateLinuxResourcesCPUEmpty(config *rspec.Spec, t *tap.T, state *rspec.State) error
- func ValidateLinuxResourcesDevices(config *rspec.Spec, t *tap.T, state *rspec.State) error
- func ValidateLinuxResourcesMemory(config *rspec.Spec, t *tap.T, state *rspec.State) error
- func ValidateLinuxResourcesNetwork(config *rspec.Spec, t *tap.T, state *rspec.State) error
- func ValidateLinuxResourcesPids(config *rspec.Spec, t *tap.T, state *rspec.State) error
- func WaitingForStatus(r Runtime, status LifecycleStatus, retryTimeout time.Duration, ...) error
- type AfterFunc
- type LifecycleAction
- type LifecycleConfig
- type LifecycleStatus
- type PreFunc
- type Runtime
- func (r *Runtime) Clean(removeBundle bool, forceRemoveBundle bool) error
- func (r *Runtime) Create() (err error)
- func (r *Runtime) Delete() (err error)
- func (r *Runtime) Kill(sig string) (err error)
- func (r *Runtime) ReadStandardStreams() (stdout []byte, stderr []byte, err error)
- func (r *Runtime) SetConfig(g *generate.Generator) error
- func (r *Runtime) SetID(id string)
- func (r *Runtime) Start() (err error)
- func (r *Runtime) State() (rspecs.State, error)
Constants ¶
const ( // LifecycleActionNone does nothing LifecycleActionNone = 0 // LifecycleActionCreate creates a container LifecycleActionCreate = 1 << iota // LifecycleActionStart starts a container LifecycleActionStart // LifecycleActionDelete deletes a container LifecycleActionDelete )
const ( // LifecycleStatusCreating "creating" LifecycleStatusCreating = 1 << iota // LifecycleStatusCreated "created" LifecycleStatusCreated // LifecycleStatusRunning "running" LifecycleStatusRunning // LifecycleStatusStopped "stopped" LifecycleStatusStopped )
const ( // CPUCgroupPrefix is default path prefix where CPU cgroups are created CPUCgroupPrefix string = "/sys/fs/cgroup/cpu,cpuacct" )
const DefaultSignal = "TERM"
DefaultSignal represents the default signal sends to a container
Variables ¶
var ProcNamespaces = []string{
"cgroup",
"ipc",
"mnt",
"net",
"pid",
"user",
"uts",
}
ProcNamespaces defines a list of namespaces to be found under /proc/*/ns/. NOTE: it is not the same as generate.Namespaces, because of naming mismatches like "mnt" vs "mount" or "net" vs "network".
var (
// RuntimeCommand is the default runtime command.
RuntimeCommand = "runc"
)
Functions ¶
func GetDefaultGenerator ¶
GetDefaultGenerator creates a default configuration generator.
func GetRuntimeToolsNamespace ¶
GetRuntimeToolsNamespace converts a namespace type string for /proc into a string for runtime-tools. It deals with exceptional cases of "net" and "mnt", because those strings cannot be recognized by mapStrToNamespace(), which actually expects "network" and "mount" respectively.
func PrepareBundle ¶
PrepareBundle creates a test bundle in a temporary directory.
func RuntimeInsideValidate ¶
RuntimeInsideValidate runs runtimetest inside a container.
func RuntimeLifecycleValidate ¶
func RuntimeLifecycleValidate(config LifecycleConfig) error
RuntimeLifecycleValidate validates runtime lifecycle.
func RuntimeOutsideValidate ¶
RuntimeOutsideValidate validate runtime outside a container.
func SpecErrorOK ¶
SpecErrorOK generates TAP output indicating whether a spec code test passed or failed.
func ValidateLinuxResourcesBlockIO ¶
ValidateLinuxResourcesBlockIO validates linux.resources.blockIO.
func ValidateLinuxResourcesCPU ¶
ValidateLinuxResourcesCPU validates if Linux.Resources.CPU is set to correct values, the same as given values in the config.
func ValidateLinuxResourcesCPUEmpty ¶
ValidateLinuxResourcesCPUEmpty validates Linux.Resources.CPU is set to correct values, when each value are set to the default ones.
func ValidateLinuxResourcesDevices ¶
ValidateLinuxResourcesDevices validates linux.resources.devices.
func ValidateLinuxResourcesMemory ¶
ValidateLinuxResourcesMemory validates linux.resources.memory.
func ValidateLinuxResourcesNetwork ¶
ValidateLinuxResourcesNetwork validates linux.resources.network.
func ValidateLinuxResourcesPids ¶
ValidateLinuxResourcesPids validates linux.resources.pids.
func WaitingForStatus ¶
func WaitingForStatus(r Runtime, status LifecycleStatus, retryTimeout time.Duration, pollInterval time.Duration) error
WaitingForStatus waits an expected runtime status, return error if 1. fail to query the status 2. timeout
Types ¶
type LifecycleConfig ¶
type LifecycleConfig struct { Config *generate.Generator BundleDir string Actions LifecycleAction PreCreate func(runtime *Runtime) error PostCreate func(runtime *Runtime) error PreDelete func(runtime *Runtime) error PostDelete func(runtime *Runtime) error }
LifecycleConfig includes 1. Config to set the 'config.json' 2. BundleDir to set the bundle directory 3. Actions to define the default running lifecycles 4. Four phases for user to add his/her own operations
type LifecycleStatus ¶
type LifecycleStatus int
LifecycleStatus follows https://github.com/opencontainers/runtime-spec/blob/master/runtime.md#state
type PreFunc ¶
PreFunc initializes the test environment after preparing the bundle but before creating the container.
type Runtime ¶
type Runtime struct { RuntimeCommand string BundleDir string PidFile string ID string // contains filtered or unexported fields }
Runtime represents the basic requirement of a container runtime
func NewRuntime ¶
NewRuntime create a runtime by command and the bundle directory
func (*Runtime) Clean ¶
Clean deletes the container. If removeBundle is set, the bundle directory is removed after the container is deleted successfully or, if forceRemoveBundle is true, after the deletion attempt regardless of whether it was successful or not.
func (*Runtime) ReadStandardStreams ¶
ReadStandardStreams collects content from the stdout and stderr buffers.