From cab1dc74ffd4ec888386a67d6d631079f3ced2be Mon Sep 17 00:00:00 2001 From: John Arbash Meinel Date: Thu, 18 Apr 2019 15:09:33 +0400 Subject: [PATCH] If using Replicaset use wiredTiger. Else just use mmapv1 so we don't have to worry about the slowdown of the test suite. --- mgo.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mgo.go b/mgo.go index b5c6b16..49f59fc 100644 --- a/mgo.go +++ b/mgo.go @@ -271,7 +271,7 @@ func (inst *MgoInstance) run() error { mgoargs = append(mgoargs, "--nojournal") } if version.Compare(storageEngineMongoVersion) >= 0 { - storageEngine := mongoStorageEngine() + storageEngine := mongoStorageEngine(inst.EnableReplicaSet) if storageEngine != "" { mgoargs = append(mgoargs, "--storageEngine", storageEngine) } @@ -351,18 +351,23 @@ func (inst *MgoInstance) run() error { return nil } -func mongoStorageEngine() string { +func mongoStorageEngine(replicaset bool) string { storageEngine := os.Getenv("JUJU_MONGO_STORAGE_ENGINE") if storageEngine != "" { return storageEngine } switch runtime.GOARCH { case "amd64": + if replicaset { // Use 'wiredTiger' unless explicitly requested to use a // different backend. mmapv1 is generally available, but // doesn't support things like server-side transactions, and // also isn't our production backend. return "wiredTiger" + } else { + // We use mmapv1 in the test suite as it can be 3-4x faster in many tests. + return "mmapv1" + } } return "" // use the default }