remove whisk object (#1878)
diff --git a/catalog/deprecate.sh b/catalog/deprecate.sh
deleted file mode 100755
index 143aa63..0000000
--- a/catalog/deprecate.sh
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/bin/bash
-#
-# This script is used to deprecate the packages and actions, which have their names changed
-# after the installation of the catalog repository.
-#
-
-# The first argument is the catalog authentication key, which can be passed via either
-# a file or the key itself.
-SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)"
-OPENWHISK_HOME="$SCRIPTDIR/.."
-CATALOG_AUTH_KEY=${1:-"$OPENWHISK_HOME/ansible/files/auth.whisk.system"}
-
-# If the auth key file exists, read the key in the file. Otherwise, take the
-# first argument as the key itself.
-if [ -f "$CATALOG_AUTH_KEY" ]; then
- CATALOG_AUTH_KEY=`cat $CATALOG_AUTH_KEY`
-fi
-
-# Make sure that the catalog_auth_key is not empty.
-: ${CATALOG_AUTH_KEY:?"CATALOG_AUTH_KEY must be set and non-empty"}
-
-# The api host is passed as the second argument. If it is not provided, take the edge
-# host from the whisk properties file.
-API_HOST=$2
-if [ -z "$API_HOST" ]; then
- WHISKPROPS_FILE="$OPENWHISK_HOME/whisk.properties"
- if [ ! -f "$WHISKPROPS_FILE" ]; then
- echo "API_HOST must be set and non-empty."
- exit 1
- fi
- API_HOST=`fgrep edge.host= "$WHISKPROPS_FILE" | cut -d'=' -f2`
-fi
-
-# Make sure that the api_host is not empty.
-: ${API_HOST:?"API_HOST must be set and non-empty"}
-
-# The api host is passed as the third argument. If it is not provided, take "/whisk.system"
-# as the default value.
-WHISK_NAMESPACE=${3:-"/whisk.system"}
-
-# If the WHISK_NAMESPACE does not start with a forward slash, add it.
-if [[ $WHISK_NAMESPACE != \/* ]] ; then
- WHISK_NAMESPACE="/$WHISK_NAMESPACE"
-fi
-
-function addPackageAnnotation() {
- PACKAGE_NAME=$1
- REST=("${@:2}")
- CMD_ARRAY=("$OPENWHISK_HOME/bin/wsk" -i --apihost "$API_HOST" package update --auth "$CATALOG_AUTH_KEY" "$WHISK_NAMESPACE/$PACKAGE_NAME" "${REST[@]}")
- export WSK_CONFIG_FILE= # override local property file to avoid namespace clashes
- "${CMD_ARRAY[@]}" &
- PID=$!
- PIDS+=($PID)
- echo "Deprecating package $PACKAGE_NAME"
-}
-
-function addActionAnnotation() {
- ACTION_NAME=$1
- REST=("${@:2}")
- CMD_ARRAY=("$OPENWHISK_HOME/bin/wsk" -i --apihost "$API_HOST" action update --auth "$CATALOG_AUTH_KEY" "$WHISK_NAMESPACE/$ACTION_NAME" "${REST[@]}")
- export WSK_CONFIG_FILE= # override local property file to avoid namespace clashes
- "${CMD_ARRAY[@]}" &
- PID=$!
- PIDS+=($PID)
- echo "Deprecating action $ACTION_NAME"
-}
-
-# PIDS is the list of ongoing processes and ERRORS the total number of processes that failed
-PIDS=()
-ERRORS=0
-
-function waitForAll() {
- for pid in ${PIDS[@]}; do
- wait $pid
- STATUS=$?
- echo "$pid finished with status $STATUS"
- if [ $STATUS -ne 0 ]
- then
- let ERRORS=ERRORS+1
- fi
- done
- PIDS=()
-}
-
-echo Deprecating the open catalog package util
-addPackageAnnotation util \
- -a deprecated true
-
-array=("util/cat" "util/date" "util/head" "util/sort" "util/split" "samples/echo")
-for i in "${array[@]}"
-do
- echo Deprecating the open catalog action $i
- addActionAnnotation $i \
- -a deprecated true
-done
-
-waitForAll
-
-exit
\ No newline at end of file
diff --git a/tests/src/actionContainers/NodeJsActionContainerTests.scala b/tests/src/actionContainers/NodeJsActionContainerTests.scala
index 46f38fe..20f7d7a 100644
--- a/tests/src/actionContainers/NodeJsActionContainerTests.scala
+++ b/tests/src/actionContainers/NodeJsActionContainerTests.scala
@@ -31,8 +31,6 @@
lazy val nodejsContainerImageName = "nodejsaction"
- val hasDeprecationWarnings = true
-
override def withActionContainer(env: Map[String, String] = Map.empty)(code: ActionContainer => Unit) = {
withContainer(nodejsContainerImageName, env)(code)
}
@@ -157,126 +155,6 @@
}
}
- it should "not warn when using whisk.done" in {
- val (out, err) = withNodeJsContainer { c =>
- val code = """
- | function main(args) {
- | whisk.done({ "happy": "penguins" });
- | }
- """.stripMargin
-
- c.init(initPayload(code))._1 should be(200)
-
- val (runCode, runRes) = c.run(runPayload(JsObject()))
- runCode should be(200)
- runRes should be(Some(JsObject("happy" -> JsString("penguins"))))
- }
-
- checkStreams(out, err, {
- case (o, e) =>
- o shouldBe empty
- if (!hasDeprecationWarnings) e shouldBe empty
- })
- }
-
- it should "not warn when returning whisk.done" in {
- val (out, err) = withNodeJsContainer { c =>
- val code = """
- | function main(args) {
- | whisk.done({ "happy": "penguins" });
- | }
- """.stripMargin
-
- c.init(initPayload(code))._1 should be(200)
-
- val (runCode, runRes) = c.run(runPayload(JsObject()))
- runCode should be(200)
- runRes should be(Some(JsObject("happy" -> JsString("penguins"))))
- }
-
- checkStreams(out, err, {
- case (o, e) =>
- o shouldBe empty
- if (!hasDeprecationWarnings) e shouldBe empty
- })
- }
-
- it should "warn when using deprecated whisk object methods" in {
- val (out, err) = withNodeJsContainer { c =>
- val code = """
- | function main(args) {
- | whisk.getAuthKey(whisk.setAuthKey('xxx'));
- | try { whisk.invoke(); } catch (e) {}
- | try { whisk.trigger(); } catch (e) {}
- | setTimeout(function () { whisk.done(); }, 1000);
- | return whisk.async();
- | }
- """.stripMargin
-
- c.init(initPayload(code))._1 should be(200)
-
- val (runCode, runRes) = c.run(runPayload(JsObject()))
- runCode should be(200)
- }
-
- checkStreams(out, err, {
- case (o, e) =>
- o shouldBe empty
- e should not be empty
- val lines = e.split("\n")
- lines.filter { l => l.startsWith("[WARN] \"whisk.") && l.contains("deprecated") }.length shouldBe 8
- })
- }
-
- it should "warn when using deprecated whisk.error" in {
- val (out, err) = withNodeJsContainer { c =>
- val code = """
- | function main(args) {
- | whisk.error("{warnme: true}");
- | }
- """.stripMargin
-
- c.init(initPayload(code))._1 should be(200)
-
- val (runCode, runRes) = c.run(runPayload(JsObject()))
- runCode should be(200)
- }
-
- checkStreams(out, err, {
- case (o, e) =>
- o shouldBe empty
- e should not be empty
- val lines = e.split("\n")
- lines.length shouldBe 1
- lines.forall { l => l.startsWith("[WARN] \"whisk.") && l.contains("deprecated") }
- })
- }
-
- it should "warn when using whisk.done twice" in {
- val (out, err) = withNodeJsContainer { c =>
- val code = """
- | function main(args) {
- | setTimeout(function () { whisk.done(); }, 100);
- | setTimeout(function () { whisk.done(); }, 101);
- | return whisk.async();
- | }
- """.stripMargin
-
- c.init(initPayload(code))._1 should be(200)
-
- val (runCode, runRes) = c.run(runPayload(JsObject()))
-
- runCode should be(200) // debatable, although it seems most logical
- runRes should be(Some(JsObject()))
- }
-
- checkStreams(out, err, {
- case (o, e) =>
- o should include("more than once")
- if (!hasDeprecationWarnings) e shouldBe empty
- })
- }
-
it should "support the documentation examples (1)" in {
val (out, err) = withNodeJsContainer { c =>
val code = """
@@ -285,9 +163,9 @@
| if (params.payload == 0) {
| return;
| } else if (params.payload == 1) {
- | return whisk.done(); // indicates normal completion
+ | return {payload: 'Hello, World!'} // indicates normal completion
| } else if (params.payload == 2) {
- | return whisk.error(); // indicates abnormal completion
+ | return {error: 'payload must be 0 or 1'} // indicates abnormal completion
| }
| }
""".stripMargin
@@ -302,55 +180,34 @@
r1 should be(Some(JsObject()))
c2 should be(200)
- r2 should be(Some(JsObject()))
+ r2 should be(Some(JsObject("payload" -> JsString("Hello, World!"))))
c3 should be(200) // application error, not container or system
- r3.get.fields.get("error") shouldBe defined
+ r3.get.fields.get("error") shouldBe Some(JsString("payload must be 0 or 1"))
}
checkStreams(out, err, {
case (o, e) =>
o shouldBe empty
- if (!hasDeprecationWarnings) e shouldBe empty
+ e shouldBe empty
}, 3)
+
}
it should "support the documentation examples (2)" in {
val (out, err) = withNodeJsContainer { c =>
val code = """
- | function main() {
- | setTimeout(function() {
- | return whisk.done({ done: true });
- | }, 100);
- | return whisk.async();
- | }
- """.stripMargin
-
- c.init(initPayload(code))._1 should be(200)
-
- val (runCode, runRes) = c.run(runPayload(JsObject()))
- runCode should be(200)
- runRes should be(Some(JsObject("done" -> JsBoolean(true))))
- }
-
- checkStreams(out, err, {
- case (o, e) =>
- o shouldBe empty
- if (!hasDeprecationWarnings) e shouldBe empty
- })
- }
-
- it should "support the documentation examples (3)" in {
- val (out, err) = withNodeJsContainer { c =>
- val code = """
| function main(params) {
| if (params.payload) {
- | setTimeout(function() {
- | return whisk.done({done: true});
- | }, 100);
- | return whisk.async(); // asynchronous activation
+ | // asynchronous activation
+ | return new Promise(function(resolve, reject) {
+ | setTimeout(function() {
+ | resolve({ done: true });
+ | }, 100);
+ | })
| } else {
- | return whisk.done(); // synchronous activation
+ | // synchronous activation
+ | return {done: true};
| }
| }
""".stripMargin
@@ -361,7 +218,7 @@
val (c2, r2) = c.run(runPayload(JsObject("payload" -> JsBoolean(true))))
c1 should be(200)
- r1 should be(Some(JsObject()))
+ r1 should be(Some(JsObject("done" -> JsBoolean(true))))
c2 should be(200)
r2 should be(Some(JsObject("done" -> JsBoolean(true))))
@@ -370,7 +227,7 @@
checkStreams(out, err, {
case (o, e) =>
o shouldBe empty
- if (!hasDeprecationWarnings) e shouldBe empty
+ e shouldBe empty
}, 2)
}
diff --git a/tests/src/system/basic/WskActionTests.scala b/tests/src/system/basic/WskActionTests.scala
index deac9f7..dcb6dcd 100644
--- a/tests/src/system/basic/WskActionTests.scala
+++ b/tests/src/system/basic/WskActionTests.scala
@@ -248,38 +248,6 @@
}
}
- it should "return the value of the first synchronous whisk.done()" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val name = "helloSyncDoneTwice"
- assetHelper.withCleaner(wsk.action, name) {
- (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("helloSyncDoneTwice.js")))
- }
-
- val run = wsk.action.invoke(name, Map("payload" -> testString.toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.status shouldBe "success"
- activation.response.result shouldBe Some(testResult)
- activation.logs.get.mkString(" ") should include(testString)
- }
- }
-
- it should "return the value of the first asynchronous whisk.done()" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- val name = "helloSyncDoneTwice"
- assetHelper.withCleaner(wsk.action, name) {
- (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("helloAsyncDoneTwice.js")))
- }
-
- val run = wsk.action.invoke(name, Map("payload" -> testString.toJson))
- withActivation(wsk.activation, run) {
- activation =>
- activation.response.status shouldBe "success"
- activation.response.result shouldBe Some(testResult)
- activation.logs.get.mkString(" ") should include(testString)
- }
- }
-
it should "reject an invoke with the wrong parameters set" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val fullQualifiedName = s"/$guestNamespace/samples/helloWorld"
diff --git a/tests/src/system/basic/WskBasicNodeTests.scala b/tests/src/system/basic/WskBasicNodeTests.scala
index 9225584..a9a91f0 100644
--- a/tests/src/system/basic/WskBasicNodeTests.scala
+++ b/tests/src/system/basic/WskBasicNodeTests.scala
@@ -16,8 +16,6 @@
package system.basic
-import scala.concurrent.duration.DurationInt
-
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@@ -147,181 +145,6 @@
}
}
- // TODO: remove this tests and its assets when "whisk.js" is removed entirely as it is no longer necessary
- it should "Ensure that whisk.invoke() returns a promise" in withAssetCleaner(wskprops) {
- val expectedDuration = 3.seconds
-
- (wp, assetHelper) =>
- val asyncName = "ThreeSecondRule"
- val asyncAction = Some(TestUtils.getTestActionFilename("threeSecondRule.js"))
-
- assetHelper.withCleaner(wsk.action, asyncName) {
- (action, _) =>
- action.create(asyncName, asyncAction)
- }
-
- // this action does not supply a 'next' callback to whisk.invoke()
- // and utilizes the returned promise
- val invokeActionName = "invokeAction"
- val invokeAction = Some(TestUtils.getTestActionFilename("invokePromise.js"))
-
- assetHelper.withCleaner(wsk.action, invokeActionName) {
- (action, _) =>
- action.create(invokeActionName, invokeAction)
- }
-
- var start = System.currentTimeMillis()
- val runResolve = wsk.action.invoke(invokeActionName, Map("resolveOrReject" -> "resolve".toJson))
- withActivation(wsk.activation, runResolve) {
- activation =>
- val result = activation.response.result.get
- result.fields.get("activationId") shouldBe defined
- result.fields.get("error") should not be defined
- result.getFieldPath("result", "message") should be(Some {
- "Three second rule!".toJson
- })
-
- val duration = System.currentTimeMillis() - start
- duration should be >= expectedDuration.toMillis
- }
-
- start = System.currentTimeMillis()
- val runReject = wsk.action.invoke(invokeActionName, Map("resolveOrReject" -> "reject".toJson))
- withActivation(wsk.activation, runReject) {
- activation =>
- val result = activation.response.result.get
- result.fields.get("activationId") should not be defined
- result.getFieldPath("error", "message") should be(Some {
- "Three second rule!".toJson
- })
-
- val duration = System.currentTimeMillis() - start
- duration should be >= expectedDuration.toMillis
- }
- }
-
- // TODO: remove this tests and its assets when "whisk.js" is removed entirely as it is no longer necessary
- it should "Ensure that whisk.invoke() still uses a callback when provided one" in withAssetCleaner(wskprops) {
- val expectedDuration = 3.seconds
-
- (wp, assetHelper) =>
- val asyncName = "ThreeSecondRule"
- val asyncAction = Some(TestUtils.getTestActionFilename("threeSecondRule.js"))
-
- assetHelper.withCleaner(wsk.action, asyncName) {
- (action, _) =>
- action.create(asyncName, asyncAction)
- }
-
- // this action supplies a 'next' callback to whisk.invoke()
- val invokeActionName = "invokeAction"
- val invokeAction = Some(TestUtils.getTestActionFilename("invokeCallback.js"))
-
- assetHelper.withCleaner(wsk.action, invokeActionName) {
- (action, _) =>
- action.create(invokeActionName, invokeAction)
- }
-
- var start = System.currentTimeMillis()
- val runResolve = wsk.action.invoke(invokeActionName, Map("resolveOrReject" -> "resolve".toJson))
- withActivation(wsk.activation, runResolve) {
- activation =>
- val result = activation.response.result.get
- result.fields.get("activationId") shouldBe defined
- result.fields.get("error") should not be defined
- result.getFieldPath("result", "message") should be(Some {
- "Three second rule!".toJson
- })
-
- val duration = System.currentTimeMillis() - start
- duration should be >= expectedDuration.toMillis
- }
-
- start = System.currentTimeMillis()
- val runReject = wsk.action.invoke(invokeActionName, Map("resolveOrReject" -> "reject".toJson))
- withActivation(wsk.activation, runReject) {
- activation =>
- val result = activation.response.result.get
- result.fields.get("activationId") should not be defined
- result.getFieldPath("error", "message") should be(Some {
- "Three second rule!".toJson
- })
-
- val duration = System.currentTimeMillis() - start
- duration should be >= expectedDuration.toMillis
- }
- }
-
- // TODO: remove this tests and its assets when "whisk.js" is removed entirely as it is no longer necessary
- it should "Ensure that whisk.trigger() still uses a callback when provided one" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- // this action supplies a 'next' callback to whisk.trigger()
- val nameOfActionThatTriggers = "triggerAction"
- val actionThatTriggers = Some(TestUtils.getTestActionFilename("triggerCallback.js"))
- val triggerName = "UnitTestTrigger-" + System.currentTimeMillis()
-
- assetHelper.withCleaner(wsk.action, nameOfActionThatTriggers) {
- (action, _) =>
- action.create(nameOfActionThatTriggers, actionThatTriggers)
- }
-
- // this is expected to fail this time because we have not yet created the trigger
- val runReject = wsk.action.invoke(nameOfActionThatTriggers, Map("triggerName" -> triggerName.toJson))
- withActivation(wsk.activation, runReject) {
- activation =>
- activation.response.success shouldBe false
- activation.response.result.get.fields.get("error") shouldBe defined
- }
-
- assetHelper.withCleaner(wsk.trigger, triggerName) {
- (trigger, _) =>
- trigger.create(triggerName)
- }
-
- // now that we've created the trigger, running the action should succeed
- val runResolve = wsk.action.invoke(nameOfActionThatTriggers, Map("triggerName" -> triggerName.toJson))
- withActivation(wsk.activation, runResolve) {
- activation =>
- activation.response.success shouldBe true
- activation.response.result.get.fields.get("activationId") shouldBe defined
- }
- }
-
- // TODO: remove this tests and its assets when "whisk.js" is removed entirely as it is no longer necessary
- it should "Ensure that whisk.trigger() returns a promise" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- // this action supplies a 'next' callback to whisk.trigger()
- val nameOfActionThatTriggers = "triggerAction"
- val actionThatTriggers = Some(TestUtils.getTestActionFilename("triggerPromise.js"))
- val triggerName = "UnitTestTrigger-" + System.currentTimeMillis()
-
- assetHelper.withCleaner(wsk.action, nameOfActionThatTriggers) {
- (action, _) =>
- action.create(nameOfActionThatTriggers, actionThatTriggers)
- }
-
- // this is expected to fail this time because we have not yet created the trigger
- val runReject = wsk.action.invoke(nameOfActionThatTriggers, Map("triggerName" -> triggerName.toJson))
- withActivation(wsk.activation, runReject) {
- activation =>
- activation.response.success shouldBe false
- activation.response.result.get.fields.get("error") shouldBe defined
- }
-
- assetHelper.withCleaner(wsk.trigger, triggerName) {
- (trigger, _) =>
- trigger.create(triggerName)
- }
-
- // now that we've created the trigger, running the action should succeed
- val runResolve = wsk.action.invoke(nameOfActionThatTriggers, Map("triggerName" -> triggerName.toJson))
- withActivation(wsk.activation, runResolve) {
- activation =>
- activation.response.success shouldBe true
- activation.response.result.get.fields.get("activationId") shouldBe defined
- }
- }
-
def convertRunResultToJsObject(result: RunResult): JsObject = {
val stdout = result.stdout
val firstNewline = stdout.indexOf("\n")
diff --git a/tests/src/system/basic/WskBasicTests.scala b/tests/src/system/basic/WskBasicTests.scala
index e0ab89e..e090019 100644
--- a/tests/src/system/basic/WskBasicTests.scala
+++ b/tests/src/system/basic/WskBasicTests.scala
@@ -339,33 +339,15 @@
}
}
- /**
- * Tests creating an nodejs action that throws a whisk.error() response. The error message thrown by the
- * whisk.error() should be returned.
- */
- it should "create and invoke a blocking action resulting in a whisk.error response" in withAssetCleaner(wskprops) {
- (wp, assetHelper) =>
- // one returns whisk.error the other just calls whisk.error
- val names = Seq("applicationError1", "applicationError2")
- names foreach { name =>
- assetHelper.withCleaner(wsk.action, name) {
- (action, _) => action.create(name, Some(TestUtils.getTestActionFilename(s"$name.js")))
- }
-
- wsk.action.invoke(name, blocking = true, expectedExitCode = 246)
- .stderr should include regex (""""error": "This error thrown on purpose by the action."""")
- }
- }
-
it should "create and invoke a blocking action resulting in an application error response" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
- val name = "applicationError3"
+ val name = "applicationError"
assetHelper.withCleaner(wsk.action, name) {
- (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("applicationError3.js")))
+ (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("applicationError.js")))
}
- wsk.action.invoke(name, blocking = true, result = true, expectedExitCode = 246)
- .stderr.parseJson.asJsObject shouldBe JsObject("error" -> JsBoolean(true))
+ wsk.action.invoke(name, blocking = true, expectedExitCode = 246)
+ .stderr should include regex (""""error": "This error thrown on purpose by the action."""")
}
it should "create and invoke a blocking action resulting in an failed promise" in withAssetCleaner(wskprops) {
diff --git a/tests/src/system/basic/WskSequenceTests.scala b/tests/src/system/basic/WskSequenceTests.scala
index ea65f77..dd41108 100644
--- a/tests/src/system/basic/WskSequenceTests.scala
+++ b/tests/src/system/basic/WskSequenceTests.scala
@@ -305,7 +305,7 @@
it should "stop execution of a sequence (with no payload) on error" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val sName = "sSequence"
- val apperror = "applicationError2"
+ val apperror = "applicationError"
val echo = "echo"
// create actions
diff --git a/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala b/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala
index cba3040..8e39aae 100644
--- a/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala
+++ b/tests/src/whisk/core/cli/test/SequenceMigrationTests.scala
@@ -82,11 +82,6 @@
}
}
- it should "invoke an old-style sequence (original pipe.js) and get the result" in {
- val seqName = "seq_echo_word_count"
- testOldStyleSequence(seqName, s"$seqName.json")
- }
-
it should "invoke an old-style (kind sequence) sequence and get the result" in {
val seqName = "seq_type_2"
testOldStyleSequence(seqName, s"$seqName.json")