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/24 15:39:08 UTC

[GitHub] rabbah commented on a change in pull request #3485: Action time limit test cleanup

rabbah commented on a change in pull request #3485: Action time limit test cleanup
URL: https://github.com/apache/incubator-openwhisk/pull/3485#discussion_r176912283
 
 

 ##########
 File path: tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
 ##########
 @@ -63,37 +60,154 @@ class ActionLimitsTests extends TestHelpers with WskTestHelpers {
   behavior of "Action limits"
 
   /**
-   * Test a long running action that exceeds the maximum execution time allowed for action
-   * by setting the action limit explicitly and attempting to run the action for an additional second.
+   * Helper class for the integration test following below.
+   * @param timeout the action timeout limit to be set in test
+   * @param memory the action memory size limit to be set in test
+   * @param logs the action log size limit to be set in test
+   * @param ec the expected exit code when creating the action
+   */
+  sealed case class PermutationTestParameter(timeout: Option[Duration] = None,
+                                             memory: Option[ByteSize] = None,
+                                             logs: Option[ByteSize] = None,
+                                             ec: Int = SUCCESS_EXIT) {
+    override def toString: String =
+      s"timeout: ${toTimeoutString}, memory: ${toMemoryString}, logsize: ${toLogsString}"
+
+    val toTimeoutString = timeout match {
+      case None                                    => "None"
+      case Some(TimeLimit.MIN_DURATION)            => s"${TimeLimit.MIN_DURATION} (= min)"
+      case Some(TimeLimit.STD_DURATION)            => s"${TimeLimit.STD_DURATION} (= std)"
+      case Some(TimeLimit.MAX_DURATION)            => s"${TimeLimit.MAX_DURATION} (= max)"
+      case Some(t) if (t < TimeLimit.MIN_DURATION) => s"${t} (< min)"
+      case Some(t) if (t > TimeLimit.MAX_DURATION) => s"${t} (> max)"
+      case Some(t)                                 => s"${t} (allowed)"
+    }
+
+    val toMemoryString = memory match {
+      case None                                   => "None"
+      case Some(MemoryLimit.minMemory)            => s"${MemoryLimit.minMemory.toMB.MB} (= min)"
+      case Some(MemoryLimit.stdMemory)            => s"${MemoryLimit.stdMemory.toMB.MB} (= std)"
+      case Some(MemoryLimit.maxMemory)            => s"${MemoryLimit.maxMemory.toMB.MB} (= max)"
+      case Some(m) if (m < MemoryLimit.minMemory) => s"${m.toMB.MB} (< min)"
+      case Some(m) if (m > MemoryLimit.maxMemory) => s"${m.toMB.MB} (> max)"
+      case Some(m)                                => s"${m.toMB.MB} (allowed)"
+    }
+
+    val toLogsString = logs match {
+      case None                                  => "None"
+      case Some(LogLimit.MIN_LOGSIZE)            => s"${LogLimit.MIN_LOGSIZE} (= min)"
+      case Some(LogLimit.STD_LOGSIZE)            => s"${LogLimit.STD_LOGSIZE} (= std)"
+      case Some(LogLimit.MAX_LOGSIZE)            => s"${LogLimit.MAX_LOGSIZE} (= max)"
+      case Some(l) if (l < LogLimit.MIN_LOGSIZE) => s"${l} (< min)"
+      case Some(l) if (l > LogLimit.MAX_LOGSIZE) => s"${l} (> max)"
+      case Some(l)                               => s"${l} (allowed)"
+    }
+
+    val toExpectedResultString: String = if (ec == SUCCESS_EXIT) "allow" else "reject"
+  }
+
+  val perms = (// Assert for valid permutations that the values are set correctly
 
 Review comment:
   you can also use `{}` for code block which might be clearer.

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