Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Hook up mgo logging and reconnect properly. #110
Conversation
| @@ -422,7 +423,16 @@ func MgoTestPackage(t *testing.T, certs *Certs) { | ||
| gc.TestingT(t) | ||
| } | ||
| +// Output implements the mgo log_Logger interface. | ||
| +func (s *MgoSuite) Output(calldepth int, message string) error { |
mjs
Sep 16, 2016
•
I don't mind too much, but this doesn't really belong on the suite. A simpler wrapper type would be cleaner. The logger wouldn't even have to be added as a field on MgoSuite...
| @@ -758,6 +770,7 @@ func (inst *MgoInstance) EnsureRunning() error { | ||
| // If the server has already been destroyed for testing purposes, | ||
| // just start it again. | ||
| if inst.Addr() == "" { | ||
| + logger.Infof("restarting mongo instance") |
| + foundAddress := false | ||
| + for _, addr := range s.Session.LiveServers() { | ||
| + if addr == MgoServer.Addr() { | ||
| + foundAddress = true |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-testing |
jujubot
merged commit cad2dd5
into
juju:master
Sep 16, 2016
howbazaar
deleted the
howbazaar:reconnect-properly
branch
Sep 16, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
howbazaar commentedSep 16, 2016
Now the mgo logging is output through loggo to the "mgo" logger.
This means it is now available to be shown, but not shown by default.
To enable in other tests, they can (after logging is set up) set:
loggo.GetLogger("mgo").SetLogLevel(loggo.TRACE)
Also, when the mongo server is changed by either restarting, or other tests killing it, the teardown now reconnects the session, which avoids some of the "no reachable servers" errors we were seeing.