本文整理匯總了Golang中github.com/juju/testing.MgoInstance.Start方法的典型用法代碼示例。如果您正苦於以下問題:Golang MgoInstance.Start方法的具體用法?Golang MgoInstance.Start怎麽用?Golang MgoInstance.Start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/testing.MgoInstance
的用法示例。
在下文中一共展示了MgoInstance.Start方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: startMongo
func (s *oplogSuite) startMongo(c *gc.C) (*jujutesting.MgoInstance, *mgo.Session) {
var inst jujutesting.MgoInstance
err := inst.Start(nil)
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(*gc.C) { inst.Destroy() })
return &inst, s.dialMongo(c, &inst)
}
示例2: testStateWorkerDialSetsWriteMajority
func (s *mongoSuite) testStateWorkerDialSetsWriteMajority(c *gc.C, configureReplset bool) {
inst := gitjujutesting.MgoInstance{
Params: []string{"--replSet", "juju"},
}
err := inst.Start(coretesting.Certs)
c.Assert(err, jc.ErrorIsNil)
defer inst.Destroy()
var expectedWMode string
dialOpts := stateWorkerDialOpts
dialOpts.Timeout = coretesting.LongWait
if configureReplset {
info := inst.DialInfo()
info.Timeout = dialOpts.Timeout
args := peergrouper.InitiateMongoParams{
DialInfo: info,
MemberHostPort: inst.Addr(),
}
err = peergrouper.InitiateMongoServer(args)
c.Assert(err, jc.ErrorIsNil)
expectedWMode = "majority"
} else {
dialOpts.Direct = true
}
mongoInfo := mongo.Info{
Addrs: []string{inst.Addr()},
CACert: coretesting.CACert,
}
session, err := mongo.DialWithInfo(mongoInfo, dialOpts)
c.Assert(err, jc.ErrorIsNil)
defer session.Close()
safe := session.Safe()
c.Assert(safe, gc.NotNil)
c.Assert(safe.WMode, gc.Equals, expectedWMode)
c.Assert(safe.J, jc.IsTrue) // always enabled
}