Skip to content

Commit de504ee

Browse files
authored
Merge branch 'main' into edarke-faster-basicoutputbuffer
2 parents 969079d + fa4a9ed commit de504ee

File tree

47 files changed

+1116
-129
lines changed

Some content is hidden

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

47 files changed

+1116
-129
lines changed

.evergreen/.evg.yml

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,30 @@ functions:
798798
${PREPARE_SHELL}
799799
MONGODB_URI="${MONGODB_URI}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-graalvm-native-image-app.sh
800800
801+
"oidc-auth-test-k8s-func":
802+
- command: shell.exec
803+
type: test
804+
params:
805+
shell: bash
806+
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
807+
script: |-
808+
set -o errexit
809+
${PREPARE_SHELL}
810+
export K8S_VARIANT=${VARIANT}
811+
cd src
812+
git add .
813+
git commit --allow-empty -m "add files"
814+
# uncompressed tar used to allow appending .git folder
815+
export K8S_DRIVERS_TAR_FILE=/tmp/mongo-java-driver.tar
816+
git archive -o $K8S_DRIVERS_TAR_FILE HEAD
817+
tar -rf $K8S_DRIVERS_TAR_FILE .git
818+
export K8S_TEST_CMD="OIDC_ENV=k8s VARIANT=${VARIANT} ./.evergreen/run-mongodb-oidc-test.sh"
819+
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/setup-pod.sh
820+
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/run-self-test.sh
821+
source $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/secrets-export.sh
822+
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/run-driver-test.sh
823+
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/teardown-pod.sh
824+
801825
# Anchors
802826

803827
pre:
@@ -921,6 +945,22 @@ tasks:
921945
export GCPOIDC_TEST_CMD="OIDC_ENV=gcp ./.evergreen/run-mongodb-oidc-test.sh"
922946
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/gcp/run-driver-test.sh
923947
948+
- name: "oidc-auth-test-k8s"
949+
commands:
950+
- command: ec2.assume_role
951+
params:
952+
role_arn: ${aws_test_secrets_role}
953+
duration_seconds: 1800
954+
- func: "oidc-auth-test-k8s-func"
955+
vars:
956+
VARIANT: eks
957+
- func: "oidc-auth-test-k8s-func"
958+
vars:
959+
VARIANT: aks
960+
- func: "oidc-auth-test-k8s-func"
961+
vars:
962+
VARIANT: gke
963+
924964
- name: serverless-test
925965
commands:
926966
- func: "run serverless"
@@ -1901,6 +1941,7 @@ axes:
19011941

19021942
task_groups:
19031943
- name: "atlas-deployed-task-group"
1944+
max_hosts: -1
19041945
setup_group:
19051946
- func: fetch source
19061947
- func: prepare resources
@@ -2011,7 +2052,7 @@ task_groups:
20112052
tasks:
20122053
- testazurekms-task
20132054

2014-
- name: testoidc_task_group
2055+
- name: test-oidc-task-group
20152056
setup_group:
20162057
- func: fetch source
20172058
- func: prepare resources
@@ -2036,7 +2077,7 @@ task_groups:
20362077
tasks:
20372078
- oidc-auth-test
20382079

2039-
- name: testazureoidc_task_group
2080+
- name: test-oidc-azure-task-group
20402081
setup_group:
20412082
- func: fetch source
20422083
- func: prepare resources
@@ -2059,7 +2100,7 @@ task_groups:
20592100
tasks:
20602101
- oidc-auth-test-azure
20612102

2062-
- name: testgcpoidc_task_group
2103+
- name: test-oidc-gcp-task-group
20632104
setup_group:
20642105
- func: fetch source
20652106
- func: prepare resources
@@ -2083,6 +2124,33 @@ task_groups:
20832124
tasks:
20842125
- oidc-auth-test-gcp
20852126

2127+
- name: test-oidc-k8s-task-group
2128+
setup_group_can_fail_task: true
2129+
setup_group_timeout_secs: 1800
2130+
teardown_task_can_fail_task: true
2131+
teardown_group_timeout_secs: 180
2132+
setup_group:
2133+
- func: fetch source
2134+
- func: prepare resources
2135+
- func: fix absolute paths
2136+
- command: ec2.assume_role
2137+
params:
2138+
role_arn: ${aws_test_secrets_role}
2139+
- command: subprocess.exec
2140+
params:
2141+
binary: bash
2142+
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
2143+
args:
2144+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/setup.sh
2145+
teardown_group:
2146+
- command: subprocess.exec
2147+
params:
2148+
binary: bash
2149+
args:
2150+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/teardown.sh
2151+
tasks:
2152+
- oidc-auth-test-k8s
2153+
20862154
buildvariants:
20872155

