framework

package
v0.0.0-...-0000b31 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
	// GetName return component name
	GetName() string

	// Bringup doing setup for this component
	// Start() is being called in framework.StartUp()
	Start() error

	// Stop stop this component
	// Stop() is being called in framework.TearDown()
	Stop() error

	// IsAlive check if component is alive/running
	IsAlive() (bool, error)

	// Cleanup clean up tmp files and other resource created by this component
	Cleanup() error
}

Component is a interface of a test component

type Config

type Config interface {
	// GetConfig return the Config.
	GetConfig() *Config

	// SetConfig set a Config interface to an item.
	SetConfig(config *Config)
}

Config is interface to extend the ability of the framework. Any item (component, environment or even framework itself can has a Config) Actual implement can take this interface with its configuration. Implement is recommended to also take sync.Mutex to lock data while read/write

type TestEnv

type TestEnv interface {

	// GetName return environment ID
	GetName() string

	// GetComponents is the key of a environment
	// It defines what components a environment contains.
	// Components will be stored in framework for start and stop
	GetComponents() []Component

	// Bringup doing general setup for environment level, not components.
	// Bringup() is called by framework.SetUp()
	Bringup() error

	// Cleanup clean everything created by this test environment, not component level
	// Cleanup() is being called in framework.TearDown()
	Cleanup() error
}

TestEnv is a interface holding serveral components for testing

type TestEnvManager

type TestEnvManager struct {
	TestEnv    TestEnv
	TestID     string
	Components []Component
	// contains filtered or unexported fields
}

TestEnvManager is core test framework struct

func NewTestEnvManager

func NewTestEnvManager(env TestEnv, id string) *TestEnvManager

NewTestEnvManager create a TestEnvManager with a given environment and ID

func (*TestEnvManager) RunTest

func (envManager *TestEnvManager) RunTest(m runnable) (ret int)

RunTest is the main entry for framework: setup, run tests and clean up

func (*TestEnvManager) StartUp

func (envManager *TestEnvManager) StartUp() (err error)

StartUp sets up the whole environment as well brings up components

func (*TestEnvManager) TearDown

func (envManager *TestEnvManager) TearDown()

TearDown stop components and clean up environment

func (*TestEnvManager) WaitUntilReady

func (envManager *TestEnvManager) WaitUntilReady() (bool, error)

WaitUntilReady checks and waits until the whole environment is ready It retries several time before aborting and throwing error

type TestProcess

type TestProcess struct {
	Process *os.Process
}

TestProcess is a wrap of os.Process With implemented methods to control local components

func (*TestProcess) IsRunning

func (tp *TestProcess) IsRunning() (running bool, err error)

IsRunning checks if the process is still running

func (*TestProcess) Start

func (tp *TestProcess) Start(command string) (err error)

Start starts a background process with given command

func (*TestProcess) Stop

func (tp *TestProcess) Stop() (err error)

Stop kills the process

Jump to

Keyboard shortcuts

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