Skip to content
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

Add integration tests for query_unpaged and execute_unpaged APIs #1228

Open
wants to merge 1 commit into
base: branch-hackathon
Choose a base branch
from

Conversation

vponomaryov
Copy link

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.

Copy link

github-actions bot commented Feb 11, 2025

cargo semver-checks found no API-breaking changes in this PR! 🎉🥳
Checked commit: 4fb2684

scylla/tests/integration/query_result.rs Outdated Show resolved Hide resolved
scylla/tests/integration/query_result.rs Outdated Show resolved Hide resolved
Comment on lines 377 to 411
async fn unpaged_error(use_prepared_statements: bool) {
let table_name = if use_prepared_statements {
"execute_unpaged"
} else {
"query_unpaged"
};
let session: Session = create_session(table_name).await;
session.await_schema_agreement().await.unwrap();

let query_result: Result<QueryResult, ExecutionError>;
if use_prepared_statements {
let prepared_statement = session
.prepare(format!("SELECT * FROM {}", table_name))
.await
.unwrap();
// NOTE: drop table to make the main query return error
session
.ddl(format!("DROP TABLE IF EXISTS {}", table_name))
.await
.unwrap();
query_result = session.execute_unpaged(&prepared_statement, &[]).await;
} else {
let select_query = Query::new(format!("SELECT * FROM fake{}", table_name));
query_result = session.query_unpaged(select_query, &[]).await;
}
match query_result {
Ok(_) => panic!("Unexpected success"),
Err(err) => println!("Table not found as expected: {:?}", err),
}
}

#[tokio::test]
async fn test_query_unpaged_error() {
unpaged_error(false).await
}

#[tokio::test]
async fn test_execute_unpaged_error() {
unpaged_error(true).await
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to not make tests unnecessarily slow, which means reducing the amount of schema changes.
Those 2 tests could be merged into one which:

  • Creates KS and table
  • Makes the unprepared check (because it does not remove the table)
  • Makes the prepared check.

Copy link
Author

Choose a reason for hiding this comment

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

Answered below.

scylla/tests/integration/query_result.rs Outdated Show resolved Hide resolved
Comment on lines +418 to +461
#[tokio::test]
async fn test_query_unpaged_no_rows() {
check_query_unpaged(0, false).await;
}

#[tokio::test]
async fn test_query_unpaged_one_row() {
check_query_unpaged(1, false).await;
}

#[tokio::test]
async fn test_query_unpaged_ten_rows() {
check_query_unpaged(10, false).await;
}

#[tokio::test]
async fn test_query_unpaged_hundred_rows() {
check_query_unpaged(100, false).await;
}

#[tokio::test]
async fn test_query_unpaged_thousand_rows() {
check_query_unpaged(1000, false).await;
}

#[tokio::test]
async fn test_execute_unpaged_no_rows() {
check_query_unpaged(0, true).await;
}

#[tokio::test]
async fn test_execute_unpaged_one_row() {
check_query_unpaged(1, true).await;
}

#[tokio::test]
async fn test_execute_unpaged_ten_rows() {
check_query_unpaged(10, true).await;
}

#[tokio::test]
async fn test_execute_unpaged_hundred_rows() {
check_query_unpaged(100, true).await;
}

#[tokio::test]
async fn test_execute_unpaged_thousand_rows() {
check_query_unpaged(1000, true).await;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Those tests could be merged into one test (or two - one for prepared, one for unprepared), in order to re-use the created session and table.

Copy link
Author

Choose a reason for hiding this comment

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

All the 23 tests in this module take about 5 seconds not considering the compilation time.

Current approach is the test isolation, reusing session and tables we create side-effects.
Having 5 seconds for 23 tests I don't think that the gained test run time worth the side-effects.

Then, existing 11 tests follow the same approach - isolated logic. Which, I think, is proper approach for "tests".

Copy link
Collaborator

@Lorak-mmk Lorak-mmk Feb 12, 2025

Choose a reason for hiding this comment

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

5 seconds of execution time is not short.
I know that writing them as one tests is a bit more involved (e.g. you need to DELETE stuff from the table between test cases) but I think its still worth it to speed things up.

Copy link
Author

Choose a reason for hiding this comment

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

It is not just some delete's or truncate's, it is losing test isolation.
Also, delete and truncate calls take some time too.
Adding new tests we should not bother ourselves in which order tests run and how they may fail in the middle and cause other tests to fail due to unexpected DB table state.
I still value the test isolation more than the really small possible time gain.

Also, note that 5 seconds is taken by all the tests in this module including existing ones.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If some test case fails in the middle, then just report failure without running other test cases.
DELETE will take time, but much less time that creating keyspace, table, and session.
Test time is important. It directly affects iteration time for developers.

Copy link
Author

Choose a reason for hiding this comment

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

Proper test isolation reduces the investigation time in case of failures.

So, looks like we need other opinions here to get a quorum.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Investigating failing tests has never been a problem in Rust Driver. Iteration time is something that constantly affects development speed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to merge them, another reason is that there is chance for ddl statement to fail when ran in parralell due to Scylla bug, to make suit more stable we need reduce them as much as possible.

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.

3 participants