diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 30c6700..8654b16 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -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 diff --git a/.evergreen/fetch-secrets.sh b/.evergreen/fetch-secrets.sh index 808e506..2ca2980 100644 --- a/.evergreen/fetch-secrets.sh +++ b/.evergreen/fetch-secrets.sh @@ -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 diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index f163066..d72e673 100644 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -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() {