You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2017/09/29 02:13:16 UTC
[incubator-openwhisk-wskdeploy] branch master updated: Adding real
world live application (#562)
This is an automated email from the ASF dual-hosted git repository.
mrutkowski 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 2500186 Adding real world live application (#562)
2500186 is described below
commit 2500186de15ba1bc8320b3d41445c8b723a16af4
Author: Priti Desai <pd...@us.ibm.com>
AuthorDate: Thu Sep 28 19:13:13 2017 -0700
Adding real world live application (#562)
---
tests/README.md | 144 +++++++++++++++------
tests/apps/owbp-cloudant-trigger/README.md | 2 +
tests/apps/owbp-cloudant-trigger/manifest-bp.json | 17 +++
.../owbp-cloudant-trigger_test.go | 103 +++++++++++++++
.../runtimes/node/actions/process-change.js | 24 ++++
.../runtimes/node/manifest.yaml | 50 +++++++
.../runtimes/php/actions/process-change.php | 12 ++
.../runtimes/php/manifest.yaml | 50 +++++++
.../runtimes/python/actions/process-change.py | 8 ++
.../runtimes/python/manifest.yaml | 50 +++++++
.../runtimes/swift/actions/process-change.swift | 11 ++
.../runtimes/swift/manifest.yaml | 50 +++++++
12 files changed, 479 insertions(+), 42 deletions(-)
diff --git a/tests/README.md b/tests/README.md
index 79e20a0..2a95c2b 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,56 +1,42 @@
-# Test Cases for wskdeploy.
+# `wskdeploy` Test Cases and Real World Applications
+
+## Test Cases
There are two types of test cases supported (1) unit test and (2) integration test.
-You can identify them by the first line of each test file. Unit tests are tagged
-with `+build unit` and integration tests are tagged with `+build integration`.
-For example, the test file `deploymentreader_test.go` under `deployers/` contains
-unit test cases, so it is indicated with the unit tests tag on the top of the file:
+You can identify them by the first line of each test file `_test.go`.
-```
-// +build unit
+### Unit Tests
-package tests
-...
-```
+Unit tests are tagged with `+build unit` tag. For example, the test file
+[deploymentreader_test.go](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/deployers/deploymentreader_test.go)
+under `deployers/` contains unit test cases which is indicated with the unit tests
+tag on the top of the file:
-Integration tests are indicated with the integration tests tag on the top of the file:
```
-// +build integration
+// +build unit
package tests
...
```
-## How to run wskdeploy tests
-
-Before running unit or integration tests, you need to install the package
-[Testify](https://github.com/stretchr/testify/):
-
-```
-cd $GOPATH
-go get -u github.com/stretchr/testify
-
-```
-
-### Running Unit Tests
+#### How do I run unit tests?
+In order to run any unit tests, you need to install the package [Testify](https://github.com/stretchr/testify/).
After installing Testify, all the unit tests can be run from the main `incubator-openwhisk-wskdeploy`
repository folder using the following command:
+
```
+cd $GOPATH
+go get -u github.com/stretchr/testify
+cd incubator-openwhisk-wskdeploy/
$ go test -v ./... -tags unit
```
-### Running Integration Tests
-
-After installing Testify, all integration tests can be run rom the main `incubator-openwhisk-wskdeploy`
-repository folder using the following command:
-
-```
-$ go test -v ./... -tags integration
-```
+#### How do I run an individual test?
-### Run an Individual Test
+Above command will run all the unit tests from `incubator-openwhisk-wskdeploy`, in
+order to run a specific test, use:
```
go test -v <path-to-package-dir> -tags unit -run <test-name>
@@ -60,16 +46,13 @@ For example:
```
go test -v ./parsers/ -tags unit -run TestComposeActionsForWebActions
-go test -v ./tests/src/integration/zipaction/ -tags integration
```
-## How to Structure Unit Tests
-
-All integration test cases are put under the folder `tests/src/integration`.
+#### Where should I write unit tests?
Unit tests are co-located in the same directory as the package being tested (by Go convention).
The test files uses the same basename as the file that contains the package,
-but with the added '_test' postfix to the base file name.
+but with the added `_test` postfix to the base file name.
For example, the package `deployers`, which defines a `DeploymentReader` service,
is declared in the file `deploymentreader.go`; its corresponding unit test file
@@ -77,11 +60,58 @@ should be named `deploymentreader_test.go` under `deployers/`.
Also, the manifest and deployment YAML files used by unit tests should go under `tests/dat`.
-## How to Structure Integration Tests
-Every integration test has to have a test file
-Integration tests are created under `tests/src/integration`. The test file and
-manifest and deployment YAML files should go under the same directory.
+### Integration Tests
+
+Integration tests are tagged with `+build integration` tag. For example, the test
+file [zipaction_test.go](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/tests/src/integration/zipaction/zipaction_test.go)
+contains integration test which is indicated with the integration tests tag on
+the top of the file:
+
+```
+// +build integration
+
+package tests
+...
+```
+
+#### How do I run integration tests?
+
+In order to run any integration tests, you need to install the package [Testify](https://github.com/stretchr/testify/).
+After installing Testify, all the integration tests can be run from the main `incubator-openwhisk-wskdeploy`
+repository folder using the following command:
+
+
+```
+cd $GOPATH
+go get -u github.com/stretchr/testify
+cd incubator-openwhisk-wskdeploy/
+$ go test -v ./... -tags integration
+```
+
+`wskdeploy` tests are located under [tests/](https://github.com/apache/incubator-openwhisk-wskdeploy/tree/master/tests)
+folder.
+
+#### How do I run an individual test?
+
+Above command will run all the integration tests from `incubator-openwhisk-wskdeploy`, in
+order to run a specific test, use:
+
+```
+go test -v <path-to-package-dir> -tags integration -run <test-name>
+```
+
+For example:
+
+```
+go test -v ./tests/src/integration/zipaction/ -tags integration -run TestZipAction
+```
+
+#### Where should I write integration tests?
+
+All integration test cases are created under the folder `tests/src/integration`.
+Every integration test has to have a test file `_test.go` along with manifest and/or
+deployment YAML file under the same directory.
For example, `helloworld` integration test:
@@ -93,3 +123,33 @@ deployment.yaml
helloworld_test.go
manifest.yaml
```
+
+## Real World Applications
+
+[apps](https://github.com/apache/incubator-openwhisk-wskdeploy/tree/master/tests/apps)
+holds various real world applications which are being deployed using `wskdeploy`.
+This space gives an opportunity to `wskdeploy` consumers to integrate with `wskdeploy`
+and verify deployment/undeployment of their applications against a clean OpenWhisk
+instance. With this shared platform, application developer can work with `wskdeploy`
+developers to implement their requirements and usecases as they come in.
+
+As an application developer, you can follow [Contributing to Project](https://github.com/apache/incubator-openwhisk-wskdeploy#contributing-to-the-project)\
+guide to add your application under [apps](https://github.com/apache/incubator-openwhisk-wskdeploy/tree/master/tests/apps)
+or if you want to skip cloning the whole [incubator-openwhisk-wskdeploy](https://github.com/apache/incubator-openwhisk-wskdeploy)
+GitHub repo. There is a one time settings possible if you just want to
+clone your own application and submit pull requests:
+
+```
+# create a new directory where you want to clone your application
+$ mkdir <my-wskdeploy-application>
+$ cd <my-wskdeploy-application>
+# initialize empty local repo
+$ git init
+# add the remote named origin using your fork
+$ git remote add origin -f https://github.com/<application-developer>/incubator-openwhisk-wskdeploy.git
+# the following git command is very important where we tell git we are checking out specifics
+$ git config core.sparsecheckout true
+$ echo "apps/*" >> .git/info/sparse-checkout
+$ git pull origin master
+```
+
diff --git a/tests/apps/owbp-cloudant-trigger/README.md b/tests/apps/owbp-cloudant-trigger/README.md
new file mode 100644
index 0000000..277c005
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/README.md
@@ -0,0 +1,2 @@
+# owbp-cloudant-trigger
+code for openwhisk-cloudant-trigger
diff --git a/tests/apps/owbp-cloudant-trigger/manifest-bp.json b/tests/apps/owbp-cloudant-trigger/manifest-bp.json
new file mode 100644
index 0000000..2b79e10
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/manifest-bp.json
@@ -0,0 +1,17 @@
+{
+ "_id": "d8cf3281dabeab2946d55276beb13020",
+ "_rev": "7-6bd988c10a1ff8c04b5700b5d800c275",
+ "name": "New Cloudant Item",
+ "description": "When a cloudant DB has a data item edited or added, log the change in the console.",
+ "long_description": "This blueprint will create a sequence of actions, and a trigger that will kick off that sequence. The trigger is fired when there is a change in the connected Cloudant DB, which should be a database of cats, with a name and a color. The expected data item is a cat, with a name and a color defined. When a new cat is added to the database, or a current cat edited, the data will be logged to the console.",
+ "url": "https://github.com/apache/incubator-openwhisk-wskdeploy/tree/master/tests/apps/owbp-cloudant-trigger",
+ "runtime": {
+ "name": "Node.js 6",
+ "kind": "nodejs:6",
+ "type": "node"
+ },
+ "categories": [
+ "nodejs",
+ "cloudant"
+ ]
+}
diff --git a/tests/apps/owbp-cloudant-trigger/owbp-cloudant-trigger_test.go b/tests/apps/owbp-cloudant-trigger/owbp-cloudant-trigger_test.go
new file mode 100644
index 0000000..9703a07
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/owbp-cloudant-trigger_test.go
@@ -0,0 +1,103 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests
+
+import (
+ "testing"
+ "github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
+ "github.com/stretchr/testify/assert"
+ "os"
+ "fmt"
+)
+
+var projectPath = "/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/apps/owbp-cloudant-trigger/runtimes/"
+
+func TestCloudantTriggerNode(t *testing.T) {
+ manifestPath := os.Getenv("GOPATH") + projectPath + "node/manifest.yaml"
+ deploymentPath := ""
+ os.Setenv("CLOUDANT_DATABASE", "testdb")
+ wskprops := common.GetWskpropsFromEnvVars(common.BLUEMIX_APIHOST, common.BLUEMIX_NAMESPACE, common.BLUEMIX_AUTH)
+ err := common.ValidateWskprops(wskprops)
+ if err != nil {
+ fmt.Println(err.Error())
+ fmt.Println("Wsk properties are not properly configured, so tests are skipped.")
+ } else {
+ wskdeploy := common.NewWskdeploy()
+ _, err := wskdeploy.DeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to deploy the manifest file.")
+ _, err = wskdeploy.UndeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to undeploy the manifest file.")
+ }
+}
+
+func TestCloudantTriggerPhp(t *testing.T) {
+ manifestPath := os.Getenv("GOPATH") + projectPath + "php/manifest.yaml"
+ deploymentPath := ""
+ os.Setenv("CLOUDANT_DATABASE", "testdb")
+ wskprops := common.GetWskpropsFromEnvVars(common.BLUEMIX_APIHOST, common.BLUEMIX_NAMESPACE, common.BLUEMIX_AUTH)
+ err := common.ValidateWskprops(wskprops)
+ if err != nil {
+ fmt.Println(err.Error())
+ fmt.Println("Wsk properties are not properly configured, so tests are skipped.")
+ } else {
+ wskdeploy := common.NewWskdeploy()
+ _, err := wskdeploy.DeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to deploy the manifest file.")
+ _, err = wskdeploy.UndeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to undeploy the manifest file.")
+ }
+}
+
+func TestCloudantTriggerPython(t *testing.T) {
+ manifestPath := os.Getenv("GOPATH") + projectPath + "python/manifest.yaml"
+ deploymentPath := ""
+ os.Setenv("CLOUDANT_DATABASE", "testdb")
+ wskprops := common.GetWskpropsFromEnvVars(common.BLUEMIX_APIHOST, common.BLUEMIX_NAMESPACE, common.BLUEMIX_AUTH)
+ err := common.ValidateWskprops(wskprops)
+ if err != nil {
+ fmt.Println(err.Error())
+ fmt.Println("Wsk properties are not properly configured, so tests are skipped.")
+ } else {
+ wskdeploy := common.NewWskdeploy()
+ _, err := wskdeploy.DeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to deploy the manifest file.")
+ _, err = wskdeploy.UndeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to undeploy the manifest file.")
+ }
+}
+
+func TestCloudantTriggerSwift(t *testing.T) {
+ manifestPath := os.Getenv("GOPATH") + projectPath + "swift/manifest.yaml"
+ deploymentPath := ""
+ os.Setenv("CLOUDANT_DATABASE", "testdb")
+ wskprops := common.GetWskpropsFromEnvVars(common.BLUEMIX_APIHOST, common.BLUEMIX_NAMESPACE, common.BLUEMIX_AUTH)
+ err := common.ValidateWskprops(wskprops)
+ if err != nil {
+ fmt.Println(err.Error())
+ fmt.Println("Wsk properties are not properly configured, so tests are skipped.")
+ } else {
+ wskdeploy := common.NewWskdeploy()
+ _, err := wskdeploy.DeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to deploy the manifest file.")
+ _, err = wskdeploy.UndeployWithCredentials(manifestPath, deploymentPath, wskprops)
+ assert.Equal(t, nil, err, "Failed to undeploy the manifest file.")
+ }
+}
+
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/node/actions/process-change.js b/tests/apps/owbp-cloudant-trigger/runtimes/node/actions/process-change.js
new file mode 100644
index 0000000..6eb36e2
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/node/actions/process-change.js
@@ -0,0 +1,24 @@
+function main(params) {
+
+ return new Promise(function(resolve, reject) {
+ console.log(params.name);
+ console.log(params.color);
+
+ if (!params.name) {
+ console.error('name parameter not set.');
+ reject({
+ 'error': 'name parameter not set.'
+ });
+ return;
+ } else {
+ var message = 'A ' + params.color + ' cat named ' + params.name + ' was added.';
+ console.log(message);
+ resolve({
+ change: message
+ });
+ return;
+ }
+
+ });
+
+}
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/node/manifest.yaml b/tests/apps/owbp-cloudant-trigger/runtimes/node/manifest.yaml
new file mode 100644
index 0000000..9454a09
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/node/manifest.yaml
@@ -0,0 +1,50 @@
+# Wskdeploy manifest for openwhisk-cloudant-trigger
+# Installing openwhisk actions, triggers, and rules for OpenWhisk building block - Cloudant Trigger
+
+# Deployment using this manifest file creates following OpenWhisk components:
+# Package: openwhisk-cloudant
+# Package: cloudant-trigger
+# Action: cloudant-trigger/process-change.js
+# Sequence: cloudant-trigger/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-trigger:
+ 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
+ actions:
+ # Action named "process-change"
+ # Creating action that is printing data which is written to the database
+ process-change:
+ function: actions/process-change.js
+
+ sequences:
+ # Sequence named "process-change-cloudant-sequence"
+ # Creating sequence to connect the cloudant "read" action with the "process-change" action
+ process-change-cloudant-sequence:
+ actions: openwhisk-cloudant/read, process-change
+ rules:
+ # Rule named "log-change-rule"
+ # Creating rule that maps database change trigger to sequence
+ log-change-rule:
+ trigger: data-inserted-trigger
+ action: process-change-cloudant-sequence
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/php/actions/process-change.php b/tests/apps/owbp-cloudant-trigger/runtimes/php/actions/process-change.php
new file mode 100644
index 0000000..bb3c80b
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/php/actions/process-change.php
@@ -0,0 +1,12 @@
+function main(array $args) : array
+{
+ if (array_key_exists("name", $args) && array_key_exists("color", $args)) {
+ $name = $args["name"];
+ $color = $args["color"];
+ $message = "A $color cat named $name was added.";
+ print($message);
+ return ["change" => $message];
+ } else {
+ return ["error" => "Please make sure name and color parameters are set."];
+ }
+}
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/php/manifest.yaml b/tests/apps/owbp-cloudant-trigger/runtimes/php/manifest.yaml
new file mode 100644
index 0000000..5a6b537
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/php/manifest.yaml
@@ -0,0 +1,50 @@
+# Wskdeploy manifest for openwhisk-cloudant-trigger
+# Installing openwhisk actions, triggers, and rules for OpenWhisk building block - Cloudant Trigger
+
+# Deployment using this manifest file creates following OpenWhisk components:
+# Package: openwhisk-cloudant
+# Package: cloudant-trigger
+# Action: cloudant-trigger/process-change.js
+# Sequence: cloudant-trigger/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-trigger:
+ 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
+ actions:
+ # Action named "process-change"
+ # Creating action that is printing data which is written to the database
+ process-change:
+ function: actions/process-change.php
+
+ sequences:
+ # Sequence named "process-change-cloudant-sequence"
+ # Creating sequence to connect the cloudant "read" action with the "process-change" action
+ process-change-cloudant-sequence:
+ actions: openwhisk-cloudant/read, process-change
+ rules:
+ # Rule named "log-change-rule"
+ # Creating rule that maps database change trigger to sequence
+ log-change-rule:
+ trigger: data-inserted-trigger
+ action: process-change-cloudant-sequence
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/python/actions/process-change.py b/tests/apps/owbp-cloudant-trigger/runtimes/python/actions/process-change.py
new file mode 100644
index 0000000..07171a0
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/python/actions/process-change.py
@@ -0,0 +1,8 @@
+def main(params):
+ if 'name' not in params or 'color' not in params:
+ return { 'error': 'Please make sure name and color are passed in params.' }
+ name = params['name']
+ color = params['color']
+ message = 'A ' + color + ' cat named ' + name + ' was added.';
+ print(message)
+ return { 'change': message }
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/python/manifest.yaml b/tests/apps/owbp-cloudant-trigger/runtimes/python/manifest.yaml
new file mode 100644
index 0000000..c9fbb4c
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/python/manifest.yaml
@@ -0,0 +1,50 @@
+# Wskdeploy manifest for openwhisk-cloudant-trigger
+# Installing openwhisk actions, triggers, and rules for OpenWhisk building block - Cloudant Trigger
+
+# Deployment using this manifest file creates following OpenWhisk components:
+# Package: openwhisk-cloudant
+# Package: cloudant-trigger
+# Action: cloudant-trigger/process-change.js
+# Sequence: cloudant-trigger/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-trigger:
+ 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
+ actions:
+ # Action named "process-change"
+ # Creating action that is printing data which is written to the database
+ process-change:
+ function: actions/process-change.py
+
+ sequences:
+ # Sequence named "process-change-cloudant-sequence"
+ # Creating sequence to connect the cloudant "read" action with the "process-change" action
+ process-change-cloudant-sequence:
+ actions: openwhisk-cloudant/read, process-change
+ rules:
+ # Rule named "log-change-rule"
+ # Creating rule that maps database change trigger to sequence
+ log-change-rule:
+ trigger: data-inserted-trigger
+ action: process-change-cloudant-sequence
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/swift/actions/process-change.swift b/tests/apps/owbp-cloudant-trigger/runtimes/swift/actions/process-change.swift
new file mode 100644
index 0000000..8fc6741
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/swift/actions/process-change.swift
@@ -0,0 +1,11 @@
+func main(args: [String:Any]) -> [String:Any] {
+ if let color = args["color"] as? String,
+ let name = args["name"] as? String
+ {
+ let message = "A \(color) cat named \(name) was added."
+ print(message)
+ return [ "change": message ]
+ } else {
+ return [ "error": "Please make sure to pass color and name into params" ]
+ }
+}
diff --git a/tests/apps/owbp-cloudant-trigger/runtimes/swift/manifest.yaml b/tests/apps/owbp-cloudant-trigger/runtimes/swift/manifest.yaml
new file mode 100644
index 0000000..60a12d2
--- /dev/null
+++ b/tests/apps/owbp-cloudant-trigger/runtimes/swift/manifest.yaml
@@ -0,0 +1,50 @@
+# Wskdeploy manifest for openwhisk-cloudant-trigger
+# Installing openwhisk actions, triggers, and rules for OpenWhisk building block - Cloudant Trigger
+
+# Deployment using this manifest file creates following OpenWhisk components:
+# Package: openwhisk-cloudant
+# Package: cloudant-trigger
+# Action: cloudant-trigger/process-change.js
+# Sequence: cloudant-trigger/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-trigger:
+ 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
+ actions:
+ # Action named "process-change"
+ # Creating action that is printing data which is written to the database
+ process-change:
+ function: actions/process-change.swift
+
+ sequences:
+ # Sequence named "process-change-cloudant-sequence"
+ # Creating sequence to connect the cloudant "read" action with the "process-change" action
+ process-change-cloudant-sequence:
+ actions: openwhisk-cloudant/read, process-change
+ rules:
+ # Rule named "log-change-rule"
+ # Creating rule that maps database change trigger to sequence
+ log-change-rule:
+ trigger: data-inserted-trigger
+ action: process-change-cloudant-sequence
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].