dummy

package
v0.0.0-...-f19ae85 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2015 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

The dummy provider implements an environment provider for testing purposes, registered with environs under the name "dummy".

The configuration YAML for the testing environment must specify a "state-server" property with a boolean value. If this is true, a state server will be started when the environment is bootstrapped.

The configuration data also accepts a "broken" property of type boolean. If this is non-empty, any operation after the environment has been opened will return the error "broken environment", and will also log that.

The DNS name of instances is the same as the Id, with ".dns" appended.

To avoid enumerating all possible series and architectures, any series or architecture with the prefix "unknown" is treated as bad when starting a new instance.

Index

Constants

View Source
const (
	BootstrapInstanceId = instance.Id("localhost")
)

Variables

View Source
var (
	ErrNotPrepared = errors.New("environment is not prepared")
	ErrDestroyed   = errors.New("environment has been destroyed")
)
View Source
var DataDir = ""

Override for testing - the data directory with which the state api server is initialised.

View Source
var LogDir = ""

Functions

func AdminUserTag

func AdminUserTag() names.UserTag

AdminUserTag returns the user tag used to bootstrap the dummy environment. The dummy bootstrapping is handled slightly differently, and the user is created as part of the bootstrap process. This method is used to provide tests a way to get to the user name that was used to initialise the database, and as such, is the owner of the initial environment.

func IsSameStorage

func IsSameStorage(s1, s2 storage.Storage) bool

IsSameStorage returns whether the storage instances are the same. Both storages must have been created through the dummy provider.

func Listen

func Listen(c chan<- Operation)

Listen closes the previously registered listener (if any). Subsequent operations on any dummy environment can be received on c (if not nil).

func PatchTransientErrorInjectionChannel

func PatchTransientErrorInjectionChannel(c chan error) func()

PatchTransientErrorInjectionChannel sets the transientInjectionError channel which can be used to inject errors into StartInstance for testing purposes The injected errors will use the string received on the channel and the instance's state will eventually go to error, while the received string will appear in the info field of the machine's status

func Poison

func Poison(ss storage.Storage, path string, poisonErr error)

Poison causes all fetches of the given path to return the given error.

func Reset

func Reset()

Reset resets the entire dummy environment and forgets any registered operation listener. All opened environments after Reset will share the same underlying state.

func SampleConfig

func SampleConfig() testing.Attrs

SampleConfig() returns an environment configuration with all required attributes set.

func SetInstanceAddresses

func SetInstanceAddresses(inst instance.Instance, addrs []network.Address)

SetInstanceAddresses sets the addresses associated with the given dummy instance.

func SetInstanceStatus

func SetInstanceStatus(inst instance.Instance, status string)

SetInstanceStatus sets the status associated with the given dummy instance.

func SetStatePolicy

func SetStatePolicy(policy state.Policy)

SetStatePolicy sets the state.Policy to use when a state server is initialised by dummy.

func SetStorageDelay

func SetStorageDelay(d time.Duration)

SetStorageDelay causes any storage download operation in any current environment to be delayed for the given duration.

Types

type OpAllocateAddress

type OpAllocateAddress struct {
	Env        string
	InstanceId instance.Id
	SubnetId   network.Id
	Address    network.Address
}

type OpBootstrap

type OpBootstrap struct {
	Context environs.BootstrapContext
	Env     string
	Args    environs.BootstrapParams
}

type OpClosePorts

type OpClosePorts struct {
	Env        string
	MachineId  string
	InstanceId instance.Id
	Ports      []network.PortRange
}

type OpDestroy

type OpDestroy struct {
	Env   string
	Error error
}

type OpFinalizeBootstrap

type OpFinalizeBootstrap struct {
	Context       environs.BootstrapContext
	Env           string
	MachineConfig *cloudinit.MachineConfig
}

type OpListNetworks

type OpListNetworks struct {
	Env  string
	Info []network.SubnetInfo
}

TODO(dimitern) Rename this to OpSubnets and add InstanceId field.

type OpNetworkInterfaces

type OpNetworkInterfaces struct {
	Env        string
	InstanceId instance.Id
	Info       []network.InterfaceInfo
}

type OpOpenPorts

type OpOpenPorts struct {
	Env        string
	MachineId  string
	InstanceId instance.Id
	Ports      []network.PortRange
}

type OpPutFile

type OpPutFile struct {
	Env      string
	FileName string
}

type OpReleaseAddress

type OpReleaseAddress struct {
	Env        string
	InstanceId instance.Id
	SubnetId   network.Id
	Address    network.Address
}

type OpStartInstance

type OpStartInstance struct {
	Env              string
	MachineId        string
	MachineNonce     string
	PossibleTools    coretools.List
	Instance         instance.Instance
	Constraints      constraints.Value
	Networks         []string
	NetworkInfo      []network.InterfaceInfo
	Info             *mongo.MongoInfo
	Jobs             []multiwatcher.MachineJob
	APIInfo          *api.Info
	Secret           string
	AgentEnvironment map[string]string
}

type OpStopInstances

type OpStopInstances struct {
	Env string
	Ids []instance.Id
}

type Operation

type Operation interface{}

Operation represents an action on the dummy provider.

Jump to

Keyboard shortcuts

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