Skip to content

Commit 50d13ab

Browse files
blink1073Jibola
andauthored
DRIVERS-3032 Add Python CLI for drivers-evergreen-tools orchestration (#578)
Co-authored-by: Jib <[email protected]>
1 parent 6a0686e commit 50d13ab

19 files changed

+564
-356
lines changed

.evergreen/auth_oidc/azure/remote-scripts/start-mongodb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export TOPOLOGY=server
1111
export ORCHESTRATION_FILE=auth-oidc.json
1212
export DRIVERS_TOOLS=$HOME/drivers-evergreen-tools
1313
export PROJECT_ORCHESTRATION_HOME=$DRIVERS_TOOLS/.evergreen/orchestration
14-
export MONGO_ORCHESTRATION_HOME=$HOME
14+
export MONGO_ORCHESTRATION_HOME=$PROJECT_ORCHESTRATION_HOME
1515
export SKIP_LEGACY_SHELL=true
1616
export NO_IPV6=${NO_IPV6:-""}
1717

.evergreen/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ functions:
295295
MONGODB_VERSION: ${VERSION}
296296
TOPOLOGY: ${TOPOLOGY}
297297
SSL: ${SSL}
298+
AUTH: ${AUTH}
298299
STORAGE_ENGINE: ${STORAGE_ENGINE}
299300
LOAD_BALANCER: ${LOAD_BALANCER}
300301
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}

.evergreen/docker/overwrite_orchestration.py

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

.evergreen/docker/rhel8/base-entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env bash
22
set -eu
33

4+
# Remove the virtual env.
5+
rm -rf $DRIVERS_TOOLS/.evergreen/venv || true
6+
47
# Start the server.
58
cd $DRIVERS_TOOLS
69
make run-server

.evergreen/docker/run-server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ test -t 1 && ARGS+=" -t"
7676

7777
# Launch server container.
7878
$DOCKER run $ARGS $NAME $ENTRYPOINT
79+
80+
# Restore the clis
81+
bash $DRIVERS_TOOLS/.evergreen/orchestration/setup.sh

.evergreen/docker/ubuntu20.04/base-entrypoint.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
2-
set -eu
2+
set -eux
3+
4+
# Remove the virtual env.
5+
rm -rf $DRIVERS_TOOLS/.evergreen/venv || true
36

47
# Start the server.
58
cd $DRIVERS_TOOLS

.evergreen/download-mongodb.sh

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,16 @@
11
#!/usr/bin/env bash
22
# shellcheck shell=sh
33

4-
# For future use the feed to get full list of distros : http://downloads.mongodb.org/full.json
5-
4+
# This file is no longer used directly by drivers-evergreen-tools.
5+
# If using this file to download mongodb binaries, you should consider instead using `mongodl.py` and `mongosh-dl.py`.
6+
# If using this file for get_distro, use `get-distro.sh`.
67
set -o errexit # Exit the script with error if any of the commands fail
78

89
get_distro ()
910
{
10-
if [ -f /etc/os-release ]; then
11-
. /etc/os-release
12-
DISTRO="${ID}-${VERSION_ID}"
13-
elif [ -f /etc/centos-release ]; then
14-
version=$(cat /etc/centos-release | tr -dc '0-9.' | cut -d '.' -f1)
15-
DISTRO="centos-${version}"
16-
elif command -v lsb_release >/dev/null 2>&1; then
17-
name=$(lsb_release -s -i)
18-
if [ "$name" = "RedHatEnterpriseServer" ]; then # RHEL 6.2 at least
19-
name="rhel"
20-
fi
21-
version=$(lsb_release -s -r)
22-
DISTRO="${name}-${version}"
23-
elif [ -f /etc/redhat-release ]; then
24-
release=$(cat /etc/redhat-release)
25-
case $release in
26-
*Red\ Hat*)
27-
name="rhel"
28-
;;
29-
Fedora*)
30-
name="fedora"
31-
;;
32-
esac
33-
version=$(echo $release | sed 's/.*\([[:digit:]]\).*/\1/g')
34-
DISTRO="${name}-${version}"
35-
elif [ -f /etc/lsb-release ]; then
36-
. /etc/lsb-release
37-
DISTRO="${DISTRIB_ID}-${DISTRIB_RELEASE}"
38-
elif grep -R "Amazon Linux" "/etc/system-release" >/dev/null 2>&1; then
39-
DISTRO="amzn64"
40-
fi
41-
42-
OS_NAME=$(uname -s)
43-
MARCH=$(uname -m)
44-
DISTRO=$(echo "$OS_NAME-$DISTRO-$MARCH" | tr '[:upper:]' '[:lower:]')
45-
46-
echo $DISTRO
11+
# shellcheck disable=SC3028
12+
_script_dir="$(dirname ${BASH_SOURCE:-$0})"
13+
. ${_script_dir}/get-distro.sh
4714
}
4815

