You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/12/14 10:15:15 UTC

[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #6984: make api rate limit test a little more robust

weizhouapache commented on code in PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#discussion_r1048263071


##########
plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java:
##########
@@ -112,15 +112,24 @@ public void sequentialApiAccess() {
     public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
         int allowedRequests = 200;
         s_limitService.setMaxAllowed(allowedRequests);
-        s_limitService.setTimeToLive(1);
+        s_limitService.setTimeToLive(5);
+        long startTime = System.nanoTime();
 
         User key = createFakeUser();
 
         for (int i = 0; i < allowedRequests; i++) {
-            assertTrue("We should allow " + allowedRequests + " requests per second, but failed at request " + i, isUnderLimit(key));
+            assertTrue(String.format("We should allow %d requests per second, but failed at request %d.", allowedRequests, i), isUnderLimit(key));
         }
-
-        assertFalse("We should block >" + allowedRequests + " requests per second", isUnderLimit(key));
+        // we cannot really say more about this test
+        boolean underLimit =  isUnderLimit(key);
+        long endtime = System.nanoTime();

Review Comment:
   ```suggestion
           long endtime = System.nanoTime();
           System.out.println("time elapsed " + (endtime - startTime)/1000/1000 + " ms");
   ```



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org