Documentation ¶
Index ¶
- Variables
- func NewMockDriver(ctx context.Context, logger hclog.Logger) drivers.DriverPlugin
- type Command
- type Config
- type Driver
- func (d *Driver) Capabilities() (*drivers.Capabilities, error)
- func (d *Driver) ConfigSchema() (*hclspec.Spec, error)
- func (d *Driver) CreateNetwork(allocID string, request *drivers.NetworkCreateRequest) (*drivers.NetworkIsolationSpec, bool, error)
- func (d *Driver) DestroyNetwork(allocID string, spec *drivers.NetworkIsolationSpec) error
- func (d *Driver) DestroyTask(taskID string, force bool) error
- func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
- func (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, execOpts *drivers.ExecOptions) (*drivers.ExitResult, error)
- func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
- func (d *Driver) GetHandle(taskID string) *taskHandle
- func (d *Driver) GetTaskConfig() (*drivers.TaskConfig, *TaskConfig)
- func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error)
- func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error)
- func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error
- func (d *Driver) SetConfig(cfg *base.Config) error
- func (d *Driver) SignalTask(taskID string, signal string) error
- func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
- func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) error
- func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error)
- func (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)
- func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
- func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
- type MockTaskState
- type TaskConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // PluginID is the mock driver plugin metadata registered in the plugin // catalog. PluginID = loader.PluginID{ Name: pluginName, PluginType: base.PluginTypeDriver, } // PluginConfig is the mock driver factory function registered in the // plugin catalog. PluginConfig = &loader.InternalPluginConfig{ Config: map[string]interface{}{}, Factory: func(ctx context.Context, l hclog.Logger) interface{} { return NewMockDriver(ctx, l) }, } )
Functions ¶
func NewMockDriver ¶
NewMockDriver returns a new DriverPlugin implementation
Types ¶
type Command ¶ added in v0.9.2
type Command struct { // RunFor is the duration for which the fake task runs for. After this // period the MockDriver responds to the task running indicating that the // task has terminated RunFor string `codec:"run_for"` // ExitCode is the exit code with which the MockDriver indicates the task // has exited ExitCode int `codec:"exit_code"` // ExitSignal is the signal with which the MockDriver indicates the task has // been killed ExitSignal int `codec:"exit_signal"` // ExitErrMsg is the error message that the task returns while exiting ExitErrMsg string `codec:"exit_err_msg"` // SignalErr is the error message that the task returns if signalled SignalErr string `codec:"signal_error"` // StdoutString is the string that should be sent to stdout StdoutString string `codec:"stdout_string"` // StdoutRepeat is the number of times the output should be sent. StdoutRepeat int `codec:"stdout_repeat"` // StdoutRepeatDur is the duration between repeated outputs. StdoutRepeatDur string `codec:"stdout_repeat_duration"` // StderrString is the string that should be sent to stderr StderrString string `codec:"stderr_string"` // StderrRepeat is the number of times the errput should be sent. StderrRepeat int `codec:"stderr_repeat"` // StderrRepeatDur is the duration between repeated errputs. StderrRepeatDur string `codec:"stderr_repeat_duration"` // contains filtered or unexported fields }
type Config ¶
type Config struct { FSIsolation string `codec:"fs_isolation"` // ShutdownPeriodicAfter is a toggle that can be used during tests to // "stop" a previously-functioning driver, allowing for testing of periodic // drivers and fingerprinters ShutdownPeriodicAfter bool `codec:"shutdown_periodic_after"` // ShutdownPeriodicDuration is a option that can be used during tests // to "stop" a previously functioning driver after the specified duration // for testing of periodic drivers and fingerprinters. ShutdownPeriodicDuration time.Duration `codec:"shutdown_periodic_duration"` }
Config is the configuration for the driver that applies to all tasks
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is a mock DriverPlugin implementation
func (*Driver) Capabilities ¶
func (d *Driver) Capabilities() (*drivers.Capabilities, error)
func (*Driver) CreateNetwork ¶ added in v0.10.0
func (d *Driver) CreateNetwork(allocID string, request *drivers.NetworkCreateRequest) (*drivers.NetworkIsolationSpec, bool, error)
func (*Driver) DestroyNetwork ¶ added in v0.10.0
func (d *Driver) DestroyNetwork(allocID string, spec *drivers.NetworkIsolationSpec) error
func (*Driver) ExecTaskStreaming ¶ added in v0.9.2
func (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, execOpts *drivers.ExecOptions) (*drivers.ExitResult, error)
func (*Driver) Fingerprint ¶
func (*Driver) GetHandle ¶
GetHandle is unique to the mock driver and for testing purposes only. It returns the handle of the given task ID
func (*Driver) GetTaskConfig ¶
func (d *Driver) GetTaskConfig() (*drivers.TaskConfig, *TaskConfig)
GetTaskConfig is unique to the mock driver and for testing purposes only. It returns the *drivers.TaskConfig passed to StartTask and the decoded *mock.TaskConfig created by the last StartTask call.
func (*Driver) InspectTask ¶
func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error)
func (*Driver) PluginInfo ¶
func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error)
func (*Driver) RecoverTask ¶
func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error
func (*Driver) StartTask ¶
func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
func (*Driver) TaskEvents ¶
type MockTaskState ¶
type TaskConfig ¶
type TaskConfig struct { Command ExecCommand *Command `codec:"exec_command"` // PluginExitAfter is the duration after which the mock driver indicates the // plugin has exited via the WaitTask call. PluginExitAfter string `codec:"plugin_exit_after"` // StartErr specifies the error that should be returned when starting the // mock driver. StartErr string `codec:"start_error"` // StartErrRecoverable marks the error returned is recoverable StartErrRecoverable bool `codec:"start_error_recoverable"` // StartBlockFor specifies a duration in which to block before returning StartBlockFor string `codec:"start_block_for"` // KillAfter is the duration after which the mock driver indicates the task // has exited after getting the initial SIGINT signal KillAfter string `codec:"kill_after"` // DriverIP will be returned as the DriverNetwork.IP from Start() DriverIP string `codec:"driver_ip"` // DriverAdvertise will be returned as DriverNetwork.AutoAdvertise from // Start(). DriverAdvertise bool `codec:"driver_advertise"` // DriverPortMap will parse a label:number pair and return it in // DriverNetwork.PortMap from Start(). DriverPortMap string `codec:"driver_port_map"` // contains filtered or unexported fields }
TaskConfig is the driver configuration of a task within a job
Click to show internal directories.
Click to hide internal directories.