testing

package
v0.0.0-...-a002913 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2015 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCanStopWhenSending

func AssertCanStopWhenSending(c *gc.C, stopper Stopper)

AssertCanStopWhenSending ensures even when there are changes pending to be delivered by the watcher it can still stop cleanly. This is necessary to check for deadlocks in case the watcher's inner loop is blocked trying to send and its tomb is already dying.

func AssertKillAndWait

func AssertKillAndWait(c *gc.C, killWaiter KillWaiter)

func AssertStop

func AssertStop(c *gc.C, stopper Stopper)

func Initialize

func Initialize(c *gc.C, owner names.UserTag, cfg *config.Config, policy state.Policy) *state.State

Initialize initializes the state and returns it. If state was not already initialized, and cfg is nil, the minimal default environment configuration will be used.

func NewDialOpts

func NewDialOpts() mongo.DialOpts

NewDialOpts returns configuration parameters for connecting to the testing state server.

func NewMongoInfo

func NewMongoInfo() *mongo.MongoInfo

NewMongoInfo returns information suitable for connecting to the testing state server's mongo database.

func NewState

func NewState(c *gc.C) *state.State

NewState initializes a new state with default values for testing and returns it.

func SetAgentVersion

func SetAgentVersion(st *state.State, vers version.Number) error

SetAgentVersion sets the current agent version in the state's environment configuration. This is similar to state.SetEnvironAgentVersion but it doesn't require that the environment have all agents at the same version already.

Types

type KillWaiter

type KillWaiter interface {
	Kill()
	Wait() error
}

type MapStorage

type MapStorage struct {
	Map map[string][]byte
}

func (*MapStorage) Get

func (s *MapStorage) Get(path string) (r io.ReadCloser, length int64, err error)

func (*MapStorage) Put

func (s *MapStorage) Put(path string, r io.Reader, length int64) error

func (*MapStorage) Remove

func (s *MapStorage) Remove(path string) error

type MockPolicy

type MockPolicy struct {
	GetPrechecker           func(*config.Config) (state.Prechecker, error)
	GetConfigValidator      func(string) (state.ConfigValidator, error)
	GetEnvironCapability    func(*config.Config) (state.EnvironCapability, error)
	GetConstraintsValidator func(*config.Config) (constraints.Validator, error)
	GetInstanceDistributor  func(*config.Config) (state.InstanceDistributor, error)
}

func (*MockPolicy) ConfigValidator

func (p *MockPolicy) ConfigValidator(providerType string) (state.ConfigValidator, error)

func (*MockPolicy) ConstraintsValidator

func (p *MockPolicy) ConstraintsValidator(cfg *config.Config) (constraints.Validator, error)

func (*MockPolicy) EnvironCapability

func (p *MockPolicy) EnvironCapability(cfg *config.Config) (state.EnvironCapability, error)

func (*MockPolicy) InstanceDistributor

func (p *MockPolicy) InstanceDistributor(cfg *config.Config) (state.InstanceDistributor, error)

func (*MockPolicy) Prechecker

func (p *MockPolicy) Prechecker(cfg *config.Config) (state.Prechecker, error)

type NotifyWatcher

type NotifyWatcher interface {
	Stop() error
	Changes() <-chan struct{}
}

type NotifyWatcherC

type NotifyWatcherC struct {
	*gc.C
	State   SyncStarter
	Watcher NotifyWatcher
}

NotifyWatcherC embeds a gocheck.C and adds methods to help verify the behaviour of any watcher that uses a <-chan struct{}.

func NewNotifyWatcherC

func NewNotifyWatcherC(c *gc.C, st SyncStarter, w NotifyWatcher) NotifyWatcherC

NewNotifyWatcherC returns a NotifyWatcherC that checks for aggressive event coalescence.

func (NotifyWatcherC) AssertClosed

func (c NotifyWatcherC) AssertClosed()

