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/13 16:30:51 UTC

[GitHub] [cloudstack] DaanHoogland opened a new pull request, #6984: make api rate limit test a little more robust

DaanHoogland opened a new pull request, #6984:
URL: https://github.com/apache/cloudstack/pull/6984

   ### Description
   
   This PR...
   <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   Fixes: #6975 
   
   <!--- ********************************************************************************* -->
   <!--- NOTE: AUTOMATATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- ********************************************************************************* -->
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [x] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [x] Major
   - [ ] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):
   
   
   ### How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   <!-- see how your change affects other areas of the code, etc. -->
   
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
   unit test


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


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

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#discussion_r1048187925


##########
plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java:
##########
@@ -110,17 +110,25 @@ public void sequentialApiAccess() {
 
     @Test
     public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
-        int allowedRequests = 200;
+        int allowedRequests = 2000;
         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();
+        int issued = s_limitService.getIssued(key.getAccountId());
+        int timeToLive = s_limitService.getTimeToLive();
+
+        // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
+        assertFalse(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
+                s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), underLimit);

Review Comment:
   ```suggestion
           // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
           // so only fail if timeToLive is not exeeded and we didn´t get the requested number of calls
           assertTrue(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
                   s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), ( ! underLimit) || ((endtime - starttime)/1000000 > timeToLive);
   ```



##########
plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java:
##########
@@ -110,17 +110,25 @@ public void sequentialApiAccess() {
 
     @Test
     public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
-        int allowedRequests = 200;
+        int allowedRequests = 2000;
         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();
+        int issued = s_limitService.getIssued(key.getAccountId());
+        int timeToLive = s_limitService.getTimeToLive();
+
+        // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
+        assertFalse(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
+                s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), underLimit);

Review Comment:
   @davidjumani @nvazquez @weizhouapache , I did a self review and I think we need this extra condition



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


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

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#discussion_r1048235508


##########
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();
+        int issued = s_limitService.getIssued(key.getAccountId());
+        int timeToLive = s_limitService.getTimeToLive();
+
+        // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
+        // so only fail if timeToLive is not exeeded and we didn´t get the requested number of calls
+        assertFalse(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
+                s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), ((endtime - starttime)/1000000 < timeToLive) && underLimit);

Review Comment:
   ```suggestion
           assertFalse(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d ns)",
                   s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), ((endtime - starttime)/1000000000 < timeToLive) && underLimit);
   ```



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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1351773022

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian :heavy_check_mark: suse15. SL-JID 4942


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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1351660253

   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 4941


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


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

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1349003771

   @blueorangutan package


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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1351981190

   @weizhouapache a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


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


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

Posted by GitBox <gi...@apache.org>.
davidjumani commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1350668858

   @blueorangutan package


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


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

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#discussion_r1048224921


