Merge lp:~axwalk/juju-core/lp1097556-mongod-failure-hangs-tests into lp:~go-bot/juju-core/trunk

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 1569
Proposed branch: lp:~axwalk/juju-core/lp1097556-mongod-failure-hangs-tests
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 22 lines (+5/-0)
1 file modified
testing/mgo.go (+5/-0)
To merge this branch: bzr merge lp:~axwalk/juju-core/lp1097556-mongod-failure-hangs-tests
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+177752@code.launchpad.net

Commit message

Prevent testing.MgoDial from hanging tests.

Add timeout to testing.MgoDial, so if mongod
fails, MgoDial doesn't block forever.

https://codereview.appspot.com/12150043/

Description of the change

Prevent testing.MgoDial from hanging tests.

Add timeout to testing.MgoDial, so if mongod
fails, MgoDial doesn't block forever.

https://codereview.appspot.com/12150043/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :

Reviewers: mp+177752_code.launchpad.net,

Message:
Please take a look.

Description:
Prevent testing.MgoDial from hanging tests.

Add timeout to testing.MgoDial, so if mongod
fails, MgoDial doesn't block forever.

https://code.launchpad.net/~axwalk/juju-core/lp1097556-mongod-failure-hangs-tests/+merge/177752

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/12150043/

Affected files:
   A [revision details]
   M testing/mgo.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20130731041121-ner0j2mn53rh64d7
+New revision: <email address hidden>

Index: testing/mgo.go
=== modified file 'testing/mgo.go'
--- testing/mgo.go 2013-07-09 10:32:23 +0000
+++ testing/mgo.go 2013-07-31 08:17:33 +0000
@@ -42,6 +42,10 @@
   mgoDir string
  )

+// We specify a timeout to mgo.Dial, to prevent
+// mongod failures hanging the tests.
+const mgoDialTimeout = 5 * time.Second
+
  // MgoSuite is a suite that deletes all content from the shared MongoDB
  // server at the end of every test and supplies a connection to the shared
  // MongoDB server.
@@ -183,6 +187,7 @@
    Dial: func(addr net.Addr) (net.Conn, error) {
     return tls.Dial("tcp", addr.String(), tlsConfig)
    },
+ Timeout: mgoDialTimeout,
   })
   if err != nil {
    panic(err)

Revision history for this message
William Reade (fwereade) wrote :
Revision history for this message
William Reade (fwereade) wrote :

On 2013/07/31 13:03:57, fwereade wrote:
> LGTM, thanks.

trivial, I think, go ahead and land it

https://codereview.appspot.com/12150043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testing/mgo.go'
2--- testing/mgo.go 2013-07-09 10:32:23 +0000
3+++ testing/mgo.go 2013-07-31 08:20:36 +0000
4@@ -42,6 +42,10 @@
5 mgoDir string
6 )
7
8+// We specify a timeout to mgo.Dial, to prevent
9+// mongod failures hanging the tests.
10+const mgoDialTimeout = 5 * time.Second
11+
12 // MgoSuite is a suite that deletes all content from the shared MongoDB
13 // server at the end of every test and supplies a connection to the shared
14 // MongoDB server.
15@@ -183,6 +187,7 @@
16 Dial: func(addr net.Addr) (net.Conn, error) {
17 return tls.Dial("tcp", addr.String(), tlsConfig)
18 },
19+ Timeout: mgoDialTimeout,
20 })
21 if err != nil {
22 panic(err)

Subscribers

People subscribed via source and target branches

to status/vote changes: