Skip to content

Commit

Permalink
Adding juju supported series to the tests
Browse files Browse the repository at this point in the history
The following introduces supported series to all the tests.
  • Loading branch information
SimonRichardson committed Aug 28, 2019
1 parent f93ce10 commit 7786fe0
Show file tree
Hide file tree
Showing 19 changed files with 186 additions and 156 deletions.
10 changes: 6 additions & 4 deletions caas/kubernetes/provider/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,9 @@ func (s *K8sBrokerSuite) TestBootstrapNoOperatorStorage(c *gc.C) {
ctx := envtesting.BootstrapContext(c)
callCtx := &context.CloudCallContext{}
bootstrapParams := environs.BootstrapParams{
ControllerConfig: testing.FakeControllerConfig(),
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
ControllerConfig: testing.FakeControllerConfig(),
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
}

_, err := s.broker.Bootstrap(ctx, callCtx, bootstrapParams)
Expand All @@ -516,8 +517,9 @@ func (s *K8sBrokerSuite) TestBootstrap(c *gc.C) {
ctx := envtesting.BootstrapContext(c)
callCtx := &context.CloudCallContext{}
bootstrapParams := environs.BootstrapParams{
ControllerConfig: testing.FakeControllerConfig(),
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
ControllerConfig: testing.FakeControllerConfig(),
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
}

sc := &k8sstorage.StorageClass{
Expand Down
10 changes: 1 addition & 9 deletions environs/jujutest/livetests.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"
"time"

"github.com/juju/collections/set"
"github.com/juju/errors"
"github.com/juju/os/series"
gitjujutesting "github.com/juju/testing"
Expand Down Expand Up @@ -179,13 +178,6 @@ func (t *LiveTests) prepareForBootstrapParams(c *gc.C) bootstrap.PrepareParams {
}
}

var (
// Ensure that we add the default supported series so that tests that
// use the default supported lts internally will always work in the
// future.
supportedJujuSeries = set.NewStrings("precise", "trusty", "quantal", "bionic", series.DefaultSupportedLTS())
)

func (t *LiveTests) bootstrapParams() bootstrap.BootstrapParams {
credential := t.Credential
if credential.AuthType() == "" {
Expand All @@ -212,7 +204,7 @@ func (t *LiveTests) bootstrapParams() bootstrap.BootstrapParams {
CloudCredentialName: "credential",
AdminSecret: AdminSecret,
CAPrivateKey: coretesting.CAKey,
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
}
}

Expand Down
11 changes: 6 additions & 5 deletions environs/jujutest/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,12 @@ func (t *Tests) TestBootstrap(c *gc.C) {
Regions: regions,
Endpoint: t.CloudEndpoint,
},
CloudRegion: t.CloudRegion,
CloudCredential: &credential,
CloudCredentialName: "credential",
AdminSecret: AdminSecret,
CAPrivateKey: coretesting.CAKey,
CloudRegion: t.CloudRegion,
CloudCredential: &credential,
CloudCredentialName: "credential",
AdminSecret: AdminSecret,
CAPrivateKey: coretesting.CAKey,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
}

e := t.Prepare(c)
Expand Down
4 changes: 1 addition & 3 deletions environs/open_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
package environs_test

import (
"github.com/juju/collections/set"
"github.com/juju/errors"
"github.com/juju/os/series"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
Expand Down Expand Up @@ -74,7 +72,7 @@ func (s *OpenSuite) TestNewDummyEnviron(c *gc.C) {
ControllerConfig: controllerCfg,
AdminSecret: "admin-secret",
CAPrivateKey: testing.CAKey,
SupportedBootstrapSeries: set.NewStrings(series.DefaultSupportedLTS()),
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
})
c.Assert(err, jc.ErrorIsNil)

Expand Down
2 changes: 1 addition & 1 deletion juju/testing/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func (s *JujuConnSuite) setUpConn(c *gc.C) {
CloudCredentialName: "cred",
AdminSecret: AdminSecret,
CAPrivateKey: testing.CAKey,
SupportedBootstrapSeries: defaultSupportedJujuSeries,
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
})
c.Assert(err, jc.ErrorIsNil)

Expand Down
23 changes: 12 additions & 11 deletions provider/azure/environ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/Azure/go-autorest/autorest/mocks"
"github.com/Azure/go-autorest/autorest/to"
"github.com/juju/clock/testclock"
"github.com/juju/collections/set"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
Expand Down Expand Up @@ -1219,10 +1218,11 @@ func (s *environSuite) TestBootstrap(c *gc.C) {
s.requests = nil
result, err := env.Bootstrap(
ctx, s.callCtx, environs.BootstrapParams{
ControllerConfig: testing.FakeControllerConfig(),
AvailableTools: makeToolsList("quantal"),
BootstrapSeries: "quantal",
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
ControllerConfig: testing.FakeControllerConfig(),
AvailableTools: makeToolsList("quantal"),
BootstrapSeries: "quantal",
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
},
)
c.Assert(err, jc.ErrorIsNil)
Expand Down Expand Up @@ -1253,10 +1253,11 @@ func (s *environSuite) TestBootstrapWithInvalidCredential(c *gc.C) {
c.Assert(s.invalidatedCredential, jc.IsFalse)
_, err := env.Bootstrap(
ctx, s.callCtx, environs.BootstrapParams{
ControllerConfig: testing.FakeControllerConfig(),
AvailableTools: makeToolsList("quantal"),
BootstrapSeries: "quantal",
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
ControllerConfig: testing.FakeControllerConfig(),
AvailableTools: makeToolsList("quantal"),
BootstrapSeries: "quantal",
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
},
)
c.Assert(err, gc.NotNil)
Expand Down Expand Up @@ -1289,7 +1290,7 @@ func (s *environSuite) TestBootstrapInstanceConstraints(c *gc.C) {
c.Assert(build, jc.IsFalse)
return &sync.BuiltAgent{Dir: c.MkDir()}, nil
},
SupportedBootstrapSeries: set.NewStrings("quantal"),
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
},
)
// If we aren't on amd64, this should correctly fail. See also:
Expand Down Expand Up @@ -1335,7 +1336,7 @@ func (s *environSuite) TestBootstrapWithAutocert(c *gc.C) {
AvailableTools: makeToolsList("quantal"),
BootstrapSeries: "quantal",
BootstrapConstraints: constraints.MustParse("mem=3.5G"),
SupportedBootstrapSeries: set.NewStrings("quantal"),
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
},
)
c.Assert(err, jc.ErrorIsNil)
Expand Down
32 changes: 12 additions & 20 deletions provider/common/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"time"

