tests

package
v0.0.0-...-5db00e0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HelloWorld = &tes.Task{
	Executors: []*tes.Executor{
		{
			Image:   "alpine",
			Command: []string{"echo", "hello world"},
		},
	},
}

HelloWorld is a simple, valid task that is easy to reuse in tests.

Functions

func DefaultConfig

func DefaultConfig() config.Config

DefaultConfig returns a default configuration useful for testing, including temp storage dirs, random ports, S3 + minio config, etc.

func LogConfig

func LogConfig() logger.Config

LogConfig returns logger configuration useful for tests, which has a text indent.

func NewRPCConn

func NewRPCConn(conf config.Config, opts ...grpc.DialOption) (*grpc.ClientConn, error)

NewRPCConn returns a new grpc.ClientConn, to make creating TES clients easier.

func RandomPort

func RandomPort() string

RandomPort returns a random port string between 10000 and 20000.

func RandomPortConfig

func RandomPortConfig(conf config.Config) config.Config

RandomPortConfig returns a modified config with random HTTP and RPC ports.

func RandomString

func RandomString(n int) string

RandomString generates a random string of length n

func SetLogOutput

func SetLogOutput(l *logger.Logger, t *testing.T)

SetLogOutput provides a method for connecting funnel logso the the test logger

func TempDirConfig

func TempDirConfig(conf config.Config) config.Config

TempDirConfig returns a modified config with workdir and db path set to a temp. directory.

func TestifyConfig

func TestifyConfig(conf config.Config) config.Config

TestifyConfig modifies a ports, directory paths, etc. to avoid conflicts between tests.

func TestingWriter

func TestingWriter(t *testing.T) io.Writer

TestingWriter returns an io.Writer that writes each line via t.Log

Types

type Funnel

type Funnel struct {
	// Clients
	RPC    tes.TaskServiceClient
	HTTP   *client.Client
	Docker *docker.Client

	// Config
	Conf       config.Config
	StorageDir string

	// Components
	DB        server.Database
	Server    *server.Server
	Scheduler *scheduler.Scheduler
	SDB       scheduler.Database
	Srv       *servercmd.Server
	// contains filtered or unexported fields
}

Funnel provides a test server and RPC/HTTP clients

func NewFunnel

func NewFunnel(conf config.Config) *Funnel

NewFunnel creates a new funnel test server with some test configuration automatically set: random ports, temp work dir, etc.

func (*Funnel) AddNode

func (f *Funnel) AddNode(conf config.Config)

AddNode starts an in-memory node routine.

func (*Funnel) AddRPCClient

func (f *Funnel) AddRPCClient(opts ...grpc.DialOption) error

AddRPCClient configures and connects the RPC client to the server.

func (*Funnel) Cancel

func (f *Funnel) Cancel(id string) error

Cancel cancels a task by ID

func (*Funnel) Cleanup

func (f *Funnel) Cleanup()

Cleanup cleans up test resources

func (*Funnel) CleanupTestServerContainer

func (f *Funnel) CleanupTestServerContainer()

CleanupTestServerContainer stops the docker container running the test funnel server

func (*Funnel) Get

func (f *Funnel) Get(id string) *tes.Task

Get gets a task by ID

func (*Funnel) GetView

func (f *Funnel) GetView(id string, view tes.TaskView) *tes.Task

GetView returns a task (calls GetTask) with the given view.

func (*Funnel) ListNodes

func (f *Funnel) ListNodes() []*pbs.Node

ListNodes calls db.ListNodes.

func (*Funnel) ListView

func (f *Funnel) ListView(view tes.TaskView) []*tes.Task

ListView returns a task list (calls ListTasks) with the given view.

func (*Funnel) PollForServerStart

func (f *Funnel) PollForServerStart() error

PollForServerStart polls the server http address to check if the server is running.

func (*Funnel) ReadFile

func (f *Funnel) ReadFile(name string) string

ReadFile reads a file to the local (temporary) storage directory.

func (*Funnel) Run

func (f *Funnel) Run(s string) string

Run uses `funnel run` syntax to create a task. Run panics on error.

func (*Funnel) RunE

func (f *Funnel) RunE(s string) (string, error)

RunE is like Run(), but returns an error instead of panicing.

func (*Funnel) RunTask

func (f *Funnel) RunTask(t *tes.Task) (string, error)

RunTask calls CreateTask with the given task message and returns the ID.

func (*Funnel) StartServer

func (f *Funnel) StartServer()

StartServer starts the server

func (*Funnel) StartServerInDocker

func (f *Funnel) StartServerInDocker(imageName string, extraArgs []string)

StartServerInDocker starts a funnel server in a docker image

func (*Funnel) Tempdir

func (f *Funnel) Tempdir() string

Tempdir returns a new temporary directory path

func (*Funnel) Wait

func (f *Funnel) Wait(id string) *tes.Task

Wait waits for a task to complete.

func (*Funnel) WaitForDockerDestroy

func (f *Funnel) WaitForDockerDestroy(id string)

WaitForDockerDestroy waits for a "destroy" event from docker for the given container ID

TODO probably could use docker.ContainerWait() https://godoc.org/github.com/moby/moby/client#Client.ContainerWait

func (*Funnel) WaitForExec

func (f *Funnel) WaitForExec(id string, i int)

WaitForExec waits for a task to reach the given executor index. 1 is the first executor.

func (*Funnel) WaitForRunning

func (f *Funnel) WaitForRunning(ids ...string)

WaitForRunning waits for a task to be in the RUNNING state

func (*Funnel) WriteFile

func (f *Funnel) WriteFile(name string, content string)

WriteFile writes a file to the local (temporary) storage directory.

Jump to

Keyboard shortcuts

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