adwetojha commented on code in PR #11752:
URL: https://github.com/apache/ozone/pull/11752#discussion_r4493456830


##########
hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestOzoneManagerProtocolClientSideTranslatorPB.java:
##########
@@ -60,6 +73,167 @@ class TestOzoneManagerProtocolClientSideTranslatorPB {
       omTransport, "test-client-id");
   private static final OmDeleteKeys DELETE_KEYS = new OmDeleteKeys("vol", 
"bucket", Arrays.asList("key1", "key2"));
 
+  @ParameterizedTest
+  @EnumSource(value = Type.class, names = {"CreateKey", "CreateFile", 
"AllocateBlock"})
+  void retriesMissingPipelineAllocationForEachClientOperation(Type operation) 
throws Exception {
+    OzoneManagerProtocolClientSideTranslatorPB client = retryingClient();
+    when(omTransport.submitRequest(any(OMRequest.class)))
+        .thenReturn(errorResponse(operation, Status.KEY_ALLOCATION_ERROR), 
successResponse(operation));
+
+    invokeBlockAllocation(client, operation);
+
+    ArgumentCaptor<OMRequest> requests = 
ArgumentCaptor.forClass(OMRequest.class);
+    verify(omTransport, times(2)).submitRequest(requests.capture());
+    
assertThat(requests.getAllValues().get(0)).isEqualTo(requests.getAllValues().get(1));
+    assertThat(requests.getValue().getCmdType()).isEqualTo(operation);
+  }
+
+  @Test
+  void stopsRetryingMissingPipelineAndPreservesLastError() throws Exception {
+    Type operation = Type.CreateKey;
+    when(omTransport.submitRequest(any(OMRequest.class)))
+        .thenReturn(errorResponse(operation, Status.KEY_ALLOCATION_ERROR));
+
+    ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+    PrintStream originalErr = System.err;
+    OMException error;
+    try {
+      System.setErr(new PrintStream(stderr, false, 
StandardCharsets.UTF_8.name()));
+      error = assertThrows(OMException.class, () -> 
retryingClient().openKey(keyArgs()));
+    } finally {
+      System.setErr(originalErr);

Review Comment:
   Thanks for the suggestion! I've updated both tests to use 
`GenericTestUtils.SystemErrCapturer` with try-with-resources and removed the 
manual stderr capture logic.



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