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 {
        	gitjujutesting.CleanupSuite
        
        	envtesting.ToolsFixture
        
        	// TestConfig contains the configuration attributes for opening an environment.
        	TestConfig coretesting.Attrs
        
        	// 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
        
        	// Env holds the currently opened environment.
        	// This is set by PrepareOnce and BootstrapOnce.
        	Env environs.Environ
        
        	// ConfigStore holds the configuration storage
        	// used when preparing the environment.
        	// This is initialized by SetUpSuite.
        	ConfigStore configstore.Storage
        	// 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 *gc.C)

          func (*LiveTests) Destroy

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

          func (*LiveTests) PrepareOnce

          func (t *LiveTests) PrepareOnce(c *gc.C)

            PrepareOnce ensures that the environment is available and prepared. It sets t.Env appropriately.

            func (*LiveTests) SetUpSuite

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

            func (*LiveTests) SetUpTest

            func (t *LiveTests) SetUpTest(c *gc.C)

            func (*LiveTests) TearDownSuite

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

            func (*LiveTests) TearDownTest

            func (t *LiveTests) TearDownTest(c *gc.C)

            func (*LiveTests) TestBootstrapAndDeploy

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

            func (*LiveTests) TestBootstrapMultiple

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

            func (*LiveTests) TestBootstrapWithDefaultSeries

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

            func (*LiveTests) TestGlobalPorts

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

            func (*LiveTests) TestPorts

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

            func (*LiveTests) TestPrechecker

            func (t *LiveTests) TestPrechecker(c *gc.C)

            func (*LiveTests) TestStartInstanceWithEmptyNonceFails

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

              Check that we get a consistent error when asking for an instance without a valid machine config.

              func (*LiveTests) TestStartStop

              func (t *LiveTests) TestStartStop(c *gc.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 Tests

                    type Tests struct {
                    	TestConfig coretesting.Attrs
                    	envtesting.ToolsFixture
                    
                    	// ConfigStore holds the configuration storage
                    	// used when preparing the environment.
                    	// This is initialized by SetUpTest.
                    	ConfigStore configstore.Storage
                    }

                      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 *gc.C) environs.Environ

                        Open opens an instance of the testing environment.

                        func (*Tests) Prepare

                        func (t *Tests) Prepare(c *gc.C) environs.Environ

                          Prepare prepares an instance of the testing environment.

                          func (*Tests) SetUpTest

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

                          func (*Tests) TearDownTest

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

                          func (*Tests) TestBootstrap

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

                          func (*Tests) TestPersistence

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

                          func (*Tests) TestStartStop

                          func (t *Tests) TestStartStop(c *gc.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