You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/03/19 12:44:58 UTC
[GitHub] sven-lange-last closed pull request #3461: Add action creation test with maximum time limit
sven-lange-last closed pull request #3461: Add action creation test with maximum time limit
URL: https://github.com/apache/incubator-openwhisk/pull/3461
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/tests/dat/actions/timeoutLean.js b/tests/dat/actions/timeoutLean.js
new file mode 100644
index 0000000000..7a8f89c86a
--- /dev/null
+++ b/tests/dat/actions/timeoutLean.js
@@ -0,0 +1,19 @@
+/**
+ * Node.js based OpenWhisk action that waits for the specified number
+ * of milliseconds before returning. Uses a timer instead of a busy loop.
+ * The function actually waits slightly longer than requested.
+ *
+ * @param parm Object with Number property timeoutInMs
+ * @returns Object with String property msg describing how long the function waited
+ */
+function main(parm) {
+ console.log("Specified timeout is " + parm.timeoutInMs + " ms.")
+
+ return new Promise(function(resolve, reject) {
+ setTimeout(function () {
+ const result = { msg: "Terminated successfully after at least " + parm.timeoutInMs + " ms." }
+ console.log(result.msg)
+ resolve(result)
+ }, parm.timeoutInMs)
+ })
+}
diff --git a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
index 5c77f30ec9..8093c97a38 100644
--- a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
+++ b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
@@ -19,16 +19,13 @@ package whisk.core.limits
import akka.http.scaladsl.model.StatusCodes.RequestEntityTooLarge
import akka.http.scaladsl.model.StatusCodes.BadGateway
-
import java.io.File
import java.io.PrintWriter
import scala.concurrent.duration.DurationInt
import scala.language.postfixOps
-
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
import common.ActivationResult
import common.TestHelpers
import common.TestUtils
@@ -38,9 +35,7 @@ import common.WskProps
import common.WskTestHelpers
import spray.json._
import spray.json.DefaultJsonProtocol._
-import whisk.core.entity.ActivationEntityLimit
-import whisk.core.entity.ActivationResponse
-import whisk.core.entity.Exec
+import whisk.core.entity.{ActivationEntityLimit, ActivationResponse, Exec, TimeLimit}
import whisk.core.entity.size._
import whisk.http.Messages
@@ -53,6 +48,9 @@ class ActionLimitsTests extends TestHelpers with WskTestHelpers {
val defaultDosAction = TestUtils.getTestActionFilename("timeout.js")
val allowedActionDuration = 10 seconds
+ val defaultTimeoutAction = TestUtils.getTestActionFilename("timeoutLean.js")
+ val activationTimeLimit = TimeLimit.MAX_DURATION
+
val testActionsDir = WhiskProperties.getFileRelativeToWhiskHome("tests/dat/actions")
val actionCodeLimit = Exec.sizeLimit
@@ -97,6 +95,15 @@ class ActionLimitsTests extends TestHelpers with WskTestHelpers {
}
}
+ it should "create an action with maximum time limit" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
+ val name = "TestActionWithMaxTimeLimit-" + System.currentTimeMillis()
+ assetHelper.withCleaner(wsk.action, name, confirmDelete = false) { (action, _) =>
+ withClue(s"Could not create action '${name}' with timeout ${activationTimeLimit}:") {
+ action.create(name, Some(defaultTimeoutAction), timeout = Some(activationTimeLimit))
+ }
+ }
+ }
+
it should "succeed but truncate logs, if log size exceeds its limit" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val bytesPerLine = 16
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services