本文整理汇总了Golang中github.com/juju/juju/mongo.DefaultDialOpts函数的典型用法代码示例。如果您正苦于以下问题:Golang DefaultDialOpts函数的具体用法?Golang DefaultDialOpts怎么用?Golang DefaultDialOpts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DefaultDialOpts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestInitializeStateFailsSecondTime
func (s *bootstrapSuite) TestInitializeStateFailsSecondTime(c *gc.C) {
dataDir := c.MkDir()
configParams := agent.AgentConfigParams{
Paths: agent.Paths{DataDir: dataDir},
Tag: names.NewMachineTag("0"),
UpgradedToVersion: jujuversion.Current,
StateAddresses: []string{s.mgoInst.Addr()},
CACert: testing.CACert,
Password: testing.DefaultMongoPassword,
Model: testing.ModelTag,
}
cfg, err := agent.NewAgentConfig(configParams)
c.Assert(err, jc.ErrorIsNil)
cfg.SetStateServingInfo(params.StateServingInfo{
APIPort: 5555,
StatePort: s.mgoInst.Port(),
Cert: "foo",
PrivateKey: "bar",
SharedSecret: "baz",
SystemIdentity: "qux",
})
expectHW := instance.MustParseHardware("mem=2048M")
mcfg := agentbootstrap.BootstrapMachineConfig{
BootstrapConstraints: constraints.MustParse("mem=1024M"),
Jobs: []multiwatcher.MachineJob{multiwatcher.JobManageModel},
InstanceId: "i-bootstrap",
Characteristics: expectHW,
}
envAttrs := dummy.SampleConfig().Delete("admin-secret").Merge(testing.Attrs{
"agent-version": jujuversion.Current.String(),
})
envCfg, err := config.New(config.NoDefaults, envAttrs)
c.Assert(err, jc.ErrorIsNil)
hostedModelConfigAttrs := map[string]interface{}{
"name": "hosted",
"uuid": utils.MustNewUUID().String(),
}
adminUser := names.NewLocalUserTag("agent-admin")
st, _, err := agentbootstrap.InitializeState(
adminUser, cfg, envCfg, hostedModelConfigAttrs, mcfg,
mongo.DefaultDialOpts(), state.Policy(nil),
)
c.Assert(err, jc.ErrorIsNil)
st.Close()
st, _, err = agentbootstrap.InitializeState(adminUser, cfg, envCfg, nil, mcfg, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if err == nil {
st.Close()
}
c.Assert(err, gc.ErrorMatches, "failed to initialize mongo admin user: cannot set admin password: not authorized .*")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:54,代码来源:bootstrap_test.go
示例2: TestInitialPassword
func (s *BootstrapSuite) TestInitialPassword(c *gc.C) {
machineConf, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.b64yamlEnvcfg, "--instance-id", string(s.instanceId))
c.Assert(err, jc.ErrorIsNil)
err = cmd.Run(nil)
c.Assert(err, jc.ErrorIsNil)
info := &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
},
}
// Check we can log in to mongo as admin.
// TODO(dfc) does passing nil for the admin user name make your skin crawl ? mine too.
info.Tag, info.Password = nil, testPasswordHash()
st, err := state.Open(testing.EnvironmentTag, info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
// We're running Mongo with --noauth; let's explicitly verify
// that we can login as that user. Even with --noauth, an
// explicit Login will still be verified.
adminDB := st.MongoSession().DB("admin")
err = adminDB.Login("admin", "invalid-password")
c.Assert(err, gc.ErrorMatches, "auth fail(s|ed)")
err = adminDB.Login("admin", info.Password)
c.Assert(err, jc.ErrorIsNil)
// Check that the admin user has been given an appropriate
// password
u, err := st.User(names.NewLocalUserTag("admin"))
c.Assert(err, jc.ErrorIsNil)
c.Assert(u.PasswordValid(testPassword), jc.IsTrue)
// Check that the machine configuration has been given a new
// password and that we can connect to mongo as that machine
// and that the in-mongo password also verifies correctly.
machineConf1, err := agent.ReadConfig(agent.ConfigPath(machineConf.DataDir(), names.NewMachineTag("0")))
c.Assert(err, jc.ErrorIsNil)
stateinfo, ok := machineConf1.MongoInfo()
c.Assert(ok, jc.IsTrue)
st, err = state.Open(testing.EnvironmentTag, stateinfo, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
m, err := st.Machine("0")
c.Assert(err, jc.ErrorIsNil)
c.Assert(m.HasVote(), jc.IsTrue)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:52,代码来源:bootstrap_test.go
示例3: TestInitializeStateFailsSecondTime
func (s *bootstrapSuite) TestInitializeStateFailsSecondTime(c *gc.C) {
dataDir := c.MkDir()
pwHash := utils.UserPasswordHash(testing.DefaultMongoPassword, utils.CompatSalt)
configParams := agent.AgentConfigParams{
Paths: agent.Paths{DataDir: dataDir},
Tag: names.NewMachineTag("0"),
UpgradedToVersion: version.Current.Number,
StateAddresses: []string{s.mgoInst.Addr()},
CACert: testing.CACert,
Password: pwHash,
Environment: testing.EnvironmentTag,
}
cfg, err := agent.NewAgentConfig(configParams)
c.Assert(err, jc.ErrorIsNil)
cfg.SetStateServingInfo(params.StateServingInfo{
APIPort: 5555,
StatePort: s.mgoInst.Port(),
Cert: "foo",
PrivateKey: "bar",
SharedSecret: "baz",
SystemIdentity: "qux",
})
expectConstraints := constraints.MustParse("mem=1024M")
expectHW := instance.MustParseHardware("mem=2048M")
mcfg := agent.BootstrapMachineConfig{
Constraints: expectConstraints,
Jobs: []multiwatcher.MachineJob{multiwatcher.JobManageEnviron},
InstanceId: "i-bootstrap",
Characteristics: expectHW,
}
envAttrs := dummy.SampleConfig().Delete("admin-secret").Merge(testing.Attrs{
"agent-version": version.Current.Number.String(),
"state-id": "1", // needed so policy can Open config
})
envCfg, err := config.New(config.NoDefaults, envAttrs)
c.Assert(err, jc.ErrorIsNil)
adminUser := names.NewLocalUserTag("agent-admin")
st, _, err := agent.InitializeState(adminUser, cfg, envCfg, mcfg, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, jc.ErrorIsNil)
st.Close()
st, _, err = agent.InitializeState(adminUser, cfg, envCfg, mcfg, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if err == nil {
st.Close()
}
c.Assert(err, gc.ErrorMatches, "failed to initialize mongo admin user: cannot set admin password: not authorized .*")
}
开发者ID:kakamessi99,项目名称:juju,代码行数:49,代码来源:bootstrap_test.go
示例4: Run
func (c *MigrateCommand) Run(ctx *cmd.Context) (err error) {
defer func() {
if err != nil {
fmt.Fprintf(ctx.Stdout, "error stack:\n"+errors.ErrorStack(err))
}
}()
loggo.GetLogger("juju").SetLogLevel(loggo.DEBUG)
conf, err := agent.ReadConfig(agent.ConfigPath(c.dataDir, c.machineTag))
if err != nil {
return err
}
info, ok := conf.MongoInfo()
if !ok {
return errors.Errorf("no state info available")
}
st, err := state.Open(conf.Model(), info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if err != nil {
return err
}
defer st.Close()
if c.operation == "export" {
return c.exportModel(ctx, st)
}
return c.importModel(ctx, st)
}
开发者ID:howbazaar,项目名称:migration-test,代码行数:31,代码来源:main.go
示例5: Run
// Run implements cmd.Command.
func (c *dumpLogsCommand) Run(ctx *cmd.Context) error {
config := c.agentConfig.CurrentConfig()
info, ok := config.MongoInfo()
if !ok {
return errors.New("no database connection info available (is this a controller host?)")
}
st0, err := state.Open(config.Environment(), info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if err != nil {
return errors.Annotate(err, "failed to connect to database")
}
defer st0.Close()
envs, err := st0.AllEnvironments()
if err != nil {
return errors.Annotate(err, "failed to look up environments")
}
for _, env := range envs {
err := c.dumpLogsForEnv(ctx, st0, env.EnvironTag())
if err != nil {
return errors.Annotatef(err, "failed to dump logs for environment %s", env.UUID())
}
}
return nil
}
开发者ID:imoapps,项目名称:juju,代码行数:27,代码来源:dumplogs.go
示例6: fixEnvironment
// fixEnvironment undoes the work of invalidateEnvironment.
func (s *CommonProvisionerSuite) fixEnvironment(c *gc.C) error {
st, err := state.Open(s.MongoInfo(c), mongo.DefaultDialOpts(), state.Policy(nil))
c.Assert(err, gc.IsNil)
defer st.Close()
attrs := map[string]interface{}{"type": s.cfg.AllAttrs()["type"]}
return st.UpdateEnvironConfig(attrs, nil, nil)
}
开发者ID:zhouqt,项目名称:juju,代码行数:8,代码来源:provisioner_test.go
示例7: TestInitializeEnvironmentToolsNotFound
func (s *BootstrapSuite) TestInitializeEnvironmentToolsNotFound(c *gc.C) {
// bootstrap with 1.99.1 but there will be no tools so version will be reset.
envcfg, err := s.envcfg.Apply(map[string]interface{}{
"agent-version": "1.99.1",
})
c.Assert(err, jc.ErrorIsNil)
b64yamlEnvcfg := b64yaml(envcfg.AllAttrs()).encode()
hw := instance.MustParseHardware("arch=amd64 mem=8G")
_, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", b64yamlEnvcfg, "--instance-id", string(s.instanceId), "--hardware", hw.String())
c.Assert(err, jc.ErrorIsNil)
err = cmd.Run(nil)
c.Assert(err, jc.ErrorIsNil)
st, err := state.Open(testing.EnvironmentTag, &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
},
Password: testPasswordHash(),
}, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
cfg, err := st.EnvironConfig()
c.Assert(err, jc.ErrorIsNil)
vers, ok := cfg.AgentVersion()
c.Assert(ok, jc.IsTrue)
c.Assert(vers.String(), gc.Equals, "1.99.0")
}
开发者ID:imoapps,项目名称:juju,代码行数:30,代码来源:bootstrap_test.go
示例8: TestInvalidConfig
func (s *environSuite) TestInvalidConfig(c *gc.C) {
var oldType string
oldType = s.Environ.Config().AllAttrs()["type"].(string)
// Create an invalid config by taking the current config and
// tweaking the provider type.
info := s.MongoInfo(c)
opts := mongo.DefaultDialOpts()
st2, err := state.Open(info, opts, state.Policy(nil))
c.Assert(err, gc.IsNil)
defer st2.Close()
err = st2.UpdateEnvironConfig(map[string]interface{}{"type": "unknown"}, nil, nil)
c.Assert(err, gc.IsNil)
w := st2.WatchForEnvironConfigChanges()
defer stopWatcher(c, w)
done := make(chan environs.Environ)
go func() {
env, err := worker.WaitForEnviron(w, st2, nil)
c.Check(err, gc.IsNil)
done <- env
}()
// Wait for the loop to process the invalid configuratrion
<-worker.LoadedInvalid
st2.UpdateEnvironConfig(map[string]interface{}{
"type": oldType,
"secret": "environ_test",
}, nil, nil)
env := <-done
c.Assert(env, gc.NotNil)
c.Assert(env.Config().AllAttrs()["secret"], gc.Equals, "environ_test")
}
开发者ID:klyachin,项目名称:juju,代码行数:34,代码来源:environ_test.go
示例9: dialAndLogin
// dialAndLogin returns a mongo session logged in as a user with administrative
// privileges
func dialAndLogin(mongoInfo *mongo.MongoInfo, callArgs retry.CallArgs) (mgoSession, mgoDb, error) {
var session *mgo.Session
opts := mongo.DefaultDialOpts()
callArgs.Func = func() error {
// Try to connect, retry a few times until the db comes up.
var err error
session, err = mongo.DialWithInfo(mongoInfo.Info, opts)
if err == nil {
return nil
}
logger.Errorf("cannot open mongo connection: %v", err)
return err
}
if err := retry.Call(callArgs); err != nil {
return nil, nil, errors.Annotate(err, "error dialing mongo to resume HA")
}
admin := session.DB("admin")
if mongoInfo.Tag != nil {
if err := admin.Login(mongoInfo.Tag.String(), mongoInfo.Password); err != nil {
return nil, nil, errors.Annotatef(err, "cannot log in to admin database as %q", mongoInfo.Tag)
}
} else if mongoInfo.Password != "" {
if err := admin.Login(mongo.AdminUser, mongoInfo.Password); err != nil {
return nil, nil, errors.Annotate(err, "cannot log in to admin database")
}
}
return session, admin, nil
}
开发者ID:makyo,项目名称:juju,代码行数:30,代码来源:upgrade_mongo.go
示例10: newState
// newState returns a new State that uses the given environment.
// The environment must have already been bootstrapped.
func newState(environ environs.Environ, mongoInfo *mongo.MongoInfo) (*state.State, error) {
config := environ.Config()
password := config.AdminSecret()
if password == "" {
return nil, fmt.Errorf("cannot connect without admin-secret")
}
modelTag := names.NewModelTag(config.UUID())
mongoInfo.Password = password
opts := mongo.DefaultDialOpts()
st, err := state.Open(modelTag, mongoInfo, opts, environs.NewStatePolicy())
if errors.IsUnauthorized(errors.Cause(err)) {
// We try for a while because we might succeed in
// connecting to mongo before the state has been
// initialized and the initial password set.
for a := redialStrategy.Start(); a.Next(); {
st, err = state.Open(modelTag, mongoInfo, opts, environs.NewStatePolicy())
if !errors.IsUnauthorized(errors.Cause(err)) {
break
}
}
if err != nil {
return nil, err
}
} else if err != nil {
return nil, err
}
if err := updateSecrets(environ, st); err != nil {
st.Close()
return nil, fmt.Errorf("unable to push secrets: %v", err)
}
return st, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:35,代码来源:conn.go
示例11: TestSetConstraints
func (s *BootstrapSuite) TestSetConstraints(c *gc.C) {
tcons := constraints.Value{Mem: uint64p(2048), CpuCores: uint64p(2)}
_, cmd, err := s.initBootstrapCommand(c, nil,
"--env-config", s.b64yamlEnvcfg,
"--instance-id", string(s.instanceId),
"--constraints", tcons.String(),
)
c.Assert(err, jc.ErrorIsNil)
err = cmd.Run(nil)
c.Assert(err, jc.ErrorIsNil)
st, err := state.Open(testing.EnvironmentTag, &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
},
Password: testPasswordHash(),
}, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
cons, err := st.EnvironConstraints()
c.Assert(err, jc.ErrorIsNil)
c.Assert(cons, gc.DeepEquals, tcons)
machines, err := st.AllMachines()
c.Assert(err, jc.ErrorIsNil)
c.Assert(machines, gc.HasLen, 1)
cons, err = machines[0].Constraints()
c.Assert(err, jc.ErrorIsNil)
c.Assert(cons, gc.DeepEquals, tcons)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:31,代码来源:bootstrap_test.go
示例12: tryOpenState
func tryOpenState(modelTag names.ModelTag, info *mongo.MongoInfo) error {
st, err := state.Open(modelTag, info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if err == nil {
st.Close()
}
return err
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:machine_test.go
示例13: invalidateEnvironment
// invalidateEnvironment alters the environment configuration
// so the Settings returned from the watcher will not pass
// validation.
func (s *CommonProvisionerSuite) invalidateEnvironment(c *gc.C) {
st, err := state.Open(s.MongoInfo(c), mongo.DefaultDialOpts(), state.Policy(nil))
c.Assert(err, gc.IsNil)
defer st.Close()
attrs := map[string]interface{}{"type": "unknown"}
err = st.UpdateEnvironConfig(attrs, nil, nil)
c.Assert(err, gc.IsNil)
}
开发者ID:zhouqt,项目名称:juju,代码行数:11,代码来源:provisioner_test.go
示例14: openStateForUpgrade
func (s *UpgradeSuite) openStateForUpgrade() (*state.State, func(), error) {
mongoInfo := s.State.MongoConnectionInfo()
st, err := state.Open(s.State.ModelTag(), mongoInfo, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if err != nil {
return nil, nil, err
}
return st, func() { st.Close() }, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:8,代码来源:worker_test.go
示例15: TestEnvironmentChanges
func (s *environSuite) TestEnvironmentChanges(c *gc.C) {
originalConfig, err := s.State.EnvironConfig()
c.Assert(err, gc.IsNil)
logc := make(logChan, 1009)
c.Assert(loggo.RegisterWriter("testing", logc, loggo.WARNING), gc.IsNil)
defer loggo.RemoveWriter("testing")
obs, err := worker.NewEnvironObserver(s.State)
c.Assert(err, gc.IsNil)
env := obs.Environ()
c.Assert(env.Config().AllAttrs(), gc.DeepEquals, originalConfig.AllAttrs())
var oldType string
oldType = env.Config().AllAttrs()["type"].(string)
info := s.MongoInfo(c)
opts := mongo.DefaultDialOpts()
st2, err := state.Open(info, opts, state.Policy(nil))
defer st2.Close()
// Change to an invalid configuration and check
// that the observer's environment remains the same.
st2.UpdateEnvironConfig(map[string]interface{}{"type": "invalid"}, nil, nil)
st2.StartSync()
// Wait for the observer to register the invalid environment
timeout := time.After(coretesting.LongWait)
loop:
for {
select {
case msg := <-logc:
if strings.Contains(msg, "error creating Environ") {
break loop
}
case <-timeout:
c.Fatalf("timed out waiting to see broken environment")
}
}
// Check that the returned environ is still the same.
env = obs.Environ()
c.Assert(env.Config().AllAttrs(), gc.DeepEquals, originalConfig.AllAttrs())
// Change the environment back to a valid configuration
// with a different name and check that we see it.
st2.UpdateEnvironConfig(map[string]interface{}{"type": oldType, "name": "a-new-name"}, nil, nil)
st2.StartSync()
for a := coretesting.LongAttempt.Start(); a.Next(); {
env := obs.Environ()
if !a.HasNext() {
c.Fatalf("timed out waiting for new environ")
}
if env.Config().Name() == "a-new-name" {
break
}
}
}
开发者ID:klyachin,项目名称:juju,代码行数:58,代码来源:environ_test.go
示例16: AssertCanOpenState
func (s *AgentSuite) AssertCanOpenState(c *gc.C, tag names.Tag, dataDir string) {
config, err := agent.ReadConfig(agent.ConfigPath(dataDir, tag))
c.Assert(err, jc.ErrorIsNil)
info, ok := config.MongoInfo()
c.Assert(ok, jc.IsTrue)
st, err := state.Open(config.Model(), info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, jc.ErrorIsNil)
st.Close()
}
开发者ID:pmatulis,项目名称:juju,代码行数:9,代码来源:agent.go
示例17: TestConnWithPassword
func (*NewConnSuite) TestConnWithPassword(c *gc.C) {
attrs := dummy.SampleConfig().Merge(coretesting.Attrs{
"admin-secret": "nutkin",
})
cfg, err := config.New(config.NoDefaults, attrs)
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)
// Check that Bootstrap has correctly used a hash
// of the admin password.
info, _, err := env.StateInfo()
c.Assert(err, gc.IsNil)
info.Password = utils.UserPasswordHash("nutkin", utils.CompatSalt)
st, err := state.Open(info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, gc.IsNil)
assertClose(c, st)
// Check that we can connect with the original environment.
conn, err := juju.NewConn(env)
c.Assert(err, gc.IsNil)
assertClose(c, conn)
// Check that the password has now been changed to the original
// admin password.
info.Password = "nutkin"
st1, err := state.Open(info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, gc.IsNil)
assertClose(c, st1)
// Check that we can still connect with the original
// environment.
conn, err = juju.NewConn(env)
c.Assert(err, gc.IsNil)
defer assertClose(c, conn)
// Reset the admin password so the state db can be reused.
err = conn.State.SetAdminMongoPassword("")
c.Assert(err, gc.IsNil)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:44,代码来源:conn_test.go
示例18: TestInitializeEnvironment
func (s *BootstrapSuite) TestInitializeEnvironment(c *gc.C) {
hw := instance.MustParseHardware("arch=amd64 mem=8G")
machConf, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.envcfg, "--instance-id", string(s.instanceId), "--hardware", hw.String())
c.Assert(err, gc.IsNil)
err = cmd.Run(nil)
c.Assert(err, gc.IsNil)
c.Assert(s.fakeEnsureMongo.dataDir, gc.Equals, s.dataDir)
c.Assert(s.fakeEnsureMongo.initiateCount, gc.Equals, 1)
c.Assert(s.fakeEnsureMongo.ensureCount, gc.Equals, 1)
c.Assert(s.fakeEnsureMongo.dataDir, gc.Equals, s.dataDir)
c.Assert(s.fakeEnsureMongo.oplogSize, gc.Equals, 1234)
expectInfo, exists := machConf.StateServingInfo()
c.Assert(exists, jc.IsTrue)
c.Assert(expectInfo.SharedSecret, gc.Equals, "")
servingInfo := s.fakeEnsureMongo.info
c.Assert(len(servingInfo.SharedSecret), gc.Not(gc.Equals), 0)
servingInfo.SharedSecret = ""
c.Assert(servingInfo, jc.DeepEquals, expectInfo)
expectDialAddrs := []string{fmt.Sprintf("127.0.0.1:%d", expectInfo.StatePort)}
gotDialAddrs := s.fakeEnsureMongo.initiateParams.DialInfo.Addrs
c.Assert(gotDialAddrs, gc.DeepEquals, expectDialAddrs)
memberHost := fmt.Sprintf("%s:%d", s.bootstrapName, expectInfo.StatePort)
c.Assert(s.fakeEnsureMongo.initiateParams.MemberHostPort, gc.Equals, memberHost)
c.Assert(s.fakeEnsureMongo.initiateParams.User, gc.Equals, "")
c.Assert(s.fakeEnsureMongo.initiateParams.Password, gc.Equals, "")
st, err := state.Open(&authentication.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
},
Password: testPasswordHash(),
}, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, gc.IsNil)
defer st.Close()
machines, err := st.AllMachines()
c.Assert(err, gc.IsNil)
c.Assert(machines, gc.HasLen, 1)
instid, err := machines[0].InstanceId()
c.Assert(err, gc.IsNil)
c.Assert(instid, gc.Equals, instance.Id(string(s.instanceId)))
stateHw, err := machines[0].HardwareCharacteristics()
c.Assert(err, gc.IsNil)
c.Assert(stateHw, gc.NotNil)
c.Assert(*stateHw, gc.DeepEquals, hw)
cons, err := st.EnvironConstraints()
c.Assert(err, gc.IsNil)
c.Assert(&cons, jc.Satisfies, constraints.IsEmpty)
}
开发者ID:jiasir,项目名称:juju,代码行数:56,代码来源:bootstrap_test.go
示例19: testOpenState
func testOpenState(c *gc.C, info *authentication.MongoInfo, expectErrType error) {
st, err := state.Open(info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if st != nil {
st.Close()
}
if expectErrType != nil {
c.Assert(err, gc.FitsTypeOf, expectErrType)
} else {
c.Assert(err, gc.IsNil)
}
}
开发者ID:jiasir,项目名称:juju,代码行数:11,代码来源:bootstrap_test.go
示例20: testOpenState
func testOpenState(c *gc.C, info *mongo.MongoInfo, expectErrType error) {
st, err := state.Open(testing.EnvironmentTag, info, mongo.DefaultDialOpts(), environs.NewStatePolicy())
if st != nil {
st.Close()
}
if expectErrType != nil {
c.Assert(err, gc.FitsTypeOf, expectErrType)
} else {
c.Assert(err, jc.ErrorIsNil)
}
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:11,代码来源:bootstrap_test.go
注:本文中的github.com/juju/juju/mongo.DefaultDialOpts函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论