Skip to content

Commit

Permalink
merge dev into vec-330
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-spike committed Oct 10, 2024
2 parents 88f5003 + dd73d96 commit 1ed18c5
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 71 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/extensive_vector_search_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ on:
push:
branches:
- dev
- main
# TODO remove this after testing it in the PR
pull_request:
branches:
- dev

jobs:
test-exhaustive-vector-search:
Expand Down Expand Up @@ -74,7 +69,7 @@ jobs:
sleep 5
python -m pytest standard -s --host 0.0.0.0 --port 5000 --extensive_vector_search --cov=aerospike_vector_search -vs
python -m pytest standard -s --host 0.0.0.0 --port 5000 --extensive_vector_search -vs
mv .coverage coverage_data
working-directory: tests
Expand Down
65 changes: 31 additions & 34 deletions tests/standard/aio/test_extensive_vector_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import asyncio
import pytest
import random
import time
from aerospike_vector_search import types, AVSServerError

import grpc
Expand Down Expand Up @@ -184,6 +184,11 @@ async def test_vector_search(
session_vector_client.wait_for_index_completion(namespace="test", name="demo1")
)
await asyncio.gather(*tasks)

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

await grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -221,6 +226,11 @@ async def test_vector_search_with_set_same_as_index(
session_vector_client.wait_for_index_completion(namespace="test", name="demo2")
)
await asyncio.gather(*tasks)

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

await grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -262,6 +272,11 @@ async def test_vector_search_with_set_different_than_name(
session_vector_client.wait_for_index_completion(namespace="test", name="demo3")
)
await asyncio.gather(*tasks)

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

await grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -303,6 +318,11 @@ async def test_vector_search_with_index_storage_different_than_name(
session_vector_client.wait_for_index_completion(namespace="test", name="demo4")
)
await asyncio.gather(*tasks)

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

await grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -344,6 +364,11 @@ async def test_vector_search_with_index_storage_different_location(
session_vector_client.wait_for_index_completion(namespace="test", name="demo5")
)
await asyncio.gather(*tasks)

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

await grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -385,6 +410,11 @@ async def test_vector_search_with_separate_namespace(
session_vector_client.wait_for_index_completion(namespace="test", name="demo6")
)
await asyncio.gather(*tasks)

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

