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-package-cloudant.git


The following commit(s) were added to refs/heads/master by this push:
     new 933cb95  add trigger rules to existing tests (#157)
933cb95 is described below

commit 933cb95c57262f548de57936ec3a631dae612802
Author: Jason Peterson <jason...@us.ibm.com>
AuthorDate: Fri Feb 9 16:57:35 2018 -0500

    add trigger rules to existing tests (#157)
---
 actions/changesWebAction.js                        |  6 +-
 installCatalog.sh                                  | 56 ++++++++---------
 .../system/health/CloudantHealthFeedTests.scala    | 72 +++++++++-------------
 .../scala/system/packages/CloudantFeedTests.scala  | 45 ++++++++++++--
 .../redundancy/CloudantRedundancyTests.scala       | 33 ++++++++--
 5 files changed, 126 insertions(+), 86 deletions(-)

diff --git a/actions/changesWebAction.js b/actions/changesWebAction.js
index 7078b73..3f02994 100644
--- a/actions/changesWebAction.js
+++ b/actions/changesWebAction.js
@@ -145,7 +145,7 @@ function main(params) {
                 return getTrigger(db, triggerID);
             })
             .then(trigger => {
-                if (!trigger.status.active) {
+                if (trigger.status && trigger.status.active === false) {
                     reject(sendError(400, `${params.triggerName} cannot be 
updated because it is disabled`));
                 }
                 if (params.filter || params.query_params) {
@@ -380,9 +380,7 @@ function updateTrigger(triggerDB, triggerID, existing, 
params) {
     })
     .then(trigger => {
         for (var key in params) {
-            if (params[key]) {
-                trigger[key] = params[key];
-            }
+            trigger[key] = params[key];
         }
         var status = {
             'active': true,
diff --git a/installCatalog.sh b/installCatalog.sh
index 0aef5a6..cfa5521 100755
--- a/installCatalog.sh
+++ b/installCatalog.sh
@@ -74,7 +74,7 @@ fi
 
 # Cloudant feed action
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/changes "$PACKAGE_HOME/actions/changes.js" \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/changes "$PACKAGE_HOME/actions/changes.js" \
     -t 90000 \
     -a feed true \
     -a description 'Database change feed' \
@@ -83,102 +83,102 @@ $WSK_CLI -i --apihost "$EDGEHOST" action update --auth 
"$AUTH" cloudant/changes
 
 # Cloudant web feed action
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudantWeb/changesWebAction "$PACKAGE_HOME/actions/changesWebAction.js" \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudantWeb/changesWebAction "$PACKAGE_HOME/actions/changesWebAction.js" \
     -a description 'Create/Delete a trigger in cloudant provider Database' \
     --web true
 
 # Cloudant account actions
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/create-database \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/create-database \
     "$PACKAGE_HOME/actions/account-actions/create-database.js" \
     -a description 'Create Cloudant database' \
     -a parameters '[ {"name":"dbname", "required":true} ]'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/read-database \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/read-database \
     "$PACKAGE_HOME/actions/account-actions/read-database.js" \
     -a description 'Read Cloudant database' \
     -a parameters '[ {"name":"dbname", "required":true} ]'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/delete-database \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/delete-database \
     "$PACKAGE_HOME/actions/account-actions/delete-database.js" \
     -a description 'Delete Cloudant database' \
     -a parameters '[ {"name":"dbname", "required":true} ]'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/list-all-databases \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/list-all-databases \
     "$PACKAGE_HOME/actions/account-actions/list-all-databases.js" \
     -a description 'List all Cloudant databases'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/read-updates-feed \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/read-updates-feed \
     "$PACKAGE_HOME/actions/account-actions/read-updates-feed.js" \
     -a description 'Read updates feed from Cloudant account (non-continuous)' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"params", 
"required":false} ]'
 
 # Cloudant database actions
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/create-document \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/create-document \
     "$PACKAGE_HOME/actions/database-actions/create-document.js" \
     -a description 'Create document in database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"doc", 
"required":true, "description": "The JSON document to insert"}, 
{"name":"params", "required":false} ]' \
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" cloudant/read \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/read \
     "$PACKAGE_HOME/actions/database-actions/read-document.js" \
     -a description 'Read document from database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"id", 
"required":true, "description": "The Cloudant document id to fetch"}, 
{"name":"params", "required":false}]' \
     -p id ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/read-document \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/read-document \
     "$PACKAGE_HOME/actions/database-actions/read-document.js" \
     -a description 'Read document from database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true, "description": "The Cloudant document id to fetch"}, 
{"name":"params", "required":false}]' \
     -p docid ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" cloudant/write \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/write \
     "$PACKAGE_HOME/actions/database-actions/write-document.js" \
     -a description 'Write document in database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"doc", 
