taskcluster-worker: github.com/taskcluster/taskcluster-worker/engines/enginetest Index | Files

package enginetest

import "github.com/taskcluster/taskcluster-worker/engines/enginetest"

Package enginetest provides utilities for testing generic engine implementations.

Index

Package Files

artifacts.go attachproxy.go attachvolume.go display.go environmentvariable.go kill.go logging.go shell.go testutils.go

Constants

const PingPath = "/v1/ping"

PingPath is the path that PingProxyPayload should hit on the proxy.

type ArtifactTestCase Uses

type ArtifactTestCase struct {
    *EngineProvider
    // Text to search for in files
    Text string
    // Path of a file containing the Text string above
    TextFilePath string
    // Path to a file that doesn't exist, and will return ErrResourceNotFound
    FileNotFoundPath string
    // Path to a folder that doesn't exist, and will return ErrResourceNotFound
    FolderNotFoundPath string
    // Files to expect in NestedFolderPath (must be relative and slash separated)
    NestedFolderFiles []string
    // Path to a folder that contains files NestedFolderFiles each containing
    // Text
    NestedFolderPath string
    // Payload that will generate a ResultSet containing paths described above.
    Payload string
}

The ArtifactTestCase contains information sufficient to test artifact extration from an engine.

func (*ArtifactTestCase) Test Uses

func (c *ArtifactTestCase) Test()

Test runs all test cases in parallel

func (*ArtifactTestCase) TestExtractFileNotFound Uses

func (c *ArtifactTestCase) TestExtractFileNotFound()

TestExtractFileNotFound checks that FileNotFoundPath returns ErrResourceNotFound

func (*ArtifactTestCase) TestExtractFolderHandlerInterrupt Uses

func (c *ArtifactTestCase) TestExtractFolderHandlerInterrupt()

TestExtractFolderHandlerInterrupt checks that errors in handler given to ExtractFolder causes ErrHandlerInterrupt

func (*ArtifactTestCase) TestExtractFolderNotFound Uses

func (c *ArtifactTestCase) TestExtractFolderNotFound()

TestExtractFolderNotFound checks that FolderNotFoundPath returns ErrResourceNotFound

func (*ArtifactTestCase) TestExtractNestedFolderPath Uses

func (c *ArtifactTestCase) TestExtractNestedFolderPath()

TestExtractNestedFolderPath checks FolderNotFoundPath contains files NestedFolderFiles

func (*ArtifactTestCase) TestExtractTextFile Uses

func (c *ArtifactTestCase) TestExtractTextFile()

TestExtractTextFile checks that TextFilePath contains Text

type DisplayTestCase Uses

type DisplayTestCase struct {
    *EngineProvider
    // List of display that should be returned from Sandbox.ListDisplays(),
    // They will all be opened to ensure that they are in fact VNC connections.
    Displays []engines.Display
    // Name of a display that does not exist, it will be attempted opened to
    // check that this failure is handled gracefully.
    InvalidDisplayName string
    // Payload for the engine that will contain an interactive environment as
    // described above.
    Payload string
}

The DisplayTestCase contains information sufficient to test the interactive display provided by a Sandbox

func (*DisplayTestCase) Test Uses

func (c *DisplayTestCase) Test()

Test runs all tests in parallel

func (*DisplayTestCase) TestDisplays Uses

func (c *DisplayTestCase) TestDisplays()

TestDisplays tests that we can connect to all Displays listed, and that the resolution is correct if advertized (ie. non-zero). To facilitate that resolution changes in the test sandbox this test will only require that the resolution either before or after connecting matches what is listed.

func (*DisplayTestCase) TestInvalidDisplayName Uses

func (c *DisplayTestCase) TestInvalidDisplayName()

TestInvalidDisplayName test that IpenDisplay on InvalidDisplayName is properly handled.

func (*DisplayTestCase) TestKillDisplay Uses

func (c *DisplayTestCase) TestKillDisplay()

TestKillDisplay opens a display and test that it is closed if Sandbox.Kill() is called.

