Documentation ¶
Index ¶
- type Component
- type Config
- type Status
- type TestEnv
- type TestEnvManager
- func (envManager *TestEnvManager) GetEnv() TestEnv
- func (envManager *TestEnvManager) GetID() string
- func (envManager *TestEnvManager) RunTest(m runnable) (ret int)
- func (envManager *TestEnvManager) StartUp() (err error)
- func (envManager *TestEnvManager) TearDown()
- func (envManager *TestEnvManager) WaitUntilReady() (bool, error)
- type TestProcess
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface { // GetName returns component name GetName() string // GetConfig returns the config of this component for outside use // It can be called anytime during the whole component lifetime // It's recommended to use sync.Mutex to lock data while read // in case component itself is accessing config GetConfig() Config // SetConfig sets a config into this component // Initial config is set when during initialization // But config can be updated at runtime using SetConfig // Component needs to implement extra functions to apply new configs // It's recommended to use sync.Mutex to lock data while write // in case component itself is accessing config SetConfig(config Config) error // GetStatus returns the status of this component for outside use // It can be called anytime during the whole component lifetime // It's recommended to use sync.Mutex to lock data while read // in case component itself is updating status GetStatus() Status // Start sets up for this component // Start is being called in framework.StartUp() Start() error // Stop stops this component and clean it up // Stop is being called in framework.TearDown() Stop() error // IsAlive checks if component is alive/running IsAlive() (bool, error) }
Component is a interface of a test component
type Config ¶
type Config interface { }
Config is interface to extend the ability of the framework. It is a interface to accumulate config fields into one structure Any item (component, environment or even framework itself can has a Config) Actual implement can take this interface with its configuration.
type Status ¶
type Status interface { }
Status is interface to extend the ability of the framework. It includes anything needed to be exposed outside to other components, environment or testcases. Any item (component, environment can has a Status) Actual implement can take this interface with its status field.
type TestEnv ¶
type TestEnv interface { // GetName returns environment ID GetName() string // GetComponents is the key of a environment // It defines what components a environment contains. // It should be a singleton-like function // Components will be stored in framework for start and stop GetComponents() []Component // Bringup does general setup for environment level, not components. // Bringup() is called by framework.SetUp() Bringup() error // Cleanup cleans 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 {
// contains filtered or unexported fields
}
TestEnvManager is core test framework struct
func NewTestEnvManager ¶
func NewTestEnvManager(env TestEnv, id string) *TestEnvManager
NewTestEnvManager creates a TestEnvManager with a given environment and ID
func (*TestEnvManager) GetEnv ¶
func (envManager *TestEnvManager) GetEnv() TestEnv
GetEnv returns the test environment currently using
func (*TestEnvManager) GetID ¶
func (envManager *TestEnvManager) GetID() string
GetID returns this test 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 stops 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 ¶
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