|
8 | 8 | * the Business Source License, use of this software will be governed
|
9 | 9 | * by the Apache License, Version 2.0
|
10 | 10 | */
|
| 11 | +#include "cluster/scheduling/leader_balancer_types.h" |
| 12 | + |
| 13 | +#include <cstdint> |
11 | 14 | #define BOOST_TEST_MODULE leader_balancer
|
12 | 15 |
|
13 | 16 | #include "absl/container/flat_hash_map.h"
|
@@ -152,7 +155,7 @@ static auto from_spec(
|
152 | 155 | bool no_movement(
|
153 | 156 | const cluster_spec& spec,
|
154 | 157 | const absl::flat_hash_set<int>& muted = {},
|
155 |
| - const absl::flat_hash_set<raft::group_id>& skip = {}) { |
| 158 | + const cluster::leader_balancer_types::muted_groups_t& skip = {}) { |
156 | 159 | auto [_, balancer] = from_spec(spec, muted);
|
157 | 160 | return !balancer.find_movement(skip);
|
158 | 161 | }
|
@@ -206,12 +209,10 @@ ss::sstring expect_movement(
|
206 | 209 | const absl::flat_hash_set<int>& skip = {}) {
|
207 | 210 | auto [index, balancer] = from_spec(spec, muted);
|
208 | 211 |
|
209 |
| - absl::flat_hash_set<raft::group_id> skip_typed; |
210 |
| - std::transform( |
211 |
| - skip.begin(), |
212 |
| - skip.end(), |
213 |
| - std::inserter(skip_typed, skip_typed.begin()), |
214 |
| - [](auto groupid) { return raft::group_id{groupid}; }); |
| 212 | + cluster::leader_balancer_types::muted_groups_t skip_typed; |
| 213 | + for (auto s : skip) { |
| 214 | + skip_typed.add(static_cast<uint64_t>(s)); |
| 215 | + } |
215 | 216 |
|
216 | 217 | auto reassignment = balancer.find_movement(skip_typed);
|
217 | 218 |
|
@@ -357,7 +358,6 @@ BOOST_AUTO_TEST_CASE(greedy_skip) {
|
357 | 358 | expect_movement(spec, re(5, 1, 2), {}, {1, 2, 3, 4}), "");
|
358 | 359 |
|
359 | 360 | // mute node 0 and skip all groups on node 1, no movement
|
360 |
| - absl::flat_hash_set<raft::group_id> skip{ |
361 |
| - raft::group_id(5), raft::group_id(6)}; |
| 361 | + cluster::leader_balancer_types::muted_groups_t skip{5, 6}; |
362 | 362 | BOOST_REQUIRE(no_movement(spec, {0}, skip));
|
363 | 363 | }
|
0 commit comments