Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3977c1d
wip
blink1073 Nov 23, 2025
87c92c2
use mongodb-runner
blink1073 Nov 24, 2025
6ed9c44
fix location
blink1073 Nov 24, 2025
b0212df
fix node handling
blink1073 Nov 24, 2025
5b3add6
fix node handling
blink1073 Nov 24, 2025
b87ad2f
fix mongodb-runner teardown
blink1073 Nov 24, 2025
84535e2
add new scripts and tests
blink1073 Nov 24, 2025
f7489ae
fix spelling
blink1073 Nov 24, 2025
1eecf93
fix test
blink1073 Nov 24, 2025
e78c6ab
try a windows fix
blink1073 Nov 24, 2025
8a2d6a3
try a windows fix
blink1073 Nov 24, 2025
ac5ad32
incorporate shard and tls updates
blink1073 Nov 25, 2025
572273d
cleanup
blink1073 Dec 1, 2025
b12c0d3
use the right node
blink1073 Dec 1, 2025
e23b58c
fix windows path
blink1073 Dec 1, 2025
d75c8a7
fix windows path
blink1073 Dec 1, 2025
67d5ccb
fix ocsp and server tests
blink1073 Dec 1, 2025
d0ef74c
fix node and ocsp usage
blink1073 Dec 5, 2025
534fd8b
use main
blink1073 Dec 5, 2025
aad2f44
fix var usage
blink1073 Dec 5, 2025
b120f2b
fix shlex usage
blink1073 Dec 5, 2025
d64f337
fix value formatting
blink1073 Dec 5, 2025
c70b0a0
fix ocsp
blink1073 Dec 5, 2025
b282da7
try to fix oidc
blink1073 Dec 5, 2025
aabc6e8
try to fix oidc
blink1073 Dec 5, 2025
1071b9f
try to fix oidc
blink1073 Dec 5, 2025
337f88e
fix docker and oidc
blink1073 Dec 6, 2025
462b3b8
test args and keyfile improvements
blink1073 Dec 8, 2025
bd5a93a
fix typing syntax
blink1073 Dec 8, 2025
2af8a2c
Merge branch 'master' of github.com:mongodb-labs/drivers-evergreen-to…
blink1073 Dec 8, 2025
cee8899
fix prefix
blink1073 Dec 8, 2025
185c4dc
try with npx
blink1073 Dec 8, 2025
e4f89ac
fix windows path
blink1073 Dec 8, 2025
3538afa
debug
blink1073 Dec 8, 2025
8e4ac51
include node improvements
blink1073 Dec 8, 2025
bfd3a43
include npx.cmd
blink1073 Dec 8, 2025
92f985f
try with branch
blink1073 Dec 8, 2025
dc82a2a
handle requireApiVersion
blink1073 Dec 8, 2025
c612a85
swap server and log files and fix shutdown
blink1073 Dec 9, 2025
739f008
fix shutdown
blink1073 Dec 9, 2025
c1f7dd0
fixups
blink1073 Dec 9, 2025
674b02a
fixup for node version
blink1073 Dec 9, 2025
76701c6
fix order
blink1073 Dec 9, 2025
9624974
fix 3.6 handling
blink1073 Dec 9, 2025
b00e756
enable auth and ssl testing in test-server
blink1073 Dec 9, 2025
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
27 changes: 27 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,20 @@ functions:
include_expansions_in_env: [AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, AWS_SESSION_TOKEN]
args: [src/.evergreen/tests/test-csfle.sh]

"run server test partial":
- command: subprocess.exec
type: test
params:
binary: bash
args: [src/.evergreen/tests/test-server.sh, partial]

"run server test full":
- command: subprocess.exec
type: test
params:
binary: bash
args: [src/.evergreen/tests/test-server.sh]

"run cli test partial":
- command: subprocess.exec
type: test
Expand Down Expand Up @@ -1103,6 +1117,11 @@ tasks:
commands:
- func: "run cli test full"

- name: "test-server-full"
tags: ["pr"]
commands:
- func: "run server test full"

- name: "test-ocsp"
tags: ["pr", "ocsp"]
commands:
Expand All @@ -1118,6 +1137,11 @@ tasks:
commands:
- func: "run cli test partial"

- name: "test-server-partial"
tags: ["pr"]
commands:
- func: "run server test partial"

# }}}

task_groups:
Expand Down Expand Up @@ -1556,6 +1580,7 @@ buildvariants:
- "test-install-binaries"
- "test-csfle"
- "test-cli-full"
- "test-server-full"
- "test-happy-eyeballs"
- "test-ocsp"
- "test-8.0-standalone-require-api"
Expand Down Expand Up @@ -1585,6 +1610,7 @@ buildvariants:
add_tasks:
- "test-install-binaries"
- "test-cli-partial"
- "test-server-partial"

- matrix_name: "tests-os-requires-70"
matrix_spec: {"os-requires-70": "*", auth: "*", ssl: "*" }
Expand All @@ -1608,6 +1634,7 @@ buildvariants:
add_tasks:
- "test-install-binaries"
- "test-cli-partial"
- "test-server-partial"

# Storage Engine Tests on Ubuntu 20.04
- matrix_name: "tests-storage-engines"
Expand Down
3 changes: 2 additions & 1 deletion .evergreen/docker/rhel8/base-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
set -eu

# Remove the virtual env.
# Remove the virtual env and any node install.
rm -rf $DRIVERS_TOOLS/.evergreen/venv || true
rm -rf $DRIVERS_TOOLS/.evergreen/node-artifacts || true

# Start the server.
cd $DRIVERS_TOOLS
Expand Down
3 changes: 2 additions & 1 deletion .evergreen/docker/ubuntu22.04/base-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
set -eu

# Remove the virtual env.
# Remove the virtual env and any node install.
rm -rf $DRIVERS_TOOLS/.evergreen/venv || true
rm -rf $DRIVERS_TOOLS/.evergreen/node-artifacts || true

# Start the server.
cd $DRIVERS_TOOLS
Expand Down
11 changes: 7 additions & 4 deletions .evergreen/init-node-and-npm-env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env bash
# shellcheck shell=sh
##
## This script add the location of `npm` and `node` to the path.
## This is necessary because evergreen uses separate bash scripts for
Expand All @@ -7,10 +8,12 @@
## access to `npm`, `node`, or need to install something globally from
## npm.

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/handle-paths.sh
NODE_ARTIFACTS_PATH="$SCRIPT_DIR/node-artifacts"
if [[ "${OS:-}" == "Windows_NT" ]]; then
# See https://stackoverflow.com/questions/35006457/choosing-between-0-and-bash-source/35006505#35006505
# Why we need this syntax when sh is not aliased to bash (this script must be able to be called from sh)
# shellcheck disable=SC3028
_SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
NODE_ARTIFACTS_PATH="$_SCRIPT_DIR/node-artifacts"
if [ "${OS:-}" = "Windows_NT" ]; then
NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH")
fi

Expand Down
75 changes: 47 additions & 28 deletions .evergreen/install-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ set -o errexit # Exit the script with error if any of the commands fail

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/handle-paths.sh
pushd $SCRIPT_DIR

NODE_LTS_VERSION=${NODE_LTS_VERSION:-20}
DEFAULT_NODE_VERSION=20
if grep -q "release 7" /etc/redhat-release 2> /dev/null; then
DEFAULT_NODE_VERSION=16
fi
NODE_LTS_VERSION=${NODE_LTS_VERSION:-$DEFAULT_NODE_VERSION}

# If NODE_LTS_VERSION is numeric and less than 18, default to 9, if less than 20, default to 10.
# Do not override if it is already set.
if [[ "$NODE_LTS_VERSION" =~ ^[0-9]+$ && "$NODE_LTS_VERSION" -lt 18 ]]; then
Expand All @@ -17,11 +21,32 @@ else
fi
export NPM_VERSION=${NPM_VERSION}

source "./init-node-and-npm-env.sh"
source "$SCRIPT_DIR/init-node-and-npm-env.sh"

if [[ -z "${npm_global_prefix}" ]]; then echo "npm_global_prefix is unset" && exit 1; fi
if [[ -z "${NODE_ARTIFACTS_PATH}" ]]; then echo "NODE_ARTIFACTS_PATH is unset" && exit 1; fi

function debug_output {
echo "node location: $(which node)"
echo "node version: $(node -v)"
echo "npm location: $(which npm)"
echo "npm version: $(npm -v)"
echo "Run 'source init-node-and-npm-env.sh' to handle environment setup."
}

# Bail early if this version of node was already installed.
if grep -Fxq "$NODE_LTS_VERSION" $NODE_ARTIFACTS_PATH/node-version.txt 2> /dev/null; then
echo "Node $NODE_LTS_VERSION already installed!"
debug_output
exit 0
fi

# Ensure a clean directory.
rm -rf $NODE_ARTIFACTS_PATH
mkdir -p "$NODE_ARTIFACTS_PATH/npm_global"

echo "Installing Node.js $NODE_LTS_VERSION..."

