-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): Setup Search Index e2e tests with local atlas COMPASS-7255 (…
…#5954) * chore(ci): Setup Search Index e2e tests with local atlas COMPASS-7255 * unskip search index tests * don't throw on exit * skip when no docker, setup on packaged app * only run for e2e-coverage * fix regular indexes test * fix connection name --------- Co-authored-by: Basit Chonka <[email protected]> Co-authored-by: Basit <[email protected]>
- Loading branch information
1 parent
0ff925d
commit a6a5440
Showing
3 changed files
with
94 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# Check if ATLAS_LOCAL_VERSION is set | ||
if [ -z "$ATLAS_LOCAL_VERSION" ]; then | ||
echo "ATLAS_LOCAL_VERSION is not set. Skipping script." | ||
return | ||
fi | ||
|
||
# Container name | ||
CONTAINER_NAME=compass-e2e-tests-atlas-local | ||
|
||
docker rm -f $CONTAINER_NAME || true | ||
|
||
cleanup() { | ||
echo "Stopping and removing container..." | ||
docker stop $CONTAINER_NAME || true | ||
docker rm -f $CONTAINER_NAME || true | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
# Image name with version | ||
IMAGE_NAME="mongodb/mongodb-atlas-local:$ATLAS_LOCAL_VERSION" | ||
echo docker run --rm --name $CONTAINER_NAME -d -e DO_NOT_TRACK=1 -P "$IMAGE_NAME" | ||
|
||
# Start the Docker container | ||
docker run --rm --name $CONTAINER_NAME -d -e DO_NOT_TRACK=1 -P "$IMAGE_NAME" | ||
|
||
echo "Waiting for container to become healthy..." | ||
|
||
STATUS="" | ||
CONSECUTIVE_FAILED_ATTEMPTS=0 | ||
MAX_CONSECUTIVE_FAILED_ATTEMPTS=20 | ||
|
||
while true; do | ||
INSPECT_OUTPUT=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_NAME 2>&1) | ||
if [[ $? -ne 0 ]]; then | ||
echo "Inspect Failed: ${INSPECT_OUTPUT}" | ||
STATUS="failed" | ||
else | ||
STATUS="$INSPECT_OUTPUT" | ||
fi | ||
|
||
echo "Status: $STATUS" | ||
|
||
if [[ "$STATUS" != "starting" && "$STATUS" != "failed" ]]; then | ||
break | ||
fi | ||
|
||
if [[ "$STATUS" == "failed" ]]; then | ||
CONSECUTIVE_FAILED_ATTEMPTS=$((CONSECUTIVE_FAILED_ATTEMPTS + 1)) | ||
else | ||
CONSECUTIVE_FAILED_ATTEMPTS=0 | ||
fi | ||
|
||
if [[ $CONSECUTIVE_FAILED_ATTEMPTS -ge $MAX_CONSECUTIVE_FAILED_ATTEMPTS ]]; then | ||
echo "Maximum number of consecutive failed attempts reached. Exiting." | ||
exit 1 | ||
fi | ||
|
||
sleep 2 | ||
done | ||
|
||
if [[ "$STATUS" != "healthy" ]]; then | ||
echo "Atlas Local is not healthy, exiting." | ||
exit 1 | ||
fi | ||
|
||
EXPOSED_PORT=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "27017/tcp") 0).HostPort }}' $CONTAINER_NAME) | ||
|
||
export ATLAS_LOCAL_URL="mongodb://127.0.0.1:$EXPOSED_PORT/test?directConnection=true" | ||
echo "ATLAS_LOCAL_URL set to $ATLAS_LOCAL_URL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters