Skip to content

Commit d82d1ec

Browse files
authored
feat: Add local tests for s3 registry using minio (#4029)
1 parent 5579f5c commit d82d1ec

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ test-python-unit:
6767
python -m pytest -n 8 --color=yes sdk/python/tests
6868

6969
test-python-integration:
70-
python -m pytest -n 8 --integration --color=yes --durations=5 --timeout=1200 --timeout_method=thread sdk/python/tests
70+
python -m pytest -n 8 --integration -k "not minio_registry" --color=yes --durations=5 --timeout=1200 --timeout_method=thread sdk/python/tests
7171

7272
test-python-integration-local:
7373
@(docker info > /dev/null 2>&1 && \

sdk/python/tests/integration/registration/test_registry.py

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
import os
1515
import time
1616
from datetime import timedelta
17+
from unittest import mock
1718

1819
import pytest
1920
from pytest_lazyfixture import lazy_fixture
21+
from testcontainers.core.container import DockerContainer
2022

2123
from feast import FileSource
2224
from feast.data_format import ParquetFormat
@@ -60,12 +62,56 @@ def s3_registry() -> Registry:
6062
return Registry("project", registry_config, None)
6163

6264

65+
@pytest.fixture
66+
def minio_registry() -> Registry:
67+
minio_user = "minio99"
68+
minio_password = "minio123"
69+
bucket_name = "test-bucket"
70+
71+
container: DockerContainer = (
72+
DockerContainer("quay.io/minio/minio")
73+
.with_exposed_ports(9000, 9001)
74+
.with_env("MINIO_ROOT_USER", minio_user)
75+
.with_env("MINIO_ROOT_PASSWORD", minio_password)
76+
.with_command('server /data --console-address ":9001"')
77+
.with_exposed_ports()
78+
)
79+
80+
container.start()
81+
82+
exposed_port = container.get_exposed_port("9000")
83+
container_host = container.get_container_host_ip()
84+
85+
container.exec(f"mkdir /data/{bucket_name}")
86+
87+
registry_config = RegistryConfig(
88+
path=f"s3://{bucket_name}/registry.db", cache_ttl_seconds=600
89+
)
90+
91+
mock_environ = {
92+
"FEAST_S3_ENDPOINT_URL": f"http://{container_host}:{exposed_port}",
93+
"AWS_ACCESS_KEY_ID": minio_user,
94+
"AWS_SECRET_ACCESS_KEY": minio_password,
95+
"AWS_SESSION_TOKEN": "",
96+
}
97+
98+
with mock.patch.dict(os.environ, mock_environ):
99+
yield Registry("project", registry_config, None)
100+
101+
container.stop()
102+
103+
63104
@pytest.mark.integration
64105
@pytest.mark.parametrize(
65106
"test_registry",
66-
[lazy_fixture("gcs_registry"), lazy_fixture("s3_registry")],
107+
[
108+
lazy_fixture("gcs_registry"),
109+
lazy_fixture("s3_registry"),
110+
lazy_fixture("minio_registry"),
111+
],
67112
)
68113
def test_apply_entity_integration(test_registry):
114+
69115
entity = Entity(
70116
name="driver_car_id",
71117
description="Car driver id",
@@ -106,7 +152,11 @@ def test_apply_entity_integration(test_registry):
106152
@pytest.mark.integration
107153
@pytest.mark.parametrize(
108154
"test_registry",
109-
[lazy_fixture("gcs_registry"), lazy_fixture("s3_registry")],
155+
[
156+
lazy_fixture("gcs_registry"),
157+
lazy_fixture("s3_registry"),
158+
lazy_fixture("minio_registry"),
159+
],
110160
)
111161
def test_apply_feature_view_integration(test_registry):
112162
# Create Feature Views
@@ -183,7 +233,11 @@ def test_apply_feature_view_integration(test_registry):
183233
@pytest.mark.integration
184234
@pytest.mark.parametrize(
185235
"test_registry",
186-
[lazy_fixture("gcs_registry"), lazy_fixture("s3_registry")],
236+
[
237+
lazy_fixture("gcs_registry"),
238+
lazy_fixture("s3_registry"),
239+
lazy_fixture("minio_registry"),
240+
],
187241
)
188242
def test_apply_data_source_integration(test_registry: Registry):
189243
validate_registry_data_source_apply(test_registry)

0 commit comments

Comments
 (0)