Documentation ¶
Overview ¶
Package runner provides a test runner for running golem test integration suites
Index ¶
- func BuildBaseImage(client DockerClient, conf BaseImageConfiguration, c CacheConfiguration) (string, error)
- func RunScript(lc LogCapturer, script Script) error
- func StartDaemon(binary string, lc LogCapturer) (*dockerclient.Client, func() error, error)
- type BaseImageConfiguration
- type CacheConfiguration
- type ConfigurationManager
- type CustomImage
- type DockerClient
- type ImageCache
- type Instance
- type InstanceConfiguration
- type LogCapturer
- type RunConfiguration
- type Runner
- type Script
- type SuiteConfiguration
- type SuiteRunner
- type SuiteRunnerConfiguration
- type TestRunner
- type TestScript
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildBaseImage ¶
func BuildBaseImage(client DockerClient, conf BaseImageConfiguration, c CacheConfiguration) (string, error)
BuildBaseImage builds a base image using the given configuration and returns an image id for the given image
func RunScript ¶
func RunScript(lc LogCapturer, script Script) error
RunScript runs the script command attaching results to stdout and stdout
func StartDaemon ¶
func StartDaemon(binary string, lc LogCapturer) (*dockerclient.Client, func() error, error)
StartDaemon starts a daemon using the provided binary returning a client to the binary, a close function, and error.
Types ¶
type BaseImageConfiguration ¶
type BaseImageConfiguration struct { Base reference.Named ExtraImages []reference.NamedTagged CustomImages []CustomImage DockerLoadVersion versionutil.Version DockerVersion versionutil.Version }
BaseImageConfiguration represents the configuration for constructing a base image used by a test suite. Every container in the test suite will be derived from an image created with this configuration.
type CacheConfiguration ¶
type CacheConfiguration struct { ImageCache *ImageCache BuildCache buildutil.BuildCache }
CacheConfiguration represents a cache configuration for storing docker build version cache and a custome image cache for locally built images.
type ConfigurationManager ¶
type ConfigurationManager struct {
// contains filtered or unexported fields
}
ConfigurationManager manages flags and resolving configuration settings into a runner configuration.
func NewConfigurationManager ¶
func NewConfigurationManager() *ConfigurationManager
NewConfigurationManager creates a new configuraiton manager and registers associated flags.
func (*ConfigurationManager) CreateRunner ¶
func (c *ConfigurationManager) CreateRunner(loadDockerVersion versionutil.Version, cache CacheConfiguration) (TestRunner, error)
CreateRunner creates a new test runner from a docker load version and cache configuration.
type CustomImage ¶
type CustomImage struct { Source string Target reference.NamedTagged }
CustomImage represents an image which will exist in a test container with a given name and exported from another Docker instance with the source image name.
type DockerClient ¶
type DockerClient struct { *dockerclient.Client // contains filtered or unexported fields }
DockerClient represents the docker client used by the runner
func NewDockerClient ¶
func NewDockerClient(co *clientutil.ClientOptions) (client DockerClient, err error)
NewDockerClient creates a new docker client from client options
func (DockerClient) NewBuilder ¶
func (dc DockerClient) NewBuilder(contextDirectory, dockerfilePath, repoTag string) (*build.Builder, error)
NewBuilder creates a new docker builder using the given client
type ImageCache ¶
type ImageCache struct {
// contains filtered or unexported fields
}
ImageCache reprsents a cache for mapping digests to image ids. This can be used to create a custom image build cache based on a digest from instructions.
func NewImageCache ¶
func NewImageCache(root string) *ImageCache
NewImageCache creates an image cache at the provided root.
type Instance ¶
type Instance struct { RunConfiguration CustomImages []CustomImage }
Instance represents a single runnable test instance including all prerun scripts, test commands, and Docker images to include in instance. This structure will be serialized and placed inside the test runner container.
type InstanceConfiguration ¶
type InstanceConfiguration struct { RunConfiguration Name string BaseImage BaseImageConfiguration }
InstanceConfiguration is the configuration for constructing the test instance container.
type LogCapturer ¶
LogCapturer is an interface for providing writers to a logging backend.
func NewConsoleLogCapturer ¶
func NewConsoleLogCapturer() LogCapturer
NewConsoleLogCapturer creates a new log capturer which uses the console as a backend.
func NewFileLogCapturer ¶
func NewFileLogCapturer(basename string) (LogCapturer, error)
NewFileLogCapturer uses files as a logging backend. Stdout and Stderr will be written to separate files with suffixes "-stdout" and "-stderr".
type RunConfiguration ¶
type RunConfiguration struct { Setup []Script `json:"setup"` TestRunner []TestScript `json:"runner"` }
RunConfiguration is the all the command configurations for running a test instance including setup and test commands.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner represents a golem run session including the run configuration information and cache information to optimize creation and runtime.
func (*Runner) Build ¶
func (r *Runner) Build(client DockerClient) error
Build builds all suite instance image configured for the runner. The result of build will be locally built and tagged images ready to push or run directory.
func (*Runner) Run ¶
func (r *Runner) Run(client DockerClient) error
Run starts the test instance containers as well as any containers which will manage the tests and waits for the results.
type SuiteConfiguration ¶
type SuiteConfiguration struct { Name string Path string Args []string DockerInDocker bool Instances []InstanceConfiguration }
SuiteConfiguration is the configuration for a test suite and is used for constructing the test suite containers and runtime configurations.
type SuiteRunner ¶
type SuiteRunner struct {
// contains filtered or unexported fields
}
SuiteRunner is the runtime manager for the test inside the suite instance container.
func NewSuiteRunner ¶
func NewSuiteRunner(config SuiteRunnerConfiguration) *SuiteRunner
NewSuiteRunner creates a new SuiteRunner with the provided suite runner configuration.
func (*SuiteRunner) RunTests ¶
func (sr *SuiteRunner) RunTests() error
RunTests runs the tests in order, capturing any output to the test capturer. TODO: Parse output and send to a test result manager.
func (*SuiteRunner) Setup ¶
func (sr *SuiteRunner) Setup() error
Setup does the test setup for the suite. This includes importing any docker images, running setup scripts, and starting the docker daemon used by the tests.
func (*SuiteRunner) TearDown ¶
func (sr *SuiteRunner) TearDown() (err error)
TearDown releases on test resources and stops any running containers docker daemon.
type SuiteRunnerConfiguration ¶
type SuiteRunnerConfiguration struct { DockerInDocker bool CleanDockerGraph bool DockerLoadLogCapturer LogCapturer DockerLogCapturer LogCapturer ComposeFile string ComposeCapturer LogCapturer RunConfiguration RunConfiguration SetupLogCapturer LogCapturer TestCapturer LogCapturer }
SuiteRunnerConfiguration is the configuration for running a test inside the suite instance container.
type TestRunner ¶
type TestRunner interface { Build(DockerClient) error Run(DockerClient) error }
TestRunner defines an interface for building and running a test.
type TestScript ¶
TestScript is a command configuration along with expected output for parsing test results.