Skip to content

Commit 90976e4

Browse files
authored
Move most skips to single file, expand API to handle conditions (#1557)
1 parent 5c8f6b2 commit 90976e4

33 files changed

+596
-629
lines changed

Diff for: driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/UnifiedCrudTest.kt

-6
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@
1515
*/
1616
package com.mongodb.kotlin.client.coroutine
1717

18-
import com.mongodb.client.unified.UnifiedCrudTest.doSkips
1918
import java.io.IOException
2019
import java.net.URISyntaxException
2120
import org.junit.jupiter.params.provider.Arguments
2221

2322
internal class UnifiedCrudTest() : UnifiedTest() {
24-
25-
override fun skips(fileDescription: String, testDescription: String) {
26-
doSkips(fileDescription, testDescription)
27-
}
28-
2923
companion object {
3024
@JvmStatic
3125
@Throws(URISyntaxException::class, IOException::class)

Diff for: driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/UnifiedCrudTest.kt

-6
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@
1515
*/
1616
package com.mongodb.kotlin.client
1717

18-
import com.mongodb.client.unified.UnifiedCrudTest.doSkips
1918
import java.io.IOException
2019
import java.net.URISyntaxException
2120
import org.junit.jupiter.params.provider.Arguments
2221

2322
internal class UnifiedCrudTest() : UnifiedTest() {
24-
25-
override fun skips(fileDescription: String, testDescription: String) {
26-
doSkips(fileDescription, testDescription)
27-
}
28-
2923
companion object {
3024
@JvmStatic
3125
@Throws(URISyntaxException::class, IOException::class)

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/ChangeStreamsTest.java

-76
Original file line numberDiff line numberDiff line change
@@ -16,89 +16,13 @@
1616

1717
package com.mongodb.reactivestreams.client.unified;
1818

19-
import com.mongodb.lang.Nullable;
20-
import org.bson.BsonArray;
21-
import org.bson.BsonDocument;
22-
import org.junit.jupiter.api.AfterEach;
23-
import org.junit.jupiter.api.BeforeEach;
2419
import org.junit.jupiter.params.provider.Arguments;
2520

2621
import java.io.IOException;
2722
import java.net.URISyntaxException;
28-
import java.util.Arrays;
2923
import java.util.Collection;
30-
import java.util.List;
31-
32-
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableSleep;
33-
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableWaitForBatchCursorCreation;
34-
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableSleepAfterCursorOpen;
35-
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableWaitForBatchCursorCreation;
36-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
3724

3825
final class ChangeStreamsTest extends UnifiedReactiveStreamsTest {
39-
40-
private static final List<String> ERROR_REQUIRED_FROM_CHANGE_STREAM_INITIALIZATION_TESTS =
41-
Arrays.asList(
42-
"Test with document comment - pre 4.4"
43-
);
44-
45-
private static final List<String> EVENT_SENSITIVE_TESTS =
46-
Arrays.asList(
47-
"Test that comment is set on getMore",
48-
"Test that comment is not set on getMore - pre 4.4"
49-
);
50-
51-
private static final List<String> TESTS_WITH_EXTRA_EVENTS =
52-
Arrays.asList(
53-
"Test with document comment",
54-
"Test with string comment"
55-
);
56-
57-
private static final List<String> REQUIRES_BATCH_CURSOR_CREATION_WAITING =
58-
Arrays.asList(
59-
"Change Stream should error when an invalid aggregation stage is passed in",
60-
"The watch helper must not throw a custom exception when executed against a single server topology, "
61-
+ "but instead depend on a server error"
62-
);
63-
64-
@Override
65-
protected void skips(final String fileDescription, final String testDescription) {
66-
assumeFalse(ERROR_REQUIRED_FROM_CHANGE_STREAM_INITIALIZATION_TESTS.contains(testDescription));
67-
assumeFalse(EVENT_SENSITIVE_TESTS.contains(testDescription));
68-
assumeFalse(TESTS_WITH_EXTRA_EVENTS.contains(testDescription));
69-
}
70-
71-
@BeforeEach
72-
@Override
73-
public void setUp(@Nullable final String fileDescription,
74-
@Nullable final String testDescription,
75-
final String schemaVersion,
76-
@Nullable final BsonArray runOnRequirements,
77-
final BsonArray entitiesArray,
78-
final BsonArray initialData,
79-
final BsonDocument definition) {
80-
super.setUp(
81-
fileDescription,
82-
testDescription,
83-
schemaVersion,
84-
runOnRequirements,
85-
entitiesArray,
86-
initialData,
87-
definition);
88-
enableSleepAfterCursorOpen(256);
89-
if (REQUIRES_BATCH_CURSOR_CREATION_WAITING.contains(testDescription)) {
90-
enableWaitForBatchCursorCreation();
91-
}
92-
}
93-
94-
@AfterEach
95-
@Override
96-
public void cleanUp() {
97-
super.cleanUp();
98-
disableSleep();
99-
disableWaitForBatchCursorCreation();
100-
}
101-
10226
private static Collection<Arguments> data() throws URISyntaxException, IOException {
10327
return getTestData("unified-test-format/change-streams");
10428
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/ClientSideOperationTimeoutTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ The Reactive Streams specification prevents us from allowing a subsequent next c
101101
public void shouldPassAllOutcomes(
102102
@Nullable final String fileDescription,
103103
@Nullable final String testDescription,
104+
@Nullable final String directoryName,
104105
final String schemaVersion,
105106
@Nullable final BsonArray runOnRequirements,
106107
final BsonArray entitiesArray,
@@ -109,6 +110,7 @@ public void shouldPassAllOutcomes(
109110
try {
110111
super.shouldPassAllOutcomes(fileDescription,
111112
testDescription,
113+
directoryName,
112114
schemaVersion,
113115
runOnRequirements,
114116
entitiesArray,

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/CollectionManagementTest.java

-7
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@
2222
import java.net.URISyntaxException;
2323
import java.util.Collection;
2424

25-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
26-
2725
final class CollectionManagementTest extends UnifiedReactiveStreamsTest {
28-
@Override
29-
protected void skips(final String fileDescription, final String testDescription) {
30-
assumeFalse(testDescription.equals("modifyCollection to changeStreamPreAndPostImages enabled"));
31-
}
32-
3326
private static Collection<Arguments> data() throws URISyntaxException, IOException {
3427
return getTestData("unified-test-format/collection-management");
3528
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/CommandLoggingTest.java

-9
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222
import java.net.URISyntaxException;
2323
import java.util.Collection;
2424

25-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
26-
2725
final class CommandLoggingTest extends UnifiedReactiveStreamsTest {
28-
@Override
29-
protected void skips(final String fileDescription, final String testDescription) {
30-
// The driver has a hack where getLastError command is executed as part of the handshake in order to get a connectionId
31-
// even when the hello command response doesn't contain it.
32-
assumeFalse(fileDescription.equals("pre-42-server-connection-id"));
33-
}
34-
3526
private static Collection<Arguments> data() throws URISyntaxException, IOException {
3627
return getTestData("unified-test-format/command-logging");
3728
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/CommandMonitoringTest.java

-9
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222
import java.net.URISyntaxException;
2323
import java.util.Collection;
2424

25-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
26-
2725
final class CommandMonitoringTest extends UnifiedReactiveStreamsTest {
28-
@Override
29-
protected void skips(final String fileDescription, final String testDescription) {
30-
// The driver has a hack where getLastError command is executed as part of the handshake in order to get a connectionId
31-
// even when the hello command response doesn't contain it.
32-
assumeFalse(fileDescription.equals("pre-42-server-connection-id"));
33-
}
34-
3526
private static Collection<Arguments> data() throws URISyntaxException, IOException {
3627
return getTestData("unified-test-format/command-monitoring");
3728
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/ConnectionPoolLoggingTest.java

-9
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222
import java.net.URISyntaxException;
2323
import java.util.Collection;
2424

25-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
26-
2725
final class ConnectionPoolLoggingTest extends UnifiedReactiveStreamsTest {
28-
@Override
29-
protected void skips(final String fileDescription, final String testDescription) {
30-
// The implementation of the functionality related to clearing the connection pool before closing the connection
31-
// will be carried out once the specification is finalized and ready.
32-
assumeFalse(testDescription.equals("Connection checkout fails due to error establishing connection"));
33-
}
34-
3526
private static Collection<Arguments> data() throws URISyntaxException, IOException {
3627
return getTestData("unified-test-format/connection-monitoring-and-pooling/logging");
3728
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/LoadBalancerTest.java

-75
Original file line numberDiff line numberDiff line change
@@ -16,88 +16,13 @@
1616

1717
package com.mongodb.reactivestreams.client.unified;
1818

19-
import com.mongodb.lang.Nullable;
20-
import org.bson.BsonArray;
21-
import org.bson.BsonDocument;
22-
import org.junit.jupiter.api.AfterEach;
23-
import org.junit.jupiter.api.BeforeEach;
2419
import org.junit.jupiter.params.provider.Arguments;
2520

2621
import java.io.IOException;
2722
import java.net.URISyntaxException;
28-
import java.util.Arrays;
2923
import java.util.Collection;
30-
import java.util.List;
31-
32-
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableSleep;
33-
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableSleepAfterCursorClose;
34-
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableSleepAfterCursorOpen;
35-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
3624

3725
final class LoadBalancerTest extends UnifiedReactiveStreamsTest {
38-
39-
private static final List<String> CURSOR_OPEN_TIMING_SENSITIVE_TESTS =
40-
Arrays.asList(
41-
"pinned connections are returned when the cursor is drained",
42-
"only connections for a specific serviceId are closed when pools are cleared",
43-
"pinned connections are returned to the pool when the cursor is closed",
44-
"no connection is pinned if all documents are returned in the initial batch",
45-
"stale errors are ignored",
46-
"a connection can be shared by a transaction and a cursor",
47-
"wait queue timeout errors include cursor statistics");
48-
49-
private static final List<String> CURSOR_CLOSE_TIMING_SENSITIVE_TESTS =
50-
Arrays.asList(
51-
"pinned connections are returned to the pool when the cursor is closed",
52-
"only connections for a specific serviceId are closed when pools are cleared",
53-
"pinned connections are returned after a network error during a killCursors request",
54-
"a connection can be shared by a transaction and a cursor");
55-
56-
@Override
57-
protected void skips(final String fileDescription, final String testDescription) {
58-
// Reactive streams driver can't implement these tests because the underlying cursor is closed on error, which
59-
// breaks assumption in the tests that closing the cursor is something that happens under user control
60-
assumeFalse(testDescription.equals("pinned connections are not returned after an network error during getMore"));
61-
assumeFalse(testDescription.equals("pinned connections are not returned to the pool after a non-network error on getMore"));
62-
// Reactive streams driver can't implement this test because there is no way to tell that a change stream cursor
63-
// that has not yet received any results has even initiated the change stream
64-
assumeFalse(testDescription.equals("change streams pin to a connection"));
65-
}
66-
67-
@Override
68-
@BeforeEach
69-
public void setUp(
70-
@Nullable final String fileDescription,
71-
@Nullable final String testDescription,
72-
final String schemaVersion,
73-
@Nullable final BsonArray runOnRequirements,
74-
final BsonArray entitiesArray,
75-
final BsonArray initialData,
76-
final BsonDocument definition) {
77-
super.setUp(
78-
fileDescription,
79-
testDescription,
80-
schemaVersion,
81-
runOnRequirements,
82-
entitiesArray,
83-
initialData,
84-
definition);
85-
if (CURSOR_OPEN_TIMING_SENSITIVE_TESTS.contains(testDescription)) {
86-
enableSleepAfterCursorOpen(256);
87-
}
88-
89-
if (CURSOR_CLOSE_TIMING_SENSITIVE_TESTS.contains(testDescription)) {
90-
enableSleepAfterCursorClose(256);
91-
}
92-
}
93-
94-
@Override
95-
@AfterEach
96-
public void cleanUp() {
97-
super.cleanUp();
98-
disableSleep();
99-
}
100-
10126
private static Collection<Arguments> data() throws URISyntaxException, IOException {
10227
return getTestData("unified-test-format/load-balancers");
10328
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/UnifiedCrudTest.java

-7
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@
2222
import java.net.URISyntaxException;
2323
import java.util.Collection;
2424

25-
import static com.mongodb.client.unified.UnifiedCrudTest.doSkips;
26-
2725
final class UnifiedCrudTest extends UnifiedReactiveStreamsTest {
28-
@Override
29-
protected void skips(final String fileDescription, final String testDescription) {
30-
doSkips(fileDescription, testDescription);
31-
}
32-
3326
private static Collection<Arguments> data() throws URISyntaxException, IOException {
3427
return getTestData("unified-test-format/crud");
3528
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/UnifiedGridFSTest.java

-10
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@
2222
import java.net.URISyntaxException;
2323
import java.util.Collection;
2424

25-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
26-
2725
final class UnifiedGridFSTest extends UnifiedReactiveStreamsTest {
28-
@Override
29-
protected void skips(final String fileDescription, final String testDescription) {
30-
// contentType is deprecated in GridFS spec, and 4.x Java driver no longer support it, so skipping this test
31-
assumeFalse(testDescription.equals("upload when contentType is provided"));
32-
// Re-enable when JAVA-4214 is fixed
33-
assumeFalse(testDescription.equals("delete when files entry does not exist and there are orphaned chunks"));
34-
}
35-
3626
private static Collection<Arguments> data() throws URISyntaxException, IOException {
3727
return getTestData("unified-test-format/gridfs");
3828
}

Diff for: driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/UnifiedReactiveStreamsTest.java

+45
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.mongodb.client.MongoDatabase;
2323
import com.mongodb.client.gridfs.GridFSBucket;
2424
import com.mongodb.client.unified.UnifiedTest;
25+
import com.mongodb.client.unified.UnifiedTestModifications;
2526
import com.mongodb.client.vault.ClientEncryption;
2627
import com.mongodb.reactivestreams.client.MongoClients;
2728
import com.mongodb.reactivestreams.client.gridfs.GridFSBuckets;
@@ -31,6 +32,14 @@
3132
import com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient;
3233
import com.mongodb.reactivestreams.client.syncadapter.SyncMongoDatabase;
3334

35+
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier;
36+
import static com.mongodb.client.unified.UnifiedTestModifications.TestDef;
37+
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableSleep;
38+
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableWaitForBatchCursorCreation;
39+
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableSleepAfterCursorClose;
40+
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableSleepAfterCursorOpen;
41+
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableWaitForBatchCursorCreation;
42+
3443
public abstract class UnifiedReactiveStreamsTest extends UnifiedTest {
3544
protected UnifiedReactiveStreamsTest() {
3645
}
@@ -49,4 +58,40 @@ protected GridFSBucket createGridFSBucket(final MongoDatabase database) {
4958
protected ClientEncryption createClientEncryption(final MongoClient keyVaultClient, final ClientEncryptionSettings clientEncryptionSettings) {
5059
return new SyncClientEncryption(new ClientEncryptionImpl(((SyncMongoClient) keyVaultClient).getWrapped(), clientEncryptionSettings));
5160
}
61+
62+
@Override
63+
protected boolean isReactive() {
64+
return true;
65+
}
66+
67+
@Override
68+
protected void postSetUp(final TestDef testDef) {
69+
super.postSetUp(testDef);
70+
if (testDef.wasAssignedModifier(UnifiedTestModifications.Modifier.IGNORE_EXTRA_EVENTS)) {
71+
ignoreExtraEvents(); // no disable needed
72+
}
73+
if (testDef.wasAssignedModifier(Modifier.SLEEP_AFTER_CURSOR_OPEN)) {
74+
enableSleepAfterCursorOpen(256);
75+
}
76+
if (testDef.wasAssignedModifier(Modifier.SLEEP_AFTER_CURSOR_CLOSE)) {
77+
enableSleepAfterCursorClose(256);
78+
}
79+
if (testDef.wasAssignedModifier(Modifier.WAIT_FOR_BATCH_CURSOR_CREATION)) {
80+
enableWaitForBatchCursorCreation();
81+
}
82+
}
83+
84+
@Override
85+
protected void postCleanUp(final TestDef testDef) {
86+
super.postCleanUp(testDef);
87+
if (testDef.wasAssignedModifier(Modifier.WAIT_FOR_BATCH_CURSOR_CREATION)) {
88+
disableWaitForBatchCursorCreation();
89+
}
90+
if (testDef.wasAssignedModifier(Modifier.SLEEP_AFTER_CURSOR_CLOSE)) {
91+
disableSleep();
92+
}
93+
if (testDef.wasAssignedModifier(Modifier.SLEEP_AFTER_CURSOR_OPEN)) {
94+
disableSleep();
95+
}
96+
}
5297
}

0 commit comments

Comments
 (0)