"required":true} ]' \
     -p doc '{}'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/update-document \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/update-document \
     "$PACKAGE_HOME/actions/database-actions/update-document.js" \
     -a description 'Update document in database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"doc", 
"required":true}, {"name":"params", "required":false} ]' \
     -p doc '{}'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/delete-document \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/delete-document \
     "$PACKAGE_HOME/actions/database-actions/delete-document.js" \
     -a description 'Delete document from database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true, "description": "The Cloudant document id to delete"},  
{"name":"docrev", "required":true, "description": "The document revision 
number"} ]' \
     -p docid '' \
     -p docrev ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/list-documents \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/list-documents \
     "$PACKAGE_HOME/actions/database-actions/list-documents.js" \
     -a description 'List all docs from database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"params", 
"required":false} ]'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/list-design-documents \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/list-design-documents \
     "$PACKAGE_HOME/actions/database-actions/list-design-documents.js" \
     -a description 'List design documents from database' \
     -a parameters '[ {"name":"dbname", "required":true}, 
{"name":"includedocs", "required":false} ]' \
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/create-query-index \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/create-query-index \
     "$PACKAGE_HOME/actions/database-actions/create-query-index.js" \
     -a description 'Create a Cloudant Query index into database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"index", 
"required":true} ]' \
     -p index ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/list-query-indexes \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/list-query-indexes \
     "$PACKAGE_HOME/actions/database-actions/list-query-indexes.js" \
     -a description 'List Cloudant Query indexes from database' \
     -a parameters '[ {"name":"dbname", "required":true} ]' \
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/exec-query-find \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/exec-query-find \
     "$PACKAGE_HOME/actions/database-actions/exec-query-find.js" \
     -a description 'Execute query against Cloudant Query index' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"query", 
"required":true} ]' \
     -p query ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/exec-query-search \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/exec-query-search \
     "$PACKAGE_HOME/actions/database-actions/exec-query-search.js" \
     -a description 'Execute query against Cloudant search' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"indexname", "required":true}, {"name":"search", 
"required":true} ]' \
@@ -186,39 +186,39 @@ $WSK_CLI -i --apihost "$EDGEHOST" action update --auth 
"$AUTH" cloudant/exec-que
     -p indexname '' \
     -p search ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/exec-query-view \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/exec-query-view \
     "$PACKAGE_HOME/actions/database-actions/exec-query-view.js" \
     -a description 'Call view in design document from database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"viewname", "required":true}, {"name":"params", 
"required":false} ]' \
     -p docid '' \
     -p viewname ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/manage-bulk-documents \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/manage-bulk-documents \
     "$PACKAGE_HOME/actions/database-actions/manage-bulk-documents.js" \
     -a description 'Create, Update, and Delete documents in bulk' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docs", 
"required":true}, {"name":"params", "required":false} ]' \
     -p docs '{}'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/delete-view \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/delete-view \
     "$PACKAGE_HOME/actions/database-actions/delete-view.js" \
     -a description 'Delete view from design document' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"viewname", "required":true}, {"name":"params", 
"required":false} ]' \
     -p docid '' \
     -p viewname ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/delete-query-index \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/delete-query-index \
     "$PACKAGE_HOME/actions/database-actions/delete-query-index.js" \
     -a description 'Delete index from design document' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"indexname", "required":true}, {"name":"params", 
"required":false} ]' \
     -p docid '' \
     -p indexname ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/read-changes-feed \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/read-changes-feed \
     "$PACKAGE_HOME/actions/database-actions/read-changes-feed.js" \
     -a description 'Read Cloudant database changes feed (non-continuous)' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"params", 
"required":false} ]'
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/create-attachment \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/create-attachment \
     "$PACKAGE_HOME/actions/database-actions/create-update-attachment.js" \
     -a description 'Create document attachment in database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"docrev", "required":true}, {"name":"attachment", 
"required":true}, {"name":"attachmentname", "required":true}, 
{"name":"contenttype", "required":true}, {"name":"params", "required":false} ]' 
\
@@ -228,14 +228,14 @@ $WSK_CLI -i --apihost "$EDGEHOST" action update --auth 
"$AUTH" cloudant/create-a
     -p attachmentname '' \
     -p contenttype ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/read-attachment \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/read-attachment \
     "$PACKAGE_HOME/actions/database-actions/read-attachment.js" \
     -a description 'Read document attachment from database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"attachmentname", "required":true}, {"name":"params", 
"required":false} ]' \
     -p docid '' \
     -p attachmentname ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/update-attachment \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/update-attachment \
     "$PACKAGE_HOME/actions/database-actions/create-update-attachment.js" \
     -a description 'Update document attachment in database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"docrev", "required":true}, {"name":"attachment", 
"required":true}, {"name":"attachmentname", "required":true}, 
{"name":"contenttype", "required":true}, {"name":"params", "required":false} ]' 
\
@@ -245,7 +245,7 @@ $WSK_CLI -i --apihost "$EDGEHOST" action update --auth 
"$AUTH" cloudant/update-a
     -p attachmentname '' \
     -p contenttype ''
 
-$WSK_CLI -i --apihost "$EDGEHOST" action update --auth "$AUTH" 
cloudant/delete-attachment \
+$WSK_CLI -i --apihost "$EDGEHOST" action update --kind nodejs:6 --auth "$AUTH" 
cloudant/delete-attachment \
     "$PACKAGE_HOME/actions/database-actions/delete-attachment.js" \
     -a description 'Delete document attachment from database' \
     -a parameters '[ {"name":"dbname", "required":true}, {"name":"docid", 
"required":true}, {"name":"docrev", "required":true}, {"name":"attachmentname", 
"required":true}, {"name":"params", "required":false} ]' \
diff --git a/tests/src/test/scala/system/health/CloudantHealthFeedTests.scala 
b/tests/src/test/scala/system/health/CloudantHealthFeedTests.scala
index c9e3d01..42e842c 100644
--- a/tests/src/test/scala/system/health/CloudantHealthFeedTests.scala
+++ b/tests/src/test/scala/system/health/CloudantHealthFeedTests.scala
@@ -21,11 +21,7 @@ import java.time.{Clock, Instant}
 import org.junit.runner.RunWith
 import org.scalatest.{BeforeAndAfterEach, FlatSpec, Inside}
 import org.scalatest.junit.JUnitRunner
-import common.TestHelpers
-import common.Wsk
-import common.WskActorSystem
-import common.WskProps
-import common.WskTestHelpers
+import common._
 import spray.json.DefaultJsonProtocol.IntJsonFormat
 import spray.json.DefaultJsonProtocol.StringJsonFormat
 import spray.json.DefaultJsonProtocol.BooleanJsonFormat
@@ -46,6 +42,7 @@ class CloudantHealthFeedTests
 
     val wskprops = WskProps()
     val wsk = new Wsk
+    val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
     val myCloudantCreds = 
CloudantUtil.Credential.makeFromVCAPFile("cloudantNoSQLDB", 
this.getClass.getSimpleName)
 
     behavior of "Cloudant Health trigger service"
@@ -66,6 +63,8 @@ class CloudantHealthFeedTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val actionName = s"dummyAlarmsAction-${System.currentTimeMillis}"
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
@@ -79,6 +78,11 @@ class CloudantHealthFeedTests
                 (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
             }
 
+            // create action
+            assetHelper.withCleaner(wsk.action, actionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+
             // create whisk stuff
             println(s"Creating trigger: $triggerName")
             val feedCreationResult = assetHelper.withCleaner(wsk.trigger, 
triggerName) {
@@ -89,7 +93,11 @@ class CloudantHealthFeedTests
                         "host" -> myCloudantCreds.host().toJson,
                         "dbname" -> myCloudantCreds.dbname.toJson))
             }
-            feedCreationResult.stdout should include("ok")
+
+            // create rule
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = actionName)
+            }
 
             val activationsBeforeChange = wsk.activation.pollFor(N = 1, 
Some(triggerName)).length
             activationsBeforeChange should be(0)
@@ -121,10 +129,12 @@ class CloudantHealthFeedTests
             activationsAfterDelete should be(1)
     }
 
