Documentation ¶
Index ¶
- Constants
- func WithIdentityFile(identityFile string) func(e *SSHExecutor)
- func WithPassword(pass string) func(e *SSHExecutor)
- type CommandResult
- type CommandUnderTest
- type DockerExecutor
- type EventHandler
- type Executor
- type Expected
- type ExpectedOut
- type Filters
- type GlobalTestConfig
- type LocalExecutor
- type Node
- type Result
- type ResultStatus
- type Runner
- type Runtime
- type SSHExecutor
- type TestCase
- type TestResult
- type ValidationResult
Constants ¶
const ( ExitCode = "ExitCode" Stdout = "Stdout" Stderr = "Stderr" LineCount = "LineCount" )
Constants for defining the various tested properties
Variables ¶
This section is empty.
Functions ¶
func WithIdentityFile ¶
func WithIdentityFile(identityFile string) func(e *SSHExecutor)
WithIdentityFile sets the identity file option for the ssh executor
func WithPassword ¶
func WithPassword(pass string) func(e *SSHExecutor)
WithPassword sets the identity file option for the ssh executor
Types ¶
type CommandResult ¶
type CommandResult struct { Status ResultStatus Stdout string Stderr string ExitCode int FailureProperties []string Error error }
CommandResult holds the result for a specific test
type CommandUnderTest ¶
type CommandUnderTest struct { Cmd string InheritEnv bool Env map[string]string Dir string Timeout string Retries int Interval string }
CommandUnderTest represents the command under test
func (*CommandUnderTest) GetRetries ¶
func (c *CommandUnderTest) GetRetries() int
GetRetries returns the retries of the command
type DockerExecutor ¶
type DockerExecutor struct { Image string // Image which is started to execute the test Privileged bool // Enable privileged mode for the container ExecUser string // ExecUser defines which user executes the docker container RegistryUser string RegistryPass string }
DockerExecutor executes the test inside a docker container
func (DockerExecutor) Execute ¶
func (e DockerExecutor) Execute(test TestCase) TestResult
Execute executes the script inside a docker container
type EventHandler ¶
type EventHandler struct { TestFinished func(TestResult) TestSkipped func(TestResult) }
EventHandler is a configurable event system that handles events such as test completion
type Executor ¶
type Executor interface {
Execute(test TestCase) TestResult
}
Executor interface which will be implemented by all available executors, like ssh or local
func NewLocalExecutor ¶
func NewLocalExecutor() Executor
NewLocalExecutor creates a new local executor
func NewSSHExecutor ¶
func NewSSHExecutor(host string, user string, opts ...func(e *SSHExecutor)) Executor
NewSSHExecutor creates a new executor
type Expected ¶
type Expected struct { Stdout ExpectedOut Stderr ExpectedOut LineCount int ExitCode int }
Expected is the expected output of the command under test
type ExpectedOut ¶
type ExpectedOut struct { Contains []string `yaml:"contains,omitempty"` Lines map[int]string `yaml:"lines,omitempty"` Exactly string `yaml:"exactly,omitempty"` MatchPattern string `yaml:"match-pattern,omitempty"` LineCount int `yaml:"line-count,omitempty"` LineCountMax int `yaml:"line-count-max,omitempty"` LineCountMin int `yaml:"line-count-min,omitempty"` NotContains []string `yaml:"not-contains,omitempty"` JSON map[string]string `yaml:"json,omitempty"` XML map[string]string `yaml:"xml,omitempty"` File string `yaml:"file,omitempty"` }
ExpectedOut represents the assertions on stdout and stderr
type GlobalTestConfig ¶
type GlobalTestConfig struct { Env map[string]string Dir string Timeout string Retries int Interval string InheritEnv bool Nodes []string }
GlobalTestConfig represents the configuration for a test
type LocalExecutor ¶
type LocalExecutor struct { }
LocalExecutor will be used to execute tests on the local host
func (LocalExecutor) Execute ¶
func (e LocalExecutor) Execute(test TestCase) TestResult
Execute will execute the given test on the current node
type Node ¶
type Node struct { Name string Type string User string Pass string Addr string Image string IdentityFile string Privileged bool DockerExecUser string }
Node represents a configured node with everything needed to connect to the given host which is defined in the type property If the type is not available the test will fail and stop its execution
type Result ¶
type Result struct { TestResults []TestResult Duration time.Duration Failed int Skipped int }
Result respresents the aggregation of all TestResults/summary of a runtime
type Runner ¶
type Runner struct {
Nodes []Node
}
Runner holds the config and executes the desired runtime env
type Runtime ¶
type Runtime struct { Runner *Runner EventHandler *EventHandler }
Runtime represents the current runtime, please use NewRuntime() instead of creating an instance directly
func NewRuntime ¶
func NewRuntime(eh *EventHandler, nodes ...Node) Runtime
NewRuntime creates a new runtime and inits default nodes
type SSHExecutor ¶
SSHExecutor
func (SSHExecutor) Execute ¶
func (e SSHExecutor) Execute(test TestCase) TestResult
Execute executes a command on a remote host viá SSH
type TestCase ¶
type TestCase struct { Title string Command CommandUnderTest Expected Expected Result CommandResult Nodes []string FileName string Skip bool }
TestCase represents a test case which will be executed by the runtime
type TestResult ¶
type TestResult struct { TestCase TestCase ValidationResult ValidationResult FailedProperty string Tries int Node string Skipped bool }
TestResult represents the TestCase and the ValidationResult
func Validate ¶
func Validate(test TestCase) TestResult
Validate validates the test results with the expected values The test should hold the result and expected to validate the result
type ValidationResult ¶
ValidationResult will be returned after the validation was executed