func (*DisplayTestCase) TestListDisplays Uses

func (c *DisplayTestCase) TestListDisplays()

TestListDisplays tests that listDisplays works and returns Displays

type EngineProvider Uses

type EngineProvider struct {

    // Name of engine
    Engine string
    // Engine configuration as JSON
    Config string
    // Function to be called before using the engine, may return a function to be
    // called after running the engine.
    Setup func() func()
    // contains filtered or unexported fields
}

EngineProvider is a base object used by test case to get an engine.

func (*EngineProvider) SetupEngine Uses

func (p *EngineProvider) SetupEngine()

SetupEngine will initialize the engine and hold reference to it. This allows the same engine instance to be reused between tests. TearDownEngine must be called later to ensure the engine is destroyed.

This is not necessary, but can be used to improve test efficiency and reliability in cases where engine setup/teardown is flaky/slow.

func (*EngineProvider) TearDownEngine Uses

func (p *EngineProvider) TearDownEngine()

TearDownEngine the opposite of SetupEngine.

type EnvVarTestCase Uses

type EnvVarTestCase struct {
    *EngineProvider
    // Valid name for an environment variable.
    VariableName string
    // Invalid environment variable names.
    InvalidVariableNames []string
    // Payload that will print the value of VariableName to the log.
    Payload string
}

The EnvVarTestCase contains information sufficient to setting an environment variable.

func (*EnvVarTestCase) Test Uses

func (c *EnvVarTestCase) Test()

Test runs all tests in parallel

func (*EnvVarTestCase) TestInvalidVariableNames Uses

func (c *EnvVarTestCase) TestInvalidVariableNames()

TestInvalidVariableNames checks that invalid variables returns correct error

func (*EnvVarTestCase) TestPrintVariable Uses

func (c *EnvVarTestCase) TestPrintVariable()

TestPrintVariable checks that variable value can be printed

func (*EnvVarTestCase) TestVariableNameConflict Uses

func (c *EnvVarTestCase) TestVariableNameConflict()

TestVariableNameConflict checks that variable name can't conflict

type KillTestCase Uses

type KillTestCase struct {
    *EngineProvider
    Target  string
    Payload string
}

A KillTestCase tests if calling Sandbox.Kill() works by invoking it after Target has been printed to log by Payload.

func (KillTestCase) Test Uses

func (c KillTestCase) Test()

Test runs the test case

type LoggingTestCase Uses

type LoggingTestCase struct {
    *EngineProvider
    // String that we will look for in the log
    Target string
    // A task.payload as accepted by the engine, which will Target to the log and
    // exit successfully.
    TargetPayload string
    // A task.payload which will write Target, but the task will be unsuccessful.
    FailingPayload string
    // A task.payload which won't write Target to the log, but will by successful.
    SilentPayload string
}

A LoggingTestCase holds information necessary to run tests that an engine can write things to the log.

func (*LoggingTestCase) Test Uses

func (c *LoggingTestCase) Test()

Test will run all logging tests

func (*LoggingTestCase) TestLogTarget Uses

func (c *LoggingTestCase) TestLogTarget()

TestLogTarget check that Target is logged by TargetPayload

func (*LoggingTestCase) TestLogTargetWhenFailing Uses

func (c *LoggingTestCase) TestLogTargetWhenFailing()

TestLogTargetWhenFailing check that Target is logged by FailingPayload

func (*LoggingTestCase) TestSilentTask Uses

func (c *LoggingTestCase) TestSilentTask()

TestSilentTask checks that Target isn't logged by SilentPayload

type ProxyTestCase Uses

type ProxyTestCase struct {
    *EngineProvider
    // A valid name for a proxy attachment
    ProxyName string
    // A task.payload as accepted by the engine, which will write "Pinging"
    // to the log, then ping the proxy given by ProxyName with GET to the path
    // "/v1/ping", and write the response to log.
    // The task payload must exit successfully if proxy response code is 200,
    // and unsuccessful if the response code is 404.
    PingProxyPayload string
}

A ProxyTestCase holds information necessary to run tests that an engine can attach proxies, call them and forward calls correctly