4916
# get_mongodb_download_url_for "linux-distro-version-architecture" "latest|44|42|40|36|34|32|30|28|26|24" "true|false"

.evergreen/get-distro.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
get_distro ()
4+
{
5+
if [ -f /etc/os-release ]; then
6+
. /etc/os-release
7+
DISTRO="${ID}-${VERSION_ID}"
8+
elif [ -f /etc/centos-release ]; then
9+
version=$(cat /etc/centos-release | tr -dc '0-9.' | cut -d '.' -f1)
10+
DISTRO="centos-${version}"
11+
elif command -v lsb_release >/dev/null 2>&1; then
12+
name=$(lsb_release -s -i)
13+
if [ "$name" = "RedHatEnterpriseServer" ]; then # RHEL 6.2 at least
14+
name="rhel"
15+
fi
16+
version=$(lsb_release -s -r)
17+
DISTRO="${name}-${version}"
18+
elif [ -f /etc/redhat-release ]; then
19+
release=$(cat /etc/redhat-release)
20+
case $release in
21+
*Red\ Hat*)
22+
name="rhel"
23+
;;
24+
Fedora*)
25+
name="fedora"
26+
;;
27+
esac
28+
version=$(echo $release | sed 's/.*\([[:digit:]]\).*/\1/g')
29+
DISTRO="${name}-${version}"
30+
elif [ -f /etc/lsb-release ]; then
31+
. /etc/lsb-release
32+
DISTRO="${DISTRIB_ID}-${DISTRIB_RELEASE}"
33+
elif grep -R "Amazon Linux" "/etc/system-release" >/dev/null 2>&1; then
34+
DISTRO="amzn64"
35+
fi
36+
37+
OS_NAME=$(uname -s)
38+
MARCH=$(uname -m)
39+
DISTRO=$(echo "$OS_NAME-$DISTRO-$MARCH" | tr '[:upper:]' '[:lower:]')
40+
41+
echo $DISTRO
42+
}
43+
44+
get_distro

.evergreen/install-cli.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ fi
1515
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
1616
. $SCRIPT_DIR/handle-paths.sh
1717

18-
pushd $SCRIPT_DIR
18+
pushd $SCRIPT_DIR > /dev/null
1919

2020
# Ensure pipx is writing assets to a contained location.
2121
export UV_CACHE_DIR=${DRIVERS_TOOLS}/.local/uv-cache
2222
export UV_TOOL_DIR=${DRIVERS_TOOLS}/.local/uv-tool
2323

24+
if [ "${DOCKER_RUNNING:-}" == "true" ]; then
25+
_root_dir=$(mktemp -d)
26+
UV_CACHE_DIR=$_root_dir/uv-cache
27+
UV_TOOL_DIR=$_root_dir/uv-tool
28+
fi
29+
2430
. ./venv-utils.sh
2531

2632
if [ ! -d $SCRIPT_DIR/venv ]; then
@@ -34,13 +40,12 @@ if [ ! -d $SCRIPT_DIR/venv ]; then
3440
echo "Creating virtual environment 'venv'..."
3541
venvcreate "${PYTHON:?}" venv
3642
echo "Creating virtual environment 'venv'... done."
37-
38-
python -m pip install uv
43+
python -m pip install -q uv
3944
else
4045
venvactivate venv
4146
fi
4247

43-
pushd $1
48+
pushd $1 > /dev/null
4449

4550
# On Windows, we have to do a bit of path manipulation.
4651
if [ "Windows_NT" == "${OS:-}" ]; then
@@ -53,8 +58,8 @@ if [ "Windows_NT" == "${OS:-}" ]; then
5358
done
5459
rm -rf $TMP_DIR
5560
else
56-
UV_TOOL_BIN_DIR=$(pwd) uv tool install --python "$(which python)" --force --editable .
61+
UV_TOOL_BIN_DIR=$(pwd) uv tool install -q --python "$(which python)" --force --editable .
5762
fi
5863

59-
popd
60-
popd
64+
popd > /dev/null
65+
popd > /dev/null

.evergreen/mongosh_dl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _get_latest_version_git():
6161
shlex.split(cmd), cwd=path, stderr=subprocess.PIPE
6262
)
6363
for line in reversed(output.decode("utf-8").splitlines()):
64-
if re.match("^v\d+\.\d+\.\d+$", line):
64+
if re.match(r"^v\d+\.\d+\.\d+$", line):
6565
LOGGER.debug("Found version %s", line)
6666
return line.replace("v", "").strip()
6767

0 commit comments

Comments
 (0)