Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add db migration guide sample tests #380

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions samples.cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
- id: Install dependencies
name: python:${_VERSION}
entrypoint: pip
args: ["install", "--user", "-r", "samples/migrations/requirements.txt"]

- id: Install module (and test requirements)
name: python:${_VERSION}
entrypoint: pip
args: ["install", ".[test]", "--user"]

- id: Run samples tests
name: python:${_VERSION}
entrypoint: /bin/bash
args:
- "-c"
- |
python -m pytest samples/migrations/
env:
- "PROJECT_ID=$PROJECT_ID"
- "INSTANCE_ID=$_INSTANCE_ID"
- "CLUSTER_ID=$_CLUSTER_ID"
- "DATABASE_ID=$_DATABASE_ID"
- "REGION=$_REGION"
- "OMNI_DATABASE_ID=$_OMNI_DATABASE_ID"
- "IP_ADDRESS=$_IP_ADDRESS"
- "PINECONE_INDEX_NAME=$_PINECONE_INDEX_NAME"
- "WEAVIATE_COLLECTION_NAME=$_WEAVIATE_COLLECTION_NAME"
- "CHROMADB_COLLECTION_NAME=$_CHROMADB_COLLECTION_NAME"
- "MILVUS_COLLECTION_NAME=$_MILVUS_COLLECTION_NAME"
- "QDRANT_COLLECTION_NAME=$_QDRANT_COLLECTION_NAME"

secretEnv:
[
"DB_USER",
"DB_PASSWORD",
"OMNI_HOST",
"OMNI_USER",
"OMNI_PASSWORD",
"IAM_ACCOUNT",
"PINECONE_API_KEY",
"WEAVIATE_API_KEY",
"WEAVIATE_URL",
]

availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/DB_USER/versions/1
env: "DB_USER"
- versionName: projects/$PROJECT_ID/secrets/DB_PASSWORD/versions/1
env: "DB_PASSWORD"
- versionName: projects/$PROJECT_ID/secrets/OMNI_HOST/versions/1
env: "OMNI_HOST"
- versionName: projects/$PROJECT_ID/secrets/OMNI_USER/versions/1
env: "OMNI_USER"
- versionName: projects/$PROJECT_ID/secrets/OMNI_PASSWORD/versions/1
env: "OMNI_PASSWORD"
- versionName: projects/$PROJECT_ID/secrets/service_account_email/versions/1
env: "IAM_ACCOUNT"
- versionName: projects/$PROJECT_ID/secrets/PINECONE_API_KEY/versions/1
env: "PINECONE_API_KEY"
- versionName: projects/$PROJECT_ID/secrets/WEAVIATE_API_KEY/versions/1
env: "WEAVIATE_API_KEY"
- versionName: projects/$PROJECT_ID/secrets/WEAVIATE_URL/versions/1
env: "WEAVIATE_URL"

substitutions:
_VERSION: "3.10"
_INSTANCE_CONNECTION_NAME: projects/${PROJECT_ID}/locations/${_REGION}/clusters/${_CLUSTER_ID}/instances/${_INSTANCE_ID}
_DATABASE_PORT: "5432"
_IP_ADDRESS: "127.0.0.1" # required in other tests else pytest fails
_PINECONE_INDEX_NAME: "langchain-test-index"
_WEAVIATE_COLLECTION_NAME: "example_collection"
_CHROMADB_COLLECTION_NAME: "example_collection"
_MILVUS_COLLECTION_NAME: "langchain_example"
_QDRANT_COLLECTION_NAME: "demo_collection"

options:
dynamicSubstitutions: true
2 changes: 1 addition & 1 deletion samples/migrations/test_pinecone_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def create_pinecone_index(
name=pinecone_index_name,
dimension=768,
metric="cosine",
spec=ServerlessSpec(cloud="aws", region="us-east-1"),
spec=ServerlessSpec(cloud="gcp", region="us-central1"),
)
while not client.describe_index(pinecone_index_name).status["ready"]:
time.sleep(1)
Expand Down