20882156
# Test packaging and other release related routines
@@ -2254,21 +2322,28 @@ buildvariants:
22542322
display_name: "OIDC Auth"
22552323
run_on: ubuntu2204-small
22562324
tasks:
2257-
- name: testoidc_task_group
2325+
- name: test-oidc-task-group
22582326
batchtime: 20160 # 14 days
22592327

2260-
- name: testazureoidc-variant
2328+
- name: test-oidc-azure-variant
22612329
display_name: "OIDC Auth Azure"
22622330
run_on: ubuntu2204-small
22632331
tasks:
2264-
- name: testazureoidc_task_group
2332+
- name: test-oidc-azure-task-group
22652333
batchtime: 20160 # 14 days
22662334

2267-
- name: testgcpoidc-variant
2335+
- name: test-oidc-gcp-variant
22682336
display_name: "OIDC Auth GCP"
22692337
run_on: ubuntu2204-small
22702338
tasks:
2271-
- name: testgcpoidc_task_group
2339+
- name: test-oidc-gcp-task-group
2340+
batchtime: 20160 # 14 days
2341+
2342+
- name: test-oidc-k8s-variant
2343+
display_name: "OIDC Auth K8S"
2344+
run_on: ubuntu2204-small
2345+
tasks:
2346+
- name: test-oidc-k8s-task-group
22722347
batchtime: 20160 # 14 days
22732348

22742349
- matrix_name: "aws-auth-test"

.evergreen/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626
SYSTEM_PROPERTIES="-Dorg.gradle.internal.publish.checksums.insecure=true -Dorg.gradle.internal.http.connectionTimeout=120000 -Dorg.gradle.internal.http.socketTimeout=120000"
2727

2828
./gradlew -version
29-
./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info ${TASK}
29+
./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info ${TASK} # Scala 2.13 is published as result of this gradle execution.
3030
./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info :bson-scala:${TASK} :driver-scala:${TASK} -PdefaultScalaVersions=2.12.12
3131
./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info :bson-scala:${TASK} :driver-scala:${TASK} -PdefaultScalaVersions=2.11.12

.evergreen/run-mongodb-oidc-test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ elif [ $OIDC_ENV == "azure" ]; then
1919
source ./env.sh
2020
elif [ $OIDC_ENV == "gcp" ]; then
2121
source ./secrets-export.sh
22+
elif [ $OIDC_ENV == "k8s" ]; then
23+
# Make sure K8S_VARIANT is set.
24+
if [ -z "$K8S_VARIANT" ]; then
25+
echo "Must specify K8S_VARIANT"
26+
popd
27+
exit 1
28+
fi
29+
30+
# fix for git permissions issue:
31+
git config --global --add safe.directory /tmp/test
2232
else
2333
echo "Unrecognized OIDC_ENV $OIDC_ENV"
2434
exit 1

bom/build.gradle.kts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
group = "org.mongodb"
2+
description = "This Bill of Materials POM simplifies dependency management when referencing multiple" +
3+
" MongoDB Java Driver artifacts in projects using Gradle or Maven."
4+
5+
dependencies {
6+
constraints {
7+
api(project(":mongodb-crypt"))
8+
api(project(":driver-core"))
9+
api(project(":bson"))
10+
api(project(":bson-record-codec"))
11+
12+
api(project(":driver-sync"))
13+
api(project(":driver-reactive-streams"))
14+
15+
api(project(":bson-kotlin"))
16+
api(project(":bson-kotlinx"))
17+
api(project(":driver-kotlin-coroutine"))
18+
api(project(":driver-kotlin-sync"))
19+
20+
api(project(":bson-scala"))
21+
api(project(":driver-scala"))
22+
}
23+
}

bson/src/main/org/bson/codecs/BsonArrayCodec.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.bson.codecs.configuration.CodecRegistry;
2525

2626
import static org.bson.assertions.Assertions.notNull;
27+
import static org.bson.codecs.BsonValueCodecProvider.getBsonTypeClassMap;
2728
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
2829