##########
plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java:
##########
@@ -110,17 +110,26 @@ public void sequentialApiAccess() {
 
     @Test
     public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
-        int allowedRequests = 200;
+        int allowedRequests = 2000;

Review Comment:
   ```suggestion
           int allowedRequests = 200;
   ```



##########
plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java:
##########
@@ -110,17 +110,26 @@ public void sequentialApiAccess() {
 
     @Test
     public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
-        int allowedRequests = 200;
+        int allowedRequests = 2000;
         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();
+        int issued = s_limitService.getIssued(key.getAccountId());
+        int timeToLive = s_limitService.getTimeToLive();
+
+        // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
+        // so only fail if timeToLive is not exeeded and we didn´t get the requested number of calls
+        assertTrue(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
+                s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), ( ! underLimit) || ((endtime - starttime)/1000000 > timeToLive);

Review Comment:
   ```suggestion
           // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
           // so only fail if timeToLive is not exeeded and we didn´t get the requested number of calls
           assertFalse(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
                   s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), ((endtime - starttime)/1000000 < timeToLive) && underLimit);
   ```



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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1349388912

   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 4911


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


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

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1352185356

   test succeed after 12 seconds, looks good.
   
   ```
   20:39:01 [INFO] Running org.apache.cloudstack.ratelimit.ApiRateLimitTest
   20:39:06 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
   20:39:06 SLF4J: Defaulting to no-operation (NOP) logger implementation
   20:39:06 SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
   20:39:06 log4j:WARN No appenders could be found for logger (org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl).
   20:39:06 log4j:WARN Please initialize the log4j system properly.
   20:39:06 log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
   20:39:10 time elapsed 3347 ms
   20:39:13 [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.544 s - in org.apache.cloudstack.ratelimit.ApiRateLimitTest
   ```


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


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

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1350719625

   @blueorangutan package


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


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

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1351979114

   @blueorangutan package


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


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

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1351791149

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=6984)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6984&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6984&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6984&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=CODE_SMELL)
   
   [![69.6%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '69.6%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_coverage&view=list) [69.6% Coverage](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_duplicated_lines_density&view=list)
   
   


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


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

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#discussion_r1048187925


##########
plugins/api/rate-limit/src/test/java/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java:
##########
@@ -110,17 +110,25 @@ public void sequentialApiAccess() {
 
     @Test
     public void canDoReasonableNumberOfApiAccessPerSecond() throws Exception {
-        int allowedRequests = 200;
+        int allowedRequests = 2000;
         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();
+        int issued = s_limitService.getIssued(key.getAccountId());
+        int timeToLive = s_limitService.getTimeToLive();
+
+        // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
+        assertFalse(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
+                s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), underLimit);

Review Comment:
   ```suggestion
           // this assertion is really invalid as we don´t know if we exceeded the time to live for the amount of api calls (for sure)
           // so only fail if timeToLive is not exeeded and we didn´t get the requested number of calls
           assertFalse(String.format("We should block >%d requests per %d seconds (managed %d, time elapsed %d)",
                   s_limitService.getMaxAllowed(), timeToLive, issued, endtime - startTime), underLimit || ((endtime - starttime)/1000000 > timeToLive);
   ```



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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1350720592

   @DaanHoogland a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


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


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

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1349247931

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=6984)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6984&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6984&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6984&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6984&resolved=false&types=CODE_SMELL)
   
   [![69.6%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png '69.6%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_coverage&view=list) [69.6% Coverage](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6984&metric=new_duplicated_lines_density&view=list)
   
   


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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1352110236

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian :heavy_check_mark: suse15. SL-JID 4944


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


[GitHub] [cloudstack] DaanHoogland merged pull request #6984: make api rate limit test a little more robust

Posted by GitBox <gi...@apache.org>.
DaanHoogland merged PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984


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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1349005202

   @DaanHoogland a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1350702053

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian :heavy_check_mark: suse15. SL-JID 4919


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


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

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1349426561

   # [Codecov](https://codecov.io/gh/apache/cloudstack/pull/6984?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#6984](https://codecov.io/gh/apache/cloudstack/pull/6984?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (528836f) into [main](https://codecov.io/gh/apache/cloudstack/commit/def7ce655df38c89f3dffed1da3ba785d8e2ee3e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (def7ce6) will **increase** coverage by `0.00%`.
   > The diff coverage is `85.71%`.
   
   ```diff
   @@            Coverage Diff            @@
   ##               main    #6984   +/-   ##
   =========================================
     Coverage     11.50%   11.50%           
   - Complexity     7534     7535    +1     
   =========================================
     Files          2492     2492           
     Lines        246775   246782    +7     
     Branches      38559    38560    +1     
   =========================================
   + Hits          28391    28393    +2     
   - Misses       214787   214791    +4     
   - Partials       3597     3598    +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cloudstack/pull/6984?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../cloudstack/ratelimit/ApiRateLimitServiceImpl.java](https://codecov.io/gh/apache/cloudstack/pull/6984/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9hcGkvcmF0ZS1saW1pdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvY2xvdWRzdGFjay9yYXRlbGltaXQvQXBpUmF0ZUxpbWl0U2VydmljZUltcGwuamF2YQ==) | `70.10% <85.71%> (+1.21%)` | :arrow_up: |
   | [...apache/cloudstack/syslog/AlertsSyslogAppender.java](https://codecov.io/gh/apache/cloudstack/pull/6984/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9hbGVydC1oYW5kbGVycy9zeXNsb2ctYWxlcnRzL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL3N5c2xvZy9BbGVydHNTeXNsb2dBcHBlbmRlci5qYXZh) | `56.49% <0.00%> (-2.26%)` | :arrow_down: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1350669750

   @davidjumani a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


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


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

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6984:
URL: https://github.com/apache/cloudstack/pull/6984#issuecomment-1354389733

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 4978


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