func (*ProxyTestCase) Test Uses

func (c *ProxyTestCase) Test()

Test runs all tests for the ProxyTestCase is parallel

func (*ProxyTestCase) TestLiveLogging Uses

func (c *ProxyTestCase) TestLiveLogging()

TestLiveLogging checks that "Pinging" is readable from log before the task is finished.

func (*ProxyTestCase) TestParallelPings Uses

func (c *ProxyTestCase) TestParallelPings()

TestParallelPings checks that two parallel pings is possible when running two engines next to each other.

func (*ProxyTestCase) TestPing404IsUnsuccessful Uses

func (c *ProxyTestCase) TestPing404IsUnsuccessful()

TestPing404IsUnsuccessful checks that 404 returns unsuccessful

func (*ProxyTestCase) TestPingProxyPayload Uses

func (c *ProxyTestCase) TestPingProxyPayload()

TestPingProxyPayload checks that PingProxyPayload works as defined

type ShellTestCase Uses

type ShellTestCase struct {
    *EngineProvider
    // Command to pipe to the Shell over stdin
    Command string
    // Result to expect from the Shell on stdout when running Command
    Stdout string
    // Result to expect from the Shell on stderr when running Command
    Stderr string
    // Command to execute that exits the shell false
    BadCommand string
    // Command to execute that sleeps long enough for Shell.Abort() or
    // Sandbox.Kill() to terminate it. Should exit true, if not terminate.
    SleepCommand string
    // Payload for the engine that will contain an interactive environment as
    // described above.
    Payload string
}

The ShellTestCase contains information sufficient to test the interactive shell provided by a Sandbox

func (*ShellTestCase) Test Uses

func (c *ShellTestCase) Test()

Test runs all tests in parallel

func (*ShellTestCase) TestAbortSleepCommand Uses

func (c *ShellTestCase) TestAbortSleepCommand()

TestAbortSleepCommand checks we can Abort the sleep command

func (*ShellTestCase) TestBadCommand Uses

func (c *ShellTestCase) TestBadCommand()

TestBadCommand checks we can run BadCommand in the shell

func (*ShellTestCase) TestCommand Uses

func (c *ShellTestCase) TestCommand()

TestCommand checks we can run Command in the shell

func (*ShellTestCase) TestKillSleepCommand Uses

func (c *ShellTestCase) TestKillSleepCommand()

TestKillSleepCommand checks we can Sandbox.Kill() the sleep command

type VolumeTestCase Uses

type VolumeTestCase struct {
    *EngineProvider
    // A valid mountpoint
    Mountpoint string
    // A task.payload as accepted by the engine, which will write something to the
    // mountpoint given.
    WriteVolumePayload string
    // A task.payload as accepted by the engine, which will check that something
    // was written to the mountpoint given.
    CheckVolumePayload string
}

A VolumeTestCase holds information necessary to run tests that an engine can create volumes, mount and read/write to volumes.

func (*VolumeTestCase) Test Uses

func (c *VolumeTestCase) Test()

Test runs all tests on the test case.

func (*VolumeTestCase) TestReadEmptyVolume Uses

func (c *VolumeTestCase) TestReadEmptyVolume()

TestReadEmptyVolume tests that read from empty volume doesn't work

func (*VolumeTestCase) TestReadToReadOnlyVolume Uses

func (c *VolumeTestCase) TestReadToReadOnlyVolume()

TestReadToReadOnlyVolume tests that we can read from a read-only volume

func (*VolumeTestCase) TestWriteReadVolume Uses

func (c *VolumeTestCase) TestWriteReadVolume()

TestWriteReadVolume tests that we can write and read from a volume

func (*VolumeTestCase) TestWriteToReadOnlyVolume Uses

func (c *VolumeTestCase) TestWriteToReadOnlyVolume()

TestWriteToReadOnlyVolume tests that write doesn't work to a read-only volume

Package enginetest imports 21 packages (graph) and is imported by 1 packages. Updated 2017-11-12. Refresh now. Tools for package owners.