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

Improve cassandra int test execute_query error #425

Merged
merged 1 commit into from Dec 14, 2021

Conversation

rukai
Copy link
Member

@rukai rukai commented Dec 14, 2021

Include the failed query and ignore the second element in Error.
The docs specifically say that the second element of Error is only relevant for internal use https://docs.rs/cassandra-cpp/0.17.0/cassandra_cpp/struct.Error.html

Error now looks like:

thread 'cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache' panicked at 'The CSQL query: BEGIN BATCH
                INSERT INTO test_cache_keyspace.test_table (id, x, name) VALUES (1, 2, 'foo');
                INSERT INTO test_cache_keyspace.test_table (id, x, name) VALUES (2, 3, 'bar');
                INSERT INTO test_cache_keyspace.test_table (id, x, names) VALUES (3, 4, 'baz');
            APPLY BATCH;
Failed with: Cassandra detailed error SERVER_INVALID_QUERY: Undefined column name names', shotover-proxy/tests/cassandra_int_tests/mod.rs:47:31
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   2: lib::cassandra_int_tests::execute_query
             at ./tests/cassandra_int_tests/mod.rs:47:31
   3: lib::cassandra_int_tests::assert_query_result
             at ./tests/cassandra_int_tests/mod.rs:53:27
   4: lib::cassandra_int_tests::run_query
             at ./tests/cassandra_int_tests/mod.rs:86:5
   5: lib::cassandra_int_tests::basic_driver_tests::cache::test
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:229:9
   6: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache::{{closure}}
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:317:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
   8: serial_test::serial_core
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/serial_test-0.5.1/src/lib.rs:64:5
   9: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:302:1
  10: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache::{{closure}}
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:303:1
  11: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  12: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Previously it looked like:

---- cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache stdout ----
thread 'cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache' panicked at 'called `Result::unwrap()` on an `Err` value: Error(CassErrorResult(SERVER_INVALID_QUERY, "Undefined column name names", UNKNOWN, -1, -1, -1, false, UNKNOWN, None, None, None), State { next_error: None, backtrace: InternalBacktrace { backtrace: Some(   0: error_chain::backtrace::imp::InternalBacktrace::new
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.12.4/src/backtrace.rs:56:48
   1: <error_chain::State as core::default::Default>::default
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.12.4/src/lib.rs:687:24
   2: cassandra_cpp::cassandra::error::Error::from_kind
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.12.4/src/error_chain.rs:269:21
   3: <cassandra_cpp::cassandra::error::Error as core::convert::From<cassandra_cpp::cassandra::error::ErrorKind>>::from
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.12.4/src/error_chain.rs:370:17
   4: <T as core::convert::Into<U>>::into
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/convert/mod.rs:542:9
   5: cassandra_cpp::cassandra::error::build_error_result
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/cassandra-cpp-0.17.0/src/cassandra/error.rs:150:9
   6: cassandra_cpp::cassandra::error::get_cass_future_error
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/cassandra-cpp-0.17.0/src/cassandra/error.rs:175:5
   7: cassandra_cpp::cassandra::future::get_completion
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/cassandra-cpp-0.17.0/src/cassandra/future.rs:268:18
   8: cassandra_cpp::cassandra::future::CassFuture<T>::wait
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/cassandra-cpp-0.17.0/src/cassandra/future.rs:249:18
   9: lib::cassandra_int_tests::execute_query
             at tests/cassandra_int_tests/mod.rs:42:18
  10: lib::cassandra_int_tests::assert_query_result
             at tests/cassandra_int_tests/mod.rs:51:27
  11: lib::cassandra_int_tests::run_query
             at tests/cassandra_int_tests/mod.rs:84:5
  12: lib::cassandra_int_tests::basic_driver_tests::cache::test
             at tests/cassandra_int_tests/basic_driver_tests.rs:229:9
  13: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache::{{closure}}
             at tests/cassandra_int_tests/basic_driver_tests.rs:317:5
  14: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  15: serial_test::serial_core
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/serial_test-0.5.1/src/lib.rs:64:5
  16: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache
             at tests/cassandra_int_tests/basic_driver_tests.rs:302:1
  17: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache::{{closure}}
             at tests/cassandra_int_tests/basic_driver_tests.rs:303:1
  18: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  19: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
      test::__rust_begin_short_backtrace
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:585:5
  20: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691:9
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panic/unwind_safe.rs:271:9
      std::panicking::try::do_call
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:403:40
      std::panicking::try
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:367:19
      std::panic::catch_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133:14
      test::run_test_in_process
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:608:18
      test::run_test::run_test_inner::{{closure}}
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:500:39
  21: test::run_test::run_test_inner::{{closure}}
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:527:37
      std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:123:18
  22: std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/thread/mod.rs:483:17
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panic/unwind_safe.rs:271:9
      std::panicking::try::do_call
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:403:40
      std::panicking::try
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:367:19
      std::panic::catch_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133:14
      std::thread::Builder::spawn_unchecked::{{closure}}
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/thread/mod.rs:482:30
      core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  23: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691:9
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys/unix/thread.rs:106:17
  24: start_thread
  25: __GI___clone
) } })', shotover-proxy/tests/cassandra_int_tests/mod.rs:42:53
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   2: core::result::unwrap_failed
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/result.rs:1616:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/result.rs:1298:23
   4: lib::cassandra_int_tests::execute_query
             at ./tests/cassandra_int_tests/mod.rs:42:18
   5: lib::cassandra_int_tests::assert_query_result
             at ./tests/cassandra_int_tests/mod.rs:51:27
   6: lib::cassandra_int_tests::run_query
             at ./tests/cassandra_int_tests/mod.rs:84:5
   7: lib::cassandra_int_tests::basic_driver_tests::cache::test
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:229:9
   8: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache::{{closure}}
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:317:5
   9: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  10: serial_test::serial_core
             at /home/rukai/.cargo/registry/src/github.com-1ecc6299db9ec823/serial_test-0.5.1/src/lib.rs:64:5
  11: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:302:1
  12: lib::cassandra_int_tests::basic_driver_tests::test_cassandra_redis_cache::{{closure}}
             at ./tests/cassandra_int_tests/basic_driver_tests.rs:303:1
  13: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  14: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@conorbros conorbros merged commit 1bd248b into shotover:main Dec 14, 2021
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.

None yet

3 participants