|
14 | 14 | import os |
15 | 15 | import time |
16 | 16 | from datetime import timedelta |
| 17 | +from unittest import mock |
17 | 18 |
|
18 | 19 | import pytest |
19 | 20 | from pytest_lazyfixture import lazy_fixture |
| 21 | +from testcontainers.core.container import DockerContainer |
20 | 22 |
|
21 | 23 | from feast import FileSource |
22 | 24 | from feast.data_format import ParquetFormat |
@@ -60,12 +62,56 @@ def s3_registry() -> Registry: |
60 | 62 | return Registry("project", registry_config, None) |
61 | 63 |
|
62 | 64 |
|
| 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 | + |
63 | 104 | @pytest.mark.integration |
64 | 105 | @pytest.mark.parametrize( |
65 | 106 | "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 | + ], |
67 | 112 | ) |
68 | 113 | def test_apply_entity_integration(test_registry): |
| 114 | + |
69 | 115 | entity = Entity( |
70 | 116 | name="driver_car_id", |
71 | 117 | description="Car driver id", |
@@ -106,7 +152,11 @@ def test_apply_entity_integration(test_registry): |
106 | 152 | @pytest.mark.integration |
107 | 153 | @pytest.mark.parametrize( |
108 | 154 | "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 | + ], |
110 | 160 | ) |
111 | 161 | def test_apply_feature_view_integration(test_registry): |
112 | 162 | # Create Feature Views |
@@ -183,7 +233,11 @@ def test_apply_feature_view_integration(test_registry): |
183 | 233 | @pytest.mark.integration |
184 | 234 | @pytest.mark.parametrize( |
185 | 235 | "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 | + ], |
187 | 241 | ) |
188 | 242 | def test_apply_data_source_integration(test_registry: Registry): |
189 | 243 | validate_registry_data_source_apply(test_registry) |
0 commit comments