Verify that the allocations that GetDistributionMap() returns for each node sum to the size of the hash space (UINT_MAX + 1).
| 50 | // Verify that the allocations that GetDistributionMap() returns for each node |
| 51 | // sum to the size of the hash space (UINT_MAX + 1). |
| 52 | void VerifyTotalAllocation(const vector<IpAddr>& addresses, |
| 53 | const uint32_t replication) { |
| 54 | HashRing hash_ring(replication); |
| 55 | for (const IpAddr& addr : addresses) hash_ring.AddNode(addr); |
| 56 | std::map<IpAddr, uint64_t> dist_map; |
| 57 | hash_ring.GetDistributionMap(&dist_map); |
| 58 | uint64_t total_allocation = 0; |
| 59 | uint64_t total_uint32_range = static_cast<uint64_t>(UINT_MAX) + 1; |
| 60 | for (auto dist_map_it : dist_map) { |
| 61 | total_allocation += dist_map_it.second; |
| 62 | } |
| 63 | EXPECT_EQ(total_allocation, total_uint32_range); |
| 64 | } |
| 65 | |
| 66 | // Verify that ratio of the maximum allocation to the minimum allocation is below |
| 67 | // the 'expected_ratio_limit'. |
nothing calls this directly
no test coverage detected