Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: default to mmapv1 only on x86(_64) #133

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions mgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ const (

// The default password to use when connecting to the mongo database.
DefaultMongoPassword = "conn-from-name-secret"

// defaultMongoStorageEngine is the default storage engine to use
// in Mongo 3.2 onwards for tests. We default to mmapv1 (vs. the
// mongo default of wiredTiger) for the best performance in tests,
// but make it configurable.
defaultMongoStorageEngine = "mmapv1"
)

// Certs holds the certificates and keys required to make a secure
Expand Down Expand Up @@ -267,11 +261,10 @@ func (inst *MgoInstance) run() error {
mgoargs = append(mgoargs, "--nojournal")
}
if version.Compare(storageEngineMongoVersion) >= 0 {
storageEngine := os.Getenv("JUJU_MONGO_STORAGE_ENGINE")
if storageEngine == "" {
storageEngine = defaultMongoStorageEngine
storageEngine := mongoStorageEngine()
if storageEngine != "" {
mgoargs = append(mgoargs, "--storageEngine", storageEngine)
}
mgoargs = append(mgoargs, "--storageEngine", storageEngine)
}

if inst.Params != nil {
Expand Down Expand Up @@ -339,6 +332,21 @@ func (inst *MgoInstance) run() error {
return nil
}

func mongoStorageEngine() string {
storageEngine := os.Getenv("JUJU_MONGO_STORAGE_ENGINE")
if storageEngine != "" {
return storageEngine
}
switch runtime.GOARCH {
case "386", "amd64":
// On x86(_64), mmapv1 should always be available. If not
// overridden via the environment variable above, we use
// mmapv1 by default for the best performance in tests.
return "mmapv1"
}
return "" // use the default
}

// mongodCache looks up mongod path and version and caches the result.
type mongodCache struct {
sync.Mutex
Expand Down