rabbah commented on a change in pull request #2533: Add the ability to define
user-specific throttles.
URL:
https://github.com/apache/incubator-openwhisk/pull/2533#discussion_r129856555
##########
File path: tests/src/test/scala/limits/ThrottleTests.scala
##########
@@ -278,3 +280,89 @@ class ThrottleTests
waitForActivations(combinedResults.par)
}
}
+
+@RunWith(classOf[JUnitRunner])
+class NamespaceSpecificThrottleTests
+ extends FlatSpec
+ with TestHelpers
+ with WskTestHelpers
+ with Matchers
+ with BeforeAndAfterAll {
+
+ val wskadmin = new RunWskAdminCmd {}
+ val wsk = new Wsk
+
+ val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+
+ // Create a subject with rate limits == 0
+ val zeroProps = getAdditionalTestSubject("zeroSubject")
+ wskadmin.cli(Seq("limits", "set", zeroProps.namespace,
"--invocationsPerMinute", "0", "--firesPerMinute", "0",
"--concurrentInvocations", "0"))
+
+ // Create a subject where only the concurrency limit is set to 0
+ val zeroConcProps = getAdditionalTestSubject("zeroConcSubject")
+ wskadmin.cli(Seq("limits", "set", zeroConcProps.namespace,
"--concurrentInvocations", "0"))
+
+ // Create a subject where the rate limits are set to 1
+ val oneProps = getAdditionalTestSubject("oneSubject")
+ wskadmin.cli(Seq("limits", "set", oneProps.namespace,
"--invocationsPerMinute", "1", "--firesPerMinute", "1"))
+
+ override def afterAll() = {
+ disposeAdditionalTestSubject(zeroProps.namespace)
+ disposeAdditionalTestSubject(zeroConcProps.namespace)
+ disposeAdditionalTestSubject(oneProps.namespace)
+ }
+
+ behavior of "Namespace-specific throttles"
+
+ it should "respect overridden rate-throttles of 0" in
withAssetCleaner(zeroProps) {
+ (wp, assetHelper) =>
+ implicit val props = wp
+ val triggerName = "zeroTrigger"
+ val actionName = "zeroAction"
+
+ assetHelper.withCleaner(wsk.action, actionName) {
+ (action, _) => action.create(actionName, defaultAction)
+ }
+ assetHelper.withCleaner(wsk.trigger, triggerName) {
+ (trigger, _) => trigger.create(triggerName)
+ }
+
+ wsk.action.invoke(actionName, expectedExitCode =
TestUtils.THROTTLED)
+ wsk.trigger.fire(triggerName, expectedExitCode =
TestUtils.THROTTLED)
+ }
+
+ it should "respect overridden rate-throttles of 1" in
withAssetCleaner(oneProps) {
+ (wp, assetHelper) =>
+ implicit val props = wp
+ val triggerName = "oneTrigger"
+ val actionName = "oneAction"
+
+ assetHelper.withCleaner(wsk.action, actionName) {
+ (action, _) => action.create(actionName, defaultAction)
+ }
+ assetHelper.withCleaner(wsk.trigger, triggerName) {
+ (trigger, _) => trigger.create(triggerName)
+ }
+
+ // One invoke should be allowed, the second one throttled
+ wsk.action.invoke(actionName)
+ wsk.action.invoke(actionName, expectedExitCode =
TestUtils.THROTTLED)
Review comment:
could check the error message to make sure it's the rate per minute throttle
and not the concurrent throttle for tighter check.
----------------------------------------------------------------
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