2930
/**
@@ -34,16 +35,16 @@
3435
public class BsonArrayCodec implements Codec<BsonArray> {
3536

3637
private static final CodecRegistry DEFAULT_REGISTRY = fromProviders(new BsonValueCodecProvider());
37-
38-
private final CodecRegistry codecRegistry;
38+
private static final BsonTypeCodecMap DEFAULT_BSON_TYPE_CODEC_MAP = new BsonTypeCodecMap(getBsonTypeClassMap(), DEFAULT_REGISTRY);
39+
private final BsonTypeCodecMap bsonTypeCodecMap;
3940

4041
/**
4142
* Creates a new instance with a default codec registry that uses the {@link BsonValueCodecProvider}.
4243
*
4344
* @since 3.4
4445
*/
4546
public BsonArrayCodec() {
46-
this(DEFAULT_REGISTRY);
47+
this(DEFAULT_BSON_TYPE_CODEC_MAP);
4748
}
4849

4950
/**
@@ -52,7 +53,11 @@ public BsonArrayCodec() {
5253
* @param codecRegistry the codec registry
5354
*/
5455
public BsonArrayCodec(final CodecRegistry codecRegistry) {
55-
this.codecRegistry = notNull("codecRegistry", codecRegistry);
56+
this(new BsonTypeCodecMap(getBsonTypeClassMap(), codecRegistry));
57+
}
58+
59+
private BsonArrayCodec(final BsonTypeCodecMap bsonTypeCodecMap) {
60+
this.bsonTypeCodecMap = notNull("bsonTypeCodecMap", bsonTypeCodecMap);
5661
}
5762

5863
@Override
@@ -72,7 +77,7 @@ public void encode(final BsonWriter writer, final BsonArray array, final Encoder
7277
writer.writeStartArray();
7378

7479
for (BsonValue value : array) {
75-
Codec codec = codecRegistry.get(value.getClass());
80+
Codec codec = bsonTypeCodecMap.get(value.getBsonType());
7681
encoderContext.encodeWithChildContext(codec, writer, value);
7782
}
7883

@@ -93,7 +98,7 @@ public Class<BsonArray> getEncoderClass() {
9398
* @return the non-null value read from the reader
9499
*/
95100
protected BsonValue readValue(final BsonReader reader, final DecoderContext decoderContext) {
96-
return codecRegistry.get(BsonValueCodecProvider.getClassForBsonType(reader.getCurrentBsonType())).decode(reader, decoderContext);
101+
BsonType currentBsonType = reader.getCurrentBsonType();
102+
return (BsonValue) bsonTypeCodecMap.get(currentBsonType).decode(reader, decoderContext);
97103
}
98-
99104
}

bson/src/main/org/bson/codecs/BsonDocumentCodec.java

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

1919
import org.bson.BsonDocument;
20-
import org.bson.BsonElement;
2120
import org.bson.BsonObjectId;
2221
import org.bson.BsonReader;
2322
import org.bson.BsonType;
@@ -26,8 +25,6 @@
2625
import org.bson.codecs.configuration.CodecRegistry;
2726
import org.bson.types.ObjectId;
2827

29-
import java.util.ArrayList;
30-
import java.util.List;
3128
import java.util.Map;
3229

3330
import static org.bson.assertions.Assertions.notNull;
@@ -79,17 +76,15 @@ public CodecRegistry getCodecRegistry() {
7976

8077
@Override
8178
public BsonDocument decode(final BsonReader reader, final DecoderContext decoderContext) {
82-
List<BsonElement> keyValuePairs = new ArrayList<>();
83-
79+
BsonDocument bsonDocument = new BsonDocument();
8480
reader.readStartDocument();
8581
while (reader.readBsonType() != BsonType.END_OF_DOCUMENT) {
8682
String fieldName = reader.readName();
87-
keyValuePairs.add(new BsonElement(fieldName, readValue(reader, decoderContext)));
83+
bsonDocument.append(fieldName, readValue(reader, decoderContext));
8884
}
8985

9086
reader.readEndDocument();
91-
92-
return new BsonDocument(keyValuePairs);
87+
return bsonDocument;
9388
}
9489

9590
/**
@@ -135,7 +130,7 @@ private boolean skipField(final EncoderContext encoderContext, final String key)
135130

136131
@SuppressWarnings({"unchecked", "rawtypes"})
137132
private void writeValue(final BsonWriter writer, final EncoderContext encoderContext, final BsonValue value) {
138-
Codec codec = codecRegistry.get(value.getClass());
133+
Codec codec = bsonTypeCodecMap.get(value.getBsonType());
139134
encoderContext.encodeWithChildContext(codec, writer, value);
140135
}
141136

0 commit comments

Comments
 (0)