Skip to content

Commit

Permalink
Add initial ysb.py test for Pinecone
Browse files Browse the repository at this point in the history
Check that we can run the mnist-test workload against it.
  • Loading branch information
daverigby committed Apr 29, 2024
1 parent c6be306 commit 9529e53
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
poetry run pytest
env:
PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}'
INDEX_HOST: ${{ steps.create-index.outputs.index_host }}
INDEX_NAME: ${{ steps.create-index.outputs.index_name }}
- name: Delete test index
if: always()
uses: ./.github/actions/delete-index
Expand Down
58 changes: 58 additions & 0 deletions tests/integration/test_pinecone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import pytest
import subprocess
import os
import sys
from subprocess import PIPE


@pytest.fixture
def index_name():
host = os.environ.get("INDEX_NAME", None)
if host is None or host == "":
raise Exception(
"INDEX_NAME environment variable is not set. Set to the host of a Pinecone index suitable for testing "
"against."
)
return host


def spawn_ysb(workload, index_name, timeout=60, extra_args=[]):
proc = subprocess.Popen(
[
"ysb.py",
"--database",
"pinecone",
"--workload",
workload,
"--index_name",
index_name,
]
+ extra_args,
stdout=PIPE,
stderr=PIPE,
text=True,
)
try:
stdout, stderr = proc.communicate(timeout=timeout)
except subprocess.TimeoutExpired as e:
# Echo whatever stdout / stderr we got so far, to aid in debugging
if e.stdout:
for line in e.stdout.decode(errors="replace").splitlines():
print(line)
if e.stderr:
for line in e.stderr.decode(errors="replace").splitlines():
print(line, file=sys.stderr)
raise
# Echo subprocesses stdout & stderr to our own, so pytest can capture and
# report them on error.
print(stdout)
print(stderr, file=sys.stderr)
return proc, stdout, stderr


class TestPinecone:
def test_mnist(self, index_name):
# Test "-test" variant of mnist loads and runs successfully.
(proc, stdout, stderr) = spawn_ysb(workload="mnist-test", index_name=index_name)
# TODO: Check more here when ysb output is more structured.
assert proc.returncode == 0
199 changes: 0 additions & 199 deletions tests/integration/test_requests.py

This file was deleted.

2 changes: 0 additions & 2 deletions tests/test_dummy.py

This file was deleted.

0 comments on commit 9529e53

Please sign in to comment.