You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/06/26 16:00:09 UTC

[incubator-openwhisk-cli] 29/36: Allow docker actions with zip files. (#2112)

This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git

commit e701f5598a8cffcd11d673a542bc65c066cf2741
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Sat Jun 17 11:54:29 2017 -0400

    Allow docker actions with zip files.  (#2112)
    
    * Allow docker actions with zip files.
    Add native action for binary injection.
    Add note about breaking change for --docker option.
    
    * Separate dep fetching from rest of build to avoid repeated fetches when none changed.
---
 .../test/scala/system/basic/WskBasicTests.scala    |  8 ++---
 .../whisk/core/cli/test/WskBasicUsageTests.scala   | 39 ++++++++++++++--------
 2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/tests/src/test/scala/system/basic/WskBasicTests.scala b/tests/src/test/scala/system/basic/WskBasicTests.scala
index 2311f6a..4e379d0 100644
--- a/tests/src/test/scala/system/basic/WskBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicTests.scala
@@ -273,7 +273,7 @@ class WskBasicTests
         (wp, assetHelper) =>
             assetHelper.withCleaner(wsk.action, name) {
                 // this docker image will be need to be pulled from dockerhub and hence has to be published there first
-                (action, _) => action.create(name, Some("openwhisk/example"), kind = Some("docker"))
+                (action, _) => action.create(name, None, docker = Some("openwhisk/example"))
             }
 
             val args = Map("payload" -> "test".toJson)
@@ -291,7 +291,7 @@ class WskBasicTests
         (wp, assetHelper) =>
             assetHelper.withCleaner(wsk.action, name) {
                 // this docker image will be need to be pulled from dockerhub and hence has to be published there first
-                (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("blackbox.zip")), kind = Some("docker"))
+                (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("blackbox.zip")), kind = Some("native"))
             }
 
             val run = wsk.action.invoke(name, Map())
@@ -348,7 +348,7 @@ class WskBasicTests
             wsk.action.get(name, fieldFilter = Some("annotations")).stdout should include regex (s"""$successMsg annotations\n\\[\\s+\\{\\s+"key":\\s+"exec",\\s+"value":\\s+"nodejs:6"\\s+\\}\\s+\\]""")
             wsk.action.get(name, fieldFilter = Some("limits")).stdout should include regex (s"""$successMsg limits\n\\{\\s+"timeout":\\s+60000,\\s+"memory":\\s+256,\\s+"logs":\\s+10\\s+\\}""")
             wsk.action.get(name, fieldFilter = Some("namespace")).stdout should include regex (s"""(?i)$successMsg namespace\n$ns_regex_list""")
-            wsk.action.get(name, fieldFilter = Some("invalid"), expectedExitCode = ERROR_EXIT).stderr should include("error: Invalid field filter 'invalid'.")
+            wsk.action.get(name, fieldFilter = Some("invalid"), expectedExitCode = MISUSE_EXIT).stderr should include("error: Invalid field filter 'invalid'.")
             wsk.action.get(name, fieldFilter = Some("publish")).stdout should include(s"""$successMsg publish\nfalse""")
     }
 
