Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit d1c9089

Browse files
committed
Polish the suite a tad.
1 parent d1c6cd2 commit d1c9089

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ func (s *S) TestDefaultDatabase(c *C) {
744744
func (s *S) TestAuthDirect(c *C) {
745745
// Direct connections must work to the master and slaves.
746746
for _, port := range []string{"40031", "40032", "40033"} {
747-
url := fmt.Sprintf("mongodb://reader:rapadura@localhost:%s/?connect=direct", port)
747+
url := fmt.Sprintf("mongodb://root:rapadura@localhost:%s/?connect=direct", port)
748748
session, err := mgo.Dial(url)
749749
c.Assert(err, IsNil)
750750
defer session.Close()

cluster_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,9 @@ func (s *S) TestPrimaryShutdownMonotonic(c *C) {
538538
err = coll.Insert(M{"a": 1})
539539
c.Assert(err, IsNil)
540540

541+
// Wait a bit for this to be synchronized to slaves.
542+
time.Sleep(3 * time.Second)
543+
541544
result := &struct{ Host string }{}
542545
err = session.Run("serverStatus", result)
543546
c.Assert(err, IsNil)
@@ -662,6 +665,9 @@ func (s *S) TestPrimaryShutdownEventual(c *C) {
662665
err = coll.Insert(M{"a": 1})
663666
c.Assert(err, IsNil)
664667

668+
// Wait a bit for this to be synchronized to slaves.
669+
time.Sleep(3 * time.Second)
670+
665671
// Kill the master.
666672
s.Stop(master)
667673

@@ -1314,6 +1320,10 @@ func (s *S) TestConnectCloseConcurrency(c *C) {
13141320
}
13151321

13161322
func (s *S) TestSelectServers(c *C) {
1323+
if !s.versionAtLeast(2, 2) {
1324+
c.Skip("read preferences introduced in 2.2")
1325+
}
1326+
13171327
session, err := mgo.Dial("localhost:40011")
13181328
c.Assert(err, IsNil)
13191329
defer session.Close()
@@ -1336,6 +1346,10 @@ func (s *S) TestSelectServers(c *C) {
13361346
}
13371347

13381348
func (s *S) TestSelectServersWithMongos(c *C) {
1349+
if !s.versionAtLeast(2, 2) {
1350+
c.Skip("read preferences introduced in 2.2")
1351+
}
1352+
13391353
session, err := mgo.Dial("localhost:40021")
13401354
c.Assert(err, IsNil)
13411355
defer session.Close()

testdb/init.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ function configShards() {
5050

5151
function configAuth() {
5252
var addrs = ["127.0.0.1:40002", "127.0.0.1:40203", "127.0.0.1:40031"]
53-
var ports = [40002, 40203]
5453
for (var i in addrs) {
5554
db = new Mongo(addrs[i]).getDB("admin")
5655
db.addUser("root", "rapadura")
5756
db.auth("root", "rapadura")
58-
db.addUser("reader", "rapadura", true)
57+
if (db.serverBuildInfo().versionArray >= [2, 4]) {
58+
db.addUser({user: "reader", pwd: "rapadura", roles: ["readAnyDatabase"]})
59+
} else {
60+
db.addUser("reader", "rapadura", true)
61+
}
5962
}
6063
}
6164

0 commit comments

Comments
 (0)