本文整理汇总了Golang中github.com/juju/juju/testcharms.UploadCharm函数的典型用法代码示例。如果您正苦于以下问题:Golang UploadCharm函数的具体用法?Golang UploadCharm怎么用?Golang UploadCharm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UploadCharm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestDeployBundleWithAnnotations_OutputIsCorrect
func (s *BundleDeployCharmStoreSuite) TestDeployBundleWithAnnotations_OutputIsCorrect(c *gc.C) {
testcharms.UploadCharm(c, s.client, "xenial/django-42", "dummy")
testcharms.UploadCharm(c, s.client, "xenial/mem-47", "dummy")
output, err := s.DeployBundleYAML(c, `
applications:
django:
charm: cs:django
num_units: 1
annotations:
key1: value1
key2: value2
to: [1]
memcached:
charm: xenial/mem-47
num_units: 1
machines:
1:
annotations: {foo: bar}
`)
c.Assert(err, jc.ErrorIsNil)
c.Check(output, gc.Equals, ""+
`Deploying charm "cs:xenial/django-42"`+"\n"+
`Deploying charm "cs:xenial/mem-47"`+"\n"+
`Deploy of bundle completed.`,
)
}
示例2: TestSwitch
func (s *UpgradeCharmCharmStoreStateSuite) TestSwitch(c *gc.C) {
testcharms.UploadCharm(c, s.client, "cs:~other/trusty/riak-0", "riak")
testcharms.UploadCharm(c, s.client, "cs:~other/trusty/anotherriak-7", "riak")
err := runDeploy(c, "cs:~other/trusty/riak-0")
c.Assert(err, jc.ErrorIsNil)
riak, err := s.State.Application("riak")
c.Assert(err, jc.ErrorIsNil)
ch, forced, err := riak.Charm()
c.Assert(err, jc.ErrorIsNil)
c.Assert(ch.Revision(), gc.Equals, 0)
c.Assert(forced, jc.IsFalse)
err = runUpgradeCharm(c, "riak", "--switch=cs:~other/trusty/anotherriak")
c.Assert(err, jc.ErrorIsNil)
curl := s.assertUpgraded(c, riak, 7, false)
c.Assert(curl.String(), gc.Equals, "cs:~other/trusty/anotherriak-7")
// Now try the same with explicit revision - should fail.
err = runUpgradeCharm(c, "riak", "--switch=cs:~other/trusty/anotherriak-7")
c.Assert(err, gc.ErrorMatches, `already running specified charm "cs:~other/trusty/anotherriak-7"`)
// Change the revision to 42 and upgrade to it with explicit revision.
testcharms.UploadCharm(c, s.client, "cs:~other/trusty/anotherriak-42", "riak")
err = runUpgradeCharm(c, "riak", "--switch=cs:~other/trusty/anotherriak-42")
c.Assert(err, jc.ErrorIsNil)
curl = s.assertUpgraded(c, riak, 42, false)
c.Assert(curl.String(), gc.Equals, "cs:~other/trusty/anotherriak-42")
}
示例3: TestDeployAuthorization
func (s *DeployCharmStoreSuite) TestDeployAuthorization(c *gc.C) {
// Upload the two charms required to upload the bundle.
testcharms.UploadCharm(c, s.client, "trusty/mysql-0", "mysql")
testcharms.UploadCharm(c, s.client, "trusty/wordpress-1", "wordpress")
// Run the tests.
for i, test := range deployAuthorizationTests {
c.Logf("test %d: %s", i, test.about)
// Upload the charm or bundle under test.
url := charm.MustParseURL(test.uploadURL)
if url.Series == "bundle" {
url, _ = testcharms.UploadBundle(c, s.client, test.uploadURL, "wordpress-simple")
} else {
url, _ = testcharms.UploadCharm(c, s.client, test.uploadURL, "wordpress")
}
// Change the ACL of the uploaded entity if required in this case.
if test.readPermUser != "" {
s.changeReadPerm(c, url, test.readPermUser)
}
ctx, err := coretesting.RunCommand(c, envcmd.Wrap(&deployCommand{}), test.deployURL, fmt.Sprintf("wordpress%d", i))
if test.expectError != "" {
c.Assert(err, gc.ErrorMatches, test.expectError)
continue
}
c.Assert(err, jc.ErrorIsNil)
output := strings.Trim(coretesting.Stderr(ctx), "\n")
c.Assert(output, gc.Equals, strings.TrimSpace(test.expectOutput))
}
}
示例4: TestDeployBundleApplicationConstrants
func (s *BundleDeployCharmStoreSuite) TestDeployBundleApplicationConstrants(c *gc.C) {
testcharms.UploadCharm(c, s.client, "xenial/wordpress-42", "wordpress")
testcharms.UploadCharm(c, s.client, "precise/dummy-0", "dummy")
_, err := s.DeployBundleYAML(c, `
applications:
wordpress:
charm: wordpress
constraints: mem=4G cores=2
customized:
charm: precise/dummy-0
num_units: 1
constraints: arch=i386
`)
c.Assert(err, jc.ErrorIsNil)
s.assertCharmsUploaded(c, "cs:precise/dummy-0", "cs:xenial/wordpress-42")
s.assertApplicationsDeployed(c, map[string]serviceInfo{
"customized": {
charm: "cs:precise/dummy-0",
constraints: constraints.MustParse("arch=i386"),
},
"wordpress": {
charm: "cs:xenial/wordpress-42",
constraints: constraints.MustParse("mem=4G cores=2"),
},
})
s.assertUnitsCreated(c, map[string]string{
"customized/0": "0",
})
}
示例5: TestDeployBundleUnitPlacedInService
func (s *deployRepoCharmStoreSuite) TestDeployBundleUnitPlacedInService(c *gc.C) {
testcharms.UploadCharm(c, s.client, "trusty/django-42", "dummy")
testcharms.UploadCharm(c, s.client, "trusty/wordpress-0", "wordpress")
output, err := s.deployBundleYAML(c, `
services:
wordpress:
charm: wordpress
num_units: 3
django:
charm: cs:trusty/django-42
num_units: 2
to: [wordpress]
`)
c.Assert(err, jc.ErrorIsNil)
expectedOutput := `
added charm cs:trusty/django-42
service django deployed (charm: cs:trusty/django-42)
added charm cs:trusty/wordpress-0
service wordpress deployed (charm: cs:trusty/wordpress-0)
added wordpress/0 unit to new machine
added wordpress/1 unit to new machine
added wordpress/2 unit to new machine
added django/0 unit to machine 0
added django/1 unit to machine 1
deployment of bundle "local:bundle/example-0" completed`
c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
s.assertUnitsCreated(c, map[string]string{
"django/0": "0",
"django/1": "1",
"wordpress/0": "0",
"wordpress/1": "1",
"wordpress/2": "2",
})
}
示例6: TestDeployBundleApplicationOptions
func (s *BundleDeployCharmStoreSuite) TestDeployBundleApplicationOptions(c *gc.C) {
testcharms.UploadCharm(c, s.client, "xenial/wordpress-42", "wordpress")
testcharms.UploadCharm(c, s.client, "precise/dummy-0", "dummy")
_, err := s.DeployBundleYAML(c, `
applications:
wordpress:
charm: wordpress
num_units: 1
options:
blog-title: these are the voyages
customized:
charm: precise/dummy-0
num_units: 1
options:
username: who
skill-level: 47
`)
c.Assert(err, jc.ErrorIsNil)
s.assertCharmsUploaded(c, "cs:precise/dummy-0", "cs:xenial/wordpress-42")
s.assertApplicationsDeployed(c, map[string]serviceInfo{
"customized": {
charm: "cs:precise/dummy-0",
config: charm.Settings{"username": "who", "skill-level": int64(47)},
},
"wordpress": {
charm: "cs:xenial/wordpress-42",
config: charm.Settings{"blog-title": "these are the voyages"},
},
})
s.assertUnitsCreated(c, map[string]string{
"wordpress/0": "1",
"customized/0": "0",
})
}
示例7: TestDeployBundleStorage
func (s *BundleDeployCharmStoreSuite) TestDeployBundleStorage(c *gc.C) {
testcharms.UploadCharm(c, s.client, "xenial/mysql-42", "mysql-storage")
testcharms.UploadCharm(c, s.client, "xenial/wordpress-47", "wordpress")
testcharms.UploadBundle(c, s.client, "bundle/wordpress-with-mysql-storage-1", "wordpress-with-mysql-storage")
_, err := runDeployCommand(
c, "bundle/wordpress-with-mysql-storage",
"--storage", "mysql:logs=tmpfs,10G", // override logs
)
c.Assert(err, jc.ErrorIsNil)
s.assertCharmsUploaded(c, "cs:xenial/mysql-42", "cs:xenial/wordpress-47")
s.assertApplicationsDeployed(c, map[string]serviceInfo{
"mysql": {
charm: "cs:xenial/mysql-42",
storage: map[string]state.StorageConstraints{
"data": state.StorageConstraints{Pool: "rootfs", Size: 50 * 1024, Count: 1},
"logs": state.StorageConstraints{Pool: "tmpfs", Size: 10 * 1024, Count: 1},
},
},
"wordpress": {charm: "cs:xenial/wordpress-47"},
})
s.assertRelationsEstablished(c, "wordpress:db mysql:server")
s.assertUnitsCreated(c, map[string]string{
"mysql/0": "0",
"wordpress/0": "1",
})
}
示例8: TestDeployBundleWatcherTimeout
func (s *deployRepoCharmStoreSuite) TestDeployBundleWatcherTimeout(c *gc.C) {
// Inject an "AllWatcher" that never delivers a result.
ch := make(chan struct{})
defer close(ch)
watcher := mockAllWatcher{
next: func() []multiwatcher.Delta {
<-ch
return nil
},
}
s.PatchValue(&watchAll, func(*api.Client) (allWatcher, error) {
return watcher, nil
})
testcharms.UploadCharm(c, s.client, "trusty/django-0", "dummy")
testcharms.UploadCharm(c, s.client, "trusty/wordpress-0", "wordpress")
s.PatchValue(&updateUnitStatusPeriod, 0*time.Second)
_, err := s.deployBundleYAML(c, `
services:
django:
charm: django
num_units: 1
wordpress:
charm: wordpress
num_units: 1
to: [django]
`)
c.Assert(err, gc.ErrorMatches, `cannot deploy bundle: cannot retrieve placement for "wordpress" unit: cannot resolve machine: timeout while trying to get new changes from the watcher`)
}
示例9: TestDeployBundleServiceUpgradeFailure
func (s *deployRepoCharmStoreSuite) TestDeployBundleServiceUpgradeFailure(c *gc.C) {
s.AddTestingService(c, "wordpress", s.AddTestingCharm(c, "wordpress"))
// Try upgrading to a different charm name.
testcharms.UploadCharm(c, s.client, "trusty/incompatible-42", "wordpress")
_, err := s.deployBundleYAML(c, `
services:
wordpress:
charm: trusty/incompatible-42
num_units: 1
`)
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"`)
// Try upgrading to a different user.
testcharms.UploadCharm(c, s.client, "~who/trusty/wordpress-42", "wordpress")
_, err = s.deployBundleYAML(c, `
services:
wordpress:
charm: cs:~who/trusty/wordpress-42
num_units: 1
`)
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"`)
// Try upgrading to a different series.
testcharms.UploadCharm(c, s.client, "vivid/wordpress-42", "wordpress")
_, err = s.deployBundleYAML(c, `
services:
wordpress:
charm: vivid/wordpress
num_units: 1
`)
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"`)
}
示例10: TestDeployBundleWithTermsSuccess
func (s *DeployCharmStoreSuite) TestDeployBundleWithTermsSuccess(c *gc.C) {
testcharms.UploadCharm(c, s.client, "trusty/terms1-17", "terms1")
testcharms.UploadCharm(c, s.client, "trusty/terms2-42", "terms2")
testcharms.UploadBundle(c, s.client, "bundle/terms-simple-1", "terms-simple")
output, err := runDeployCommand(c, "bundle/terms-simple")
c.Assert(err, jc.ErrorIsNil)
expectedOutput := `
added charm cs:trusty/terms1-17
service terms1 deployed (charm: cs:trusty/terms1-17)
added charm cs:trusty/terms2-42
service terms2 deployed (charm: cs:trusty/terms2-42)
added terms1/0 unit to new machine
added terms2/0 unit to new machine
deployment of bundle "cs:bundle/terms-simple-1" completed`
c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
s.assertCharmsUplodaded(c, "cs:trusty/terms1-17", "cs:trusty/terms2-42")
s.assertServicesDeployed(c, map[string]serviceInfo{
"terms1": {charm: "cs:trusty/terms1-17"},
"terms2": {charm: "cs:trusty/terms2-42"},
})
s.assertUnitsCreated(c, map[string]string{
"terms1/0": "0",
"terms2/0": "1",
})
c.Assert(s.termsString, gc.Not(gc.Equals), "")
}
示例11: TestDeployBundleSuccess
func (s *DeployCharmStoreSuite) TestDeployBundleSuccess(c *gc.C) {
testcharms.UploadCharm(c, s.client, "trusty/mysql-42", "mysql")
testcharms.UploadCharm(c, s.client, "trusty/wordpress-47", "wordpress")
testcharms.UploadBundle(c, s.client, "bundle/wordpress-simple-1", "wordpress-simple")
output, err := runDeployCommand(c, "bundle/wordpress-simple")
c.Assert(err, jc.ErrorIsNil)
expectedOutput := `
added charm cs:trusty/mysql-42
service mysql deployed (charm: cs:trusty/mysql-42)
added charm cs:trusty/wordpress-47
service wordpress deployed (charm: cs:trusty/wordpress-47)
related wordpress:db and mysql:server
added mysql/0 unit to new machine
added wordpress/0 unit to new machine
deployment of bundle "cs:bundle/wordpress-simple-1" completed`
c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
s.assertCharmsUplodaded(c, "cs:trusty/mysql-42", "cs:trusty/wordpress-47")
s.assertServicesDeployed(c, map[string]serviceInfo{
"mysql": {charm: "cs:trusty/mysql-42"},
"wordpress": {charm: "cs:trusty/wordpress-47"},
})
s.assertRelationsEstablished(c, "wordpress:db mysql:server")
s.assertUnitsCreated(c, map[string]string{
"mysql/0": "0",
"wordpress/0": "1",
})
}
示例12: TestDeployBundleMultipleRelations
func (s *BundleDeployCharmStoreSuite) TestDeployBundleMultipleRelations(c *gc.C) {
testcharms.UploadCharm(c, s.client, "xenial/wordpress-0", "wordpress")
testcharms.UploadCharm(c, s.client, "xenial/mysql-1", "mysql")
testcharms.UploadCharm(c, s.client, "xenial/postgres-2", "mysql")
testcharms.UploadCharm(c, s.client, "xenial/varnish-3", "varnish")
_, err := s.DeployBundleYAML(c, `
applications:
wp:
charm: wordpress
num_units: 1
mysql:
charm: mysql
num_units: 1
pgres:
charm: xenial/postgres-2
num_units: 1
varnish:
charm: xenial/varnish
num_units: 1
relations:
- ["wp:db", "mysql:server"]
- ["wp:db", "pgres:server"]
- ["varnish:webcache", "wp:cache"]
`)
c.Assert(err, jc.ErrorIsNil)
s.assertRelationsEstablished(c, "wp:db mysql:server", "wp:db pgres:server", "wp:cache varnish:webcache")
s.assertUnitsCreated(c, map[string]string{
"mysql/0": "0",
"pgres/0": "1",
"varnish/0": "2",
"wp/0": "3",
})
}
示例13: TestDeployBundleGatedCharmUnauthorized
func (s *DeployCharmStoreSuite) TestDeployBundleGatedCharmUnauthorized(c *gc.C) {
testcharms.UploadCharm(c, s.client, "trusty/mysql-42", "mysql")
url, _ := testcharms.UploadCharm(c, s.client, "trusty/wordpress-47", "wordpress")
s.changeReadPerm(c, url, "who")
testcharms.UploadBundle(c, s.client, "bundle/wordpress-simple-1", "wordpress-simple")
_, err := runDeployCommand(c, "bundle/wordpress-simple")
c.Assert(err, gc.ErrorMatches, `cannot deploy bundle: .*: unauthorized: access denied for user "client-username"`)
}
示例14: TestDeployBundleNewRelations
func (s *deployRepoCharmStoreSuite) TestDeployBundleNewRelations(c *gc.C) {
testcharms.UploadCharm(c, s.client, "trusty/wordpress-0", "wordpress")
testcharms.UploadCharm(c, s.client, "trusty/mysql-1", "mysql")
testcharms.UploadCharm(c, s.client, "trusty/postgres-2", "mysql")
testcharms.UploadCharm(c, s.client, "trusty/varnish-3", "varnish")
_, err := s.deployBundleYAML(c, `
services:
wp:
charm: wordpress
num_units: 1
mysql:
charm: mysql
num_units: 1
varnish:
charm: trusty/varnish
num_units: 1
relations:
- ["wp:db", "mysql:server"]
`)
c.Assert(err, jc.ErrorIsNil)
output, err := s.deployBundleYAML(c, `
services:
wp:
charm: wordpress
num_units: 1
mysql:
charm: mysql
num_units: 1
varnish:
charm: trusty/varnish
num_units: 1
relations:
- ["wp:db", "mysql:server"]
- ["varnish:webcache", "wp:cache"]
`)
c.Assert(err, jc.ErrorIsNil)
expectedOutput := `
added charm cs:trusty/mysql-1
reusing service mysql (charm: cs:trusty/mysql-1)
added charm cs:trusty/varnish-3
reusing service varnish (charm: cs:trusty/varnish-3)
added charm cs:trusty/wordpress-0
reusing service wp (charm: cs:trusty/wordpress-0)
wp:db and mysql:server are already related
related varnish:webcache and wp:cache
avoid adding new units to service mysql: 1 unit already present
avoid adding new units to service varnish: 1 unit already present
avoid adding new units to service wp: 1 unit already present
deployment of bundle "local:bundle/example-0" completed`
c.Assert(output, gc.Equals, strings.TrimSpace(expectedOutput))
s.assertRelationsEstablished(c, "wp:db mysql:server", "wp:cache varnish:webcache")
s.assertUnitsCreated(c, map[string]string{
"mysql/0": "0",
"varnish/0": "1",
"wp/0": "2",
})
}
示例15: TestDeployBundleInvalidFlags
func (s *DeployCharmStoreSuite) TestDeployBundleInvalidFlags(c *gc.C) {
testcharms.UploadCharm(c, s.client, "trusty/mysql-42", "mysql")
testcharms.UploadCharm(c, s.client, "trusty/wordpress-47", "wordpress")
testcharms.UploadBundle(c, s.client, "bundle/wordpress-simple-1", "wordpress-simple")
_, err := runDeployCommand(c, "bundle/wordpress-simple", "--config", "config.yaml")
c.Assert(err, gc.ErrorMatches, "Flags provided but not supported when deploying a bundle: --config.")
_, err = runDeployCommand(c, "bundle/wordpress-simple", "-n", "2")
c.Assert(err, gc.ErrorMatches, "Flags provided but not supported when deploying a bundle: -n.")
_, err = runDeployCommand(c, "bundle/wordpress-simple", "--series", "trusty", "--force")
c.Assert(err, gc.ErrorMatches, "Flags provided but not supported when deploying a bundle: --force, --series.")
}