Пример #1
0
func (s *UpgradeSuite) TestAbortCurrentUpgrade(c *gc.C) {
	// First try with nothing to abort.
	err := s.State.AbortCurrentUpgrade()
	c.Assert(err, jc.ErrorIsNil)

	upgradeInfos, err := state.GetAllUpgradeInfos(s.State)
	c.Assert(len(upgradeInfos), gc.Equals, 0)

	// Now create a UpgradeInfo to abort.
	_, err = s.State.EnsureUpgradeInfo(s.serverIdA, vers("1.1.1"), vers("1.2.3"))
	c.Assert(err, jc.ErrorIsNil)

	err = s.State.AbortCurrentUpgrade()
	c.Assert(err, jc.ErrorIsNil)

	info := s.getOneUpgradeInfo(c)
	c.Check(info.Status(), gc.Equals, state.UpgradeAborted)

	// It should now be possible to start another upgrade.
	_, err = s.State.EnsureUpgradeInfo(s.serverIdA, vers("1.2.3"), vers("1.3.0"))
	c.Check(err, jc.ErrorIsNil)
}
Пример #2
0
func (s *UpgradeSuite) getOneUpgradeInfo(c *gc.C) *state.UpgradeInfo {
	upgradeInfos, err := state.GetAllUpgradeInfos(s.State)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(len(upgradeInfos), gc.Equals, 1)
	return upgradeInfos[0]
}