~waigani/juju-core/user-detail

« back to all changes in this revision

Viewing changes to replicaset/replicaset_test.go

  • Committer: Tarmac
  • Author(s): Ian Booth
  • Date: 2014-05-27 05:03:26 UTC
  • mfrom: (2795.1.1 replicaset-test-setup)
  • Revision ID: tarmac-20140527050326-y76dbybaykpv5lc8
[r=wallyworld] Attempt to make replicaset tests robust

The repliaset tests were creating a mongo instance
for the suite and cleaning up replicas etc between
tests. This branch changes that to set up a new
instance for each test. A bunch of cleanup code can
then be removed and there will be better isolation
between tests. This may hopefully help with some
of the intermittent replicaset test failures.

https://codereview.appspot.com/101780043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
var _ = gc.Suite(&MongoSuite{})
48
48
 
49
 
func (s *MongoSuite) SetUpSuite(c *gc.C) {
50
 
        s.BaseSuite.SetUpSuite(c)
 
49
func (s *MongoSuite) SetUpTest(c *gc.C) {
 
50
        s.BaseSuite.SetUpTest(c)
51
51
        s.root = newServer(c)
52
52
        s.dialAndTestInitiate(c)
53
53
}
54
54
 
55
55
func (s *MongoSuite) TearDownTest(c *gc.C) {
56
 
        // remove all secondaries from the replicaset on test teardown
57
 
        session, err := s.root.DialDirect()
58
 
        if err != nil {
59
 
                c.Logf("Failed to dial root during test cleanup: %v", err)
60
 
                return
61
 
        }
62
 
        defer session.Close()
63
 
        mems, err := CurrentMembers(session)
64
 
        if err != nil {
65
 
                c.Logf("Failed to get list of memners during test cleanup: %v", err)
66
 
                return
67
 
        }
68
 
        addrs := []string{}
69
 
        for _, m := range mems {
70
 
                if s.root.Addr() != m.Address {
71
 
                        addrs = append(addrs, m.Address)
72
 
                }
73
 
        }
74
 
        err = Remove(session, addrs...)
75
 
        c.Assert(err, gc.IsNil)
 
56
        s.root.Destroy()
76
57
        s.BaseSuite.TearDownTest(c)
77
58
}
78
59
 
126
107
        }
127
108
}
128
109
 
129
 
func (s *MongoSuite) TearDownSuite(c *gc.C) {
130
 
        s.root.Destroy()
131
 
        s.BaseSuite.TearDownSuite(c)
132
 
}
133
 
 
134
110
func attemptLoop(c *gc.C, strategy utils.AttemptStrategy, desc string, f func() error) {
135
111
        var err error
136
112
        start := time.Now()