-
Notifications
You must be signed in to change notification settings - Fork 123
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
tests: add integration tests for batch statements #1226
base: branch-hackathon
Are you sure you want to change the base?
Conversation
|
e8fb95f
to
b5b6185
Compare
I intended to open a PR instead of pushing to your branch directly, sorry @dimakr... |
ca37183
to
947c483
Compare
@wprzytula I've made the changes as per the comments above |
947c483
to
bd00e4b
Compare
Turned out that we have a few batch tests in scylla/tests/integration/session.rs test suite. |
/// TODO: Remove #[ignore] once LWTs are supported with tablets. | ||
#[tokio::test] | ||
#[ignore] | ||
async fn test_cas_batch() { | ||
setup_tracing(); | ||
let test_name = String::from("test_cas_batch"); |
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.
I guess you got the inspiration from test_lwt_optimization_works_with_tablets
. The difference is that this test does not depend on tablets, while test_lwt_optimization_works_with_tablets
does.
Please disable tablets explicitly during keyspace creation. This will allow the test to actually run.
6ec6b38
to
c53c53b
Compare
scylla/tests/integration/batch.rs
Outdated
// Scylla returns 4 columns, but Cassandra returns only 1 | ||
let is_scylla: bool = batch_deserializer.column_specs().len() == 4; | ||
|
||
if is_scylla { | ||
test_batch_lwts_for_scylla(&session, &batch, &batch_deserializer, &test_name).await; | ||
} else { | ||
test_batch_lwts_for_cassandra(&session, &batch, &batch_deserializer, &test_name).await; | ||
} |
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.
🔧 Please provide links to documentation explaining this difference.
c53c53b
to
2c7d920
Compare
@wprzytula @Lorak-mmk addressed the last comments. |
In commit "tests: add integration tests for batch statements" some tests are still marked with |
scylla/tests/common/utils.rs
Outdated
SystemTime::now() | ||
.duration_since(UNIX_EPOCH) | ||
.unwrap() | ||
.as_secs(), | ||
.as_micros(), |
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.
I don't see why this change is necessary.
Notice that the keyspace name also utilizes the global counter.
The only way I see to acutally get a collision is to have 2 copies of the repository, run the same test in both, and be extremely unlucky for them to clash both on the counter and the timestamp. This seems extremely unlikely.
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.
This is how the batch tests fail. if as_sec()
is used to generate suffix for KS name:
──── STDERR: scylla::integration batch::test_batch_lwts
thread 'batch::test_batch_lwts' panicked at scylla/tests/integration/batch.rs:506:76:
called `Result::unwrap()` on an `Err` value: LastAttemptError(DbError(Invalid, "Cannot use LightWeight Transactions for table test_rust_1739527888_0.test_counter_batch: LWT is not yet supported with tablets"))
...
──── STDERR: scylla::integration batch::test_fail_counter_batch_with_non_counter_increment
thread 'batch::test_fail_counter_batch_with_non_counter_increment' panicked at scylla/tests/integration/batch.rs:54:14:
called `Result::unwrap()` on an `Err` value: LastAttemptError(DbError(Invalid, "Cannot use the 'counter' type for table test_rust_1739527888_0.counter1: Counters are not yet supported with tablets"))
...
The batch
test suite uses the common helper to create a KS and table. Then when each test is executed and calls the helper it would try to get its own, unique, KS name. But tests in this test suite are executed within 1 second so the unique_keyspace_name
cannot guarantee unique value. And in this particular test suite part of tests require KS with tablets disabled, so the existing KS cannot be reused.
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.
Probably for the affected tests here some other approach could be used, i.e. do not useunique_keyspace_name
, but some dedicated KS name generation logic. But I thought that the symptom might pop up in other tests as well, and this change would help.
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.
But tests in this test suite are executed within 1 second so the unique_keyspace_name cannot guarantee unique value.
Please the the source code of unique_keyspace_name. It uses an atomic counter to guarantee uniqueness.
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.
──── STDERR: scylla::integration batch::test_batch_lwts thread 'batch::test_batch_lwts' panicked at scylla/tests/integration/batch.rs:506:76: called `Result::unwrap()` on an `Err` value: LastAttemptError(DbError(Invalid, "Cannot use LightWeight Transactions for table test_rust_1739527888_0.test_counter_batch: LWT is not yet supported with tablets")) ... ──── STDERR: scylla::integration batch::test_fail_counter_batch_with_non_counter_increment thread 'batch::test_fail_counter_batch_with_non_counter_increment' panicked at scylla/tests/integration/batch.rs:54:14: called `Result::unwrap()` on an `Err` value: LastAttemptError(DbError(Invalid, "Cannot use the 'counter' type for table test_rust_1739527888_0.counter1: Counters are not yet supported with tablets")) ...
Weird, the counter is 0 for both of them. How are you running the tests?
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.
It fails when specific module is executed, e.g.:
> cargo nextest r -E 'test(/^batch::/)'
But it is ok when all tests are executed at once (make test, etc.). So I'll drop that change.
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.
cargo nextest
is not something we ever tested, nor recommended in CONTRIBUTING.md
.
It uses process-per-test architecture, making a counter that guarantees uniqueness useless - because each process, and thus test, will have its own copy of it, thus always using 0.
2c7d920
to
6974ed0
Compare
@Lorak-mmk the tablets disabling was done as part of "tests: move batch statements tests to batch.rs module" commit. I've adjusted that commit message to clearly mention this. |
Is there a reason for doing it in the commit that moves tests, instead of doing it that way from the beginning? |
6974ed0
to
650ec58
Compare
There was a bit of mess in the series of commits in this PR from the beginning after a commit from another person was accidentally pushed in (that one is squashed eventually). But to avoid further issues I've made 'disable tablets'-change in the subsequent commit. |
Two things:
|
It was OK, but due to this number of nit related changes one of recent rebases went wrong. Will correct it |
New batch statement test cases are moved to exising batch.rs test suite. Additionally, the test cases for LWT and counter tables are unskipped and adjusted to use keyspace with tablets disabled. This allows executing the underlying test scenarios even though LWT and counters are not yet supported with tablets.
650ec58
to
fc9def4
Compare
@Lorak-mmk This time should be ok - got rid of |
Test cases/ideas are inspired by Java driver batch statements tests.
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.