Skip to content

Commit 2235b83

Browse files
authored
PYTHON-5050 Clean up handling of installed dependencies across deployment targets (#2071)
1 parent 7dba1e5 commit 2235b83

File tree

6 files changed

+75
-61
lines changed

6 files changed

+75
-61
lines changed

.evergreen/install-dependencies.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

.evergreen/run-azurekms-test.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ export AZUREKMS_VMNAME=${AZUREKMS_VMNAME}
88
export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey
99
export LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian11/master/latest/libmongocrypt.tar.gz
1010
SKIP_SERVERS=1 bash $HERE/setup-encryption.sh
11-
tar czf /tmp/mongo-python-driver.tgz .
11+
# Set up the remote files to test.
12+
git add .
13+
git commit -m "add files" || true
14+
git archive -o /tmp/mongo-python-driver.tar HEAD
15+
tar -rf /tmp/mongo-python-driver.tar libmongocrypt
16+
gzip -f /tmp/mongo-python-driver.tar
1217
# shellcheck disable=SC2088
13-
AZUREKMS_SRC="/tmp/mongo-python-driver.tgz" AZUREKMS_DST="~/" \
18+
AZUREKMS_SRC="/tmp/mongo-python-driver.tar.gz" AZUREKMS_DST="~/" \
1419
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/copy-file.sh
1520
echo "Copying files ... end"
1621
echo "Untarring file ... begin"
17-
AZUREKMS_CMD="tar xf mongo-python-driver.tgz" \
22+
AZUREKMS_CMD="tar xf mongo-python-driver.tar.gz" \
1823
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
1924
echo "Untarring file ... end"
2025
echo "Running test ... begin"
21-
AZUREKMS_CMD="KEY_NAME=\"$AZUREKMS_KEYNAME\" KEY_VAULT_ENDPOINT=\"$AZUREKMS_KEYVAULTENDPOINT\" SUCCESS=true TEST_FLE_AZURE_AUTO=1 ./.evergreen/just.sh test-eg" \
26+
AZUREKMS_CMD="KEY_NAME=\"$AZUREKMS_KEYNAME\" KEY_VAULT_ENDPOINT=\"$AZUREKMS_KEYVAULTENDPOINT\" SUCCESS=true TEST_FLE_AZURE_AUTO=1 bash ./.evergreen/just.sh test-eg" \
2227
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
2328
echo "Running test ... end"
2429
bash $HERE/teardown-encryption.sh

.evergreen/run-gcpkms-test.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ export GCPKMS_ZONE=${GCPKMS_ZONE}
1010
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME}
1111
export LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian11/master/latest/libmongocrypt.tar.gz
1212
SKIP_SERVERS=1 bash $HERE/setup-encryption.sh
13-
tar czf /tmp/mongo-python-driver.tgz .
14-
GCPKMS_SRC=/tmp/mongo-python-driver.tgz GCPKMS_DST=$GCPKMS_INSTANCENAME: $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/copy-file.sh
13+
# Set up the remote files to test.
14+
git add .
15+
git commit -m "add files" || true
16+
git archive -o /tmp/mongo-python-driver.tar HEAD
17+
tar -rf /tmp/mongo-python-driver.tar libmongocrypt
18+
gzip -f /tmp/mongo-python-driver.tar
19+
GCPKMS_SRC=/tmp/mongo-python-driver.tar.gz GCPKMS_DST=$GCPKMS_INSTANCENAME: $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/copy-file.sh
1520
echo "Copying files ... end"
1621
echo "Untarring file ... begin"
17-
GCPKMS_CMD="tar xf mongo-python-driver.tgz" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
22+
GCPKMS_CMD="tar xf mongo-python-driver.tar.gz" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
1823
echo "Untarring file ... end"
1924
echo "Running test ... begin"
2025
GCPKMS_CMD="SUCCESS=true TEST_FLE_GCP_AUTO=1 ./.evergreen/just.sh test-eg" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
#!/bin/bash
22

33
set -eu
4-
file="$PROJECT_DIRECTORY/.evergreen/install-dependencies.sh"
5-
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
6-
[ -f "$file" ] && bash "$file" || echo "$file not available, skipping"
4+
5+
# On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME.
6+
if [ "${CI:-}" == "true" ]; then
7+
_BIN_DIR=${DRIVERS_TOOLS_BINARIES:-}
8+
else
9+
_BIN_DIR=$HOME/.local/bin
10+
fi
11+
12+
13+
# Helper function to pip install a dependency using a temporary python env.
14+
function _pip_install() {
15+
_HERE=$(dirname ${BASH_SOURCE:-$0})
16+
. $_HERE/../utils.sh
17+
_VENV_PATH=$(mktemp -d)
18+
echo "Installing $2 using pip..."
19+
createvirtualenv "$(find_python3)" $_VENV_PATH
20+
python -m pip install $1
21+
ln -s "$(which $2)" $_BIN_DIR/$2
22+
echo "Installing $2 using pip... done."
23+
}
24+
25+
26+
# Ensure just is installed.
27+
if ! command -v just 2>/dev/null; then
28+
# On most systems we can install directly.
29+
_TARGET=""
30+
if [ "Windows_NT" = "${OS:-}" ]; then
31+
_TARGET="--target x86_64-pc-windows-msvc"
32+
fi
33+
echo "Installing just..."
34+
mkdir -p "$_BIN_DIR" 2>/dev/null || true
35+
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- $_TARGET --to "$_BIN_DIR" || {
36+
_pip_install rust-just just
37+
}
38+
if ! command -v just 2>/dev/null; then
39+
export PATH="$PATH:$_BIN_DIR"
40+
fi
41+
echo "Installing just... done."
42+
fi

.evergreen/scripts/prepare-resources.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@ pushd $HERE
66
. env.sh
77

88
rm -rf $DRIVERS_TOOLS
9-
if [ "$PROJECT" = "drivers-tools" ]; then
10-
# If this was a patch build, doing a fresh clone would not actually test the patch
11-
cp -R $PROJECT_DIRECTORY/ $DRIVERS_TOOLS
12-
else
13-
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
14-
fi
9+
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
1510
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" >$MONGO_ORCHESTRATION_HOME/orchestration.config
1611

1712
popd
13+
14+
# Copy PyMongo's test certificates over driver-evergreen-tools'
15+
cp ${PROJECT_DIRECTORY}/test/certificates/* ${DRIVERS_TOOLS}/.evergreen/x509gen/
16+
17+
# Replace MongoOrchestration's client certificate.
18+
cp ${PROJECT_DIRECTORY}/test/certificates/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem
19+
20+
if [ -w /etc/hosts ]; then
21+
SUDO=""
22+
else
23+
SUDO="sudo"
24+
fi
25+
26+
# Add 'server' and 'hostname_not_in_cert' as a hostnames
27+
echo "127.0.0.1 server" | $SUDO tee -a /etc/hosts
28+
echo "127.0.0.1 hostname_not_in_cert" | $SUDO tee -a /etc/hosts

.evergreen/scripts/setup-dev-env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ else
1717
BIN_DIR=.venv/bin
1818
fi
1919

20+
. $HERE/install-dependencies.sh
21+
2022
# Ensure there is a python venv.
2123
if [ ! -d $BIN_DIR ]; then
2224
. .evergreen/utils.sh

0 commit comments

Comments
 (0)