Skip to content

Commit 7f9dd4f

Browse files
tadukurowdomodwyer
authored andcommitted
Ignore dial error in dbtest after stopping server. (globalsign#122)
* 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.
1 parent c8fc2eb commit 7f9dd4f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dbtest/dbserver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func (dbs *DBServer) start() {
6969
dbs.server.Stderr = &dbs.output
7070
err = dbs.server.Start()
7171
if err != nil {
72+
// print error to facilitate troubleshooting as the panic will be caught in a panic handler
73+
fmt.Fprintf(os.Stderr, "mongod failed to start: %v\n",err)
7274
panic(err)
7375
}
7476
dbs.tomb.Go(dbs.monitor)

dbtest/dbserver_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ func (s *S) TestStop(c *C) {
7777
server.Stop()
7878

7979
// Server should not be running anymore.
80-
session, err = mgo.DialWithTimeout(addr, 500*time.Millisecond)
81-
c.Assert(err, IsNil)
82-
80+
session, _ = mgo.DialWithTimeout(addr, 500*time.Millisecond)
8381
if session != nil {
8482
session.Close()
8583
c.Fatalf("Stop did not stop the server")

0 commit comments

Comments
 (0)