~sidnei/juju-core/lxc-clone-with-overlayfs

« back to all changes in this revision

Viewing changes to cmd/juju/bootstrap_test.go

  • Committer: Sidnei da Silva
  • Date: 2013-10-21 18:33:07 UTC
  • mfrom: (1667.1.329 juju-core)
  • Revision ID: sidnei.da.silva@canonical.com-20131021183307-fylyr68s4gtbxr08
- Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
package main
5
5
 
6
6
import (
 
7
        "bytes"
 
8
        "fmt"
7
9
        "io/ioutil"
8
10
        "os"
9
11
        "path/filepath"
 
12
        "strings"
10
13
 
11
14
        gc "launchpad.net/gocheck"
12
15
 
13
 
        "launchpad.net/juju-core/agent/tools"
14
16
        "launchpad.net/juju-core/cmd"
15
17
        "launchpad.net/juju-core/constraints"
16
18
        "launchpad.net/juju-core/environs"
17
 
        "launchpad.net/juju-core/environs/dummy"
 
19
        "launchpad.net/juju-core/environs/configstore"
 
20
        "launchpad.net/juju-core/environs/storage"
18
21
        "launchpad.net/juju-core/environs/sync"
19
22
        envtesting "launchpad.net/juju-core/environs/testing"
 
23
        envtools "launchpad.net/juju-core/environs/tools"
 
24
        "launchpad.net/juju-core/errors"
 
25
        "launchpad.net/juju-core/provider/dummy"
20
26
        coretesting "launchpad.net/juju-core/testing"
 
27
        "launchpad.net/juju-core/testing/testbase"
 
28
        coretools "launchpad.net/juju-core/tools"
21
29
        "launchpad.net/juju-core/version"
22
30
)
23
31
 
24
32
type BootstrapSuite struct {
25
 
        coretesting.LoggingSuite
 
33
        testbase.LoggingSuite
26
34
        coretesting.MgoSuite
 
35
        envtesting.ToolsFixture
27
36
}
28
37
 
29
38
var _ = gc.Suite(&BootstrapSuite{})
36
45
func (s *BootstrapSuite) SetUpTest(c *gc.C) {
37
46
        s.LoggingSuite.SetUpTest(c)
38
47
        s.MgoSuite.SetUpTest(c)
 
48
        s.ToolsFixture.SetUpTest(c)
39
49
}
40
50
 
41
51
func (s *BootstrapSuite) TearDownSuite(c *gc.C) {
44
54
}
45
55
 
46
56
func (s *BootstrapSuite) TearDownTest(c *gc.C) {
 
57
        s.ToolsFixture.TearDownTest(c)
47
58
        s.MgoSuite.TearDownTest(c)
48
59
        s.LoggingSuite.TearDownTest(c)
49
60
        dummy.Reset()
50
61
}
51
62
 
 
63
type bootstrapRetryTest struct {
 
64
        info               string
 
65
        args               []string
 
66
        expectedAllowRetry []bool
 
67
        err                string
 
68
        // If version != "", version.Current will be
 
69
        // set to it for the duration of the test.
 
70
        version string
 
71
        // If addVersionToSource is true, then "version"
 
72
        // above will be populated in the tools source.
 
73
        addVersionToSource bool
 
74
}
 
75
 
 
76
var bootstrapRetryTests = []bootstrapRetryTest{{
 
77
        info:               "no tools uploaded, first check has no retries; no matching binary in source; sync fails with no second attempt",
 
78
        expectedAllowRetry: []bool{false},
 
79
        err:                "no matching tools available",
 
80
        version:            "1.16.0-precise-amd64",
 
81
}, {
 
82
        info:               "no tools uploaded, first check has no retries; matching binary in source; check after sync has retries",
 
83
        expectedAllowRetry: []bool{false, true},
 
84
        err:                "tools not found",
 
85
        version:            "1.16.0-precise-amd64",
 
86
        addVersionToSource: true,
 
87
}, {
 
88
        info:               "no tools uploaded, first check has no retries; no matching binary in source; check after upload has retries",
 
89
        expectedAllowRetry: []bool{false, true},
 
90
        err:                "tools not found",
 
91
        version:            "1.15.1-precise-amd64", // dev version to force upload
 
92
}, {
 
93
        info:               "new tools uploaded, so we want to allow retries to give them a chance at showing up",
 
94
        args:               []string{"--upload-tools"},
 
95
        expectedAllowRetry: []bool{true},
 
96
        err:                "no matching tools available",
 
97
}}
 
98
 
 
99
// Test test checks that bootstrap calls FindTools with the expected allowRetry flag.
 
100
func (s *BootstrapSuite) TestAllowRetries(c *gc.C) {
 
101
        for i, test := range bootstrapRetryTests {
 
102
                c.Logf("test %d: %s\n", i, test.info)
 
103
                s.runAllowRetriesTest(c, test)
 
104
        }
 
105
}
 
106
 
 
107
func (s *BootstrapSuite) runAllowRetriesTest(c *gc.C, test bootstrapRetryTest) {
 
108
        var extraVersions []version.Binary
 
109
        if test.version != "" {
 
110
                testVersion := version.MustParseBinary(test.version)
 
111
                restore := testbase.PatchValue(&version.Current, testVersion)
 
112
                defer restore()
 
113
                if test.addVersionToSource {
 
114
                        extraVersions = append(extraVersions, testVersion)
 
115
                }
 
116
        }
 
117
        _, fake := makeEmptyFakeHome(c)
 
118
        defer fake.Restore()
 
119
        defer createToolsStore(c, extraVersions...)()
 
120
 
 
121
        var findToolsRetryValues []bool
 
122
        mockFindTools := func(cloudInst environs.ConfigGetter, majorVersion, minorVersion int,
 
123
                filter coretools.Filter, allowRetry bool) (list coretools.List, err error) {
 
124
                findToolsRetryValues = append(findToolsRetryValues, allowRetry)
 
125
                return nil, errors.NotFoundf("tools")
 
126
        }
 
127
 
 
128
        restore := envtools.TestingPatchBootstrapFindTools(mockFindTools)
 
129
        defer restore()
 
130
 
 
131
        _, errc := runCommand(nullContext(), new(BootstrapCommand), test.args...)
 
132
        err := <-errc
 
133
        c.Check(findToolsRetryValues, gc.DeepEquals, test.expectedAllowRetry)
 
134
        c.Assert(err, gc.ErrorMatches, test.err)
 
135
}
 
136
 
52
137
func (s *BootstrapSuite) TestTest(c *gc.C) {
53
138
        uploadTools = mockUploadTools
54
 
        defer func() { uploadTools = tools.Upload }()
 
139
        defer func() { uploadTools = sync.Upload }()
55
140
 
56
141
        for i, test := range bootstrapTests {
57
142
                c.Logf("\ntest %d: %s", i, test.info)
78
163
        defer restore()
79
164
 
80
165
        // Create home with dummy provider and remove all
81
 
        // of its tools.
 
166
        // of its envtools.
82
167
        env, fake := makeEmptyFakeHome(c)
83
168
        defer fake.Restore()
84
169
 
92
177
        if uploadCount == 0 {
93
178
                usefulVersion := version.Current
94
179
                usefulVersion.Series = env.Config().DefaultSeries()
95
 
                envtesting.UploadFakeToolsVersion(c, env.Storage(), usefulVersion)
 
180
                envtesting.AssertUploadFakeToolsVersions(c, env.Storage(), usefulVersion)
96
181
        }
97
182
 
98
183
        // Run command and check for uploads.
99
 
        opc, errc := runCommand(nil, new(BootstrapCommand), test.args...)
 
184
        opc, errc := runCommand(nullContext(), new(BootstrapCommand), test.args...)
100
185
        if uploadCount > 0 {
101
186
                for i := 0; i < uploadCount; i++ {
102
187
                        c.Check((<-opc).(dummy.OpPutFile).Env, gc.Equals, "peckham")
103
188
                }
104
 
                list, err := environs.FindAvailableTools(env, version.Current.Major)
 
189
                list, err := envtools.FindTools(
 
190
                        env, version.Current.Major, version.Current.Minor, coretools.Filter{}, envtools.DoNotAllowRetry)
105
191
                c.Check(err, gc.IsNil)
106
192
                c.Logf("found: " + list.String())
107
193
                urls := list.URLs()
122
208
        if !c.Check(<-errc, gc.IsNil) {
123
209
                return
124
210
        }
 
211
        if len(test.uploads) > 0 {
 
212
                indexFile := (<-opc).(dummy.OpPutFile)
 
213
                c.Check(indexFile.FileName, gc.Equals, "tools/streams/v1/index.json")
 
214
                productFile := (<-opc).(dummy.OpPutFile)
 
215
                c.Check(productFile.FileName, gc.Equals, "tools/streams/v1/com.ubuntu.juju:released:tools.json")
 
216
        }
125
217
        opPutBootstrapVerifyFile := (<-opc).(dummy.OpPutFile)
126
218
        c.Check(opPutBootstrapVerifyFile.Env, gc.Equals, "peckham")
127
 
        c.Check(opPutBootstrapVerifyFile.FileName, gc.Equals, "bootstrap-verify")
 
219
        c.Check(opPutBootstrapVerifyFile.FileName, gc.Equals, environs.VerificationFilename)
 
220
 
 
221
        opPutBootstrapInitFile := (<-opc).(dummy.OpPutFile)
 
222
        c.Check(opPutBootstrapInitFile.Env, gc.Equals, "peckham")
 
223
        c.Check(opPutBootstrapInitFile.FileName, gc.Equals, "provider-state")
128
224
 
129
225
        opBootstrap := (<-opc).(dummy.OpBootstrap)
130
226
        c.Check(opBootstrap.Env, gc.Equals, "peckham")
131
227
        c.Check(opBootstrap.Constraints, gc.DeepEquals, test.constraints)
132
228
 
 
229
        store, err := configstore.Default()
 
230
        c.Assert(err, gc.IsNil)
133
231
        // Check a CA cert/key was generated by reloading the environment.
134
 
        env, err := environs.NewFromName("peckham")
 
232
        env, err = environs.NewFromName("peckham", store)
135
233
        c.Assert(err, gc.IsNil)
136
234
        _, hasCert := env.Config().CACert()
137
235
        c.Check(hasCert, gc.Equals, true)
158
256
        args: []string{"--series", "fine"},
159
257
        err:  `--series requires --upload-tools`,
160
258
}, {
161
 
        info: "bad environment",
162
 
        args: []string{"-e", "brokenenv"},
163
 
        err:  `environment configuration has no admin-secret`,
 
259
        info:    "bad environment",
 
260
        version: "1.2.3-precise-amd64",
 
261
        args:    []string{"-e", "brokenenv"},
 
262
        err:     `dummy.Bootstrap is broken`,
164
263
}, {
165
264
        info:        "constraints",
166
265
        args:        []string{"--constraints", "mem=4G cpu-cores=4"},
167
266
        constraints: constraints.MustParse("mem=4G cpu-cores=4"),
168
267
}, {
169
268
        info:    "--upload-tools picks all reasonable series",
170
 
        version: "1.2.3-hostseries-hostarch",
 
269
        version: "1.2.3-saucy-amd64",
171
270
        args:    []string{"--upload-tools"},
172
271
        uploads: []string{
173
 
                "1.2.3.1-hostseries-hostarch",    // from version.Current
174
 
                "1.2.3.1-defaultseries-hostarch", // from env.Config().DefaultSeries()
175
 
                "1.2.3.1-precise-hostarch",       // from environs/config.DefaultSeries
 
272
                "1.2.3.1-saucy-amd64",   // from version.Current
 
273
                "1.2.3.1-raring-amd64",  // from env.Config().DefaultSeries()
 
274
                "1.2.3.1-precise-amd64", // from environs/config.DefaultSeries
176
275
        },
177
276
}, {
178
277
        info:    "--upload-tools only uploads each file once",
179
 
        version: "1.2.3-precise-hostarch",
 
278
        version: "1.2.3-precise-amd64",
180
279
        args:    []string{"--upload-tools"},
181
280
        uploads: []string{
182
 
                "1.2.3.1-defaultseries-hostarch",
183
 
                "1.2.3.1-precise-hostarch",
 
281
                "1.2.3.1-raring-amd64",
 
282
                "1.2.3.1-precise-amd64",
184
283
        },
185
284
}, {
186
 
        info:    "--upload-tools accepts specific series even if they're crazy",
187
 
        version: "1.2.3-hostseries-hostarch",
 
285
        info:    "--upload-tools rejects invalid series",
 
286
        version: "1.2.3-saucy-amd64",
188
287
        args:    []string{"--upload-tools", "--series", "ping,ping,pong"},
189
 
        uploads: []string{
190
 
                "1.2.3.1-hostseries-hostarch",
191
 
                "1.2.3.1-ping-hostarch",
192
 
                "1.2.3.1-pong-hostarch",
193
 
        },
194
 
        err: "no matching tools available",
 
288
        err:     `invalid series "ping"`,
195
289
}, {
196
290
        info:    "--upload-tools always bumps build number",
197
 
        version: "1.2.3.4-defaultseries-hostarch",
 
291
        version: "1.2.3.4-raring-amd64",
198
292
        args:    []string{"--upload-tools"},
199
293
        uploads: []string{
200
 
                "1.2.3.5-defaultseries-hostarch",
201
 
                "1.2.3.5-precise-hostarch",
 
294
                "1.2.3.5-raring-amd64",
 
295
                "1.2.3.5-precise-amd64",
202
296
        },
203
297
}}
204
298
 
 
299
func (s *BootstrapSuite) TestBootstrapTwice(c *gc.C) {
 
300
        env, fake := makeEmptyFakeHome(c)
 
301
        defer fake.Restore()
 
302
        defaultSeriesVersion := version.Current
 
303
        defaultSeriesVersion.Series = env.Config().DefaultSeries()
 
304
        restore := createToolsStore(c, defaultSeriesVersion)
 
305
        defer restore()
 
306
 
 
307
        ctx := coretesting.Context(c)
 
308
        code := cmd.Main(&BootstrapCommand{}, ctx, nil)
 
309
        c.Check(code, gc.Equals, 0)
 
310
 
 
311
        ctx2 := coretesting.Context(c)
 
312
        code2 := cmd.Main(&BootstrapCommand{}, ctx2, nil)
 
313
        c.Check(code2, gc.Equals, 1)
 
314
        c.Check(coretesting.Stderr(ctx2), gc.Equals, "error: environment is already bootstrapped\n")
 
315
        c.Check(coretesting.Stdout(ctx2), gc.Equals, "")
 
316
}
 
317
 
205
318
func (s *BootstrapSuite) TestAutoSync(c *gc.C) {
206
319
        // Prepare a mock storage for testing and store the
207
320
        // dummy tools in there.
211
324
        // Change the tools location to be the test location and also
212
325
        // the version and ensure their later restoring.
213
326
        origVersion := version.Current
214
 
        version.Current.Number = version.MustParse("1.2.3")
 
327
        version.Current.Number = version.MustParse("1.2.0")
215
328
        defer func() { version.Current = origVersion }()
216
329
 
217
330
        // Create home with dummy provider and remove all
218
 
        // of its tools.
 
331
        // of its envtools.
219
332
        env, fake := makeEmptyFakeHome(c)
220
333
        defer fake.Restore()
221
334
 
226
339
        code := cmd.Main(&BootstrapCommand{}, ctx, nil)
227
340
        c.Check(code, gc.Equals, 0)
228
341
 
229
 
        // Now check the available tools which are the 1.0.0 tools.
230
 
        checkTools(c, env, v100All)
 
342
        // Now check the available tools which are the 1.2.0 envtools.
 
343
        checkTools(c, env, v120All)
231
344
}
232
345
 
233
346
func (s *BootstrapSuite) TestAutoSyncLocalSource(c *gc.C) {
237
350
 
238
351
        // Change the version and ensure its later restoring.
239
352
        origVersion := version.Current
240
 
        version.Current.Number = version.MustParse("1.2.3")
 
353
        version.Current.Number = version.MustParse("1.2.0")
241
354
        defer func() {
242
355
                version.Current = origVersion
243
356
        }()
244
357
 
245
358
        // Create home with dummy provider and remove all
246
 
        // of its tools.
 
359
        // of its envtools.
247
360
        env, fake := makeEmptyFakeHome(c)
248
361
        defer fake.Restore()
249
362
 
254
367
        c.Check(code, gc.Equals, 1)
255
368
 
256
369
        // Now check that there are no tools available.
257
 
        _, err := environs.FindAvailableTools(env, version.Current.Major)
258
 
        c.Assert(err, gc.ErrorMatches, "no tools available")
 
370
        _, err := envtools.FindTools(
 
371
                env, version.Current.Major, version.Current.Minor, coretools.Filter{}, envtools.DoNotAllowRetry)
 
372
        c.Assert(err, gc.FitsTypeOf, errors.NotFoundf(""))
259
373
 
260
374
        // Bootstrap the environment with the valid source. This time
261
375
        // the bootstrapping has to show no error, because the tools
264
378
        code = cmd.Main(&BootstrapCommand{}, ctx, []string{"--source", source})
265
379
        c.Check(code, gc.Equals, 0)
266
380
 
267
 
        // Now check the available tools which are the 1.0.0 tools.
268
 
        checkTools(c, env, v100All)
 
381
        // Now check the available tools which are the 1.2.0 envtools.
 
382
        checkTools(c, env, v120All)
 
383
}
 
384
 
 
385
func (s *BootstrapSuite) setupAutoUploadTest(c *gc.C, vers, series string) environs.Environ {
 
386
        uploadTools = mockUploadTools
 
387
        s.AddCleanup(func(*gc.C) { uploadTools = sync.Upload })
 
388
 
 
389
        // Prepare a mock storage for testing and store the
 
390
        // dummy tools in there.
 
391
        restore := createToolsStore(c)
 
392
        s.AddCleanup(func(*gc.C) { restore() })
 
393
 
 
394
        // Change the tools location to be the test location and also
 
395
        // the version and ensure their later restoring.
 
396
        // Set the current version to be something for which there are no tools
 
397
        // so we can test that an upload is forced.
 
398
        origVersion := version.Current
 
399
        version.Current.Number = version.MustParse(vers)
 
400
        version.Current.Series = series
 
401
        s.AddCleanup(func(*gc.C) { version.Current = origVersion })
 
402
 
 
403
        // Create home with dummy provider and remove all
 
404
        // of its envtools.
 
405
        env, fake := makeEmptyFakeHome(c)
 
406
        s.AddCleanup(func(*gc.C) { fake.Restore() })
 
407
        return env
 
408
}
 
409
 
 
410
func (s *BootstrapSuite) TestAutoUploadAfterFailedSync(c *gc.C) {
 
411
        otherSeries := "precise"
 
412
        if otherSeries == version.Current.Series {
 
413
                otherSeries = "raring"
 
414
        }
 
415
        env := s.setupAutoUploadTest(c, "1.7.3", otherSeries)
 
416
        // Run command and check for that upload has been run for tools matching the current juju version.
 
417
        opc, errc := runCommand(nullContext(), new(BootstrapCommand))
 
418
        c.Assert(<-errc, gc.IsNil)
 
419
        c.Assert((<-opc).(dummy.OpPutFile).Env, gc.Equals, "peckham")
 
420
        list, err := envtools.FindTools(env, version.Current.Major, version.Current.Minor, coretools.Filter{}, false)
 
421
        c.Assert(err, gc.IsNil)
 
422
        c.Logf("found: " + list.String())
 
423
        urls := list.URLs()
 
424
        c.Assert(urls, gc.HasLen, 2)
 
425
        expectedVers := []version.Binary{
 
426
                version.MustParseBinary(fmt.Sprintf("1.7.3.1-%s-%s", otherSeries, version.Current.Arch)),
 
427
                version.MustParseBinary(fmt.Sprintf("1.7.3.1-%s-%s", version.Current.Series, version.Current.Arch)),
 
428
        }
 
429
        for _, vers := range expectedVers {
 
430
                c.Logf("seeking: " + vers.String())
 
431
                _, found := urls[vers]
 
432
                c.Check(found, gc.Equals, true)
 
433
        }
 
434
}
 
435
 
 
436
func (s *BootstrapSuite) TestAutoUploadOnlyForDev(c *gc.C) {
 
437
        s.setupAutoUploadTest(c, "1.8.3", "precise")
 
438
        _, errc := runCommand(nullContext(), new(BootstrapCommand))
 
439
        err := <-errc
 
440
        c.Assert(err, gc.ErrorMatches, "no matching tools available")
 
441
}
 
442
 
 
443
func (s *BootstrapSuite) TestMissingToolsError(c *gc.C) {
 
444
        s.setupAutoUploadTest(c, "1.8.3", "precise")
 
445
        context := coretesting.Context(c)
 
446
        code := cmd.Main(&BootstrapCommand{}, context, nil)
 
447
        c.Assert(code, gc.Equals, 1)
 
448
        errText := context.Stderr.(*bytes.Buffer).String()
 
449
        errText = strings.Replace(errText, "\n", "", -1)
 
450
        expectedErrText := strings.Replace(fmt.Sprintf(".*%s.*", NoToolsNoUploadMessage), "\n", "", -1)
 
451
        c.Assert(errText, gc.Matches, expectedErrText)
 
452
}
 
453
 
 
454
func uploadToolsAlwaysFails(stor storage.Storage, forceVersion *version.Number, series ...string) (*coretools.Tools, error) {
 
455
        return nil, fmt.Errorf("an error")
 
456
}
 
457
 
 
458
func (s *BootstrapSuite) TestMissingToolsUploadFailedError(c *gc.C) {
 
459
        s.setupAutoUploadTest(c, "1.7.3", "precise")
 
460
        uploadTools = uploadToolsAlwaysFails
 
461
        context := coretesting.Context(c)
 
462
        code := cmd.Main(&BootstrapCommand{}, context, nil)
 
463
        c.Assert(code, gc.Equals, 1)
 
464
        errText := context.Stderr.(*bytes.Buffer).String()
 
465
        errText = strings.Replace(errText, "\n", "", -1)
 
466
        expectedErrText := strings.Replace(fmt.Sprintf(".*%s.*", NoToolsMessage), "\n", "", -1)
 
467
        c.Assert(errText, gc.Matches, expectedErrText)
269
468
}
270
469
 
271
470
// createToolsStore creates the fake tools store.
272
 
func createToolsStore(c *gc.C) func() {
273
 
        storage, err := envtesting.NewEC2HTTPTestStorage("127.0.0.1")
 
471
func createToolsStore(c *gc.C, additionalBinaries ...version.Binary) func() {
 
472
        stor, err := envtesting.NewEC2HTTPTestStorage("127.0.0.1")
274
473
        c.Assert(err, gc.IsNil)
275
474
        origLocation := sync.DefaultToolsLocation
276
 
        sync.DefaultToolsLocation = storage.Location()
 
475
        sync.DefaultToolsLocation = stor.Location()
277
476
        for _, vers := range vAll {
278
 
                storage.PutBinary(vers)
 
477
                stor.PutBinary(vers)
 
478
        }
 
479
        for _, vers := range additionalBinaries {
 
480
                stor.PutBinary(vers)
279
481
        }
280
482
        restore := func() {
281
483
                sync.DefaultToolsLocation = origLocation
284
486
}
285
487
 
286
488
// createToolsSource writes the mock tools into a temporary
287
 
// derectory and returns it.
 
489
// directory and returns it.
288
490
func createToolsSource(c *gc.C) string {
289
491
        source := c.MkDir()
290
492
        for _, vers := range vAll {
291
493
                data := vers.String()
292
 
                name := tools.StorageName(vers)
 
494
                name := envtools.StorageName(vers)
293
495
                filename := filepath.Join(source, name)
294
496
                dir := filepath.Dir(filename)
295
497
                err := os.MkdirAll(dir, 0755)
300
502
        return source
301
503
}
302
504
 
303
 
// makeEmptyFakeHome creates a faked home without tools.
 
505
// makeEmptyFakeHome creates a faked home without envtools.
304
506
func makeEmptyFakeHome(c *gc.C) (environs.Environ, *coretesting.FakeHome) {
305
507
        fake := coretesting.MakeFakeHome(c, envConfig)
306
508
        dummy.Reset()
307
 
        env, err := environs.NewFromName("peckham")
 
509
        store, err := configstore.Default()
 
510
        c.Assert(err, gc.IsNil)
 
511
        env, err := environs.PrepareFromName("peckham", store)
308
512
        c.Assert(err, gc.IsNil)
309
513
        envtesting.RemoveAllTools(c, env)
310
514
        return env, fake
311
515
}
312
516
 
313
 
// checkTools check if the environment contains the passed tools.
314
 
func checkTools(c *gc.C, env environs.Environ, tools []version.Binary) {
315
 
        list, err := environs.FindAvailableTools(env, version.Current.Major)
 
517
// checkTools check if the environment contains the passed envtools.
 
518
func checkTools(c *gc.C, env environs.Environ, expected []version.Binary) {
 
519
        list, err := envtools.FindTools(
 
520
                env, version.Current.Major, version.Current.Minor, coretools.Filter{}, envtools.DoNotAllowRetry)
316
521
        c.Check(err, gc.IsNil)
317
522
        c.Logf("found: " + list.String())
318
523
        urls := list.URLs()
319
 
        c.Check(urls, gc.HasLen, len(tools))
 
524
        c.Check(urls, gc.HasLen, len(expected))
320
525
}
321
526
 
322
527
var (
323
 
        v100d64 = version.MustParseBinary("1.0.0-defaultseries-amd64")
 
528
        v100d64 = version.MustParseBinary("1.0.0-raring-amd64")
324
529
        v100p64 = version.MustParseBinary("1.0.0-precise-amd64")
325
530
        v100q32 = version.MustParseBinary("1.0.0-quantal-i386")
326
531
        v100q64 = version.MustParseBinary("1.0.0-quantal-amd64")
 
532
        v120d64 = version.MustParseBinary("1.2.0-raring-amd64")
 
533
        v120p64 = version.MustParseBinary("1.2.0-precise-amd64")
 
534
        v120q32 = version.MustParseBinary("1.2.0-quantal-i386")
 
535
        v120q64 = version.MustParseBinary("1.2.0-quantal-amd64")
327
536
        v190p32 = version.MustParseBinary("1.9.0-precise-i386")
328
537
        v190q64 = version.MustParseBinary("1.9.0-quantal-amd64")
329
538
        v200p64 = version.MustParseBinary("2.0.0-precise-amd64")
330
539
        v100All = []version.Binary{
331
540
                v100d64, v100p64, v100q64, v100q32,
332
541
        }
 
542
        v120All = []version.Binary{
 
543
                v120d64, v120p64, v120q64, v120q32,
 
544
        }
333
545
        vAll = []version.Binary{
334
546
                v100d64, v100p64, v100q32, v100q64,
 
547
                v120d64, v120p64, v120q32, v120q64,
335
548
                v190p32, v190q64,
336
549
                v200p64,
337
550
        }