enginetest

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package enginetest provides utilities for testing generic engine implementations.

Index

Constants

View Source
const PingPath = "/v1/ping"

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

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactTestCase added in v0.0.2

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 added in v0.0.2

func (c *ArtifactTestCase) Test()

Test runs all test cases in parallel

func (*ArtifactTestCase) TestExtractFileNotFound added in v0.0.2

func (c *ArtifactTestCase) TestExtractFileNotFound()

TestExtractFileNotFound checks that FileNotFoundPath returns ErrResourceNotFound

func (*ArtifactTestCase) TestExtractFolderHandlerInterrupt added in v0.0.2

func (c *ArtifactTestCase) TestExtractFolderHandlerInterrupt()

TestExtractFolderHandlerInterrupt checks that errors in handler given to ExtractFolder causes ErrHandlerInterrupt

func (*ArtifactTestCase) TestExtractFolderNotFound added in v0.0.2

func (c *ArtifactTestCase) TestExtractFolderNotFound()

TestExtractFolderNotFound checks that FolderNotFoundPath returns ErrResourceNotFound

func (*ArtifactTestCase) TestExtractNestedFolderPath added in v0.0.2

func (c *ArtifactTestCase) TestExtractNestedFolderPath()

TestExtractNestedFolderPath checks FolderNotFoundPath contains files NestedFolderFiles

func (*ArtifactTestCase) TestExtractTextFile added in v0.0.2

func (c *ArtifactTestCase) TestExtractTextFile()

TestExtractTextFile checks that TextFilePath contains Text

type DisplayTestCase added in v0.0.2

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 added in v0.0.2

func (c *DisplayTestCase) Test()

Test runs all tests in parallel

func (*DisplayTestCase) TestDisplays added in v0.0.2

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 added in v0.0.2

func (c *DisplayTestCase) TestInvalidDisplayName()

TestInvalidDisplayName test that IpenDisplay on InvalidDisplayName is properly handled.

func (*DisplayTestCase) TestKillDisplay added in v0.1.0

func (c *DisplayTestCase) TestKillDisplay()

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

func (*DisplayTestCase) TestListDisplays added in v0.0.2

func (c *DisplayTestCase) TestListDisplays()

TestListDisplays tests that listDisplays works and returns Displays

type EngineProvider added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

func (p *EngineProvider) TearDownEngine()

TearDownEngine the opposite of SetupEngine.

type EnvVarTestCase added in v0.0.2

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 added in v0.0.2

func (c *EnvVarTestCase) Test()

Test runs all tests in parallel

func (*EnvVarTestCase) TestInvalidVariableNames added in v0.0.2

func (c *EnvVarTestCase) TestInvalidVariableNames()

TestInvalidVariableNames checks that invalid variables returns correct error

func (*EnvVarTestCase) TestPrintVariable added in v0.0.2

func (c *EnvVarTestCase) TestPrintVariable()

TestPrintVariable checks that variable value can be printed

func (*EnvVarTestCase) TestVariableNameConflict added in v0.0.2

func (c *EnvVarTestCase) TestVariableNameConflict()

TestVariableNameConflict checks that variable name can't conflict

type KillTestCase added in v0.1.0

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 added in v0.1.0

func (c KillTestCase) Test()

Test runs the test case

type LoggingTestCase added in v0.0.2

type LoggingTestCase struct {
	*EngineProvider
	// Scopes to assign the TaskContext
	Scopes []string
	// 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 added in v0.0.2

func (c *LoggingTestCase) Test()

Test will run all logging tests

func (*LoggingTestCase) TestLogTarget added in v0.0.2

func (c *LoggingTestCase) TestLogTarget()

TestLogTarget check that Target is logged by TargetPayload

func (*LoggingTestCase) TestLogTargetWhenFailing added in v0.0.2

func (c *LoggingTestCase) TestLogTargetWhenFailing()

TestLogTargetWhenFailing check that Target is logged by FailingPayload

func (*LoggingTestCase) TestSilentTask added in v0.0.2

func (c *LoggingTestCase) TestSilentTask()

TestSilentTask checks that Target isn't logged by SilentPayload

type ProxyTestCase added in v0.0.2

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 added in v0.0.2

func (c *ProxyTestCase) Test()

Test runs all tests for the ProxyTestCase is parallel

func (*ProxyTestCase) TestLiveLogging added in v0.0.2

func (c *ProxyTestCase) TestLiveLogging()

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

func (*ProxyTestCase) TestParallelPings added in v0.0.2

func (c *ProxyTestCase) TestParallelPings()

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

func (*ProxyTestCase) TestPing404IsUnsuccessful added in v0.0.2

func (c *ProxyTestCase) TestPing404IsUnsuccessful()

TestPing404IsUnsuccessful checks that 404 returns unsuccessful

func (*ProxyTestCase) TestPingProxyPayload added in v0.0.2

func (c *ProxyTestCase) TestPingProxyPayload()

TestPingProxyPayload checks that PingProxyPayload works as defined

type ShellTestCase added in v0.0.2

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 added in v0.0.2

func (c *ShellTestCase) Test()

Test runs all tests in parallel

func (*ShellTestCase) TestAbortSleepCommand added in v0.0.2

func (c *ShellTestCase) TestAbortSleepCommand()

TestAbortSleepCommand checks we can Abort the sleep command

func (*ShellTestCase) TestBadCommand added in v0.0.2

func (c *ShellTestCase) TestBadCommand()

TestBadCommand checks we can run BadCommand in the shell

func (*ShellTestCase) TestCommand added in v0.0.2

func (c *ShellTestCase) TestCommand()

TestCommand checks we can run Command in the shell

func (*ShellTestCase) TestKillSleepCommand added in v0.1.0

func (c *ShellTestCase) TestKillSleepCommand()

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

type VolumeTestCase

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

func (c *VolumeTestCase) Test()

Test runs all tests on the test case.

func (*VolumeTestCase) TestReadEmptyVolume

func (c *VolumeTestCase) TestReadEmptyVolume()

TestReadEmptyVolume tests that read from empty volume doesn't work

func (*VolumeTestCase) TestReadToReadOnlyVolume

func (c *VolumeTestCase) TestReadToReadOnlyVolume()

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

func (*VolumeTestCase) TestWriteReadVolume

func (c *VolumeTestCase) TestWriteReadVolume()

TestWriteReadVolume tests that we can write and read from a volume

func (*VolumeTestCase) TestWriteToReadOnlyVolume

func (c *VolumeTestCase) TestWriteToReadOnlyVolume()

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

Jump to

Keyboard shortcuts

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