Skip to content

Commit b85f288

Browse files
committed
Improve Netty test variants
* Only run driver-core and driver-reactive-streams test suites, each in its own task (as we do in other variants). * Use Netty configuration in all unified reactive tests, increasing coverage of Netty in driver-reactive-streams JAVA-5887
1 parent b644e7e commit b85f288

File tree

5 files changed

+33
-44
lines changed

5 files changed

+33
-44
lines changed

.evergreen/.evg.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ functions:
458458
459459
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
460460
461+
ASYNC_TRANSPORT="${ASYNC_TRANSPORT}" NETTY_SSL_PROVIDER="${NETTY_SSL_PROVIDER}" \
461462
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" \
462463
COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
463464
TESTS="${TESTS}" .evergreen/run-tests.sh
@@ -533,18 +534,6 @@ functions:
533534
${PREPARE_SHELL}
534535
AUTH="${AUTH}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-socket-tests.sh
535536
536-
"run-netty-tests":
537-
- command: shell.exec
538-
type: "test"
539-
params:
540-
working_dir: "src"
541-
script: |
542-
${PREPARE_SHELL}
543-
STREAM_TYPE="netty" AUTH="${AUTH}" SSL="${SSL}" NETTY_SSL_PROVIDER="${NETTY_SSL_PROVIDER}" MONGODB_URI="${MONGODB_URI}" \
544-
TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" \
545-
AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} AZUREKMS_KEY_NAME=${testazurekms_keyname} \
546-
.evergreen/run-tests.sh
547-
548537
"run-plain-auth-test":
549538
- command: shell.exec
550539
type: "test"
@@ -1552,11 +1541,6 @@ tasks:
15521541
- func: "start-mongo-orchestration"
15531542
- func: "run-socket-tests"
15541543

1555-
- name: "netty-test-task"
1556-
commands:
1557-
- func: "start-mongo-orchestration"
1558-
- func: "run-netty-tests"
1559-
15601544
- name: "publish-snapshot-task"
15611545
depends_on:
15621546
- variant: "static-checks"
@@ -1850,6 +1834,14 @@ axes:
18501834
variables:
18511835
SSL: "nossl"
18521836

1837+
- id: async_transport
1838+
display_name: Async Transport
1839+
values:
1840+
- id: "netty"
1841+
display_name: Netty
1842+
variables:
1843+
ASYNC_TRANSPORT: "netty"
1844+
18531845
- id: "netty-ssl-provider"
18541846
display_name: "Netty TLS/SSL protocol provider"
18551847
values:
@@ -2467,18 +2459,22 @@ buildvariants:
24672459
- name: "socket-test-task"
24682460

24692461
- matrix_name: "tests-netty"
2470-
matrix_spec: { auth: "noauth", ssl: "*", jdk: "jdk8", version: [ "7.0" ], topology: "replicaset", os: "linux" }
2462+
matrix_spec: { auth: "noauth", ssl: "*", jdk: "jdk8", version: [ "7.0" ], topology: "replicaset", os: "linux",
2463+
async_transport: "netty" }
24712464
display_name: "Netty: ${version} ${topology} ${ssl} ${auth} ${jdk} ${os} "
24722465
tags: [ "tests-netty-variant" ]
24732466
tasks:
2474-
- name: "netty-test-task"
2467+
- name: "test-reactive"
2468+
- name: "test-core"
24752469

24762470
- matrix_name: "tests-netty-ssl-provider"
2477-
matrix_spec: { netty-ssl-provider: "*", auth: "auth", ssl: "ssl", jdk: "jdk8", version: [ "7.0" ], topology: "replicaset", os: "linux" }
2471+
matrix_spec: { auth: "auth", ssl: "ssl", jdk: "jdk8", version: [ "7.0" ], topology: "replicaset", os: "linux",
2472+
async_transport: "netty", netty-ssl-provider: "*" }
24782473
display_name: "Netty SSL provider: ${version} ${topology} ${ssl} SslProvider.${netty-ssl-provider} ${auth} ${jdk} ${os} "
24792474
tags: [ "tests-netty-variant" ]
24802475
tasks:
2481-
- name: "netty-test-task"
2476+
- name: "test-reactive"
2477+
- name: "test-core"
24822478

24832479
- matrix_name: "tests-socket-snappy-compression"
24842480
matrix_spec: { compressor: "snappy", auth: "noauth", ssl: "nossl", jdk: "jdk8", version: [ "4.2" ], topology: "standalone", os: "linux" }

.evergreen/run-tests.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ set -o errexit # Exit the script with error if any of the commands fail
66
# Supported/used environment variables:
77
# AUTH Set to enable authentication. Values are: "auth" / "noauth" (default)
88
# SSL Set to enable SSL. Values are "ssl" / "nossl" (default)
9-
# NETTY_SSL_PROVIDER The Netty TLS/SSL protocol provider. Ignored unless SSL is "ssl" and STREAM_TYPE is "netty". Values are "JDK", "OPENSSL", null (a.k.a. "" or '') (default).
9+
# NETTY_SSL_PROVIDER The Netty TLS/SSL protocol provider. Ignored unless SSL is "ssl" and ASYNC_TRANSPORT is "netty". Values are "JDK", "OPENSSL", null (a.k.a. "" or '') (default).
1010
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
1111
# TOPOLOGY Allows you to modify variables and the MONGODB_URI based on test topology
1212
# Supported values: "server", "replica_set", "sharded_cluster"
1313
# COMPRESSOR Set to enable compression. Values are "snappy" and "zlib" (default is no compression)
14-
# STREAM_TYPE Set the stream type. Values are "nio2" or "netty". Defaults to "nio2".
14+
# ASYNC_TRANSPORT Set the async transport. Values are "nio2" or "netty".
1515
# JDK Set the version of java to be used. Java versions can be set from the java toolchain /opt/java
1616
# SLOW_TESTS_ONLY Set to true to only run the slow tests
1717
# AWS_ACCESS_KEY_ID The AWS access key identifier for client-side encryption
@@ -34,13 +34,14 @@ SSL=${SSL:-nossl}
3434
MONGODB_URI=${MONGODB_URI:-}
3535
TOPOLOGY=${TOPOLOGY:-server}
3636
COMPRESSOR=${COMPRESSOR:-}
37-
STREAM_TYPE=${STREAM_TYPE:-nio2}
3837
TESTS=${TESTS:-test}
3938
SLOW_TESTS_ONLY=${SLOW_TESTS_ONLY:-false}
4039

