Skip to content

Commit c0d089e

Browse files
committed
test: add s3 storage provider test fixtures
1 parent 4c8b808 commit c0d089e

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"tests.fixtures.guardrails",
7272
"tests.fixtures.trustyai",
7373
"tests.fixtures.vector_io",
74+
"tests.fixtures.files",
7475
]
7576

7677

tests/fixtures/files.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from typing import Callable, Dict
2+
import pytest
3+
import os
4+
from _pytest.fixtures import FixtureRequest
5+
6+
S3_BUCKET_NAME = os.getenv("LLS_FILES_S3_BUCKET_NAME", "opendatathub-tests-llama-stack")
7+
S3_BUCKET_REGION = os.getenv("LLS_FILES_S3_REGION", "us-east-1")
8+
S3_BUCKET_ENDPOINT_URL = os.getenv("AWS_DEFAULT_ENDPOINT", "https://s3.us-east-1.amazonaws.com")
9+
S3_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID", "minio")
10+
S3_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY", "minio123")
11+
S3_AUTO_CREATE_BUCKET = os.getenv("LLS_FILES_S3_AUTO_CREATE_BUCKET", "true")
12+
13+
@pytest.fixture(scope="class")
14+
def files_provider_config_factory(
15+
request: FixtureRequest,
16+
) -> Callable[[str], list[Dict[str, str]]]:
17+
"""
18+
Factory fixture for configuring external files providers and returning their configuration.
19+
20+
This fixture returns a factory function that can configure additional files storage providers
21+
(such as S3/minio) and return the necessary environment variables
22+
for configuring the LlamaStack server to use these providers.
23+
24+
Args:
25+
request: Pytest fixture request object for accessing other fixtures
26+
27+
Returns:
28+
Callable[[str], list[Dict[str, str]]]: Factory function that takes a provider name
29+
and returns a list of environment variable dictionaries
30+
31+
Supported Providers:
32+
- "local": defaults to using just local filesystem
33+
- "s3": a remote S3/Minio storage provider
34+
35+
Environment Variables by Provider:
36+
- "s3":
37+
* S3_BUCKET_NAME: Name of the S3/Minio bucket
38+
* AWS_DEFAULT_REGION: Region of the S3/Minio bucket
39+
* S3_ENDPOINT_URL: Endpoint URL of the S3/Minio bucket
40+
* AWS_ACCESS_KEY_ID: Access key ID for the S3/Minio bucket
41+
* AWS_SECRET_ACCESS_KEY: Secret access key for the S3/Minio bucket
42+
* S3_AUTO_CREATE_BUCKET: Whether to automatically create the S3/Minio bucket if it doesn't exist
43+
44+
Example:
45+
def test_with_s3(files_provider_config_factory):
46+
env_vars = files_provider_config_factory("s3")
47+
# env_vars contains S3_BUCKET_NAME, S3_BUCKET_ENDPOINT_URL, etc.
48+
"""
49+
50+
def _factory(provider_name: str) -> list[Dict[str, str]]:
51+
env_vars: list[dict[str, str]] = []
52+
53+
if provider_name is "local" or provider_name is None:
54+
# Default case - no additional environment variables needed
55+
pass
56+
elif provider_name == "s3":
57+
env_vars.append({"name": "ENABLE_S3", "value": "s3"})
58+
env_vars.append({"name": "S3_BUCKET_NAME", "value": S3_BUCKET_NAME})
59+
env_vars.append({"name": "AWS_DEFAULT_REGION", "value": S3_BUCKET_REGION})
60+
env_vars.append({"name": "S3_ENDPOINT_URL", "value": S3_BUCKET_ENDPOINT_URL})
61+
env_vars.append({"name": "AWS_ACCESS_KEY_ID", "value": S3_ACCESS_KEY_ID})
62+
env_vars.append({"name": "AWS_SECRET_ACCESS_KEY", "value": S3_SECRET_ACCESS_KEY})
63+
env_vars.append({"name": "S3_AUTO_CREATE_BUCKET", "value": S3_AUTO_CREATE_BUCKET})
64+
65+
return env_vars
66+
67+
return _factory

tests/llama_stack/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def enabled_llama_stack_operator(dsc_resource: DataScienceCluster) -> Generator[
5050
def llama_stack_server_config(
5151
request: FixtureRequest,
5252
vector_io_provider_deployment_config_factory: Callable[[str], list[Dict[str, str]]],
53+
files_provider_config_factory: Callable[[str], list[Dict[str, str]]],
5354
) -> Dict[str, Any]:
5455
"""
5556
Generate server configuration for LlamaStack distribution deployment and deploy vector I/O provider resources.
@@ -188,6 +189,11 @@ def test_with_remote_milvus(llama_stack_server_config):
188189

189190
# KUBEFLOW_PIPELINES_TOKEN: Get from current client token
190191
env_vars.append({"name": "KUBEFLOW_PIPELINES_TOKEN", "value": str(current_client_token)})
192+
193+
# Depending on parameter files_provider, configure files provider and obtain required env_vars
194+
files_provider = params.get("files_provider") or "local"
195+
env_vars_files = files_provider_config_factory(provider_name=files_provider)
196+
env_vars.extend(env_vars_files)
191197

192198
# Depending on parameter vector_io_provider, deploy vector_io provider and obtain required env_vars
193199
vector_io_provider = params.get("vector_io_provider") or "milvus"

tests/llama_stack/vector_io/test_vector_stores.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
{
2121
"llama_stack_storage_size": "2Gi",
2222
"vector_io_provider": "milvus",
23+
"files_provider": "s3",
2324
},
2425
{"vector_io_provider": "milvus"},
2526
id="vector_io_provider_milvus",
@@ -29,6 +30,7 @@
2930
{
3031
"llama_stack_storage_size": "2Gi",
3132
"vector_io_provider": "faiss",
33+
"files_provider": "local",
3234
},
3335
{"vector_io_provider": "faiss"},
3436
id="vector_io_provider_faiss",
@@ -38,6 +40,7 @@
3840
{
3941
"llama_stack_storage_size": "2Gi",
4042
"vector_io_provider": "milvus-remote",
43+
"files_provider": "s3",
4144
},
4245
{"vector_io_provider": "milvus-remote"},
4346
id="vector_io_provider_milvus-remote",

0 commit comments

Comments
 (0)