Documentation ¶
Index ¶
- Constants
- Variables
- func AddCharm(st *state.State, curl *charm.URL, ch charm.Charm, force bool) (*state.Charm, error)
- func AddControllerMachine(c *gc.C, st *state.State) *state.Machine
- func AddSubnetsWithTemplate(c *gc.C, st *state.State, numSubnets uint, infoTemplate network.SubnetInfo)
- func AssertStartControllerInstance(c *gc.C, env environs.Environ, ctx context.ProviderCallContext, ...) (instances.Instance, *instance.HardwareCharacteristics)
- func AssertStartInstance(c *gc.C, env environs.Environ, ctx context.ProviderCallContext, ...) (instances.Instance, *instance.HardwareCharacteristics)
- func AssertStartInstanceWithConstraints(c *gc.C, env environs.Environ, ctx context.ProviderCallContext, ...) (instances.Instance, *instance.HardwareCharacteristics)
- func DefaultVersions(conf *config.Config) []version.Binary
- func FakeAPIInfo(machineId string) *api.Info
- func FillInStartInstanceParams(env environs.Environ, machineId string, isController bool, ...) error
- func PutCharm(st *state.State, curl *charm.URL, ch *charm.CharmDir) (*state.Charm, error)
- func SetImageMetadata(env environs.Environ, fetcher imagemetadata.SimplestreamsFetcher, ...) error
- func StartInstance(env environs.Environ, ctx context.ProviderCallContext, ...) (instances.Instance, *instance.HardwareCharacteristics, ...)
- func StartInstanceWithConstraints(env environs.Environ, ctx context.ProviderCallContext, ...) (instances.Instance, *instance.HardwareCharacteristics, ...)
- func StartInstanceWithParams(env environs.Environ, ctx context.ProviderCallContext, machineId string, ...) (*environs.StartInstanceResult, error)
- func WaitInstanceAddresses(env environs.Environ, ctx context.ProviderCallContext, instId instance.Id) (corenetwork.ProviderAddresses, error)
- type GetStater
- type JujuConnSuite
- func (s *JujuConnSuite) APIInfo(c *gc.C) *api.Info
- func (s *JujuConnSuite) AddDefaultToolsToState(c *gc.C)
- func (s *JujuConnSuite) AddTestingApplication(c *gc.C, name string, ch *state.Charm) *state.Application
- func (s *JujuConnSuite) AddTestingApplicationWithArch(c *gc.C, name string, ch *state.Charm, arch string) *state.Application
- func (s *JujuConnSuite) AddTestingApplicationWithBindings(c *gc.C, name string, ch *state.Charm, bindings map[string]string) *state.Application
- func (s *JujuConnSuite) AddTestingApplicationWithOrigin(c *gc.C, name string, ch *state.Charm, origin *state.CharmOrigin) *state.Application
- func (s *JujuConnSuite) AddTestingApplicationWithStorage(c *gc.C, name string, ch *state.Charm, ...) *state.Application
- func (s *JujuConnSuite) AddTestingCharm(c *gc.C, name string) *state.Charm
- func (s *JujuConnSuite) AddTestingCharmForSeries(c *gc.C, name, series string) *state.Charm
- func (s *JujuConnSuite) AddToolsToState(c *gc.C, versions ...version.Binary)
- func (s *JujuConnSuite) AdminUserTag(c *gc.C) names.UserTag
- func (s *JujuConnSuite) AgentConfigForTag(c *gc.C, tag names.Tag) agent.ConfigSetterWriter
- func (s *JujuConnSuite) AssertConfigParameterUpdated(c *gc.C, key string, value interface{})
- func (s *JujuConnSuite) ConfDir() string
- func (s *JujuConnSuite) CreateUserHome(c *gc.C, params *UserHomeParams)
- func (s *JujuConnSuite) DataDir() string
- func (s *JujuConnSuite) EnsureCachedModel(c *gc.C, uuid string)
- func (s *JujuConnSuite) MongoInfo() *mongo.MongoInfo
- func (s *JujuConnSuite) OpenAPIAs(c *gc.C, tag names.Tag, password string) api.Connection
- func (s *JujuConnSuite) OpenAPIAsMachine(c *gc.C, tag names.Tag, password, nonce string) api.Connection
- func (s *JujuConnSuite) OpenAPIAsNewMachine(c *gc.C, jobs ...state.MachineJob) (api.Connection, *state.Machine)
- func (s *JujuConnSuite) OpenControllerAPI(c *gc.C) api.Connection
- func (s *JujuConnSuite) OpenControllerAPIAs(c *gc.C, tag names.Tag, password string) api.Connection
- func (s *JujuConnSuite) Reset(c *gc.C)
- func (s *JujuConnSuite) SetUpSuite(c *gc.C)
- func (s *JujuConnSuite) SetUpTest(c *gc.C)
- func (s *JujuConnSuite) TearDownSuite(c *gc.C)
- func (s *JujuConnSuite) TearDownTest(c *gc.C)
- func (s *JujuConnSuite) TransientDataDir() string
- func (s *JujuConnSuite) WaitForModelWatchersIdle(c *gc.C, modelUUID string)
- func (s *JujuConnSuite) WaitForNextSync(c *gc.C)
- type RepoSuite
- func (s *RepoSuite) AssertApplication(c *gc.C, name string, expectCurl string, unitCount, relCount int) (*state.Application, []*state.Relation)
- func (s *RepoSuite) AssertCharmUploaded(c *gc.C, curl string)
- func (s *RepoSuite) AssertUnitMachines(c *gc.C, units []*state.Unit)
- func (s *RepoSuite) SetUpTest(c *gc.C)
- type UserHomeParams
Constants ¶
const AdminSecret = "dummy-secret"
const (
ControllerName = "kontroll"
)
Variables ¶
var ( // KubernetesSeriesName is the kubernetes series name that is validated at // runtime, otherwise it panics. KubernetesSeriesName = strings.ToLower(ostype.Kubernetes.String()) )
Functions ¶
func AddControllerMachine ¶
AddControllerMachine adds a "controller" machine to the state so that State.Addresses and State.APIAddresses will work. It returns the added machine. The addresses that those methods will return bear no relation to the addresses actually used by the state and API servers. It returns the addresses that will be returned by the State.Addresses and State.APIAddresses methods, which will not bear any relation to the be the addresses used by the controllers.
func AddSubnetsWithTemplate ¶
func AddSubnetsWithTemplate(c *gc.C, st *state.State, numSubnets uint, infoTemplate network.SubnetInfo)
AddSubnetsWithTemplate adds numSubnets subnets, using the given infoTemplate. Any string field in the infoTemplate can be specified as a text/template string containing {{.}}, which is the current index of the subnet-to-add (between 0 and numSubnets-1).
Example:
AddSubnetsWithTemplate(c, st, 2, state.SubnetInfo{ CIDR: "10.10.{{.}}.0/24", ProviderId: "subnet-{{.}}", SpaceName: "space1", AvailabilityZone: "zone-{{.}}", VLANTag: 42, })
This is equivalent to the following calls:
_, err := st.AddSubnet(state.SubnetInfo{ CIDR: "10.10.0.0/24", ProviderId: "subnet-0", SpaceName: "space1", AvailabilityZone: "zone-0", VLANTag: 42, })
c.Assert(err, jc.ErrorIsNil)
_, err = st.AddSubnet(state.SubnetInfo{ CIDR: "10.10.1.0/24", ProviderId: "subnet-1", SpaceName: "space1", AvailabilityZone: "zone-1", VLANTag: 42, })
func AssertStartControllerInstance ¶
func AssertStartControllerInstance( c *gc.C, env environs.Environ, ctx context.ProviderCallContext, controllerUUID, machineId string, ) ( instances.Instance, *instance.HardwareCharacteristics, )
AssertStartControllerInstance is a test helper function that starts a controller instance with a plausible but invalid configuration, and checks that it succeeds.
func AssertStartInstance ¶
func AssertStartInstance( c *gc.C, env environs.Environ, ctx context.ProviderCallContext, controllerUUID, machineId string, ) ( instances.Instance, *instance.HardwareCharacteristics, )
AssertStartInstance is a test helper function that starts an instance with a plausible but invalid configuration, and checks that it succeeds.
func AssertStartInstanceWithConstraints ¶
func AssertStartInstanceWithConstraints( c *gc.C, env environs.Environ, ctx context.ProviderCallContext, controllerUUID, machineId string, cons constraints.Value, ) ( instances.Instance, *instance.HardwareCharacteristics, )
AssertStartInstanceWithConstraints is a test helper function that starts an instance with the given constraints, and a plausible but invalid configuration, and returns the result of Environ.StartInstance.
func DefaultVersions ¶
DefaultVersions returns a slice of unique 'versions' for the current environment's host architecture. Additionally, it ensures that 'versions' for amd64 are returned if that is not the current host's architecture.
func FakeAPIInfo ¶
FakeAPIInfo holds information about no state - it will always give an error when connected to. The machine id gives the machine id of the machine to be started.
func FillInStartInstanceParams ¶
func FillInStartInstanceParams(env environs.Environ, machineId string, isController bool, params *environs.StartInstanceParams) error
FillInStartInstanceParams prepares the instance parameters for starting the instance.
func PutCharm ¶
PutCharm uploads the given charm to provider storage, and adds a state.Charm to the state. The charm is not uploaded if a charm with the same URL already exists in the state.
func SetImageMetadata ¶
func SetImageMetadata(env environs.Environ, fetcher imagemetadata.SimplestreamsFetcher, release, arches []string, out *[]*imagemetadata.ImageMetadata) error
func StartInstance ¶
func StartInstance( env environs.Environ, ctx context.ProviderCallContext, controllerUUID, machineId string, ) ( instances.Instance, *instance.HardwareCharacteristics, corenetwork.InterfaceInfos, error, )
StartInstance is a test helper function that starts an instance with a plausible but invalid configuration, and returns the result of Environ.StartInstance.
func StartInstanceWithConstraints ¶
func StartInstanceWithConstraints( env environs.Environ, ctx context.ProviderCallContext, controllerUUID, machineId string, cons constraints.Value, ) ( instances.Instance, *instance.HardwareCharacteristics, corenetwork.InterfaceInfos, error, )
StartInstanceWithConstraints is a test helper function that starts an instance with the given constraints, and a plausible but invalid configuration, and returns the result of Environ.StartInstance.
func StartInstanceWithParams ¶
func StartInstanceWithParams( env environs.Environ, ctx context.ProviderCallContext, machineId string, params environs.StartInstanceParams, ) ( *environs.StartInstanceResult, error, )
StartInstanceWithParams is a test helper function that starts an instance with the given parameters, and a plausible but invalid configuration, and returns the result of Environ.StartInstance. The provided params's InstanceConfig and Tools field values will be ignored.
func WaitInstanceAddresses ¶
func WaitInstanceAddresses( env environs.Environ, ctx context.ProviderCallContext, instId instance.Id, ) (corenetwork.ProviderAddresses, error)
WaitInstanceAddresses waits until the specified instance has addresses, and returns them.
Types ¶
type JujuConnSuite ¶
type JujuConnSuite struct { // ConfigAttrs can be set up before SetUpTest // is invoked. Any attributes set here will be // added to the suite's environment configuration. ConfigAttrs map[string]interface{} // ControllerConfigAttrs can be set up before SetUpTest // is invoked. Any attributes set here will be added to // the suite's controller configuration. ControllerConfigAttrs map[string]interface{} // TODO: JujuConnSuite should not be concerned both with JUJU_DATA and with // /var/lib/juju: the use cases are completely non-overlapping, and any tests that // really do need both to exist ought to be embedding distinct fixtures for the // distinct environments. mgotesting.MgoSuite testing.FakeJujuXDGDataHomeSuite envtesting.ToolsFixture InitialLoggingConfig string DefaultToolsStorageDir string DefaultToolsStorage storage.Storage ControllerConfig controller.Config State *state.State StatePool *state.StatePool Model *state.Model Environ environs.Environ APIState api.Connection ControllerStore jujuclient.ClientStore BackingState *state.State // The State being used by the API server. Hub *pubsub.StructuredHub // The central hub being used by the API server. Controller *cache.Controller // The cache.Controller used by the API server. LeaseManager lease.Manager // The lease manager being used by the API server. RootDir string // The faked-up root directory. LogDir string DummyConfig testing.Attrs Factory *factory.Factory ProviderCallContext envcontext.ProviderCallContext // contains filtered or unexported fields }
JujuConnSuite provides a freshly bootstrapped juju.Conn for each test. It also includes testing.BaseSuite.
It also sets up RootDir to point to a directory hierarchy mirroring the intended juju directory structure, including the following:
RootDir/var/lib/juju An empty directory returned as DataDir - the root of the juju data storage space.
$HOME is set to point to RootDir/home/ubuntu.
func (*JujuConnSuite) AddDefaultToolsToState ¶
func (s *JujuConnSuite) AddDefaultToolsToState(c *gc.C)
AddDefaultToolsToState adds tools to tools storage for default juju series and architectures.
func (*JujuConnSuite) AddTestingApplication ¶
func (s *JujuConnSuite) AddTestingApplication(c *gc.C, name string, ch *state.Charm) *state.Application
func (*JujuConnSuite) AddTestingApplicationWithArch ¶
func (s *JujuConnSuite) AddTestingApplicationWithArch(c *gc.C, name string, ch *state.Charm, arch string) *state.Application
func (*JujuConnSuite) AddTestingApplicationWithBindings ¶
func (s *JujuConnSuite) AddTestingApplicationWithBindings(c *gc.C, name string, ch *state.Charm, bindings map[string]string) *state.Application
func (*JujuConnSuite) AddTestingApplicationWithOrigin ¶
func (s *JujuConnSuite) AddTestingApplicationWithOrigin(c *gc.C, name string, ch *state.Charm, origin *state.CharmOrigin) *state.Application
func (*JujuConnSuite) AddTestingApplicationWithStorage ¶
func (s *JujuConnSuite) AddTestingApplicationWithStorage(c *gc.C, name string, ch *state.Charm, storage map[string]state.StorageConstraints) *state.Application
func (*JujuConnSuite) AddTestingCharm ¶
func (*JujuConnSuite) AddTestingCharmForSeries ¶
func (*JujuConnSuite) AddToolsToState ¶
func (s *JujuConnSuite) AddToolsToState(c *gc.C, versions ...version.Binary)
AddToolsToState adds tools to tools storage.
func (*JujuConnSuite) AdminUserTag ¶
func (s *JujuConnSuite) AdminUserTag(c *gc.C) names.UserTag
func (*JujuConnSuite) AgentConfigForTag ¶
func (s *JujuConnSuite) AgentConfigForTag(c *gc.C, tag names.Tag) agent.ConfigSetterWriter
func (*JujuConnSuite) AssertConfigParameterUpdated ¶
func (s *JujuConnSuite) AssertConfigParameterUpdated(c *gc.C, key string, value interface{})
AssertConfigParameterUpdated updates environment parameter and asserts that no errors were encountered
func (*JujuConnSuite) ConfDir ¶
func (s *JujuConnSuite) ConfDir() string
func (*JujuConnSuite) CreateUserHome ¶
func (s *JujuConnSuite) CreateUserHome(c *gc.C, params *UserHomeParams)
CreateUserHome creates a home directory and Juju data home for user username. This is used by setUpConn to create the 'ubuntu' user home, after RootDir, and may be used again later for other users.
func (*JujuConnSuite) DataDir ¶
func (s *JujuConnSuite) DataDir() string
func (*JujuConnSuite) EnsureCachedModel ¶
func (s *JujuConnSuite) EnsureCachedModel(c *gc.C, uuid string)
EnsureCachedModel is used to ensure that the model specified is in the model cache. This is used when tests create models and then want to do things with those models where the actions may touch the model cache.
func (*JujuConnSuite) MongoInfo ¶
func (s *JujuConnSuite) MongoInfo() *mongo.MongoInfo
func (*JujuConnSuite) OpenAPIAs ¶
func (s *JujuConnSuite) OpenAPIAs(c *gc.C, tag names.Tag, password string) api.Connection
OpenAPIAs opens the API using the given identity tag and password for authentication. The returned api.Connection should not be closed by the caller as a cleanup function has been registered to do that.
func (*JujuConnSuite) OpenAPIAsMachine ¶
func (s *JujuConnSuite) OpenAPIAsMachine(c *gc.C, tag names.Tag, password, nonce string) api.Connection
OpenAPIAsMachine opens the API using the given machine tag, password and nonce for authentication. The returned api.Connection should not be closed by the caller as a cleanup function has been registered to do that.
func (*JujuConnSuite) OpenAPIAsNewMachine ¶
func (s *JujuConnSuite) OpenAPIAsNewMachine(c *gc.C, jobs ...state.MachineJob) (api.Connection, *state.Machine)
OpenAPIAsNewMachine creates a new machine entry that lives in system state, and then uses that to open the API. The returned api.Connection should not be closed by the caller as a cleanup function has been registered to do that. The machine will run the supplied jobs; if none are given, JobHostUnits is assumed.
func (*JujuConnSuite) OpenControllerAPI ¶
func (s *JujuConnSuite) OpenControllerAPI(c *gc.C) api.Connection
func (*JujuConnSuite) OpenControllerAPIAs ¶
func (s *JujuConnSuite) OpenControllerAPIAs(c *gc.C, tag names.Tag, password string) api.Connection
func (*JujuConnSuite) Reset ¶
func (s *JujuConnSuite) Reset(c *gc.C)
Reset returns environment state to that which existed at the start of the test.
func (*JujuConnSuite) SetUpSuite ¶
func (s *JujuConnSuite) SetUpSuite(c *gc.C)
func (*JujuConnSuite) SetUpTest ¶
func (s *JujuConnSuite) SetUpTest(c *gc.C)
func (*JujuConnSuite) TearDownSuite ¶
func (s *JujuConnSuite) TearDownSuite(c *gc.C)
func (*JujuConnSuite) TearDownTest ¶
func (s *JujuConnSuite) TearDownTest(c *gc.C)
func (*JujuConnSuite) TransientDataDir ¶
func (s *JujuConnSuite) TransientDataDir() string
func (*JujuConnSuite) WaitForModelWatchersIdle ¶
func (s *JujuConnSuite) WaitForModelWatchersIdle(c *gc.C, modelUUID string)
func (*JujuConnSuite) WaitForNextSync ¶
func (s *JujuConnSuite) WaitForNextSync(c *gc.C)
type RepoSuite ¶
type RepoSuite struct {
JujuConnSuite
}
func (*RepoSuite) AssertApplication ¶
func (*RepoSuite) AssertCharmUploaded ¶
func (*RepoSuite) AssertUnitMachines ¶
type UserHomeParams ¶
type UserHomeParams struct { // The username of the operating system user whose fake home // directory is to be created. Username string // Override the default osenv.JujuModelEnvKey. ModelEnvKey string // Should the oldJujuXDGDataHome field be set? // This is likely only true during setUpConn, as we want teardown to // reset to the most original value. SetOldHome bool }
UserHomeParams stores parameters with which to create an os user home dir.