You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by lz...@apache.org on 2017/09/25 01:30:14 UTC

[incubator-openwhisk-wskdeploy] branch master updated: Cloudant updates (#546)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new fa1ba2d  Cloudant updates (#546)
fa1ba2d is described below

commit fa1ba2d9eebb182cffd5b34fde9a806d04a12c84
Author: Priti Desai <pd...@us.ibm.com>
AuthorDate: Sun Sep 24 18:30:12 2017 -0700

    Cloudant updates (#546)
    
    * wip: updating dependency documentation
    
    * updating cloudant use case
    
    adapt the same style as Belinda's BP
    adding README
    
    * adding list of env variables
    
    * undo editing dependency readme
    
    * adding new line
---
 tests/src/integration/cloudant/README.md        | 81 +++++++++++++++++++++++++
 tests/src/integration/cloudant/cloudant_test.go |  1 +
 tests/src/integration/cloudant/manifest.yaml    | 11 +++-
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/tests/src/integration/cloudant/README.md b/tests/src/integration/cloudant/README.md
new file mode 100644
index 0000000..59c9205
--- /dev/null
+++ b/tests/src/integration/cloudant/README.md
@@ -0,0 +1,81 @@
+# Using Cloudant Package with `wskdeploy`
+
+The [Cloudant usecase](https://github.com/apache/incubator-openwhisk-wskdeploy/tree/master/tests/src/integration/cloudant) demonstrates how to build an OpenWhisk app to retrieve document updates from cloudant using `wskdeploy`.
+
+OpenWhisk supports [Cloudant package](https://github.com/apache/incubator-openwhisk-package-cloudant) which can be used to integrate with Cloudant APIs. For our simple app to display document IDs,  we need:
+ 
+- [manifest.yaml](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/tests/usecases/cloudant/manifest.yaml)
+- [Action File](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/tests/usecases/cloudant/src/process-change.js)
+
+All you have to do is export following environment variables:
+
+- CLOUDANT_USERNAME
+- CLOUDANT_PASSWORD
+- CLOUDANT_DATABASE (make sure that this databas exists in your cloudant instance)
+
+These env. variables are used in manifest file for:
+
+```yaml
+        dependencies:
+            # binding cloudant package named openwhisk-cloudant
+            openwhisk-cloudant:
+                location: /whisk.system/cloudant
+                inputs:
+                    username: $CLOUDANT_USERNAME
+                    password: $CLOUDANT_PASSWORD
+                    host: ${CLOUDANT_USERNAME}.cloudant.com
+        triggers:
+            # Trigger named "data-inserted-trigger"
+            # Creating trigger to fire events when data is inserted into database
+            data-inserted-trigger:
+                source: openwhisk-cloudant/changes
+                inputs:
+                    dbname: $CLOUDANT_DATABASE
+```
+
+### Step 1: Deploy
+
+Deploy it using `wskdeploy`:
+
+```
+wskdeploy -m tests/usecases/cloudant/manifest.yaml 
+```
+
+### Step 2: Verify
+
+```
+$ wsk package get cloudant-sample
+$ wsk package get openwhisk-cloudant
+$ wsk trigger get data-inserted-trigger 
+$ wsk rule get log-change-rule 
+```
+### Step 3: Run
+
+Create a new document in your cloudant instance which invokes trigger `data-inserted-trigger`
+which in turn invokes `openwhisk-cloudant/changes` trigger followed by `process-change` action:
+
+```
+Activation: process-change (cadfc8008e68416b9af6c6d94ec81dd1)
+[
+    "2017-09-22T21:43:33.498579123Z stdout: The changed document ID is:e97e6e30fe198c25d3a38f50c5e2a9a7"
+]
+
+Activation: read (2033d2f25ed34295a36e63a5f1012452)
+[
+    "2017-09-22T21:43:33.475515191Z stdout: success { _id: 'e97e6e30fe198c25d3a38f50c5e2a9a7',",
+    "2017-09-22T21:43:33.475558073Z stdout: _rev: '1-3f58ef522e6ba68731509a5c1b14fedf',",
+    "2017-09-22T21:43:33.475564787Z stdout: data: 'creating one more document' }"
+]
+
+Activation: process-change-cloudant-sequence (8798e2e739c948e08a76cb920b3a8d65)
+[
+    "2033d2f25ed34295a36e63a5f1012452",
+    "cadfc8008e68416b9af6c6d94ec81dd1"
+]
+
+Activation: log-change-rule (5662cb7250364730aceb7a8534ffb91d)
+[]
+
+Activation: data-inserted-trigger (adc3ea6b02f64a86a283a836364d46ea)
+[]
+```
diff --git a/tests/src/integration/cloudant/cloudant_test.go b/tests/src/integration/cloudant/cloudant_test.go
index 85824e0..c915add 100644
--- a/tests/src/integration/cloudant/cloudant_test.go
+++ b/tests/src/integration/cloudant/cloudant_test.go
@@ -28,6 +28,7 @@ import (
 )
 
 func TestCloudant(t *testing.T) {
+	os.Setenv("CLOUDANT_DATABASE", "testdb")
 	wskprops := common.GetWskpropsFromEnvVars(common.BLUEMIX_APIHOST, common.BLUEMIX_NAMESPACE, common.BLUEMIX_AUTH)
 	err := common.ValidateWskprops(wskprops)
 	if err != nil {
diff --git a/tests/src/integration/cloudant/manifest.yaml b/tests/src/integration/cloudant/manifest.yaml
index a31fe80..72b4a6d 100644
--- a/tests/src/integration/cloudant/manifest.yaml
+++ b/tests/src/integration/cloudant/manifest.yaml
@@ -1,6 +1,15 @@
+# Deployment using this manifest file creates following OpenWhisk components:
+#   Package:    cloudant-sample
+#   Package:    openwhisk-cloudant
+#   Action:     cloudant-sample/process-change
+#   Sequence:   cloudant-sample/process-change-cloudant-sequence
+#   Trigger:    data-inserted-trigger
+#   Rule:       log-change-rule
+
 # This manifest file reads following env. variables:
 #   CLOUDANT_USERNAME
 #   CLOUDANT_PASSWORD
+#   CLOUDANT_DATABASE
 
 packages:
     cloudant-sample:
@@ -18,7 +27,7 @@ packages:
             data-inserted-trigger:
                 source: openwhisk-cloudant/changes
                 inputs:
-                    dbname: testdb
+                    dbname: $CLOUDANT_DATABASE
         actions:
             # Action named "process-change"
             # Creating action that is printing data which is written to the database

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