Example #1
0
func (s *upgradeStateContextSuite) TestInstalledBooleanTrueIfInstalled(c *gc.C) {
	oldState := &operation.State{
		Kind: operation.Continue,
		Step: operation.Pending,
	}
	err := s.statefile.Write(oldState)
	c.Assert(err, jc.ErrorIsNil)
	err = uniter.AddInstalledToUniterState(s.unitTag, s.datadir)
	c.Assert(err, jc.ErrorIsNil)
	newState := s.readState(c)
	c.Assert(newState.Installed, gc.Equals, true)
}
Example #2
0
File: unit.go Project: makyo/juju
// runUpgrades is a temporary fix to deal with upgrade steps that need
// to be run for each unit. This function cannot fail. Errors in the
// upgrade steps are logged, but the uniter will attempt to continue.
// Worst case, we are no worse off than we are today, best case, things
// actually work properly. Only simple upgrade steps that don't use the API
// are available now. If we need really complex steps using the API, there
// should be significant steps to unify the agents first.
func runUpgrades(tag names.Tag, dataDir string) {
	unitTag, ok := tag.(names.UnitTag)
	if !ok {
		logger.Errorf("unit agent tag not a unit tag: %v", tag)
		return
	}
	if err := uniter.AddStoppedFieldToUniterState(unitTag, dataDir); err != nil {
		logger.Errorf("Upgrade step failed - add Stopped field to uniter state: %v", err)
	}
	if err := uniter.AddInstalledToUniterState(unitTag, dataDir); err != nil {
		logger.Errorf("Upgrade step failed - installed boolean needs to be set in the uniter local state: %v", err)
	}
}
Example #3
0
func (s *upgradeStateContextSuite) TestInstalledBooleanFalseIfInstalling(c *gc.C) {
	oldState := &operation.State{
		Kind:     operation.Install,
		Step:     operation.Pending,
		CharmURL: charm.MustParseURL("local:quantal/charm"),
	}
	err := s.statefile.Write(oldState)
	c.Assert(err, jc.ErrorIsNil)
	err = uniter.AddInstalledToUniterState(s.unitTag, s.datadir)
	c.Assert(err, jc.ErrorIsNil)
	newState := s.readState(c)
	c.Assert(newState.Installed, gc.Equals, false)
}
Example #4
0
func (s *upgradeStateContextSuite) TestInstalledBooleanFalseIfRunHookInstalling(c *gc.C) {
	oldState := &operation.State{
		Kind: operation.RunHook,
		Step: operation.Pending,
		Hook: &hook.Info{
			Kind: hooks.Install,
		},
	}
	err := s.statefile.Write(oldState)
	c.Assert(err, jc.ErrorIsNil)
	err = uniter.AddInstalledToUniterState(s.unitTag, s.datadir)
	c.Assert(err, jc.ErrorIsNil)
	newState := s.readState(c)
	c.Assert(newState.Installed, gc.Equals, false)
}