-    it should "fire changes since sequence 0 of DB" in 
withAssetCleaner(wskprops) {
+    it should "fire changes when a document is deleted" in 
withAssetCleaner(wskprops) {
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val actionName = s"dummyAlarmsAction-${System.currentTimeMillis}"
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
@@ -137,37 +147,9 @@ class CloudantHealthFeedTests
                 (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
             }
 
-            println(s"Creating trigger: $triggerName")
-            val feedCreationResult = assetHelper.withCleaner(wsk.trigger, 
triggerName) {
-                (trigger, name) =>
-                    trigger.create(name, feed = Some(s"$packageName/$feed"), 
parameters = Map(
-                        "username" -> myCloudantCreds.user.toJson,
-                        "password" -> myCloudantCreds.password.toJson,
-                        "host" -> myCloudantCreds.host().toJson,
-                        "dbname" -> myCloudantCreds.dbname.toJson,
-                        "maxTriggers" -> 100000000.toJson,
-                        "since" -> "0".toJson))
-            }
-            feedCreationResult.stdout should include("ok")
-
-            val activations = wsk.activation.pollFor(N = 1, Some(triggerName), 
retries = 60).length
-            activations should be(1)
-    }
-
-    it should "fire changes when a document is deleted" in 
withAssetCleaner(wskprops) {
-        (wp, assetHelper) =>
-            implicit val wskprops = wp // shadow global props and make implicit
-            val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
-            val packageName = "dummyCloudantPackage"
-            val feed = "changes"
-
-            val packageGetResult = wsk.pkg.get("/whisk.system/cloudant")
-            println("Fetching cloudant package.")
-            packageGetResult.stdout should include("ok")
-
-            println("Creating cloudant package binding.")
-            assetHelper.withCleaner(wsk.pkg, packageName) {
-                (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
+            // create action
+            assetHelper.withCleaner(wsk.action, actionName) { (action, name) =>
+                action.create(name, defaultAction)
             }
 
             println(s"Creating trigger: $triggerName")
@@ -180,7 +162,11 @@ class CloudantHealthFeedTests
                         "dbname" -> myCloudantCreds.dbname.toJson,
                         "maxTriggers" -> (-1).toJson))
             }
-            feedCreationResult.stdout should include("ok")
+
+            // create rule
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = actionName)
+            }
 
             val activationsBeforeDelete = wsk.activation.pollFor(N = 1, 
Some(triggerName)).length
             activationsBeforeDelete should be(0)
@@ -200,7 +186,7 @@ class CloudantHealthFeedTests
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
-            // the package alarms should be there
+            // the package cloudant should be there
             val packageGetResult = wsk.pkg.get("/whisk.system/cloudant")
             println("fetched package cloudant")
             packageGetResult.stdout should include("ok")
@@ -225,7 +211,7 @@ class CloudantHealthFeedTests
             val filter = "test_filter/fruit"
             val queryParams = JsObject("type" -> JsString("tomato"))
 
