本文整理汇总了Golang中github.com/juju/juju/testing.CustomModelConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang CustomModelConfig函数的具体用法?Golang CustomModelConfig怎么用?Golang CustomModelConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CustomModelConfig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestInitializeFromConfig
func (*NetworkSuite) TestInitializeFromConfig(c *gc.C) {
c.Check(network.PreferIPv6(), jc.IsFalse)
envConfig := testing.CustomModelConfig(c, testing.Attrs{
"prefer-ipv6": true,
})
network.SetPreferIPv6(envConfig.PreferIPv6())
c.Check(network.PreferIPv6(), jc.IsTrue)
envConfig = testing.CustomModelConfig(c, testing.Attrs{
"prefer-ipv6": false,
})
network.SetPreferIPv6(envConfig.PreferIPv6())
c.Check(network.PreferIPv6(), jc.IsFalse)
}
开发者ID:pmatulis,项目名称:juju,代码行数:15,代码来源:network_test.go
示例2: SetUpTest
func (s *Suite) SetUpTest(c *gc.C) {
// Set up InitialConfig with a dummy provider configuration. This
// is required to allow model import test to work.
env, err := environs.Prepare(
modelcmd.BootstrapContext(testing.Context(c)),
jujuclienttesting.NewMemStore(),
environs.PrepareParams{
ControllerName: "dummycontroller",
BaseConfig: dummy.SampleConfig(),
CloudName: "dummy",
},
)
c.Assert(err, jc.ErrorIsNil)
s.InitialConfig = testing.CustomModelConfig(c, env.Config().AllAttrs())
// The call up to StateSuite's SetUpTest uses s.InitialConfig so
// it has to happen here.
s.StateSuite.SetUpTest(c)
s.resources = common.NewResources()
s.AddCleanup(func(*gc.C) { s.resources.StopAll() })
s.authorizer = apiservertesting.FakeAuthorizer{
Tag: s.Owner,
}
}
开发者ID:makyo,项目名称:juju,代码行数:26,代码来源:migrationtarget_test.go
示例3: ModelConfig
func (sb *stubBackend) ModelConfig() (*config.Config, error) {
sb.MethodCall(sb, "ModelConfig")
if err := sb.NextErr(); err != nil {
return nil, err
}
return coretesting.CustomModelConfig(sb.c, sb.configAttrs), nil
}
开发者ID:makyo,项目名称:juju,代码行数:7,代码来源:proxyupdater_test.go
示例4: TestNewModelSameUserSameNameFails
func (s *ModelSuite) TestNewModelSameUserSameNameFails(c *gc.C) {
cfg, _ := s.createTestModelConfig(c)
owner := s.Factory.MakeUser(c, nil).UserTag()
// Create the first model.
_, st1, err := s.State.NewModel(state.ModelArgs{
CloudName: "dummy",
CloudRegion: "dummy-region",
Config: cfg,
Owner: owner,
StorageProviderRegistry: storage.StaticProviderRegistry{},
})
c.Assert(err, jc.ErrorIsNil)
defer st1.Close()
// Attempt to create another model with a different UUID but the
// same owner and name as the first.
newUUID, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg2 := testing.CustomModelConfig(c, testing.Attrs{
"name": cfg.Name(),
"uuid": newUUID.String(),
})
_, _, err = s.State.NewModel(state.ModelArgs{
CloudName: "dummy",
CloudRegion: "dummy-region",
Config: cfg2,
Owner: owner,
StorageProviderRegistry: storage.StaticProviderRegistry{},
})
errMsg := fmt.Sprintf("model %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 model.
env1, err := st1.Model()
c.Assert(err, jc.ErrorIsNil)
err = env1.Destroy()
c.Assert(err, jc.ErrorIsNil)
// Destroy only sets the model to dying and RemoveAllModelDocs can
// only be called on a dead model. Normally, the environ's lifecycle
// would be set to dead after machines and services have been cleaned up.
err = state.SetModelLifeDead(st1, env1.ModelTag().Id())
c.Assert(err, jc.ErrorIsNil)
err = st1.RemoveAllModelDocs()
c.Assert(err, jc.ErrorIsNil)
// We should now be able to create the other model.
env2, st2, err := s.State.NewModel(state.ModelArgs{
CloudName: "dummy",
CloudRegion: "dummy-region",
Config: cfg2,
Owner: owner,
StorageProviderRegistry: storage.StaticProviderRegistry{},
})
c.Assert(err, jc.ErrorIsNil)
defer st2.Close()
c.Assert(env2, gc.NotNil)
c.Assert(st2, gc.NotNil)
}
开发者ID:kat-co,项目名称:juju,代码行数:60,代码来源:model_test.go
示例5: 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, params: &state.VolumeParams{
Pool: "loop", Size: 1024,
}},
&fakeStorageInstance{tag: storageTag, owner: unitTag},
testing.CustomModelConfig(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.JujuController: testing.ModelTag.Id(),
tags.JujuModel: testing.ModelTag.Id(),
tags.JujuStorageInstance: "mystore/0",
tags.JujuStorageOwner: "mysql/123",
},
})
}
开发者ID:makyo,项目名称:juju,代码行数:25,代码来源:volumes_test.go
示例6: MakeModel
// MakeModel creates an model with specified params,
// filling in sane defaults for missing values. If params is nil,
// defaults are used for all values.
//
// By default the new model shares the same owner as the calling
// Factory's model.
func (factory *Factory) MakeModel(c *gc.C, params *ModelParams) *state.State {
if params == nil {
params = new(ModelParams)
}
if params.Name == "" {
params.Name = uniqueString("testenv")
}
if params.Owner == nil {
origEnv, err := factory.st.Model()
c.Assert(err, jc.ErrorIsNil)
params.Owner = origEnv.Owner()
}
// It only makes sense to make an model with the same provider
// as the initial model, or things will break elsewhere.
currentCfg, err := factory.st.ModelConfig()
c.Assert(err, jc.ErrorIsNil)
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg := testing.CustomModelConfig(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.NewModel(state.ModelArgs{
Config: cfg,
Owner: params.Owner.(names.UserTag),
})
c.Assert(err, jc.ErrorIsNil)
return st
}
开发者ID:makyo,项目名称:juju,代码行数:39,代码来源:factory.go
示例7: testVolumeParams
func (*volumesSuite) testVolumeParams(c *gc.C, volumeParams *state.VolumeParams, info *state.VolumeInfo) {
tag := names.NewVolumeTag("100")
p, err := storagecommon.VolumeParams(
&fakeVolume{tag: tag, params: volumeParams, info: info},
nil, // StorageInstance
testing.ModelTag.Id(),
testing.ControllerTag.Id(),
testing.CustomModelConfig(c, testing.Attrs{
"resource-tags": "a=b c=",
}),
&fakePoolManager{},
provider.CommonStorageProviders(),
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(p, jc.DeepEquals, params.VolumeParams{
VolumeTag: "volume-100",
Provider: "loop",
Size: 1024,
Tags: map[string]string{
tags.JujuController: testing.ControllerTag.Id(),
tags.JujuModel: testing.ModelTag.Id(),
"a": "b",
"c": "",
},
})
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:volumes_test.go
示例8: TestNewModelConfigForksControllerValue
func (s *ModelConfigSourceSuite) TestNewModelConfigForksControllerValue(c *gc.C) {
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg := testing.CustomModelConfig(c, testing.Attrs{
"name": "another",
"uuid": uuid.String(),
})
owner := names.NewUserTag("[email protected]")
_, st, err := s.State.NewModel(state.ModelArgs{
Config: cfg, Owner: owner, CloudName: "dummy", CloudRegion: "nether-region",
StorageProviderRegistry: storage.StaticProviderRegistry{},
})
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
modelCfg, err := st.ModelConfig()
c.Assert(err, jc.ErrorIsNil)
c.Assert(modelCfg.AllAttrs()["apt-mirror"], gc.Equals, "http://mirror")
// Change the local controller settings and ensure the model setting stays the same.
localCloudSettings, err := s.State.ReadSettings(state.GlobalSettingsC, state.ControllerInheritedSettingsGlobalKey)
c.Assert(err, jc.ErrorIsNil)
localCloudSettings.Set("apt-mirror", "http://anothermirror")
_, err = localCloudSettings.Write()
c.Assert(err, jc.ErrorIsNil)
modelCfg, err = st.ModelConfig()
c.Assert(err, jc.ErrorIsNil)
c.Assert(modelCfg.AllAttrs()["apt-mirror"], gc.Equals, "http://mirror")
}
开发者ID:bac,项目名称:juju,代码行数:30,代码来源:modelconfig_test.go
示例9: SetUpTest
func (s *binaryStorageSuite) SetUpTest(c *gc.C) {
s.ConnSuite.SetUpTest(c)
// Store the controller UUID.
model, err := s.State.ControllerModel()
c.Assert(err, jc.ErrorIsNil)
s.controllerUUID = model.UUID()
// Create a new model and store its UUID.
s.modelUUID = utils.MustNewUUID().String()
cfg := testing.CustomModelConfig(c, testing.Attrs{
"name": "new-model",
"uuid": s.modelUUID,
})
_, s.st, err = s.State.NewModel(state.ModelArgs{
CloudName: "dummy",
CloudRegion: "dummy-region",
Config: cfg,
Owner: names.NewLocalUserTag("test-admin"),
StorageProviderRegistry: storage.StaticProviderRegistry{},
})
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(*gc.C) {
s.st.Close()
})
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:binarystorage_test.go
示例10: createTestEnvConfig
// createTestEnvConfig returns a new model config and its UUID for testing.
func (s *ModelSuite) createTestEnvConfig(c *gc.C) (*config.Config, string) {
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
return testing.CustomModelConfig(c, testing.Attrs{
"name": "testing",
"uuid": uuid.String(),
}), uuid.String()
}
开发者ID:makyo,项目名称:juju,代码行数:9,代码来源:model_test.go
示例11: newModelConfig
// newModelConfig returns an environment config map with the supplied attrs
// (on top of some default set), or fails the test.
func newModelConfig(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.CustomModelConfig(c, attrs).AllAttrs()
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:fixture_test.go
示例12: TestInstanceTagsUserSpecified
func (*instancecfgSuite) TestInstanceTagsUserSpecified(c *gc.C) {
cfg := testing.CustomModelConfig(c, testing.Attrs{
"resource-tags": "a=b c=",
})
testInstanceTags(c, cfg, nil, map[string]string{
"juju-model-uuid": testing.ModelTag.Id(),
"a": "b",
"c": "",
})
}
开发者ID:pmatulis,项目名称:juju,代码行数:10,代码来源:instancecfg_test.go
示例13: SetUpTest
func (s *ImportSuite) SetUpTest(c *gc.C) {
// Specify the config to use for the controller model before calling
// SetUpTest of the StateSuite, otherwise we get testing.ModelConfig(c).
// The default provider type specified in the testing.ModelConfig function
// is one that isn't registered as a valid provider. For our tests here we
// need a real registered provider, so we use the dummy provider.
// NOTE: make a better test provider.
s.InitialConfig = testing.CustomModelConfig(c, dummy.SampleConfig())
s.StateSuite.SetUpTest(c)
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:migration_test.go
示例14: createTestModelConfig
func createTestModelConfig(c *gc.C, controllerUUID string) (*config.Config, string) {
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
if controllerUUID == "" {
controllerUUID = uuid.String()
}
return testing.CustomModelConfig(c, testing.Attrs{
"name": "testing",
"uuid": uuid.String(),
}), uuid.String()
}
开发者ID:kat-co,项目名称:juju,代码行数:11,代码来源:model_test.go
示例15: NewStateForModelNamed
// NewStateForModelNamed returns an new model with the given modelName, which
// has a unique UUID, and does not need to be closed when the test completes.
func (s *ConnSuite) NewStateForModelNamed(c *gc.C, modelName string) *state.State {
cfg := testing.CustomModelConfig(c, testing.Attrs{
"name": modelName,
"uuid": utils.MustNewUUID().String(),
})
otherOwner := names.NewLocalUserTag("test-admin")
_, otherState, err := s.State.NewModel(cfg, otherOwner)
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(*gc.C) { otherState.Close() })
return otherState
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:14,代码来源:conn_test.go
示例16: createTestEnv
func (s *blockSuite) createTestEnv(c *gc.C) (*state.Model, *state.State) {
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg := testing.CustomModelConfig(c, testing.Attrs{
"name": "testing",
"uuid": uuid.String(),
})
owner := names.NewUserTag("[email protected]")
env, st, err := s.State.NewModel(state.ModelArgs{Config: cfg, Owner: owner})
c.Assert(err, jc.ErrorIsNil)
return env, st
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:block_test.go
示例17: TestInstanceTagsStateServer
func (*instancecfgSuite) TestInstanceTagsStateServer(c *gc.C) {
cfg := testing.CustomModelConfig(c, testing.Attrs{})
stateServerJobs := []multiwatcher.MachineJob{multiwatcher.JobManageModel}
nonStateServerJobs := []multiwatcher.MachineJob{multiwatcher.JobHostUnits}
testInstanceTags(c, cfg, stateServerJobs, map[string]string{
"juju-model-uuid": testing.ModelTag.Id(),
"juju-is-state": "true",
})
testInstanceTags(c, cfg, nonStateServerJobs, map[string]string{
"juju-model-uuid": testing.ModelTag.Id(),
})
}
开发者ID:pmatulis,项目名称:juju,代码行数:12,代码来源:instancecfg_test.go
示例18: NewStateForModelNamed
// NewStateForModelNamed returns an new model with the given modelName, which
// has a unique UUID, and does not need to be closed when the test completes.
func (s *ConnWithWallClockSuite) NewStateForModelNamed(c *gc.C, modelName string) *state.State {
cfg := testing.CustomModelConfig(c, testing.Attrs{
"name": modelName,
"uuid": utils.MustNewUUID().String(),
})
otherOwner := names.NewLocalUserTag("test-admin")
_, otherState, err := s.State.NewModel(state.ModelArgs{
CloudName: "dummy", CloudRegion: "dummy-region", Config: cfg, Owner: otherOwner,
StorageProviderRegistry: storage.StaticProviderRegistry{},
})
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(*gc.C) { otherState.Close() })
return otherState
}
开发者ID:bac,项目名称:juju,代码行数:17,代码来源:conn_wallclock_test.go
示例19: createTestEnv
func (s *AnnotationsEnvSuite) createTestEnv(c *gc.C) (*state.Model, *state.State) {
uuid, err := utils.NewUUID()
c.Assert(err, jc.ErrorIsNil)
cfg := testing.CustomModelConfig(c, testing.Attrs{
"name": "testing",
"uuid": uuid.String(),
})
owner := names.NewUserTag("[email protected]")
env, st, err := s.State.NewModel(state.ModelArgs{
CloudName: "dummy", CloudRegion: "dummy-region", Config: cfg, Owner: owner,
StorageProviderRegistry: storage.StaticProviderRegistry{},
})
c.Assert(err, jc.ErrorIsNil)
return env, st
}
开发者ID:bac,项目名称:juju,代码行数:15,代码来源:annotations_test.go
示例20: testBadModelConfig
func (s *InitializeSuite) testBadModelConfig(c *gc.C, update map[string]interface{}, remove []string, expect string) {
good := testing.CustomModelConfig(c, testing.Attrs{"uuid": testing.ModelTag.Id()})
bad, err := good.Apply(update)
c.Assert(err, jc.ErrorIsNil)
bad, err = bad.Remove(remove)
c.Assert(err, jc.ErrorIsNil)
owner := names.NewLocalUserTag("initialize-admin")
controllerCfg := testing.FakeControllerConfig()
args := state.InitializeParams{
Clock: clock.WallClock,
ControllerConfig: controllerCfg,
ControllerModelArgs: state.ModelArgs{
CloudName: "dummy",
CloudRegion: "dummy-region",
Owner: owner,
Config: bad,
StorageProviderRegistry: storage.StaticProviderRegistry{},
},
CloudName: "dummy",
Cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
Regions: []cloud.Region{{Name: "dummy-region"}},
},
MongoInfo: statetesting.NewMongoInfo(),
MongoDialOpts: mongotest.DialOpts(),
}
_, err = state.Initialize(args)
c.Assert(err, gc.ErrorMatches, expect)
args.ControllerModelArgs.Config = good
st, err := state.Initialize(args)
c.Assert(err, jc.ErrorIsNil)
st.Close()
s.openState(c, st.ModelTag())
err = s.State.UpdateModelConfig(update, remove, nil)
c.Assert(err, gc.ErrorMatches, expect)
// ModelConfig remains inviolate.
cfg, err := s.State.ModelConfig()
c.Assert(err, jc.ErrorIsNil)
goodWithDefaults, err := config.New(config.UseDefaults, good.AllAttrs())
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.AllAttrs(), jc.DeepEquals, goodWithDefaults.AllAttrs())
}
开发者ID:kat-co,项目名称:juju,代码行数:48,代码来源:initialize_test.go
注:本文中的github.com/juju/juju/testing.CustomModelConfig函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论