From f520c3a61333c36316b8f4adb41c086949839f67 Mon Sep 17 00:00:00 2001 From: Jie Yao Date: Tue, 12 Nov 2024 04:10:28 -0700 Subject: [PATCH] refine --- src/lib/homestore_backend/tests/homeobj_fixture.hpp | 12 ++++-------- .../tests/test_homestore_backend.cpp | 4 +--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/lib/homestore_backend/tests/homeobj_fixture.hpp b/src/lib/homestore_backend/tests/homeobj_fixture.hpp index a1bf5c6..c5e2ca3 100644 --- a/src/lib/homestore_backend/tests/homeobj_fixture.hpp +++ b/src/lib/homestore_backend/tests/homeobj_fixture.hpp @@ -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; @@ -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 } @@ -373,7 +368,8 @@ 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; + std::string member_name = std::get< 1 >(member); + if (member_name == g_helper->name()) return true; } return false; } diff --git a/src/lib/homestore_backend/tests/test_homestore_backend.cpp b/src/lib/homestore_backend/tests/test_homestore_backend.cpp index a869fc0..35dd607 100644 --- a/src/lib/homestore_backend/tests/test_homestore_backend.cpp +++ b/src/lib/homestore_backend/tests/test_homestore_backend.cpp @@ -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;