本文整理汇总了Golang中github.com/juju/juju/testing.CustomEnvironConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang CustomEnvironConfig函数的具体用法?Golang CustomEnvironConfig怎么用?Golang CustomEnvironConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CustomEnvironConfig函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestInitializeFromConfig
func (*NetworkSuite) TestInitializeFromConfig(c *gc.C) {
c.Check(network.GetPreferIPv6(), jc.IsFalse)
envConfig := testing.CustomEnvironConfig(c, testing.Attrs{
"prefer-ipv6": true,
})
network.InitializeFromConfig(envConfig)
c.Check(network.GetPreferIPv6(), jc.IsTrue)
envConfig = testing.CustomEnvironConfig(c, testing.Attrs{
"prefer-ipv6": false,
})
network.InitializeFromConfig(envConfig)
c.Check(network.GetPreferIPv6(), jc.IsFalse)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:15,代码来源:network_test.go
示例2: TestNewEnvironmentSameUserSameNameFails
func (s *EnvironSuite) TestNewEnvironmentSameUserSameNameFails(c *gc.C) {
cfg, _ := s.createTestEnvConfig(c)
owner := s.factory.MakeUser(c, nil).UserTag()
// Create the first environment.
_, st1, err := s.State.NewEnvironment(cfg, owner)
c.Assert(err, jc.ErrorIsNil)
defer st1.Close()
// Attempt to create another environment with a different UUID but the
// same owner and name as the first.
newUUID, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg2 := testing.CustomEnvironConfig(c, testing.Attrs{
"name": cfg.Name(),
"uuid": newUUID.String(),
})
_, _, err = s.State.NewEnvironment(cfg2, owner)
errMsg := fmt.Sprintf("environment %q for %s already exists", cfg2.Name(), owner.Username())
c.Assert(err, gc.ErrorMatches, errMsg)
c.Assert(errors.IsAlreadyExists(err), jc.IsTrue)
// Remove the first environment.
err = st1.RemoveAllEnvironDocs()
c.Assert(err, jc.ErrorIsNil)
// We should now be able to create the other environment.
env2, st2, err := s.State.NewEnvironment(cfg2, owner)
c.Assert(err, jc.ErrorIsNil)
defer st2.Close()
c.Assert(env2, gc.NotNil)
c.Assert(st2, gc.NotNil)
}
开发者ID:Pankov404,项目名称:juju,代码行数:33,代码来源:environ_test.go
示例3: TestAddInstanceTagsDoesNotSupportTagging
func (s *tagsSuite) TestAddInstanceTagsDoesNotSupportTagging(c *gc.C) {
env := &testEnviron{cfg: testing.CustomEnvironConfig(c, nil)}
err := upgrades.AddInstanceTags(env, []*state.Machine{
s.stateServer, s.unprovisioned, s.provisioned, s.container,
})
c.Assert(err, jc.ErrorIsNil)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:7,代码来源:tags_test.go
示例4: TestAddInstanceTagsSupportsTagging
func (s *tagsSuite) TestAddInstanceTagsSupportsTagging(c *gc.C) {
env := &testEnvironWithTagging{
testEnviron: testEnviron{
cfg: testing.CustomEnvironConfig(c, testing.Attrs{
"resource-tags": "abc=123",
}),
},
}
err := upgrades.AddInstanceTags(env, []*state.Machine{
s.stateServer, s.unprovisioned, s.provisioned, s.container,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(env.calls, jc.DeepEquals, []tagInstanceArgs{{
"inst-0", map[string]string{
"juju-is-state": "true",
"juju-env-uuid": testing.EnvironmentTag.Id(),
"abc": "123",
},
}, {
"inst-1", map[string]string{
"juju-env-uuid": testing.EnvironmentTag.Id(),
"abc": "123",
},
}})
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:25,代码来源:tags_test.go
示例5: createTestEnvConfig
// createTestEnvConfig returns a new environment config and its UUID for testing.
func (s *EnvironSuite) createTestEnvConfig(c *gc.C) (*config.Config, string) {
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
return testing.CustomEnvironConfig(c, testing.Attrs{
"name": "testing",
"uuid": uuid.String(),
}), uuid.String()
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:environ_test.go
示例6: newEnvironConfig
// newEnvironConfig returns an environment config map with the supplied attrs
// (on top of some default set), or fails the test.
func newEnvironConfig(c *gc.C, extraAttrs coretesting.Attrs) map[string]interface{} {
attrs := dummy.SampleConfig()
attrs["broken"] = ""
attrs["state-id"] = "42"
for k, v := range extraAttrs {
attrs[k] = v
}
return coretesting.CustomEnvironConfig(c, attrs).AllAttrs()
}
开发者ID:felicianotech,项目名称:juju,代码行数:11,代码来源:fixture_test.go
示例7: TestInstanceTagsUserSpecified
func (*instancecfgSuite) TestInstanceTagsUserSpecified(c *gc.C) {
cfg := testing.CustomEnvironConfig(c, testing.Attrs{
"resource-tags": "a=b c=",
})
testInstanceTags(c, cfg, nil, map[string]string{
"juju-env-uuid": testing.EnvironmentTag.Id(),
"a": "b",
"c": "",
})
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:instancecfg_test.go
示例8: TestInstanceTagsStateServer
func (*instancecfgSuite) TestInstanceTagsStateServer(c *gc.C) {
cfg := testing.CustomEnvironConfig(c, testing.Attrs{})
stateServerJobs := []multiwatcher.MachineJob{multiwatcher.JobManageEnviron}
nonStateServerJobs := []multiwatcher.MachineJob{multiwatcher.JobHostUnits}
testInstanceTags(c, cfg, stateServerJobs, map[string]string{
"juju-env-uuid": testing.EnvironmentTag.Id(),
"juju-is-state": "true",
})
testInstanceTags(c, cfg, nonStateServerJobs, map[string]string{
"juju-env-uuid": testing.EnvironmentTag.Id(),
})
}
开发者ID:imoapps,项目名称:juju,代码行数:12,代码来源:instancecfg_test.go
示例9: createTestEnv
func (s *blockSuite) createTestEnv(c *gc.C) (*state.Environment, *state.State) {
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg := testing.CustomEnvironConfig(c, testing.Attrs{
"name": "testing",
"uuid": uuid.String(),
})
owner := names.NewUserTag("[email protected]")
env, st, err := s.State.NewEnvironment(cfg, owner)
c.Assert(err, jc.ErrorIsNil)
return env, st
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:12,代码来源:block_test.go
示例10: newEnvWithOwner
func (s *EnvUserSuite) newEnvWithOwner(c *gc.C, name string, owner names.UserTag) *state.Environment {
// Don't use the factory to call MakeEnvironment because it may at some
// time in the future be modified to do additional things. Instead call
// the state method directly to create an environment to make sure that
// the owner is able to access the environment.
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg := testing.CustomEnvironConfig(c, testing.Attrs{
"name": name,
"uuid": uuid.String(),
})
env, st, err := s.State.NewEnvironment(cfg, owner)
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
return env
}
开发者ID:imoapps,项目名称:juju,代码行数:16,代码来源:envuser_test.go
示例11: SetConfig
// SetConfig changes the stored environment config with the given
// extraAttrs and triggers a change for the watcher.
func (s *fakeState) SetConfig(c *gc.C, extraAttrs coretesting.Attrs) {
s.mu.Lock()
defer s.mu.Unlock()
attrs := dummy.SampleConfig()
for k, v := range extraAttrs {
attrs[k] = v
}
// Simulate it's prepared.
attrs["broken"] = ""
attrs["state-id"] = "42"
s.config = coretesting.CustomEnvironConfig(c, attrs).AllAttrs()
s.changes <- struct{}{}
}
开发者ID:imoapps,项目名称:juju,代码行数:18,代码来源:environ_test.go
示例12: TestNewEnvironmentSameUserSameNameFails
func (s *EnvironSuite) TestNewEnvironmentSameUserSameNameFails(c *gc.C) {
cfg, _ := s.createTestEnvConfig(c)
owner := s.Factory.MakeUser(c, nil).UserTag()
// Create the first environment.
_, st1, err := s.State.NewEnvironment(cfg, owner)
c.Assert(err, jc.ErrorIsNil)
defer st1.Close()
// Attempt to create another environment with a different UUID but the
// same owner and name as the first.
newUUID, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg2 := testing.CustomEnvironConfig(c, testing.Attrs{
"name": cfg.Name(),
"uuid": newUUID.String(),
})
_, _, err = s.State.NewEnvironment(cfg2, owner)
errMsg := fmt.Sprintf("environment %q for %s already exists", cfg2.Name(), owner.Canonical())
c.Assert(err, gc.ErrorMatches, errMsg)
c.Assert(errors.IsAlreadyExists(err), jc.IsTrue)
// Remove the first environment.
env1, err := st1.Environment()
c.Assert(err, jc.ErrorIsNil)
err = env1.Destroy()
c.Assert(err, jc.ErrorIsNil)
// Destroy only sets the environment to dying and RemoveAllEnvironDocs can
// only be called on a dead environment. Normally, the environ's lifecycle
// would be set to dead after machines and services have been cleaned up.
err = state.SetEnvLifeDead(st1, env1.EnvironTag().Id())
c.Assert(err, jc.ErrorIsNil)
err = st1.RemoveAllEnvironDocs()
c.Assert(err, jc.ErrorIsNil)
// We should now be able to create the other environment.
env2, st2, err := s.State.NewEnvironment(cfg2, owner)
c.Assert(err, jc.ErrorIsNil)
defer st2.Close()
c.Assert(env2, gc.NotNil)
c.Assert(st2, gc.NotNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:42,代码来源:environ_test.go
示例13: MakeEnvironment
// MakeEnvironment creates an environment with specified params,
// filling in sane defaults for missing values. If params is nil,
// defaults are used for all values.
//
// By default the new enviroment shares the same owner as the calling
// Factory's environment.
func (factory *Factory) MakeEnvironment(c *gc.C, params *EnvParams) *state.State {
if params == nil {
params = new(EnvParams)
}
if params.Name == "" {
params.Name = uniqueString("testenv")
}
if params.Owner == nil {
origEnv, err := factory.st.Environment()
c.Assert(err, jc.ErrorIsNil)
params.Owner = origEnv.Owner()
}
// It only makes sense to make an environment with the same provider
// as the initial environment, or things will break elsewhere.
currentCfg, err := factory.st.EnvironConfig()
c.Assert(err, jc.ErrorIsNil)
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg := testing.CustomEnvironConfig(c, testing.Attrs{
"name": params.Name,
"uuid": uuid.String(),
"type": currentCfg.Type(),
"state-port": currentCfg.StatePort(),
"api-port": currentCfg.APIPort(),
}.Merge(params.ConfigAttrs))
_, st, err := factory.st.NewEnvironment(cfg, params.Owner.(names.UserTag))
c.Assert(err, jc.ErrorIsNil)
if params.Prepare {
// Prepare the environment.
provider, err := environs.Provider(cfg.Type())
c.Assert(err, jc.ErrorIsNil)
env, err := provider.PrepareForBootstrap(envtesting.BootstrapContext(c), cfg)
c.Assert(err, jc.ErrorIsNil)
// Now save the config back.
err = st.UpdateEnvironConfig(env.Config().AllAttrs(), nil, nil)
c.Assert(err, jc.ErrorIsNil)
}
return st
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:46,代码来源:factory.go
示例14: TestVolumeParamsStorageTags
func (*volumesSuite) TestVolumeParamsStorageTags(c *gc.C) {
volumeTag := names.NewVolumeTag("100")
storageTag := names.NewStorageTag("mystore/0")
unitTag := names.NewUnitTag("mysql/123")
p, err := storagecommon.VolumeParams(
&fakeVolume{tag: volumeTag},
&fakeStorageInstance{tag: storageTag, owner: unitTag},
testing.CustomEnvironConfig(c, nil),
&fakePoolManager{},
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(p, jc.DeepEquals, params.VolumeParams{
VolumeTag: "volume-100",
Provider: "loop",
Size: 1024,
Tags: map[string]string{
tags.JujuEnv: testing.EnvironmentTag.Id(),
tags.JujuStorageInstance: "mystore/0",
tags.JujuStorageOwner: "mysql/123",
},
})
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:22,代码来源:volumes_test.go
示例15: testVolumeParams
func (*volumesSuite) testVolumeParams(c *gc.C, provisioned bool) {
tag := names.NewVolumeTag("100")
p, err := storagecommon.VolumeParams(
&fakeVolume{tag: tag, provisioned: provisioned},
nil, // StorageInstance
testing.CustomEnvironConfig(c, testing.Attrs{
"resource-tags": "a=b c=",
}),
&fakePoolManager{},
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(p, jc.DeepEquals, params.VolumeParams{
VolumeTag: "volume-100",
Provider: "loop",
Size: 1024,
Tags: map[string]string{
tags.JujuEnv: testing.EnvironmentTag.Id(),
"a": "b",
"c": "",
},
})
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:22,代码来源:volumes_test.go
示例16: SetUp
func (sb *StubBacking) SetUp(c *gc.C, envName string, withZones, withSpaces, withSubnets SetUpFlag) {
// This method must be called at the beginning of each test, which
// needs access to any of the mocks, to reset the recorded calls
// and errors, as well as to initialize the mocks as needed.
ResetStub(sb.Stub)
// Make sure we use the stub provider.
extraAttrs := coretesting.Attrs{
"uuid": utils.MustNewUUID().String(),
"type": StubProviderType,
"name": envName,
}
sb.EnvConfig = coretesting.CustomEnvironConfig(c, extraAttrs)
sb.Zones = []providercommon.AvailabilityZone{}
if withZones {
sb.Zones = make([]providercommon.AvailabilityZone, len(ProviderInstance.Zones))
copy(sb.Zones, ProviderInstance.Zones)
}
sb.Spaces = []common.BackingSpace{}
if withSpaces {
// Note that full subnet data is generated from the SubnetIds in
// FakeSpace.Subnets().
sb.Spaces = []common.BackingSpace{
&FakeSpace{
SpaceName: "default",
SubnetIds: []string{"192.168.0.0/24", "192.168.3.0/24"},
NextErr: sb.NextErr},
&FakeSpace{
SpaceName: "dmz",
SubnetIds: []string{"192.168.1.0/24"},
NextErr: sb.NextErr},
&FakeSpace{
SpaceName: "private",
SubnetIds: []string{"192.168.2.0/24"},
NextErr: sb.NextErr},
&FakeSpace{
SpaceName: "private",
SubnetIds: []string{"192.168.2.0/24"},
NextErr: sb.NextErr}, // duplicates are ignored when caching spaces.
}
}
sb.Subnets = []common.BackingSubnet{}
if withSubnets {
info0 := common.BackingSubnetInfo{
CIDR: ProviderInstance.Subnets[0].CIDR,
ProviderId: string(ProviderInstance.Subnets[0].ProviderId),
AllocatableIPLow: ProviderInstance.Subnets[0].AllocatableIPLow.String(),
AllocatableIPHigh: ProviderInstance.Subnets[0].AllocatableIPHigh.String(),
AvailabilityZones: ProviderInstance.Subnets[0].AvailabilityZones,
SpaceName: "private",
}
info1 := common.BackingSubnetInfo{
CIDR: ProviderInstance.Subnets[1].CIDR,
ProviderId: string(ProviderInstance.Subnets[1].ProviderId),
AvailabilityZones: ProviderInstance.Subnets[1].AvailabilityZones,
SpaceName: "dmz",
}
sb.Subnets = []common.BackingSubnet{
&FakeSubnet{info0},
&FakeSubnet{info1},
}
}
}
开发者ID:mhilton,项目名称:juju,代码行数:64,代码来源:stub_network.go
注:本文中的github.com/juju/juju/testing.CustomEnvironConfig函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论