Esempio n. 1
0
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)
}
Esempio n. 2
0
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)
}
Esempio n. 3
0
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)
}
Esempio n. 4
0
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)
}
Esempio n. 5
0
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)
}
Esempio n. 6
0
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)

}
Esempio n. 7
0
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)
}
Esempio n. 8
0
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)
}
Esempio n. 9
0
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)
}
Esempio n. 10
0
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)
}