Skip to content

Commit

Permalink
Merge pull request #3843 from mjs/upgrade-steps-test-refactor
Browse files Browse the repository at this point in the history
Refactor tests for upgrade-steps worker

These revisions make significant changes to the tests for the upgrade-tests worker in order to make it possible to extract the worker into it's own subpackage under "/worker". The tests used to be heavily reliant on the commonMachineSuite suite in cmd/jujud/agent.

Highlights:

1. Some tests which were testing functionality that is already better tested elsewhere were removed.
2. The functional style tests which spin up a full machine agent were moved to featuretests and were reworked to use cmd/jujud/agent/testing.AgentSuite.
3. The unit style tests are now based on state/testing.StateSuite (a much simpler base suite).
4. Many many clean ups.

There are a number of new TODOs in the new feature tests regarding changes to AgentSuite which
are too big too include in this PR. They will be addressed shortly.

(Review request: http://reviews.vapour.ws/r/3262/)
  • Loading branch information
jujubot committed Nov 29, 2015
2 parents da5ec85 + 2b942c5 commit c932fce
Show file tree
Hide file tree
Showing 4 changed files with 398 additions and 441 deletions.
16 changes: 8 additions & 8 deletions cmd/jujud/agent/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ type upgradingMachineAgent interface {
}

var (
upgradesPerformUpgrade = upgrades.PerformUpgrade // Allow patching
PerformUpgrade = upgrades.PerformUpgrade // Allow patching

// The maximum time a master state server will wait for other
// state servers to come up and indicate they are ready to begin
// running upgrade steps.
upgradeStartTimeoutMaster = time.Minute * 15
UpgradeStartTimeoutMaster = time.Minute * 15

// The maximum time a secondary state server will wait for other
// state servers to come up and indicate they are ready to begin
Expand All @@ -49,7 +49,7 @@ var (
// This should get reduced when/if master re-elections are
// introduce in the case a master that failing to come up for
// upgrade.
upgradeStartTimeoutSecondary = time.Hour * 4
UpgradeStartTimeoutSecondary = time.Hour * 4
)

func NewUpgradeWorkerContext() *upgradeWorkerContext {
Expand Down Expand Up @@ -173,7 +173,7 @@ func (c *upgradeWorkerContext) run(stop <-chan struct{}) error {
}
defer c.st.Close()

if c.isMaster, err = isMachineMaster(c.st, c.machineId); err != nil {
if c.isMaster, err = IsMachineMaster(c.st, c.machineId); err != nil {
return errors.Trace(err)
}

Expand Down Expand Up @@ -336,7 +336,7 @@ func (c *upgradeWorkerContext) runUpgradeSteps(agentConfig agent.ConfigSetter) e
targets := jobsToTargets(c.jobs, c.isMaster)
attempts := getUpgradeRetryStrategy()
for attempt := attempts.Start(); attempt.Next(); {
upgradeErr = upgradesPerformUpgrade(c.fromVersion, targets, context)
upgradeErr = PerformUpgrade(c.fromVersion, targets, context)
if upgradeErr == nil {
break
}
Expand Down Expand Up @@ -396,9 +396,9 @@ func getUpgradeStartTimeout(isMaster bool) time.Duration {
}

if isMaster {
return upgradeStartTimeoutMaster
return UpgradeStartTimeoutMaster
}
return upgradeStartTimeoutSecondary
return UpgradeStartTimeoutSecondary
}

var openStateForUpgrade = func(
Expand All @@ -420,7 +420,7 @@ var openStateForUpgrade = func(
return st, nil
}

var isMachineMaster = func(st *state.State, machineId string) (bool, error) {
var IsMachineMaster = func(st *state.State, machineId string) (bool, error) {
if st == nil {
// If there is no state, we aren't a master.
return false, nil
Expand Down

0 comments on commit c932fce

Please sign in to comment.