testutils

package
v0.9.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetEnvvars

func SetEnvvars(envBuilder *taskenv.Builder, fsi drivers.FSIsolation, taskDir *allocdir.TaskDir, conf *config.Config)

SetEnvvars sets path and host env vars depending on the FS isolation used.

Types

type DriverHarness

type DriverHarness struct {
	drivers.DriverPlugin
	// contains filtered or unexported fields
}

func NewDriverHarness

func NewDriverHarness(t testing.T, d drivers.DriverPlugin) *DriverHarness

func (*DriverHarness) Impl

func (*DriverHarness) Kill

func (h *DriverHarness) Kill()

func (*DriverHarness) MkAllocDir

func (h *DriverHarness) MkAllocDir(t *drivers.TaskConfig, enableLogs bool) func()

MkAllocDir creates a tempory directory and allocdir structure. If enableLogs is set to true a logmon instance will be started to write logs to the LogDir of the task A cleanup func is returned and should be defered so as to not leak dirs between tests.

func (*DriverHarness) WaitUntilStarted

func (h *DriverHarness) WaitUntilStarted(taskID string, timeout time.Duration) error

WaitUntilStarted will block until the task for the given ID is in the running state or the timeout is reached

type MockDriver

type MockDriver struct {
	base.MockPlugin
	TaskConfigSchemaF func() (*hclspec.Spec, error)
	FingerprintF      func(context.Context) (<-chan *drivers.Fingerprint, error)
	CapabilitiesF     func() (*drivers.Capabilities, error)
	RecoverTaskF      func(*drivers.TaskHandle) error
	StartTaskF        func(*drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
	WaitTaskF         func(context.Context, string) (<-chan *drivers.ExitResult, error)
	StopTaskF         func(string, time.Duration, string) error
	DestroyTaskF      func(string, bool) error
	InspectTaskF      func(string) (*drivers.TaskStatus, error)
	TaskStatsF        func(context.Context, string, time.Duration) (<-chan *drivers.TaskResourceUsage, error)
	TaskEventsF       func(context.Context) (<-chan *drivers.TaskEvent, error)
	SignalTaskF       func(string, string) error
	ExecTaskF         func(string, []string, time.Duration) (*drivers.ExecTaskResult, error)
}

MockDriver is used for testing. Each function can be set as a closure to make assertions about how data is passed through the base plugin layer.

func (*MockDriver) Capabilities

func (d *MockDriver) Capabilities() (*drivers.Capabilities, error)

func (*MockDriver) DestroyTask

func (d *MockDriver) DestroyTask(taskID string, force bool) error

func (*MockDriver) ExecTask

func (d *MockDriver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)

func (*MockDriver) Fingerprint

func (d *MockDriver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)

func (*MockDriver) InspectTask

func (d *MockDriver) InspectTask(taskID string) (*drivers.TaskStatus, error)

func (*MockDriver) RecoverTask

func (d *MockDriver) RecoverTask(h *drivers.TaskHandle) error

func (*MockDriver) SignalTask

func (d *MockDriver) SignalTask(taskID string, signal string) error

func (*MockDriver) StartTask

func (*MockDriver) StopTask

func (d *MockDriver) StopTask(taskID string, timeout time.Duration, signal string) error

func (*MockDriver) TaskConfigSchema

func (d *MockDriver) TaskConfigSchema() (*hclspec.Spec, error)

func (*MockDriver) TaskEvents

func (d *MockDriver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)

func (*MockDriver) TaskStats

func (d *MockDriver) TaskStats(ctx context.Context, taskID string, i time.Duration) (<-chan *drivers.TaskResourceUsage, error)

func (*MockDriver) WaitTask

func (d *MockDriver) WaitTask(ctx context.Context, id string) (<-chan *drivers.ExitResult, error)

Jump to

Keyboard shortcuts

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