diff --git a/.evergreen/execute-tests.sh b/.evergreen/execute-tests.sh index 789370a..f55db50 100644 --- a/.evergreen/execute-tests.sh +++ b/.evergreen/execute-tests.sh @@ -13,13 +13,13 @@ set +a cd ${REPO_NAME} -MAX_ATTEMPTS=3 +MAX_ATTEMPTS=${MAX_ATTEMPTS:-3} ATTEMPT=1 EXIT_CODE=0 set +e while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do - bash ${ROOT_DIR}/${DIR}/run.sh + bash ${ROOT_DIR}/${DIR}/run.sh "$@" EXIT_CODE=$? @@ -27,7 +27,7 @@ while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do break else echo "Tests failed on attempt $ATTEMPT of $MAX_ATTEMPTS..." - ((ATTEMPT++)) + ATTEMPT=$((ATTEMPT+1)) fi done diff --git a/.evergreen/provision-atlas.sh b/.evergreen/provision-atlas.sh index ad3598f..d758dfb 100644 --- a/.evergreen/provision-atlas.sh +++ b/.evergreen/provision-atlas.sh @@ -17,6 +17,7 @@ scaffold_atlas source secrets-export.sh # Create the env file +echo "export DIR=$DIR" > env.sh echo "export VOYAGEAI_S3_BUCKET=$VOYAGEAI_S3_BUCKET" >> env.sh echo "export AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT" >> env.sh echo "export AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY" >> env.sh diff --git a/.evergreen/setup-remote.sh b/.evergreen/setup-remote.sh index 408aa45..c0796a7 100644 --- a/.evergreen/setup-remote.sh +++ b/.evergreen/setup-remote.sh @@ -61,6 +61,7 @@ esac export MONGODB_URI # Create the env file +echo "export DIR=$DIR" > env.sh echo "export VOYAGEAI_S3_BUCKET=$VOYAGEAI_S3_BUCKET" >> env.sh echo "export AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT" >> env.sh echo "export AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY" >> env.sh diff --git a/.gitignore b/.gitignore index 972b725..1df4163 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ xunit-results/ drivers-evergreen-tools atlas .evergreen/.local_atlas_uri +mo-expansion.* pwfile # Secrets diff --git a/README.md b/README.md index 2612144..a187e58 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ CONN_STRING=$(fetch_local_atlas_uri) Stores the local Atlas URI within the `CONN_STRING` var. The script can then pass `CONN_STRING` as an environment variable to the test suite. -#### Running tests locally. +#### Running tests locally We can run the tests with a local checkout of the repo. @@ -86,6 +86,18 @@ bash .evergreen/execute-tests.sh Use `.evergreen/setup-remote.sh` instead of `.evergreen/provision-atlas.sh` to test against the remote cluster. Set `COMMUNITY_WITH_SEARCH=1` to test against MongoDB Community with Search edition. +We can also run locally using `just` (`brew install just`): + +```bash +just setup docarray # local atlas +just test +``` + +```bash +just setup-remote n8n-js # remote atlas +just test +``` + #### Pre-populating the Local Atlas Deployment You can pre-populate a test's local Atlas deployment before running the `run.sh` script by providing JSON files in the optional `database` directory of the created subdirectory. The `.evergreen/scaffold_atlas.py` file will search for every JSON file within this database directory and upload the documents to the database provided by the `DATABASE` expansion provided in the build variant of the `.evergreen/config.yml` setup. The collection the script uploads to is based on the name of your JSON file: diff --git a/justfile b/justfile new file mode 100644 index 0000000..e8db1bd --- /dev/null +++ b/justfile @@ -0,0 +1,23 @@ +# See https://just.systems/man/en/ for instructions +set shell := ["bash", "-c"] +set dotenv-filename := "env.sh" + +# Make the default recipe private so it doesn't show up in the list. +[private] +default: + @just --list + +_base dir: + DIR={{dir}} bash .evergreen/fetch-secrets.sh + DIR={{dir}} bash .evergreen/fetch-repo.sh + +setup dir: + just _base {{dir}} + DIR={{dir}} bash .evergreen/provision-atlas.sh + +setup-remote dir: + just _base {{dir}} + DIR={{dir}} bash .evergreen/setup-remote.sh + +test *args="": + MAX_ATTEMPTS=1 bash .evergreen/execute-tests.sh {{args}}