juju: github.com/juju/juju/state/testing Index | Files

package testing

import "github.com/juju/juju/state/testing"

Index

Package Files

agent.go cloudcredentials.go conn.go policy.go suite.go suite_wallclock.go watcher.go

func AssertCanStopWhenSending Uses

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 Uses

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

func AssertStop Uses

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

func CloudCredential Uses

func CloudCredential(authType cloud.AuthType, attrs map[string]string) state.Credential

CloudCredential is a convenience method to create state.Credential to be used in unit tests.

func Initialize Uses

func Initialize(c *gc.C, owner names.UserTag, cfg *config.Config, controllerInheritedConfig map[string]interface{}, regionConfig cloud.RegionConfig, newPolicy state.NewPolicyFunc) *state.Controller

Initialize initializes the state and returns it. If state was not already initialized, and cfg is nil, the minimal default model configuration will be used. This provides for tests still using a real clock from utils as tests are migrated to use the testing clock

func InitializeWithArgs Uses

func InitializeWithArgs(c *gc.C, args InitializeArgs) *state.Controller

InitializeWithArgs initializes the state and returns it. If state was not already initialized, and args.Config is nil, the minimal default model configuration will be used.

func NewEmptyCredential Uses

func NewEmptyCredential() state.Credential

NewEmptyCredential is a convenience method to create an empty state.Credential with a cloud.EmptyAuthType as auth type to be used in unit tests.

func NewMongoInfo Uses

func NewMongoInfo() *mongo.MongoInfo

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

func SetAgentVersion Uses

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

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

type InitializeArgs Uses

type InitializeArgs struct {
    Owner                     names.UserTag
    InitialConfig             *config.Config
    ControllerConfig          map[string]interface{}
    ControllerInheritedConfig map[string]interface{}
    RegionConfig              cloud.RegionConfig
    NewPolicy                 state.NewPolicyFunc
    Clock                     clock.Clock
}

type KillWaiter Uses

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

type MockConfigSchemaSource Uses

type MockConfigSchemaSource struct {
    CloudName string
}

func (*MockConfigSchemaSource) ConfigDefaults Uses

func (m *MockConfigSchemaSource) ConfigDefaults() schema.Defaults

func (*MockConfigSchemaSource) ConfigSchema Uses

func (m *MockConfigSchemaSource) ConfigSchema() schema.Fields

type MockNotifyWatcher Uses

type MockNotifyWatcher struct {
    // contains filtered or unexported fields
}

MockNotifyWatcher implements state.NotifyWatcher.

func NewMockNotifyWatcher Uses

func NewMockNotifyWatcher(ch <-chan struct{}) *MockNotifyWatcher

func (*MockNotifyWatcher) Changes Uses

func (w *MockNotifyWatcher) Changes() <-chan struct{}

func (*MockNotifyWatcher) Err Uses

func (w *MockNotifyWatcher) Err() error

func (*MockNotifyWatcher) Kill Uses

func (w *MockNotifyWatcher) Kill()

func (*MockNotifyWatcher) Stop Uses

func (w *MockNotifyWatcher) Stop() error

func (*MockNotifyWatcher) Wait Uses

func (w *MockNotifyWatcher) Wait() error

type MockPolicy Uses

type MockPolicy struct {
    GetPrechecker                 func() (environs.InstancePrechecker, error)
    GetConfigValidator            func() (config.Validator, error)
    GetProviderConfigSchemaSource func(cloudName string) (config.ConfigSchemaSource, error)
    GetConstraintsValidator       func() (constraints.Validator, error)
    GetInstanceDistributor        func() (context.Distributor, error)
    GetStorageProviderRegistry    func() (storage.ProviderRegistry, error)
}

func (*MockPolicy) ConfigValidator Uses

func (p *MockPolicy) ConfigValidator() (config.Validator, error)

func (*MockPolicy) ConstraintsValidator Uses

func (p *MockPolicy) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error)

func (*MockPolicy) InstanceDistributor Uses

func (p *MockPolicy) InstanceDistributor() (context.Distributor, error)

func (*MockPolicy) Prechecker Uses

func (p *MockPolicy) Prechecker() (environs.InstancePrechecker, error)

func (*MockPolicy) ProviderConfigSchemaSource Uses

func (p *MockPolicy) ProviderConfigSchemaSource(cloudName string) (config.ConfigSchemaSource, error)

func (*MockPolicy) StorageProviderRegistry Uses

func (p *MockPolicy) StorageProviderRegistry() (storage.ProviderRegistry, error)

type MockStringsWatcher Uses

type MockStringsWatcher struct {
    // contains filtered or unexported fields
}

MockStringsWatcher implements state.StringsWatcher.

func NewMockStringsWatcher Uses

func NewMockStringsWatcher(ch <-chan []string) *MockStringsWatcher

func (*MockStringsWatcher) Changes Uses

func (w *MockStringsWatcher) Changes() <-chan []string

func (*MockStringsWatcher) Err Uses

func (w *MockStringsWatcher) Err() error

func (*MockStringsWatcher) Kill Uses

func (w *MockStringsWatcher) Kill()

func (*MockStringsWatcher) Stop Uses

func (w *MockStringsWatcher) Stop() error

func (*MockStringsWatcher) Wait Uses

func (w *MockStringsWatcher) Wait() error

type NotifyWatcher Uses

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

type NotifyWatcherC Uses

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 Uses

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

NewNotifyWatcherC returns a NotifyWatcherC that checks for aggressive event coalescence.

func (NotifyWatcherC) AssertClosed Uses

func (c NotifyWatcherC) AssertClosed()

func (NotifyWatcherC) AssertNoChange Uses

func (c NotifyWatcherC) AssertNoChange()

func (NotifyWatcherC) AssertOneChange Uses

func (c NotifyWatcherC) AssertOneChange()

type RelationUnitsWatcher Uses

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

type RelationUnitsWatcherC Uses

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 Uses

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

NewRelationUnitsWatcherC returns a RelationUnitsWatcherC that checks for aggressive event coalescence.

func (RelationUnitsWatcherC) AssertChange Uses

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 Uses

func (c RelationUnitsWatcherC) AssertClosed()

func (RelationUnitsWatcherC) AssertNoChange Uses

func (c RelationUnitsWatcherC) AssertNoChange()

type StateSuite Uses

type StateSuite struct {
    jujutesting.MgoSuite
    testing.BaseSuite
    NewPolicy                 state.NewPolicyFunc
    Controller                *state.Controller
    StatePool                 *state.StatePool
    State                     *state.State
    Model                     *state.Model
    Owner                     names.UserTag
    Factory                   *factory.Factory
    InitialConfig             *config.Config
    InitialTime               time.Time
    ControllerConfig          map[string]interface{}
    ControllerInheritedConfig map[string]interface{}
    RegionConfig              cloud.RegionConfig
    Clock                     *testclock.Clock
    // contains filtered or unexported fields
}

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

func (*StateSuite) SetUpSuite Uses

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

func (*StateSuite) SetUpTest Uses

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

func (*StateSuite) TearDownSuite Uses

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

func (*StateSuite) TearDownTest Uses

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

func (*StateSuite) WaitForModelWatchersIdle Uses

func (s *StateSuite) WaitForModelWatchersIdle(c *gc.C, modelUUID string)

WaitForModelWatchersIdle firstly waits for the txn poller to process all pending changes, then waits for the hub watcher on the state object to have finished processing all those events.

func (*StateSuite) WaitForNextSync Uses

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

WaitForNextSync repeatedly advances the testing clock with short waits between until the txn poller doesn't find any more changes.

type StateWithWallClockSuite Uses

type StateWithWallClockSuite struct {
    testing.MgoSuite
    coretesting.BaseSuite
    NewPolicy                 state.NewPolicyFunc
    Controller                *state.Controller
    StatePool                 *state.StatePool
    State                     *state.State
    Model                     *state.Model
    Owner                     names.UserTag
    Factory                   *factory.Factory
    InitialConfig             *config.Config
    ControllerInheritedConfig map[string]interface{}
    RegionConfig              cloud.RegionConfig
}

StateWithWallClockSuite provides setup and teardown for tests that require a state.State. This should be deprecated in favour of StateSuite, and tests updated to use the testing clock StateSuite provides.

func (*StateWithWallClockSuite) SetUpSuite Uses

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

func (*StateWithWallClockSuite) SetUpTest Uses

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

func (*StateWithWallClockSuite) TearDownSuite Uses

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

func (*StateWithWallClockSuite) TearDownTest Uses

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

type Stopper Uses

type Stopper interface {
    Stop() error
}

type StringsWatcher Uses

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

type StringsWatcherC Uses

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 Uses

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

NewStringsWatcherC returns a StringsWatcherC that checks for aggressive event coalescence.

func (StringsWatcherC) AssertChange Uses

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

func (StringsWatcherC) AssertChangeInSingleEvent Uses

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

func (StringsWatcherC) AssertChangeMaybeIncluding Uses

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 Uses

func (c StringsWatcherC) AssertChanges()

func (StringsWatcherC) AssertClosed Uses

func (c StringsWatcherC) AssertClosed()

func (StringsWatcherC) AssertNoChange Uses

func (c StringsWatcherC) AssertNoChange()

type SyncStarter Uses

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.

Package testing imports 30 packages (graph) and is imported by 141 packages. Updated 2019-08-27. Refresh now. Tools for package owners.