workertest

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2017 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package workertest provides a framework for declarative definition of worker integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyArtifact

func AnyArtifact() func(t *testing.T, a Artifact)

AnyArtifact creates an assertion that checks matches anything.

func ErrorArtifact

func ErrorArtifact() func(t *testing.T, a Artifact)

ErrorArtifact creates an assertion that holds if the artifact is an error artifact

func GrepArtifact

func GrepArtifact(substring string) func(t *testing.T, a Artifact)

GrepArtifact creates an assertion that holds if the artifact contains the given substring.

func LogArtifact added in v0.1.1

func LogArtifact() func(t *testing.T, a Artifact)

LogArtifact creates an assetion that logs the artifact, to test log. This is mostly useful when developing integration tests.

func MatchArtifact added in v0.1.1

func MatchArtifact(body, contentType string) func(t *testing.T, a Artifact)

MatchArtifact creates an assertion that holds if the artifact body matches given body and has the given contentType

func ReferenceArtifact

func ReferenceArtifact() func(t *testing.T, a Artifact)

ReferenceArtifact creates an assertion that holds if the artifact is a reference artifact

func S3Artifact

func S3Artifact() func(t *testing.T, a Artifact)

S3Artifact creates an assertion that holds if the artifact is an S3 artifact

Types

type Artifact

type Artifact struct {
	ContentType     string
	Expires         time.Time
	Name            string
	StorageType     string
	Data            []byte
	ContentEncoding string
}

Artifact contains artifact meta-data.

type ArtifactAssertions

type ArtifactAssertions map[string]func(t *testing.T, a Artifact)

An ArtifactAssertions is a mapping from artifact name to assertion for the artifact. If mapping to nil value, any artifact will be permitted.

type Case

type Case struct {
	Engine            string        // Engine to be used
	EngineConfig      string        // Engine configuration as JSON
	PluginConfig      string        // Configuration of plugins, see plugins.PluginManagerConfigSchema()
	Tasks             []Task        // Tasks to create and associated assertions
	Concurrency       int           // Worker concurrency, if zero defaulted to 1 and tasks will sequantially dependent
	StoppedGracefully bool          // True, if worker is expected to stop gracefully
	StoppedNow        bool          // True, if worker is expected to stop now
	Timeout           time.Duration // Test timeout, defaults to 10 min
}

Case is a worker test case

func (Case) Test

func (c Case) Test(t *testing.T)

Test runs the test case

func (Case) TestWithFakeQueue

func (c Case) TestWithFakeQueue(t *testing.T)

TestWithFakeQueue runs integration tests against FakeQueue

func (Case) TestWithRealQueue

func (c Case) TestWithRealQueue(t *testing.T)

TestWithRealQueue runs integration tests against production queue

type StatusAssertion

type StatusAssertion func(t *testing.T, q *queue.Queue, status queue.TaskStatusStructure)

A StatusAssertion is a function that can make an assertion on a task status

type Task

type Task struct {
	Title           string                  // Optional title (for debugging)
	Payload         string                  // Task payload as JSON
	Success         bool                    // True, if task should be successfully
	Exception       runtime.ExceptionReason // Reason, if exception is expected
	Artifacts       ArtifactAssertions      // Mapping from artifact name to assertion
	AllowAdditional bool                    // True, if additional artifacts is allowed
	Status          StatusAssertion         // Optional, custom assertion on status and queue
}

A Task to be included in a worker test case

Directories

Path Synopsis
Package fakequeue provides a fake implementation of taskcluster-queue in golang, The FakeQueue server stores tasks in-memory, it doesn't validate authentication, but implements most end-points correctly.
Package fakequeue provides a fake implementation of taskcluster-queue in golang, The FakeQueue server stores tasks in-memory, it doesn't validate authentication, but implements most end-points correctly.

Jump to

Keyboard shortcuts

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