Fixed races in cleaner test #2621

Merged
merged 2 commits into from Jun 22, 2015

Conversation

Projects
None yet
3 participants
Contributor

dooferlad commented Jun 22, 2015

api/base/testing/apicaller.go
@@ -49,6 +49,34 @@ type CheckArgs struct {
VersionIsZero bool
}
+func checkArgs(c *gc.C, args *CheckArgs, facade string, version int, id, method string, inArgs, outResults interface{}) {
+ if args != nil {
@dimitern

dimitern Jun 22, 2015

Contributor

How about?

if args == nil {
  c.Logf("checkArgs: args is nil!")
  return
}
if args.Facade != "" {
...
}
@dooferlad

dooferlad Jun 22, 2015

Contributor

I just moved existing code - didn't want to change the functionality. I agree that moving the if args != nil out of that function and putting it in the caller would make it more obvious that args checking is only done if you pass in expected args. It seems like the original intent was for args = nil to be OK.

api/base/testing/apicaller.go
+// time it recives a call, as well as check if any of the arguments passed to the APICall() method match
+// the values given in args (if args itself is not nil, otherwise no arguments are checked). The final
+// error result of the APICall() will be set to err.
+func PingingCheckingAPICaller(c *gc.C, args *CheckArgs, called chan struct{}, err error) base.APICaller {
@dimitern

dimitern Jun 22, 2015

Contributor

I don't like "Pinging" - it might imply it has something to do with apiserver.Ping(). How about dropping the original CheckingAPICaller and using only this one instead? It shouldn't be too difficult to change existing tests?

@dooferlad

dooferlad Jun 22, 2015

Contributor

It would be a much larger change to switch over the existing tests (api/instancepoller) outside of api/cleaner. The instance poller tests are perfectly served by CheckingAPICaller, so changing them would be a nuisance.

How about CheckingAPICallPoller as a better name? NotifyingCheckingAPICaller? I don't mind overloading ping with yet another implementation myself, but don't have a strong opinion.

Contributor

dimitern commented Jun 22, 2015

LGTM with the suggested changes.

Contributor

dimitern commented Jun 22, 2015

I still think 'if args != nil' should be checked first (I wrote it, so I should've done it like this in retrospect :/) to save some indentation. I'm OK with renaming PingingCheckingAPICaller to NotifyingCheckingAPICaller.

Contributor

dooferlad commented Jun 22, 2015

$$merge$$

Contributor

jujubot commented Jun 22, 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 22, 2015

@jujubot jujubot merged commit b5f3ec3 into juju:master Jun 22, 2015

@dooferlad dooferlad deleted the dooferlad:master-fix-cleaner-races branch Jul 6, 2015

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