Skip to content

INTPYTHON-573 Use drivers-tools to run the local atlas server #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,17 @@ functions:
args: [.evergreen/setup-remote.sh]

pre_error_fails_task: true
post_error_fails_task: true
pre:
- func: "fetch source"
- func: "fetch secrets"
post:
- command: subprocess.exec
type: setup
params:
working_dir: "src"
binary: bash
args: [drivers-evergreen-tools/.evergreen/teardown.sh]

tasks:
- name: test-semantic-kernel-python-local
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/fetch-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eu

# Clone drivers-evergeen-tools.
git clone https://github.com/mongodb-labs/drivers-evergreen-tools || true
git clone https://github.com/mongodb-labs/drivers-evergreen-tools

# Get the secrets for drivers/ai-ml-pipeline-testing.
. drivers-evergreen-tools/.evergreen/secrets_handling/setup-secrets.sh drivers/ai-ml-pipeline-testing
60 changes: 7 additions & 53 deletions .evergreen/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,64 +52,18 @@ is_python_310() {
}


retry() {
for i in 1 2 4 8 16; do
{ "$@" && return 0; } || sleep $i
done
return 1
}


# start mongodb-atlas-local container, because of a bug in podman we have to define the healtcheck ourselves (is the same as in the image)
# stores the connection string in .local_atlas_uri file
setup_local_atlas() {
echo "Starting the container"

IMAGE=mongodb/mongodb-atlas-local:latest
retry podman pull $IMAGE

podman kill mongodb_atlas_local || true

CONTAINER_ID=$(podman run --rm -d -e DO_NOT_TRACK=1 -P --health-cmd "/usr/local/bin/runner healthcheck" $IMAGE)
podman rename $CONTAINER_ID mongodb_atlas_local || true

echo "waiting for container to become healthy..."
function wait() {
CONTAINER_ID=$1

echo "waiting for container to become healthy..."
podman healthcheck run "$CONTAINER_ID"
for _ in $(seq 600); do
STATE=$(podman inspect -f '{{ .State.Health.Status }}' "$CONTAINER_ID")

case $STATE in
healthy)
echo "container is healthy"
return 0
;;
unhealthy)
echo "container is unhealthy"
podman logs "$CONTAINER_ID"
stop
exit 1
;;
*)
echo "Unrecognized state $STATE"
sleep 1
esac
done

echo "container did not get healthy within 120 seconds, quitting"
podman logs mongodb_atlas_local
stop
exit 2
}

wait "$CONTAINER_ID"
EXPOSED_PORT=$(podman inspect --format='{{ (index (index .NetworkSettings.Ports "27017/tcp") 0).HostPort }}' "$CONTAINER_ID")
export CONN_STRING="mongodb://127.0.0.1:$EXPOSED_PORT/?directConnection=true"
SCRIPT_DIR=$(realpath "$(dirname ${BASH_SOURCE[0]})")
echo "CONN_STRING=mongodb://127.0.0.1:$EXPOSED_PORT/?directConnection=true" > $SCRIPT_DIR/.local_atlas_uri
# Ensure drivers-evergeen-tools checkout.
pushd $SCRIPT_DIR/..
git clone https://github.com/mongodb-labs/drivers-evergreen-tools || true
. drivers-evergreen-tools/.evergreen/run-orchestration.sh --local-atlas -v
popd
export CONN_STRING"=mongodb://127.0.0.1:27017/?directConnection=true"
echo "CONN_STRING=$CONN_STRING" > $SCRIPT_DIR/.local_atlas_uri
}

fetch_local_atlas_uri() {
Expand Down