Skip to content

Request coordinator tests #1352

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

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

wprzytula
Copy link
Collaborator

@wprzytula wprzytula commented May 10, 2025

Stacked on: #1351

Adds a test case for exposed Coordinator. The test checks that if a node is enforced as the coordinator of a request, the Coordinator struct exposed on the request result (QueryResult and QueryPager) contains that Node.

Fixes: #1347

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • [ ] I have provided docstrings for the public items that I want to introduce.
  • [ ] I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

wprzytula added 30 commits May 10, 2025 07:42
`test_shard_out_of_range()` was put in `load_balancing.rs`, while
`shards.rs` seems to be a much better place for it.
The only test that is left there regards latency latency_awareness,
so such rename makes sense. And module_inception is no longer there.
Vector type is definitely more about a CQL collection than about
the Session.
…ns.rs

The test is definitely more about CQL collections than about
the Session.
This test is about load balancing more than about the Session.
This obviously belongs to `metadata` category.
These are tests that simply check that driver keeps metadata of some
kind. As these tests are similar in their concept, I believe it makes
sense to have them all in one file.
Materialized views test suits metadata/contents.rs as well.
Having read the contents of the test, I was confused what it actually
tests. `git blame` shed some light, so I pasted the commit message as
a doc comment: "This test case indicates that we support enough CQL
types to parse schema keyspace information.". A-ha!

But we no longer type check nor deserialize rows eagerly!
The deserialization refactor seems to have rendered this test case
useless. To fix this, I materialise all rows as Row, which actually
performs the type check and deserialization. This way I virtually
bring back the old, intended semantics of this test.
Test `test_unusual_valuelists()` is moved from `session/session.rs`
to `types/valuelists.rs`.
As `Session::get_keyspace()` returns the name of the keyspace that was
set in `Session::use_keyspace()`, it makes sense for tests of both
functionalities to reside in the same place.
Test `test_keyspaces_to_fetch()` is extracted from `session/session.rs`
and now comprises `metadata/keyspace_filtering.rs`.
Tests `tests_timestamp()` and `test_timestamp_generator()` are extracted
from `session/session.rs` into `statement/timestamps.rs`
There is a bunch of tests which check that statements are reprepared
if the DB responds with DbError::Unprepared. They are extracted from
`session/session.rs` into `statements/unprepared_reprepare.rs`.
Test `test_unprepared_statement()` is extracted into
`statements/unprepared/basic.rs`.
Test `test_prepared_statement()` is extracted into
`statements/prepared/basic.rs`.
Test `test_prepared_batch()` is extracted into
`statements/batch/basic.rs`.
The test is extracted into `statements/batch/counter_batch.rs`.
The test is extracted into `statements/batch/multi_table_batch.rs`.
The test is extracted into
`statements/prepared/prepared_inherits_config.rs`.
The test is about creating a new Session, so it fits there well.
Tests:
- test_iter_works_when_retry_policy_returns_ignore_write_error()
- test_iter_methods_with_modification_statements()
are extracted into `session/pager.rs`.
wprzytula added 12 commits May 10, 2025 10:13
The test is extracted into `statements/prepared/partitioner.rs`.
The test is extracted into `statements/prepared/token_calculation.rs`.
The test is extracted to `statements/request_timeout.rs`.
The test case brings no value to our suite. There are plenty of other
tests that call `Session::await_schema_agreement()`.
The test is extracted to `statements/named_bind_markers.rs`.
The remaining two tests in session.rs:
- test_db_errors(),
- test_rate_limit_exceeded_exception(),
regard DB errors, so the file is renamed accordingly.

This finishes dissolution of the old overloaded `session_test.rs` module.
Hooray!
The test is extracted into `prepared/col_specs.rs`.
The only tests remaining in `statement.rs` are about coordinator
enforcing, so the file is renamed accordingly.
The test is strictly about unprepared statements, so it's moved to
the corresponding module.
The test is strictly about prepared statements, so it's moved to the
corresponding module.
The file will soon contain more coordinator-related tests than only
enforcing-related ones.
The test checks that if a node is enforced as the coordinator
of a request, the [Coordinator] struct exposed on the request result
(`QueryResult` and `QueryPager`) contains that `Node`.

Fixes: scylladb#1347
@wprzytula wprzytula requested review from Lorak-mmk and muzarski May 10, 2025 09:14
@wprzytula wprzytula self-assigned this May 10, 2025
@wprzytula wprzytula added the area/testing Related to tests - unit, integration, or even out of repo label May 10, 2025
@wprzytula wprzytula added this to the 1.2.0 milestone May 10, 2025
Copy link

cargo semver-checks found no API-breaking changes in this PR.
Checked commit: 414f7ef

Copy link
Collaborator

@Lorak-mmk Lorak-mmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to test query_* methods but not execute_* methods?

Note: Do not merge, the prerequisite PR is not merged yet.

@wprzytula
Copy link
Collaborator Author

Is there a reason to test query_* methods but not execute_* methods?

No, I can test execute_* too.

@Lorak-mmk Lorak-mmk modified the milestones: 1.2.0, 1.3.0 May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Related to tests - unit, integration, or even out of repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exposed Coordinator: write tests
3 participants