Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Nov 12, 2024
1 parent 4f0747f commit 8ffa9a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 3 additions & 8 deletions src/lib/homestore_backend/tests/homeobj_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ class HomeObjectFixture : public ::testing::Test {
std::optional< std::unordered_set< uint8_t > > excluding_replicas_in_pg = std::nullopt) {
std::unordered_set< uint8_t > excluding_pg_replicas;
if (excluding_replicas_in_pg.has_value()) excluding_pg_replicas = excluding_replicas_in_pg.value();

/*
RELEASE_ASSERT(!excluding_pg_replicas.contains(leader_replica_num),
"leader_replica_num {} is excluded in the pg, excluding replicas {}", leader_replica_num,
excluding_pg_replicas);
*/
if (excluding_pg_replicas.contains(leader_replica_num))
RELEASE_ASSERT(false, "fail to create pg, leader_replica_num {} is excluded in the pg", leader_replica_num);

auto my_replica_num = g_helper->replica_num();
if (excluding_pg_replicas.contains(my_replica_num)) return;
Expand Down Expand Up @@ -359,7 +355,6 @@ class HomeObjectFixture : public ::testing::Test {
PGStats pg_stats;
auto res = _obj_inst->pg_manager()->get_stats(pg_id, pg_stats);
if (!res) return;
RELEASE_ASSERT(res, "can not get pg {} stats", pg_id);
if (g_helper->my_replica_id() == pg_stats.leader_id) { lambda(); }
// TODO: add logic for check and retry of leader change if necessary
}
Expand All @@ -373,7 +368,7 @@ class HomeObjectFixture : public ::testing::Test {
auto res = _obj_inst->pg_manager()->get_stats(pg_id, pg_stats);
if (!res) return false;
for (const auto& member : pg_stats.members) {
if (std::get< 1 >(member) == g_helper->name()) return true;
if (std::get< 0 >(member) == g_helper->my_replica_id()) return true;
}
return false;
}
Expand Down
4 changes: 1 addition & 3 deletions src/lib/homestore_backend/tests/test_homestore_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ int main(int argc, char* argv[]) {
SISL_OPTIONS_LOAD(parsed_argc, argv, test_options);

g_helper = std::make_unique< test_common::HSReplTestHelper >("test_homeobject", args, orig_argv);
// We spawn spare replica's, which is used for testing baseline resync
auto total_replicas = SISL_OPTIONS["replicas"].as< uint8_t >();
g_helper->setup(total_replicas);
g_helper->setup(SISL_OPTIONS["replicas"].as< uint8_t >());
auto ret = RUN_ALL_TESTS();
g_helper->teardown();
return ret;
Expand Down

0 comments on commit 8ffa9a8

Please sign in to comment.