You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2021/03/24 07:23:02 UTC

[cloudstack] 01/01: Revert "plugins: Add 'break' at RedifshClient request re-try loop (#4846)"

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch revert-4846-redifsh-retry-break
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 480a72ee3bf6975bd840c79e7d11f18639a41fcb
Author: Rohit Yadav <ro...@apache.org>
AuthorDate: Wed Mar 24 12:52:45 2021 +0530

    Revert "plugins: Add 'break' at RedifshClient request re-try loop (#4846)"
    
    This reverts commit 96dd7280f69f940c077e27fdca67263f24f9c4c9.
---
 .../cloudstack/utils/redfish/RedfishClient.java    |  3 +--
 .../utils/redfish/RedfishClientTest.java           | 22 ----------------------
 2 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java
index 32b4f38..8b211c0 100644
--- a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java
+++ b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java
@@ -231,9 +231,8 @@ public class RedfishClient {
         for (int attempt = 1; attempt < redfishRequestMaxRetries + 1; attempt++) {
             try {
                 TimeUnit.SECONDS.sleep(WAIT_FOR_REQUEST_RETRY);
-                LOGGER.debug(String.format("HTTP %s request retry attempt %d/%d [URL: %s].", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries));
+                LOGGER.debug(String.format("Retry HTTP %s request [URL: %s], attempt %d/%d.", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries));
                 response = client.execute(httpReq);
-                break;
             } catch (IOException | InterruptedException e) {
                 if (attempt == redfishRequestMaxRetries) {
                     throw new RedfishException(String.format("Failed to execute HTTP %s request retry attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries,url, e));
diff --git a/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java b/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java
index 674700b..15a75ba 100644
--- a/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java
+++ b/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java
@@ -207,26 +207,4 @@ public class RedfishClientTest {
         Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
         Mockito.verify(client, Mockito.times(3)).execute(Mockito.any());
     }
-
-    @Test(expected = RedfishException.class)
-    public void retryHttpRequestExceptionAfterTwoRetries() throws IOException {
-        Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenThrow(IOException.class);
-
-        RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES));
-        newRedfishClientspy.retryHttpRequest(url, httpReq, client);
-
-        Mockito.verify(newRedfishClientspy, Mockito.never()).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
-        Mockito.verify(client, Mockito.never()).execute(Mockito.any());
-    }
-
-    @Test
-    public void retryHttpRequestSuccessAtTheSecondRetry() throws IOException {
-        Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenReturn(httpResponse);
-
-        RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES));
-        newRedfishClientspy.retryHttpRequest(url, httpReq, client);
-
-        Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any());
-        Mockito.verify(client, Mockito.times(REDFISHT_REQUEST_RETRIES)).execute(Mockito.any());
-    }
 }