peterxcli commented on code in PR #10333:
URL: https://github.com/apache/ozone/pull/10333#discussion_r3294355086
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/diskbalancer/TestDiskBalancerTask.java:
##########
@@ -676,7 +706,106 @@ public void
testMoveSkippedWhenContainerStateChanged(State invalidState)
assertFalse(diskBalancerService.getInProgressContainers().contains(ContainerID.valueOf(CONTAINER_ID)));
// Verify delta sizes are restored
- assertEquals(initialSourceDelta,
diskBalancerService.getDeltaSizes().get(sourceVolume));
+ assertEquals(initialSourceDelta, getDeltaSize(sourceVolume));
+ }
+
+ private DiskBalancerService.DiskBalancerTask newTask(long containerId) {
+ KeyValueContainerData containerData = new KeyValueContainerData(
+ containerId, ContainerLayoutVersion.FILE_PER_BLOCK, CONTAINER_SIZE,
+ UUID.randomUUID().toString(), datanodeUuid);
+ containerData.getStatistics().setBlockBytesForTesting(CONTAINER_SIZE);
+ return diskBalancerService.new DiskBalancerTask(containerData,
+ sourceVolume, destVolume);
+ }
+
+ private void invokePostCall(Method postCall,
+ DiskBalancerService.DiskBalancerTask task) {
+ try {
+ postCall.invoke(task, false, TimeUnit.MILLISECONDS.toMillis(1));
+ } catch (ReflectiveOperationException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ private void setDeltaSizes(Map<HddsVolume, Long> deltaSizes)
+ throws ReflectiveOperationException {
+ Field field = DiskBalancerService.class.getDeclaredField("deltaSizes");
+ field.setAccessible(true);
+ field.set(diskBalancerService, deltaSizes);
+ }
+
+ private long getDeltaSize(HddsVolume volume) {
+ return diskBalancerService.getDeltaSizes().getOrDefault(volume, 0L);
+ }
+
+ private static final class RacingDeltaMap
Review Comment:
I don't think this helps, we might want to use lock, semaphore, condition
variable or barrier to do the real race regression test.
I can’t think of a clean way to test the race either. If no one has other
ideas, maybe we should just leave the test as-is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]