Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook up mgo logging and reconnect properly. #110

Merged
merged 1 commit into from
Sep 16, 2016

Conversation

howbazaar
Copy link
Contributor

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.

@@ -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 {
Copy link

@mjs mjs Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

foundAddress := false
for _, addr := range s.Session.LiveServers() {
if addr == MgoServer.Addr() {
foundAddress = true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@@ -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")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be debug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@howbazaar
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Contributor

jujubot commented Sep 16, 2016

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

@jujubot jujubot merged commit cad2dd5 into juju:master Sep 16, 2016
@howbazaar howbazaar deleted the reconnect-properly branch September 16, 2016 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants