Skip to content

Commit

Permalink
Fix flaky TestQueryManagerConfig
Browse files Browse the repository at this point in the history
This test relies on rounding large integers and will sometimes fail
depending on the amount of memory available to the test runner.

This commit reuses the exact same calculation for tests as it does in
the code, so that we will always get the correct value for the default.
  • Loading branch information
Pluies authored and losipiuk committed Jan 13, 2025
1 parent 94c3ec5 commit fa8f143
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static io.airlift.units.DataSize.Unit.KILOBYTE;
import static io.airlift.units.DataSize.Unit.MEGABYTE;
import static io.trino.execution.QueryManagerConfig.AVAILABLE_HEAP_MEMORY;
import static io.trino.execution.QueryManagerConfig.DEFAULT_TASK_DESCRIPTOR_STORAGE_MAX_MEMORY;
import static io.trino.execution.QueryManagerConfig.FAULT_TOLERANT_EXECUTION_MAX_PARTITION_COUNT_LIMIT;
import static java.lang.Math.max;
import static java.lang.Math.round;
Expand Down Expand Up @@ -100,8 +101,8 @@ public void testDefaults()
.setFaultTolerantExecutionStandardSplitSize(DataSize.of(64, MEGABYTE))
.setFaultTolerantExecutionMaxTaskSplitCount(2048)
.setFaultTolerantExecutionTaskDescriptorStorageMaxMemory(DataSize.ofBytes(round(AVAILABLE_HEAP_MEMORY * 0.15)))
.setFaultTolerantExecutionTaskDescriptorStorageHighWaterMark(DataSize.ofBytes((long) (AVAILABLE_HEAP_MEMORY * 0.09)))
.setFaultTolerantExecutionTaskDescriptorStorageLowWaterMark(DataSize.ofBytes((long) (AVAILABLE_HEAP_MEMORY * 0.06)))
.setFaultTolerantExecutionTaskDescriptorStorageHighWaterMark(DataSize.ofBytes((long) (DEFAULT_TASK_DESCRIPTOR_STORAGE_MAX_MEMORY.toBytes() * 0.6)))
.setFaultTolerantExecutionTaskDescriptorStorageLowWaterMark(DataSize.ofBytes((long) (DEFAULT_TASK_DESCRIPTOR_STORAGE_MAX_MEMORY.toBytes() * 0.4)))
.setFaultTolerantExecutionMaxPartitionCount(50)
.setFaultTolerantExecutionMinPartitionCount(4)
.setFaultTolerantExecutionMinPartitionCountForWrite(50)
Expand Down

0 comments on commit fa8f143

Please sign in to comment.