jujutest

package
v0.0.0-...-9d6b0cf Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2013 License: AGPL-3.0, AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CannedRoundTripper

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

CannedRoundTripper can be used to provide canned "http" responses without actually starting an HTTP server.

Use this in conjunction with ProxyRoundTripper. A ProxyRoundTripper is what gets registered as the default handler for a given protocol (such as "test") and then tests can direct the ProxyRoundTripper to delegate to a CannedRoundTripper. The reason for this is that we can register a roundtripper to handle a scheme, but there is no way to unregister it: you may need to re-use the same ProxyRoundTripper but use different CannedRoundTrippers to return different results.

func NewCannedRoundTripper

func NewCannedRoundTripper(files map[string]string, errorURLs map[string]int) *CannedRoundTripper

NewCannedRoundTripper returns a CannedRoundTripper with the given canned responses.

func (*CannedRoundTripper) RoundTrip

func (v *CannedRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip returns a canned error or body for the given request.

type LiveTests

type LiveTests struct {
	coretesting.LoggingSuite

	// TestConfig contains the configuration attributes for opening an environment.
	TestConfig TestConfig

	// Env holds the currently opened environment.
	Env environs.Environ

	// Attempt holds a strategy for waiting until the environment
	// becomes logically consistent.
	Attempt utils.AttemptStrategy

	// CanOpenState should be true if the testing environment allows
	// the state to be opened after bootstrapping.
	CanOpenState bool

	// HasProvisioner should be true if the environment has
	// a provisioning agent.
	HasProvisioner bool
	// contains filtered or unexported fields
}

LiveTests contains tests that are designed to run against a live server (e.g. Amazon EC2). The Environ is opened once only for all the tests in the suite, stored in Env, and Destroyed after the suite has completed.

func (*LiveTests) BootstrapOnce

func (t *LiveTests) BootstrapOnce(c *C)

func (*LiveTests) Destroy

func (t *LiveTests) Destroy(c *C)

func (*LiveTests) SetUpSuite

func (t *LiveTests) SetUpSuite(c *C)

func (*LiveTests) TearDownSuite

func (t *LiveTests) TearDownSuite(c *C)

func (*LiveTests) TestBootstrapAndDeploy

func (t *LiveTests) TestBootstrapAndDeploy(c *C)

func (*LiveTests) TestBootstrapMultiple

func (t *LiveTests) TestBootstrapMultiple(c *C)

func (*LiveTests) TestBootstrapVerifyStorage

func (t *LiveTests) TestBootstrapVerifyStorage(c *C)

func (*LiveTests) TestBootstrapWithDefaultSeries

func (t *LiveTests) TestBootstrapWithDefaultSeries(c *C)

func (*LiveTests) TestCheckEnvironmentOnConnect

func (t *LiveTests) TestCheckEnvironmentOnConnect(c *C)

func (*LiveTests) TestCheckEnvironmentOnConnectBadVerificationFile

func (t *LiveTests) TestCheckEnvironmentOnConnectBadVerificationFile(c *C)

func (*LiveTests) TestCheckEnvironmentOnConnectNoVerificationFile

func (t *LiveTests) TestCheckEnvironmentOnConnectNoVerificationFile(c *C)

func (*LiveTests) TestFile

func (t *LiveTests) TestFile(c *C)

func (*LiveTests) TestGlobalPorts

func (t *LiveTests) TestGlobalPorts(c *C)

func (*LiveTests) TestPorts

func (t *LiveTests) TestPorts(c *C)

func (*LiveTests) TestStartInstanceOnUnknownPlatform

func (t *LiveTests) TestStartInstanceOnUnknownPlatform(c *C)

Check that we can't start an instance running tools that correspond with no available platform. The first thing start instance should do is find appropriate tools.

func (*LiveTests) TestStartInstanceWithEmptyNonceFails

func (t *LiveTests) TestStartInstanceWithEmptyNonceFails(c *C)

Check that we can't start an instance with an empty nonce value.

func (*LiveTests) TestStartStop

func (t *LiveTests) TestStartStop(c *C)

TestStartStop is similar to Tests.TestStartStop except that it does not assume a pristine environment.

type ProxyRoundTripper

type ProxyRoundTripper struct {
	// Sub is the roundtripper that this roundtripper delegates to, if any.
	// If you leave this nil, this roundtripper is effectively disabled.
	Sub http.RoundTripper
}

ProxyRoundTripper is an http.RoundTripper implementation that does nothing but delegate to another RoundTripper. This lets tests change how they handle requests for a given scheme, despite the fact that the standard library does not support un-registration, or registration of a new roundtripper with a URL scheme that's already handled.

Use the RegisterForScheme method to install this as the standard handler for a particular protocol. For example, if you call prt.RegisterForScheme("test") then afterwards, any request to "test:///foo" will be routed to prt.

func (*ProxyRoundTripper) RegisterForScheme

func (prt *ProxyRoundTripper) RegisterForScheme(scheme string)

RegisterForScheme registers a ProxyRoundTripper as the default roundtripper for the given URL scheme.

This cannot be undone, nor overwritten with a different roundtripper. If you change your mind later about what the roundtripper should do, set its "Sub" field to delegate to a different roundtripper (or to nil if you don't want to handle its requests at all any more).

func (*ProxyRoundTripper) RoundTrip

func (prt *ProxyRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type TestConfig

type TestConfig struct {
	Config map[string]interface{}
}

TestConfig contains the configuration for the environment This is a is an indirection to make it harder for tests to accidentally share the underlying map.

func (*TestConfig) UpdateConfig

func (testConfig *TestConfig) UpdateConfig(update map[string]interface{})

UpdateConfig modifies the configuration safely by creating a new map

type Tests

type Tests struct {
	coretesting.LoggingSuite
	TestConfig TestConfig
	Env        environs.Environ
}

Tests is a gocheck suite containing tests verifying juju functionality against the environment with the given configuration. The tests are not designed to be run against a live server - the Environ is opened once for each test, and some potentially expensive operations may be executed.

func (*Tests) Open

func (t *Tests) Open(c *C) environs.Environ

Open opens an instance of the testing environment.

func (*Tests) SetUpTest

func (t *Tests) SetUpTest(c *C)

func (*Tests) TearDownTest

func (t *Tests) TearDownTest(c *C)

func (*Tests) TestBootstrap

func (t *Tests) TestBootstrap(c *C)

func (*Tests) TestPersistence

func (t *Tests) TestPersistence(c *C)

func (*Tests) TestStartStop

func (t *Tests) TestStartStop(c *C)

Notes

Bugs

  • Logic below is very much wrong. Must be:

    1. EnsureDying on the unit and EnsureDying on the machine 2. Unit dies by itself 3. Machine removes dead unit 4. Machine dies by itself 5. Provisioner removes dead machine

Jump to

Keyboard shortcuts

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