testing

package
Version: 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: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	V100    = version.MustParse("1.0.0")
	V100p64 = version.MustParseBinary("1.0.0-precise-amd64")
	V100p32 = version.MustParseBinary("1.0.0-precise-i386")
	V100p   = []version.Binary{V100p64, V100p32}

	V100q64 = version.MustParseBinary("1.0.0-quantal-amd64")
	V100q32 = version.MustParseBinary("1.0.0-quantal-i386")
	V100q   = []version.Binary{V100q64, V100q32}
	V100all = append(V100p, V100q...)

	V1001    = version.MustParse("1.0.0.1")
	V1001p64 = version.MustParseBinary("1.0.0.1-precise-amd64")
	V100Xall = append(V100all, V1001p64)

	V110    = version.MustParse("1.1.0")
	V110p64 = version.MustParseBinary("1.1.0-precise-amd64")
	V110p32 = version.MustParseBinary("1.1.0-precise-i386")
	V110p   = []version.Binary{V110p64, V110p32}

	V110q64 = version.MustParseBinary("1.1.0-quantal-amd64")
	V110q32 = version.MustParseBinary("1.1.0-quantal-i386")
	V110q   = []version.Binary{V110q64, V110q32}
	V110all = append(V110p, V110q...)

	V1101p64 = version.MustParseBinary("1.1.0.1-precise-amd64")
	V110Xall = append(V110all, V1101p64)

	V120    = version.MustParse("1.2.0")
	V120p64 = version.MustParseBinary("1.2.0-precise-amd64")
	V120p32 = version.MustParseBinary("1.2.0-precise-i386")
	V120p   = []version.Binary{V120p64, V120p32}

	V120q64 = version.MustParseBinary("1.2.0-quantal-amd64")
	V120q32 = version.MustParseBinary("1.2.0-quantal-i386")
	V120q   = []version.Binary{V120q64, V120q32}

	V120t64 = version.MustParseBinary("1.2.0-trusty-amd64")
	V120t32 = version.MustParseBinary("1.2.0-trusty-i386")
	V120t   = []version.Binary{V120t64, V120t32}

	V120all = append(append(V120p, V120q...), V120t...)
	V1all   = append(V100Xall, append(V110all, V120all...)...)

	V220    = version.MustParse("2.2.0")
	V220p32 = version.MustParseBinary("2.2.0-precise-i386")
	V220p64 = version.MustParseBinary("2.2.0-precise-amd64")
	V220q32 = version.MustParseBinary("2.2.0-quantal-i386")
	V220q64 = version.MustParseBinary("2.2.0-quantal-amd64")
	V220all = []version.Binary{V220p64, V220p32, V220q64, V220q32}
	VAll    = append(V1all, V220all...)

	V31d0qppc64  = version.MustParseBinary("3.1-dev0-quantal-ppc64el")
	V31d01qppc64 = version.MustParseBinary("3.1-dev0.1-quantal-ppc64el")
)
View Source
var BootstrapToolsTests = []BootstrapToolsTest{
	{
		Info:          "no tools at all",
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: use newest compatible release version",
		Available:     VAll,
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Expect:        V100p,
	}, {
		Info:          "released cli: cli Arch ignored",
		Available:     VAll,
		CliVersion:    V100p32,
		DefaultSeries: "precise",
		Expect:        V100p,
	}, {
		Info:          "released cli: cli series ignored",
		Available:     VAll,
		CliVersion:    V100q64,
		DefaultSeries: "precise",
		Expect:        V100p,
	}, {
		Info:          "released cli: series taken from default-series",
		Available:     V120all,
		CliVersion:    V120p64,
		DefaultSeries: "quantal",
		Expect:        V120q,
	}, {
		Info:          "released cli: ignore close dev match",
		Available:     V100Xall,
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Expect:        V100p,
	}, {
		Info:          "released cli: filter by arch constraints",
		Available:     V120all,
		CliVersion:    V120p64,
		DefaultSeries: "precise",
		Arch:          "i386",
		Expect:        []version.Binary{V120p32},
	}, {
		Info:          "released cli: specific released version",
		Available:     VAll,
		CliVersion:    V100p64,
		AgentVersion:  V100,
		DefaultSeries: "precise",
		Expect:        V100p,
	}, {
		Info:          "released cli: specific dev version",
		Available:     VAll,
		CliVersion:    V110p64,
		AgentVersion:  V110,
		DefaultSeries: "precise",
		Expect:        V110p,
	}, {
		Info:          "released cli: major upgrades bad",
		Available:     V220all,
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: minor upgrades bad",
		Available:     V120all,
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: major downgrades bad",
		Available:     V100Xall,
		CliVersion:    V220p64,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: minor downgrades bad",
		Available:     V100Xall,
		CliVersion:    V120p64,
		DefaultSeries: "quantal",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: no matching series",
		Available:     VAll,
		CliVersion:    V100p64,
		DefaultSeries: "raring",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: no matching arches",
		Available:     VAll,
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Arch:          "armhf",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: specific bad major 1",
		Available:     VAll,
		CliVersion:    V220p64,
		AgentVersion:  V120,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: specific bad major 2",
		Available:     VAll,
		CliVersion:    V120p64,
		AgentVersion:  V220,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: ignore dev tools 1",
		Available:     V110all,
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: ignore dev tools 2",
		Available:     V110all,
		CliVersion:    V120p64,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli: ignore dev tools 3",
		Available:     []version.Binary{V1001p64},
		CliVersion:    V100p64,
		DefaultSeries: "precise",
		Err:           noToolsMessage,
	}, {
		Info:          "released cli with dev setting respects agent-version",
		Available:     VAll,
		CliVersion:    V100q32,
		AgentVersion:  V1001,
		DefaultSeries: "precise",
		Development:   true,
		Expect:        []version.Binary{V1001p64},
	}, {
		Info:          "dev cli respects agent-version",
		Available:     VAll,
		CliVersion:    V100q32,
		AgentVersion:  V1001,
		DefaultSeries: "precise",
		Expect:        []version.Binary{V1001p64},
	}, {
		Info:          "released cli with dev setting respects agent-version",
		Available:     V1all,
		CliVersion:    V100q32,
		AgentVersion:  V1001,
		DefaultSeries: "precise",
		Development:   true,
		Expect:        []version.Binary{V1001p64},
	}, {
		Info:          "dev cli respects agent-version",
		Available:     V1all,
		CliVersion:    V100q32,
		AgentVersion:  V1001,
		DefaultSeries: "precise",
		Expect:        []version.Binary{V1001p64},
	}}

