Merge lp:~axwalk/juju-core/replicaset-test-race 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: 2314
Proposed branch: lp:~axwalk/juju-core/replicaset-test-race
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 22 lines (+8/-4)
1 file modified
replicaset/replicaset_test.go (+8/-4)
To merge this branch: bzr merge lp:~axwalk/juju-core/replicaset-test-race
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+205900@code.launchpad.net

Commit message

replicaset: fix race/nil pointer deref in test

If CurrentStatus returns an error but there are
still more attempts, then the test continues on
and refers to a nil result.

Description of the change

replicaset: fix race/nil pointer deref in test

If CurrentStatus returns an error but there are
still more attempts, then the test continues on
and refers to a nil result.

As seen in:
https://code.launchpad.net/~axwalk/juju-core/local-provider-testability/+merge/204169/comments/482324

https://codereview.appspot.com/62040043/

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

Reviewers: mp+205900_code.launchpad.net,

Message:
Please take a look.

Description:
replicaset: fix race/nil pointer deref in test

If CurrentStatus returns an error but there are
still more attempts, then the test continues on
and refers to a nil result.

As seen in:
https://code.launchpad.net/~axwalk/juju-core/local-provider-testability/+merge/204169/comments/482324

https://code.launchpad.net/~axwalk/juju-core/replicaset-test-race/+merge/205900

(do not edit description out of merge proposal)

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

Affected files (+10, -4 lines):
   A [revision details]
   M replicaset/replicaset_test.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-20140211064343-d5yn0b3om93nuecj
+New revision: <email address hidden>

Index: replicaset/replicaset_test.go
=== modified file 'replicaset/replicaset_test.go'
--- replicaset/replicaset_test.go 2014-01-13 21:18:11 +0000
+++ replicaset/replicaset_test.go 2014-02-12 05:20:21 +0000
@@ -348,10 +348,14 @@
   for attempt.Next() {
    var err error
    res, err = CurrentStatus(session)
-
- if err != nil && !attempt.HasNext() {
- c.Errorf("Couldn't get status before timeout, got err: %v", err)
- return
+ if err != nil {
+ if !attempt.HasNext() {
+ c.Errorf("Couldn't get status before timeout, got err: %v", err)
+ return
+ } else {
+ // try again
+ continue
+ }
    }

    if res.Members[0].State == PrimaryState &&

Revision history for this message
Ian Booth (wallyworld) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'replicaset/replicaset_test.go'
2--- replicaset/replicaset_test.go 2014-01-13 21:18:11 +0000
3+++ replicaset/replicaset_test.go 2014-02-12 05:36:19 +0000
4@@ -348,10 +348,14 @@
5 for attempt.Next() {
6 var err error
7 res, err = CurrentStatus(session)
8-
9- if err != nil && !attempt.HasNext() {
10- c.Errorf("Couldn't get status before timeout, got err: %v", err)
11- return
12+ if err != nil {
13+ if !attempt.HasNext() {
14+ c.Errorf("Couldn't get status before timeout, got err: %v", err)
15+ return
16+ } else {
17+ // try again
18+ continue
19+ }
20 }
21
22 if res.Members[0].State == PrimaryState &&

Subscribers

People subscribed via source and target branches

to status/vote changes: