@@ -64,12 +64,6 @@ const (
64
64
65
65
// The default password to use when connecting to the mongo database.
66
66
DefaultMongoPassword = "conn-from-name-secret"
67
-
68
- // defaultMongoStorageEngine is the default storage engine to use
69
- // in Mongo 3.2 onwards for tests. We default to mmapv1 (vs. the
70
- // mongo default of wiredTiger) for the best performance in tests,
71
- // but make it configurable.
72
- defaultMongoStorageEngine = "mmapv1"
73
67
)
74
68
75
69
// Certs holds the certificates and keys required to make a secure
@@ -267,11 +261,10 @@ func (inst *MgoInstance) run() error {
267
261
mgoargs = append (mgoargs , "--nojournal" )
268
262
}
269
263
if version .Compare (storageEngineMongoVersion ) >= 0 {
270
- storageEngine := os . Getenv ( "JUJU_MONGO_STORAGE_ENGINE" )
271
- if storageEngine = = "" {
272
- storageEngine = defaultMongoStorageEngine
264
+ storageEngine := mongoStorageEngine ( )
265
+ if storageEngine ! = "" {
266
+ mgoargs = append ( mgoargs , "--storageEngine" , storageEngine )
273
267
}
274
- mgoargs = append (mgoargs , "--storageEngine" , storageEngine )
275
268
}
276
269
277
270
if inst .Params != nil {
@@ -339,6 +332,21 @@ func (inst *MgoInstance) run() error {
339
332
return nil
340
333
}
341
334
335
+ func mongoStorageEngine () string {
336
+ storageEngine := os .Getenv ("JUJU_MONGO_STORAGE_ENGINE" )
337
+ if storageEngine != "" {
338
+ return storageEngine
339
+ }
340
+ switch runtime .GOARCH {
341
+ case "386" , "amd64" :
342
+ // On x86(_64), mmapv1 should always be available. If not
343
+ // overridden via the environment variable above, we use
344
+ // mmapv1 by default for the best performance in tests.
345
+ return "mmapv1"
346
+ }
347
+ return "" // use the default
348
+ }
349
+
342
350
// mongodCache looks up mongod path and version and caches the result.
343
351
type mongodCache struct {
344
352
sync.Mutex
0 commit comments