-            // create whisk stuff
+            // create trigger feed
             val feedCreationResult = assetHelper.withCleaner(wsk.trigger, 
triggerName, confirmDelete = false) {
                 (trigger, name) =>
                     trigger.create(name, feed = Some(s"$packageName/$feed"), 
parameters = Map(
@@ -286,7 +272,7 @@ class CloudantHealthFeedTests
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
-            // the package alarms should be there
+            // the package cloudant should be there
             val packageGetResult = wsk.pkg.get("/whisk.system/cloudant")
             println("fetched package cloudant")
             packageGetResult.stdout should include("ok")
@@ -308,7 +294,7 @@ class CloudantHealthFeedTests
             val filter = "test_filter/fruit"
             val queryParams = JsObject("type" -> JsString("tomato"))
 
-            // create whisk stuff
+            // create trigger feed
             val feedCreationResult = assetHelper.withCleaner(wsk.trigger, 
triggerName, confirmDelete = false) {
                 (trigger, name) =>
                     trigger.create(name, feed = Some(s"$packageName/$feed"), 
parameters = Map(
diff --git a/tests/src/test/scala/system/packages/CloudantFeedTests.scala 
b/tests/src/test/scala/system/packages/CloudantFeedTests.scala
index f6f1c9e..e0be2db 100644
--- a/tests/src/test/scala/system/packages/CloudantFeedTests.scala
+++ b/tests/src/test/scala/system/packages/CloudantFeedTests.scala
@@ -39,6 +39,7 @@ class CloudantFeedTests
     val wskprops = WskProps()
     val wsk = new Wsk
     val myCloudantCreds = 
CloudantUtil.Credential.makeFromVCAPFile("cloudantNoSQLDB", 
this.getClass.getSimpleName)
+    val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
 
     behavior of "Cloudant trigger service"
 
@@ -203,6 +204,8 @@ class CloudantFeedTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val actionName = s"dummyAlarmsAction-${System.currentTimeMillis}"
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
@@ -218,6 +221,11 @@ class CloudantFeedTests
                     (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
                 }
 
+                // create action
+                assetHelper.withCleaner(wsk.action, actionName) { (action, 
name) =>
+                    action.create(name, defaultAction)
+                }
+
                 println("Creating cloudant trigger feed.")
                 val feedCreationResult = assetHelper.withCleaner(wsk.trigger, 
triggerName, confirmDelete = false) {
                     (trigger, name) =>
@@ -228,7 +236,11 @@ class CloudantFeedTests
                             "dbname" -> myCloudantCreds.dbname.toJson,
                             "maxTriggers" -> 1.toJson))
                 }
-                feedCreationResult.stdout should include("ok")
+
+                // create rule
+                assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                    rule.create(name, trigger = triggerName, action = 
actionName)
+                }
 
                 // Create test docs in cloudant and assert that document was 
inserted successfully
                 println("Creating a test doc-1 in the cloudant")
@@ -258,6 +270,8 @@ class CloudantFeedTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val actionName = s"dummyAlarmsAction-${System.currentTimeMillis}"
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
@@ -273,6 +287,11 @@ class CloudantFeedTests
                     (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
                 }
 
+                // create action
+                assetHelper.withCleaner(wsk.action, actionName) { (action, 
name) =>
+                    action.create(name, defaultAction)
+                }
+
                 //Create filter design doc
                 val filterDesignDoc = 
CloudantUtil.createDesignFromFile(CloudantUtil.FILTER_DDOC_PATH).toString
                 val getResponse = CloudantUtil.createDocument(myCloudantCreds, 
filterDesignDoc)
@@ -289,7 +308,11 @@ class CloudantFeedTests
                             "filter" -> "test_filter/fruit".toJson,
                             "query_params" -> JsObject("type" -> 
JsString("tomato"))))
                 }
-                feedCreationResult.stdout should include("ok")
+
+                // create rule
+                assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                    rule.create(name, trigger = triggerName, action = 
actionName)
+                }
 
                 // Create test docs in cloudant and assert that document was 
inserted successfully
                 println("Creating a test doc-1 in the cloudant")
@@ -513,9 +536,10 @@ class CloudantFeedTests
         (wp, assetHelper) =>
             implicit val wskProps = wp // shadow global props and make implicit
             val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val actionName = s"dummyAlarmsAction-${System.currentTimeMillis}"
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
-            val actionName = s"$packageName/$feed"
 
             try {
                 CloudantUtil.setUp(myCloudantCreds)
@@ -529,6 +553,11 @@ class CloudantFeedTests
                     (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
                 }
 
+                // create action
+                assetHelper.withCleaner(wsk.action, actionName) { (action, 
name) =>
+                    action.create(name, defaultAction)
+                }
+
                 //Create filter design doc
                 val filterDesignDoc = 
CloudantUtil.createDesignFromFile(CloudantUtil.FILTER_DDOC_PATH).toString
                 val getResponse = CloudantUtil.createDocument(myCloudantCreds, 
filterDesignDoc)
@@ -545,7 +574,11 @@ class CloudantFeedTests
                             "filter" -> "test_filter/fruit".toJson,
                             "query_params" -> JsObject("type" -> 
JsString("tomato"))))
                 }
-                feedCreationResult.stdout should include("ok")
+
+                // create rule
+                assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                    rule.create(name, trigger = triggerName, action = 
actionName)
+                }
 
                 // Create test docs in cloudant and assert that document was 
inserted successfully
                 println("Creating a test doc-1 in the cloudant")
@@ -567,7 +600,7 @@ class CloudantFeedTests
                 noNewActivations should be(1)
 
                 println("Updating trigger query_params.")
