Files
scylladb/test/lib/error_injection.hh
Botond Dénes e52e1f842e test/lib: introduce error_injection.hh
Test-specific helpers for working with error injection. Provides an
RAII object to enable/disable error injection points, on all shards.
2025-12-02 14:21:26 +02:00

31 lines
714 B
C++

/*
* Copyright (C) 2025-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include "utils/error_injection.hh"
// Injects the error for the duration of the scope on all shards.
// Runs in seastar thread.
class scoped_error_injection {
std::string_view _name;
public:
// Add other overloads as needed
explicit scoped_error_injection(std::string_view name) : _name(name) {
smp::invoke_on_all([this] {
utils::get_local_injector().enable(_name);
}).get();
}
~scoped_error_injection() {
smp::invoke_on_all([this] {
utils::get_local_injector().disable(_name);
}).get();
}
};