Skip to content

Commit 3f2c151

Browse files
committed
Run gradle classes and cache build before running on azure/gcp/k8s
Similar to the overall goals of JAVA-5891
1 parent 871db76 commit 3f2c151

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

.evergreen/.evg.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,21 @@ functions:
129129
params:
130130
role_arn: ${aws_test_secrets_role}
131131

132+
"gradle-cache":
133+
- command: shell.exec
134+
params:
135+
working_dir: "src"
136+
script: |
137+
export GRADLE_RO_DEP_CACHE="$(pwd)/build/gradle-cache"
138+
.evergreen/gradle-cache.sh
139+
132140
"create-archive-tar-file":
133141
- command: shell.exec
134142
params:
135143
working_dir: "src"
136144
script: |
137145
echo "Creating archive tar file at ${ARCHIVE_FILE_PATH}"
138-
tar --exclude="**build/" --exclude-vcs -czf "${ARCHIVE_FILE_PATH}" .
146+
tar --exclude-vcs -czf "${ARCHIVE_FILE_PATH}" .
139147
echo "Created archive tar file at ${ARCHIVE_FILE_PATH}"
140148
141149
"start-mongo-orchestration":
@@ -820,7 +828,7 @@ functions:
820828
${PREPARE_SHELL}
821829
export K8S_VARIANT=${VARIANT}
822830
export K8S_DRIVERS_TAR_FILE=$ARCHIVE_FILE_PATH
823-
export K8S_TEST_CMD="OIDC_ENV=k8s VARIANT=${VARIANT} ./.evergreen/run-mongodb-oidc-test.sh"
831+
export K8S_TEST_CMD="GRADLE_RO_DEP_CACHE='./build/gradle-cache' OIDC_ENV=k8s VARIANT=${VARIANT} ./.evergreen/run-mongodb-oidc-test.sh"
824832
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/setup-pod.sh
825833
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/run-self-test.sh
826834
source $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/secrets-export.sh
@@ -936,6 +944,8 @@ tasks:
936944
- .evergreen/run-mongodb-oidc-test.sh
937945

938946
- name: "oidc-auth-test-azure-task"
947+
# Might exceed 1 hour of execution.
948+
exec_timeout_secs: 7200
939949
commands:
940950
- command: shell.exec
941951
params:
@@ -948,11 +958,13 @@ tasks:
948958
set -o errexit
949959
${PREPARE_SHELL}
950960
export AZUREOIDC_DRIVERS_TAR_FILE=$ARCHIVE_FILE_PATH
951-
export AZUREOIDC_TEST_CMD="OIDC_ENV=azure ./.evergreen/run-mongodb-oidc-test.sh"
952-
tar --exclude="**build/" --exclude-vcs -czf $AZUREOIDC_DRIVERS_TAR_FILE .
961+
export AZUREOIDC_TEST_CMD="GRADLE_RO_DEP_CACHE='/home/azureuser/build/gradle-cache' OIDC_ENV=azure ./.evergreen/run-mongodb-oidc-test.sh"
962+
tar --exclude-vcs -czf $AZUREOIDC_DRIVERS_TAR_FILE .
953963
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/azure/run-driver-test.sh
954964
955965
- name: "oidc-auth-test-gcp-task"
966+
# Might exceed 1 hour of execution.
967+
exec_timeout_secs: 7200
956968
commands:
957969
- command: shell.exec
958970
params:
@@ -966,8 +978,8 @@ tasks:
966978
# Define the command to run on the VM.
967979
# Ensure that we source the environment file created for us, set up any other variables we need,
968980
# and then run our test suite on the vm.
969-
export GCPOIDC_TEST_CMD="OIDC_ENV=gcp ./.evergreen/run-mongodb-oidc-test.sh"
970-
tar --exclude="**build/" --exclude-vcs -czf $GCPOIDC_DRIVERS_TAR_FILE .
981+
export GCPOIDC_TEST_CMD="GRADLE_RO_DEP_CACHE='./build/gradle-cache' OIDC_ENV=gcp ./.evergreen/run-mongodb-oidc-test.sh"
982+
tar --exclude-vcs -czf $GCPOIDC_DRIVERS_TAR_FILE .
971983
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/gcp/run-driver-test.sh
972984
973985
- name: "oidc-auth-test-k8s-task"
@@ -1711,7 +1723,7 @@ tasks:
17111723
export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup}
17121724
export AZUREKMS_VMNAME=${AZUREKMS_VMNAME}
17131725
export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey
1714-
AZUREKMS_CMD="MONGODB_URI=mongodb://localhost:27017 PROVIDER=azure AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} AZUREKMS_KEY_NAME=${testazurekms_keyname} ./.evergreen/run-fle-on-demand-credential-test.sh" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
1726+
AZUREKMS_CMD="GRADLE_RO_DEP_CACHE='/home/azureuser/build/gradle-cache' MONGODB_URI=mongodb://localhost:27017 PROVIDER=azure AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} AZUREKMS_KEY_NAME=${testazurekms_keyname} ./.evergreen/run-fle-on-demand-credential-test.sh" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
17151727
17161728
- name: "test-socks5-task"
17171729
tags: [ ]
@@ -1970,6 +1982,7 @@ task_groups:
19701982
- func: "fetch-source"
19711983
- func: "prepare-resources"
19721984
- func: "fix-absolute-paths"
1985+
- func: "gradle-cache"
19731986
- func: "create-archive-tar-file"
19741987
- command: shell.exec
19751988
params:
@@ -2007,6 +2020,7 @@ task_groups:
20072020
- func: "fetch-source"
20082021
- func: "prepare-resources"
20092022
- func: "fix-absolute-paths"
2023+
- func: "gradle-cache"
20102024
- func: "create-archive-tar-file"
20112025
- func: "assume-aws-test-secrets-role"
20122026
- command: shell.exec
@@ -2082,6 +2096,7 @@ task_groups:
20822096
- func: "fetch-source"
20832097
- func: "prepare-resources"
20842098
- func: "fix-absolute-paths"
2099+
- func: "gradle-cache"
20852100
- func: "create-archive-tar-file"
20862101
- func: "assume-aws-test-secrets-role"
20872102
- command: subprocess.exec
@@ -2110,6 +2125,7 @@ task_groups:
21102125
- func: "fetch-source"
21112126
- func: "prepare-resources"
21122127
- func: "fix-absolute-paths"
2128+
- func: "gradle-cache"
21132129
- func: "create-archive-tar-file"
21142130
- func: "assume-aws-test-secrets-role"
21152131
- command: subprocess.exec
@@ -2139,6 +2155,7 @@ task_groups:
21392155
- func: "fetch-source"
21402156
- func: "prepare-resources"
21412157
- func: "fix-absolute-paths"
2158+
- func: "gradle-cache"
21422159
- func: "create-archive-tar-file"
21432160
- func: "assume-aws-test-secrets-role"
21442161
- command: subprocess.exec
@@ -2192,14 +2209,14 @@ buildvariants:
21922209