-                val feedUpdateResult = wsk.action.invoke(actionName, 
parameters = Map(
+                val feedUpdateResult = 
wsk.action.invoke(s"$packageName/$feed", parameters = Map(
                     "triggerName" -> triggerName.toJson,
                     "lifecycleEvent" -> "UPDATE".toJson,
                     "authKey" -> wskProps.authKey.toJson,
@@ -582,7 +615,7 @@ class CloudantFeedTests
                 println("Giving the trigger service a moment to process the 
update")
                 Thread.sleep(10000)
 
-                val runResult = wsk.action.invoke(actionName, parameters = Map(
+                val runResult = wsk.action.invoke(s"$packageName/$feed", 
parameters = Map(
                     "triggerName" -> triggerName.toJson,
                     "lifecycleEvent" -> "READ".toJson,
                     "authKey" -> wskProps.authKey.toJson
diff --git 
a/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala 
b/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala
index c029aee..e78cc24 100644
--- a/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala
+++ b/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala
@@ -18,7 +18,7 @@ package system.redundancy
 
 import com.jayway.restassured.RestAssured
 import com.jayway.restassured.config.SSLConfig
-import common.{WhiskProperties, Wsk, WskProps, WskTestHelpers}
+import common._
 import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers}
@@ -47,12 +47,13 @@ class CloudantRedundancyTests
     val wskprops = WskProps()
     val wsk = new Wsk
     val myCloudantCreds = 
CloudantUtil.Credential.makeFromVCAPFile("cloudantNoSQLDB", 
this.getClass.getSimpleName)
-    var edgeHost = WhiskProperties.getEdgeHost
+    val edgeHost = WhiskProperties.getEdgeHost
     val auth = WhiskProperties.getBasicAuth
     val user = auth.fst
     val password = auth.snd
 
-    var endpointPrefix = 
s"https://$user:$password@$edgeHost/cloudanttrigger/worker0/";
+    val endpointPrefix = 
s"https://$user:$password@$edgeHost/cloudanttrigger/worker0/";
+    val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
 
     behavior of "Cloudant redundancy tests"
 
@@ -60,6 +61,8 @@ class CloudantRedundancyTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val actionName = s"dummyAlarmsAction-${System.currentTimeMillis}"
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
@@ -76,6 +79,11 @@ class CloudantRedundancyTests
                     (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
                 }
 
+                // create action
+                assetHelper.withCleaner(wsk.action, actionName) { (action, 
name) =>
+                    action.create(name, defaultAction)
+                }
+
                 // create whisk stuff
                 val feedCreationResult = assetHelper.withCleaner(wsk.trigger, 
triggerName, confirmDelete = false) {
                     (trigger, name) =>
@@ -85,7 +93,11 @@ class CloudantRedundancyTests
                             "host" -> myCloudantCreds.host().toJson,
                             "dbname" -> myCloudantCreds.dbname.toJson))
                 }
-                feedCreationResult.stdout should include("ok")
+
+                // create rule
+                assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                    rule.create(name, trigger = triggerName, action = 
actionName)
+                }
 
                 Thread.sleep(3000)
 
@@ -131,6 +143,8 @@ class CloudantRedundancyTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = 
s"dummyCloudantTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val actionName = s"dummyAlarmsAction-${System.currentTimeMillis}"
             val packageName = "dummyCloudantPackage"
             val feed = "changes"
 
@@ -147,6 +161,11 @@ class CloudantRedundancyTests
                     (pkg, name) => pkg.bind("/whisk.system/cloudant", name)
                 }
 
+                // create action
+                assetHelper.withCleaner(wsk.action, actionName) { (action, 
name) =>
+                    action.create(name, defaultAction)
+                }
+
                 // create whisk stuff
                 val feedCreationResult = assetHelper.withCleaner(wsk.trigger, 
triggerName, confirmDelete = false) {
                     (trigger, name) =>
@@ -156,7 +175,11 @@ class CloudantRedundancyTests
                             "host" -> myCloudantCreds.host().toJson,
                             "dbname" -> myCloudantCreds.dbname.toJson))
                 }
-                feedCreationResult.stdout should include("ok")
+
+                // create rule
+                assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                    rule.create(name, trigger = triggerName, action = 
actionName)
+                }
 
                 Thread.sleep(3000)
 

-- 
To stop receiving notification emails like this one, please contact
csantan...@apache.org.

Reply via email to