func (NotifyWatcherC) AssertNoChange

func (c NotifyWatcherC) AssertNoChange()

func (NotifyWatcherC) AssertOneChange

func (c NotifyWatcherC) AssertOneChange()

type RelationUnitsWatcher

type RelationUnitsWatcher interface {
	Stop() error
	Changes() <-chan multiwatcher.RelationUnitsChange
}

type RelationUnitsWatcherC

type RelationUnitsWatcherC struct {
	*gc.C
	State   SyncStarter
	Watcher RelationUnitsWatcher
	// contains filtered or unexported fields
}

RelationUnitsWatcherC embeds a gocheck.C and adds methods to help verify the behaviour of any watcher that uses a <-chan params.RelationUnitsChange.

func NewRelationUnitsWatcherC

func NewRelationUnitsWatcherC(c *gc.C, st SyncStarter, w RelationUnitsWatcher) RelationUnitsWatcherC

NewRelationUnitsWatcherC returns a RelationUnitsWatcherC that checks for aggressive event coalescence.

func (RelationUnitsWatcherC) AssertChange

func (c RelationUnitsWatcherC) AssertChange(changed []string, departed []string)

AssertChange asserts the given changes was reported by the watcher, but does not assume there are no following changes.

func (RelationUnitsWatcherC) AssertClosed

func (c RelationUnitsWatcherC) AssertClosed()

func (RelationUnitsWatcherC) AssertNoChange

func (c RelationUnitsWatcherC) AssertNoChange()

type StateSuite

type StateSuite struct {
	jujutesting.MgoSuite
	testing.BaseSuite
	Policy  state.Policy
	State   *state.State
	Owner   names.UserTag
	Factory *factory.Factory
}

StateSuite provides setup and teardown for tests that require a state.State.

func (*StateSuite) SetUpSuite

func (s *StateSuite) SetUpSuite(c *gc.C)

func (*StateSuite) SetUpTest

func (s *StateSuite) SetUpTest(c *gc.C)

func (*StateSuite) TearDownSuite

func (s *StateSuite) TearDownSuite(c *gc.C)

func (*StateSuite) TearDownTest

func (s *StateSuite) TearDownTest(c *gc.C)

type Stopper

type Stopper interface {
	Stop() error
}

type StringsWatcher

type StringsWatcher interface {
	Stop() error
	Changes() <-chan []string
}

type StringsWatcherC

type StringsWatcherC struct {
	*gc.C
	State   SyncStarter
	Watcher StringsWatcher
}

StringsWatcherC embeds a gocheck.C and adds methods to help verify the behaviour of any watcher that uses a <-chan []string.

func NewStringsWatcherC

func NewStringsWatcherC(c *gc.C, st SyncStarter, w StringsWatcher) StringsWatcherC

NewStringsWatcherC returns a StringsWatcherC that checks for aggressive event coalescence.

func (StringsWatcherC) AssertChange

func (c StringsWatcherC) AssertChange(expect ...string)

func (StringsWatcherC) AssertChangeInSingleEvent

func (c StringsWatcherC) AssertChangeInSingleEvent(expect ...string)

func (StringsWatcherC) AssertChangeMaybeIncluding

func (c StringsWatcherC) AssertChangeMaybeIncluding(expect ...string)

AssertChangeMaybeIncluding verifies that there is a change that may contain zero to all of the passed in strings, and no other changes.

func (StringsWatcherC) AssertChanges

func (c StringsWatcherC) AssertChanges()

func (StringsWatcherC) AssertClosed

func (c StringsWatcherC) AssertClosed()

func (StringsWatcherC) AssertNoChange

func (c StringsWatcherC) AssertNoChange()

type SyncStarter

type SyncStarter interface {
	StartSync()
}

SyncStarter is an interface that watcher checkers will use to ensure that changes to the watched object have been synchronized. This is primarily implemented by state.State.

Jump to

Keyboard shortcuts

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