本文整理匯總了Golang中github.com/juju/juju/state.SetRetryHooks函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetRetryHooks函數的具體用法?Golang SetRetryHooks怎麽用?Golang SetRetryHooks使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SetRetryHooks函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestDestroySetCharmRetry
func (s *UnitSuite) TestDestroySetCharmRetry(c *gc.C) {
defer state.SetRetryHooks(c, s.State, func() {
err := s.unit.SetCharmURL(s.charm.URL())
c.Assert(err, gc.IsNil)
}, func() {
assertRemoved(c, s.unit)
}).Check()
err := s.unit.Destroy()
c.Assert(err, gc.IsNil)
}
示例2: TestDestroySetStatusRetry
func (s *UnitSuite) TestDestroySetStatusRetry(c *gc.C) {
defer state.SetRetryHooks(c, s.State, func() {
err := s.unit.SetStatus(params.StatusStarted, "", nil)
c.Assert(err, gc.IsNil)
}, func() {
assertLife(c, s.unit, state.Dying)
}).Check()
err := s.unit.Destroy()
c.Assert(err, gc.IsNil)
}
示例3: TestDestroySetStatusRetry
func (s *UnitSuite) TestDestroySetStatusRetry(c *gc.C) {
defer state.SetRetryHooks(c, s.State, func() {
err := s.unit.SetAgentStatus(state.StatusIdle, "", nil)
c.Assert(err, jc.ErrorIsNil)
}, func() {
assertLife(c, s.unit, state.Dying)
}).Check()
err := s.unit.Destroy()
c.Assert(err, jc.ErrorIsNil)
}
示例4: TestEnsureMinUnitsAddUnitsRetry
func (s *MinUnitsSuite) TestEnsureMinUnitsAddUnitsRetry(c *gc.C) {
err := s.service.SetMinUnits(3)
c.Assert(err, jc.ErrorIsNil)
defer state.SetRetryHooks(c, s.State, func() {
s.addUnits(c, 2)
}, func() {
assertAllUnits(c, s.service, 3)
}).Check()
err = s.service.EnsureMinUnits()
c.Assert(err, jc.ErrorIsNil)
}
示例5: TestMinUnitsInsertRetry
func (s *MinUnitsSuite) TestMinUnitsInsertRetry(c *gc.C) {
defer state.SetRetryHooks(c, s.State, func() {
err := s.service.SetMinUnits(41)
c.Assert(err, jc.ErrorIsNil)
s.assertRevno(c, 0, nil)
}, func() {
s.assertRevno(c, 1, nil)
}).Check()
err := s.service.SetMinUnits(42)
c.Assert(err, jc.ErrorIsNil)
c.Assert(s.service.MinUnits(), gc.Equals, 42)
}
示例6: TestEnsureMinUnitsUpdateMinUnitsRetry
func (s *MinUnitsSuite) TestEnsureMinUnitsUpdateMinUnitsRetry(c *gc.C) {
s.addUnits(c, 1)
err := s.service.SetMinUnits(4)
c.Assert(err, gc.IsNil)
defer state.SetRetryHooks(c, s.State, func() {
err := s.service.SetMinUnits(2)
c.Assert(err, gc.IsNil)
}, func() {
assertAllUnits(c, s.service, 2)
}).Check()
err = s.service.EnsureMinUnits()
c.Assert(err, gc.IsNil)
}
示例7: TestMinUnitsUpdateRetry
func (s *MinUnitsSuite) TestMinUnitsUpdateRetry(c *gc.C) {
err := s.service.SetMinUnits(41)
c.Assert(err, gc.IsNil)
defer state.SetRetryHooks(c, s.State, func() {
err := s.service.SetMinUnits(0)
c.Assert(err, gc.IsNil)
s.assertRevno(c, 0, mgo.ErrNotFound)
}, func() {
s.assertRevno(c, 0, nil)
}).Check()
err = s.service.SetMinUnits(42)
c.Assert(err, gc.IsNil)
c.Assert(s.service.MinUnits(), gc.Equals, 42)
}
示例8: TestDestroyUnassignRetry
func (s *UnitSuite) TestDestroyUnassignRetry(c *gc.C) {
machine, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, gc.IsNil)
err = s.unit.AssignToMachine(machine)
c.Assert(err, gc.IsNil)
defer state.SetRetryHooks(c, s.State, func() {
err := s.unit.UnassignFromMachine()
c.Assert(err, gc.IsNil)
}, func() {
assertRemoved(c, s.unit)
}).Check()
err = s.unit.Destroy()
c.Assert(err, gc.IsNil)
}
示例9: TestDestroyChangeCharmRetry
func (s *UnitSuite) TestDestroyChangeCharmRetry(c *gc.C) {
err := s.unit.SetCharmURL(s.charm.URL())
c.Assert(err, gc.IsNil)
newCharm := s.AddConfigCharm(c, "mysql", "options: {}", 99)
err = s.service.SetCharm(newCharm, false)
c.Assert(err, gc.IsNil)
defer state.SetRetryHooks(c, s.State, func() {
err := s.unit.SetCharmURL(newCharm.URL())
c.Assert(err, gc.IsNil)
}, func() {
assertRemoved(c, s.unit)
}).Check()
err = s.unit.Destroy()
c.Assert(err, gc.IsNil)
}
示例10: TestDestroyAssignRetry
func (s *UnitSuite) TestDestroyAssignRetry(c *gc.C) {
machine, err := s.State.AddMachine("quantal", state.JobHostUnits)
c.Assert(err, gc.IsNil)
defer state.SetRetryHooks(c, s.State, func() {
err := s.unit.AssignToMachine(machine)
c.Assert(err, gc.IsNil)
}, func() {
assertRemoved(c, s.unit)
// Also check the unit ref was properly removed from the machine doc --
// if it weren't, we wouldn't be able to make the machine Dead.
err := machine.EnsureDead()
c.Assert(err, gc.IsNil)
}).Check()
err = s.unit.Destroy()
c.Assert(err, gc.IsNil)
}