Skip to content

Commit

Permalink
Revert "Usability improvements" (mongodb-labs#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Aug 26, 2024
1 parent d495e58 commit f2384ff
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 82 deletions.
4 changes: 3 additions & 1 deletion .evergreen/atlas/atlas-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ check_deployment ()
ATLAS_BASE_URL=${ATLAS_BASE_URL:-"https://account-dev.mongodb.com/api/atlas/v1.0"}
TYPE=${DEPLOYMENT_TYPE:-"clusters"}

PYTHON=$(ensure_python3)
echo "Finding Python3 binary..." 1>&2
PYTHON="$(find_python3 2>/dev/null)"
echo "Finding Python3 binary... done." 1>&2

# Don't try longer than 20 minutes.
echo "" 1>&2
Expand Down
5 changes: 4 additions & 1 deletion .evergreen/auth_aws/activate-authawsvenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ activate_authawsvenv() {
else
# shellcheck source=.evergreen/find-python3.sh
. ../find-python3.sh || return
PYTHON=$(ensure_python3)

echo "Finding Python3 binary..."
PYTHON="$(find_python3 2>/dev/null)" || return
echo "Finding Python3 binary... done."

echo "Creating virtual environment 'authawsvenv'..."
venvcreate "${PYTHON:?}" authawsvenv || return
Expand Down
5 changes: 4 additions & 1 deletion .evergreen/auth_oidc/activate-authoidcvenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ activate_authoidcvenv() {
else
# shellcheck source=.evergreen/find-python3.sh
. ../find-python3.sh || return
PYTHON=$(ensure_python3)

echo "Finding Python3 binary..."
PYTHON="$(find_python3 2>/dev/null)" || return
echo "Finding Python3 binary... done."

echo "Creating virtual environment 'authoidcvenv'..."
venvcreate "${PYTHON:?}" authoidcvenv || return
Expand Down
5 changes: 4 additions & 1 deletion .evergreen/csfle/activate-kmstlsvenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ activate_kmstlsvenv() {
else
# shellcheck source=.evergreen/find-python3.sh
. ../find-python3.sh || return
PYTHON=$(ensure_python3)

echo "Finding Python3 binary..."
PYTHON="$(find_python3 2>/dev/null)" || return
echo "Finding Python3 binary... done."

echo "Creating virtual environment 'kmstlsvenv'..."
venvcreate "${PYTHON:?}" kmstlsvenv || return
Expand Down
1 change: 1 addition & 0 deletions .evergreen/docker/ubuntu18.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ARG GROUP_ID
ENV DRIVERS_TOOLS=/root/drivers-evergreen-tools
ENV PROJECT_ORCHESTRATION_HOME=/root/drivers-evergreen-tools/.evergreen/orchestration
ENV MONGODB_BINARIES=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu18.04/mongodb/bin
ENV MONGODB_BINARY_ROOT=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu18.04/
ENV MONGO_ORCHESTRATION_HOME=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu18.04/orchestration
ENV DOCKER_RUNNING=true

Expand Down
1 change: 1 addition & 0 deletions .evergreen/docker/ubuntu20.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ARG GROUP_ID
ENV DRIVERS_TOOLS=/root/drivers-evergreen-tools
ENV PROJECT_ORCHESTRATION_HOME=/root/drivers-evergreen-tools/.evergreen/orchestration
ENV MONGODB_BINARIES=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu20.04/mongodb/bin
ENV MONGODB_BINARY_ROOT=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu20.04/
ENV MONGO_ORCHESTRATION_HOME=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu20.04/orchestration
ENV DOCKER_RUNNING=true

Expand Down
22 changes: 15 additions & 7 deletions .evergreen/download-mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,13 @@ download_and_extract_package ()
MONGODB_DOWNLOAD_URL=$1
EXTRACT=$2

pushd $(dirname $(dirname ${MONGODB_BINARIES}))
rm -rf mongodb

if [ -n "$MONGODB_BINARY_ROOT" ]; then
cd $MONGODB_BINARY_ROOT
else
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
. $SCRIPT_DIR/handle-paths.sh
cd $DRIVERS_TOOLS
fi
echo "Installing server binaries..."
curl_retry $MONGODB_DOWNLOAD_URL --output mongodb-binaries.tgz

Expand All @@ -713,7 +717,7 @@ download_and_extract_package ()
chmod -R +x mongodb
find . -name vcredist_x64.exe -exec {} /install /quiet \;
echo "MongoDB server version: $(./mongodb/bin/mongod --version)"
popd
cd -
}

download_and_extract_mongosh ()
Expand All @@ -725,9 +729,13 @@ download_and_extract_mongosh ()
get_mongodb_download_url_for $(get_distro) latest false
fi

pushd $(dirname $(dirname ${MONGODB_BINARIES}))
rm -rf mongosh

if [ -n "$MONGODB_BINARY_ROOT" ]; then
cd $MONGODB_BINARY_ROOT
else
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
. $SCRIPT_DIR/handle-paths.sh
cd $DRIVERS_TOOLS
fi
echo "Installing MongoDB shell..."
curl_retry $MONGOSH_DOWNLOAD_URL --output mongosh.tgz
$EXTRACT_MONGOSH mongosh.tgz
Expand Down
27 changes: 0 additions & 27 deletions .evergreen/find-python3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -291,30 +291,3 @@ find_python3() (

return 0
)

#
# Usage:
# ensure_python3
# PYTHON_BINARY=$(ensure_python3)
# PYTHON_BINARY=$(ensure_python3 2>/dev/null)
#
# If successful, print the name of the binary stdout (pipe 1).
# Otherwise, no output is printed to stdout (pipe 1).
#
# Diagnostic messages may be printed to stderr (pipe 2). Redirect to /dev/null
# with `2>/dev/null` to silence these messages.
#
# If PYTHON or PYTHON_BINARY are set, it will return that value. Otherwise
# it will use find_python3 to return a suitable value.
#
ensure_python3() {
PYTHON=${PYTHON:-${PYTHON_BINARY:-""}}
if [ -z "${PYTHON}" ]; then
echo "Finding Python3 binary..." 1>&2
echo $(find_python3 2>/dev/null)
echo "Finding Python3 binary... done." 1>&2
else
echo "Using Python binary $PYTHON" 1>&2
echo $PYTHON
fi
}
4 changes: 0 additions & 4 deletions .evergreen/handle-paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ else
fi
if [[ "$(uname -s)" == CYGWIN* ]]; then
SCRIPT_DIR=$(cygpath -m $SCRIPT_DIR)
# USERPROFILE is required by Python for Pathlib.Path().expanduser().
if [ -z "${USERPROFILE:-}" ]; then
export USERPROFILE=$(cygpath -m $HOME)
fi
fi

# Find the DRIVERS_TOOLS by walking up the folder tree until there
Expand Down
5 changes: 4 additions & 1 deletion .evergreen/ocsp/activate-ocspvenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ activate_ocspvenv() {
else
# shellcheck source=.evergreen/find-python3.sh
. ../find-python3.sh || return
PYTHON=$(ensure_python3)

echo "Finding Python3 binary..."
PYTHON="$(find_python3 2>/dev/null)" || return
echo "Finding Python3 binary... done."

echo "Creating virtual environment 'ocspvenv'..."
venvcreate "${PYTHON:?}" ocspvenv || return
Expand Down
10 changes: 5 additions & 5 deletions .evergreen/run-orchestration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ set -o errexit # Exit the script with error if any of the commands fail
# ORCHESTRATION_FILE Set to a non-empty string to use the <topology>/<orchestration_file>.json configuration.
# SKIP_CRYPT_SHARED Set to a non-empty string to skip downloading crypt_shared
# MONGODB_BINARIES Set to a non-empty string to set the path to the MONGODB_BINARIES for mongo orchestration.
# PYTHON Set to a non-empty string to set the Python binary to use.
# INSTALL_LEGACY_SHELL Set to a non-empty string to install the legacy mongo shell.

# See https://stackoverflow.com/questions/35006457/choosing-between-0-and-bash-source/35006505#35006505
Expand All @@ -32,18 +31,19 @@ DISABLE_TEST_COMMANDS=${DISABLE_TEST_COMMANDS}
MONGODB_VERSION=${MONGODB_VERSION:-latest}
MONGODB_DOWNLOAD_URL=${MONGODB_DOWNLOAD_URL}
ORCHESTRATION_FILE=${ORCHESTRATION_FILE}
MONGODB_BINARIES=${MONGODB_BINARIES:-}
INSTALL_LEGACY_SHELL=${INSTALL_LEGACY_SHELL:-}
PYTHON=${PYTHON:-}
# Note: MONGO_ORCHESTRATION_HOME and MONGODB_BINARIES defaults are handled in handle-paths.sh.

DL_START=$(date +%s)

# Functions to fetch MongoDB binaries.
. $SCRIPT_DIR/download-mongodb.sh

# To continue supporting `sh run-orchestration.sh` for backwards-compatibility,
# explicitly invoke Bash as a subshell here when running `ensure_python3`.
PYTHON=$(bash -c ". $SCRIPT_DIR/find-python3.sh && ensure_python3 2>/dev/null")
# explicitly invoke Bash as a subshell here when running `find_python3`.
echo "Finding Python3 binary..."
PYTHON="$(bash -c ". $SCRIPT_DIR/find-python3.sh && find_python3 2>/dev/null")"
echo "Finding Python3 binary... done."

# Set up the mongo orchestration config.
mkdir -p $MONGO_ORCHESTRATION_HOME
Expand Down
4 changes: 3 additions & 1 deletion .evergreen/serverless/create-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ if [ $SERVERLESS_URI = "null" ]; then
exit 1
fi

PYTHON=$(ensure_python3)
echo "Finding Python3 binary..." 1>&2
PYTHON="$(find_python3 2>/dev/null)"
echo "Finding Python3 binary... done." 1>&2

RESP=$(curl -sS \
--digest -u "${ATLAS_PUBLIC_API_KEY}:${ATLAS_PRIVATE_API_KEY}" \
Expand Down
11 changes: 9 additions & 2 deletions .evergreen/start-orchestration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ det_evergreen_dir=$SCRIPT_DIR

cd "$MONGO_ORCHESTRATION_HOME"

PYTHON=$(ensure_python3)
if [[ -z "${PYTHON:-}" ]]; then
echo "Finding Python3 binary..."
PYTHON="$(find_python3 2>/dev/null)"
echo "Finding Python3 binary... done."
else
# May have already been found by run-orchestration.sh. Avoid redundant lookup.
echo "Using Python3 binary: $PYTHON"
fi

echo "Creating virtual environment 'venv'..."
venvcreate "${PYTHON:?}" venv
Expand All @@ -37,7 +44,7 @@ echo "Creating virtual environment 'venv'... done."
# Install from github to get the latest mongo-orchestration.
python -m pip install -q --upgrade 'https://github.com/mongodb/mongo-orchestration/archive/master.tar.gz'
python -m pip list
cd $DRIVERS_TOOLS
cd -

# Create default config file if it doesn't exist
if [ ! -f $MONGO_ORCHESTRATION_HOME/orchestration.config ]; then
Expand Down
14 changes: 4 additions & 10 deletions .evergreen/stop-orchestration.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#!/usr/bin/env bash
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

cd ${DRIVERS_TOOLS}

cd "$MONGO_ORCHESTRATION_HOME"
# source the mongo-orchestration virtualenv if it exists
if [ -f venv/bin/activate ]; then
. $MONGO_ORCHESTRATION_HOME/venv/bin/activate
. venv/bin/activate
mongo-orchestration stop
elif [ -f venv/Scripts/activate ]; then
. $MONGO_ORCHESTRATION_HOME/venv/Scripts/activate
. venv/Scripts/activate
mongo-orchestration stop
else
echo "No virtualenv found!"
echo "No mongo orchestration to stop!"
fi

cd -
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ __pycache__/

# C extensions
*.so
*.dylib

# Distribution / packaging
.Python
Expand Down
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
all:
@echo "Project successfully compiled"

run-server:
bash .evergreen/run-orchestration.sh

stop-server:
bash .evergreen/stop-orchestration.sh

test:
@echo "Running tests..."
@echo "All done, thank you and please come again"
Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ returned from the `setup-mongodb` workflow step when running tests:
CRYPT_SHARED_LIB_PATH: ${{ steps.setup-mongodb.outputs.crypt-shared-lib-path }}
```

### Starting and Stopping Servers Locally or on an Evergreen Host

There are two options for running a MongoDB server configuration.
One is to use [docker](./.evergreen/docker/README.md).
The other is to run `./evergreen/run-orchestration.sh` locally.
For convenience, you can run `make run-server` and `make stop-server` to start and stop the server(s).
For example:

```bash
TOPOLOGY=replica_set MONGODB_VERSION=7.0 make run-server
```

See (run-orchestration.sh)[./evergreen/run-orchestration.sh] for the available environment variables.

## Linters and Formatters

This repo uses [pre-commit](https://pre-commit.com/) for managing linting and formatting of the codebase.
Expand Down

0 comments on commit f2384ff

Please sign in to comment.