CURL_FLAGS=(
--fail # Exit code 1 if request fails
--compressed # Request a compressed response should keep fetching fast
Expand All @@ -32,19 +57,16 @@ CURL_FLAGS=(
--max-time 900 # 900 seconds is 15 minutes, evergreen times out at 20
)

mkdir -p "$NODE_ARTIFACTS_PATH/npm_global"

# Comparisons are all case insensitive
shopt -s nocasematch

# index.tab is a sorted tab separated values file with the following headers
# 0 1 2 3 4 5 6 7 8 9 10
# version date files npm v8 uv zlib openssl modules lts security
"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "https://nodejs.org/dist/index.tab" --output node_index.tab
"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "https://nodejs.org/dist/index.tab" --output node_index.tab > /dev/null 2>&1

while IFS=$'\t' read -r -a row; do
node_index_version="${row[0]}"
echo $node_index_version >> "versions.txt"
node_index_major_version=$(echo $node_index_version | sed -E 's/^v([0-9]+).*$/\1/')
node_index_date="${row[1]}"
[[ "$node_index_version" = "version" ]] && continue # skip tsv header
Expand Down Expand Up @@ -93,42 +115,39 @@ node_shasum_url="https://nodejs.org/dist/${node_index_version}/SHASUMS256.txt"

echo "Node.js ${node_index_version} for ${operating_system}-${architecture} released on ${node_index_date}"

"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path" > /dev/null 2>&1
"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "${node_shasum_url}" --output "$node_shasum_path" > /dev/null 2>&1

# Remove extra entries from the SHASUMS256.txt file. Not every OS supports the --ignore-missing flag.
(
cd "$NODE_ARTIFACTS_PATH"
awk '{ if (system("[ -e \"" $2 "\" ]") == 0) print $0 }' SHASUMS256.txt > SHASUMS256.filtered.txt
sha256sum -c SHASUMS256.filtered.txt > /dev/null 2>&1 || sha256sum -c SHASUMS256.filtered.txt
)

if [[ "$file_extension" = "zip" ]]; then
if [[ -d "${NODE_ARTIFACTS_PATH}/nodejs/bin/${node_directory}" ]]; then
echo "Node.js already installed!"
else
"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path"
"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "${node_shasum_url}" --output "$node_shasum_path"
(cd "$NODE_ARTIFACTS_PATH" && sha256sum -c SHASUMS256.txt --ignore-missing)
unzip -q "$node_archive_path" -d "${NODE_ARTIFACTS_PATH}"
mkdir -p "${NODE_ARTIFACTS_PATH}/nodejs"
# Windows "bins" are at the top level
mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs/bin"
# Need to add executable flag ourselves
chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/node.exe"
chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/npm"
fi
chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/npx"
chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/npx.CMD"
else
if [[ -d "${NODE_ARTIFACTS_PATH}/nodejs/${node_directory}" ]]; then
echo "Node.js already installed!"
else
"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path"
"$SCRIPT_DIR/retry-with-backoff.sh" curl "${CURL_FLAGS[@]}" "${node_shasum_url}" --output "$node_shasum_path"
pushd $NODE_ARTIFACTS_PATH
sha256sum -c SHASUMS256.txt --ignore-missing
popd
tar -xf "$node_archive_path" -C "${NODE_ARTIFACTS_PATH}"
mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs"
fi
fi
echo "$NODE_LTS_VERSION" > $NODE_ARTIFACTS_PATH/node-version.txt
echo "Installing Node.js $NODE_LTS_VERSION... done."

if [[ $operating_system != "win" ]]; then
# Update npm to latest when we can
npm install --global npm@$NPM_VERSION
echo "Installing npm $NPM_VERSION..."
npm install --silent --global npm@$NPM_VERSION
hash -r
echo "Installing npm $NPM_VERSION... done."
fi

echo "npm location: $(which npm)"
echo "npm version: $(npm -v)"

popd
debug_output
54 changes: 47 additions & 7 deletions .evergreen/orchestration/drivers_orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@

import psutil

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from mongodb_runner import start_mongodb_runner

# Get global values.
HERE = Path(__file__).absolute().parent
EVG_PATH = HERE.parent
DRIVERS_TOOLS = EVG_PATH.parent
LOGGER = logging.getLogger(__name__)
LOGGER = logging.getLogger("drivers_orchestration")
logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(message)s")
PLATFORM = sys.platform.lower()
CRYPT_NAME_MAP = {
Expand Down Expand Up @@ -83,6 +86,11 @@ def get_options():
action="store_true",
help="Whether to use mongodb-atlas-local to start the server",
)
parser.add_argument(
"--mongodb-runner",
action="store_true",
help="Whether to use mongodb-runner to start the server",
)
parser.add_argument(
"--orchestration-file", help="The name of the orchestration config file"
)
Expand Down Expand Up @@ -231,6 +239,7 @@ def traverse(root):
item["ipv6"] = False
item["bind_ip"] = "0.0.0.0,::1"
item["dbpath"] = f"/tmp/mongo-{item['port']}"
os.makedirs(item["dbpath"], exist_ok=True)

if "routers" in data:
for router in data["routers"]:
Expand Down Expand Up @@ -386,6 +395,7 @@ def run(opts):
from mongosh_dl import main as mongosh_dl

LOGGER.info("Running orchestration...")
stop(opts)
clean_run(opts)

# NOTE: in general, we need to normalize paths to account for cygwin/Windows.
Expand Down Expand Up @@ -414,9 +424,9 @@ def run(opts):
args = f"{default_args} --version {version}"
args += " --strip-path-components 2 --component archive"
if not opts.existing_binaries_dir:
LOGGER.info(f"Downloading mongodb {version}...")
LOGGER.info(f"Downloading mongodb {version} to {mdb_binaries}...")
mongodl(shlex.split(args))
LOGGER.info(f"Downloading mongodb {version}... done.")
LOGGER.info(f"Downloading mongodb {version} to {mdb_binaries}... done.")
else:
LOGGER.info(
f"Using existing mongod binaries dir: {opts.existing_binaries_dir}"
Expand Down Expand Up @@ -470,11 +480,20 @@ def run(opts):
dl_end = datetime.now()
mo_start = datetime.now()

data = get_orchestration_data(opts)

if opts.mongodb_runner and version in ("3.6", "4.0"):
LOGGER.warning(
"mongodb-runner does not support MongoDB < 4.2, using mongo-orchestration"
)
opts.mongodb_runner = False

if opts.local_atlas:
uri = start_atlas(opts)
elif opts.mongodb_runner:
uri = start_mongodb_runner(opts, data)
else:
mo_home = Path(opts.mongo_orchestration_home)
data = get_orchestration_data(opts)

# Write the config file.
orch_file = Path(mo_home / "config.json")
Expand Down Expand Up @@ -645,7 +664,7 @@ def shutdown_proc(proc: psutil.Process) -> None:
try:
proc.terminate()
try:
proc.wait(10) # Wait up to 10 seconds.
proc.wait(2) # Wait up to 2 seconds.
except psutil.TimeoutExpired:
proc.kill()
except Exception as e:
Expand All @@ -663,6 +682,7 @@ def shutdown_docker(docker: str, container_id: str) -> None:
def stop(opts):
mo_home = Path(opts.mongo_orchestration_home)
pid_file = mo_home / "server.pid"
out_log = mo_home / "out.log"
container_file = mo_home / "container_id.txt"
docker = get_docker_cmd()

Expand All @@ -675,6 +695,26 @@ def stop(opts):
shutdown_proc(psutil.Process(pid))
LOGGER.info("Stopping mongo-orchestration using pid file... done.")

# Next try and use the output.log file as a serialized json file.
if out_log.exists():
try:
data = json.loads(out_log.read_text())
except Exception:
data = None
if data:
LOGGER.info("Stopping mongodb-runner cluster...")
all_servers = data["serialized"]["servers"]
for shard in data["serialized"].get("shards", []):
all_servers.extend(shard["servers"])
for server in all_servers:
pid = server["pid"]
if psutil.pid_exists(pid):
shutdown_proc(psutil.Process(pid))
if Path(server["dbPath"]).exists():
shutil.rmtree(server["dbPath"])
LOGGER.info("Stopping mongodb-runner cluster... done.")
out_log.unlink()

# Next try using a docker container file.
if docker is not None and container_file.exists():
LOGGER.info("Stopping mongodb_atlas_local using container file...")
Expand Down Expand Up @@ -708,7 +748,7 @@ def stop(opts):
response = subprocess.check_output(
shlex.split(cmd), encoding="utf-8"
).strip()
except subprocess.CalledProcessError as e:
except (subprocess.CalledProcessError, FileNotFoundError) as e:
LOGGER.exception(e)
response = ""
for line in response.splitlines():
Expand All @@ -724,7 +764,7 @@ def stop(opts):
name = proc.name()
except psutil.NoSuchProcess:
continue
if name in ["mongod", "mongos"]:
if name in ["mongod", "mongos", "mongod.exe", "mongos.exe"]:
LOGGER.info(f"Stopping {name} by process name...")
shutdown_proc(proc)
LOGGER.info(f"Stopping {name} by process name... done.")
Expand Down
Loading
Loading