diff --git a/tests/src/test/scala/system/basic/WskConsoleTests.scala b/tests/src/test/scala/system/basic/WskConsoleTests.scala index c513eec53..b8a7233f5 100644 --- a/tests/src/test/scala/system/basic/WskConsoleTests.scala +++ b/tests/src/test/scala/system/basic/WskConsoleTests.scala @@ -121,4 +121,14 @@ abstract class WskConsoleTests extends TestHelpers with WskTestHelpers { } } + it should "invoke an action and poll activations and verify that action names are quoted." in withAssetCleaner(wskprops) { + (wp, assetHelper) => + val name = "helloRunActivationPoll" + assetHelper.withCleaner(wsk.action, name) { (action, _) => + action.create(name, Some(TestCLIUtils.getTestActionFilename("hello.js"))) + } + val activationId = wsk.action.invoke(name) + val pollResults = wsk.activation.console(duration = 5.second, actionName = Some(name)) + pollResults.stdout should include (s"""Activation: '${name}'""") + } } diff --git a/tests/src/test/scala/system/basic/WskSdkTests.scala b/tests/src/test/scala/system/basic/WskSdkTests.scala index b36c823db..574d35b69 100644 --- a/tests/src/test/scala/system/basic/WskSdkTests.scala +++ b/tests/src/test/scala/system/basic/WskSdkTests.scala @@ -31,6 +31,8 @@ import common.Wsk import common.WskProps import common.WskTestHelpers +import scala.sys.process._ + @RunWith(classOf[JUnitRunner]) class WskSdkTests extends TestHelpers with WskTestHelpers { @@ -82,6 +84,76 @@ class WskSdkTests extends TestHelpers with WskTestHelpers { } } + it should "download docker sdk when blackbox.tar.gz exists, and docker name should be quoted in error." in { + val fileName = "blackbox.tar.gz" + val dir = File.createTempFile("wskinstall", ".tmp") + dir.delete() + dir.mkdir() should be(true) + val file = new File(dir, fileName) + file.createNewFile should be (true) + try { + wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"), + workingDir = dir, + expectedExitCode = 1).stderr should include( + s"""The file '${fileName}' already exists. Delete it and retry.""") + } finally { + file.delete() + FileUtils.deleteDirectory(dir) + } + } + + it should "download ios sdk when OpenWhiskIOSStarterApp.zip exists, and ios name should be quoted in error." in { + val fileName = "OpenWhiskIOSStarterApp.zip" + val dir = File.createTempFile("wskinstall", ".tmp") + dir.delete() + dir.mkdir() should be(true) + val file = new File(dir, fileName) + file.createNewFile should be (true) + try { + wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "ios"), + workingDir = dir, + expectedExitCode = 1).stderr should include( + s"""The file '${fileName}' already exists. Delete it and retry.""") + } finally { + file.delete() + FileUtils.deleteDirectory(dir) + } + } + + it should "download ios sdk, check filename is quoted in error when create fails." in { + val fileName = "OpenWhiskIOSStarterApp.zip" + val dir = File.createTempFile("wskinstall", ".tmp") + dir.delete() + dir.mkdir() should be(true) + Seq("chmod", "555", dir.getAbsolutePath).!! + try { + wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "ios"), + workingDir = dir, + expectedExitCode = 1).stderr should include( + s"""Error creating SDK file '${fileName}':""") + } finally { + FileUtils.deleteDirectory(dir) + } + } + + it should "download docker sdk twice, check directory is quoted in error when create fails." in { + val dir = File.createTempFile("wskinstall", ".tmp") + dir.delete() + dir.mkdir() should be(true) + try { + wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"), + workingDir = dir).stdout should include( + s"""The docker skeleton is now installed at the current directory.""") + + wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"), + workingDir = dir, + expectedExitCode = 1).stderr should include( + s"""The directory 'dockerSkeleton' already exists. Delete it and retry.""") + } finally { + FileUtils.deleteDirectory(dir) + } + } + it should "download iOS sdk" in { val dir = File.createTempFile("wskinstall", ".tmp") dir.delete() diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala index ce3844991..73780b08f 100644 --- a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala +++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala @@ -262,6 +262,32 @@ abstract class ApiGwTests extends BaseApiGwTests { verifyMissingField(rr) } + it should "api create should fail if action is not a web action" in { + val testName = "CLI_APIGWTEST_RO1" + val testbasepath = "/" + testName + "_bp" + val testrelpath = "/path" + val testnewrelpath = "/path_new" + val testurlop = "get" + val testapiname = testName + " API Name" + val actionName = testName + "_action" + try { + // Create the action for the API. It must be a "web-action" action. + val file = TestCLIUtils.getTestActionFilename(s"echo.js") + wsk.action.create(name = actionName, artifact = Some(file), expectedExitCode = createCode) + + var rr = apiCreate( + basepath = Some(testbasepath), + relpath = Some(testrelpath), + operation = Some(testurlop), + action = Some(actionName), + apiname = Some(testapiname), + expectedExitCode = ERROR_EXIT) + rr.stderr should include(s"""Action '/_/${actionName}' is not a web action. Issue 'wsk action update "${actionName}" --web true' to convert the action to a web action.""") + } finally { + wsk.action.delete(name = actionName, expectedExitCode = DONTCARE_EXIT) + } + } + it should "verify full list output" in { val testName = "CLI_APIGWTEST_RO1" val testbasepath = "/" + testName + "_bp" 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 8c60c9059..45bbdfc15 100644 --- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala +++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala @@ -275,6 +275,19 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers { } } + it should "invoke an action that exits during run and check that the activation summary has the name in quoted" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + val name = "helloRunSummary" + assetHelper.withCleaner(wsk.action, name) { (action, _) => + action.create(name, Some(TestCLIUtils.getTestActionFilename("hello.js"))) + } + val activationId = wsk.action.invoke(name).stdout.split("with id ")(1).trim + wsk.activation.waitForActivation(activationId) + val activationResponse = wsk.activation.get(Some(activationId), summary = Some(true)) + activationResponse.stdout should include(s"""activation result for '/guest/${name}'""") + } + + it should "retrieve the last activation using --last flag" in withAssetCleaner(wskprops) { (wp, assetHelper) => val auth: Seq[String] = Seq("--auth", wskprops.authKey) val includeStr = "hello, undefined!"