Merge lp:~axwalk/juju-core/lp1318527-testing-dropdatabases 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: | 2730 |
Proposed branch: | lp:~axwalk/juju-core/lp1318527-testing-dropdatabases |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
37 lines (+20/-0) 1 file modified
testing/mgo.go (+20/-0) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1318527-testing-dropdatabases |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+219462@code.launchpad.net |
Commit message
testing: drop databases before each Mgo test
Previously the store package had its own mgo
suite, which was largely the same as the one
in juju-core/testing. It also had code to drop
the non-admin databases before each test case,
which I did not carry over when migrating. This
caused flakeyness.
Fixes lp:1318527
Description of the change
testing: drop databases before each Mgo test
Previously the store package had its own mgo
suite, which was largely the same as the one
in juju-core/testing. It also had code to drop
the non-admin databases before each test case,
which I did not carry over when migrating. This
caused flakeyness.
Fixes lp:1318527
To post a comment you must log in.
Reviewers: mp+219462_ code.launchpad. net,
Message:
Please take a look.
Description:
testing: drop databases before each Mgo test
Previously the store package had its own mgo
suite, which was largely the same as the one
in juju-core/testing. It also had code to drop
the non-admin databases before each test case,
which I did not carry over when migrating. This
caused flakeyness.
Fixes lp:1318527
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1318527- testing- dropdatabases/ +merge/ 219462
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/94460045/
Affected files (+22, -0 lines):
A [revision details]
M testing/mgo.go
Index: [revision details] 20140514033806- f68i80gbds824vt w
=== 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-
+New revision: <email address hidden>
Index: testing/mgo.go MustDial( )
=== modified file 'testing/mgo.go'
--- testing/mgo.go 2014-05-12 07:59:38 +0000
+++ testing/mgo.go 2014-05-14 07:25:05 +0000
@@ -401,6 +401,7 @@
func (s *MgoSuite) SetUpTest(c *gc.C) {
mgo.ResetStats()
s.Session = MgoServer.
+ dropAll(s.Session)
}
// Reset deletes all content from the MongoDB server and panics if it
encounters
@@ -441,6 +442,25 @@
}
}
+// dropAll drops all databases apart from admin, local and config. DatabaseNames( ) DB(name) .DropDatabase( ) ordAndFetchDBNa mes logs into the database with a
+func dropAll(session *mgo.Session) (err error) {
+ names, err := session.
+ if err != nil {
+ return err
+ }
+ for _, name := range names {
+ switch name {
+ case "admin", "local", "config":
+ default:
+ err = session.
+ if err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
// resetAdminPassw
// plausible password and returns all the database's db names. We need
// to try several passwords because we don't know what state the mongo