tysonnorris commented on a change in pull request #3656: Adjust the behavior 
when update controller cluster
URL: 
https://github.com/apache/incubator-openwhisk/pull/3656#discussion_r218628376
 
 

 ##########
 File path: tests/src/test/scala/whisk/common/ForcibleSemaphoreTests.scala
 ##########
 @@ -85,4 +85,18 @@ class ForcibleSemaphoreTests extends FlatSpec with Matchers 
{
       acquires should contain theSameElementsAs result
     }
   }
+
+  it should "set the max allowed permits dynamically" in {
+    val s = new ForcibleSemaphore(10)
+    s.tryAcquire(2) shouldBe true // 8 permits left
+
+    s.setMaxPermits(5) // reduce max permits
+    s.availablePermits shouldBe 3
+
+    s.setMaxPermits(10) // increase max permits
+    s.availablePermits shouldBe 8
+
+    s.setMaxPermits(10) // nothing changed
+    s.availablePermits shouldBe 8
 
 Review comment:
   Please update the test to include:
   * hitting the case where `if delta < 0 =>` (I think in the case where 
permits are exhausted, and then there is also a reduction in maxPermits?)
   * concurrently executing tryAquire/forceAquire/release while setMaxPermits 
is in flight (I think that you will still end up with inaccurate permits, e.g. 
if release is invoked while setMaxPermits is incomplete)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to