tasks

package
v0.0.0-...-7630055 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTask

type BaseTask struct {
	Type string `json:"type"`
}

BaseTask is a struct that is intended to be embedded by specific task structs. Both of these in conjunction are used primarily to house the JSON message for passing tasks over the comms package (i.e. message queue), but may also contain important dependencies of the task, such as an HTTP handler.

type DeleteTestDataTask

type DeleteTestDataTask struct {
	BaseTask
	Config   config.Config `json:"-"`
	TestUuid string        `json:"key"`
}

DeleteTestDataTask embeds BaseTask and adds the necessary fields to transport a DeleteTestData task through comms

func (DeleteTestDataTask) Run

func (dtdt DeleteTestDataTask) Run() error

Run contains the logic necessary to perform this task on the agent.

type DownloadAssetTask

type DownloadAssetTask struct {
	BaseTask
	HTTPClient   *http.Client `json:"-"`
	Fs           FileSystem   `json:"-"`
	Ios          IoSystem     `json:"-"`
	CollectorDir string       `json:"-"`
	Assets       []string     `json:"assets"`
	TestletDir   string       `json:"-"`
}

DownloadAssetTask defines this particular task. It contains definitions not only for the task message, but also HTTPClient, filesystem, and i/o system abstractions to be more conducive to unit testing.

func (DownloadAssetTask) Run

func (dat DownloadAssetTask) Run() error

Run contains the logic necessary to perform this task on the agent. This particular task will download all required assets, copy them into the appropriate directory, and ensure that the execute permission is given to each collector file.

type ExecuteTestRunTask

type ExecuteTestRunTask struct {
	BaseTask
	Config    config.Config `json:"-"`
	TestUuid  string        `json:"testuuid"`
	TimeLimit int           `json:"timelimit"`
}

ExecuteTestRunTask defines this particular task.

func (ExecuteTestRunTask) Run

func (ett ExecuteTestRunTask) Run() error

Run contains the logic necessary to perform this task on the agent. This particular task will execute a testrun that has already been installed into the local agent cache. In this context (single agent), a testrun will be executed once per target, all in parallel.

type FileSystem

type FileSystem interface {
	Open(name string) (file, error)
	Stat(name string) (os.FileInfo, error)
	Create(name string) (file, error)
	Chmod(name string, mode os.FileMode) error
}

FileSystem is an interface to abstract the "os" calls, to properly mock out functions that work with the filesystem.

type InstallTestRunTask

type InstallTestRunTask struct {
	BaseTask
	Config config.Config `json:"-"`
	Tr     defs.TestRun  `json:"testrun"`
}

InstallTestRunTask defines this particular task.

func (InstallTestRunTask) Run

func (itt InstallTestRunTask) Run() error

Run contains the logic necessary to perform this task on the agent. This particular task will install, but not execute a testrun on this agent. The installation procedure will first run the referenced testlet in check mode to help ensure that the actual testrun execution can take place. If that succeeds, the testrun is installed in the agent cache.

type IoSys

type IoSys struct{}

IoSys implements IoSystem using the local disk.

func (IoSys) Copy

func (IoSys) Copy(dst io.Writer, src io.Reader) (int64, error)

type IoSystem

type IoSystem interface {
	Copy(dst io.Writer, src io.Reader) (int64, error)
}

IoSystem is an interface to abstract the "ios" calls, to properly mock out functions that work with the filesystem.

type KeyValueTask

type KeyValueTask struct {
	BaseTask
	Config config.Config `json:"-"`
	Key    string        `json:"key"`
	Value  string        `json:"value"`
}

KeyValueTask defines this particular task.

func (KeyValueTask) Run

func (kvt KeyValueTask) Run() error

Run contains the logic necessary to perform this task on the agent. This particular task will simply pass a key/value pair to the agent cache to be set

type OsFS

type OsFS struct{}

OsFS implements fileSystem using the local disk.

func (OsFS) Chmod

func (OsFS) Chmod(name string, mode os.FileMode) error

func (OsFS) Create

func (OsFS) Create(name string) (file, error)

func (OsFS) Open

func (OsFS) Open(name string) (file, error)

func (OsFS) Stat

func (OsFS) Stat(name string) (os.FileInfo, error)

type SetGroupTask

type SetGroupTask struct {
	BaseTask
	Config    config.Config `json:"-"`
	GroupName string        `json:"groupName"`
}

SetGroupTask defines this particular task.

func (SetGroupTask) Run

func (sgt SetGroupTask) Run() error

Run contains the logic necessary to perform this task on the agent.

type Task

type Task interface {

	// TODO(mierdin): This works but is a little "meh". Basically, each task has to have a "Run()" function, as enforced
	// by this interface. If the task needs some additional data, it gets these through struct properties. This works but
	// doesn't quite feel right. Come back to this and see if there's a better way.
	Run() error
}

Task is an interface to define task behavior This is used for functions like those in comms that need to work with all specific task types, not one specific task.

Jump to

Keyboard shortcuts

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