Functions

func AssertUploadFakeToolsVersions

func AssertUploadFakeToolsVersions(c *gc.C, stor storage.Storage, toolsDir, stream string, versions ...version.Binary) []*coretools.Tools

AssertUploadFakeToolsVersions puts fake tools in the supplied storage for the supplied versions.

func BootstrapContext

func BootstrapContext(c *gc.C) environs.BootstrapContext

BootstrapContext creates a simple bootstrap execution context.

func CheckTools

func CheckTools(c *gc.C, obtained, expected *coretools.Tools)

CheckTools ensures the obtained and expected tools are equal, allowing for the fact that the obtained tools may not have size and checksum set.

func CheckUpgraderReadyError

func CheckUpgraderReadyError(c *gc.C, obtained error, expected *upgrader.UpgradeReadyError)

CheckUpgraderReadyError ensures the obtained and expected errors are equal.

func CreateLocalTestStorage

func CreateLocalTestStorage(c *gc.C) (closer io.Closer, stor storage.Storage, dataDir string)

CreateLocalTestStorage returns the listener, which needs to be closed, and the storage that is backed by a directory created in the running test's temp directory.

func DisableFinishBootstrap

func DisableFinishBootstrap() func()

DisableFinishBootstrap disables common.FinishBootstrap so that tests do not attempt to SSH to non-existent machines. The result is a function that restores finishBootstrap.

func InstallFakeDownloadedTools

func InstallFakeDownloadedTools(c *gc.C, dataDir string, vers version.Binary) *coretools.Tools

InstallFakeDownloadedTools creates and unpacks fake tools of the given version into the data directory specified.

func MustUploadFakeTools

func MustUploadFakeTools(stor storage.Storage, toolsDir, stream string)

MustUploadFakeTools acts as UploadFakeTools, but panics on failure.

func MustUploadFakeToolsVersions

func MustUploadFakeToolsVersions(stor storage.Storage, stream string, versions ...version.Binary) []*coretools.Tools

MustUploadFakeToolsVersions acts as UploadFakeToolsVersions, but panics on failure.

func PatchAttemptStrategies

func PatchAttemptStrategies(strategies ...*utils.AttemptStrategy) func()

PatchAttemptStrategies patches environs' global polling strategy, plus any otther AttemptStrategy objects whose addresses you pass, to very short polling and timeout times so that tests can run fast. It returns a cleanup function that restores the original settings. You must call this afterwards.

func PrimeTools

func PrimeTools(c *gc.C, stor storage.Storage, dataDir, toolsDir string, vers version.Binary) *coretools.Tools

PrimeTools sets up the current version of the tools to vers and makes sure that they're available in the dataDir.

func RemoveFakeTools

func RemoveFakeTools(c *gc.C, stor storage.Storage, toolsDir string)

RemoveFakeTools deletes the fake tools from the supplied storage.

func RemoveFakeToolsMetadata

func RemoveFakeToolsMetadata(c *gc.C, stor storage.Storage)

RemoveFakeToolsMetadata deletes the fake simplestreams tools metadata from the supplied storage.

func RemoveTools

func RemoveTools(c *gc.C, stor storage.Storage, toolsDir string)

RemoveTools deletes all tools from the supplied storage.

func SetSSLHostnameVerification

func SetSSLHostnameVerification(c *gc.C, st *state.State, SSLHostnameVerification bool)

func UploadFakeTools

func UploadFakeTools(c *gc.C, stor storage.Storage, toolsDir, stream string)

UploadFakeTools puts fake tools into the supplied storage with a binary version matching version.Current; if version.Current's series is different to coretesting.FakeDefaultSeries, matching fake tools will be uploaded for that series. This is useful for tests that are kinda casual about specifying their environment.

func UploadFakeToolsVersions

func UploadFakeToolsVersions(stor storage.Storage, toolsDir, stream string, versions ...version.Binary) ([]*coretools.Tools, error)

UploadFakeToolsVersions puts fake tools in the supplied storage for the supplied versions.

Types

type BootstrapToolsTest

type BootstrapToolsTest struct {
	Info          string
	Available     []version.Binary
	CliVersion    version.Binary
	DefaultSeries string
	AgentVersion  version.Number
	Development   bool
	Arch          string
	Expect        []version.Binary
	Err           string
}

type ToolsFixture

type ToolsFixture struct {
	DefaultBaseURL string

	// UploadArches holds the architectures of tools to
	// upload in UploadFakeTools. If empty, it will default
	// to just arch.HostArch()
	UploadArches []string
	// contains filtered or unexported fields
}

ToolsFixture is used as a fixture to stub out the default tools URL so we don't hit the real internet during tests.

func (*ToolsFixture) SetUpTest

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

func (*ToolsFixture) TearDownTest

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

func (*ToolsFixture) UploadFakeTools

func (s *ToolsFixture) UploadFakeTools(c *gc.C, stor storage.Storage, toolsDir, stream string)

UploadFakeTools uploads fake tools of the architectures in s.UploadArches for each LTS release to the specified storage.

func (*ToolsFixture) UploadFakeToolsToDirectory

func (s *ToolsFixture) UploadFakeToolsToDirectory(c *gc.C, dir, toolsDir, stream string)

UploadFakeToolsToDirectory uploads fake tools of the architectures in s.UploadArches for each LTS release to the specified directory.

Jump to

Keyboard shortcuts

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