Skip to content

Improve Netty test variants #1721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions .evergreen/.evg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ functions:
export AWS_TEMP_SESSION_TOKEN=$CSFLE_AWS_TEMP_SESSION_TOKEN
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}

ASYNC_TRANSPORT="${ASYNC_TRANSPORT}" NETTY_SSL_PROVIDER="${NETTY_SSL_PROVIDER}" \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add support for the Netty variants in the main "run tests" function and remove the "run netty tests" function below.

AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" \
COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
TESTS="${TESTS}" .evergreen/run-tests.sh
Expand Down Expand Up @@ -371,18 +372,6 @@ functions:
${PREPARE_SHELL}
AUTH="${AUTH}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-socket-tests.sh

"run netty tests":
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
STREAM_TYPE="netty" AUTH="${AUTH}" SSL="${SSL}" NETTY_SSL_PROVIDER="${NETTY_SSL_PROVIDER}" MONGODB_URI="${MONGODB_URI}" \
TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" \
AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} AZUREKMS_KEY_NAME=${testazurekms_keyname} \
.evergreen/run-tests.sh

"run plain auth test":
- command: shell.exec
type: test
Expand Down Expand Up @@ -1545,11 +1534,6 @@ tasks:
- func: "bootstrap mongo-orchestration"
- func: "run socket tests"

- name: "netty-test"
commands:
- func: "bootstrap mongo-orchestration"
- func: "run netty tests"

- name: publish-snapshot
depends_on:
- variant: "static-checks"
Expand Down Expand Up @@ -1835,6 +1819,13 @@ axes:
display_name: NoSSL
variables:
SSL: "nossl"
- id: async_transport
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only way I could figure out how to set a variable. It's not possible afaik to set it directly on the matrix definition.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good enough

display_name: Async Transport
values:
- id: "netty"
display_name: Netty
variables:
ASYNC_TRANSPORT: "netty"
- id: netty-ssl-provider
display_name: Netty TLS/SSL protocol provider
values:
Expand Down Expand Up @@ -2274,18 +2265,22 @@ buildvariants:
- name: "socket-test"

