From 1283d29d9c5b5c0668d74f0886d69dfd4a3c7d09 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 6 Dec 2024 08:31:04 -0600 Subject: [PATCH] INTPYTHON-445 Enable integration tests (#24) --- .github/workflows/_release.yml | 3 ++- .github/workflows/_test.yml | 8 ++++++++ libs/mongodb/tests/integration_tests/test_cache.py | 2 +- .../mongodb/tests/integration_tests/test_chain_example.py | 4 ++-- .../integration_tests/test_chat_message_histories.py | 2 +- libs/mongodb/tests/integration_tests/test_docstore.py | 2 +- libs/mongodb/tests/integration_tests/test_index.py | 2 +- libs/mongodb/tests/integration_tests/test_mmr.py | 2 +- .../tests/integration_tests/test_parent_document.py | 2 +- libs/mongodb/tests/integration_tests/test_retrievers.py | 2 +- .../integration_tests/test_vectorstore_add_delete.py | 2 +- .../integration_tests/test_vectorstore_from_documents.py | 2 +- .../integration_tests/test_vectorstore_from_texts.py | 2 +- 13 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml index a3e50d3..ee02baa 100644 --- a/.github/workflows/_release.yml +++ b/.github/workflows/_release.yml @@ -167,7 +167,8 @@ jobs: - name: Run integration tests env: - MONGODB_ATLAS_URI: ${{ secrets.MONGODB_ATLAS_URI }} + MONGODB_URI: ${{ secrets.MONGODB_ATLAS_URI }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: make integration_tests working-directory: ${{ inputs.working-directory }} diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index bc02880..7ae4c1d 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -46,6 +46,14 @@ jobs: run: | make test + - name: Run integration tests + env: + MONGODB_URI: ${{ secrets.MONGODB_ATLAS_URI }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + run: | + [[ "${{ github.repository_owner }}" == "langchain-ai" ]] && make integration_tests || true + working-directory: ${{ inputs.working-directory }} + - name: Ensure the tests did not create any additional files shell: bash run: | diff --git a/libs/mongodb/tests/integration_tests/test_cache.py b/libs/mongodb/tests/integration_tests/test_cache.py index c0fe736..62d4b00 100644 --- a/libs/mongodb/tests/integration_tests/test_cache.py +++ b/libs/mongodb/tests/integration_tests/test_cache.py @@ -13,7 +13,7 @@ from ..utils import ConsistentFakeEmbeddings, FakeChatModel, FakeLLM -CONN_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONN_STRING = os.environ.get("MONGODB_URI") INDEX_NAME = "langchain-test-index-semantic-cache" DATABASE = "langchain_test_db" COLLECTION = "langchain_test_cache" diff --git a/libs/mongodb/tests/integration_tests/test_chain_example.py b/libs/mongodb/tests/integration_tests/test_chain_example.py index e75664a..a67147b 100644 --- a/libs/mongodb/tests/integration_tests/test_chain_example.py +++ b/libs/mongodb/tests/integration_tests/test_chain_example.py @@ -16,7 +16,7 @@ from ..utils import PatchedMongoDBAtlasVectorSearch -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" COLLECTION_NAME = "langchain_test_chain_example" INDEX_NAME = "langchain-test-chain-example-vector-index" @@ -61,7 +61,7 @@ def test_chain( Follows example in the docs: https://python.langchain.com/docs/how_to/hybrid/ Requires OpenAI_API_KEY for embedding and chat model. - Requires INDEX_NAME to have been set up on MONGODB_ATLAS_URI + Requires INDEX_NAME to have been set up on MONGODB_URI """ from langchain_openai import ChatOpenAI, OpenAIEmbeddings diff --git a/libs/mongodb/tests/integration_tests/test_chat_message_histories.py b/libs/mongodb/tests/integration_tests/test_chat_message_histories.py index 5b0a7b4..0c6c929 100644 --- a/libs/mongodb/tests/integration_tests/test_chat_message_histories.py +++ b/libs/mongodb/tests/integration_tests/test_chat_message_histories.py @@ -10,7 +10,7 @@ COLLECTION = "langchain_test_chat" # Replace these with your mongodb connection string -connection_string = os.environ.get("MONGODB_ATLAS_URI", "") +connection_string = os.environ.get("MONGODB_URI", "") def test_memory_with_message_store() -> None: diff --git a/libs/mongodb/tests/integration_tests/test_docstore.py b/libs/mongodb/tests/integration_tests/test_docstore.py index 2cd95c8..e4cfd63 100644 --- a/libs/mongodb/tests/integration_tests/test_docstore.py +++ b/libs/mongodb/tests/integration_tests/test_docstore.py @@ -6,7 +6,7 @@ from langchain_mongodb.docstores import MongoDBDocStore -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" COLLECTION_NAME = "langchain_test_docstore" diff --git a/libs/mongodb/tests/integration_tests/test_index.py b/libs/mongodb/tests/integration_tests/test_index.py index fe4021c..d8a68d0 100644 --- a/libs/mongodb/tests/integration_tests/test_index.py +++ b/libs/mongodb/tests/integration_tests/test_index.py @@ -20,7 +20,7 @@ @pytest.fixture def collection() -> Generator: """Depending on uri, this could point to any type of cluster.""" - uri = os.environ.get("MONGODB_ATLAS_URI") + uri = os.environ.get("MONGODB_URI") client: MongoClient = MongoClient(uri) client[DB_NAME].create_collection(COLLECTION_NAME) clxn = client[DB_NAME][COLLECTION_NAME] diff --git a/libs/mongodb/tests/integration_tests/test_mmr.py b/libs/mongodb/tests/integration_tests/test_mmr.py index a2f011d..22934e5 100644 --- a/libs/mongodb/tests/integration_tests/test_mmr.py +++ b/libs/mongodb/tests/integration_tests/test_mmr.py @@ -11,7 +11,7 @@ from ..utils import ConsistentFakeEmbeddings, PatchedMongoDBAtlasVectorSearch -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" COLLECTION_NAME = "langchain_test_vectorstores" INDEX_NAME = "langchain-test-index-vectorstores" diff --git a/libs/mongodb/tests/integration_tests/test_parent_document.py b/libs/mongodb/tests/integration_tests/test_parent_document.py index 17f4fbd..444c06d 100644 --- a/libs/mongodb/tests/integration_tests/test_parent_document.py +++ b/libs/mongodb/tests/integration_tests/test_parent_document.py @@ -17,7 +17,7 @@ from ..utils import ConsistentFakeEmbeddings, PatchedMongoDBAtlasVectorSearch -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" COLLECTION_NAME = "langchain_test_parent_document_combined" VECTOR_INDEX_NAME = "langchain-test-parent-document-vector-index" diff --git a/libs/mongodb/tests/integration_tests/test_retrievers.py b/libs/mongodb/tests/integration_tests/test_retrievers.py index bf19351..f2510ae 100644 --- a/libs/mongodb/tests/integration_tests/test_retrievers.py +++ b/libs/mongodb/tests/integration_tests/test_retrievers.py @@ -20,7 +20,7 @@ from ..utils import PatchedMongoDBAtlasVectorSearch -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" COLLECTION_NAME = "langchain_test_retrievers" VECTOR_INDEX_NAME = "vector_index" diff --git a/libs/mongodb/tests/integration_tests/test_vectorstore_add_delete.py b/libs/mongodb/tests/integration_tests/test_vectorstore_add_delete.py index 3fb4220..85862a1 100644 --- a/libs/mongodb/tests/integration_tests/test_vectorstore_add_delete.py +++ b/libs/mongodb/tests/integration_tests/test_vectorstore_add_delete.py @@ -17,7 +17,7 @@ from ..utils import ConsistentFakeEmbeddings, PatchedMongoDBAtlasVectorSearch -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" INDEX_NAME = "langchain-test-index-vectorstores" COLLECTION_NAME = "langchain_test_vectorstores" diff --git a/libs/mongodb/tests/integration_tests/test_vectorstore_from_documents.py b/libs/mongodb/tests/integration_tests/test_vectorstore_from_documents.py index 0be4de4..0336f1f 100644 --- a/libs/mongodb/tests/integration_tests/test_vectorstore_from_documents.py +++ b/libs/mongodb/tests/integration_tests/test_vectorstore_from_documents.py @@ -13,7 +13,7 @@ from ..utils import ConsistentFakeEmbeddings, PatchedMongoDBAtlasVectorSearch -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" COLLECTION_NAME = "langchain_test_from_documents" INDEX_NAME = "langchain-test-index-from-documents" diff --git a/libs/mongodb/tests/integration_tests/test_vectorstore_from_texts.py b/libs/mongodb/tests/integration_tests/test_vectorstore_from_texts.py index 84bb448..4dc2e9d 100644 --- a/libs/mongodb/tests/integration_tests/test_vectorstore_from_texts.py +++ b/libs/mongodb/tests/integration_tests/test_vectorstore_from_texts.py @@ -14,7 +14,7 @@ from ..utils import ConsistentFakeEmbeddings, PatchedMongoDBAtlasVectorSearch -CONNECTION_STRING = os.environ.get("MONGODB_ATLAS_URI") +CONNECTION_STRING = os.environ.get("MONGODB_URI") DB_NAME = "langchain_test_db" COLLECTION_NAME = "langchain_test_from_texts" INDEX_NAME = "langchain-test-index-from-texts"