Skip to content

Commit 51aa520

Browse files
authored
Merge branch 'mongodb:main' into main
2 parents bcc22ba + 2143320 commit 51aa520

File tree

137 files changed

+9423
-1737
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+9423
-1737
lines changed

.evergreen/.evg.yml

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ functions:
287287
288288
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" \
289289
COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
290-
.evergreen/run-tests.sh
290+
TESTS="${TESTS}" .evergreen/run-tests.sh
291291
292292
"run load-balancer tests":
293293
- command: shell.exec
@@ -335,7 +335,7 @@ functions:
335335
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" \
336336
JAVA_VERSION="${JAVA_VERSION}" \
337337
AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} AZUREKMS_KEY_NAME=${testazurekms_keyname} \
338-
SLOW_TESTS_ONLY=true .evergreen/run-tests.sh
338+
TESTS="testSlowOnly" .evergreen/run-tests.sh
339339
340340
"run scala tests":
341341
- command: shell.exec
@@ -861,11 +861,42 @@ tasks:
861861
vars:
862862
file: ".evergreen/static-checks.sh"
863863

864-
- name: "test"
864+
- name: "test-bson-and-crypt"
865+
commands:
866+
- func: "run tests"
867+
vars:
868+
TESTS: 'bson:test bson-record-codec:test mongodb-crypt:test'
869+
870+
- name: "test-core"
871+
commands:
872+
- func: "bootstrap mongo-orchestration"
873+
- func: "run tests"
874+
vars:
875+
TESTS: 'driver-core:test'
876+
877+
- name: "test-legacy"
878+
commands:
879+
- func: "start-kms-kmip-server"
880+
- func: "bootstrap mongo-orchestration"
881+
- func: "run tests"
882+
vars:
883+
TESTS: 'driver-legacy:test'
884+
885+
- name: "test-sync"
886+
commands:
887+
- func: "start-kms-kmip-server"
888+
- func: "bootstrap mongo-orchestration"
889+
- func: "run tests"
890+
vars:
891+
TESTS: 'driver-sync:test'
892+
893+
- name: "test-reactive"
865894
commands:
866895
- func: "start-kms-kmip-server"
867896
- func: "bootstrap mongo-orchestration"
868897
- func: "run tests"
898+
vars:
899+
TESTS: 'driver-reactive-streams:test'
869900

870901
- name: load-balancer-test
871902
commands:
@@ -1826,11 +1857,11 @@ axes:
18261857
- id: "2.12"
18271858
display_name: "Scala 2.12"
18281859
variables:
1829-
SCALA: "2.12.15"
1860+
SCALA: "2.12.20"
18301861
- id: "2.13"
18311862
display_name: "Scala 2.13"
18321863
variables:
1833-
SCALA: "2.13.6"
1864+
SCALA: "2.13.15"
18341865

18351866
# Choice of MongoDB storage engine
18361867
- id: storage-engine
@@ -2105,14 +2136,20 @@ buildvariants:
21052136
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21062137
tags: ["tests-variant"]
21072138
tasks:
2108-
- name: "test"
2139+
- name: "test-sync"
2140+
- name: "test-reactive"
2141+
- name: "test-core"
2142+
- name: "test-legacy"
21092143

21102144
- matrix_name: "tests-snappy-compression"
21112145
matrix_spec: { compressor : "snappy", auth: "noauth", ssl: "nossl", jdk: "jdk8", version: "*", topology: "standalone", os: "linux" }
21122146
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21132147
tags: ["tests-variant"]
21142148
tasks:
2115-
- name: "test"
2149+
- name: "test-sync"
2150+
- name: "test-reactive"
2151+
- name: "test-core"
2152+
- name: "test-legacy"
21162153

21172154
- matrix_name: "tests-zstd-compression"
21182155
matrix_spec: { compressor : "zstd", auth: "noauth", ssl: "nossl", jdk: "jdk8",
@@ -2121,15 +2158,28 @@ buildvariants:
21212158
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21222159
tags: ["tests-variant"]
21232160
tasks:
2124-
- name: "test"
2161+
- name: "test-sync"
2162+
- name: "test-reactive"
2163+
- name: "test-core"
2164+
- name: "test-legacy"
2165+
2166+
- matrix_name: "tests-unit"
2167+
matrix_spec: { jdk: [ "jdk8", "jdk11", "jdk17", "jdk21"], os: "linux" }
2168+
display_name: "${jdk} ${os} Unit"
2169+
tags: ["tests-variant"]
2170+
tasks:
2171+
- name: "test-bson-and-crypt"
21252172

21262173
- matrix_name: "tests-jdk8-unsecure"
21272174
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
21282175
topology: "*", os: "linux" }
21292176
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21302177
tags: ["tests-variant"]
21312178
tasks:
2132-
- name: "test"
2179+
- name: "test-sync"
2180+
- name: "test-reactive"
2181+
- name: "test-core"
2182+
- name: "test-legacy"
21332183

