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

Add Pinecone Local testing support in CI #77

Merged
merged 17 commits into from
Sep 20, 2024

Conversation

austin-denoble
Copy link
Contributor

@austin-denoble austin-denoble commented Sep 18, 2024

Problem

We want to add CI that validates testing the Go SDK against an instance of pclocal hosted in a Docker container.

Solution

  • Update the ci.yaml GitHub workflow file to add a new services block, which includes using the ghcr.io/pinecone-io/pinecone-index:latest Docker image to create and how two indexes locally (pods and serverless).
  • Add new /pinecone/local_test.go which defines a new LocalIntegrationTests struct, which isolates a collection of tests specifically meant for pclocal. The tests are isolated from our unit + integration test suite with the //go:build localServer build tag. Two suites are defined for pods and serverless, and each set of tests is run against both indexes. For now the test suite generates 100 vectors, upserts them to the index, tests basic Fetch, Query, Update, DescribeIndexStats, and Delete.
  • Add a new Run local integration tests step to the ci.yaml workflow. This triggers the new local-test.go file which tests both instances of locally hosted indexes (PINECONE_INDEX_URL_POD, PINECONE_INDEX_URL_SERVERLESS) with go test -count=1 -v ./pinecone -run TestRunLocalIntegrationSuite -tags=localServer.

To Do

I'd like to expand the number of different tests we exercise on each index. Specifically:

  • Metadata filtering
  • Sparse vectors
  • Multiple namespaces
  • List vectors

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

Make sure the CI workflow passes for this PR.

If you'd like to run the local integration tests locally, you will need to download Docker, and use docker compose up to create the same indexes on your local machine. Once you've done that, you'll need to export environment variables for the different index addresses, along with the dimension.

Here's an example:

export PINECONE_INDEX_URL_POD="http://localhost:5082" PINECONE_INDEX_URL_SERVERLESS="http://localhost:5081" PINECONE_DIMENSION="1536"

Then, you can run the local integration tests directly:

go test -count=1 -v ./pinecone -run TestRunLocalIntegrationSuite -tags=localServer

@@ -17,6 +36,13 @@ jobs:
run: |
go get ./pinecone
- name: Run tests
continue-on-error: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still want to run the subsequent step that specifically runs local integration tests.

@@ -0,0 +1,154 @@
//go:build localServer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isolating these tests from the other tests. I think this works for not running these tests as a part of the unit / integration test suite, but there may be a better way to do this in Go.

@@ -54,7 +54,6 @@ func (ts *IntegrationTests) SetupSuite() {
for i, v := range vectors {
vectorIds[i] = v.Id
}
ts.vectorIds = append(ts.vectorIds, vectorIds...)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was being done twice. I think it's better to keep the actual appending where we upsert successfully. It's inside the upsertVectors helper function.

@austin-denoble austin-denoble force-pushed the adenoble/pclocal-ci-support branch from 34048a3 to 165e7f4 Compare September 19, 2024 07:30
@austin-denoble austin-denoble marked this pull request as ready for review September 19, 2024 07:33
…index and namespace combinations, make sure we're using sparse vectors and attaching metadata, cover more deletion cases when the suite cleans up
… amount we were previously checking for because of multiple namespaces
…ctorsResponse, only run test for list vectors when the test suite is for serverless, update serverless pclocal to dot-product in github ci
@austin-denoble austin-denoble changed the title Add Pinecone Local Testing support in CI Add Pinecone Local testing support in CI Sep 20, 2024
Copy link
Contributor

@haruska haruska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This is a good setup. It'll be great if we can eventually eliminate some of the integration testing against prod db.

Comment on lines 390 to 399
var usage *Usage
if res.Usage != nil {
usage = &Usage{ReadUnits: derefOrDefault(res.Usage.ReadUnits, 0)}
} else {
usage = nil
}

return &ListVectorsResponse{
VectorIds: vectorIds,
Usage: &Usage{ReadUnits: derefOrDefault(res.Usage.ReadUnits, 0)},
Usage: usage,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@austin-denoble austin-denoble merged commit 7c4bc23 into main Sep 20, 2024
2 checks passed
@austin-denoble austin-denoble deleted the adenoble/pclocal-ci-support branch September 20, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants