sodonnel commented on code in PR #4618:
URL: https://github.com/apache/ozone/pull/4618#discussion_r1178012140
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisorScheduling.java:
##########
@@ -129,4 +129,38 @@ public void test() throws InterruptedException {
"Execution was too slow : " + executionTime + " ms");
}
+ @Test
+ public void testMaxQueueSize() throws InterruptedException {
+ OzoneConfiguration conf = new OzoneConfiguration();
+ ReplicationServer.ReplicationConfig replicationConfig
+ = conf.getObject(ReplicationServer.ReplicationConfig.class);
+ List<DatanodeDetails> datanodes = new ArrayList<>();
+ datanodes.add(MockDatanodeDetails.randomDatanodeDetails());
+ datanodes.add(MockDatanodeDetails.randomDatanodeDetails());
+
+ Integer[] count = new Integer[1];
+ count[0] = 0;
+ ContainerReplicator replicator = task -> {
+ try {
+ count[0]++;
+ Thread.sleep(2000);
Review Comment:
We should try to avoid sleeps in tests. It leads to slow tests and
potentially flaky tests. Instead of a sleep please use some sort of barrier to
block execution - eg a countdown latch.
In TestReplicationSupervisor there is a BlockingTask class defined that
makes use of latches to block execution for a period of time, so you could
probably make use of that.
```
// schedule a few tasks up to the limit
// try to schedule one more and the queue size should not increase
// unblock the execution.
```
--
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]