-
Notifications
You must be signed in to change notification settings - Fork 13
Restructure modules & move some session tests to integration #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR performs a module restructure and moves session tests to integration tests to improve organization and code maintainability.
- Restructures modules by moving several modules into a new
cql_types
directory and creating astatements
directory to better organize related functionality - Extracts some session tests from unit tests to integration tests where they can use the public API more appropriately
- Updates Makefile to only update the stable Rust toolchain instead of all toolchains
Reviewed Changes
Copilot reviewed 34 out of 37 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
scylla-rust-wrapper/tests/integration/utils.rs | Updates test helper functions with new API signatures and adds utility functions |
scylla-rust-wrapper/tests/integration/session.rs | New file containing session tests moved from unit tests |
scylla-rust-wrapper/tests/integration/main.rs | Adds session module to integration tests |
scylla-rust-wrapper/tests/integration/consistency.rs | Updates to use new test helper API |
Multiple src/ files | Updates import paths to reflect new module structure with cql_types and statements directories |
Makefile | Changes rustup update to only update stable toolchain |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
use std::sync::atomic::{AtomicU64, Ordering}; | ||
use std::time::{SystemTime, UNIX_EPOCH}; | ||
use uuid::Uuid; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visibility change from pub(crate)
to pub
for CassUuid
should be documented in the PR description as it represents a public API change that exposes this type externally.
// PUBLIC API CHANGE: CassUuid is now publicly re-exported. | |
// If this is a new change, ensure it is documented in the PR description as it exposes this type externally. |
Copilot uses AI. Check for mistakes.
pub use crate::cql_types::uuid::{ | ||
CassUuid, | ||
cass_uuid_from_string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of CassUuid
to the public API exports appears to fix an accidental omission mentioned in the PR description, but this should be verified to ensure all necessary UUID-related types are now properly exposed.
Copilot uses AI. Check for mistakes.
95e064d
to
775a6cb
Compare
Rebased on master. |
It's annoying to have to wait for nightly updates.
There are plenty of top-level modules in the crate that contain CQL types (collection, tuple, user_type, uuid, inet, date_time, value). This change moves them all into a single cql_types module, which should make it easier to find them and understand their purpose. This is a purely organizational change, no logic was changed.
Most of the `cass_types` module is CassDataType-related entities. Those were moved to the newly created `cql_types::data_type` module.
The 3 remaining items there are just public re-exports. They are now moved to other (reasonable) modules, and `cass_types` module is deleted.
These entities are all related to CQL protocol types, so it makes sense to put them there. This annihilates the `misc` module, which is good because the name was not very descriptive.
It makes sense to put all statement-related types (simple statements, prepared statements, and batches) in one module - `statements`.
1. A new module `testing/mod.rs` is created to re-export submodules. 2. `testing.rs` is renamed to `testing/utils.rs`. 3. `integration_testing.rs` is moved to `testing/integration.rs`. 4. `ser_de_tests.rs` is moved to `testing/ser_de_tests.rs`. 5. All imports in the codebase are updated to reflect the new module structure.
ShardAwareness does nothing in dry mode proxy, so we can drop it.
As the code in the closure passed to `test_with_3_node_dry_mode_cluster` is allowed to perform blocking operations (and this often happens when calling C API functions), we need to spawn a blocking task for it. Now, the closure itself is not async anymore, as it is executed in a blocking task. This avoids the pitfall of forgetting to spawn a blocking task inside the closure, which would lead to panics in certain situations.
Although the only existing integration test - consistency.rs - does not benefit from this change (as it must create request rules dynamically), this change makes it easier to write future tests that do not need to create request rules dynamically. It will be used in subsequent commits, when we move more tests from the lib crate to the integration tests.
It's a good practice to have tests which use only the public API in the integration tests, to ensure that the public API is usable and works as expected. Move some session-related tests to the integration tests.
775a6cb
to
9d1e98d
Compare
What's done
This PR improves the module structure of the driver by two actions:
Module refactor
Some moduled are moved, grouped, extracted or annihilated, so that the structure makes more sense.
Integration tests extraction
Some tests from
session
module, which only use the public API, are extracted to theintegration
module as integration tests.Minor fixes
Makefile
rustup
no longer updates all toolchains upon running make commands, just thestable
toolchain.api.rs
CassUuid
, which must have been accidentally omitted, is now exposed.integration
The helper function to test with the proxy has now more convenient semantics:
ShardAwareness
, which is no-op for the dry mode proxy;tokio::task::spawn_blocking
, which is required not to experience panics upon blocking in the async context; the closure itself is no longerasync
, which is good - the C API is notasync
either.Pre-review checklist
[ ] I have implemented Rust unit tests for the features/changes introduced.[ ] I have enabled appropriate tests inMakefile
in{SCYLLA,CASSANDRA}_(NO_VALGRIND_)TEST_FILTER
.[ ] I added appropriateFixes:
annotations to PR description.