- matrix_name: "tests-netty"
matrix_spec: { auth: "noauth", ssl: "*", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux" }
matrix_spec: { auth: "noauth", ssl: "*", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux",
async_transport: "netty" }
display_name: "Netty: ${version} ${topology} ${ssl} ${auth} ${jdk} ${os} "
tags: ["tests-netty-variant"]
tasks:
- name: "netty-test"
- name: "test-reactive"
- name: "test-core"

- matrix_name: "tests-netty-ssl-provider"
matrix_spec: { netty-ssl-provider: "*", auth: "auth", ssl: "ssl", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux" }
matrix_spec: { auth: "auth", ssl: "ssl", jdk: "jdk8", version: ["7.0"], topology: "replicaset", os: "linux",
async_transport: "netty", netty-ssl-provider: "*" }
display_name: "Netty SSL provider: ${version} ${topology} ${ssl} SslProvider.${netty-ssl-provider} ${auth} ${jdk} ${os} "
tags: ["tests-netty-variant"]
tasks:
- name: "netty-test"
- name: "test-reactive"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spilt into the two tasks to make it run faster, as has already been done for the main test matrix. Core and reactive are the only two modules that pay attention to the transport settings.

- name: "test-core"

- matrix_name: "tests-socket-snappy-compression"
matrix_spec: { compressor : "snappy", auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.2"], topology: "standalone", os: "linux" }
Expand Down
15 changes: 8 additions & 7 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ set -o errexit # Exit the script with error if any of the commands fail
# Supported/used environment variables:
# AUTH Set to enable authentication. Values are: "auth" / "noauth" (default)
# SSL Set to enable SSL. Values are "ssl" / "nossl" (default)
# 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).
# 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).
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
# TOPOLOGY Allows you to modify variables and the MONGODB_URI based on test topology
# Supported values: "server", "replica_set", "sharded_cluster"
# COMPRESSOR Set to enable compression. Values are "snappy" and "zlib" (default is no compression)
# STREAM_TYPE Set the stream type. Values are "nio2" or "netty". Defaults to "nio2".
# ASYNC_TRANSPORT Set the async transport. Values are "nio2" or "netty".
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name to match the new TransportSettings class introduced in 5.0

# JDK Set the version of java to be used. Java versions can be set from the java toolchain /opt/java
# SLOW_TESTS_ONLY Set to true to only run the slow tests
# AWS_ACCESS_KEY_ID The AWS access key identifier for client-side encryption
Expand All @@ -34,13 +34,14 @@ SSL=${SSL:-nossl}
MONGODB_URI=${MONGODB_URI:-}
TOPOLOGY=${TOPOLOGY:-server}
COMPRESSOR=${COMPRESSOR:-}
STREAM_TYPE=${STREAM_TYPE:-nio2}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to default it since it's already defaulted in ClusterFixture

TESTS=${TESTS:-test}
SLOW_TESTS_ONLY=${SLOW_TESTS_ONLY:-false}

export ASYNC_TYPE="-Dorg.mongodb.test.async.type=${STREAM_TYPE}"
if [ "${ASYNC_TRANSPORT}" != "" ]; then
readonly JAVA_SYSPROP_ASYNC_TRANSPORT="-Dorg.mongodb.test.async.transport=${ASYNC_TRANSPORT}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match the style just below for JAVA_SYSPROP_NETTY_SSL_PROVIDER

fi

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

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

./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} \
${JAVA_SYSPROP_ASYNC_TRANSPORT} ${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
-Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled=true \
--stacktrace --info --continue ${TESTS}
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ public static StreamFactory getAsyncStreamFactory() {

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

if (nettyTransportSettings == null && streamType.equals("netty")) {
if (nettyTransportSettings == null && asyncTransport.equals("netty")) {
NettyTransportSettings.Builder builder = TransportSettings.nettyBuilder();
String sslProvider = System.getProperty("org.mongodb.test.netty.ssl.provider");
if (sslProvider != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@

package com.mongodb.reactivestreams.client.unified;

import com.mongodb.ClusterFixture;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.connection.TransportSettings;
import com.mongodb.lang.Nullable;
import com.mongodb.reactivestreams.client.MongoClients;
import com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient;
import org.bson.BsonArray;
import org.bson.BsonDocument;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -138,13 +132,6 @@ public void shouldPassAllOutcomes(
}
assertNoDroppedError(format("%s passed but there was a dropped error; `onError` called with no handler.", testDescription));
}
@Override
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push this down to the base class for all reactive tests.

protected MongoClient createMongoClient(final MongoClientSettings settings) {
TransportSettings overriddenTransportSettings = ClusterFixture.getOverriddenTransportSettings();
MongoClientSettings clientSettings = overriddenTransportSettings == null ? settings
: MongoClientSettings.builder(settings).transportSettings(overriddenTransportSettings).build();
return new SyncMongoClient(MongoClients.create(clientSettings));
}

@AfterEach
public void cleanUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.mongodb.client.unified.UnifiedTest;
import com.mongodb.client.unified.UnifiedTestModifications;
import com.mongodb.client.vault.ClientEncryption;
import com.mongodb.connection.TransportSettings;
import com.mongodb.lang.NonNull;
import com.mongodb.reactivestreams.client.MongoClients;
import com.mongodb.reactivestreams.client.gridfs.GridFSBuckets;
Expand All @@ -36,6 +37,7 @@

import java.util.Collection;

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

@Override
protected MongoClient createMongoClient(final MongoClientSettings settings) {
return new SyncMongoClient(MongoClients.create(settings));
TransportSettings overriddenTransportSettings = getOverriddenTransportSettings();
MongoClientSettings clientSettings = overriddenTransportSettings == null ? settings
: MongoClientSettings.builder(settings).transportSettings(overriddenTransportSettings).build();
return new SyncMongoClient(MongoClients.create(clientSettings));
}

@Override
Expand Down