@@ -485,7 +485,7 @@ class WskBasicTests
         val name = "dockerContainer"
         (wp, assetHelper) =>
             assetHelper.withCleaner(wsk.action, name) {
-                (action, _) => action.create(name, Some("fake-container"), kind = Some("docker"))
+                (action, _) => action.create(name, None, docker = Some("fake-container"))
             }
 
             wsk.action.get(name).stdout should not include (""""code"""")
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
index 8513875..83f27d8 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
@@ -273,7 +273,15 @@ class WskBasicUsageTests
             val file = Some(TestUtils.getTestActionFilename("hello.js"))
             assetHelper.withCleaner(wsk.action, name) { (action, name) => action.create(name, file) }
             // Update it with a missing file
-            wsk.action.create("updateMissingFile", Some("notfound"), update = true, expectedExitCode = MISUSE_EXIT)
+            wsk.action.create(name, Some("notfound"), update = true, expectedExitCode = MISUSE_EXIT)
+    }
+
+    it should "reject action update for sequence with no components" in withAssetCleaner(wskprops) {
+        (wp, assetHelper) =>
+            val name = "updateMissingComponents"
+            val file = Some(TestUtils.getTestActionFilename("hello.js"))
+            assetHelper.withCleaner(wsk.action, name) { (action, name) => action.create(name, file) }
+            wsk.action.create(name, None, update = true, kind = Some("sequence"), expectedExitCode = MISUSE_EXIT)
     }
 
     it should "create, and get an action to verify parameter and annotation parsing" in withAssetCleaner(wskprops) {
@@ -467,13 +475,13 @@ class WskBasicUsageTests
     }
 
     it should "create, and invoke an action that utilizes an invalid docker container with appropriate error" in withAssetCleaner(wskprops) {
-        val name = "invalid dockerContainer"
+        val name = "invalidDockerContainer"
         val containerName = s"bogus${Random.alphanumeric.take(16).mkString.toLowerCase}"
 
         (wp, assetHelper) =>
             assetHelper.withCleaner(wsk.action, name) {
                 // docker name is a randomly generate string
-                (action, _) => action.create(name, Some(containerName), kind = Some("docker"))
+                (action, _) => action.create(name, None, docker = Some(containerName))
             }
 
             val run = wsk.action.invoke(name)
@@ -608,6 +616,9 @@ class WskBasicUsageTests
                     assert(stdout.startsWith(s"ok: got action $name, displaying field annotations\n"))
                     removeCLIHeader(stdout).parseJson shouldBe JsArray(
                         JsObject(
+                            "key" -> JsString("exec"),
+                            "value" -> JsString("nodejs:6")),
+                        JsObject(
                             "key" -> JsString("web-export"),
                             "value" -> JsBoolean(webEnabled || rawEnabled)),
                         JsObject(
@@ -615,10 +626,7 @@ class WskBasicUsageTests
                             "value" -> JsBoolean(rawEnabled)),
                         JsObject(
                             "key" -> JsString("final"),
-                            "value" -> JsBoolean(webEnabled || rawEnabled)),
-                        JsObject(
-                            "key" -> JsString("exec"),
-                            "value" -> JsString("nodejs:6")))
+                            "value" -> JsBoolean(webEnabled || rawEnabled)))
                 }
     }
 
@@ -628,8 +636,8 @@ class WskBasicUsageTests
             val file = Some(TestUtils.getTestActionFilename("echo.js"))
             val invalidInput = "bogus"
             val errorMsg = s"Invalid argument '$invalidInput' for --web flag. Valid input consist of 'yes', 'true', 'raw', 'false', or 'no'."
-            wsk.action.create(name, file, web = Some(invalidInput), expectedExitCode = ERROR_EXIT).stderr should include(errorMsg)
-            wsk.action.create(name, file, web = Some(invalidInput), update = true, expectedExitCode = ERROR_EXIT).stderr should include(errorMsg)
+            wsk.action.create(name, file, web = Some(invalidInput), expectedExitCode = MISUSE_EXIT).stderr should include(errorMsg)
+            wsk.action.create(name, file, web = Some(invalidInput), update = true, expectedExitCode = MISUSE_EXIT).stderr should include(errorMsg)
     }
 
     it should "invoke action while not encoding &, <, > characters" in withAssetCleaner(wskprops) {
@@ -1168,9 +1176,9 @@ class WskBasicUsageTests
         val invalidArgsMsg = "error: Invalid argument(s)"
         val tooFewArgsMsg = invalidArgsMsg + "."
         val tooManyArgsMsg = invalidArgsMsg + ": "
-        val actionNameActionReqMsg = "An action name and action are required."
+        val actionNameActionReqMsg = "An action name and code artifact are required."
         val actionNameReqMsg = "An action name is required."
-        val actionOptMsg = "An action is optional."
+        val actionOptMsg = "A code artifact is optional."
         val packageNameReqMsg = "A package name is required."
         val packageNameBindingReqMsg = "A package name and binding name are required."
         val ruleNameReqMsg = "A rule name is required."
@@ -1273,9 +1281,12 @@ class WskBasicUsageTests
 
         invalidArgs foreach {
             case (cmd, err) =>
-                val stderr = wsk.cli(cmd ++ wskprops.overrides, expectedExitCode = ERROR_EXIT).stderr
-                stderr should include(err)
-                stderr should include("Run 'wsk --help' for usage.")
+                withClue(cmd) {
+                    val rr = wsk.cli(cmd ++ wskprops.overrides, expectedExitCode = ANY_ERROR_EXIT)
+                    rr.exitCode should (be(ERROR_EXIT) or be(MISUSE_EXIT))
+                    rr.stderr should include(err)
+                    rr.stderr should include("Run 'wsk --help' for usage.")
+                }
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.