taskcluster-worker: github.com/taskcluster/taskcluster-worker/test Index | Files

package test

import "github.com/taskcluster/taskcluster-worker/test"

Index

Package Files

helper.go

func NewTestTask Uses

func NewTestTask(name string) (task *queue.TaskDefinitionRequest, workerType string)

NewTestTask generates a task definition for the given test name. This task definition is typically then further refined, before being sumbitted to the queue via a call to SubmitTask(...). It will also generate and return a unique (slug) workerType for this task, and this task only. This is useful for being able to run multiple tasks in parallel, and being confident that the worker instance that was started to run this task, is the one that receives it.

func RunTestWorker Uses

func RunTestWorker(workerType string)

RunTestWorker will start up the taskcluster-worker, claim one task, and then return. This is useful in integration tests, such that tests can submit a real task to the queue, then call this function to execute the task, and then query the queue to get task results.

func SubmitTask Uses

func SubmitTask(
    t *testing.T,
    td *queue.TaskDefinitionRequest,
    payload TaskPayload,
) (taskID string, q *queue.Queue)

SubmitTask will submit a real task to the production queue, if at least environment variables TASKCLUSTER_CLIENT_ID and TASKCLUSTER_ACCESS_TOKEN have been set in the current process (TASKCLUSTER_CERTIFICATE is also respected, but not required). It will return a reference to the queue and the taskID used, in order that the caller can query the queue for results, if required.

type TaskPayload Uses

type TaskPayload struct {
    // Artifacts to be published
    Artifacts []struct {
        Expires tcclient.Time `json:"expires,omitempty"`

        // This will be the leading path to directories and the full name for
        // files that are uploaded to s3. It must not begin or end with "/" and
        // must only contain printable ascii characters otherwise.
        //
        // Syntax:     ^([\x20-\x2e\x30-\x7e][\x20-\x7e]*)[\x20-\x2e\x30-\x7e]$
        Name string `json:"name"`

        // File system path of artifact
        //
        // Syntax:     ^.*[^/]$
        Path string `json:"path"`

        // Artifacts can be either an individual `file` or a `directory`
        // containing potentially multiple files with recursively included
        // subdirectories
        //
        // Possible values:
        //   * "file"
        //   * "directory"
        Type string `json:"type"`
    }   `json:"artifacts,omitempty"`

    // Command to execute
    Command []string `json:"command"`

    // Optional URL for a gzipped tar-ball to be downloaded and extracted in
    // the HOME directory for running the command.
    Context string `json:"context,omitempty"`

    // Mapping from environment variables to values
    Env json.RawMessage `json:"env,omitempty"`

    // If true, reboot the machine after task is finished.
    Reboot bool `json:"reboot,omitempty"`
}

TaskPayload is generated from running `taskcluster-worker schema payload [options] <config.yml>` and then passing the results through github.com/taskcluster/jsonschema2go. It represents the structure expected when using the test config.yml

Package test imports 18 packages (graph). Updated 2017-03-28. Refresh now. Tools for package owners.