Skip to content

Commit 54e437a

Browse files
committed
Added a Fixture method to check if journaling is enabled on the server
1 parent a4ea6e4 commit 54e437a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/com/mongodb/Fixture.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.mongodb;
1818

1919
import java.net.UnknownHostException;
20+
import java.util.List;
2021

2122
/**
2223
* Helper class for the acceptance tests.
@@ -76,6 +77,20 @@ public static boolean isReplicaSet() {
7677
return runIsMaster().get("setName") != null;
7778
}
7879

80+
public static boolean isServerStartedWithJournalingDisabled() {
81+
return serverStartedWithBooleanOption("--nojournal", "nojournal");
82+
}
83+
84+
private static boolean serverStartedWithBooleanOption(final String commandLineOption, final String configOption) {
85+
CommandResult res = getMongoClient().getDB("admin").command(new BasicDBObject("getCmdLineOpts", 1));
86+
res.throwOnError();
87+
if (res.containsField("parsed") && ((DBObject) res.get("parsed")).containsField(configOption)) {
88+
return (Boolean) ((DBObject) res.get("parsed")).get(configOption);
89+
} else {
90+
return ((List) res.get("argv")).contains(commandLineOption);
91+
}
92+
}
93+
7994
private static CommandResult runIsMaster() {
8095
// Check to see if this is a replica set... if not, get out of here.
8196
return getMongoClient().getDB("admin").command(new BasicDBObject("ismaster", 1));

0 commit comments

Comments
 (0)