21342184
- matrix_name: "tests-jdk-secure"
21352185
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17", "jdk21"],
@@ -2138,22 +2188,31 @@ buildvariants:
21382188
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21392189
tags: ["tests-variant"]
21402190
tasks:
2141-
- name: "test"
2191+
- name: "test-sync"
2192+
- name: "test-reactive"
2193+
- name: "test-core"
2194+
- name: "test-legacy"
21422195

21432196
- matrix_name: "tests-jdk-secure-jdk11"
21442197
matrix_spec: { auth: "auth", ssl: "ssl", jdk: ["jdk11"], version: ["7.0"], topology: ["replicaset"], os: "linux" }
21452198
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21462199
tags: ["tests-variant"]
21472200
tasks:
2148-
- name: "test"
2201+
- name: "test-sync"
2202+
- name: "test-reactive"
2203+
- name: "test-core"
2204+
- name: "test-legacy"
21492205

21502206
- matrix_name: "tests-require-api-version"
21512207
matrix_spec: { api-version: "required", auth: "auth", ssl: "nossl", jdk: ["jdk21"], version: ["5.0", "6.0", "7.0", "8.0", "latest"],
21522208
topology: "standalone", os: "linux" }
21532209
display_name: "${version} ${topology} ${api-version} "
21542210
tags: ["tests-variant"]
21552211
tasks:
2156-
- name: "test"
2212+
- name: "test-sync"
2213+
- name: "test-reactive"
2214+
- name: "test-core"
2215+
- name: "test-legacy"
21572216

