Skip to content

Commit 8a55003

Browse files
committed
Ignore tests that rely on the fsync command if the storage engine does not support it. Currently that includes the inMemory storage engine.
1 parent 54b996d commit 8a55003

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

driver-core/src/test/functional/com/mongodb/ClusterFixture.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ public static Document getBuildInfo() {
114114
.execute(getBinding());
115115
}
116116

117+
public static Document getServerStatus() {
118+
return new CommandWriteOperation<Document>("admin", new BsonDocument("serverStatus", new BsonInt32(1)), new DocumentCodec())
119+
.execute(getBinding());
120+
}
121+
117122
@SuppressWarnings("unchecked")
118123
public static boolean isEnterpriseServer() {
119124
Document buildInfo = getBuildInfo();
@@ -125,6 +130,13 @@ public static boolean isEnterpriseServer() {
125130
return modules.contains("enterprise");
126131
}
127132

133+
public static boolean supportsFsync() {
134+
Document serverStatus = getServerStatus();
135+
Document storageEngine = (Document) serverStatus.get("storageEngine");
136+
137+
return !storageEngine.get("name").equals("inMemory");
138+
}
139+
128140
private static ServerVersion getConnectedServerVersion() {
129141
ClusterDescription clusterDescription = getCluster().getDescription();
130142
int retries = 0;

driver-core/src/test/functional/com/mongodb/operation/FsyncUnlockOperationSpecification.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import spock.lang.Specification
2525

2626
import static com.mongodb.ClusterFixture.getBinding
2727
import static com.mongodb.ClusterFixture.isSharded
28-
28+
import static com.mongodb.ClusterFixture.supportsFsync
2929

3030
class FsyncUnlockOperationSpecification extends Specification {
31-
@IgnoreIf({ isSharded() })
31+
@IgnoreIf({ isSharded() || !supportsFsync() })
3232
def 'should unlock server'() {
3333
given:
3434
new CommandWriteOperation('admin', new BsonDocument('fsync', new BsonInt32(1)).append('lock', new BsonInt32(1)),

driver/src/test/functional/com/mongodb/MongoMethodsTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
import java.net.UnknownHostException;
2222

2323
import static com.mongodb.ClusterFixture.clusterIsType;
24+
import static com.mongodb.ClusterFixture.supportsFsync;
2425
import static com.mongodb.connection.ClusterType.SHARDED;
2526
import static org.hamcrest.CoreMatchers.hasItems;
2627
import static org.junit.Assert.assertFalse;
2728
import static org.junit.Assert.assertThat;
2829
import static org.junit.Assert.assertTrue;
2930
import static org.junit.Assume.assumeFalse;
31+
import static org.junit.Assume.assumeTrue;
3032

3133
public class MongoMethodsTest extends DatabaseTestCase {
3234
@Test
@@ -46,6 +48,7 @@ public void shouldGetDatabaseNames() throws UnknownHostException {
4648
@Test
4749
public void shouldLockAndUnlock() {
4850
assumeFalse(clusterIsType(SHARDED));
51+
assumeTrue(supportsFsync());
4952

5053
assertFalse(getClient().isLocked());
5154

0 commit comments

Comments
 (0)