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

Upgrade cassandra version #102

Merged
merged 3 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/cassandra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Build
run: cmake -DCASS_BUILD_INTEGRATION_TESTS=ON . && make

- name: Run integration tests on Cassandra 3.0.9
- name: Run integration tests on Cassandra 4.0.7
env:
# Ignored tests are added in the end, after the "-" sign.
Tests: "ClusterTests.*\
Expand All @@ -51,12 +51,13 @@ jobs:
:CompressionTests.*\
:LoggingTests.*\
:-PreparedTests.Integration_Cassandra_PreparedIDUnchangedDuringReprepare\
:PreparedTests.Integration_Cassandra_FailFastWhenPreparedIDChangesDuringReprepare\
:*5.Integration_Cassandra_*\
:*19.Integration_Cassandra_*\
:CassandraTypes/CassandraTypesTests/*.Integration_Cassandra_UDT\
:*7.Integration_Cassandra_*\
:SslTests.Integration_Cassandra_ReconnectAfterClusterCrashAndRestart\
wprzytula marked this conversation as resolved.
Show resolved Hide resolved
:ExecutionProfileTest.InvalidName"
run: valgrind --error-exitcode=123 --leak-check=full --errors-for-leak-kinds=definite ./cassandra-integration-tests --version=3.0.9 --category=CASSANDRA --verbose=ccm --gtest_filter="$Tests"
run: valgrind --error-exitcode=123 --leak-check=full --errors-for-leak-kinds=definite ./cassandra-integration-tests --version=4.0.7 --category=CASSANDRA --verbose=ccm --gtest_filter="$Tests"

- name: Upload test logs
uses: actions/upload-artifact@v3
Expand Down
29 changes: 1 addition & 28 deletions scylla-rust-wrapper/src/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ use crate::inet::CassInet;
use crate::metadata::{
CassColumnMeta, CassKeyspaceMeta, CassMaterializedViewMeta, CassSchemaMeta, CassTableMeta,
};
use crate::statement::CassStatement;
use crate::types::*;
use crate::uuid::CassUuid;
use scylla::frame::response::result::{ColumnSpec, CqlValue};
use scylla::{BufMut, Bytes, BytesMut};
use scylla::Bytes;
use std::convert::TryInto;
use std::os::raw::c_char;
use std::slice;
use std::sync::Arc;
use uuid::Uuid;

Expand Down Expand Up @@ -1248,31 +1246,6 @@ pub unsafe extern "C" fn cass_result_paging_state_token(
CassError::CASS_OK
}

#[no_mangle]
pub unsafe extern "C" fn cass_statement_set_paging_state_token(
statement: *mut CassStatement,
paging_state: *const c_char,
paging_state_size: size_t,
) -> CassError {
let statement_from_raw = ptr_to_ref_mut(statement);

if paging_state.is_null() {
statement_from_raw.paging_state = None;
return CassError::CASS_ERROR_LIB_NULL_VALUE;
}

let paging_state_usize: usize = paging_state_size.try_into().unwrap();
let mut b = BytesMut::with_capacity(paging_state_usize + 1);
b.put_slice(slice::from_raw_parts(
paging_state as *const u8,
paging_state_usize,
));
b.extend_from_slice(b"\0");
statement_from_raw.paging_state = Some(b.freeze());

CassError::CASS_OK
}

// CassResult functions:
/*
extern "C" {
Expand Down
28 changes: 27 additions & 1 deletion scylla-rust-wrapper/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ use scylla::frame::value::MaybeUnset::{Set, Unset};
use scylla::query::Query;
use scylla::statement::prepared_statement::PreparedStatement;
use scylla::statement::SerialConsistency;
use scylla::Bytes;
use scylla::{BufMut, Bytes, BytesMut};
use std::collections::HashMap;
use std::convert::TryInto;
use std::os::raw::{c_char, c_int};
use std::slice;
use std::sync::Arc;

include!(concat!(env!("OUT_DIR"), "/cppdriver_data_query_error.rs"));
Expand Down Expand Up @@ -224,6 +226,30 @@ pub unsafe extern "C" fn cass_statement_set_paging_state(
CassError::CASS_OK
}

#[no_mangle]
pub unsafe extern "C" fn cass_statement_set_paging_state_token(
statement: *mut CassStatement,
paging_state: *const c_char,
paging_state_size: size_t,
) -> CassError {
let statement_from_raw = ptr_to_ref_mut(statement);

if paging_state.is_null() {
statement_from_raw.paging_state = None;
return CassError::CASS_ERROR_LIB_NULL_VALUE;
}

let paging_state_usize: usize = paging_state_size.try_into().unwrap();
let mut b = BytesMut::with_capacity(paging_state_usize);
let paging_state_bytes = slice::from_raw_parts(paging_state, paging_state_usize);
for byte in paging_state_bytes {
b.put_i8(*byte);
}
Comment on lines +245 to +247
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would b.put(&paging_state_bytes) work here? Documentation for BytesMut suggests that it is possible:

https://docs.rs/bytes/latest/bytes/struct.BytesMut.html#method.with_capacity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it should work, will fix it. Indeed, it will be better to put it without specifying whether it is i8 or u8, as c_char is considered to be u8 on some processors (e.g. ARM) and it may cause a compilation error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, b.put(&paging_state_bytes) is not implemented for &[u8] or &[i8], so I think either we should add an explicit cast to i8 and ignore the warnings or use the cfg! macro with some configuration flags to put c_char as i8 or u8 depending on the processor type.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@piodul WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's keep the current version for simplicity and hope that the compiler optimizes it.

statement_from_raw.paging_state = Some(b.freeze());

CassError::CASS_OK
}

#[no_mangle]
pub unsafe extern "C" fn cass_statement_set_is_idempotent(
statement_raw: *mut CassStatement,
Expand Down
1 change: 1 addition & 0 deletions tests/src/integration/ccm/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@ CCM::Bridge::generate_create_updateconf_command(CassVersion cassandra_version) {
updateconf_command.push_back("request_timeout_in_ms:10000");
updateconf_command.push_back("phi_convict_threshold:16");
updateconf_command.push_back("hinted_handoff_enabled:false");
updateconf_command.push_back("enable_materialized_views:true");
updateconf_command.push_back("dynamic_snitch_update_interval_in_ms:1000");
updateconf_command.push_back("native_transport_max_threads:1");
updateconf_command.push_back("concurrent_reads:2");
Expand Down
6 changes: 6 additions & 0 deletions tests/src/integration/tests/test_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ CASSANDRA_INTEGRATION_TEST_F(TracingTests, Simple) {
Statement statement("SELECT * FROM system_traces.sessions WHERE session_id = ?", 1);
statement.bind(0, tracing_id);
Result result = session_.execute(statement);
int retries = 0;
while (result.row_count() == 0u && retries < 10) {
msleep(1000);
retries++;
result = session_.execute(statement);
}
ASSERT_GT(result.row_count(), 0u);
Uuid session_id = result.first_row().column_by_name<Uuid>("session_id");
ASSERT_FALSE(session_id.is_null());
Expand Down