1538735: Pass BootstrapSeries to provider bootstrap #4899

Merged
merged 3 commits into from Mar 30, 2016

Conversation

Projects
None yet
3 participants

cherylj commented Mar 28, 2016

--bootstrap-series is used to filter tools before
calling the provider bootstrap method, but then the
bootstrap-series is not passed into the provider when
calling bootstrap.

The provider then used either the specified
default-series, or the default default-series to choose
tools. This led to a "no matching tools available"
error if the bootstrap series differed from the default
series used.

In this patch, I update the BootstrapParams to include
the bootstrap series and have the provider use that
to check for tools.

Unit tests reference unsupported "utopic" as support
for xenial and wily has yet to land for non-ubuntu
clients: juju/utils#201

Cheryl Jennings added some commits Mar 27, 2016

1538735: Pass BootstrapSeries to provider bootstrap
--bootstrap-series is used to filter tools before
calling the provider bootstrap method, but then the
bootstrap-series is not passed into the provider when
calling bootstrap.

The provider then used either the specified
default-series, or the default default-series to choose
tools.  This led to a "no matching tools available"
error if the bootstrap series differed from the default
series used.

In this patch, I update the BootstrapParams to include
the bootstrap series and have the provider use that
to check for tools.
"xenial" unknown series on CentOS
Changed "xenial" to "utopic" because the unit tests
will fail on CentOS (and windows) until this PR lands:
juju/utils#201
provider/common/bootstrap_test.go
+ instance.Instance, *instance.HardwareCharacteristics, []network.InterfaceInfo, error,
+ ) {
+ return &mockInstance{id: checkInstanceId}, &checkHardware, nil, nil
+ }
@kat-co

kat-co Mar 28, 2016

Contributor

Can you please reformat this? Typically if you want a multi-line function, you align it as you would a struct.

provider/common/bootstrap_test.go
+ return &mockInstance{id: checkInstanceId}, &checkHardware, nil, nil
+ }
+ var mocksConfig = minimalConfig(c)
+ var getConfigCalled int
@kat-co

kat-co Mar 28, 2016

Contributor

Rename to numGetConfigCalls?

@@ -135,6 +135,55 @@ func (s *BootstrapSuite) TestCannotStartInstance(c *gc.C) {
c.Assert(err, gc.ErrorMatches, "cannot start bootstrap instance: meh, not started")
}
+func (s *BootstrapSuite) TestBootstrapSeries(c *gc.C) {
+ s.PatchValue(&jujuversion.Current, coretesting.FakeVersionNumber)
+ s.PatchValue(&series.HostSeries, func() string { return "precise" })
@kat-co

kat-co Mar 28, 2016

Contributor

I'm going to be that person and say -- even though we don't have time to fix this right now -- patching values is a smell that our design is bad, and we should stop doing this in tests.

Carry on! ;)

provider/common/bootstrap_test.go
+ }})
+ c.Assert(err, jc.ErrorIsNil)
+ c.Assert(result.Arch, gc.Equals, "ppc64el") // based on hardware characteristics
+ c.Assert(result.Series, gc.Equals, bootstrapSeries)
@kat-co

kat-co Mar 28, 2016

Contributor

Change the prior 2 asserts to .Check so that we get all errors in a failing test. .Assert needs to be kept on the err as a gate.

environs/bootstrap/bootstrap_test.go
+ c.Assert(err, jc.ErrorIsNil)
+ c.Assert(env.bootstrapCount, gc.Equals, 1)
+ c.Assert(env.args.BootstrapSeries, gc.Equals, "trusty")
+ c.Assert(env.args.AvailableTools.AllSeries(), jc.SameContents, []string{"trusty"})
@kat-co

kat-co Mar 28, 2016

Contributor

Change the prior 3 asserts to .Check so that we get all errors in a failing test. .Assert needs to be kept on the err as a gate.

Contributor

kat-co commented Mar 28, 2016

LGTM

cherylj commented Mar 29, 2016

$$merge$$

Contributor

jujubot commented Mar 30, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit a71b6b9 into juju:master Mar 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment