Skip to content

Commit

Permalink
Fix test MockSharedArbitratorTest.arbitrationFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjialiang committed Nov 6, 2024
1 parent f9b24d5 commit 894ba7d
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions velox/common/memory/tests/MockSharedArbitratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,9 @@ class MockSharedArbitrationTest : public testing::Test {
{std::string(ExtraConfig::kGlobalArbitrationEnabled),
folly::to<std::string>(globalArtbitrationEnabled)},
{std::string(ExtraConfig::kGlobalArbitrationWithoutSpill),
folly::to<std::string>(globalArbitrationWithoutSpill)}};
folly::to<std::string>(globalArbitrationWithoutSpill)},
{std::string(ExtraConfig::kGlobalArbitrationAbortTimeRatio),
folly::to<std::string>(globalArbitrationAbortTimeRatio)}};
options.arbitrationStateCheckCb = std::move(arbitrationStateCheckCb);
options.checkUsageLeak = true;
manager_ = std::make_unique<MemoryManager>(options);
Expand Down Expand Up @@ -858,6 +860,26 @@ TEST_F(MockSharedArbitrationTest, asyncArbitrationWork) {

// Test different kinds of arbitraton failures.
TEST_F(MockSharedArbitrationTest, arbitrationFailures) {
// Set the globalArbitrationAbortTimeRatio to be very small so that the query
// can be aborted sooner and the test would not timeout.
setupMemory(
kMemoryCapacity,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
kMemoryReclaimThreadsHwMultiplier,
nullptr,
true,
5 * 60 * 1'000'000'000UL,
false,
0.005);
// Local arbitration failure with exceeded capacity limit.
{
auto task = addTask(64 * MB);
Expand Down Expand Up @@ -3903,8 +3925,26 @@ TEST_F(MockSharedArbitrationTest, arbitrationFailure) {

for (const auto& testData : testSettings) {
SCOPED_TRACE(testData.debugString());

setupMemory(maxCapacity, 0, initialCapacity, 0);
// Set the globalArbitrationAbortTimeRatio to be very small so that the
// query can be aborted sooner and the test would not timeout.
setupMemory(
maxCapacity,
0,
initialCapacity,
0,
0,
0,
0,
0,
0,
0,
0,
kMemoryReclaimThreadsHwMultiplier,
nullptr,
true,
5 * 60 * 1'000'000'000UL,
false,
0.005);
std::shared_ptr<MockTask> requestorTask = addTask();
MockMemoryOperator* requestorOp = addMemoryOp(requestorTask, false);
requestorOp->allocate(testData.requestorCapacity);
Expand Down

0 comments on commit 894ba7d

Please sign in to comment.