[GitHub] dubeejw commented on a change in pull request #3109: Add binary, image, and main properties to WhiskActionMetaData

2018-02-12 Thread GitBox
dubeejw commented on a change in pull request #3109: Add binary, image, and 
main properties to WhiskActionMetaData
URL: 
https://github.com/apache/incubator-openwhisk/pull/3109#discussion_r167669280
 
 

 ##
 File path: common/scala/src/main/scala/whisk/core/entity/Exec.scala
 ##
 @@ -95,9 +95,23 @@ sealed abstract class CodeExec[+T <% SizeConversion] 
extends Exec {
 
 sealed abstract class ExecMetaData extends ExecMetaDataBase {
 
+  /** An entrypoint (typically name of 'main' function). 'None' means a 
default value will be used. */
+  val entryPoint: Option[String]
+
+  /** The runtime image (either built-in or a public image). */
+  val image: ImageName
+
   /** Indicates if a container image is required from the registry to execute 
the action. */
   val pull: Boolean
 
+  /**
+   * Indicates whether the code is stored in a text-readable or binary format.
+   * The binary bit may be read from the database but currently it is always 
computed
+   * when the "code" is moved to an attachment this may get changed to avoid 
recomputing
+   * the binary property.
+   */
+  val binary: Boolean
 
 Review comment:
   Hmm, I think they all should be there except `code`.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #3109: Add binary, image, and main properties to WhiskActionMetaData

2018-02-12 Thread GitBox
dubeejw commented on a change in pull request #3109: Add binary, image, and 
main properties to WhiskActionMetaData
URL: 
https://github.com/apache/incubator-openwhisk/pull/3109#discussion_r167661815
 
 

 ##
 File path: 
tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
 ##
 @@ -159,26 +159,136 @@ class ActionsApiTests extends ControllerTestCommon with 
WhiskActionsApi {
 }
   }
 
+  def getExecPermutations() = {
+implicit val tid = transid()
+
+// BlackBox: binary: true, main: bbMain
+val bbAction1 = WhiskAction(namespace, aname(), bb("bb", "RHViZWU=", 
Some("bbMain")))
+val bbAction1Content = Map("exec" -> Map(
+  "kind" -> Exec.BLACKBOX,
+  "code" -> "RHViZWU=",
+  "image" -> "bb",
+  "main" -> "bbMain")).toJson.asJsObject
+val bbAction1ExecMetaData = blackBoxMetaData("bb", Some("bbMain"), true)
+
+// BlackBox: binary: false, main: bbMain
+val bbAction2 = WhiskAction(namespace, aname(), bb("bb", "", 
Some("bbMain")))
+val bbAction2Content =
+  Map("exec" -> Map("kind" -> Exec.BLACKBOX, "code" -> "", "image" -> 
"bb", "main" -> "bbMain")).toJson.asJsObject
+val bbAction2ExecMetaData = blackBoxMetaData("bb", Some("bbMain"), false)
+
+// BlackBox: binary: true, no main
+val bbAction3 = WhiskAction(namespace, aname(), bb("bb", "RHViZWU="))
+val bbAction3Content =
+  Map("exec" -> Map("kind" -> Exec.BLACKBOX, "code" -> "RHViZWU=", "image" 
-> "bb")).toJson.asJsObject
+val bbAction3ExecMetaData = blackBoxMetaData("bb", None, true)
+
+// BlackBox: binary: false, no main
+val bbAction4 = WhiskAction(namespace, aname(), bb("bb", ""))
+val bbAction4Content = Map("exec" -> Map("kind" -> Exec.BLACKBOX, "code" 
-> "", "image" -> "bb")).toJson.asJsObject
+val bbAction4ExecMetaData = blackBoxMetaData("bb", None, false)
+
+// Attachment: binary: true, main: javaMain
+val javaAction1 = WhiskAction(namespace, aname(), javaDefault("RHViZWU=", 
Some("javaMain")))
+val javaAction1Content =
+  Map("exec" -> Map("kind" -> JAVA_DEFAULT, "code" -> "RHViZWU=", "main" 
-> "javaMain")).toJson.asJsObject
+val javaAction1ExecMetaData = javaMetaData(Some("javaMain"), true)
+
+// String: binary: true, main: jsMain
+val jsAction1 = WhiskAction(namespace, aname(), jsDefault("RHViZWU=", 
Some("jsMain")))
+val jsAction1Content =
+  Map("exec" -> Map("kind" -> NODEJS6, "code" -> "RHViZWU=", "main" -> 
"jsMain")).toJson.asJsObject
+val jsAction1ExecMetaData = js6MetaData(Some("jsMain"), true)
+
+// String: binary: false, main: jsMain
+val jsAction2 = WhiskAction(namespace, aname(), jsDefault("", 
Some("jsMain")))
+val jsAction2Content = Map("exec" -> Map("kind" -> NODEJS6, "code" -> "", 
"main" -> "jsMain")).toJson.asJsObject
+val jsAction2ExecMetaData = js6MetaData(Some("jsMain"), false)
+
+// String: binary: true, no main
+val jsAction3 = WhiskAction(namespace, aname(), jsDefault("RHViZWU="))
+val jsAction3Content = Map("exec" -> Map("kind" -> NODEJS6, "code" -> 
"RHViZWU=")).toJson.asJsObject
+val jsAction3ExecMetaData = js6MetaData(None, true)
+
+// String: binary: false, no main
+val jsAction4 = WhiskAction(namespace, aname(), jsDefault(""))
+val jsAction4Content = Map("exec" -> Map("kind" -> NODEJS6, "code" -> 
"")).toJson.asJsObject
+val jsAction4ExecMetaData = js6MetaData(None, false)
+
+// Sequence
+val component = WhiskAction(namespace, aname(), jsDefault("??"))
+put(entityStore, component)
+val components = 
Vector(s"/$namespace/${component.name}").map(stringToFullyQualifiedName(_))
+val seqAction = WhiskAction(namespace, aname(), sequence(components), 
seqParameters(components))
+val seqActionContent = JsObject(
+  "exec" -> JsObject("kind" -> "sequence".toJson, "components" -> 
JsArray(s"/$namespace/${component.name}".toJson)))
+val seqActionExecMetaData = sequenceMetaData(components)
+
+Seq(
+  (bbAction1, bbAction1Content, bbAction1ExecMetaData),
+  (bbAction2, bbAction2Content, bbAction2ExecMetaData),
+  (bbAction3, bbAction3Content, bbAction3ExecMetaData),
+  (bbAction4, bbAction4Content, bbAction4ExecMetaData),
+  (javaAction1, javaAction1Content, javaAction1ExecMetaData),
+  (jsAction1, jsAction1Content, jsAction1ExecMetaData),
+  (jsAction2, jsAction2Content, jsAction2ExecMetaData),
+  (jsAction3, jsAction3Content, jsAction3ExecMetaData),
+  (jsAction4, jsAction4Content, jsAction4ExecMetaData),
+  (seqAction, seqActionContent, seqActionExecMetaData))
+  }
+
   it should "get action using code query parameter" in {
 implicit val tid = transid()
-val action = WhiskAction(namespace, aname(), jsDefault("??"), 
Parameters("x", "b"))
 
-put(entityStore, action)
+getExecPermutations.foreach {
+  case (action, content, execMetaData) =>
+val expectedWhiskAction = WhiskAction(
+  action.namespace,
+ 

[GitHub] dubeejw commented on a change in pull request #3109: Add binary, image, and main properties to WhiskActionMetaData

2017-12-15 Thread GitBox
dubeejw commented on a change in pull request #3109: Add binary, image, and 
main properties to WhiskActionMetaData
URL: 
https://github.com/apache/incubator-openwhisk/pull/3109#discussion_r157277534
 
 

 ##
 File path: 
tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
 ##
 @@ -190,7 +190,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon 
with BeforeAndAfterEac
 WhiskActionMetaData(
   actionName.path,
   actionName.name,
-  js6MetaData(),
+  js6MetaData(binary = false),
 
 Review comment:
   The binary field could be optional and default to a value of `false`.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #3109: Add binary, image, and main properties to WhiskActionMetaData

2017-12-15 Thread GitBox
dubeejw commented on a change in pull request #3109: Add binary, image, and 
main properties to WhiskActionMetaData
URL: 
https://github.com/apache/incubator-openwhisk/pull/3109#discussion_r157281385
 
 

 ##
 File path: tests/src/test/scala/whisk/core/entity/test/ExecHelpers.scala
 ##
 @@ -80,6 +82,12 @@ trait ExecHelpers extends Matchers with WskActorSystem with 
StreamLogging {
 CodeExecAsAttachment(manifest, attachment, main.map(_.trim))
   }
 
+  protected def javaMetaData(main: Option[String] = None, binary: Boolean) = {
 
 Review comment:
   `binary` can be optional and default to `true`.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #3109: Add binary, image, and main properties to WhiskActionMetaData

2017-12-15 Thread GitBox
dubeejw commented on a change in pull request #3109: Add binary, image, and 
main properties to WhiskActionMetaData
URL: 
https://github.com/apache/incubator-openwhisk/pull/3109#discussion_r157281385
 
 

 ##
 File path: tests/src/test/scala/whisk/core/entity/test/ExecHelpers.scala
 ##
 @@ -80,6 +82,12 @@ trait ExecHelpers extends Matchers with WskActorSystem with 
StreamLogging {
 CodeExecAsAttachment(manifest, attachment, main.map(_.trim))
   }
 
+  protected def javaMetaData(main: Option[String] = None, binary: Boolean) = {
 
 Review comment:
   `binary` can be optional and default to `true`.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] dubeejw commented on a change in pull request #3109: Add binary, image, and main properties to WhiskActionMetaData

2017-12-15 Thread GitBox
dubeejw commented on a change in pull request #3109: Add binary, image, and 
main properties to WhiskActionMetaData
URL: 
https://github.com/apache/incubator-openwhisk/pull/3109#discussion_r157277534
 
 

 ##
 File path: 
tests/src/test/scala/whisk/core/controller/test/WebActionsApiTests.scala
 ##
 @@ -190,7 +190,7 @@ trait WebActionsApiBaseTests extends ControllerTestCommon 
with BeforeAndAfterEac
 WhiskActionMetaData(
   actionName.path,
   actionName.name,
-  js6MetaData(),
+  js6MetaData(binary = false),
 
 Review comment:
   The binary field could be optional and default to a value of `false`.


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:
us...@infra.apache.org


With regards,
Apache Git Services