await grade_results(
base_numpy,
truth_numpy,
Expand All @@ -395,39 +425,6 @@ async def test_vector_search_with_separate_namespace(
)


async def test_vector_is_indexed(
session_vector_client, session_admin_client, with_latency
):

result = await session_vector_client.is_indexed(
namespace="test",
key=str(random.randrange(10_000)),
index_name="demo2",
set_name="demo2",
)
assert result is True


async def test_vector_is_indexed_timeout(
session_vector_client, session_admin_client, with_latency
):
if not with_latency:
pytest.skip("Server latency too low to test timeout")
for i in range(10):
try:
result = await session_vector_client.is_indexed(
namespace="test",
key=str(random.randrange(10_000)),
index_name="demo2",
timeout=0.0001,
)
except AVSServerError as se:
if se.rpc_error.code() == grpc.StatusCode.DEADLINE_EXCEEDED:
assert se.rpc_error.code() == grpc.StatusCode.DEADLINE_EXCEEDED
return
assert "In several attempts, the timeout did not happen" == "TEST FAIL"


async def test_vector_vector_search_timeout(
session_vector_client, session_admin_client, with_latency
):
Expand Down
85 changes: 85 additions & 0 deletions tests/standard/aio/test_vector_client_is_indexed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import pytest
import random
from aerospike_vector_search import AVSServerError
from aerospike_vector_search.aio import Client, AdminClient

import asyncio
import grpc

# Define module-level constants for common arguments
NAMESPACE = "test"
SET_NAME = "isidxset"
INDEX_NAME = "isidx"
DIMENSIONS = 3
VECTOR_FIELD = "vector"

@pytest.fixture(scope="module", autouse=True)
async def setup_teardown(session_vector_client: Client, session_admin_client: AdminClient):
# Setup: Create index and upsert records
await session_admin_client.index_create(
namespace=NAMESPACE,
sets=SET_NAME,
name=INDEX_NAME,
dimensions=DIMENSIONS,
vector_field=VECTOR_FIELD,
)
tasks = []
for i in range(10):
tasks.append(session_vector_client.upsert(
namespace=NAMESPACE,
set_name=SET_NAME,
key=str(i),
record_data={VECTOR_FIELD: [float(i)] * DIMENSIONS},
))
tasks.append(session_vector_client.wait_for_index_completion(
namespace=NAMESPACE,
name=INDEX_NAME,
))
await asyncio.gather(*tasks)
yield
# Teardown: remove records
tasks = []
for i in range(10):
tasks.append(session_vector_client.delete(
namespace=NAMESPACE,
set_name=SET_NAME,
key=str(i)
))
await asyncio.gather(*tasks)

# Teardown: Drop index
await session_admin_client.index_drop(
namespace=NAMESPACE,
name=INDEX_NAME
)

async def test_vector_is_indexed(
session_vector_client,
):
result = await session_vector_client.is_indexed(
namespace=NAMESPACE,
key="0",
index_name=INDEX_NAME,
set_name=SET_NAME,
)
assert result is True


async def test_vector_is_indexed_timeout(
session_vector_client, with_latency
):
if not with_latency:
pytest.skip("Server latency too low to test timeout")
for _ in range(10):
try:
await session_vector_client.is_indexed(
namespace=NAMESPACE,
key="0",
index_name=INDEX_NAME,
timeout=0.0001,
)
except AVSServerError as se:
if se.rpc_error.code() == grpc.StatusCode.DEADLINE_EXCEEDED:
assert se.rpc_error.code() == grpc.StatusCode.DEADLINE_EXCEEDED
return
assert "In several attempts, the timeout did not happen" == "TEST FAIL"
56 changes: 25 additions & 31 deletions tests/standard/sync/test_extensive_vector_search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import pytest
import random
import time
from aerospike_vector_search import types
from aerospike_vector_search import AVSServerError
import grpc
Expand Down Expand Up @@ -176,6 +176,10 @@ def test_vector_search(

session_vector_client.wait_for_index_completion(namespace="test", name="demo1")

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -211,6 +215,10 @@ def test_vector_search_with_set_same_as_index(

session_vector_client.wait_for_index_completion(namespace="test", name="demo2")

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -245,6 +253,10 @@ def test_vector_search_with_set_different_than_name(
for j, vector in enumerate(base_numpy):
put_vector(session_vector_client, vector, j, "example1")

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

session_vector_client.wait_for_index_completion(namespace="test", name="demo3")

grade_results(
Expand Down Expand Up @@ -283,6 +295,10 @@ def test_vector_search_with_index_storage_different_than_name(

session_vector_client.wait_for_index_completion(namespace="test", name="demo4")

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -319,6 +335,10 @@ def test_vector_search_with_index_storage_different_location(

session_vector_client.wait_for_index_completion(namespace="test", name="demo5")

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

grade_results(
base_numpy,
truth_numpy,
Expand Down Expand Up @@ -355,6 +375,10 @@ def test_vector_search_with_separate_namespace(

session_vector_client.wait_for_index_completion(namespace="test", name="demo6")

# Wait for index completion isn't perfect
# give the index some extra time since accuracy is the point of this test
time.sleep(5)

grade_results(
base_numpy,
truth_numpy,
Expand All @@ -365,36 +389,6 @@ def test_vector_search_with_separate_namespace(
)


def test_vector_is_indexed(session_vector_client, session_admin_client):

result = session_vector_client.is_indexed(
namespace="test",
key=str(random.randrange(10_000)),
index_name="demo2",
set_name="demo2",
)

assert result is True


def test_vector_is_indexed_timeout(
session_vector_client, session_admin_client, with_latency
):
if not with_latency:
pytest.skip("Server latency too low to test timeout")

for i in range(10):
try:
result = session_vector_client.is_indexed(
namespace="test", key=500, index_name="demo2", timeout=0.0001
)
except AVSServerError as se:
if se.rpc_error.code() == grpc.StatusCode.DEADLINE_EXCEEDED:
assert se.rpc_error.code() == grpc.StatusCode.DEADLINE_EXCEEDED
return
assert "In several attempts, the timeout did not happen" == "TEST FAIL"


def test_vector_vector_search_timeout(
session_vector_client, session_admin_client, with_latency
):
Expand Down
Loading

0 comments on commit 1ed18c5

Please sign in to comment.