21932210
- name: "test-oidc-azure-variant"
21942211
display_name: "OIDC Auth Azure"
2195-
run_on: ubuntu2204-small
2212+
run_on: ubuntu2204-large
21962213
tasks:
21972214
- name: "test-oidc-azure-task-group"
21982215
batchtime: 20160 # 14 days
21992216

22002217
- name: "test-oidc-gcp-variant"
22012218
display_name: "OIDC Auth GCP"
2202-
run_on: ubuntu2204-small
2219+
run_on: ubuntu2204-large
22032220
tasks:
22042221
- name: "test-oidc-gcp-task-group"
22052222
batchtime: 20160 # 14 days

.evergreen/gradle-cache.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -o xtrace # Write all commands first to stderr
4+
set -o errexit # Exit the script with error if any of the commands fail
5+
6+
############################################
7+
# Main Program #
8+
############################################
9+
RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE[0]:-$0}")"
10+
. "${RELATIVE_DIR_PATH}/setup-env.bash"
11+
12+
echo "Enable caching"
13+
echo "org.gradle.caching=true" >> gradle.properties
14+
echo "kotlin.caching.enabled=true" >> gradle.properties
15+
16+
echo "Compiling JVM drivers"
17+
./gradlew -version
18+
./gradlew classes --parallel
19+
20+
# Copy the Gradle dependency cache to the gradle read only dependency cache directory.
21+
if [ -n "$GRADLE_RO_DEP_CACHE" ];then
22+
echo "Copying Gradle dependency cache to $GRADLE_RO_DEP_CACHE"
23+
mkdir -p $GRADLE_RO_DEP_CACHE
24+
25+
# https://docs.gradle.org/current/userguide/dependency_caching.html#sec:cache-copy
26+
# Gradle suggests removing the "*.lock" files and the `gc.properties` file for saving/restoring cache
27+
cp -r $HOME/.gradle/caches/modules-2 "$GRADLE_RO_DEP_CACHE"
28+
find "$GRADLE_RO_DEP_CACHE" -name "*.lock" -type f | xargs rm -f
29+
find "$GRADLE_RO_DEP_CACHE" -name "gc.properties" -type f | xargs rm -f
30+
31+
echo "Copied Gradle dependency cache to $GRADLE_RO_DEP_CACHE"
32+
fi

0 commit comments

Comments
 (0)