24
24
25
25
from arcticdb import LibraryOptions
26
26
from arcticdb .storage_fixtures .api import StorageFixture
27
- from arcticdb .storage_fixtures .azure import AzuriteStorageFixtureFactory
27
+ from arcticdb .storage_fixtures .azure import AzureContainer , AzuriteStorageFixtureFactory
28
28
from arcticdb .storage_fixtures .lmdb import LmdbStorageFixture
29
29
from arcticdb .storage_fixtures .s3 import (
30
+ BaseS3StorageFixtureFactory ,
30
31
MotoS3StorageFixtureFactory ,
31
32
MotoNfsBackedS3StorageFixtureFactory ,
32
33
NfsS3Bucket ,
@@ -75,7 +76,7 @@ def sym(request: pytest.FixtureRequest):
75
76
76
77
77
78
@pytest .fixture ()
78
- def lib_name (request : pytest .FixtureRequest ):
79
+ def lib_name (request : pytest .FixtureRequest ) -> str :
79
80
name = re .sub (r"[^\w]" , "_" , request .node .name )[:30 ]
80
81
return f"{ name } .{ random .randint (0 , 999 )} _{ datetime .utcnow ().strftime ('%Y-%m-%dT%H_%M_%S_%f' )} "
81
82
@@ -112,7 +113,7 @@ def pytest_generate_tests(metafunc):
112
113
# endregion
113
114
# region ======================================= Storage Fixtures =======================================
114
115
@pytest .fixture
115
- def lmdb_storage (tmp_path ) -> Iterator [LmdbStorageFixture ]:
116
+ def lmdb_storage (tmp_path ) -> Generator [LmdbStorageFixture , None , None ]:
116
117
with LmdbStorageFixture (tmp_path ) as f :
117
118
yield f
118
119
@@ -137,64 +138,64 @@ def lmdb_library_static_dynamic(request):
137
138
138
139
# ssl is enabled by default to maximize test coverage as ssl is enabled most of the times in real world
139
140
@pytest .fixture (scope = "session" )
140
- def s3_storage_factory () -> Iterator [MotoS3StorageFixtureFactory ]:
141
+ def s3_storage_factory () -> Generator [MotoS3StorageFixtureFactory , None , None ]:
141
142
with MotoS3StorageFixtureFactory (
142
143
use_ssl = SSL_TEST_SUPPORTED , ssl_test_support = SSL_TEST_SUPPORTED , bucket_versioning = False
143
144
) as f :
144
145
yield f
145
146
146
147
147
148
@pytest .fixture (scope = "session" )
148
- def s3_no_ssl_storage_factory () -> Iterator [MotoS3StorageFixtureFactory ]:
149
+ def s3_no_ssl_storage_factory () -> Generator [MotoS3StorageFixtureFactory , None , None ]:
149
150
with MotoS3StorageFixtureFactory (use_ssl = False , ssl_test_support = SSL_TEST_SUPPORTED , bucket_versioning = False ) as f :
150
151
yield f
151
152
152
153
153
154
@pytest .fixture (scope = "session" )
154
- def s3_ssl_disabled_storage_factory () -> Iterator [MotoS3StorageFixtureFactory ]:
155
+ def s3_ssl_disabled_storage_factory () -> Generator [MotoS3StorageFixtureFactory , None , None ]:
155
156
with MotoS3StorageFixtureFactory (use_ssl = False , ssl_test_support = False , bucket_versioning = False ) as f :
156
157
yield f
157
158
158
159
159
160
@pytest .fixture (scope = "session" )
160
- def s3_bucket_versioning_storage_factory () -> Iterator [MotoS3StorageFixtureFactory ]:
161
+ def s3_bucket_versioning_storage_factory () -> Generator [MotoS3StorageFixtureFactory , None , None ]:
161
162
with MotoS3StorageFixtureFactory (use_ssl = False , ssl_test_support = False , bucket_versioning = True ) as f :
162
163
yield f
163
164
164
165
165
166
@pytest .fixture (scope = "session" )
166
- def nfs_backed_s3_storage_factory () -> Iterator [MotoNfsBackedS3StorageFixtureFactory ]:
167
+ def nfs_backed_s3_storage_factory () -> Generator [MotoNfsBackedS3StorageFixtureFactory , None , None ]:
167
168
with MotoNfsBackedS3StorageFixtureFactory (use_ssl = False , ssl_test_support = False , bucket_versioning = False ) as f :
168
169
yield f
169
170
170
171
171
172
@pytest .fixture
172
- def s3_storage (s3_storage_factory ) -> Iterator [S3Bucket ]:
173
+ def s3_storage (s3_storage_factory ) -> Generator [S3Bucket , None , None ]:
173
174
with s3_storage_factory .create_fixture () as f :
174
175
yield f
175
176
176
177
177
178
@pytest .fixture
178
- def nfs_backed_s3_storage (nfs_backed_s3_storage_factory ) -> Iterator [NfsS3Bucket ]:
179
+ def nfs_backed_s3_storage (nfs_backed_s3_storage_factory ) -> Generator [NfsS3Bucket , None , None ]:
179
180
with nfs_backed_s3_storage_factory .create_fixture () as f :
180
181
yield f
181
182
182
183
183
184
@pytest .fixture
184
- def s3_no_ssl_storage (s3_no_ssl_storage_factory ) -> Iterator [S3Bucket ]:
185
+ def s3_no_ssl_storage (s3_no_ssl_storage_factory ) -> Generator [S3Bucket , None , None ]:
185
186
with s3_no_ssl_storage_factory .create_fixture () as f :
186
187
yield f
187
188
188
189
189
190
@pytest .fixture
190
- def s3_ssl_disabled_storage (s3_ssl_disabled_storage_factory ) -> Iterator [S3Bucket ]:
191
+ def s3_ssl_disabled_storage (s3_ssl_disabled_storage_factory ) -> Generator [S3Bucket , None , None ]:
191
192
with s3_ssl_disabled_storage_factory .create_fixture () as f :
192
193
yield f
193
194
194
195
195
196
# s3 storage is picked just for its versioning capabilities for verifying arcticdb atomicity
196
197
@pytest .fixture
197
- def s3_bucket_versioning_storage (s3_bucket_versioning_storage_factory ) -> Iterator [S3Bucket ]:
198
+ def s3_bucket_versioning_storage (s3_bucket_versioning_storage_factory ) -> Generator [S3Bucket , None , None ]:
198
199
with s3_bucket_versioning_storage_factory .create_fixture () as f :
199
200
s3_admin = f .factory ._s3_admin
200
201
bucket = f .bucket
@@ -214,26 +215,31 @@ def mock_s3_storage_with_error_simulation(mock_s3_storage_with_error_simulation_
214
215
215
216
216
217
@pytest .fixture (scope = "session" )
217
- def real_s3_storage_factory ():
218
+ def real_s3_storage_factory () -> BaseS3StorageFixtureFactory :
218
219
return real_s3_from_environment_variables (shared_path = False , additional_suffix = f"{ random .randint (0 , 999 )} _{ datetime .utcnow ().strftime ('%Y-%m-%dT%H_%M_%S_%f' )} " )
219
220
220
221
221
222
@pytest .fixture (scope = "session" )
222
- def real_s3_shared_path_storage_factory ():
223
+ def real_s3_shared_path_storage_factory () -> BaseS3StorageFixtureFactory :
223
224
return real_s3_from_environment_variables (shared_path = True , additional_suffix = f"{ random .randint (0 , 999 )} _{ datetime .utcnow ().strftime ('%Y-%m-%dT%H_%M_%S_%f' )} " )
224
225
225
226
226
227
@pytest .fixture (scope = "session" )
227
- def real_s3_storage_without_clean_up (real_s3_shared_path_storage_factory ):
228
+ def real_s3_storage_without_clean_up (real_s3_shared_path_storage_factory ) -> S3Bucket :
228
229
return real_s3_shared_path_storage_factory .create_fixture ()
229
230
230
231
231
232
@pytest .fixture
232
- def real_s3_storage (real_s3_storage_factory ):
233
+ def real_s3_storage (real_s3_storage_factory ) -> Generator [ S3Bucket , None , None ] :
233
234
with real_s3_storage_factory .create_fixture () as f :
234
235
yield f
235
236
236
237
238
+ @pytest .fixture
239
+ def real_s3_library (real_s3_storage , lib_name ) -> Library :
240
+ return real_s3_storage .create_arctic ().create_library (lib_name )
241
+
242
+
237
243
@pytest .fixture (scope = "session" ) # Config loaded at the first ArcticDB binary import, so we need to set it up before any tests
238
244
def real_s3_sts_storage_factory ():
239
245
sts_test_credentials_prefix = os .getenv ("ARCTICDB_REAL_S3_STS_TEST_CREDENTIALS_POSTFIX" , f"{ random .randint (0 , 999 )} _{ datetime .utcnow ().strftime ('%Y-%m-%dT%H_%M_%S_%f' )} " )
@@ -258,32 +264,32 @@ def real_s3_sts_storage_factory():
258
264
259
265
260
266
@pytest .fixture
261
- def real_s3_sts_storage (real_s3_sts_storage_factory ):
267
+ def real_s3_sts_storage (real_s3_sts_storage_factory ) -> Generator [ BaseS3StorageFixtureFactory , None , None ] :
262
268
with real_s3_sts_storage_factory .create_fixture () as f :
263
269
yield f
264
270
265
271
266
272
# ssl cannot be ON by default due to azurite performance constraints https://github.com/man-group/ArcticDB/issues/1539
267
273
@pytest .fixture (scope = "session" )
268
- def azurite_storage_factory ():
274
+ def azurite_storage_factory () -> Generator [ AzuriteStorageFixtureFactory , None , None ] :
269
275
with AzuriteStorageFixtureFactory (use_ssl = False , ssl_test_support = SSL_TEST_SUPPORTED ) as f :
270
276
yield f
271
277
272
278
273
279
@pytest .fixture
274
- def azurite_storage (azurite_storage_factory : AzuriteStorageFixtureFactory ):
280
+ def azurite_storage (azurite_storage_factory : AzuriteStorageFixtureFactory ) -> Generator [ AzureContainer , None , None ] :
275
281
with azurite_storage_factory .create_fixture () as f :
276
282
yield f
277
283
278
284
279
285
@pytest .fixture (scope = "session" )
280
- def azurite_ssl_storage_factory ():
286
+ def azurite_ssl_storage_factory () -> Generator [ AzuriteStorageFixtureFactory , None , None ] :
281
287
with AzuriteStorageFixtureFactory (use_ssl = True , ssl_test_support = SSL_TEST_SUPPORTED ) as f :
282
288
yield f
283
289
284
290
285
291
@pytest .fixture
286
- def azurite_ssl_storage (azurite_ssl_storage_factory : AzuriteStorageFixtureFactory ):
292
+ def azurite_ssl_storage (azurite_ssl_storage_factory : AzuriteStorageFixtureFactory ) -> Generator [ AzureContainer , None , None ] :
287
293
with azurite_ssl_storage_factory .create_fixture () as f :
288
294
yield f
289
295
@@ -301,7 +307,7 @@ def mongo_storage(mongo_server):
301
307
302
308
303
309
@pytest .fixture
304
- def mem_storage () -> Iterator [InMemoryStorageFixture ]:
310
+ def mem_storage () -> Generator [InMemoryStorageFixture , None , None ]:
305
311
with InMemoryStorageFixture () as f :
306
312
yield f
307
313
@@ -357,12 +363,12 @@ def arctic_client_lmdb(request, encoding_version) -> Arctic:
357
363
358
364
359
365
@pytest .fixture
360
- def arctic_library (arctic_client , lib_name ) -> Arctic :
366
+ def arctic_library (arctic_client , lib_name ) -> Library :
361
367
return arctic_client .create_library (lib_name )
362
368
363
369
364
370
@pytest .fixture
365
- def arctic_library_lmdb (arctic_client_lmdb , lib_name ):
371
+ def arctic_library_lmdb (arctic_client_lmdb , lib_name ) -> Library :
366
372
return arctic_client_lmdb .create_library (lib_name )
367
373
368
374
@@ -418,17 +424,17 @@ def s3_store_factory_mock_storage_exception(lib_name, s3_storage):
418
424
419
425
420
426
@pytest .fixture
421
- def s3_store_factory (lib_name , s3_storage ):
427
+ def s3_store_factory (lib_name , s3_storage ) -> NativeVersionStore :
422
428
return s3_storage .create_version_store_factory (lib_name )
423
429
424
430
425
431
@pytest .fixture
426
- def s3_no_ssl_store_factory (lib_name , s3_no_ssl_storage ):
432
+ def s3_no_ssl_store_factory (lib_name , s3_no_ssl_storage ) -> NativeVersionStore :
427
433
return s3_no_ssl_storage .create_version_store_factory (lib_name )
428
434
429
435
430
436
@pytest .fixture
431
- def mock_s3_store_with_error_simulation_factory (lib_name , mock_s3_storage_with_error_simulation ):
437
+ def mock_s3_store_with_error_simulation_factory (lib_name , mock_s3_storage_with_error_simulation ) -> NativeVersionStore :
432
438
return mock_s3_storage_with_error_simulation .create_version_store_factory (lib_name )
433
439
434
440
@@ -438,12 +444,12 @@ def real_s3_store_factory(lib_name, real_s3_storage) -> Callable[..., NativeVers
438
444
439
445
440
446
@pytest .fixture
441
- def real_s3_sts_store_factory (lib_name , real_s3_sts_storage ):
447
+ def real_s3_sts_store_factory (lib_name , real_s3_sts_storage ) -> NativeVersionStore :
442
448
return real_s3_sts_storage .create_version_store_factory (lib_name )
443
449
444
450
445
451
@pytest .fixture
446
- def azure_store_factory (lib_name , azurite_storage ):
452
+ def azure_store_factory (lib_name , azurite_storage ) -> NativeVersionStore :
447
453
return azurite_storage .create_version_store_factory (lib_name )
448
454
449
455
0 commit comments