rabbah commented on a change in pull request #3840: Remove runtime tests, 
simplify Rest vs CLI test hierarchy, add sniff test for all runtimes
URL: 
https://github.com/apache/incubator-openwhisk/pull/3840#discussion_r200747434
 
 

 ##########
 File path: tests/src/test/scala/common/rest/WskRestOperations.scala
 ##########
 @@ -289,160 +288,106 @@ class RestActionOperations(implicit val actorSystem: 
ActorSystem)
     websecure: Option[String] = None,
     expectedExitCode: Int = OK.intValue)(implicit wp: WskProps): RestResult = {
 
-    val (namespace, actName) = getNamespaceEntityName(name)
-    val (kindTypeByAction, code, artifactName) = artifact match {
-      case Some(artifactFile) => {
-        val ext = getExt(artifactFile)
-        ext match {
-          case ".jar" => {
-            val jar = FileUtils.readFileToByteArray(new File(artifactFile))
-            ("java:default", Base64.getEncoder.encodeToString(jar), 
artifactFile)
-          }
-          case ".zip" => {
-            val zip = FileUtils.readFileToByteArray(new File(artifactFile))
-            ("", Base64.getEncoder.encodeToString(zip), artifactFile)
-          }
-          case ".js" => {
-            ("nodejs:default", FileUtils.readFileToString(new 
File(artifactFile), StandardCharsets.UTF_8), artifactFile)
-          }
-          case ".py" => {
-            ("python:default", FileUtils.readFileToString(new 
File(artifactFile), StandardCharsets.UTF_8), artifactFile)
-          }
-          case ".swift" => {
-            ("swift:default", FileUtils.readFileToString(new 
File(artifactFile), StandardCharsets.UTF_8), artifactFile)
-          }
-          case ".php" => {
-            ("php:default", FileUtils.readFileToString(new File(artifactFile), 
StandardCharsets.UTF_8), artifactFile)
-          }
-          case _ => ("", "", artifactFile)
-        }
-      }
-      case None => ("", "", "")
-    }
-
-    val kindType = docker map { d =>
-      "blackbox"
-    } getOrElse kindTypeByAction
-
+    val (namespace, actionName) = getNamespaceEntityName(name)
     val (paramsInput, annosInput) = getParamsAnnos(parameters, annotations, 
parameterFile, annotationFile, web = web)
-
-    val (params, annos, execByKind) = kind match {
-      case Some(k) => {
+    val (params: Array[JsValue], annos: Array[JsValue], exec: Map[String, 
JsValue]) = kind match {
+      case Some(k) =>
         k match {
-          case "copy" => {
-            val actName = entityName(artifactName)
-            val actionPath = 
Path(s"$basePath/namespaces/$namespace/$noun/$actName")
+          case "copy" =>
+            require(artifact.isDefined, "copy requires an artifact name")
+            val actionName = entityName(artifact.get)
+            val actionPath = 
Path(s"$basePath/namespaces/$namespace/$noun/$actionName")
             val resp = requestEntity(GET, actionPath)
-            if (resp == None)
-              return new RestResult(NotFound)
+            if (resp == None) return new RestResult(NotFound) // NOTE return, 
aborts the method
             else {
               val result = new RestResult(resp.status, getRespData(resp))
               val params = 
result.getFieldListJsObject("parameters").toArray[JsValue]
               val annos = 
result.getFieldListJsObject("annotations").toArray[JsValue]
               val exec = result.getFieldJsObject("exec").fields
-              (params, annos, exec)
+              (paramsInput ++ params, annosInput ++ annos, exec)
             }
-          }
-          case "sequence" => {
-            val comps = convertIntoComponents(artifactName)
+
+          case "sequence" =>
+            require(artifact.isDefined, "sequence requires a component list")
+            val comps = convertIntoComponents(artifact.get)
             val exec =
               if (comps.size > 0) Map("components" -> comps.toJson, "kind" -> 
k.toJson)
-              else
-                Map("kind" -> k.toJson)
-            (paramsInput, annosInput, exec)
-          }
-          case "native" => {
-            val exec =
-              Map("code" -> code.toJson, "kind" -> "blackbox".toJson, "image" 
-> "openwhisk/dockerskeleton".toJson)
+              else Map("kind" -> k.toJson)
             (paramsInput, annosInput, exec)
-          }
-          case _ => {
-            val exec = Map("code" -> code.toJson, "kind" -> k.toJson)
-            (paramsInput, annosInput, exec)
-          }
-        }
-      }
-      case None => (paramsInput, annosInput, Map("code" -> code.toJson, "kind" 
-> kindType.toJson))
-    }
 
-    val exec = execByKind ++ {
-      main map { m =>
-        Map("main" -> m.toJson)
-      } getOrElse Map.empty
-    } ++ {
-      docker map { d =>
-        Map("kind" -> "blackbox".toJson, "image" -> d.toJson)
-      } getOrElse Map.empty
-    }
-
-    val bodyHead = Map("name" -> name.toJson, "namespace" -> namespace.toJson)
-
-    val (updateExistence, resultExistence) = update match {
 
 Review comment:
   I removed this because this is mimicking CLI functionality and I think 
should be considered invalid for the REST operations. If this was an SDK I can 
see supporting this but here the tests should be making pass through calls and 
not really doing anything fancy. I kept `copy` support although I was tempted 
to remove that also.

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