peterxcli commented on PR #8104:
URL: https://github.com/apache/ozone/pull/8104#issuecomment-2745244883

   Thanks @chiacyu for updating the patch.
   
   The `cleanup the "set value with property name" part in testWriteTimeout` 
means:
   
   Want:
   ```java
   @Test
   public void testWriteTimout() throws Exception {
     RaftProtos.LogEntryProto entry = mock(RaftProtos.LogEntryProto.class);
     when(entry.getTerm()).thenReturn(1L);
     when(entry.getIndex()).thenReturn(1L);
     RaftProtos.LogEntryProto entryNext = mock(RaftProtos.LogEntryProto.class);
     when(entryNext.getTerm()).thenReturn(1L);
     when(entryNext.getIndex()).thenReturn(2L);
     TransactionContext trx = mock(TransactionContext.class);
     ContainerStateMachine.Context context = 
mock(ContainerStateMachine.Context.class);
     when(trx.getStateMachineContext()).thenReturn(context);
     doAnswer(e -> {
       try {
         Thread.sleep(200000);
       } catch (InterruptedException ie) {
         Thread.currentThread().interrupt();
         throw ie;
       }
       return null;
     }).when(dispatcher).dispatch(any(), any());
   
     setUpMockRequestProtoReturn(context, 1, 1);
     ThrowableCatcher catcher = new ThrowableCatcher();
   
     Field writeChunkWaitMaxNs = 
stateMachine.getClass().getDeclaredField("writeChunkWaitMaxNs");
     writeChunkWaitMaxNs.setAccessible(true);
     writeChunkWaitMaxNs.set(stateMachine, 1000_000_000);
     CompletableFuture<Message> firstWrite = stateMachine.write(entry, trx);
     Thread.sleep(2000);
     CompletableFuture<Message> secondWrite = stateMachine.write(entryNext, 
trx);
     firstWrite.exceptionally(catcher.asSetter()).get();
     assertNotNull(catcher.getCaught());
     assertInstanceOf(InterruptedException.class, catcher.getReceived());
   
     secondWrite.exceptionally(catcher.asSetter()).get();
     assertNotNull(catcher.getReceived());
     assertInstanceOf(StorageContainerException.class, catcher.getReceived());
     StorageContainerException sce = (StorageContainerException) 
catcher.getReceived();
     assertEquals(ContainerProtos.Result.CONTAINER_INTERNAL_ERROR, 
sce.getResult());
   }
   ```
   
   to be:
   
   ```java
   @Test
   public void testWriteTimout() throws Exception {
     conf.setDuration(HDDS_CONTAINER_RATIS_STATEMACHINE_WRITE_WAIT_INTERVAL, 
1000_000_000, TimeUnit.NANOSECONDS)
     stateMachine = new ContainerStateMachine(null,
           RaftGroupId.randomId(), dispatcher, controller, executor, 
ratisServer, conf, "containerOp");
     RaftProtos.LogEntryProto entry = mock(RaftProtos.LogEntryProto.class);
     when(entry.getTerm()).thenReturn(1L);
     when(entry.getIndex()).thenReturn(1L);
     RaftProtos.LogEntryProto entryNext = mock(RaftProtos.LogEntryProto.class);
     when(entryNext.getTerm()).thenReturn(1L);
     when(entryNext.getIndex()).thenReturn(2L);
     TransactionContext trx = mock(TransactionContext.class);
     ContainerStateMachine.Context context = 
mock(ContainerStateMachine.Context.class);
     when(trx.getStateMachineContext()).thenReturn(context);
     doAnswer(e -> {
       try {
         Thread.sleep(200000);
       } catch (InterruptedException ie) {
         Thread.currentThread().interrupt();
         throw ie;
       }
       return null;
     }).when(dispatcher).dispatch(any(), any());
   
     setUpMockRequestProtoReturn(context, 1, 1);
     ThrowableCatcher catcher = new ThrowableCatcher();
   
     CompletableFuture<Message> firstWrite = stateMachine.write(entry, trx);
     Thread.sleep(2000);
     CompletableFuture<Message> secondWrite = stateMachine.write(entryNext, 
trx);
     firstWrite.exceptionally(catcher.asSetter()).get();
     assertNotNull(catcher.getCaught());
     assertInstanceOf(InterruptedException.class, catcher.getReceived());
   
     secondWrite.exceptionally(catcher.asSetter()).get();
     assertNotNull(catcher.getReceived());
     assertInstanceOf(StorageContainerException.class, catcher.getReceived());
     StorageContainerException sce = (StorageContainerException) 
catcher.getReceived();
     assertEquals(ContainerProtos.Result.CONTAINER_INTERNAL_ERROR, 
sce.getResult());
   }
   ```
   
   I'm not sure if the change would lead to any test failure. So if you found 
this cleanup cant work. You can try to adjust it to make test pass or just 
ignore this.


-- 
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]

Reply via email to