"github.com/juju/cmd/cmdtesting"
"github.com/juju/collections/set"
"github.com/juju/errors"
"github.com/juju/os/series"
"github.com/juju/testing"
Expand Down Expand Up @@ -44,13 +43,6 @@ import (
jujuversion "github.com/juju/juju/version"
)

var (
// Ensure that we add the default supported series so that tests that
// use the default supported lts internally will always work in the
// future.
supportedJujuSeries = set.NewStrings("precise", "trusty", "quantal", "bionic", series.DefaultSupportedLTS())
)

type BootstrapSuite struct {
coretesting.FakeJujuXDGDataHomeSuite
envtesting.ToolsFixture
Expand Down Expand Up @@ -164,7 +156,7 @@ func (s *BootstrapSuite) TestCannotStartInstance(c *gc.C) {
ModelConstraints: checkCons,
Placement: checkPlacement,
AvailableTools: fakeAvailableTools(),
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, gc.ErrorMatches, "cannot start bootstrap instance: meh, not started")
}
Expand Down Expand Up @@ -208,7 +200,7 @@ func (s *BootstrapSuite) TestBootstrapSeries(c *gc.C) {
ControllerConfig: coretesting.FakeControllerConfig(),
BootstrapSeries: bootstrapSeries,
AvailableTools: availableTools,
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, jc.ErrorIsNil)
c.Check(result.Arch, gc.Equals, "ppc64el") // based on hardware characteristics
Expand Down Expand Up @@ -254,7 +246,7 @@ func (s *BootstrapSuite) TestBootstrapInvalidSeries(c *gc.C) {
ControllerConfig: coretesting.FakeControllerConfig(),
BootstrapSeries: bootstrapSeries,
AvailableTools: availableTools,
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, gc.ErrorMatches, "use --force to override: spock not supported")
}
Expand Down Expand Up @@ -297,7 +289,7 @@ func (s *BootstrapSuite) TestBootstrapFallbackSeries(c *gc.C) {
ControllerConfig: coretesting.FakeControllerConfig(),
BootstrapSeries: bootstrapSeries,
AvailableTools: availableTools,
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, jc.ErrorIsNil)
c.Check(result.Arch, gc.Equals, "ppc64el") // based on hardware characteristics
Expand Down Expand Up @@ -343,7 +335,7 @@ func (s *BootstrapSuite) TestBootstrapSeriesWithForce(c *gc.C) {
ControllerConfig: coretesting.FakeControllerConfig(),
BootstrapSeries: bootstrapSeries,
AvailableTools: availableTools,
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
Force: true,
})
c.Assert(err, jc.ErrorIsNil)
Expand Down Expand Up @@ -393,7 +385,7 @@ func (s *BootstrapSuite) TestBootstrapSeriesWithForceAndInvalidFallback(c *gc.C)
ControllerConfig: coretesting.FakeControllerConfig(),
BootstrapSeries: bootstrapSeries,
AvailableTools: availableTools,
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
Force: true,
})
c.Assert(err, gc.ErrorMatches, "bootstrap instance series not valid")
Expand Down Expand Up @@ -425,7 +417,7 @@ func (s *BootstrapSuite) TestStartInstanceDerivedZone(c *gc.C) {
_, err := common.Bootstrap(ctx, env, s.callCtx, environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AvailableTools: fakeAvailableTools(),
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, gc.ErrorMatches,
`cannot start bootstrap instance in availability zone "derived-zone": bloop`,
Expand Down Expand Up @@ -465,7 +457,7 @@ func (s *BootstrapSuite) TestStartInstanceAttemptAllZones(c *gc.C) {
_, err := common.Bootstrap(ctx, env, s.callCtx, environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AvailableTools: fakeAvailableTools(),
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, gc.ErrorMatches,
`cannot start bootstrap instance in any availability zone \(z0, z2\)`,
Expand Down Expand Up @@ -505,7 +497,7 @@ func (s *BootstrapSuite) TestStartInstanceStopOnZoneIndependentError(c *gc.C) {
_, err := common.Bootstrap(ctx, env, s.callCtx, environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AvailableTools: fakeAvailableTools(),
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, gc.ErrorMatches, `cannot start bootstrap instance: bloop`)
c.Assert(callZones, jc.SameContents, []string{"z0"})
Expand All @@ -531,7 +523,7 @@ func (s *BootstrapSuite) TestStartInstanceNoUsableZones(c *gc.C) {
_, err := common.Bootstrap(ctx, env, s.callCtx, environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AvailableTools: fakeAvailableTools(),
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, gc.ErrorMatches, `cannot start bootstrap instance: no usable availability zones`)
}
Expand Down Expand Up @@ -592,7 +584,7 @@ func (s *BootstrapSuite) TestSuccess(c *gc.C) {
result, err := common.Bootstrap(ctx, env, s.callCtx, environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AvailableTools: fakeAvailableTools(),
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(result.Arch, gc.Equals, "ppc64el") // based on hardware characteristics
Expand Down Expand Up @@ -683,7 +675,7 @@ func (s *BootstrapSuite) TestBootstrapFinalizeCloudInitUserData(c *gc.C) {
ControllerConfig: coretesting.FakeControllerConfig(),
BootstrapSeries: bootstrapSeries,
AvailableTools: availableTools,
SupportedBootstrapSeries: supportedJujuSeries,
SupportedBootstrapSeries: coretesting.FakeSupportedJujuSeries,
})
c.Assert(err, jc.ErrorIsNil)

Expand Down
5 changes: 3 additions & 2 deletions provider/dummy/environs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ func (s *suite) bootstrapTestEnviron(c *gc.C) environs.NetworkingEnviron {
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
},
AdminSecret: AdminSecret,
CAPrivateKey: testing.CAKey,
AdminSecret: AdminSecret,
CAPrivateKey: testing.CAKey,
SupportedBootstrapSeries: testing.FakeSupportedJujuSeries,
})
c.Assert(err, jc.ErrorIsNil)
return netenv
Expand Down
Loading

0 comments on commit 7786fe0

Please sign in to comment.