21582217
- matrix_name: "tests-load-balancer-secure"
21592218
matrix_spec: { auth: "auth", ssl: "ssl", jdk: ["jdk21"], version: ["5.0", "6.0", "7.0", "8.0", "latest"], topology: "sharded-cluster",

.evergreen/run-atlas-search-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ echo "Running Atlas Search tests"
1616
./gradlew --stacktrace --info \
1717
-Dorg.mongodb.test.atlas.search=true \
1818
-Dorg.mongodb.test.uri=${MONGODB_URI} \
19-
driver-core:test --tests AggregatesSearchIntegrationTest
19+
driver-core:test --tests AggregatesSearchIntegrationTest --tests AggregatesVectorSearchIntegrationTest

.evergreen/run-tests.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ MONGODB_URI=${MONGODB_URI:-}
3535
TOPOLOGY=${TOPOLOGY:-server}
3636
COMPRESSOR=${COMPRESSOR:-}
3737
STREAM_TYPE=${STREAM_TYPE:-nio2}
38+
TESTS=${TESTS:-test}
3839
SLOW_TESTS_ONLY=${SLOW_TESTS_ONLY:-false}
3940

4041
export ASYNC_TYPE="-Dorg.mongodb.test.async.type=${STREAM_TYPE}"
@@ -136,15 +137,8 @@ echo "Running $AUTH tests over $SSL for $TOPOLOGY and connecting to $MONGODB_URI
136137
echo "Running tests with Java ${JAVA_VERSION}"
137138
./gradlew -version
138139

139-
if [ "$SLOW_TESTS_ONLY" == "true" ]; then
140-
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
141-
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
142-
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
143-
--stacktrace --info testSlowOnly
144-
else
145-
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
146-
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
147-
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
148-
-Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled=true \
149-
--stacktrace --info --continue test
150-
fi
140+
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
141+
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
142+
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
143+
-Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled=true \
144+
--stacktrace --info --continue ${TESTS}

bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/DateTimeSerializers.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,16 @@ import org.bson.codecs.kotlinx.utils.SerializationModuleUtils.isClassAvailable
5454
public val dateTimeSerializersModule: SerializersModule by lazy {
5555
var module = SerializersModule {}
5656
if (isClassAvailable("kotlinx.datetime.Instant")) {
57-
module +=
58-
InstantAsBsonDateTime.serializersModule +
59-
LocalDateAsBsonDateTime.serializersModule +
60-
LocalDateTimeAsBsonDateTime.serializersModule +
61-
LocalTimeAsBsonDateTime.serializersModule
57+
module += InstantAsBsonDateTime.serializersModule
58+
}
59+
if (isClassAvailable("kotlinx.datetime.LocalDate")) {
60+
module += LocalDateAsBsonDateTime.serializersModule
61+
}
62+
if (isClassAvailable("kotlinx.datetime.LocalDateTime")) {
63+
module += LocalDateTimeAsBsonDateTime.serializersModule
64+
}
65+
if (isClassAvailable("kotlinx.datetime.LocalTime")) {
66+
module += LocalTimeAsBsonDateTime.serializersModule
6267
}
6368
module
6469
}

bson-scala/src/main/scala/org/mongodb/scala/bson/codecs/macrocodecs/MacroCodec.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import scala.collection.mutable
2222
import org.bson._
2323
import org.bson.codecs.configuration.{ CodecRegistries, CodecRegistry }
2424
import org.bson.codecs.{ Codec, DecoderContext, Encoder, EncoderContext }
25+
import scala.collection.immutable.Vector
2526

2627
import org.mongodb.scala.bson.BsonNull
2728

bson-scala/src/test/scala/org/mongodb/scala/bson/codecs/MacrosSpec.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.mongodb.scala.bson.annotations.{ BsonIgnore, BsonProperty }
3030
import org.mongodb.scala.bson.codecs.Macros.{ createCodecProvider, createCodecProviderIgnoreNone }
3131
import org.mongodb.scala.bson.codecs.Registry.DEFAULT_CODEC_REGISTRY
3232
import org.mongodb.scala.bson.collection.immutable.Document
33+
import scala.collection.immutable.Vector
3334

3435
import scala.collection.JavaConverters._
3536
import scala.reflect.ClassTag

bson/src/main/org/bson/BsonBinary.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818

1919
import org.bson.assertions.Assertions;
2020
import org.bson.internal.UuidHelper;
21+
import org.bson.internal.vector.VectorHelper;
2122

2223
import java.util.Arrays;
2324
import java.util.UUID;
2425

26+
import static org.bson.internal.vector.VectorHelper.encodeVectorToBinary;
27+
2528
/**
2629
* A representation of the BSON Binary type. Note that for performance reasons instances of this class are not immutable,
2730
* so care should be taken to only modify the underlying byte array if you know what you're doing, or else make a defensive copy.
@@ -89,6 +92,20 @@ public BsonBinary(final UUID uuid) {
8992
this(uuid, UuidRepresentation.STANDARD);
9093
}
9194

95+
/**
96+
* Constructs a {@linkplain BsonBinarySubType#VECTOR subtype 9} {@link BsonBinary} from the given {@link Vector}.
97+
*
98+
* @param vector the {@link Vector}
99+
* @since 5.3
100+
*/
101+
public BsonBinary(final Vector vector) {
102+
if (vector == null) {
103+
throw new IllegalArgumentException("Vector must not be null");
104+
}
105+
this.data = encodeVectorToBinary(vector);
106+
type = BsonBinarySubType.VECTOR.getValue();
107+
}
108+
92109
/**
93110
* Construct a new instance from the given UUID and UuidRepresentation
94111
*
@@ -127,6 +144,21 @@ public UUID asUuid() {
127144
return UuidHelper.decodeBinaryToUuid(this.data.clone(), this.type, UuidRepresentation.STANDARD);
128145
}
129146

147+
/**
148+
* Returns the binary as a {@link Vector}. The {@linkplain #getType() subtype} must be {@linkplain BsonBinarySubType#VECTOR 9}.
149+
*
150+
* @return the vector
151+
* @throws BsonInvalidOperationException if the binary subtype is not {@link BsonBinarySubType#VECTOR}.
152+
* @since 5.3
153+
*/
154+
public Vector asVector() {
155+
if (type != BsonBinarySubType.VECTOR.getValue()) {
156+
throw new BsonInvalidOperationException("type must be a Vector subtype.");
157+
}
158+
159+
return VectorHelper.decodeBinaryToVector(this.data);
160+
}
161+
130162
/**
131163
* Returns the binary as a UUID.
132164
*

bson/src/main/org/bson/BsonBinarySubType.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.bson;
1818

1919
/**
20-
* The Binary subtype
20+
* The Binary subtype.
2121
*
2222
* @since 3.0
2323
*/
@@ -60,7 +60,7 @@ public enum BsonBinarySubType {
6060
ENCRYPTED((byte) 0x06),
6161

6262
/**
63-
* Columnar data
63+
* Columnar data.
6464
*
6565
* @since 4.4
6666
*/
@@ -73,6 +73,15 @@ public enum BsonBinarySubType {
7373
*/
7474
SENSITIVE((byte) 0x08),
7575

76+
/**
77+
* Vector data.
78+
*
79+
* @mongodb.server.release 6.0
80+
* @since 5.3
81+
* @see Vector
82+
*/
83+
VECTOR((byte) 0x09),
84+
7685
/**
7786
* User defined binary data.
7887
*/
@@ -81,10 +90,10 @@ public enum BsonBinarySubType {
8190
private final byte value;
8291

8392
/**
84-
* Returns true if the given value is a UUID subtype
93+
* Returns true if the given value is a UUID subtype.
8594
*
86-
* @param value the subtype value as a byte
87-
* @return true if value is a UUID subtype
95+
* @param value the subtype value as a byte.
96+
* @return true if value is a UUID subtype.
8897
* @since 3.4
8998
*/
9099
public static boolean isUuid(final byte value) {

0 commit comments

Comments
 (0)