Ejemplo n.º 1
0
func (s *UnitSuite) TestDestroySetCharmRetry(c *C) {
	defer state.SetRetryHooks(c, s.State, func() {
		err := s.unit.SetCharmURL(s.charm.URL())
		c.Assert(err, IsNil)
	}, func() {
		assertUnitRemoved(c, s.unit)
	}).Check()
	err := s.unit.Destroy()
	c.Assert(err, IsNil)
}
Ejemplo n.º 2
0
func (s *UnitSuite) TestDestroySetStatusRetry(c *C) {
	defer state.SetRetryHooks(c, s.State, func() {
		err := s.unit.SetStatus(params.StatusStarted, "")
		c.Assert(err, IsNil)
	}, func() {
		assertUnitLife(c, s.unit, state.Dying)
	}).Check()
	err := s.unit.Destroy()
	c.Assert(err, IsNil)
}
Ejemplo n.º 3
0
func (s *MinUnitsSuite) TestEnsureMinUnitsAddUnitsRetry(c *C) {
	err := s.service.SetMinUnits(3)
	c.Assert(err, IsNil)
	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, IsNil)
}
Ejemplo n.º 4
0
func (s *MinUnitsSuite) TestMinUnitsInsertRetry(c *C) {
	defer state.SetRetryHooks(c, s.State, func() {
		err := s.service.SetMinUnits(41)
		c.Assert(err, IsNil)
		s.assertRevno(c, 0, nil)
	}, func() {
		s.assertRevno(c, 1, nil)
	}).Check()
	err := s.service.SetMinUnits(42)
	c.Assert(err, IsNil)
	c.Assert(s.service.MinUnits(), Equals, 42)
}
Ejemplo n.º 5
0
func (s *MinUnitsSuite) TestMinUnitsUpdateRetry(c *C) {
	err := s.service.SetMinUnits(41)
	c.Assert(err, IsNil)
	defer state.SetRetryHooks(c, s.State, func() {
		err := s.service.SetMinUnits(0)
		c.Assert(err, IsNil)
		s.assertRevno(c, 0, mgo.ErrNotFound)
	}, func() {
		s.assertRevno(c, 0, nil)
	}).Check()
	err = s.service.SetMinUnits(42)
	c.Assert(err, IsNil)
	c.Assert(s.service.MinUnits(), Equals, 42)
}
Ejemplo n.º 6
0
func (s *UnitSuite) TestDestroyUnassignRetry(c *C) {
	machine, err := s.State.AddMachine("series", state.JobHostUnits)
	c.Assert(err, IsNil)
	err = s.unit.AssignToMachine(machine)
	c.Assert(err, IsNil)

	defer state.SetRetryHooks(c, s.State, func() {
		err := s.unit.UnassignFromMachine()
		c.Assert(err, IsNil)
	}, func() {
		assertUnitRemoved(c, s.unit)
	}).Check()
	err = s.unit.Destroy()
	c.Assert(err, IsNil)
}
Ejemplo n.º 7
0
func (s *UnitSuite) TestDestroyChangeCharmRetry(c *C) {
	err := s.unit.SetCharmURL(s.charm.URL())
	c.Assert(err, IsNil)
	newCharm := s.AddConfigCharm(c, "mysql", "options: {}", 99)
	err = s.service.SetCharm(newCharm, false)
	c.Assert(err, IsNil)

	defer state.SetRetryHooks(c, s.State, func() {
		err := s.unit.SetCharmURL(newCharm.URL())
		c.Assert(err, IsNil)
	}, func() {
		assertUnitRemoved(c, s.unit)
	}).Check()
	err = s.unit.Destroy()
	c.Assert(err, IsNil)
}
Ejemplo n.º 8
0
func (s *UnitSuite) TestDestroyAssignRetry(c *C) {
	machine, err := s.State.AddMachine("series", state.JobHostUnits)
	c.Assert(err, IsNil)

	defer state.SetRetryHooks(c, s.State, func() {
		err := s.unit.AssignToMachine(machine)
		c.Assert(err, IsNil)
	}, func() {
		assertUnitRemoved(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, IsNil)
	}).Check()
	err = s.unit.Destroy()
	c.Assert(err, IsNil)
}