-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
204 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: 'Test Data Plane' | ||
description: 'Runs tests on the Pinecone data plane' | ||
|
||
# - pod vs serverless | ||
# - grpc vs rest | ||
# - metric -> vector vs sparse vector | ||
# - namespace: default vs custom | ||
# - environment: free vs paid | ||
# - with metadata vs without metadata | ||
|
||
inputs: | ||
metric: | ||
description: 'The metric of the index' | ||
required: true | ||
default: 'cosine' | ||
spec: | ||
description: 'The deploy spec of the index' | ||
required: false | ||
default: '' | ||
use_grpc: | ||
description: 'Whether to use gRPC or REST' | ||
required: false | ||
default: 'true' | ||
freshness_sleep_seconds: | ||
description: 'The number of seconds to wait for the index to become fresh' | ||
required: false | ||
default: '60' | ||
|
||
outputs: | ||
index_name: | ||
description: 'The name of the index, including randomized suffix' | ||
value: ${{ steps.create-index.outputs.index_name }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Setup Poetry | ||
uses: ./.github/actions/setup-poetry | ||
with: | ||
include_grpc: ${{ inputs.use_grpc }} | ||
include_dev: 'true' | ||
|
||
- name: Run data plane tests | ||
id: data-plane-tests | ||
shell: bash | ||
run: poetry run pytest tests/integration/data | ||
env: | ||
PINECONE_API_KEY: ${{ inputs.PINECONE_API_KEY }} | ||
USE_GRPC: ${{ inputs.use_grpc }} | ||
METRIC: ${{ inputs.metric }} | ||
SPEC: ${{ inputs.spec }} | ||
FRESHNESS_SLEEP_SECONDS: ${{ inputs.freshness_sleep_seconds }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pytest | ||
import os | ||
import json | ||
from ..helpers import get_environment_var, random_string | ||
|
||
# Test matrix needs to consider the following dimensions: | ||
# - pod vs serverless | ||
# - grpc vs rest | ||
# - metric -> vector vs sparse vector | ||
# - namespace: default vs custom | ||
# - environment: free vs paid | ||
# - with metadata vs without metadata | ||
|
||
@pytest.fixture | ||
def api_key(): | ||
return get_environment_var('PINECONE_API_KEY') | ||
|
||
@pytest.fixture | ||
def client(api_key): | ||
use_grpc = os.environ.get('USE_GRPC', 'false') == 'true' | ||
if use_grpc: | ||
from pinecone.grpc import PineconeGRPC | ||
return PineconeGRPC(api_key=api_key) | ||
else: | ||
from pinecone import Pinecone | ||
return Pinecone(api_key=api_key) | ||
|
||
@pytest.fixture | ||
def metric(): | ||
return get_environment_var('METRIC', 'cosine') | ||
|
||
@pytest.fixture | ||
def spec(): | ||
return json.loads(get_environment_var('SPEC')) | ||
|
||
@pytest.fixture | ||
def index_name(): | ||
return 'dataplane-' + random_string(20) | ||
|
||
@pytest.fixture | ||
def namespace(): | ||
return random_string(10) | ||
|
||
@pytest.fixture | ||
def index_host(client, index_name, metric, spec): | ||
client.create_index(name=index_name, dimension=2, metric=metric, spec=spec) | ||
description = client.describe_index(name=index_name) | ||
return description.host | ||
|
||
def sleep_t(): | ||
return int(os.environ.get('FRESHNESS_SLEEP_SECONDS', 60)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest | ||
import time | ||
from pinecone import Vector | ||
|
||
def test_upsert_to_default_namespace(client, index_name, sleep_t): | ||
expected_dimension = 2 | ||
desc = client.describe_index(index_name) | ||
assert desc.dimension == expected_dimension | ||
assert desc.metric == 'cosine' | ||
|
||
idx = client.Index(index_name) | ||
|
||
# Upsert with tuples | ||
idx.upsert(vectors=[ | ||
('1', [1.0, 2.0]), | ||
('2', [3.0, 4.0]), | ||
('3', [5.0, 6.0]) | ||
]) | ||
|
||
# Upsert with objects | ||
idx.upsert(vectors=[ | ||
Vector('4', [7.0, 8.0]), | ||
Vector('5', [9.0, 10.0]), | ||
Vector('6', [11.0, 12.0]) | ||
]) | ||
|
||
# Upsert with dict | ||
idx.upsert(vectors=[ | ||
{'id': '7', 'values': [13.0, 14.0]}, | ||
{'id': '8', 'values': [15.0, 16.0]}, | ||
{'id': '9', 'values': [17.0, 18.0]} | ||
]) | ||
|
||
time.sleep(sleep_t) | ||
|
||
# Check the vector count reflects some data has been upserted | ||
stats = idx.describe_index_stats() | ||
assert stats.vector_count == 9 | ||
|
||
|
||
def test_upsert_to_custom_namespace(client, index_name, namespace): | ||
expected_dimension = 2 | ||
assert client.describe_index(index_name).dimension == expected_dimension | ||
|
||
idx = client.Index(index_name) | ||
|
||
# Upsert with tuples | ||
idx.upsert(vectors=[ | ||
('1', [1.0, 2.0]), | ||
('2', [3.0, 4.0]), | ||
('3', [5.0, 6.0]) | ||
], | ||
namespace=namespace | ||
) |