mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-12 10:55:46 +02:00
test(server): test transaction locked keys (#1669)
* test(server): test transaction locked keys 1. add test utility class that will add suspension to transaction execution. 2. add test for locked keys in transaction Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
parent
16c2353faf
commit
f9a3e2811c
5 changed files with 76 additions and 18 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "io/io.h"
|
||||
#include "server/conn_context.h"
|
||||
#include "server/main_service.h"
|
||||
#include "server/transaction.h"
|
||||
#include "util/proactor_pool.h"
|
||||
|
||||
namespace dfly {
|
||||
|
@ -37,6 +38,19 @@ class TestConnection : public facade::Connection {
|
|||
bool is_admin_ = false;
|
||||
};
|
||||
|
||||
// The TransactionSuspension class is designed to facilitate the temporary suspension of commands
|
||||
// executions. When the 'start' method is invoked, it enforces the suspension of other
|
||||
// transactions by acquiring a global shard lock. Conversely, invoking the 'terminate' method
|
||||
// releases the global shard lock, enabling all transactions in the queue to resume execution.
|
||||
class TransactionSuspension {
|
||||
public:
|
||||
void Start();
|
||||
void Terminate();
|
||||
|
||||
private:
|
||||
boost::intrusive_ptr<dfly::Transaction> transaction_;
|
||||
};
|
||||
|
||||
class BaseFamilyTest : public ::testing::Test {
|
||||
protected:
|
||||
BaseFamilyTest();
|
||||
|
@ -105,6 +119,8 @@ class BaseFamilyTest : public ::testing::Test {
|
|||
size_t index) const;
|
||||
|
||||
static absl::flat_hash_set<std::string> GetLastUsedKeys();
|
||||
static void ExpectConditionWithinTimeout(const std::function<bool()>& condition,
|
||||
absl::Duration timeout = absl::Seconds(10));
|
||||
|
||||
static unsigned NumLocked();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue