File tree Expand file tree Collapse file tree 6 files changed +41
-11
lines changed
libs/mongodb/tests/integration_tests Expand file tree Collapse file tree 6 files changed +41
-11
lines changed Original file line number Diff line number Diff line change @@ -165,9 +165,14 @@ jobs:
165165 run : make tests
166166 working-directory : ${{ inputs.working-directory }}
167167
168+ - name : Start local Atlas
169+ run : bash scripts/start_local_atlas.sh
170+
171+ - name : Get MongoDB URI
172+ run : cat .local_atlas_uri >> $GITHUB_ENV
173+
168174 - name : Run integration tests
169175 env :
170- MONGODB_URI : ${{ secrets.MONGODB_ATLAS_URI }}
171176 OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
172177 run : make integration_tests
173178 working-directory : ${{ inputs.working-directory }}
Original file line number Diff line number Diff line change @@ -47,17 +47,18 @@ jobs:
4747 run : |
4848 make test
4949
50+ - name : Start local Atlas
51+ working-directory : .
52+ run : bash scripts/start_local_atlas.sh
53+
54+ - name : Get MongoDB URI
55+ working-directory : .
56+ run : cat .local_atlas_uri >> $GITHUB_ENV
57+
5058 - name : Run integration tests
5159 env :
52- MONGODB_URI : ${{ secrets.MONGODB_ATLAS_URI }}
5360 OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
54- run : |
55- if [[ "${{ github.event_name }}" == "push" ]]; then
56- # Only run on the min python version.
57- if [[ "${{ matrix.python-version }}" == "3.9" ]]; then
58- make integration_tests
59- fi
60- fi
61+ run : make integration_tests
6162 working-directory : ${{ inputs.working-directory }}
6263
6364 - name : Ensure the tests did not create any additional files
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ __pycache__
55.mypy_cache_test
66.env
77.venv *
8+ .local_atlas_uri
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def collection() -> Collection:
5151
5252
5353@pytest .mark .skipif (
54- "OPENAI_API_KEY" not in os . environ , reason = "Requires OpenAI for chat responses."
54+ os . environ . get ( "OPENAI_API_KEY" ) is not None , reason = "Requires OpenAI for chat responses."
5555)
5656def test_chain (
5757 collection : Collection ,
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ def embedding_openai() -> Embeddings:
5555 model = "text-embedding-3-small" ,
5656 )
5757 except Exception :
58- pytest .fail ("test_retrievers expects OPENAI_API_KEY in os.environ" )
58+ pytest .skip ("test_retrievers expects OPENAI_API_KEY in os.environ" )
5959
6060
6161@pytest .fixture (scope = "module" )
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -eu
3+
4+ echo " Starting the container"
5+
6+ IMAGE=mongodb/mongodb-atlas-local:latest
7+ podman pull $IMAGE
8+
9+ CONTAINER_ID=$( podman run --rm -d -e DO_NOT_TRACK=1 --name mongodb_atlas_local -P $IMAGE )
10+
11+ function wait() {
12+ CONTAINER_ID=$1
13+ echo " waiting for container to become healthy..."
14+ podman logs mongodb_atlas_local
15+ }
16+
17+ wait " $CONTAINER_ID "
18+
19+ EXPOSED_PORT=$( podman inspect --format=' {{ (index (index .NetworkSettings.Ports "27017/tcp") 0).HostPort }}' " $CONTAINER_ID " )
20+ export CONN_STRING=" mongodb://127.0.0.1:$EXPOSED_PORT /?directConnection=true"
21+ SCRIPT_DIR=$( realpath " $( dirname ${BASH_SOURCE[0]} ) " )
22+ ROOT_DIR=$( dirname $SCRIPT_DIR )
23+ echo " MONGODB_URI=mongodb://127.0.0.1:$EXPOSED_PORT /?directConnection=true" > $ROOT_DIR /.local_atlas_uri
You can’t perform that action at this time.
0 commit comments