-
Notifications
You must be signed in to change notification settings - Fork 11
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
Basic tests #65
Basic tests #65
Conversation
99414af
to
d6726c1
Compare
@@ -33,4 +33,4 @@ jobs: | |||
run: cmake -DCASS_BUILD_INTEGRATION_TESTS=ON . && make | |||
|
|||
- name: Run integration tests on Scylla 5.0.0 | |||
run: valgrind --error-exitcode=123 ./cassandra-integration-tests --version=release:5.0.0 --category=CASSANDRA --verbose=ccm --gtest_filter="ClusterTests.*:BasicsTests.*RowsInRowsOut" | |||
run: valgrind --error-exitcode=123 ./cassandra-integration-tests --version=release:5.0.0 --category=CASSANDRA --verbose=ccm --gtest_filter="ClusterTests.*:BasicsTests.*" |
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 change seems to remove tests from the filter. Is that intended?
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.
Actually, it does not remove a test instead, it enables all BasicsTests
including the RowsInRowsOut
test in it.
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.
Oh, I understand now. The filter used to include tests which match on BasicsTests.*RowsInRowsOut
, now it is BasicsTests.*
which matches on a larger number of tests.
} | ||
|
||
let paging_state_usize: usize = paging_state_size.try_into().unwrap(); | ||
let mut b = BytesMut::from(slice::from_raw_parts( |
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.
Bytes::copy_from_slice
will be more explicit here than Bytes::from
. Its name more clearly conveys what exactly it is doing.
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 think BytesMut
does not have such a method as copy_from_slice
or similar. However, I have slightly changed the implementation to first ensure the necessary capacity allocated and then to create Bytes
from a slice, so that we can avoid unnecessary reallocation.
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.
Now it's even better than what I requested, thanks.
*paging_state = result_from_raw | ||
.metadata | ||
.paging_state | ||
.clone() | ||
.unwrap() | ||
.as_ptr() as *const c_char; |
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.
You are (most probably) returning a pointer to freed memory here.
.clone() creates a temporary Option<Bytes>
object, cloned from paging_state
. I'm not entirely sure how it will work under the hood, but one of two things will happen:
- the new object will increase a reference count of the memory the old
Bytes
object pointed to (semantics similar toArc
), - or the new object will allocate its own memory and will copy the contents from the old
Bytes
(semantics similar toBox
).
If it's the first one, then you will just increase and decrease the reference count unnecessarily, but it will work.
If it's the second, then it's worse. You then call as_ptr()
to get the pointer to the contents of the temporary Bytes
, return it, but then the temporary object is deallocated, and the pointer you just returned points to freed memory.
I guess that the lifetime of the memory pointed by the result of cass_result_paging_state_token
is bound to the CassResult
, right? If so, then you should call as_ref().unwrap().as_ptr()
, similarly to the previous statement.
|
||
let result_from_raw = ptr_to_ref(result); | ||
|
||
if result_from_raw.metadata.paging_state.is_none() { |
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.
Instead of checking for is_none()
and then unwrap()
-ping, I'd recommend converting the if {} else {}
block into match
block.
@@ -254,7 +254,7 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, UnsetParameters) { | |||
|
|||
// Execute the insert statement and validate the error code | |||
Result result = session_.execute(insert_statement, false); | |||
if (server_version_ >= "2.2.0") { | |||
if (server_version_ >= "release:2.2.0") { |
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'm not sure it is the best way to do it. All other tests which perform such a comparison will probably have to be updated in such fashion. Perhaps we should strip the release:
prefix elsewhere, before server_version_
is initialized.
@jul-stas is this problem handled in the original driver?
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 have changed the implementation to set server_version_
to 3.0.8
in case provided version has the prefix release:
. The cpp-driver
tests are also run with the same version on Jenkins, and some of the tests which are not disabled may be skipped: e.g. NoCompactEnabledConnection
test in BasicsTests
.
2887397
to
e3cbc30
Compare
V2:
|
|
||
let value_from_raw: &CassValue = ptr_to_ref(value); | ||
|
||
match &value_from_raw.value { |
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.
AFAIK the original cass_value_get_bytes
works on all CQL types (see here). I understand that it might be difficult to implement it properly right now because the rust driver doesn't allow to return raw, serialized values but rather returns CqlValue - so please add a TODO or a FIXME comment about it.
} | ||
|
||
let paging_state_usize: usize = paging_state_size.try_into().unwrap(); | ||
let mut b = BytesMut::from(slice::from_raw_parts( |
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.
Now it's even better than what I requested, thanks.
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.
LGTM after adding the TODO comment.
@jul-stas please take a look, especially at the part which sets the version to "3.0.8".
Added implementation of cass_value_get_bytes to retrieve bytes of a Blob value. Added paging state token setter for CassStatement. Added paging state token getter from query result. The database version is set to 3.0.8 if the provided version in tests has prefix `release:`. This will skip some of the tests which are also skipped in the cpp-driver tests and are not disabled.
This should be merged only after #66 is merged.
This PR is dependent upon #64
This PR adds implementation for some necessary functions to pass all
BasicTests
.