Skip to content

Commit

Permalink
Ignore dial error in dbtest after stopping server. (globalsign#122)
Browse files Browse the repository at this point in the history
* Ignore dial error when server is stopped. related to globalsign#117

* Print dbtest server starting error before panic.

As seen in globalsign#117, dbtest start() throws a panic when it can't start mongo.
This panic is picked up by a panichandler obscuring the actual problem.
This PR simply prints the error start() encounters to stderr, before throwing the panic.
  • Loading branch information
tadukurow authored and domodwyer committed Mar 12, 2018
1 parent 860240e commit aa690cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions dbtest/dbserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func (dbs *DBServer) start() {
dbs.server.Stderr = &dbs.output
err = dbs.server.Start()
if err != nil {
// print error to facilitate troubleshooting as the panic will be caught in a panic handler
fmt.Fprintf(os.Stderr, "mongod failed to start: %v\n",err)
panic(err)
}
dbs.tomb.Go(dbs.monitor)
Expand Down
4 changes: 1 addition & 3 deletions dbtest/dbserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ func (s *S) TestStop(c *C) {
server.Stop()

// Server should not be running anymore.
session, err = mgo.DialWithTimeout(addr, 500*time.Millisecond)
c.Assert(err, IsNil)

session, _ = mgo.DialWithTimeout(addr, 500*time.Millisecond)
if session != nil {
session.Close()
c.Fatalf("Stop did not stop the server")
Expand Down

0 comments on commit aa690cd

Please sign in to comment.