Test UpdateStatus Hook and add UniterParams #2586

Merged
merged 2 commits into from Jun 19, 2015

Conversation

Projects
None yet
4 participants
Contributor

perrito666 commented Jun 17, 2015

Added proper testing for update-status hook and also
converted uniter to use UniterParams instead of a lot
of arguments, making it cleaner to use.
A proper way to change metrics timer was also added.

Test UpdateStatus Hook and add UniterParams
Added proper testing for update-status hook and also
converted uniter to use UniterParams instead of a lot
of arguments, making it cleaner to use.
A proper way to change metrics timer was also added.
worker/uniter/metrics.go
@@ -28,12 +28,30 @@ func inactiveMetricsTimer(_, _ time.Time, _ time.Duration) <-chan time.Time {
return nil
}
+type timerChooser struct {
@wallyworld

wallyworld Jun 18, 2015

Owner

not exported, but a comment as to what this is for i think would be good

worker/uniter/metrics.go
+ return t.inactive
+}
+
+func NewMetricsTimerChooser() *timerChooser {
@wallyworld

wallyworld Jun 18, 2015

Owner

comment please

worker/uniter/modes.go
@@ -276,7 +276,7 @@ func ModeAbide(u *Uniter) (next Mode, err error) {
// idleWaitTime is the time after which, if there are no uniter events,
// the agent state becomes idle.
-var idleWaitTime = 2 * time.Second
+var idleWaitTime = 10 * time.Second
@wallyworld

wallyworld Jun 18, 2015

Owner

Why did we change this? 10s is too long IMO. A hook will show executing long after it has finished.

@fwereade

fwereade Jun 18, 2015

Contributor

Because the underlying event resolution is 5s, and I think that 5s is the absolute minimum; and I'd rather see units take a bit longer in yellow and then go solid green, rather than to flicker optimistically back and forth. I could maybe be argued down closer to 5s?

@@ -204,6 +206,21 @@ func (s *UniterSuite) TestUniterInstallHook(c *gc.C) {
})
}
+func (s *UniterSuite) TestUniterUpdateStatusHook(c *gc.C) {
@wallyworld

wallyworld Jun 18, 2015

Owner

Is this sufficient? The status update hook also fires after significant events eg config-changed hook etc. Perhaps there are other tests I've forgotten about.

@perrito666

perrito666 Jun 18, 2015

Contributor

It is suficcient, the tests for the additional calls of update status are in the following patch which, additionally has those calls :)

worker/uniter/uniter.go
@@ -46,6 +46,8 @@ type UniterExecutionObserver interface {
HookFailed(hookName string)
}
+type simpleUniterFunc func(*Uniter) error
@fwereade

fwereade Jun 18, 2015

Contributor

are we still using this?

worker/uniter/uniter.go
+ LeadershipManager coreleadership.LeadershipManager
+ DataDir string
+ HookLock *fslock.Lock
+ MetricsTimer *timerChooser
@fwereade

fwereade Jun 18, 2015

Contributor

MetricsTimerChooser?

worker/uniter/uniter.go
+ DataDir string
+ HookLock *fslock.Lock
+ MetricsTimer *timerChooser
+ UpdateStatusSignal TimedSignal
@fwereade

fwereade Jun 18, 2015

Contributor

Did we actually want/need this? I thought we could do it entirely within the loop func.

(To be clear, I'm quite happy to have the timing managed by some type; but I don't think it's instance-scoped, I think it's only relevant within the abide loop.)

@fwereade

fwereade Jun 18, 2015

Contributor

...ah, yes we do. Ignore me.

worker/uniter/uniter.go
+ metricsTimer: uniterParams.MetricsTimer,
+ // TODO(perrito666) make these signals directly fetched from
+ // the timer.
+ collectMetricsAt: uniterParams.MetricsTimer.defaultTimer(),
@fwereade

fwereade Jun 18, 2015

Contributor

why defaultTimer and not inactiveTimer? we're making an explicit choice to use an inactive timer at this point, not because it's default but because it's not safe to read the data that would allow us to choose otherwise; and later we will make an explicit choice between active and inactive timers depending on the charm's features. There's nothing default about inactivity.

Contributor

fwereade commented Jun 18, 2015

Apart from some naming quibbles, this LGTM with agreement from ian on idle timing.

Contributor

perrito666 commented Jun 19, 2015

$$merge$$

Contributor

jujubot commented Jun 19, 2015

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

jujubot added a commit that referenced this pull request Jun 19, 2015

Merge pull request #2586 from perrito666/uas_add_testing_for_update_s…
…tatus_hool

Test UpdateStatus Hook and add UniterParams

Added proper testing for update-status hook and also
converted uniter to use UniterParams instead of a lot
of arguments, making it cleaner to use.
A proper way to change metrics timer was also added.

@jujubot jujubot merged commit f21dfe8 into juju:master Jun 19, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment