service,test: add a test case for error during pruning

The test case checks that errors which occur during materialized
view pruning are properly propagated back to the user.
This commit is contained in:
Piotr Sarna
2022-04-25 14:14:48 +02:00
parent 995468520e
commit b8a36ff253
2 changed files with 20 additions and 0 deletions

View File

@@ -92,6 +92,7 @@
#include "utils/result_loop.hh"
#include "utils/overloaded_functor.hh"
#include "utils/result_try.hh"
#include "utils/error_injection.hh"
namespace bi = boost::intrusive;
@@ -4466,6 +4467,7 @@ storage_proxy::query(schema_ptr s,
db::consistency_level cl,
storage_proxy::coordinator_query_options query_options)
{
utils::get_local_injector().inject("storage_proxy_query_failure", [] { throw std::runtime_error("Error injection: failing a query"); });
return query_result(std::move(s), std::move(cmd), std::move(partition_ranges), cl, std::move(query_options))
.then(utils::result_into_future<result<storage_proxy::coordinator_query_result>>);
}

View File

@@ -17,6 +17,7 @@
#include "test/lib/exception_utils.hh"
#include "cql3/statements/select_statement.hh"
#include "test/lib/select_statement_utils.hh"
#include "utils/error_injection.hh"
using namespace std::chrono_literals;
@@ -1934,3 +1935,20 @@ SEASTAR_TEST_CASE(test_deleting_ghost_rows) {
});
});
}
SEASTAR_TEST_CASE(test_returning_failure_from_ghost_rows_deletion) {
return do_with_cql_env_thread([] (auto& e) {
cquery_nofail(e, "CREATE TABLE t (p int, c int, v int, PRIMARY KEY (p, c))");
cquery_nofail(e, "CREATE MATERIALIZED VIEW tv AS SELECT v, p, c FROM t WHERE v IS NOT NULL AND c IS NOT NULL PRIMARY KEY (v, p, c);");
cquery_nofail(e, "INSERT INTO t (p,c,v) VALUES (1,1,1)");
cquery_nofail(e, "INSERT INTO t (p,c,v) VALUES (1,2,3)");
cquery_nofail(e, "INSERT INTO t (p,c,v) VALUES (2,4,6)");
utils::get_local_injector().enable("storage_proxy_query_failure", true);
// If error injection is disabled, this check is skipped
if (!utils::get_local_injector().enabled_injections().empty()) {
// Test that when a single query to the base table fails, it is propagated
// to the user
BOOST_REQUIRE_THROW(e.execute_cql("PRUNE MATERIALIZED VIEW tv").get0(), std::runtime_error);
}
});
}