本文整理汇总了Golang中github.com/juju/juju/provider/dummy.SampleConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang SampleConfig函数的具体用法?Golang SampleConfig怎么用?Golang SampleConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SampleConfig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
gc.Suite(&liveSuite{
LiveTests: jujutest.LiveTests{
TestConfig: dummy.SampleConfig(),
CanOpenState: true,
HasProvisioner: false,
},
})
gc.Suite(&suite{
Tests: jujutest.Tests{
TestConfig: dummy.SampleConfig(),
},
})
}
开发者ID:rogpeppe,项目名称:juju,代码行数:14,代码来源:environs_test.go
示例2: TestNewAPIState
func (*NewAPIStateSuite) TestNewAPIState(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, gc.IsNil)
ctx := coretesting.Context(c)
env, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
envtesting.UploadFakeTools(c, env.Storage())
err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
cfg = env.Config()
cfg, err = cfg.Apply(map[string]interface{}{
"secret": "fnord",
})
c.Assert(err, gc.IsNil)
err = env.SetConfig(cfg)
c.Assert(err, gc.IsNil)
st, err := juju.NewAPIState(env, api.DialOpts{})
c.Assert(st, gc.NotNil)
// the secrets will not be updated, as they already exist
attrs, err := st.Client().EnvironmentGet()
c.Assert(attrs["secret"], gc.Equals, "pork")
c.Assert(st.Close(), gc.IsNil)
}
开发者ID:klyachin,项目名称:juju,代码行数:28,代码来源:api_test.go
示例3: testConfig
func testConfig() *config.Config {
attrs := dummy.SampleConfig().Merge(coretesting.Attrs{
"type": "nonex",
})
cfg, _ := config.New(config.NoDefaults, attrs)
return cfg
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:package_test.go
示例4: SetUpTest
func (s *LXCDefaultMTUSuite) SetUpTest(c *gc.C) {
// Explicitly set lxc-default-mtu before JujuConnSuite constructs
// the environment, as the setting is immutable.
s.DummyConfig = dummy.SampleConfig()
s.DummyConfig["lxc-default-mtu"] = 9000
s.ContainerSetupSuite.SetUpTest(c)
}
开发者ID:chrisjohnston,项目名称:juju,代码行数:7,代码来源:container_initialisation_test.go
示例5: bootstrapModel
func (s *NewAPIClientSuite) bootstrapModel(c *gc.C) (environs.Environ, jujuclient.ClientStore) {
const controllerName = "local.my-controller"
store := jujuclienttesting.NewMemStore()
ctx := envtesting.BootstrapContext(c)
env, err := environs.Prepare(ctx, store, environs.PrepareParams{
ControllerName: controllerName,
BaseConfig: dummy.SampleConfig(),
CloudName: "dummy",
})
c.Assert(err, jc.ErrorIsNil)
storageDir := c.MkDir()
s.PatchValue(&envtools.DefaultBaseURL, storageDir)
stor, err := filestorage.NewFileStorageWriter(storageDir)
c.Assert(err, jc.ErrorIsNil)
envtesting.UploadFakeTools(c, stor, "released", "released")
err = bootstrap.Bootstrap(ctx, env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
return env, store
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:25,代码来源:api_test.go
示例6: makeTestEnv
func (s *BootstrapSuite) makeTestEnv(c *gc.C) {
attrs := dummy.SampleConfig().Merge(
testing.Attrs{
"agent-version": version.Current.Number.String(),
"bootstrap-timeout": "123",
},
).Delete("admin-secret", "ca-private-key")
cfg, err := config.New(config.NoDefaults, attrs)
c.Assert(err, jc.ErrorIsNil)
provider, err := environs.Provider(cfg.Type())
c.Assert(err, jc.ErrorIsNil)
env, err := provider.PrepareForBootstrap(nullContext(), cfg)
c.Assert(err, jc.ErrorIsNil)
envtesting.MustUploadFakeTools(s.toolsStorage, cfg.AgentStream(), cfg.AgentStream())
inst, _, _, err := jujutesting.StartInstance(env, "0")
c.Assert(err, jc.ErrorIsNil)
s.instanceId = inst.Id()
addresses, err := inst.Addresses()
c.Assert(err, jc.ErrorIsNil)
s.bootstrapName = network.SelectPublicAddress(addresses)
s.envcfg = env.Config()
s.b64yamlEnvcfg = b64yaml(s.envcfg.AllAttrs()).encode()
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:25,代码来源:bootstrap_test.go
示例7: TestFirewallMode
func (s *ConfigSuite) TestFirewallMode(c *gc.C) {
for i, test := range firewallModeTests {
c.Logf("test %d: %s", i, test.configFirewallMode)
attrs := dummy.SampleConfig()
if test.configFirewallMode != "" {
attrs = attrs.Merge(testing.Attrs{
"firewall-mode": test.configFirewallMode,
})
}
cfg, err := config.New(config.NoDefaults, attrs)
if err != nil {
c.Assert(err, gc.ErrorMatches, test.errorMsg)
continue
}
ctx := testing.Context(c)
env, err := environs.Prepare(cfg, ctx, configstore.NewMem())
if test.errorMsg != "" {
c.Assert(err, gc.ErrorMatches, test.errorMsg)
continue
}
c.Assert(err, gc.IsNil)
defer env.Destroy()
firewallMode := env.Config().FirewallMode()
c.Assert(firewallMode, gc.Equals, test.firewallMode)
s.TearDownTest(c)
}
}
开发者ID:kapilt,项目名称:juju,代码行数:29,代码来源:config_test.go
示例8: testingEnvConfig
func testingEnvConfig(c *gc.C) *config.Config {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, gc.IsNil)
env, err := environs.Prepare(cfg, testing.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
return env.Config()
}
开发者ID:rogpeppe,项目名称:juju,代码行数:7,代码来源:environwatcher_test.go
示例9: testingEnvConfig
// testingEnvConfig prepares an environment configuration using
// the dummy provider.
func testingEnvConfig(c *gc.C) *config.Config {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, jc.ErrorIsNil)
env, err := environs.Prepare(cfg, modelcmd.BootstrapContext(coretesting.Context(c)), configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
return env.Config()
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:addresser_test.go
示例10: CreateContainerTest
// CreateContainerTest tries to create a container and returns any errors encountered along the
// way
func CreateContainerTest(c *gc.C, manager container.Manager, machineId string) (instance.Instance, error) {
instanceConfig, err := MockMachineConfig(machineId)
if err != nil {
return nil, errors.Trace(err)
}
envConfig, err := config.New(config.NoDefaults, dummy.SampleConfig())
if err != nil {
return nil, errors.Trace(err)
}
instanceConfig.Config = envConfig
network := container.BridgeNetworkConfig("nic42", 0, nil)
storage := &container.StorageConfig{}
callback := func(settableStatus status.Status, info string, data map[string]interface{}) error { return nil }
inst, hardware, err := manager.CreateContainer(instanceConfig, "quantal", network, storage, callback)
if err != nil {
return nil, errors.Trace(err)
}
if hardware == nil {
return nil, errors.New("nil hardware characteristics")
}
if hardware.String() == "" {
return nil, errors.New("empty hardware characteristics")
}
return inst, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:32,代码来源:common.go
示例11: TestPrepareGeneratesDifferentAdminSecrets
func (*OpenSuite) TestPrepareGeneratesDifferentAdminSecrets(c *gc.C) {
baselineAttrs := dummy.SampleConfig().Merge(testing.Attrs{
"state-server": false,
"name": "erewhemos",
}).Delete(
"admin-secret",
)
cfg, err := config.New(config.NoDefaults, baselineAttrs)
c.Assert(err, gc.IsNil)
ctx := testing.Context(c)
env0, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
adminSecret0 := env0.Config().AdminSecret()
c.Assert(adminSecret0, gc.HasLen, 32)
c.Assert(adminSecret0, gc.Matches, "^[0-9a-f]*$")
env1, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
adminSecret1 := env1.Config().AdminSecret()
c.Assert(adminSecret1, gc.HasLen, 32)
c.Assert(adminSecret1, gc.Matches, "^[0-9a-f]*$")
c.Assert(adminSecret1, gc.Not(gc.Equals), adminSecret0)
}
开发者ID:jiasir,项目名称:juju,代码行数:25,代码来源:open_test.go
示例12: env
func (s *ImageMetadataSuite) env(c *gc.C, imageMetadataURL, stream string) environs.Environ {
attrs := dummy.SampleConfig()
if stream != "" {
attrs = attrs.Merge(testing.Attrs{
"image-stream": stream,
})
}
if imageMetadataURL != "" {
attrs = attrs.Merge(testing.Attrs{
"image-metadata-url": imageMetadataURL,
})
}
env, err := bootstrap.Prepare(
envtesting.BootstrapContext(c),
jujuclienttesting.NewMemStore(),
bootstrap.PrepareParams{
ControllerConfig: testing.FakeControllerConfig(),
ControllerName: attrs["name"].(string),
ModelConfig: attrs,
Cloud: dummy.SampleCloudSpec(),
AdminSecret: "admin-secret",
},
)
c.Assert(err, jc.ErrorIsNil)
return env
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:imagemetadata_test.go
示例13: TestDestroy
func (*OpenSuite) TestDestroy(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(
testing.Attrs{
"state-server": false,
"name": "erewhemos",
},
))
c.Assert(err, gc.IsNil)
store := configstore.NewMem()
// Prepare the environment and sanity-check that
// the config storage info has been made.
ctx := testing.Context(c)
e, err := environs.Prepare(cfg, ctx, store)
c.Assert(err, gc.IsNil)
_, err = store.ReadInfo(e.Config().Name())
c.Assert(err, gc.IsNil)
err = environs.Destroy(e, store)
c.Assert(err, gc.IsNil)
// Check that the environment has actually been destroyed
// and that the config info has been destroyed too.
_, err = e.StateServerInstances()
c.Assert(err, gc.ErrorMatches, "environment has been destroyed")
_, err = store.ReadInfo(e.Config().Name())
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:jiasir,项目名称:juju,代码行数:28,代码来源:open_test.go
示例14: 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
示例15: TestDestroy
func (*OpenSuite) TestDestroy(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(
testing.Attrs{
"name": "erewhemos",
},
))
c.Assert(err, jc.ErrorIsNil)
store := jujuclienttesting.NewMemStore()
// Prepare the environment and sanity-check that
// the config storage info has been made.
controllerCfg := testing.FakeControllerConfig()
ctx := envtesting.BootstrapContext(c)
e, err := bootstrap.Prepare(ctx, store, bootstrap.PrepareParams{
ControllerConfig: controllerCfg,
ControllerName: "controller-name",
ModelConfig: cfg.AllAttrs(),
Cloud: dummy.SampleCloudSpec(),
AdminSecret: "admin-secret",
})
c.Assert(err, jc.ErrorIsNil)
_, err = store.ControllerByName("controller-name")
c.Assert(err, jc.ErrorIsNil)
err = environs.Destroy("controller-name", e, store)
c.Assert(err, jc.ErrorIsNil)
// Check that the environment has actually been destroyed
// and that the controller details been removed too.
_, err = e.ControllerInstances(controllerCfg.ControllerUUID())
c.Assert(err, gc.ErrorMatches, "model is not prepared")
_, err = store.ControllerByName("controller-name")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:bac,项目名称:juju,代码行数:34,代码来源:open_test.go
示例16: TestNewAPIState
func (cs *NewAPIStateSuite) TestNewAPIState(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, jc.ErrorIsNil)
ctx := envtesting.BootstrapContext(c)
env, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
storageDir := c.MkDir()
cs.PatchValue(&envtools.DefaultBaseURL, storageDir)
stor, err := filestorage.NewFileStorageWriter(storageDir)
c.Assert(err, jc.ErrorIsNil)
envtesting.UploadFakeTools(c, stor, "released", "released")
err = bootstrap.Bootstrap(ctx, env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
cfg = env.Config()
cfg, err = cfg.Apply(map[string]interface{}{
"secret": "fnord",
})
c.Assert(err, jc.ErrorIsNil)
err = env.SetConfig(cfg)
c.Assert(err, jc.ErrorIsNil)
st, err := juju.NewAPIState(dummy.AdminUserTag(), env, api.DialOpts{})
c.Assert(st, gc.NotNil)
// the secrets will not be updated, as they already exist
attrs, err := st.Client().EnvironmentGet()
c.Assert(attrs["secret"], gc.Equals, "pork")
c.Assert(st.Close(), gc.IsNil)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:33,代码来源:api_test.go
示例17: ModelGet
func (a *fakeUpgradeJujuAPINoState) ModelGet() (map[string]interface{}, error) {
return dummy.SampleConfig().Merge(map[string]interface{}{
"name": a.name,
"uuid": a.uuid,
"controller-uuid": a.controllerUUID,
"agent-version": a.agentVersion,
}), nil
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:upgradejuju_test.go
示例18: nonexTestingEnvConfig
// nonexTestingEnvConfig prepares an environment configuration using
// a non-existent provider.
func nonexTestingEnvConfig(c *gc.C) *config.Config {
attrs := dummy.SampleConfig().Merge(coretesting.Attrs{
"type": "nonex",
})
cfg, err := config.New(config.NoDefaults, attrs)
c.Assert(err, jc.ErrorIsNil)
return cfg
}
开发者ID:exekias,项目名称:juju,代码行数:10,代码来源:addresser_test.go
示例19: SetUpTest
func (s *StorageSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, gc.IsNil)
s.env, err = environs.Prepare(cfg, testing.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
s.dataDir = c.MkDir()
}
开发者ID:jiasir,项目名称:juju,代码行数:8,代码来源:storage_test.go
示例20: TestBootstrapWithDefaultSeries
func (t *LiveTests) TestBootstrapWithDefaultSeries(c *gc.C) {
if !t.HasProvisioner {
c.Skip("HasProvisioner is false; cannot test deployment")
}
current := version.Current
other := current
other.Series = "quantal"
if current == other {
other.Series = "precise"
}
dummyCfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(coretesting.Attrs{
"state-server": false,
"name": "dummy storage",
}))
dummyenv, err := environs.Prepare(dummyCfg, coretesting.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
defer dummyenv.Destroy()
t.Destroy(c)
attrs := t.TestConfig.Merge(coretesting.Attrs{"default-series": other.Series})
cfg, err := config.New(config.NoDefaults, attrs)
c.Assert(err, gc.IsNil)
env, err := environs.Prepare(cfg, coretesting.Context(c), t.ConfigStore)
c.Assert(err, gc.IsNil)
defer environs.Destroy(env, t.ConfigStore)
currentName := envtools.StorageName(current)
otherName := envtools.StorageName(other)
envStorage := env.Storage()
dummyStorage := dummyenv.Storage()
defer envStorage.Remove(otherName)
_, err = sync.Upload(dummyStorage, ¤t.Number)
c.Assert(err, gc.IsNil)
// This will only work while cross-compiling across releases is safe,
// which depends on external elements. Tends to be safe for the last
// few releases, but we may have to refactor some day.
err = storageCopy(dummyStorage, currentName, envStorage, otherName)
c.Assert(err, gc.IsNil)
err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
st := t.Env.(testing.GetStater).GetStateInAPIServer()
// Wait for machine agent to come up on the bootstrap
// machine and ensure it deployed the proper series.
m0, err := st.Machine("0")
c.Assert(err, gc.IsNil)
mw0 := newMachineToolWaiter(m0)
defer mw0.Stop()
waitAgentTools(c, mw0, other)
}
开发者ID:klyachin,项目名称:juju,代码行数:58,代码来源:livetests.go
注:本文中的github.com/juju/juju/provider/dummy.SampleConfig函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论