-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add tests for the examples vec-473 vec-474 vec-475 (#84)
* ci: add prism example test action * ci: add quote search example testing action * ci: add basic search test action vec-473
- Loading branch information
1 parent
98ca72d
commit 88acd3b
Showing
15 changed files
with
422 additions
and
2 deletions.
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,64 @@ | ||
name: Run Basic Search Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
name: Basic Search Tests | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
WORKING_DIR: basic-search | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
# Set up Python environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
# Install Python dependencies | ||
- name: Install Dependencies | ||
working-directory: ${{ env.WORKING_DIR }} | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
# Write feature keys to config files for use by AVS and Aerospike | ||
- name: Write feature keys | ||
working-directory: docker | ||
env: | ||
FEATURES_CONF : ${{secrets.FEATURES_CONF}} | ||
|
||
run: | | ||
echo "$FEATURES_CONF" > config/features.conf | ||
# Run the AVS server with Docker Compose | ||
- name: Start AVS Server | ||
working-directory: docker | ||
run: | | ||
docker compose -f docker-compose.yaml up -d | ||
# Wait for the AVS Docker Container to be Healthy | ||
- name: Wait for Docker Container to Be Healthy | ||
run: | | ||
CONTAINER_NAME="aerospike-vector-search" | ||
while [ "$(docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME)" != "healthy" ]; do | ||
echo "Waiting for container $CONTAINER_NAME to be healthy..." | ||
sleep 1 | ||
done | ||
echo "Container $CONTAINER_NAME is healthy, continuing..." | ||
- name: Run the Basic Search | ||
working-directory: ${{ env.WORKING_DIR }} | ||
run: | | ||
python search.py --port 5555 |
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,103 @@ | ||
name: Run Prism Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
name: Prism Tests | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
WORKING_DIR: prism-image-search | ||
|
||
strategy: | ||
matrix: | ||
deployment: [waitress, docker] | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
# Set up Python environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
# Install Python dependencies | ||
- name: Install Dependencies | ||
working-directory: ${{ env.WORKING_DIR }} | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r prism/requirements.txt | ||
pip install -r tests/requirements.txt | ||
# Write feature keys to config files for use by AVS and Aerospike | ||
- name: Write feature keys | ||
working-directory: docker | ||
env: | ||
FEATURES_CONF : ${{secrets.FEATURES_CONF}} | ||
|
||
run: | | ||
echo "$FEATURES_CONF" > config/features.conf | ||
# Run the AVS server with Docker Compose | ||
- name: Start AVS Server | ||
working-directory: docker | ||
run: | | ||
docker compose -f docker-compose.yaml up -d | ||
# Wait for the AVS Docker Container to be Healthy | ||
- name: Wait for Docker Container to Be Healthy | ||
run: | | ||
CONTAINER_NAME="aerospike-vector-search" | ||
while [ "$(docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME)" != "healthy" ]; do | ||
echo "Waiting for container $CONTAINER_NAME to be healthy..." | ||
sleep 1 | ||
done | ||
echo "Container $CONTAINER_NAME is healthy, continuing..." | ||
# Run the app server with waitress | ||
- name: Start Server with Waitress | ||
working-directory: ${{ env.WORKING_DIR }}/prism | ||
if: matrix.deployment == 'waitress' | ||
env: | ||
# By default, the docker compose in /docker maps the AVS_PORT from 5000 to 5555 on localhost | ||
AVS_PORT: 5555 | ||
run: | | ||
nohup python -m waitress --host=127.0.0.1 --port=8080 --threads 32 prism:app & | ||
sleep 60 # Wait for the server to be ready | ||
# TODO come up with a better/faster way to wait for the server to be ready | ||
# Build and run Docker container | ||
- name: Build and Start app with Docker | ||
working-directory: ${{ env.WORKING_DIR }} | ||
if: matrix.deployment == 'docker' | ||
run: | | ||
docker build -t prism . -f Dockerfile-prism | ||
docker run -d -p 8080:8080 --name prism \ | ||
--network svc \ | ||
-e AVS_PORT=5000 \ | ||
-e AVS_HOST=aerospike-vector-search \ | ||
prism | ||
sleep 60 # Wait for the server to be ready | ||
# TODO come up with a better/faster way to wait for the server to be ready | ||
# Run Pytest tests | ||
- name: Run Pytest | ||
working-directory: ${{ env.WORKING_DIR }} | ||
run: | | ||
python -m pytest tests/e2e -s | ||
# Cleanup Docker container (only for Docker deployment) | ||
- name: Cleanup Docker | ||
if: matrix.deployment == 'docker' | ||
run: | | ||
docker stop prism | ||
docker rm prism |
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,118 @@ | ||
name: Run Quote Search Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
name: Quote Search Tests | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
WORKING_DIR: quote-semantic-search | ||
|
||
strategy: | ||
matrix: | ||
deployment: [waitress, docker, docker-preview] | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
# Set up Python environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
# Install Python dependencies | ||
- name: Install Dependencies | ||
working-directory: ${{ env.WORKING_DIR }} | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r quote-search/requirements.txt | ||
pip install -r tests/requirements.txt | ||
# Write feature keys to config files for use by AVS and Aerospike | ||
- name: Write feature keys | ||
working-directory: docker | ||
env: | ||
FEATURES_CONF : ${{secrets.FEATURES_CONF}} | ||
|
||
run: | | ||
echo "$FEATURES_CONF" > config/features.conf | ||
# Run the AVS server with Docker Compose | ||
- name: Start AVS Server | ||
working-directory: docker | ||
run: | | ||
docker compose -f docker-compose.yaml up -d | ||
# Wait for the AVS Docker Container to be Healthy | ||
- name: Wait for Docker Container to Be Healthy | ||
run: | | ||
CONTAINER_NAME="aerospike-vector-search" | ||
while [ "$(docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME)" != "healthy" ]; do | ||
echo "Waiting for container $CONTAINER_NAME to be healthy..." | ||
sleep 1 | ||
done | ||
echo "Container $CONTAINER_NAME is healthy, continuing..." | ||
# Run the app server with waitress | ||
- name: Start Server with Waitress | ||
working-directory: ${{ env.WORKING_DIR }}/quote-search | ||
if: matrix.deployment == 'waitress' | ||
env: | ||
# By default, the docker compose in /docker maps the AVS_PORT from 5000 to 5555 on localhost | ||
AVS_PORT: 5555 | ||
run: | | ||
nohup python -m waitress --host=127.0.0.1 --port=8080 --threads 32 quote_search:app & | ||
sleep 60 # Wait for the server to be ready | ||
# TODO come up with a better/faster way to wait for the server to be ready | ||
# Build and run Docker container | ||
- name: Build and Start app with Docker | ||
working-directory: ${{ env.WORKING_DIR }} | ||
if: matrix.deployment == 'docker' | ||
run: | | ||
docker build -t quote-search . -f Dockerfile-quote-search | ||
docker run -d -p 8080:8080 --name quote-search \ | ||
--network svc \ | ||
-e AVS_PORT=5000 \ | ||
-e AVS_HOST=aerospike-vector-search \ | ||
-v ./container-volumes/quote-search/data:/container-volumes/quote-search/data \ | ||
quote-search | ||
sleep 60 # Wait for the server to be ready | ||
# TODO come up with a better/faster way to wait for the server to be ready | ||
# Build and run preview Docker container | ||
# The preview container copies the dataset so no volume is needed | ||
- name: Build and Start app with preview Docker image | ||
if: matrix.deployment == 'docker-preview' | ||
run: | | ||
docker build -t quote-search . -f .internal/Dockerfile-quote-search-preview | ||
docker run -d -p 8080:8080 --name quote-search \ | ||
--network svc \ | ||
-e AVS_PORT=5000 \ | ||
-e AVS_HOST=aerospike-vector-search \ | ||
quote-search | ||
sleep 60 # Wait for the server to be ready | ||
# TODO come up with a better/faster way to wait for the server to be ready | ||
# Run Pytest tests | ||
- name: Run Pytest | ||
working-directory: ${{ env.WORKING_DIR }} | ||
run: | | ||
python -m pytest tests/e2e -s | ||
# Cleanup Docker container (only for Docker deployment) | ||
- name: Cleanup Docker | ||
if: matrix.deployment == 'docker' || matrix.deployment == 'docker-preview' | ||
run: | | ||
docker stop quote-search | ||
docker rm quote-search |
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 was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
# Test Information | ||
|
||
Pytest test suite for the AVS prism image search example application. | ||
These tests are simple and used by the devs to verify the examples are functional. | ||
They should not be used as a model for your production tests. | ||
|
||
## Setup | ||
|
||
Create a virtual environment and install the requirements in requirements.txt. | ||
```shell | ||
pip install -r requirements.txt | ||
``` | ||
|
||
> [!IMPORTANT] | ||
> Run the example app with the IMAGE_DIR environment variable pointing to your test image data. The CI tests use ../container-volumes/prism/images/static/data as it contains one image already. | ||
Run the prism image search example app so that it listens on port 8080. | ||
If it is not running on port 8080, you can run the tests with the --app-address option set to the correct address:port. | ||
|
||
Then run the tests with pytest. | ||
```shell | ||
python -m pytest . | ||
``` |
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,29 @@ | ||
import pytest | ||
|
||
########################################## | ||
###### GLOBALS | ||
########################################## | ||
|
||
DEFAULT_APP_ADDRESS = "127.0.0.1:8080" | ||
|
||
########################################## | ||
###### SUITE FLAGS | ||
########################################## | ||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--app-address", action="store", default=DEFAULT_APP_ADDRESS, help="app address, ip:port") | ||
|
||
|
||
@pytest.fixture(scope='session', autouse=True) | ||
def app(request): | ||
return request.config.getoption("--app-address") | ||
|
||
|
||
########################################## | ||
###### FIXTURES | ||
########################################## | ||
|
||
@pytest.fixture(scope='session') | ||
def app_url(app): | ||
app_url = f"http://{app}" | ||
yield app_url |
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,12 @@ | ||
import pytest | ||
|
||
import requests | ||
|
||
def test_search(app_url): | ||
|
||
response = requests.post(app_url + "/rest/v1/search", data={"text": "aerospike"}) | ||
assert response.status_code == 200, f"Expected status code 200, but got {response.status_code}" | ||
|
||
# by default there is 1 photo in the data dir so expect 1 | ||
results = response.json()["results"] | ||
assert len(results) == 1, f"Expected 1 results, but got {len(results)}" |
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,3 @@ | ||
pytest | ||
requests | ||
aerospike-vector-search |
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
Oops, something went wrong.