~cmars/juju-core/1.18-resolve-cs-series

« back to all changes in this revision

Viewing changes to juju/testing/conn.go

  • Committer: Tarmac
  • Author(s): Casey Marshall
  • Date: 2014-04-04 14:01:14 UTC
  • mfrom: (2257.3.1 1.18)
  • Revision ID: tarmac-20140404140114-entbcqxccpecela0
[r=sinzui] Ported r2559 from trunk to 1.18

For the deploy and upgradecharm commands, when a series is not provided, and a
default-series is not set in the environment config, the client will resolve
the series with the charm store, through the state server. If the client is
working with a 1.16 state server, it will resolve the series directly with the
charm store.

Existing environments will have a default-series, so they should have no
change in series selection.

New environments will continue to support the default-series config setting,
but it can be omitted, and is not set by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
        "launchpad.net/juju-core/constraints"
18
18
        "launchpad.net/juju-core/environs"
19
19
        "launchpad.net/juju-core/environs/bootstrap"
 
20
        "launchpad.net/juju-core/environs/config"
20
21
        "launchpad.net/juju-core/environs/configstore"
21
22
        envtesting "launchpad.net/juju-core/environs/testing"
22
23
        "launchpad.net/juju-core/juju"
164
165
        return s.openAPIAs(c, machine.Tag(), password, "fake_nonce"), machine
165
166
}
166
167
 
 
168
func PreferredDefaultVersions(conf *config.Config, template version.Binary) []version.Binary {
 
169
        prefVersion := template
 
170
        prefVersion.Series = config.PreferredSeries(conf)
 
171
        defaultVersion := template
 
172
        defaultVersion.Series = testing.FakeDefaultSeries
 
173
        return []version.Binary{prefVersion, defaultVersion}
 
174
}
 
175
 
167
176
func (s *JujuConnSuite) setUpConn(c *gc.C) {
168
177
        if s.RootDir != "" {
169
178
                panic("JujuConnSuite.setUpConn without teardown")
203
212
        c.Assert(environ.Name(), gc.Equals, "dummyenv")
204
213
        s.PatchValue(&dummy.DataDir, s.DataDir())
205
214
 
206
 
        envtesting.MustUploadFakeTools(environ.Storage())
 
215
        versions := PreferredDefaultVersions(environ.Config(), version.Current)
 
216
        versions = append(versions, version.Current)
 
217
 
 
218
        // Upload tools for both preferred and fake default series
 
219
        envtesting.MustUploadFakeToolsVersions(environ.Storage(), versions...)
207
220
        c.Assert(bootstrap.Bootstrap(ctx, environ, constraints.Value{}), gc.IsNil)
208
221
 
209
222
        s.BackingState = environ.(GetStater).GetStateInAPIServer()
285
298
        ch := testing.Charms.Dir(name)
286
299
        ident := fmt.Sprintf("%s-%d", ch.Meta().Name, ch.Revision())
287
300
        curl := charm.MustParseURL("local:quantal/" + ident)
288
 
        repo, err := charm.InferRepository(curl, testing.Charms.Path())
 
301
        repo, err := charm.InferRepository(curl.Reference, testing.Charms.Path())
289
302
        c.Assert(err, gc.IsNil)
290
303
        sch, err := s.Conn.PutCharm(curl, repo, false)
291
304
        c.Assert(err, gc.IsNil)