Skip to content

Commit 24c2016

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 f9793d3 commit 24c2016

File tree

5 files changed

+32
-44
lines changed

5 files changed

+32
-44
lines changed

.evergreen/.evg.yml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ functions:
291291
export AWS_TEMP_SESSION_TOKEN=$CSFLE_AWS_TEMP_SESSION_TOKEN
292292
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
293293
294+
ASYNC_TRANSPORT="${ASYNC_TRANSPORT}" NETTY_SSL_PROVIDER="${NETTY_SSL_PROVIDER}" \
294295
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" \
295296
COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
296297
TESTS="${TESTS}" .evergreen/run-tests.sh
@@ -371,18 +372,6 @@ functions:
371372
${PREPARE_SHELL}
372373
AUTH="${AUTH}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-socket-tests.sh
373374
374-
"run netty tests":
375-
- command: shell.exec
376-
type: test
377-
params:
378-
working_dir: "src"
379-
script: |
380-
${PREPARE_SHELL}
381-
STREAM_TYPE="netty" AUTH="${AUTH}" SSL="${SSL}" NETTY_SSL_PROVIDER="${NETTY_SSL_PROVIDER}" MONGODB_URI="${MONGODB_URI}" \
382-
TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" \
383-
AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} AZUREKMS_KEY_NAME=${testazurekms_keyname} \
384-
.evergreen/run-tests.sh
385-
386375
"run plain auth test":
387376
- command: shell.exec
388377
type: test
@@ -1545,11 +1534,6 @@ tasks:
15451534
- func: "bootstrap mongo-orchestration"
15461535
- func: "run socket tests"
15471536

1548-
- name: "netty-test"
1549-
commands:
1550-
- func: "bootstrap mongo-orchestration"
1551-
- func: "run netty tests"
1552-
15531537
- name: publish-snapshot
15541538
depends_on:
15551539
- variant: "static-checks"
@@ -1835,6 +1819,13 @@ axes:
18351819
display_name: NoSSL
18361820
variables:
18371821
SSL: "nossl"
1822+
- id: async_transport
1823+
display_name: Async Transport
1824+
values:
1825+
- id: "netty"
1826+
display_name: Netty
1827+
variables:
1828+
ASYNC_TRANSPORT: "netty"
18381829
- id: netty-ssl-provider
18391830
display_name: Netty TLS/SSL protocol provider
18401831
values:
@@ -2274,18 +2265,22 @@ buildvariants:
22742265
- name: "socket-test"
22752266

22762267
- matrix_name: "tests-netty"
2277-
matrix_spec: { auth: "noauth", ssl: "*", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux" }
2268+
matrix_spec: { auth: "noauth", ssl: "*", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux",
2269+
async_transport: "netty" }
22782270
display_name: "Netty: ${version} ${topology} ${ssl} ${auth} ${jdk} ${os} "
22792271
tags: ["tests-netty-variant"]
22802272
tasks:
2281-
- name: "netty-test"
2273+
- name: "test-reactive"
2274+
- name: "test-core"
22822275

22832276
- matrix_name: "tests-netty-ssl-provider"
2284-
matrix_spec: { netty-ssl-provider: "*", auth: "auth", ssl: "ssl", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux" }
2277+
matrix_spec: { auth: "auth", ssl: "ssl", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux",
2278+
async_transport: "netty", netty-ssl-provider: "*" }
22852279
display_name: "Netty SSL provider: ${version} ${topology} ${ssl} SslProvider.${netty-ssl-provider} ${auth} ${jdk} ${os} "
22862280
tags: ["tests-netty-variant"]
22872281
tasks:
2288-
- name: "netty-test"
2282+
- name: "test-reactive"
2283+
- name: "test-core"
22892284

22902285
- matrix_name: "tests-socket-snappy-compression"
22912286
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)