Commit f44ca91
authored
Integration test reorg and build sharding (#540)
## Summary
This PR implements a custom pytest plugin for test sharding, allowing
tests to be automatically distributed across multiple CI jobs for
parallel execution. This replaces the previous manual directory-based
test splitting approach with a more flexible, hash-based distribution
system. Additionally, integration tests have been reorganized into
top-level folders that group tests by the client type and setup
requirements needed.
This should bring down the total CI runtime to ~8 minutes or less.
## Changes
### Core Implementation
- **New pytest plugin** (`tests/pytest_shard.py`):
- Implements `pytest_addoption` hook to add `--splits` and `--group`
command-line options
- Implements `pytest_collection_modifyitems` hook to filter tests based
on shard assignment
- Uses hash-based distribution (MD5 hash of test node ID) for
deterministic test assignment
- Supports environment variables `PYTEST_SPLITS` and `PYTEST_GROUP` as
alternatives to command-line options
- Includes validation for shard parameters with helpful error messages
- **Plugin registration** (`tests/conftest.py`):
- Registers the plugin globally so it's available for all test runs
- Plugin is automatically loaded when running pytest
### CI Workflow Updates
- **Updated `.github/workflows/testing-integration.yaml`**:
- Replaced manual directory-based test splitting with automatic sharding
- `rest_sync` tests: Now uses 8 shards (was manually split by directory)
- `rest_asyncio` tests: Now uses 5 shards (was manually split by
directory)
- `grpc` tests: No sharding (runs all tests in single job, including
`tests/integration/rest_sync/db/data` with `USE_GRPC='true'`)
- **Updated `.github/actions/run-integration-test/action.yaml`**:
- Added `pytest_splits` and `pytest_group` input parameters
- Updated test execution to pass sharding arguments when provided
### Test Reorganization
- **Integration tests reorganized by client type**
(`tests/integration/`):
- **`rest_sync/`**: Tests using the synchronous REST client
(`Pinecone()`)
- Uses standard `Index()` objects for database operations
- Supports optional GRPC mode via `USE_GRPC='true'` environment variable
- Contains subdirectories for `db/` (control and data operations),
`inference/`, and `admin/` tests
- **`rest_asyncio/`**: Tests using the asynchronous REST client
(`Pinecone().IndexAsyncio()`)
- Uses async fixtures and `IndexAsyncio()` objects
- Requires `pytest-asyncio` for async test execution
- Contains subdirectories for `db/` (control and data operations) and
`inference/` tests
- **`grpc/`**: Tests using the GRPC client (`PineconeGRPC()`)
- Uses `PineconeGRPC()` client and `GRPCIndex` objects
- Contains `db/data/` tests for GRPC-specific functionality
- This organization makes it clear which client type each test requires
and simplifies fixture setup
### Bug Fixes
- **Fixed race condition in test cleanup**
(`tests/integration/rest_sync/db/control/pod/conftest.py`):
- Added `NotFoundException` handling in `attempt_delete_index` function
- Prevents teardown errors when index is deleted between `has_index`
check and `describe_index` call
### Testing
- **Unit tests** (`tests/unit/test_pytest_shard.py`):
- Tests for hash-based distribution logic
- Tests for validation and error handling
- Tests for deterministic shard assignment
- Tests for edge cases (single shard, environment variables, etc.)
- Tests gracefully handle `testdir` limitations (plugin loading in
isolated environments)
### Documentation
- **Updated `docs/maintainers/testing-guide.md`**:
- Added "Test Sharding" section with usage examples
- Documented command-line options and environment variables
- Explained how sharding works and its use in CI
- Documented actual shard counts used in CI workflows
- Fixed broken link to `testing-integration.yaml`
## Benefits
1. **Automatic test distribution**: Tests are automatically distributed
across shards using a deterministic hash algorithm, eliminating the need
to manually maintain directory-based splits
2. **Better load balancing**: Hash-based distribution ensures more even
test distribution across shards compared to directory-based splitting
3. **Easier maintenance**: No need to manually update CI workflows when
test files are added, removed, or reorganized
4. **Flexibility**: Shard counts can be easily adjusted in CI workflows
without code changes
5. **Deterministic**: Same test always goes to the same shard, making
debugging easier
6. **Clear test organization**: Tests are grouped by client type, making
it immediately clear which setup and fixtures are needed for each test
7. **Simplified fixture management**: Each client type has its own
`conftest.py` with appropriate fixtures, reducing complexity and
potential conflicts
## Usage
### Command-line
```sh
pytest tests/integration/rest_sync --splits=8 --group=1
```
### Environment variables
```sh
export PYTEST_SPLITS=8
export PYTEST_GROUP=1
pytest tests/integration/rest_sync
```
## Testing
- Plugin works correctly in real pytest environment
- CI workflows updated and ready for use
## Notes
- The plugin is automatically available when running pytest (no
installation needed)
- Shard counts in CI can be adjusted based on test suite size and CI
capacity1 parent d8d68bf commit f44ca91
File tree
199 files changed
+7020
-1784
lines changed- .github
- actions
- index-create
- run-integration-test
- setup-poetry
- test-dependency-asyncio-rest
- test-dependency-grpc
- test-dependency-rest
- scripts
- workflows
- docs/maintainers
- pinecone
- admin
- db_data
- tests
- integration_manual
- rest_asyncio
- db
- control
- resources
- backup
- restore_job
- rest_sync
- db
- control
- resources
- backup
- collections
- restore_job
- data
- proxy_config
- logs
- integration
- control_asyncio/resources/index
- data
- grpc
- db
- data
- helpers
- proxy_config/.mitm
- proxy1
- proxy2
- rest_asyncio
- db
- control
- resources
- index
- data
- inference
- rest_sync
- admin
- db
- control
- pod
- resources
- index
- serverless
- data
- inference
- plugins
- unit
- db_control
- db_data
- openapi_support
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
199 files changed
+7020
-1784
lines changedLarge diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| |||
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| 63 | + | |
55 | 64 | | |
56 | 65 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
58 | 28 | | |
59 | 29 | | |
60 | 30 | | |
| |||
74 | 44 | | |
75 | 45 | | |
76 | 46 | | |
77 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
78 | 65 | | |
79 | 66 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
84 | 72 | | |
| 73 | + | |
85 | 74 | | |
| 75 | + | |
86 | 76 | | |
87 | 77 | | |
88 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
22 | 40 | | |
23 | 41 | | |
24 | 42 | | |
| |||
33 | 51 | | |
34 | 52 | | |
35 | 53 | | |
36 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
37 | 66 | | |
38 | 67 | | |
39 | 68 | | |
| 69 | + | |
| 70 | + | |
40 | 71 | | |
41 | | - | |
| 72 | + | |
| 73 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
36 | 55 | | |
37 | 56 | | |
38 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
0 commit comments