~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/service/bundle_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        jc "github.com/juju/testing/checkers"
15
15
        gc "gopkg.in/check.v1"
16
16
        "gopkg.in/juju/charm.v6-unstable"
 
17
        "gopkg.in/juju/charmrepo.v2-unstable/csclient"
17
18
 
18
19
        "github.com/juju/juju/api"
19
20
        "github.com/juju/juju/constraints"
71
72
added wordpress/0 unit to new machine
72
73
deployment of bundle "cs:bundle/wordpress-simple-1" completed`
73
74
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
74
 
        s.assertCharmsUplodaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
 
75
        s.assertCharmsUploaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
75
76
        s.assertServicesDeployed(c, map[string]serviceInfo{
76
77
                "mysql":     {charm: "cs:trusty/mysql-42"},
77
78
                "wordpress": {charm: "cs:trusty/wordpress-47"},
98
99
added terms2/0 unit to new machine
99
100
deployment of bundle "cs:bundle/terms-simple-1" completed`
100
101
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
101
 
        s.assertCharmsUplodaded(c, "cs:trusty/terms1-17", "cs:trusty/terms2-42")
 
102
        s.assertCharmsUploaded(c, "cs:trusty/terms1-17", "cs:trusty/terms2-42")
102
103
        s.assertServicesDeployed(c, map[string]serviceInfo{
103
104
                "terms1": {charm: "cs:trusty/terms1-17"},
104
105
                "terms2": {charm: "cs:trusty/terms2-42"},
129
130
added wordpress/0 unit to new machine
130
131
deployment of bundle "cs:bundle/wordpress-with-mysql-storage-1" completed`
131
132
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
132
 
        s.assertCharmsUplodaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
 
133
        s.assertCharmsUploaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
133
134
        s.assertServicesDeployed(c, map[string]serviceInfo{
134
135
                "mysql": {
135
136
                        charm: "cs:trusty/mysql-42",
149
150
 
150
151
func (s *DeployCharmStoreSuite) TestDeployBundleEndpointBindingsSpaceMissing(c *gc.C) {
151
152
        testcharms.UploadCharm(c, s.client, "trusty/mysql-42", "mysql")
152
 
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-47", "wordpress")
 
153
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-extra-bindings-47", "wordpress-extra-bindings")
153
154
        testcharms.UploadBundle(c, s.client, "bundle/wordpress-with-endpoint-bindings-1", "wordpress-with-endpoint-bindings")
154
155
        output, err := runDeployCommand(c, "bundle/wordpress-with-endpoint-bindings")
155
156
        c.Assert(err, gc.ErrorMatches,
156
157
                "cannot deploy bundle: cannot deploy service \"mysql\": "+
157
158
                        "cannot add service \"mysql\": unknown space \"db\" not valid")
158
159
        c.Assert(output, gc.Equals, "added charm cs:trusty/mysql-42")
159
 
        s.assertCharmsUplodaded(c, "cs:trusty/mysql-42")
 
160
        s.assertCharmsUploaded(c, "cs:trusty/mysql-42")
160
161
        s.assertServicesDeployed(c, map[string]serviceInfo{})
161
162
        s.assertUnitsCreated(c, map[string]string{})
162
163
}
168
169
        c.Assert(err, jc.ErrorIsNil)
169
170
 
170
171
        testcharms.UploadCharm(c, s.client, "trusty/mysql-42", "mysql")
171
 
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-47", "wordpress")
 
172
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-extra-bindings-47", "wordpress-extra-bindings")
172
173
        testcharms.UploadBundle(c, s.client, "bundle/wordpress-with-endpoint-bindings-1", "wordpress-with-endpoint-bindings")
173
174
        output, err := runDeployCommand(c, "bundle/wordpress-with-endpoint-bindings")
174
175
        c.Assert(err, jc.ErrorIsNil)
175
176
        expectedOutput := `
176
177
added charm cs:trusty/mysql-42
177
178
service mysql deployed (charm: cs:trusty/mysql-42)
178
 
added charm cs:trusty/wordpress-47
179
 
service wordpress deployed (charm: cs:trusty/wordpress-47)
180
 
related wordpress:db and mysql:server
 
179
added charm cs:trusty/wordpress-extra-bindings-47
 
180
service wordpress-extra-bindings deployed (charm: cs:trusty/wordpress-extra-bindings-47)
 
181
related wordpress-extra-bindings:db and mysql:server
181
182
added mysql/0 unit to new machine
182
 
added wordpress/0 unit to new machine
 
183
added wordpress-extra-bindings/0 unit to new machine
183
184
deployment of bundle "cs:bundle/wordpress-with-endpoint-bindings-1" completed`
184
185
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
185
 
        s.assertCharmsUplodaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
 
186
        s.assertCharmsUploaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-extra-bindings-47")
186
187
 
187
188
        s.assertServicesDeployed(c, map[string]serviceInfo{
188
 
                "mysql":     {charm: "cs:trusty/mysql-42"},
189
 
                "wordpress": {charm: "cs:trusty/wordpress-47"},
 
189
                "mysql":                    {charm: "cs:trusty/mysql-42"},
 
190
                "wordpress-extra-bindings": {charm: "cs:trusty/wordpress-extra-bindings-47"},
190
191
        })
191
192
        s.assertDeployedServiceBindings(c, map[string]serviceInfo{
192
193
                "mysql": {
193
194
                        endpointBindings: map[string]string{"server": "db"},
194
195
                },
195
 
                "wordpress": {
 
196
                "wordpress-extra-bindings": {
196
197
                        endpointBindings: map[string]string{
197
198
                                "cache":           "",
198
199
                                "url":             "public",
199
200
                                "logging-dir":     "",
200
201
                                "monitoring-port": "",
201
202
                                "db":              "db",
 
203
                                "cluster":         "",
 
204
                                "db-client":       "db",
 
205
                                "admin-api":       "public",
 
206
                                "foo-bar":         "",
202
207
                        },
203
208
                },
204
209
        })
205
 
        s.assertRelationsEstablished(c, "wordpress:db mysql:server")
 
210
        s.assertRelationsEstablished(c, "wordpress-extra-bindings:cluster", "wordpress-extra-bindings:db mysql:server")
206
211
        s.assertUnitsCreated(c, map[string]string{
207
 
                "mysql/0":     "0",
208
 
                "wordpress/0": "1",
 
212
                "mysql/0":                    "0",
 
213
                "wordpress-extra-bindings/0": "1",
209
214
        })
210
215
}
211
216
 
227
232
avoid adding new units to service wordpress: 1 unit already present
228
233
deployment of bundle "cs:bundle/wordpress-simple-1" completed`
229
234
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
230
 
        s.assertCharmsUplodaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
 
235
        s.assertCharmsUploaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
231
236
        s.assertServicesDeployed(c, map[string]serviceInfo{
232
237
                "mysql":     {charm: "cs:trusty/mysql-42"},
233
238
                "wordpress": {charm: "cs:trusty/wordpress-47"},
246
251
        testcharms.UploadBundle(c, s.client, "bundle/wordpress-simple-1", "wordpress-simple")
247
252
        _, err := runDeployCommand(c, "bundle/wordpress-simple")
248
253
        c.Assert(err, jc.ErrorIsNil)
249
 
        s.assertCharmsUplodaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
 
254
        s.assertCharmsUploaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
250
255
        s.assertServicesDeployed(c, map[string]serviceInfo{
251
256
                "mysql":     {charm: "cs:trusty/mysql-42"},
252
257
                "wordpress": {charm: "cs:trusty/wordpress-47"},
272
277
added wordpress/0 unit to new machine
273
278
deployment of bundle %q completed`, path)
274
279
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
275
 
        s.assertCharmsUplodaded(c, "cs:trusty/wordpress-47")
 
280
        s.assertCharmsUploaded(c, "cs:trusty/wordpress-47")
276
281
        s.assertServicesDeployed(c, map[string]serviceInfo{
277
282
                "wordpress": {charm: "cs:trusty/wordpress-47"},
278
283
        })
287
292
        c.Assert(err, gc.ErrorMatches, `cannot deploy bundle: .*: unauthorized: access denied for user "client-username"`)
288
293
}
289
294
 
290
 
type deployRepoCharmStoreSuite struct {
 
295
type DeployRepoCharmStoreSuite struct {
291
296
        charmStoreSuite
292
297
        testing.BaseRepoSuite
 
298
 
 
299
        Client *csclient.Client
293
300
}
294
301
 
295
 
var _ = gc.Suite(&deployRepoCharmStoreSuite{})
 
302
var _ = gc.Suite(&DeployRepoCharmStoreSuite{})
296
303
 
297
 
func (s *deployRepoCharmStoreSuite) SetUpSuite(c *gc.C) {
 
304
func (s *DeployRepoCharmStoreSuite) SetUpSuite(c *gc.C) {
298
305
        s.charmStoreSuite.SetUpSuite(c)
299
306
        s.BaseRepoSuite.SetUpSuite(c)
 
307
        s.PatchValue(&watcher.Period, 10*time.Millisecond)
300
308
}
301
309
 
302
 
func (s *deployRepoCharmStoreSuite) TearDownSuite(c *gc.C) {
 
310
func (s *DeployRepoCharmStoreSuite) TearDownSuite(c *gc.C) {
303
311
        s.BaseRepoSuite.TearDownSuite(c)
304
312
        s.charmStoreSuite.TearDownSuite(c)
305
313
}
306
314
 
307
 
func (s *deployRepoCharmStoreSuite) SetUpTest(c *gc.C) {
308
 
        s.PatchValue(&watcher.Period, 10*time.Millisecond)
 
315
func (s *DeployRepoCharmStoreSuite) SetUpTest(c *gc.C) {
309
316
        s.charmStoreSuite.SetUpTest(c)
310
317
        s.BaseRepoSuite.SetUpTest(c)
 
318
 
 
319
        s.Client = s.client
311
320
}
312
321
 
313
 
func (s *deployRepoCharmStoreSuite) TearDownTest(c *gc.C) {
 
322
func (s *DeployRepoCharmStoreSuite) TearDownTest(c *gc.C) {
314
323
        s.BaseRepoSuite.TearDownTest(c)
315
324
        s.charmStoreSuite.TearDownTest(c)
316
325
}
317
326
 
318
 
// deployBundleYAML uses the given bundle content to create a bundle in the
 
327
// DeployBundleYAML uses the given bundle content to create a bundle in the
319
328
// local repository and then deploy it. It returns the bundle deployment output
320
329
// and error.
321
 
func (s *deployRepoCharmStoreSuite) deployBundleYAML(c *gc.C, content string) (string, error) {
 
330
func (s *DeployRepoCharmStoreSuite) DeployBundleYAML(c *gc.C, content string) (string, error) {
322
331
        bundlePath := filepath.Join(s.BundlesPath, "example")
323
332
        c.Assert(os.Mkdir(bundlePath, 0777), jc.ErrorIsNil)
324
333
        defer os.RemoveAll(bundlePath)
329
338
        return runDeployCommand(c, "local:bundle/example")
330
339
}
331
340
 
 
341
type deployRepoCharmStoreSuite struct {
 
342
        DeployRepoCharmStoreSuite
 
343
}
 
344
 
 
345
var _ = gc.Suite(&deployRepoCharmStoreSuite{})
 
346
 
332
347
var deployBundleErrorsTests = []struct {
333
348
        about   string
334
349
        content string
363
378
                charm: mysql
364
379
                num_units: -1
365
380
    `,
366
 
        err: `cannot deploy bundle: negative number of units specified on service "mysql"`,
 
381
        err: `the provided bundle has the following errors:
 
382
negative number of units specified on service "mysql"`,
367
383
}, {
368
384
        about: "invalid constraints",
369
385
        content: `
373
389
                num_units: 1
374
390
                constraints: bad-wolf
375
391
    `,
376
 
        err: `cannot deploy bundle: invalid constraints "bad-wolf" in service "mysql": malformed constraint "bad-wolf"`,
 
392
        err: `the provided bundle has the following errors:
 
393
invalid constraints "bad-wolf" in service "mysql": malformed constraint "bad-wolf"`,
 
394
}, {
 
395
        about: "multiple bundle verification errors",
 
396
        content: `
 
397
        services:
 
398
            mysql:
 
399
                charm: mysql
 
400
                num_units: -1
 
401
                constraints: bad-wolf
 
402
    `,
 
403
        err: `the provided bundle has the following errors:
 
404
invalid constraints "bad-wolf" in service "mysql": malformed constraint "bad-wolf"
 
405
negative number of units specified on service "mysql"`,
377
406
}, {
378
407
        about: "bundle inception",
379
408
        content: `
388
417
func (s *deployRepoCharmStoreSuite) TestDeployBundleErrors(c *gc.C) {
389
418
        for i, test := range deployBundleErrorsTests {
390
419
                c.Logf("test %d: %s", i, test.about)
391
 
                _, err := s.deployBundleYAML(c, test.content)
 
420
                _, err := s.DeployBundleYAML(c, test.content)
392
421
                c.Assert(err, gc.ErrorMatches, test.err)
393
422
        }
394
423
}
395
424
 
396
425
func (s *deployRepoCharmStoreSuite) TestDeployBundleInvalidOptions(c *gc.C) {
397
426
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-42", "wordpress")
398
 
        _, err := s.deployBundleYAML(c, `
 
427
        _, err := s.DeployBundleYAML(c, `
399
428
        services:
400
429
            wp:
401
430
                charm: trusty/wordpress-42
408
437
 
409
438
func (s *deployRepoCharmStoreSuite) TestDeployBundleInvalidMachineContainerType(c *gc.C) {
410
439
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-42", "wordpress")
411
 
        _, err := s.deployBundleYAML(c, `
 
440
        _, err := s.DeployBundleYAML(c, `
412
441
        services:
413
442
            wp:
414
443
                charm: trusty/wordpress
422
451
 
423
452
func (s *deployRepoCharmStoreSuite) TestDeployBundleInvalidSeries(c *gc.C) {
424
453
        testcharms.UploadCharm(c, s.client, "vivid/django-0", "dummy")
425
 
        _, err := s.deployBundleYAML(c, `
 
454
        _, err := s.DeployBundleYAML(c, `
426
455
        services:
427
456
            django:
428
457
                charm: vivid/django
453
482
        testcharms.UploadCharm(c, s.client, "trusty/django-0", "dummy")
454
483
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-0", "wordpress")
455
484
        s.PatchValue(&updateUnitStatusPeriod, 0*time.Second)
456
 
        _, err := s.deployBundleYAML(c, `
 
485
        _, err := s.DeployBundleYAML(c, `
457
486
        services:
458
487
            django:
459
488
                charm: django
469
498
func (s *deployRepoCharmStoreSuite) TestDeployBundleLocalDeployment(c *gc.C) {
470
499
        testcharms.Repo.ClonedDirPath(s.SeriesPath, "mysql")
471
500
        testcharms.Repo.ClonedDirPath(s.SeriesPath, "wordpress")
472
 
        output, err := s.deployBundleYAML(c, `
 
501
        output, err := s.DeployBundleYAML(c, `
473
502
        services:
474
503
            wordpress:
475
504
                charm: local:wordpress
492
521
added wordpress/0 unit to new machine
493
522
deployment of bundle "local:bundle/example-0" completed`
494
523
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
495
 
        s.assertCharmsUplodaded(c, "local:trusty/mysql-1", "local:trusty/wordpress-3")
 
524
        s.assertCharmsUploaded(c, "local:trusty/mysql-1", "local:trusty/wordpress-3")
496
525
        s.assertServicesDeployed(c, map[string]serviceInfo{
497
526
                "mysql":     {charm: "local:trusty/mysql-1"},
498
527
                "wordpress": {charm: "local:trusty/wordpress-3"},
505
534
        })
506
535
}
507
536
 
 
537
func (s *deployRepoCharmStoreSuite) TestDeployBundleFromBundlePath(c *gc.C) {
 
538
        testcharms.Repo.ClonedDirPath(s.SeriesPath, "wordpress")
 
539
        bundlePath := filepath.Join(c.MkDir(), "example")
 
540
        err := os.Mkdir(bundlePath, 0777)
 
541
        c.Assert(err, jc.ErrorIsNil)
 
542
        err = ioutil.WriteFile(filepath.Join(bundlePath, "bundle.yaml"), []byte(`
 
543
        services:
 
544
            wordpress:
 
545
                charm: local:wordpress
 
546
                num_units: 1
 
547
    `), 0644)
 
548
        c.Assert(err, jc.ErrorIsNil)
 
549
        err = ioutil.WriteFile(filepath.Join(bundlePath, "README.md"), []byte("README"), 0644)
 
550
        c.Assert(err, jc.ErrorIsNil)
 
551
        _, err = runDeployCommand(c, bundlePath)
 
552
        c.Assert(err, jc.ErrorIsNil)
 
553
}
 
554
 
508
555
func (s *deployRepoCharmStoreSuite) TestDeployBundleLocalAndCharmStoreCharms(c *gc.C) {
509
556
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-42", "wordpress")
510
557
        testcharms.Repo.ClonedDirPath(s.SeriesPath, "mysql")
511
 
        output, err := s.deployBundleYAML(c, `
 
558
        output, err := s.DeployBundleYAML(c, `
512
559
        services:
513
560
            wordpress:
514
561
                charm: trusty/wordpress-42
530
577
added wordpress/0 unit to new machine
531
578
deployment of bundle "local:bundle/example-0" completed`
532
579
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
533
 
        s.assertCharmsUplodaded(c, "local:trusty/mysql-1", "cs:trusty/wordpress-42")
 
580
        s.assertCharmsUploaded(c, "local:trusty/mysql-1", "cs:trusty/wordpress-42")
534
581
        s.assertServicesDeployed(c, map[string]serviceInfo{
535
582
                "mysql":     {charm: "local:trusty/mysql-1"},
536
583
                "wordpress": {charm: "cs:trusty/wordpress-42"},
545
592
func (s *deployRepoCharmStoreSuite) TestDeployBundleServiceOptions(c *gc.C) {
546
593
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-42", "wordpress")
547
594
        testcharms.UploadCharm(c, s.client, "precise/dummy-0", "dummy")
548
 
        output, err := s.deployBundleYAML(c, `
 
595
        output, err := s.DeployBundleYAML(c, `
549
596
        services:
550
597
            wordpress:
551
598
                charm: wordpress
569
616
added wordpress/0 unit to new machine
570
617
deployment of bundle "local:bundle/example-0" completed`
571
618
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
572
 
        s.assertCharmsUplodaded(c, "cs:precise/dummy-0", "cs:trusty/wordpress-42")
 
619
        s.assertCharmsUploaded(c, "cs:precise/dummy-0", "cs:trusty/wordpress-42")
573
620
        s.assertServicesDeployed(c, map[string]serviceInfo{
574
621
                "customized": {
575
622
                        charm:  "cs:precise/dummy-0",
589
636
func (s *deployRepoCharmStoreSuite) TestDeployBundleServiceConstrants(c *gc.C) {
590
637
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-42", "wordpress")
591
638
        testcharms.UploadCharm(c, s.client, "precise/dummy-0", "dummy")
592
 
        output, err := s.deployBundleYAML(c, `
 
639
        output, err := s.DeployBundleYAML(c, `
593
640
        services:
594
641
            wordpress:
595
642
                charm: wordpress
608
655
added customized/0 unit to new machine
609
656
deployment of bundle "local:bundle/example-0" completed`
610
657
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
611
 
        s.assertCharmsUplodaded(c, "cs:precise/dummy-0", "cs:trusty/wordpress-42")
 
658
        s.assertCharmsUploaded(c, "cs:precise/dummy-0", "cs:trusty/wordpress-42")
612
659
        s.assertServicesDeployed(c, map[string]serviceInfo{
613
660
                "customized": {
614
661
                        charm:       "cs:precise/dummy-0",
630
677
        testcharms.UploadCharm(c, s.client, "vivid/upgrade-2", "upgrade2")
631
678
 
632
679
        // First deploy the bundle.
633
 
        output, err := s.deployBundleYAML(c, `
 
680
        output, err := s.DeployBundleYAML(c, `
634
681
        services:
635
682
            wordpress:
636
683
                charm: wordpress
652
699
added wordpress/0 unit to new machine
653
700
deployment of bundle "local:bundle/example-0" completed`
654
701
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
655
 
        s.assertCharmsUplodaded(c, "cs:vivid/upgrade-1", "cs:trusty/wordpress-42")
 
702
        s.assertCharmsUploaded(c, "cs:vivid/upgrade-1", "cs:trusty/wordpress-42")
656
703
 
657
704
        // Then deploy a new bundle with modified charm revision and options.
658
 
        output, err = s.deployBundleYAML(c, `
 
705
        output, err = s.DeployBundleYAML(c, `
659
706
        services:
660
707
            wordpress:
661
708
                charm: wordpress
679
726
avoid adding new units to service wordpress: 1 unit already present
680
727
deployment of bundle "local:bundle/example-0" completed`
681
728
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
682
 
        s.assertCharmsUplodaded(c, "cs:vivid/upgrade-1", "cs:vivid/upgrade-2", "cs:trusty/wordpress-42")
 
729
        s.assertCharmsUploaded(c, "cs:vivid/upgrade-1", "cs:vivid/upgrade-2", "cs:trusty/wordpress-42")
683
730
        s.assertServicesDeployed(c, map[string]serviceInfo{
684
731
                "up": {charm: "cs:vivid/upgrade-2"},
685
732
                "wordpress": {
711
758
        }
712
759
 
713
760
        // First deploy the bundle.
714
 
        output, err := s.deployBundleYAML(c, content)
 
761
        output, err := s.DeployBundleYAML(c, content)
715
762
        c.Assert(err, jc.ErrorIsNil)
716
763
        expectedOutput := `
717
764
added charm cs:trusty/wordpress-42
724
771
 
725
772
        // Then deploy the same bundle again: no error is produced when the service
726
773
        // is exposed again.
727
 
        output, err = s.deployBundleYAML(c, content)
 
774
        output, err = s.DeployBundleYAML(c, content)
728
775
        c.Assert(err, jc.ErrorIsNil)
729
776
        expectedOutput = `
730
777
added charm cs:trusty/wordpress-42
737
784
 
738
785
        // Then deploy a bundle with the service unexposed, and check that the
739
786
        // service is not unexposed.
740
 
        output, err = s.deployBundleYAML(c, `
 
787
        output, err = s.DeployBundleYAML(c, `
741
788
        services:
742
789
            wordpress:
743
790
                charm: wordpress
759
806
 
760
807
        // Try upgrading to a different charm name.
761
808
        testcharms.UploadCharm(c, s.client, "trusty/incompatible-42", "wordpress")
762
 
        _, err := s.deployBundleYAML(c, `
 
809
        _, err := s.DeployBundleYAML(c, `
763
810
        services:
764
811
            wordpress:
765
812
                charm: trusty/incompatible-42
767
814
    `)
768
815
        c.Assert(err, gc.ErrorMatches, `cannot deploy bundle: cannot upgrade service "wordpress": bundle charm "cs:trusty/incompatible-42" is incompatible with existing charm "local:quantal/wordpress-3"`)
769
816
 
 
817
        // Try upgrading to a different series.
 
818
        // Note that this test comes before the next one because
 
819
        // otherwise we can't resolve the charm URL because the charm's
 
820
        // "base entity" is not marked as promulgated so the query by
 
821
        // promulgated will find it.
 
822
        testcharms.UploadCharm(c, s.client, "vivid/wordpress-42", "wordpress")
 
823
        _, err = s.DeployBundleYAML(c, `
 
824
        services:
 
825
            wordpress:
 
826
                charm: vivid/wordpress
 
827
                num_units: 1
 
828
    `)
 
829
        c.Assert(err, gc.ErrorMatches, `cannot deploy bundle: cannot upgrade service "wordpress": bundle charm "cs:vivid/wordpress-42" is incompatible with existing charm "local:quantal/wordpress-3"`)
 
830
 
770
831
        // Try upgrading to a different user.
771
832
        testcharms.UploadCharm(c, s.client, "~who/trusty/wordpress-42", "wordpress")
772
 
        _, err = s.deployBundleYAML(c, `
 
833
        _, err = s.DeployBundleYAML(c, `
773
834
        services:
774
835
            wordpress:
775
836
                charm: cs:~who/trusty/wordpress-42
776
837
                num_units: 1
777
838
    `)
778
839
        c.Assert(err, gc.ErrorMatches, `cannot deploy bundle: cannot upgrade service "wordpress": bundle charm "cs:~who/trusty/wordpress-42" is incompatible with existing charm "local:quantal/wordpress-3"`)
779
 
 
780
 
        // Try upgrading to a different series.
781
 
        testcharms.UploadCharm(c, s.client, "vivid/wordpress-42", "wordpress")
782
 
        _, err = s.deployBundleYAML(c, `
783
 
        services:
784
 
            wordpress:
785
 
                charm: vivid/wordpress
786
 
                num_units: 1
787
 
    `)
788
 
        c.Assert(err, gc.ErrorMatches, `cannot deploy bundle: cannot upgrade service "wordpress": bundle charm "cs:vivid/wordpress-42" is incompatible with existing charm "local:quantal/wordpress-3"`)
789
840
}
790
841
 
791
842
func (s *deployRepoCharmStoreSuite) TestDeployBundleMultipleRelations(c *gc.C) {
793
844
        testcharms.UploadCharm(c, s.client, "trusty/mysql-1", "mysql")
794
845
        testcharms.UploadCharm(c, s.client, "trusty/postgres-2", "mysql")
795
846
        testcharms.UploadCharm(c, s.client, "trusty/varnish-3", "varnish")
796
 
        output, err := s.deployBundleYAML(c, `
 
847
        output, err := s.DeployBundleYAML(c, `
797
848
        services:
798
849
            wp:
799
850
                charm: wordpress
845
896
        testcharms.UploadCharm(c, s.client, "trusty/mysql-1", "mysql")
846
897
        testcharms.UploadCharm(c, s.client, "trusty/postgres-2", "mysql")
847
898
        testcharms.UploadCharm(c, s.client, "trusty/varnish-3", "varnish")
848
 
        _, err := s.deployBundleYAML(c, `
 
899
        _, err := s.DeployBundleYAML(c, `
849
900
        services:
850
901
            wp:
851
902
                charm: wordpress
860
911
            - ["wp:db", "mysql:server"]
861
912
    `)
862
913
        c.Assert(err, jc.ErrorIsNil)
863
 
        output, err := s.deployBundleYAML(c, `
 
914
        output, err := s.DeployBundleYAML(c, `
864
915
        services:
865
916
            wp:
866
917
                charm: wordpress
922
973
                series: trusty
923
974
            2:
924
975
    `
925
 
        output, err := s.deployBundleYAML(c, content)
 
976
        output, err := s.DeployBundleYAML(c, content)
926
977
        c.Assert(err, jc.ErrorIsNil)
927
978
        expectedOutput := `
928
979
added charm cs:trusty/mysql-2
948
999
                },
949
1000
        })
950
1001
        s.assertRelationsEstablished(c)
951
 
        s.assertUnitsCreated(c, map[string]string{
 
1002
 
 
1003
        // We explicitly pull out the map creation in the call to
 
1004
        // s.assertUnitsCreated() and create the map as a new variable
 
1005
        // because this /appears/ to tickle a bug on ppc64le using
 
1006
        // gccgo-4.9; the bug is that the map on the receiving side
 
1007
        // does not have the same contents as it does here - which is
 
1008
        // weird because that pattern is used elsewhere in this
 
1009
        // function. And just pulling the map instantiation out of the
 
1010
        // call is not enough; we need to do something benign with the
 
1011
        // variable to keep a reference beyond the call to the
 
1012
        // s.assertUnitsCreated(). I have to chosen to delete a
 
1013
        // non-existent key. This problem does not occur on amd64
 
1014
        // using gc or gccgo-4.9. Nor does it happen using go1.6 on
 
1015
        // ppc64. Once we switch to go1.6 across the board this change
 
1016
        // should be reverted. See http://pad.lv/1556116.
 
1017
        expectedUnits := map[string]string{
952
1018
                "sql/0": "0/lxc/0",
953
1019
                "sql/1": "2",
954
1020
                "wp/0":  "0",
955
1021
                "wp/1":  "1/lxc/0",
956
 
        })
 
1022
        }
 
1023
        s.assertUnitsCreated(c, expectedUnits)
 
1024
        delete(expectedUnits, "non-existent")
957
1025
 
958
1026
        // Redeploy the same bundle again.
959
 
        output, err = s.deployBundleYAML(c, content)
 
1027
        output, err = s.DeployBundleYAML(c, content)
960
1028
        c.Assert(err, jc.ErrorIsNil)
961
1029
        expectedOutput = `
962
1030
added charm cs:trusty/mysql-2
980
1048
 
981
1049
func (s *deployRepoCharmStoreSuite) TestDeployBundleMachineAttributes(c *gc.C) {
982
1050
        testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
983
 
        output, err := s.deployBundleYAML(c, `
 
1051
        output, err := s.DeployBundleYAML(c, `
984
1052
        services:
985
1053
            django:
986
1054
                charm: cs:trusty/django-42
1029
1097
 
1030
1098
func (s *deployRepoCharmStoreSuite) TestDeployBundleTwiceScaleUp(c *gc.C) {
1031
1099
        testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
1032
 
        _, err := s.deployBundleYAML(c, `
 
1100
        _, err := s.DeployBundleYAML(c, `
1033
1101
        services:
1034
1102
            django:
1035
1103
                charm: cs:trusty/django-42
1036
1104
                num_units: 2
1037
1105
    `)
1038
1106
        c.Assert(err, jc.ErrorIsNil)
1039
 
        output, err := s.deployBundleYAML(c, `
 
1107
        output, err := s.DeployBundleYAML(c, `
1040
1108
        services:
1041
1109
            django:
1042
1110
                charm: cs:trusty/django-42
1064
1132
func (s *deployRepoCharmStoreSuite) TestDeployBundleUnitPlacedInService(c *gc.C) {
1065
1133
        testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
1066
1134
        testcharms.UploadCharm(c, s.client, "trusty/wordpress-0", "wordpress")
1067
 
        output, err := s.deployBundleYAML(c, `
 
1135
        output, err := s.DeployBundleYAML(c, `
1068
1136
        services:
1069
1137
            wordpress:
1070
1138
                charm: wordpress
1100
1168
        testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
1101
1169
        testcharms.UploadCharm(c, s.client, "trusty/mem-47", "dummy")
1102
1170
        testcharms.UploadCharm(c, s.client, "trusty/rails-0", "dummy")
1103
 
        output, err := s.deployBundleYAML(c, `
 
1171
        output, err := s.DeployBundleYAML(c, `
1104
1172
        services:
1105
1173
            memcached:
1106
1174
                charm: cs:trusty/mem-47
1168
1236
 
1169
1237
func (s *deployRepoCharmStoreSuite) TestDeployBundleUnitPlacedToMachines(c *gc.C) {
1170
1238
        testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
1171
 
        output, err := s.deployBundleYAML(c, `
 
1239
        output, err := s.DeployBundleYAML(c, `
1172
1240
        services:
1173
1241
            django:
1174
1242
                charm: cs:django
1220
1288
        testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
1221
1289
        testcharms.UploadCharm(c, s.client, "trusty/mem-47", "dummy")
1222
1290
        testcharms.UploadCharm(c, s.client, "trusty/rails-0", "dummy")
1223
 
        output, err := s.deployBundleYAML(c, `
 
1291
        output, err := s.DeployBundleYAML(c, `
1224
1292
        services:
1225
1293
            memcached:
1226
1294
                charm: cs:trusty/mem-47
1308
1376
            2:
1309
1377
            3:
1310
1378
    `
1311
 
        output, err = s.deployBundleYAML(c, content)
 
1379
        output, err = s.DeployBundleYAML(c, content)
1312
1380
        c.Assert(err, jc.ErrorIsNil)
1313
1381
        expectedOutput = `
1314
1382
added charm cs:trusty/django-42
1325
1393
        c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
1326
1394
 
1327
1395
        // Redeploy the same bundle again and check that nothing happens.
1328
 
        output, err = s.deployBundleYAML(c, content)
 
1396
        output, err = s.DeployBundleYAML(c, content)
1329
1397
        c.Assert(err, jc.ErrorIsNil)
1330
1398
        expectedOutput = `
1331
1399
added charm cs:trusty/django-42
1358
1426
func (s *deployRepoCharmStoreSuite) TestDeployBundleAnnotations(c *gc.C) {
1359
1427
        testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
1360
1428
        testcharms.UploadCharm(c, s.client, "trusty/mem-47", "dummy")
1361
 
        output, err := s.deployBundleYAML(c, `
 
1429
        output, err := s.DeployBundleYAML(c, `
1362
1430
        services:
1363
1431
            django:
1364
1432
                charm: cs:django
1402
1470
        c.Assert(ann, jc.DeepEquals, map[string]string{"foo": "bar"})
1403
1471
 
1404
1472
        // Update the annotations and deploy the bundle again.
1405
 
        output, err = s.deployBundleYAML(c, `
 
1473
        output, err = s.DeployBundleYAML(c, `
1406
1474
        services:
1407
1475
            django:
1408
1476
                charm: cs:django