Skip to content

Refactor tests#35

Draft
chaen wants to merge 5 commits into
DIRACGrid:masterfrom
chaen:refactor_tests
Draft

Refactor tests#35
chaen wants to merge 5 commits into
DIRACGrid:masterfrom
chaen:refactor_tests

Conversation

@chaen

@chaen chaen commented May 19, 2026

Copy link
Copy Markdown
Contributor

No description provided.

chaen and others added 5 commits May 20, 2026 15:20
This commit consolidates all shared test fixtures, constants, and utilities
into a single root conftest.py file, reducing code duplication across the
tests/, benchmark_tests/, and profiling_tests/ directories.

Changes:
- Created root conftest.py with all shared fixtures:
  - Server fixtures: moto_server, rustfs_server, minio_server, seaweedfs_server
  - Test infrastructure: pytest_addoption, test_results_dir
  - Timing utilities: _timeit, _timeit_async, _timeit_async_helper
  - Constants: BUCKET_NAME, OTHER_BUCKET_NAME, MISSING_BUCKET_NAME, etc.
  - Utility functions: random_file, b16_to_b64
  - Client fixtures: s3_clients, s3_clients_aio

- Updated subdirectory conftest.py files to re-export from root:
  - tests/conftest.py: re-exports constants and utilities for test imports
  - benchmark_tests/conftest.py: re-exports constants, utilities, and timing functions
  - profiling_tests/conftest.py: re-exports test infrastructure

- Added __init__.py files to tests/, benchmark_tests/, profiling_tests/
  to make them proper Python packages, ensuring relative imports work correctly

- Updated benchmark test files to use correct import paths

Benefits:
- Single source of truth for all shared fixtures
- Changes to server setup affect all test types consistently
- Reduced maintenance burden
- Eliminated duplicate rustfs_server fixture definition
- All 260 tests continue to collect and work correctly

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…rametrized file

IMPLEMENTATION:
- Created 20 operation-specific runner functions (10 sync, 10 async)
- Each runner handles: setup, warmup, benchmark execution, cleanup
- 2 parametrized test functions generate all 40 test cases:
  * test_benchmark_sync: 10 operations x 2 client patterns (plain, CM)
  * test_benchmark_async: 10 operations x 2 client patterns (plain, CM)
- Operations: generate_presigned_post, generate_presigned_url, head_bucket,
  head_object, create_bucket, delete_objects, put_object, list_objects,
  copy_object, upload_file

BENEFITS:
- Single source of truth for benchmark logic
- Adding new operations: add 2 runner functions
- Adding new modes: add parametrize values
- Consistent test structure across all benchmarks
- Easier maintenance and bug fixes

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…to test_clients.py

IMPLEMENTATION:
- Consolidated both sync and async unit tests into a single file
- Sync tests use s3_clients fixture (Client)
- Async tests use s3_clients_aio fixture (AsyncClient)
- Different bucket names for async tests to avoid conflicts
- Botocore exception handling: sync uses ClientError, async uses errorfactory.ClientError

OPERATIONS TESTED (sync + async variants):
- create_bucket, head_bucket (exists/not_found)
- head_object (exists/not_found/missing_key/missing_bucket)
- generate_presigned_post, generate_presigned_url
- put_object (basic/metadata/missing_bucket/missing_key)
- list_objects (empty/with_results/with_delimiter/missing_bucket)
- copy_object (string_source/dict_source/missing_bucket/missing_source)
- upload_file (basic/extra_args/acl_extra_args/missing_file)
- delete_objects (basic/quiet/missing_bucket/missing_objects)

BENEFITS:
- Single file for all unit tests (easier navigation and maintenance)
- Consistent test patterns across sync and async
- All tests still collected and working
- Reduced file count from 2 to 1

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Registers the 'moto' mark used in parametrized tests that only run
with the moto server backend.

This eliminates the PytestUnknownMarkWarning that appeared after
consolidating test files in Phase 3.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@chaen chaen force-pushed the refactor_tests branch from 40d5cfc to f813fe7 Compare May 20, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant