|
33 | 33 | from tests.integration.feature_repos.repo_configuration import ( |
34 | 34 | AVAILABLE_OFFLINE_STORES, |
35 | 35 | AVAILABLE_ONLINE_STORES, |
| 36 | + OFFLINE_STORE_TO_PROVIDER_CONFIG, |
36 | 37 | Environment, |
37 | 38 | TestData, |
38 | 39 | construct_test_environment, |
@@ -196,16 +197,24 @@ def pytest_generate_tests(metafunc: pytest.Metafunc): |
196 | 197 | """ |
197 | 198 | if "environment" in metafunc.fixturenames: |
198 | 199 | markers = {m.name: m for m in metafunc.definition.own_markers} |
199 | | - |
| 200 | + offline_stores = None |
200 | 201 | if "universal_offline_stores" in markers: |
201 | | - offline_stores = AVAILABLE_OFFLINE_STORES |
| 202 | + # Offline stores can be explicitly requested |
| 203 | + if "only" in markers["universal_offline_stores"].kwargs: |
| 204 | + offline_stores = [ |
| 205 | + OFFLINE_STORE_TO_PROVIDER_CONFIG.get(store_name) |
| 206 | + for store_name in markers["universal_offline_stores"].kwargs["only"] |
| 207 | + if store_name in OFFLINE_STORE_TO_PROVIDER_CONFIG |
| 208 | + ] |
| 209 | + else: |
| 210 | + offline_stores = AVAILABLE_OFFLINE_STORES |
202 | 211 | else: |
203 | 212 | # default offline store for testing online store dimension |
204 | 213 | offline_stores = [("local", FileDataSourceCreator)] |
205 | 214 |
|
206 | 215 | online_stores = None |
207 | 216 | if "universal_online_stores" in markers: |
208 | | - # Online stores are explicitly requested |
| 217 | + # Online stores can be explicitly requested |
209 | 218 | if "only" in markers["universal_online_stores"].kwargs: |
210 | 219 | online_stores = [ |
211 | 220 | AVAILABLE_ONLINE_STORES.get(store_name) |
@@ -240,40 +249,44 @@ def pytest_generate_tests(metafunc: pytest.Metafunc): |
240 | 249 | extra_dimensions.append({"go_feature_retrieval": True}) |
241 | 250 |
|
242 | 251 | configs = [] |
243 | | - for provider, offline_store_creator in offline_stores: |
244 | | - for online_store, online_store_creator in online_stores: |
245 | | - for dim in extra_dimensions: |
246 | | - config = { |
247 | | - "provider": provider, |
248 | | - "offline_store_creator": offline_store_creator, |
249 | | - "online_store": online_store, |
250 | | - "online_store_creator": online_store_creator, |
251 | | - **dim, |
252 | | - } |
253 | | - # temporary Go works only with redis |
254 | | - if config.get("go_feature_retrieval") and ( |
255 | | - not isinstance(online_store, dict) |
256 | | - or online_store["type"] != "redis" |
257 | | - ): |
258 | | - continue |
259 | | - |
260 | | - # aws lambda works only with dynamo |
261 | | - if ( |
262 | | - config.get("python_feature_server") |
263 | | - and config.get("provider") == "aws" |
264 | | - and ( |
| 252 | + if offline_stores: |
| 253 | + for provider, offline_store_creator in offline_stores: |
| 254 | + for online_store, online_store_creator in online_stores: |
| 255 | + for dim in extra_dimensions: |
| 256 | + config = { |
| 257 | + "provider": provider, |
| 258 | + "offline_store_creator": offline_store_creator, |
| 259 | + "online_store": online_store, |
| 260 | + "online_store_creator": online_store_creator, |
| 261 | + **dim, |
| 262 | + } |
| 263 | + # temporary Go works only with redis |
| 264 | + if config.get("go_feature_retrieval") and ( |
265 | 265 | not isinstance(online_store, dict) |
266 | | - or online_store["type"] != "dynamodb" |
267 | | - ) |
268 | | - ): |
269 | | - continue |
270 | | - |
271 | | - c = IntegrationTestRepoConfig(**config) |
272 | | - |
273 | | - if c not in _config_cache: |
274 | | - _config_cache[c] = c |
275 | | - |
276 | | - configs.append(_config_cache[c]) |
| 266 | + or online_store["type"] != "redis" |
| 267 | + ): |
| 268 | + continue |
| 269 | + |
| 270 | + # aws lambda works only with dynamo |
| 271 | + if ( |
| 272 | + config.get("python_feature_server") |
| 273 | + and config.get("provider") == "aws" |
| 274 | + and ( |
| 275 | + not isinstance(online_store, dict) |
| 276 | + or online_store["type"] != "dynamodb" |
| 277 | + ) |
| 278 | + ): |
| 279 | + continue |
| 280 | + |
| 281 | + c = IntegrationTestRepoConfig(**config) |
| 282 | + |
| 283 | + if c not in _config_cache: |
| 284 | + _config_cache[c] = c |
| 285 | + |
| 286 | + configs.append(_config_cache[c]) |
| 287 | + else: |
| 288 | + # No offline stores requested -> setting the default or first available |
| 289 | + offline_stores = [("local", FileDataSourceCreator)] |
277 | 290 |
|
278 | 291 | metafunc.parametrize( |
279 | 292 | "environment", configs, indirect=True, ids=[str(c) for c in configs] |
|
0 commit comments