cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [2/8] git commit: updated refs/heads/master to 8757daf
Date Mon, 07 Dec 2015 18:35:07 GMT
Add test for NSX plugin that simulates a live lock


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d248e61a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d248e61a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d248e61a

Branch: refs/heads/master
Commit: d248e61a3128fe285a18c9836d1c7d18b5b946e9
Parents: 2093c33
Author: Miguel Ferreira <miguelferreira@me.com>
Authored: Wed Dec 2 14:53:26 2015 +0100
Committer: Miguel Ferreira <miguelferreira@me.com>
Committed: Sat Dec 5 15:52:22 2015 +0100

----------------------------------------------------------------------
 .../network/nicira/NiciraRestClientTest.java    | 42 ++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d248e61a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraRestClientTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraRestClientTest.java
b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraRestClientTest.java
index 7fcab80..3c5160c 100644
--- a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraRestClientTest.java
+++ b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraRestClientTest.java
@@ -20,6 +20,7 @@
 package com.cloud.network.nicira;
 
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.isEmptyOrNullString;
 import static org.hamcrest.Matchers.not;
 import static org.hamcrest.Matchers.notNullValue;
@@ -169,4 +170,45 @@ public class NiciraRestClientTest {
             verifyPrivate(client).invoke("execute", HttpRequestMatcher.eq(loginRequest),
eq(401));
         }
     }
+
+    @Test
+    public void testExecuteLiveLockWhenControllerAllowsLoginAndFollowsWithUnauthorizedButDoesNotRediect()
throws Exception {
+        when(mockResponse.getStatusLine())
+            .thenReturn(HTTP_401_STATUSLINE)
+            .thenReturn(HTTP_200_STATUSLINE)
+            .thenReturn(HTTP_401_STATUSLINE)
+            .thenReturn(HTTP_200_STATUSLINE)
+            .thenReturn(HTTP_401_STATUSLINE)
+            .thenReturn(HTTP_200_STATUSLINE)
+            .thenReturn(HTTP_401_STATUSLINE)
+            .thenReturn(HTTP_200_STATUSLINE)
+            .thenReturn(HTTP_401_STATUSLINE);
+        when(httpClient.execute(eq(HTTP_HOST), HttpRequestMatcher.eq(request), eq(httpClientContext)))
+            .thenReturn(mockResponse)
+            .thenReturn(mockResponse)
+            .thenReturn(mockResponse)
+            .thenReturn(mockResponse)
+            .thenReturn(mockResponse);
+        when(httpClient.execute(eq(HTTP_HOST), HttpRequestMatcher.eq(loginRequest), eq(httpClientContext)))
+            .thenReturn(mockResponse)
+            .thenReturn(mockResponse)
+            .thenReturn(mockResponse)
+            .thenReturn(mockResponse);
+        final NiciraRestClient client = spy(NiciraRestClient.create()
+            .client(httpClient)
+            .clientContext(httpClientContext)
+            .hostname(LOCALHOST)
+            .username(ADMIN)
+            .password(ADMIN_PASSWORD)
+            .loginUrl(LOGIN_PATH)
+            .executionLimit(2)
+            .build());
+
+        try {
+            client.execute(request);
+            fail("Execution count should have been maxed out");
+        } catch (final CloudstackRESTException e) {
+            assertThat(e.getMessage(), containsString("Reached max executions limit of "));
+        }
+    }
 }


Mime
View raw message