-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
141 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
#ifdef private | ||
#undef private | ||
#endif | ||
#include <gtest/gtest.h> | ||
#define private public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,10 @@ | |
|
||
// Authors: Zhangyi Chen([email protected]) | ||
|
||
#include <gtest/gtest.h> | ||
#include <optional> | ||
|
||
#include "braft/ballot.h" | ||
#include "common.h" | ||
|
||
class BallotTest : public testing::Test {}; | ||
|
||
|
@@ -29,17 +31,17 @@ TEST(BallotTest, sanity) { | |
conf.add_peer(peer2); | ||
conf.add_peer(peer3); | ||
braft::Ballot bl; | ||
bl.init(conf, NULL); | ||
ASSERT_EQ(2, bl._quorum); | ||
ASSERT_EQ(0, bl._old_quorum); | ||
bl.init(conf, std::nullopt); | ||
ASSERT_EQ(2, bl.quorum()); | ||
ASSERT_EQ(0, bl.old_quorum()); | ||
bl.grant(peer1); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
braft::Ballot::PosHint hint = bl.grant(peer1, braft::Ballot::PosHint()); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
hint = bl.grant(peer1, hint); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
hint = bl.grant(peer4, hint); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
hint = bl.grant(peer2, hint); | ||
ASSERT_TRUE(bl.granted()); | ||
} | ||
|
@@ -54,27 +56,27 @@ TEST(BallotTest, joint_consensus_same_conf) { | |
conf.add_peer(peer2); | ||
conf.add_peer(peer3); | ||
braft::Ballot bl; | ||
bl.init(conf, &conf); | ||
ASSERT_EQ(2, bl._quorum); | ||
ASSERT_EQ(2, bl._old_quorum); | ||
bl.init(conf, conf); | ||
ASSERT_EQ(2, bl.quorum()); | ||
ASSERT_EQ(2, bl.old_quorum()); | ||
bl.grant(peer1); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl._old_quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
ASSERT_EQ(1, bl.old_quorum()); | ||
braft::Ballot::PosHint hint = bl.grant(peer1, braft::Ballot::PosHint()); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl._old_quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
ASSERT_EQ(1, bl.old_quorum()); | ||
hint = bl.grant(peer1, hint); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl._old_quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
ASSERT_EQ(1, bl.old_quorum()); | ||
hint = bl.grant(peer4, hint); | ||
ASSERT_EQ(1, bl._quorum); | ||
ASSERT_EQ(1, bl._old_quorum); | ||
ASSERT_EQ(1, bl.quorum()); | ||
ASSERT_EQ(1, bl.old_quorum()); | ||
ASSERT_FALSE(bl.granted()); | ||
hint = bl.grant(peer2, hint); | ||
ASSERT_TRUE(bl.granted()); | ||
hint = bl.grant(peer3, hint); | ||
ASSERT_EQ(-1, bl._quorum); | ||
ASSERT_EQ(-1, bl._old_quorum); | ||
ASSERT_EQ(-1, bl.quorum()); | ||
ASSERT_EQ(-1, bl.old_quorum()); | ||
} | ||
|
||
TEST(BallotTest, joint_consensus_different_conf) { | ||
|
@@ -92,12 +94,12 @@ TEST(BallotTest, joint_consensus_different_conf) { | |
conf2.add_peer(peer3); | ||
conf2.add_peer(peer4); | ||
braft::Ballot bl; | ||
bl.init(conf, &conf2); | ||
bl.init(conf, conf2); | ||
bl.grant(peer1); | ||
bl.grant(peer2); | ||
ASSERT_FALSE(bl.granted()); | ||
ASSERT_EQ(0, bl._quorum); | ||
ASSERT_EQ(1, bl._old_quorum); | ||
ASSERT_EQ(0, bl.quorum()); | ||
ASSERT_EQ(1, bl.old_quorum()); | ||
bl.grant(peer4); | ||
ASSERT_TRUE(bl.granted()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,14 @@ | |
// Author: Zhangyi Chen ([email protected]) | ||
// Date: 2016/02/03 15:59:18 | ||
|
||
#include <algorithm> | ||
#include <gtest/gtest.h> | ||
#include <butil/string_printf.h> | ||
|
||
#include <algorithm> | ||
|
||
#include "braft/ballot_box.h" | ||
#include "braft/configuration.h" | ||
#include "braft/fsm_caller.h" | ||
#include "common.h" | ||
|
||
class BallotBoxTest : public testing::Test { | ||
protected: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,11 @@ | |
// Author: Zhangyi Chen ([email protected]) | ||
// Date: 2016/04/11 12:15:37 | ||
|
||
#include <gtest/gtest.h> | ||
#include <braft/util.h> | ||
#include <butil/crc32c.h> | ||
|
||
#include "common.h" | ||
|
||
class ChecksumTest : public testing::Test { | ||
protected: | ||
void SetUp() {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ | |
// Author: Zhangyi Chen ([email protected]) | ||
// Date: 2018/01/12 12:56:17 | ||
|
||
#include <gtest/gtest.h> | ||
#include <gflags/gflags.h> | ||
#include <butil/unique_ptr.h> | ||
#include <brpc/server.h> | ||
#include "braft/raft.h" | ||
#include <butil/unique_ptr.h> | ||
#include <gflags/gflags.h> | ||
|
||
#include "braft/cli.h" | ||
#include "braft/node.h" | ||
#include "braft/raft.h" | ||
#include "common.h" | ||
|
||
class CliTest : public testing::Test { | ||
public: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,16 @@ | |
// Author: Zhangyi Chen ([email protected]) | ||
// Date: 2015/11/06 15:40:45 | ||
|
||
#include <gtest/gtest.h> | ||
#include <gflags/gflags.h> | ||
#include <butil/logging.h> | ||
#include <brpc/server.h> | ||
#include <butil/file_util.h> | ||
#include <butil/logging.h> | ||
#include <gflags/gflags.h> | ||
|
||
#include <brpc/server.h> | ||
#include "braft/file_service.h" | ||
#include "braft/util.h" | ||
#include "braft/remote_file_copier.h" | ||
#include "braft/file_system_adaptor.h" | ||
#include "braft/remote_file_copier.h" | ||
#include "braft/util.h" | ||
#include "common.h" | ||
|
||
namespace braft { | ||
DECLARE_bool(raft_file_check_hole); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
// Author: ZhengPengFei ([email protected]) | ||
// Date: 2017/06/16 10:29:05 | ||
|
||
#include <gtest/gtest.h> | ||
#include "braft/file_system_adaptor.h" | ||
#include "common.h" | ||
|
||
class TestFileSystemAdaptorSuits : public testing::Test { | ||
protected: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,15 @@ | |
// Author: Zhangyi Chen ([email protected]) | ||
// Date: 2015/12/01 17:03:46 | ||
|
||
#include <gtest/gtest.h> | ||
#include <butil/string_printf.h> | ||
#include <butil/memory/scoped_ptr.h> | ||
#include <butil/string_printf.h> | ||
|
||
#include "braft/configuration.h" | ||
#include "braft/fsm_caller.h" | ||
#include "braft/raft.h" | ||
#include "braft/log.h" | ||
#include "braft/configuration.h" | ||
#include "braft/log_manager.h" | ||
#include "braft/raft.h" | ||
#include "common.h" | ||
|
||
class FSMCallerTest : public testing::Test { | ||
protected: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,15 @@ | |
// Author: Zhangyi Chen ([email protected]) | ||
// Date: 2016/02/23 16:22:15 | ||
|
||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <gtest/gtest.h> | ||
#include <butil/fd_guard.h> | ||
#include <butil/time.h> | ||
#include <butil/logging.h> | ||
#include <butil/time.h> | ||
#include <fcntl.h> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
#include "common.h" | ||
|
||
class FsyncTest : public testing::Test { | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,13 @@ | |
|
||
// Authors: Pengfei Zheng ([email protected]) | ||
|
||
#include <gtest/gtest.h> | ||
#include <butil/logging.h> | ||
#include "braft/util.h" | ||
#include "braft/node.h" | ||
#include "braft/lease.h" | ||
|
||
#include "../test/util.h" | ||
#include "braft/lease.h" | ||
#include "braft/node.h" | ||
#include "braft/util.h" | ||
#include "common.h" | ||
|
||
namespace braft { | ||
DECLARE_bool(raft_enable_leader_lease); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,21 @@ | |
// Author: WangYao (fisherman), [email protected] | ||
// Date: 2015/10/08 17:00:05 | ||
|
||
#include <gtest/gtest.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
#include <butil/atomicops.h> | ||
#include <butil/file_util.h> | ||
#include <butil/files/file_path.h> | ||
#include <butil/files/file_enumerator.h> | ||
#include <butil/files/dir_reader_posix.h> | ||
#include <butil/string_printf.h> | ||
#include <butil/files/file_enumerator.h> | ||
#include <butil/files/file_path.h> | ||
#include <butil/logging.h> | ||
#include "braft/util.h" | ||
#include <butil/string_printf.h> | ||
#include <fcntl.h> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
|
||
#include "braft/log.h" | ||
#include "braft/storage.h" | ||
#include "braft/util.h" | ||
#include "common.h" | ||
|
||
namespace braft { | ||
DECLARE_bool(raft_trace_append_entry_latency); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,15 @@ | |
// Author: Zhangyi Chen ([email protected]) | ||
// Date: 2015/11/24 16:30:49 | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <bthread/countdown_event.h> | ||
#include <butil/macros.h> | ||
#include <butil/memory/scoped_ptr.h> | ||
#include <butil/string_printf.h> | ||
#include <butil/macros.h> | ||
|
||
#include <bthread/countdown_event.h> | ||
#include "braft/log_manager.h" | ||
#include "braft/configuration.h" | ||
#include "braft/log.h" | ||
#include "braft/log_manager.h" | ||
#include "common.h" | ||
|
||
class LogManagerTest : public testing::Test { | ||
protected: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
// Author: [email protected] | ||
// Date: 2017/05/23 | ||
|
||
#include <gtest/gtest.h> | ||
#include "braft/memory_log.h" | ||
#include "common.h" | ||
|
||
namespace braft { | ||
extern void global_init_once_or_die(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.