41-
export ASYNC_TYPE="-Dorg.mongodb.test.async.type=${STREAM_TYPE}"
40+
if [ "${ASYNC_TRANSPORT}" != "" ]; then
41+
readonly JAVA_SYSPROP_ASYNC_TRANSPORT="-Dorg.mongodb.test.async.transport=${ASYNC_TRANSPORT}"
42+
fi
4243

43-
if [ "${SSL}" = "ssl" ] && [ "${STREAM_TYPE}" = "netty" ] && [ "${NETTY_SSL_PROVIDER}" != "" ]; then
44+
if [ "${SSL}" = "ssl" ] && [ "${ASYNC_TRANSPORT}" = "netty" ] && [ "${NETTY_SSL_PROVIDER}" != "" ]; then
4445
readonly JAVA_SYSPROP_NETTY_SSL_PROVIDER="-Dorg.mongodb.test.netty.ssl.provider=${NETTY_SSL_PROVIDER}"
4546
fi
4647

@@ -128,7 +129,7 @@ echo "Running tests with Java ${JAVA_VERSION}"
128129
./gradlew -version
129130

130131
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
131-
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
132-
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
132+
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} \
133+
${JAVA_SYSPROP_ASYNC_TRANSPORT} ${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
133134
-Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled=true \
134135
--stacktrace --info --continue ${TESTS}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ public static StreamFactory getAsyncStreamFactory() {
520520

521521
@Nullable
522522
public static TransportSettings getOverriddenTransportSettings() {
523-
String streamType = System.getProperty("org.mongodb.test.async.type", "nio2");
523+
String asyncTransport = System.getProperty("org.mongodb.test.async.transport", "nio2");
524524

525-
if (nettyTransportSettings == null && streamType.equals("netty")) {
525+
if (nettyTransportSettings == null && asyncTransport.equals("netty")) {
526526
NettyTransportSettings.Builder builder = TransportSettings.nettyBuilder();
527527
String sslProvider = System.getProperty("org.mongodb.test.netty.ssl.provider");
528528
if (sslProvider != null) {

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616

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

19-
import com.mongodb.ClusterFixture;
20-
import com.mongodb.MongoClientSettings;
21-
import com.mongodb.client.MongoClient;
22-
import com.mongodb.connection.TransportSettings;
2319
import com.mongodb.lang.Nullable;
24-
import com.mongodb.reactivestreams.client.MongoClients;
25-
import com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient;
2620
import org.bson.BsonArray;
2721
import org.bson.BsonDocument;
2822
import org.junit.jupiter.api.AfterEach;
@@ -138,13 +132,6 @@ public void shouldPassAllOutcomes(
138132
}
139133
assertNoDroppedError(format("%s passed but there was a dropped error; `onError` called with no handler.", testDescription));
140134
}
141-
@Override
142-
protected MongoClient createMongoClient(final MongoClientSettings settings) {
143-
TransportSettings overriddenTransportSettings = ClusterFixture.getOverriddenTransportSettings();
144-
MongoClientSettings clientSettings = overriddenTransportSettings == null ? settings
145-
: MongoClientSettings.builder(settings).transportSettings(overriddenTransportSettings).build();
146-
return new SyncMongoClient(MongoClients.create(clientSettings));
147-
}
148135

149136
@AfterEach
150137
public void cleanUp() {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.mongodb.client.unified.UnifiedTest;
2525
import com.mongodb.client.unified.UnifiedTestModifications;
2626
import com.mongodb.client.vault.ClientEncryption;
27+
import com.mongodb.connection.TransportSettings;
2728
import com.mongodb.lang.NonNull;
2829
import com.mongodb.reactivestreams.client.MongoClients;
2930
import com.mongodb.reactivestreams.client.gridfs.GridFSBuckets;
@@ -36,6 +37,7 @@
3637

3738
import java.util.Collection;
3839

40+
import static com.mongodb.ClusterFixture.getOverriddenTransportSettings;
3941
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier;
4042
import static com.mongodb.client.unified.UnifiedTestModifications.TestDef;
4143
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableSleep;
@@ -50,7 +52,10 @@ protected UnifiedReactiveStreamsTest() {
5052

5153
@Override
5254
protected MongoClient createMongoClient(final MongoClientSettings settings) {
53-
return new SyncMongoClient(MongoClients.create(settings));
55+
TransportSettings overriddenTransportSettings = getOverriddenTransportSettings();
56+
MongoClientSettings clientSettings = overriddenTransportSettings == null ? settings
57+
: MongoClientSettings.builder(settings).transportSettings(overriddenTransportSettings).build();
58+
return new SyncMongoClient(MongoClients.create(clientSettings));
5459
}
5560

5661
@Override

0 commit comments

Comments
 (0)