~wwitzel3/juju-core/009-ha-rsyslog-api

« back to all changes in this revision

Viewing changes to provider/openstack/local_test.go

  • Committer: Wayne Witzel III
  • Date: 2014-05-22 13:23:37 UTC
  • mfrom: (2743.1.10 ha-rsyslog-api)
  • Revision ID: wayne.witzel@canonical.com-20140522132337-m9py79a81mjdm9su
merge mfoord

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        envtesting "launchpad.net/juju-core/environs/testing"
33
33
        "launchpad.net/juju-core/environs/tools"
34
34
        "launchpad.net/juju-core/instance"
 
35
        "launchpad.net/juju-core/juju/arch"
35
36
        "launchpad.net/juju-core/juju/testing"
36
37
        "launchpad.net/juju-core/provider/openstack"
37
38
        coretesting "launchpad.net/juju-core/testing"
38
 
        "launchpad.net/juju-core/testing/testbase"
39
39
        "launchpad.net/juju-core/version"
40
40
)
41
41
 
118
118
 
119
119
// localLiveSuite runs tests from LiveTests using an Openstack service double.
120
120
type localLiveSuite struct {
121
 
        testbase.LoggingSuite
 
121
        coretesting.BaseSuite
122
122
        LiveTests
123
123
        srv localServer
124
124
}
125
125
 
126
126
func (s *localLiveSuite) SetUpSuite(c *gc.C) {
127
 
        s.LoggingSuite.SetUpSuite(c)
 
127
        s.BaseSuite.SetUpSuite(c)
128
128
        c.Logf("Running live tests using openstack service test double")
129
129
        s.srv.start(c, s.cred)
130
130
        s.LiveTests.SetUpSuite(c)
137
137
        openstack.RemoveTestImageData(openstack.ImageMetadataStorage(s.Env))
138
138
        s.LiveTests.TearDownSuite(c)
139
139
        s.srv.stop()
140
 
        s.LoggingSuite.TearDownSuite(c)
 
140
        s.BaseSuite.TearDownSuite(c)
141
141
}
142
142
 
143
143
func (s *localLiveSuite) SetUpTest(c *gc.C) {
144
 
        s.LoggingSuite.SetUpTest(c)
 
144
        s.BaseSuite.SetUpTest(c)
145
145
        s.LiveTests.SetUpTest(c)
146
146
        s.PatchValue(&imagemetadata.DefaultBaseURL, "")
147
147
}
148
148
 
149
149
func (s *localLiveSuite) TearDownTest(c *gc.C) {
150
150
        s.LiveTests.TearDownTest(c)
151
 
        s.LoggingSuite.TearDownTest(c)
 
151
        s.BaseSuite.TearDownTest(c)
152
152
}
153
153
 
154
154
// localServerSuite contains tests that run against an Openstack service double.
156
156
// to test on a live Openstack server. The service double is started and stopped for
157
157
// each test.
158
158
type localServerSuite struct {
159
 
        testbase.LoggingSuite
 
159
        coretesting.BaseSuite
160
160
        jujutest.Tests
161
161
        cred                 *identity.Credentials
162
162
        srv                  localServer
165
165
}
166
166
 
167
167
func (s *localServerSuite) SetUpSuite(c *gc.C) {
168
 
        s.LoggingSuite.SetUpSuite(c)
169
 
        s.Tests.SetUpSuite(c)
 
168
        s.BaseSuite.SetUpSuite(c)
170
169
        restoreFinishBootstrap := envtesting.DisableFinishBootstrap()
171
170
        s.AddSuiteCleanup(func(*gc.C) { restoreFinishBootstrap() })
172
171
        c.Logf("Running local tests")
173
172
}
174
173
 
175
 
func (s *localServerSuite) TearDownSuite(c *gc.C) {
176
 
        s.Tests.TearDownSuite(c)
177
 
        s.LoggingSuite.TearDownSuite(c)
178
 
}
179
 
 
180
174
func (s *localServerSuite) SetUpTest(c *gc.C) {
181
 
        s.LoggingSuite.SetUpTest(c)
 
175
        s.BaseSuite.SetUpTest(c)
182
176
        s.srv.start(c, s.cred)
183
177
        cl := client.NewClient(s.cred, identity.AuthUserPass, nil)
184
178
        err := cl.Authenticate()
211
205
        }
212
206
        s.Tests.TearDownTest(c)
213
207
        s.srv.stop()
214
 
        s.LoggingSuite.TearDownTest(c)
 
208
        s.BaseSuite.TearDownTest(c)
215
209
}
216
210
 
217
211
// If the bootstrap node is configured to require a public IP address,
269
263
}
270
264
 
271
265
func (s *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) {
 
266
        // Ensure amd64 tools are available, to ensure an amd64 image.
 
267
        amd64Version := version.Current
 
268
        amd64Version.Arch = arch.AMD64
 
269
        for _, series := range bootstrap.ToolsLtsSeries {
 
270
                amd64Version.Series = series
 
271
                envtesting.AssertUploadFakeToolsVersions(c, s.toolsMetadataStorage, amd64Version)
 
272
        }
 
273
 
272
274
        env := s.Prepare(c)
273
275
        err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{})
274
276
        c.Assert(err, gc.IsNil)
656
658
        env := s.Open(c)
657
659
        a, err := env.SupportedArchitectures()
658
660
        c.Assert(err, gc.IsNil)
659
 
        c.Assert(a, gc.DeepEquals, []string{"amd64", "ppc64"})
 
661
        c.Assert(a, gc.DeepEquals, []string{"amd64", "i386", "ppc64"})
660
662
}
661
663
 
662
664
func (s *localServerSuite) TestSupportNetworks(c *gc.C) {
666
668
 
667
669
func (s *localServerSuite) TestFindImageBadDefaultImage(c *gc.C) {
668
670
        // Prevent falling over to the public datasource.
669
 
        s.PatchValue(&imagemetadata.DefaultBaseURL, "")
 
671
        s.BaseSuite.PatchValue(&imagemetadata.DefaultBaseURL, "")
670
672
 
671
673
        env := s.Open(c)
672
674
 
689
691
        env := s.Open(c)
690
692
        validator, err := env.ConstraintsValidator()
691
693
        c.Assert(err, gc.IsNil)
692
 
        cons := constraints.MustParse("arch=i386")
 
694
        cons := constraints.MustParse("arch=arm64")
693
695
        _, err = validator.Validate(cons)
694
 
        c.Assert(err, gc.ErrorMatches, "invalid constraint value: arch=i386\nvalid values are:.*")
 
696
        c.Assert(err, gc.ErrorMatches, "invalid constraint value: arch=arm64\nvalid values are:.*")
695
697
        cons = constraints.MustParse("instance-type=foo")
696
698
        _, err = validator.Validate(cons)
697
699
        c.Assert(err, gc.ErrorMatches, "invalid constraint value: instance-type=foo\nvalid values are:.*")
710
712
 
711
713
func (s *localServerSuite) TestFindImageInstanceConstraint(c *gc.C) {
712
714
        // Prevent falling over to the public datasource.
713
 
        s.PatchValue(&imagemetadata.DefaultBaseURL, "")
 
715
        s.BaseSuite.PatchValue(&imagemetadata.DefaultBaseURL, "")
714
716
 
715
717
        env := s.Open(c)
716
718
        spec, err := openstack.FindInstanceSpec(env, "precise", "amd64", "instance-type=m1.tiny")
720
722
 
721
723
func (s *localServerSuite) TestFindImageInvalidInstanceConstraint(c *gc.C) {
722
724
        // Prevent falling over to the public datasource.
723
 
        s.PatchValue(&imagemetadata.DefaultBaseURL, "")
 
725
        s.BaseSuite.PatchValue(&imagemetadata.DefaultBaseURL, "")
724
726
 
725
727
        env := s.Open(c)
726
728
        _, err := openstack.FindInstanceSpec(env, "precise", "amd64", "instance-type=m1.large")
845
847
// things that depend on the HTTPS connection, all other functional tests on a
846
848
// local connection should be in localServerSuite
847
849
type localHTTPSServerSuite struct {
848
 
        testbase.LoggingSuite
 
850
        coretesting.BaseSuite
849
851
        attrs map[string]interface{}
850
852
        cred  *identity.Credentials
851
853
        srv   localServer
875
877
}
876
878
 
877
879
func (s *localHTTPSServerSuite) SetUpTest(c *gc.C) {
878
 
        s.LoggingSuite.SetUpTest(c)
 
880
        s.BaseSuite.SetUpTest(c)
879
881
        s.srv.UseTLS = true
880
882
        cred := &identity.Credentials{
881
883
                User:       "fred",
902
904
                s.env = nil
903
905
        }
904
906
        s.srv.stop()
905
 
        s.LoggingSuite.TearDownTest(c)
 
907
        s.BaseSuite.TearDownTest(c)
906
908
}
907
909
 
908
910
func (s *localHTTPSServerSuite) TestCanUploadTools(c *gc.C) {