Skip to content

Commit 2400b57

Browse files
authored
INTPYTHON-573 Use drivers-tools to run the local atlas server (#63)
1 parent b3addb7 commit 2400b57

File tree

3 files changed

+16
-54
lines changed

3 files changed

+16
-54
lines changed

.evergreen/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@ functions:
7575
args: [.evergreen/setup-remote.sh]
7676

7777
pre_error_fails_task: true
78+
post_error_fails_task: true
7879
pre:
7980
- func: "fetch source"
8081
- func: "fetch secrets"
82+
post:
83+
- command: subprocess.exec
84+
type: setup
85+
params:
86+
working_dir: "src"
87+
binary: bash
88+
args: [drivers-evergreen-tools/.evergreen/teardown.sh]
8189

8290
tasks:
8391
- name: test-semantic-kernel-python-local

.evergreen/fetch-secrets.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -eu
44

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

88
# Get the secrets for drivers/ai-ml-pipeline-testing.
99
. drivers-evergreen-tools/.evergreen/secrets_handling/setup-secrets.sh drivers/ai-ml-pipeline-testing

.evergreen/utils.sh

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -52,64 +52,18 @@ is_python_310() {
5252
}
5353

5454

55-
retry() {
56-
for i in 1 2 4 8 16; do
57-
{ "$@" && return 0; } || sleep $i
58-
done
59-
return 1
60-
}
61-
6255

6356
# 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)
6457
# stores the connection string in .local_atlas_uri file
6558
setup_local_atlas() {
66-
echo "Starting the container"
67-
68-
IMAGE=mongodb/mongodb-atlas-local:latest
69-
retry podman pull $IMAGE
70-
71-
podman kill mongodb_atlas_local || true
72-
73-
CONTAINER_ID=$(podman run --rm -d -e DO_NOT_TRACK=1 -P --health-cmd "/usr/local/bin/runner healthcheck" $IMAGE)
74-
podman rename $CONTAINER_ID mongodb_atlas_local || true
75-
76-
echo "waiting for container to become healthy..."
77-
function wait() {
78-
CONTAINER_ID=$1
79-
80-
echo "waiting for container to become healthy..."
81-
podman healthcheck run "$CONTAINER_ID"
82-
for _ in $(seq 600); do
83-
STATE=$(podman inspect -f '{{ .State.Health.Status }}' "$CONTAINER_ID")
84-
85-
case $STATE in
86-
healthy)
87-
echo "container is healthy"
88-
return 0
89-
;;
90-
unhealthy)
91-
echo "container is unhealthy"
92-
podman logs "$CONTAINER_ID"
93-
stop
94-
exit 1
95-
;;
96-
*)
97-
echo "Unrecognized state $STATE"
98-
sleep 1
99-
esac
100-
done
101-
102-
echo "container did not get healthy within 120 seconds, quitting"
103-
podman logs mongodb_atlas_local
104-
stop
105-
exit 2
106-
}
107-
108-
wait "$CONTAINER_ID"
109-
EXPOSED_PORT=$(podman inspect --format='{{ (index (index .NetworkSettings.Ports "27017/tcp") 0).HostPort }}' "$CONTAINER_ID")
110-
export CONN_STRING="mongodb://127.0.0.1:$EXPOSED_PORT/?directConnection=true"
11159
SCRIPT_DIR=$(realpath "$(dirname ${BASH_SOURCE[0]})")
112-
echo "CONN_STRING=mongodb://127.0.0.1:$EXPOSED_PORT/?directConnection=true" > $SCRIPT_DIR/.local_atlas_uri
60+
# Ensure drivers-evergeen-tools checkout.
61+
pushd $SCRIPT_DIR/..
62+
git clone https://github.com/mongodb-labs/drivers-evergreen-tools || true
63+
. drivers-evergreen-tools/.evergreen/run-orchestration.sh --local-atlas -v
64+
popd
65+
export CONN_STRING"=mongodb://127.0.0.1:27017/?directConnection=true"
66+
echo "CONN_STRING=$CONN_STRING" > $SCRIPT_DIR/.local_atlas_uri
11367
}
11468

11569
fetch_local_atlas_uri() {

0 commit comments

Comments
 (0)