本文整理汇总了Golang中github.com/juju/juju/testing.FakeControllerConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang FakeControllerConfig函数的具体用法?Golang FakeControllerConfig怎么用?Golang FakeControllerConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FakeControllerConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBootstrapNeedsSettings
func (s *bootstrapSuite) TestBootstrapNeedsSettings(c *gc.C) {
env := newEnviron("bar", noKeysDefined, nil)
s.setDummyStorage(c, env)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
CAPrivateKey: coretesting.CAKey,
})
c.Assert(err, gc.ErrorMatches, "validating bootstrap parameters: admin-secret is empty")
controllerCfg := coretesting.FakeControllerConfig()
delete(controllerCfg, "ca-cert")
err = bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
ControllerConfig: controllerCfg,
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
})
c.Assert(err, gc.ErrorMatches, "validating bootstrap parameters: controller configuration has no ca-cert")
controllerCfg = coretesting.FakeControllerConfig()
err = bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
ControllerConfig: controllerCfg,
AdminSecret: "admin-secret",
})
c.Assert(err, gc.ErrorMatches, "validating bootstrap parameters: empty ca-private-key")
err = bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
ControllerConfig: controllerCfg,
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
})
c.Assert(err, jc.ErrorIsNil)
}
示例2: bootstrapTestEnviron
func (s *suite) bootstrapTestEnviron(c *gc.C) environs.NetworkingEnviron {
env, err := bootstrap.Prepare(
envtesting.BootstrapContext(c),
s.ControllerStore,
bootstrap.PrepareParams{
ControllerConfig: testing.FakeControllerConfig(),
ModelConfig: s.TestConfig,
ControllerName: s.TestConfig["name"].(string),
Cloud: dummy.SampleCloudSpec(),
AdminSecret: AdminSecret,
},
)
c.Assert(err, gc.IsNil, gc.Commentf("preparing environ %#v", s.TestConfig))
c.Assert(env, gc.NotNil)
netenv, supported := environs.SupportsNetworking(env)
c.Assert(supported, jc.IsTrue)
err = bootstrap.Bootstrap(envtesting.BootstrapContext(c), netenv, bootstrap.BootstrapParams{
ControllerConfig: testing.FakeControllerConfig(),
CloudName: "dummy",
Cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
},
AdminSecret: AdminSecret,
CAPrivateKey: testing.CAKey,
})
c.Assert(err, jc.ErrorIsNil)
return netenv
}
示例3: TestCannotStartInstance
func (s *BootstrapSuite) TestCannotStartInstance(c *gc.C) {
s.PatchValue(&jujuversion.Current, coretesting.FakeVersionNumber)
checkPlacement := "directive"
checkCons := constraints.MustParse("mem=8G")
env := &mockEnviron{
storage: newStorage(s, c),
config: configGetter(c),
}
startInstance := func(
placement string,
cons constraints.Value,
_ []string,
possibleTools tools.List,
icfg *instancecfg.InstanceConfig,
) (instance.Instance, *instance.HardwareCharacteristics, []network.InterfaceInfo, error) {
c.Assert(placement, gc.DeepEquals, checkPlacement)
c.Assert(cons, gc.DeepEquals, checkCons)
// The machine config should set its upgrade behavior based on
// the environment config.
expectedMcfg, err := instancecfg.NewBootstrapInstanceConfig(coretesting.FakeControllerConfig(), cons, cons, icfg.Series, "")
c.Assert(err, jc.ErrorIsNil)
expectedMcfg.EnableOSRefreshUpdate = env.Config().EnableOSRefreshUpdate()
expectedMcfg.EnableOSUpgrade = env.Config().EnableOSUpgrade()
expectedMcfg.Tags = map[string]string{
"juju-model-uuid": coretesting.ModelTag.Id(),
"juju-controller-uuid": coretesting.ControllerTag.Id(),
"juju-is-controller": "true",
}
c.Assert(icfg, jc.DeepEquals, expectedMcfg)
return nil, nil, nil, errors.Errorf("meh, not started")
}
env.startInstance = startInstance
ctx := envtesting.BootstrapContext(c)
_, err := common.Bootstrap(ctx, env, environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
BootstrapConstraints: checkCons,
ModelConstraints: checkCons,
Placement: checkPlacement,
AvailableTools: tools.List{
&tools.Tools{
Version: version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
},
},
}})
c.Assert(err, gc.ErrorMatches, "cannot start bootstrap instance: meh, not started")
}
示例4: TestBootstrapEmptyConstraints
func (s *bootstrapSuite) TestBootstrapEmptyConstraints(c *gc.C) {
env := newEnviron("foo", useDefaultKeys, nil)
s.setDummyStorage(c, env)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(env.bootstrapCount, gc.Equals, 1)
env.args.AvailableTools = nil
c.Assert(env.args, gc.DeepEquals, environs.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
})
}
示例5: bootstrapParams
func (t *LiveTests) bootstrapParams() bootstrap.BootstrapParams {
credential := t.Credential
if credential.AuthType() == "" {
credential = cloud.NewEmptyCredential()
}
var regions []cloud.Region
if t.CloudRegion != "" {
regions = []cloud.Region{{
Name: t.CloudRegion,
Endpoint: t.CloudEndpoint,
}}
}
return bootstrap.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
CloudName: t.TestConfig["type"].(string),
Cloud: cloud.Cloud{
Type: t.TestConfig["type"].(string),
AuthTypes: []cloud.AuthType{credential.AuthType()},
Regions: regions,
Endpoint: t.CloudEndpoint,
},
CloudRegion: t.CloudRegion,
CloudCredential: &credential,
CloudCredentialName: "credential",
AdminSecret: AdminSecret,
CAPrivateKey: coretesting.CAKey,
}
}
示例6: TestBootstrapOpensAPIPort
func (s *environSuite) TestBootstrapOpensAPIPort(c *gc.C) {
finalizer := func(environs.BootstrapContext, *instancecfg.InstanceConfig, environs.BootstrapDialOpts) error {
return nil
}
s.FakeCommon.BSFinalizer = finalizer
ctx := envtesting.BootstrapContext(c)
params := environs.BootstrapParams{
ControllerConfig: testing.FakeControllerConfig(),
}
_, err := s.Env.Bootstrap(ctx, params)
c.Assert(err, jc.ErrorIsNil)
apiPort := params.ControllerConfig.APIPort()
called, calls := s.FakeConn.WasCalled("OpenPorts")
c.Check(called, gc.Equals, true)
c.Check(calls, gc.HasLen, 1)
c.Check(calls[0].FirewallName, gc.Equals, gce.GlobalFirewallName(s.Env))
expectPorts := []network.PortRange{{
FromPort: apiPort,
ToPort: apiPort,
Protocol: "tcp",
}}
c.Check(calls[0].PortRanges, jc.DeepEquals, expectPorts)
}
示例7: 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
}
示例8: TestBootstrapCloudCredential
func (s *bootstrapSuite) TestBootstrapCloudCredential(c *gc.C) {
env := newEnviron("foo", useDefaultKeys, nil)
s.setDummyStorage(c, env)
credential := cloud.NewCredential(cloud.EmptyAuthType, map[string]string{"what": "ever"})
args := bootstrap.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
Cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
Regions: []cloud.Region{{Name: "region-name"}},
},
CloudName: "cloud-name",
CloudRegion: "region-name",
CloudCredentialName: "credential-name",
CloudCredential: &credential,
}
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, args)
c.Assert(err, jc.ErrorIsNil)
c.Assert(env.bootstrapCount, gc.Equals, 1)
c.Assert(env.instanceConfig, gc.NotNil)
c.Assert(env.instanceConfig.Bootstrap.ControllerCloud, jc.DeepEquals, args.Cloud)
c.Assert(env.instanceConfig.Bootstrap.ControllerCloudName, jc.DeepEquals, args.CloudName)
c.Assert(env.instanceConfig.Bootstrap.ControllerCloudRegion, jc.DeepEquals, args.CloudRegion)
c.Assert(env.instanceConfig.Bootstrap.ControllerCloudCredential, jc.DeepEquals, args.CloudCredential)
c.Assert(env.instanceConfig.Bootstrap.ControllerCloudCredentialName, jc.DeepEquals, args.CloudCredentialName)
}
示例9: TestBootstrapGUISuccessLocal
func (s *bootstrapSuite) TestBootstrapGUISuccessLocal(c *gc.C) {
path := makeGUIArchive(c, "jujugui-2.2.0")
s.PatchEnvironment("JUJU_GUI", path)
env := newEnviron("foo", useDefaultKeys, nil)
ctx := coretesting.Context(c)
err := bootstrap.Bootstrap(modelcmd.BootstrapContext(ctx), env, bootstrap.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(coretesting.Stderr(ctx), jc.Contains, "Fetching Juju GUI 2.2.0 from local archive\n")
// Check GUI URL and version.
c.Assert(env.instanceConfig.Bootstrap.GUI.URL, gc.Equals, "file://"+path)
c.Assert(env.instanceConfig.Bootstrap.GUI.Version.String(), gc.Equals, "2.2.0")
// Check GUI size.
f, err := os.Open(path)
c.Assert(err, jc.ErrorIsNil)
defer f.Close()
info, err := f.Stat()
c.Assert(err, jc.ErrorIsNil)
c.Assert(env.instanceConfig.Bootstrap.GUI.Size, gc.Equals, info.Size())
// Check GUI hash.
h := sha256.New()
_, err = io.Copy(h, f)
c.Assert(err, jc.ErrorIsNil)
c.Assert(env.instanceConfig.Bootstrap.GUI.SHA256, gc.Equals, fmt.Sprintf("%x", h.Sum(nil)))
}
示例10: TestBootstrapGUISuccessRemote
func (s *bootstrapSuite) TestBootstrapGUISuccessRemote(c *gc.C) {
s.PatchValue(bootstrap.GUIFetchMetadata, func(stream string, sources ...simplestreams.DataSource) ([]*gui.Metadata, error) {
c.Assert(stream, gc.Equals, gui.ReleasedStream)
c.Assert(sources[0].Description(), gc.Equals, "gui simplestreams")
c.Assert(sources[0].RequireSigned(), jc.IsTrue)
return []*gui.Metadata{{
Version: version.MustParse("2.0.42"),
FullPath: "https://1.2.3.4/juju-gui-2.0.42.tar.bz2",
SHA256: "hash-2.0.42",
Size: 42,
}, {
Version: version.MustParse("2.0.47"),
FullPath: "https://1.2.3.4/juju-gui-2.0.47.tar.bz2",
SHA256: "hash-2.0.47",
Size: 47,
}}, nil
})
env := newEnviron("foo", useDefaultKeys, nil)
ctx := coretesting.Context(c)
err := bootstrap.Bootstrap(modelcmd.BootstrapContext(ctx), env, bootstrap.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
GUIDataSourceBaseURL: "https://1.2.3.4/gui/sources",
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(coretesting.Stderr(ctx), jc.Contains, "Fetching Juju GUI 2.0.42\n")
// The most recent GUI release info has been stored.
c.Assert(env.instanceConfig.Bootstrap.GUI.URL, gc.Equals, "https://1.2.3.4/juju-gui-2.0.42.tar.bz2")
c.Assert(env.instanceConfig.Bootstrap.GUI.Version.String(), gc.Equals, "2.0.42")
c.Assert(env.instanceConfig.Bootstrap.GUI.Size, gc.Equals, int64(42))
c.Assert(env.instanceConfig.Bootstrap.GUI.SHA256, gc.Equals, "hash-2.0.42")
}
示例11: TestBootstrapNoToolsNonReleaseStream
func (s *bootstrapSuite) TestBootstrapNoToolsNonReleaseStream(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("issue 1403084: Currently does not work because of jujud problems")
}
// Patch out HostArch and FindTools to allow the test to pass on other architectures,
// such as s390.
s.PatchValue(&arch.HostArch, func() string { return arch.ARM64 })
s.PatchValue(bootstrap.FindTools, func(environs.Environ, int, int, string, tools.Filter) (tools.List, error) {
return nil, errors.NotFoundf("tools")
})
env := newEnviron("foo", useDefaultKeys, map[string]interface{}{
"agent-stream": "proposed"})
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
ControllerConfig: coretesting.FakeControllerConfig(),
BuildAgentTarball: func(bool, *version.Number, string) (*sync.BuiltAgent, error) {
return &sync.BuiltAgent{Dir: c.MkDir()}, nil
},
})
// bootstrap.Bootstrap leaves it to the provider to
// locate bootstrap tools.
c.Assert(err, jc.ErrorIsNil)
}
示例12: TestBootstrapBuildAgent
func (s *bootstrapSuite) TestBootstrapBuildAgent(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("issue 1403084: Currently does not work because of jujud problems")
}
// Patch out HostArch and FindTools to allow the test to pass on other architectures,
// such as s390.
s.PatchValue(&arch.HostArch, func() string { return arch.ARM64 })
s.PatchValue(bootstrap.FindTools, func(environs.Environ, int, int, string, tools.Filter) (tools.List, error) {
c.Fatal("should not call FindTools if BuildAgent is specified")
return nil, errors.NotFoundf("tools")
})
env := newEnviron("foo", useDefaultKeys, nil)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
BuildAgent: true,
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
ControllerConfig: coretesting.FakeControllerConfig(),
BuildAgentTarball: func(build bool, ver *version.Number, _ string) (*sync.BuiltAgent, error) {
c.Logf("BuildAgentTarball version %s", ver)
c.Assert(build, jc.IsTrue)
return &sync.BuiltAgent{Dir: c.MkDir()}, nil
},
})
c.Assert(err, jc.ErrorIsNil)
// Check that the model config has the correct version set.
cfg := env.instanceConfig.Bootstrap.ControllerModelConfig
agentVersion, valid := cfg.AgentVersion()
c.Check(valid, jc.IsTrue)
c.Check(agentVersion.String(), gc.Equals, "1.99.0.1")
}
示例13: TestBootstrapLocalToolsDifferentLinuxes
func (s *bootstrapSuite) TestBootstrapLocalToolsDifferentLinuxes(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("issue 1403084: Currently does not work because of jujud problems")
}
// Client host is some unspecified Linux system, wanting to
// bootstrap a trusty controller with local tools. This should be
// OK.
s.PatchValue(&jujuos.HostOS, func() jujuos.OSType { return jujuos.GenericLinux })
s.PatchValue(&arch.HostArch, func() string { return arch.AMD64 })
s.PatchValue(bootstrap.FindTools, func(environs.Environ, int, int, string, tools.Filter) (tools.List, error) {
return nil, errors.NotFoundf("tools")
})
env := newEnviron("foo", useDefaultKeys, nil)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
ControllerConfig: coretesting.FakeControllerConfig(),
BuildAgentTarball: func(bool, *version.Number, string) (*sync.BuiltAgent, error) {
return &sync.BuiltAgent{Dir: c.MkDir()}, nil
},
BootstrapSeries: "trusty",
})
c.Assert(err, jc.ErrorIsNil)
c.Check(env.bootstrapCount, gc.Equals, 1)
c.Check(env.args.BootstrapSeries, gc.Equals, "trusty")
c.Check(env.args.AvailableTools.AllSeries(), jc.SameContents, []string{"trusty"})
}
示例14: TestBootstrapLocalToolsMismatchingOS
func (s *bootstrapSuite) TestBootstrapLocalToolsMismatchingOS(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("issue 1403084: Currently does not work because of jujud problems")
}
// Client host is a Windows system, wanting to bootstrap a trusty
// controller with local tools. This can't work.
s.PatchValue(&jujuos.HostOS, func() jujuos.OSType { return jujuos.Windows })
s.PatchValue(&arch.HostArch, func() string { return arch.AMD64 })
s.PatchValue(bootstrap.FindTools, func(environs.Environ, int, int, string, tools.Filter) (tools.List, error) {
return nil, errors.NotFoundf("tools")
})
env := newEnviron("foo", useDefaultKeys, nil)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
ControllerConfig: coretesting.FakeControllerConfig(),
BuildAgentTarball: func(bool, *version.Number, string) (*sync.BuiltAgent, error) {
return &sync.BuiltAgent{Dir: c.MkDir()}, nil
},
BootstrapSeries: "trusty",
})
c.Assert(err, gc.ErrorMatches, `cannot use agent built for "trusty" using a machine running "Windows"`)
}
示例15: SetUpTest
func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) {
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
s.AddCleanup(dummy.Reset)
cfg, err := config.New(config.UseDefaults, map[string]interface{}{
"name": "erewhemos",
"type": "dummy",
"uuid": coretesting.ModelTag.Id(),
"controller-uuid": coretesting.ControllerTag.Id(),
"conroller": true,
})
c.Assert(err, jc.ErrorIsNil)
env, err := bootstrap.Prepare(
modelcmd.BootstrapContextNoVerify(coretesting.Context(c)),
jujuclienttesting.NewMemStore(),
bootstrap.PrepareParams{
ControllerConfig: coretesting.FakeControllerConfig(),
ControllerName: cfg.Name(),
ModelConfig: cfg.AllAttrs(),
Cloud: dummy.SampleCloudSpec(),
AdminSecret: "admin-secret",
},
)
c.Assert(err, jc.ErrorIsNil)
s.env = env
loggo.GetLogger("").SetLogLevel(loggo.INFO)
// Switch the default tools location.
s.publicStorageDir = c.MkDir()
s.PatchValue(&tools.DefaultBaseURL, s.publicStorageDir)
}