You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/08/02 17:44:56 UTC

[incubator-openwhisk-client-js] branch master updated: Travis: Integration tests and setup script (#59)

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-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 46d5884  Travis: Integration tests and setup script (#59)
46d5884 is described below

commit 46d58844593a6a451a13fdc209a8a383972967b5
Author: Angela <am...@utexas.edu>
AuthorDate: Wed Aug 2 12:44:54 2017 -0500

    Travis: Integration tests and setup script (#59)
    
    * prep integration tests script
    
    * Testing Travis CI
---
 .gitignore                               |   2 +
 .travis.yml                              |   7 +-
 README.md                                |  24 +++++-
 package.json                             |   2 +-
 test/integration/actions.test.js         |  16 ++--
 test/integration/activations.test.js     |  10 ++-
 test/integration/feeds.test.js           |   9 ++-
 test/integration/namespaces.test.js      |   6 +-
 test/integration/packages.test.js        |  10 ++-
 test/integration/prepIntegrationTests.sh | 121 +++++++++++++++++++++++++++++++
 test/integration/routes.test.js          |  33 +--------
 test/integration/rules.test.js           |  14 ++--
 test/integration/triggers.test.js        |  12 +--
 test/integration/utils.js                |  21 ++++++
 tools/travis/integration.sh              |  46 ++++++++++++
 tools/travis/setup.sh                    |  14 ++++
 tools/travis/unit.sh                     |   1 +
 tools/travis/unitsetup.sh                |   6 --
 18 files changed, 283 insertions(+), 71 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3c3629e..b0e3907 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
 node_modules
+npm-debug.log
+.DS_Store
diff --git a/.travis.yml b/.travis.yml
index 4eccf52..153a3f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,16 +4,21 @@ node_js:
 
 sudo: required
 
+services:
+ - docker
+
 before_install:
   - cd $TRAVIS_BUILD_DIR
 
 install:
   - ./tools/travis/setupscan.sh
   - cd $TRAVIS_BUILD_DIR
-  - ./tools/travis/unitsetup.sh
+  - ./tools/travis/setup.sh
   - cd $TRAVIS_BUILD_DIR
 
 script:
   - ./tools/travis/scancode.sh
   - cd $TRAVIS_BUILD_DIR
   - ./tools/travis/unit.sh
+  - cd $TRAVIS_BUILD_DIR
+  - ./tools/travis/integration.sh
diff --git a/README.md b/README.md
index bd87cca..0a30b64 100644
--- a/README.md
+++ b/README.md
@@ -422,11 +422,11 @@ The following optional parameters are supported:
 
 ## api gateway
 
-OpenWhisk supports a [built-in API gateway service](https://github.com/apache/incubator-openwhisk/blob/master/docs/apigateway.md) and external third-party providers. 
+OpenWhisk supports a [built-in API gateway service](https://github.com/apache/incubator-openwhisk/blob/master/docs/apigateway.md) and external third-party providers.
 
-This client library defaults to using the platform service. If the `apigw_token` parameter is passed into the client constructor, the implementation will switch to the [IBM Bluemix API Gateway](https://console.ng.bluemix.net/docs/openwhisk/openwhisk_apigateway.html#openwhisk_apigateway). 
+This client library defaults to using the platform service. If the `apigw_token` parameter is passed into the client constructor, the implementation will switch to the [IBM Bluemix API Gateway](https://console.ng.bluemix.net/docs/openwhisk/openwhisk_apigateway.html#openwhisk_apigateway).
 
-*The interface for managing routes through the library does not change between providers.* 
+*The interface for managing routes through the library does not change between providers.*
 
 ### list routes
 
@@ -493,3 +493,21 @@ npm test
 ```
 npm run-script test-integration
 ```
+
+**Note:** The test integration runs in secure mode by default, which means that all trusted signers must be present and available to the client process.
+If your local environment is using self-signed certificates, you can use the following command to start the script in insecure mode:
+
+`npm run test-integration -i`
+
+This will disable SSL/TLS verification for all SSL communication.
+
+Alternatively, you can run the `prepIntegrationTests.sh` script using guest credentials or by specifying specific credentials.  
+Run the script with guest credentials:  
+```
+./test/integration/prepIntegrationTests.sh guest
+```  
+Run the script with specific credentials:  
+```
+./test/integration/prepIntegrationTests.sh <your key in the form of ABCD:EFGH> <openwhisk instance hostname> <openwhisk namespace> <api gatewaytoken>
+```  
+The `prepIntegrationTests.sh` script is designed to give you feedback if it detects a setting that is not correct on your machine. ex: `node 6 is not detected`
diff --git a/package.json b/package.json
index efbb4c5..c47cd13 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
   },
   "scripts": {
     "test": "ava test/unit",
-    "test-integration": "ava test/integration"
+    "test-integration": "ava test/integration/*.test.js"
   },
   "repository": {
     "type": "git",
diff --git a/test/integration/actions.test.js b/test/integration/actions.test.js
index 634ab10..b1e98e2 100644
--- a/test/integration/actions.test.js
+++ b/test/integration/actions.test.js
@@ -7,6 +7,8 @@ const test = require('ava')
 const Actions = require('../../lib/actions.js')
 const Client = require('../../lib/client.js')
 const JSZip = require('jszip')
+const Utils = require('./utils.js')
+const options = Utils.autoOptions();
 
 const envParams = ['API_KEY', 'API_HOST', 'NAMESPACE']
 
@@ -21,7 +23,7 @@ envParams.forEach(key => {
 const NAMESPACE = process.env.__OW_NAMESPACE
 
 test('list all actions using default namespace', t => {
-  const actions = new Actions(new Client())
+  const actions = new Actions(new Client(options))
   return actions.list().then(result => {
     t.true(Array.isArray(result))
     result.forEach(action => {
@@ -35,7 +37,7 @@ test('list all actions using default namespace', t => {
 })
 
 test('list all actions using options namespace', t => {
-  const actions = new Actions(new Client())
+  const actions = new Actions(new Client(options))
   return actions.list({namespace: NAMESPACE}).then(result => {
     t.true(Array.isArray(result))
     result.forEach(action => {
@@ -54,7 +56,7 @@ test('create, get and delete an action', t => {
     t.fail()
   }
 
-  const actions = new Actions(new Client())
+  const actions = new Actions(new Client(options))
   return actions.create({actionName: 'random_action_test', action: 'function main() {return {payload:"testing"}}'}).then(result => {
     t.is(result.name, 'random_action_test')
     t.is(result.namespace, NAMESPACE)
@@ -75,7 +77,7 @@ test('create and update an action', t => {
     t.fail()
   }
 
-  const actions = new Actions(new Client())
+  const actions = new Actions(new Client(options))
   return actions.create({actionName: 'random_update_tested', action: 'function main() {return {payload:"testing"}}'}).then(result => {
     t.is(result.name, 'random_update_tested')
     t.is(result.namespace, NAMESPACE)
@@ -95,7 +97,7 @@ test('create, get and delete with parameters an action', t => {
     t.fail()
   }
 
-  const actions = new Actions(new Client())
+  const actions = new Actions(new Client(options))
   return actions.create({name: 'random_action_params_test', params: { hello: 'world' }, action: 'function main() {return {payload:"testing"}}'}).then(result => {
     t.is(result.name, 'random_action_params_test')
     t.is(result.namespace, NAMESPACE)
@@ -119,7 +121,7 @@ test('invoke action with fully-qualified name', t => {
     t.fail()
   }
 
-  const actions = new Actions(new Client())
+  const actions = new Actions(new Client(options))
   return actions.invoke({actionName: '/whisk.system/utils/sort', blocking: true}).then(invoke_result => {
     t.true(invoke_result.response.success)
     t.pass()
@@ -138,7 +140,7 @@ test('create, invoke and remove package action', t => {
   zip.file('index.js', 'function main(params) {return params};\nexports.main = main;')
 
   return zip.generateAsync({type: 'nodebuffer'}).then(content => {
-    const actions = new Actions(new Client())
+    const actions = new Actions(new Client(options))
     return actions.create({actionName: 'random_package_action_test', action: content}).then(result => {
       return actions.invoke({actionName: 'random_package_action_test', params: {hello: 'world'}, blocking: true}).then(invoke_result => {
         t.deepEqual(invoke_result.response.result, {hello: 'world'})
diff --git a/test/integration/activations.test.js b/test/integration/activations.test.js
index 9f20661..5c3d87f 100644
--- a/test/integration/activations.test.js
+++ b/test/integration/activations.test.js
@@ -6,6 +6,8 @@
 const test = require('ava')
 const Activations = require('../../lib/activations.js')
 const Client = require('../../lib/client.js')
+const Utils = require('./utils.js')
+const options = Utils.autoOptions();
 
 const envParams = ['API_KEY', 'API_HOST', 'NAMESPACE']
 
@@ -20,7 +22,7 @@ envParams.forEach(key => {
 const NAMESPACE = process.env.__OW_NAMESPACE
 
 test('list all activations', t => {
-  const activations = new Activations(new Client())
+  const activations = new Activations(new Client(options))
   return activations.list().then(result => {
     t.true(Array.isArray(result))
     result.forEach(r => t.is(r.namespace, NAMESPACE))
@@ -32,7 +34,7 @@ test('list all activations', t => {
 })
 
 test('retrieve individual activations', t => {
-  const activations = new Activations(new Client())
+  const activations = new Activations(new Client(options))
   return activations.list().then(result => {
     t.true(Array.isArray(result))
     return Promise.all(result.map(r => activations.get({activation: r.activationId})))
@@ -43,7 +45,7 @@ test('retrieve individual activations', t => {
 })
 
 test('retrieve individual activation logs', t => {
-  const activations = new Activations(new Client())
+  const activations = new Activations(new Client(options))
   return activations.list().then(result => {
     t.true(Array.isArray(result))
     return Promise.all(result.map(r => activations.logs({activation: r.activationId})))
@@ -54,7 +56,7 @@ test('retrieve individual activation logs', t => {
 })
 
 test('retrieve individual activation result', t => {
-  const activations = new Activations(new Client())
+  const activations = new Activations(new Client(options))
   return activations.list().then(result => {
     t.true(Array.isArray(result))
     return Promise.all(result.map(r => activations.result({activation: r.activationId})))
diff --git a/test/integration/feeds.test.js b/test/integration/feeds.test.js
index 0a5e5c8..ec5c0c6 100644
--- a/test/integration/feeds.test.js
+++ b/test/integration/feeds.test.js
@@ -7,6 +7,8 @@ const test = require('ava')
 const Feeds = require('../../lib/feeds.js')
 const Triggers = require('../../lib/triggers.js')
 const Client = require('../../lib/client.js')
+const Utils = require('./utils.js')
+const options = Utils.autoOptions();
 
 const envParams = ['API_KEY', 'API_HOST', 'NAMESPACE']
 
@@ -19,15 +21,16 @@ envParams.forEach(key => {
 })
 
 const NAMESPACE = process.env.__OW_NAMESPACE
+var tempTest = Utils.getInsecureFlag() ? test.skip : test;
 
-test('create and delete a feed', t => {
+tempTest('create and delete a feed', t => {
   const errors = err => {
     console.log(err)
     t.fail()
   }
 
-  const feeds = new Feeds(new Client())
-  const triggers = new Triggers(new Client())
+  const feeds = new Feeds(new Client(options))
+  const triggers = new Triggers(new Client(options))
   const feed_params = {
     feedName: '/whisk.system/alarms/alarm',
     trigger: `/${NAMESPACE}/sample_feed_trigger`,
diff --git a/test/integration/namespaces.test.js b/test/integration/namespaces.test.js
index 55e2590..9506619 100644
--- a/test/integration/namespaces.test.js
+++ b/test/integration/namespaces.test.js
@@ -6,6 +6,8 @@
 const test = require('ava')
 const Namespaces = require('../../lib/namespaces.js')
 const Client = require('../../lib/client.js')
+const Utils = require('./utils.js')
+const options = Utils.autoOptions();
 
 const envParams = ['API_KEY', 'API_HOST', 'NAMESPACE']
 
@@ -20,7 +22,7 @@ envParams.forEach(key => {
 const NAMESPACE = process.env.__OW_NAMESPACE
 
 test('list all namespaces', t => {
-  const namespaces = new Namespaces(new Client())
+  const namespaces = new Namespaces(new Client(options))
   return namespaces.list().then(result => {
     t.true(Array.isArray(result))
     t.pass()
@@ -31,7 +33,7 @@ test('list all namespaces', t => {
 })
 
 test('retrieve individual namespaces', t => {
-  const namespaces = new Namespaces(new Client())
+  const namespaces = new Namespaces(new Client(options))
   return namespaces.list().then(result => {
     t.true(Array.isArray(result))
     return Promise.all(result.map(ns => namespaces.get({namespace: ns})))
diff --git a/test/integration/packages.test.js b/test/integration/packages.test.js
index d671996..7bb7ffe 100644
--- a/test/integration/packages.test.js
+++ b/test/integration/packages.test.js
@@ -6,6 +6,8 @@
 const test = require('ava')
 const Packages = require('../../lib/packages.js')
 const Client = require('../../lib/client.js')
+const Utils = require('./utils.js')
+const options = Utils.autoOptions();
 
 const envParams = ['API_KEY', 'API_HOST', 'NAMESPACE']
 
@@ -20,7 +22,7 @@ envParams.forEach(key => {
 const NAMESPACE = process.env.__OW_NAMESPACE
 
 test('list all packages using default namespace', t => {
-  const packages = new Packages(new Client())
+  const packages = new Packages(new Client(options))
   return packages.list().then(result => {
     t.true(Array.isArray(result))
     result.forEach(packageName => {
@@ -34,7 +36,7 @@ test('list all packages using default namespace', t => {
 })
 
 test('list all packages using options namespace', t => {
-  const packages = new Packages(new Client())
+  const packages = new Packages(new Client(options))
   return packages.list({namespace: NAMESPACE}).then(result => {
     t.true(Array.isArray(result))
     result.forEach(packageName => {
@@ -53,7 +55,7 @@ test('create, get and delete an package', t => {
     t.fail()
   }
 
-  const packages = new Packages(new Client())
+  const packages = new Packages(new Client(options))
   return packages.create({packageName: 'random_package_test'}).then(result => {
     t.is(result.name, 'random_package_test')
     t.is(result.namespace, NAMESPACE)
@@ -74,7 +76,7 @@ test('create and update an package', t => {
     t.fail()
   }
 
-  const packages = new Packages(new Client())
+  const packages = new Packages(new Client(options))
   return packages.create({packageName: 'random_package_update_test'}).then(result => {
     t.is(result.name, 'random_package_update_test')
     t.is(result.namespace, NAMESPACE)
diff --git a/test/integration/prepIntegrationTests.sh b/test/integration/prepIntegrationTests.sh
new file mode 100755
index 0000000..16693ce
--- /dev/null
+++ b/test/integration/prepIntegrationTests.sh
@@ -0,0 +1,121 @@
+#!/bin/bash
+#set -e
+#Usage: ./test/integration/prepIntegrationTests.sh <yourapikeyintheformofABCD:EFGH> <openwhis hostname> <openwhisk namespace> <api gatewaytoken>
+# Run from the incubator-openwhisk-client-js
+
+# Make sure wsk is installed; exit if wsk is not available.
+if ! type "wsk" > /dev/null; then
+  echo "Exiting program; wsk is not installed on the system. Cannot preform tests"
+  exit 1
+fi
+
+# Assert NODEJS6/NPM3 or greater is default node/npm version
+NODE_VERSION_MAJOR=`node --version | awk -Fv '{print $2}' | awk -F. '{print $1}'`
+if [ ${NODE_VERSION_MAJOR} -lt 6 ]; then
+  echo "Exiting program; node less than version 6 detected"
+  exit 1
+fi
+
+# Allow user to specify key, host, namespace, or token
+override_key="$1"
+override_host="$2"
+override_namespace="$3"
+override_token="$4"
+iflag=""
+kflag=""
+
+function getvalue {
+  content="$1"
+  search="$2"
+  result="$3"
+  result=$(echo "$content" | grep "$search" | awk '{print $NF}')
+  return 0
+}
+
+if [ $override_key == "guest" ]; then
+  echo "getting guest user credentials"
+  iflag="-i"
+  kflag="-k"
+  propInfo=$(wsk -i property get)
+  getvalue "$propInfo" "whisk auth" "$result"
+  override_key="$result"
+  getvalue "$propInfo" "whisk API host" "$result"
+  override_host="$result"
+  override_namespace="guest"
+  override_token=""
+
+fi
+
+
+#If they exist, export these values (tests use a global)
+if [ -n "$override_key" ] && [ -n "$override_host" ] && [ -n "$override_namespace" ] ; then
+  echo "found key, host, namespace and token"
+  export __OW_API_KEY="$override_key"
+  export __OW_API_HOST="$override_host"
+  export __OW_NAMESPACE="$override_namespace"
+  export __OW_APIGW_TOKEN="$override_token"
+else
+  echo "Exiting program; Missing one or more of the arguments:  key, host, namespace, or token. Specified in the format: ./prepIntegrationTests.sh <yourapikey> <openwhis hostname> <openwhisk namespace> <api gatewaytoken>";
+  echo "TODO: implement script to get ~/.wskprops and grep it for key, host, namespace, and token."
+  exit 1;
+fi
+
+#verify credentials are acceptable:
+echo "Checking credentials"
+credentialsCheck=$( echo no | curl -s $kflag -u $__OW_API_KEY https://$__OW_API_HOST/api/v1/namespaces )
+credentialError=$(jq -r ".error" <<< $credentialsCheck &>/dev/null)
+if [[ $PIPESTATUS -eq 0 ]]; then
+  echo "Exiting program; There is an error with your username:password credentials: $__OW_API_KEY for accesssing the host $__OW_API_HOST";
+  exit 1;
+fi
+
+
+# make temporary files so that we can use the wsk cli to create actions and triggers.
+# in the instructions the contests of hello and tests are identical so we only make 1 version of the file, and then just create two actions from it.
+echo "Make temporary resource files"
+mkdir temp
+touch temp/tests.js
+echo "function main() {return {payload: 'Hello world'};}" > temp/tests.js
+
+echo "Create wsk actions and triggers for use by tests"
+wsk $iflag action update hello temp/tests.js
+wsk $iflag action update tests temp/tests.js
+wsk $iflag trigger update sample
+
+#run tests
+echo "running tests"
+npm run test-integration $iflag
+RUNSTAT=$PIPESTATUS
+
+#cleanup resources that may or may not exist. Hide stdout/stderr
+function cleanresources {
+  verb="$1"
+  name="$2"
+  wsk $iflag $verb get $name -s &>/dev/null
+  if [[ $PIPESTATUS -eq 0 ]]; then
+    wsk $iflag $verb delete $name
+  fi
+}
+
+#clean up artifacts generated during a bad-testRun
+echo "clean resources"
+cleanresources action routeAction
+cleanresources action random_package_action_test
+cleanresources action random_action_test
+cleanresources action random_action_params_test
+cleanresources action random_update_tested
+cleanresources trigger sample_feed_trigger
+cleanresources trigger sample_rule_trigger
+cleanresources trigger random_trigger_test
+cleanresources rule random_rule_test
+#wsk api delete /testing
+
+#cleanup workspace
+rm -rf temp
+wsk $iflag action delete hello
+wsk $iflag action delete tests
+wsk $iflag trigger delete sample
+
+echo "script finished"
+
+exit $RUNSTAT
diff --git a/test/integration/routes.test.js b/test/integration/routes.test.js
index 839eb0f..949e07c 100644
--- a/test/integration/routes.test.js
+++ b/test/integration/routes.test.js
@@ -7,6 +7,8 @@ const test = require('ava')
 const Actions = require('../../lib/actions.js')
 const Routes = require('../../lib/routes.js')
 const Client = require('../../lib/client.js')
+const Utils = require('./utils.js')
+const options = Utils.autoOptions();
 
 const envParams = ['API_KEY', 'API_HOST', 'APIGW_TOKEN']
 
@@ -18,36 +20,9 @@ envParams.forEach(key => {
   }
 })
 
-test.serial('create, retrieve and delete action route', t => {
-  const token = process.env.__OW_APIGW_TOKEN
-  delete process.env.__OW_APIGW_TOKEN
-  const routes = new Routes(new Client())
-  const actions = new Actions(new Client())
-  process.env.__OW_APIGW_TOKEN = token
-
-  return actions.create({actionName: 'routeAction', action: ''}).then(() => {
-    return routes.create({action: 'routeAction', basepath: '/testing', relpath: '/foo/bar', operation: 'POST'}).then(() => {
-      return routes.list({basepath: '/testing'}).then(results => {
-        t.is(results.apis.length, 1)
-        const apidoc = results.apis[0].value.apidoc
-        t.is(apidoc.basePath, '/testing')
-        t.true(apidoc.paths.hasOwnProperty('/foo/bar'))
-        const path = apidoc.paths['/foo/bar']
-        t.true(path.hasOwnProperty('post'))
-        t.is(path.post['x-ibm-op-ext'].actionName, 'routeAction')
-
-        return routes.delete({basepath: '/testing'}).then(() => actions.delete({actionName: 'routeAction'}))
-      })
-    })
-  }).catch(err => {
-    console.log(err)
-    t.fail()
-  })
-})
-
 test.serial('create, retrieve and delete action route using token', t => {
-  const routes = new Routes(new Client())
-  const actions = new Actions(new Client())
+  const routes = new Routes(new Client(options))
+  const actions = new Actions(new Client(options))
 
   return actions.create({actionName: 'routeAction', action: ''}).then(() => {
     return routes.create({action: 'routeAction', basepath: '/testing', relpath: '/foo/bar', operation: 'POST'}).then(() => {
diff --git a/test/integration/rules.test.js b/test/integration/rules.test.js
index d888ec2..ac7a156 100644
--- a/test/integration/rules.test.js
+++ b/test/integration/rules.test.js
@@ -7,6 +7,8 @@ const test = require('ava')
 const Rules = require('../../lib/rules.js')
 const Triggers = require('../../lib/triggers.js')
 const Client = require('../../lib/client.js')
+const Utils = require('./utils.js')
+const options = Utils.autoOptions();
 
 const envParams = ['API_KEY', 'API_HOST', 'NAMESPACE']
 
@@ -21,7 +23,7 @@ envParams.forEach(key => {
 const NAMESPACE = process.env.__OW_NAMESPACE
 
 test('list all rules using default namespace', t => {
-  const rules = new Rules(new Client())
+  const rules = new Rules(new Client(options))
   return rules.list().then(result => {
     t.true(Array.isArray(result))
     result.forEach(rule => {
@@ -35,7 +37,7 @@ test('list all rules using default namespace', t => {
 })
 
 test('list all rules using options namespace', t => {
-  const rules = new Rules(new Client())
+  const rules = new Rules(new Client(options))
   return rules.list({namespace: NAMESPACE}).then(result => {
     t.true(Array.isArray(result))
     result.forEach(rule => {
@@ -55,8 +57,8 @@ test.serial('create, get and delete a rule', t => {
     t.fail()
   }
 
-  const rules = new Rules(new Client())
-  const triggers = new Triggers(new Client())
+  const rules = new Rules(new Client(options))
+  const triggers = new Triggers(new Client(options))
   return triggers.create({triggerName: 'sample_rule_trigger'}).then(() => {
     return rules.create({ruleName: 'random_rule_test', action: `/${NAMESPACE}/hello`, trigger: `/${NAMESPACE}/sample_rule_trigger`}).then(result => {
       t.is(result.name, 'random_rule_test')
@@ -81,8 +83,8 @@ test.serial('create and update a rule', t => {
     t.fail()
   }
 
-  const rules = new Rules(new Client())
-  const triggers = new Triggers(new Client())
+  const rules = new Rules(new Client(options))
+  const triggers = new Triggers(new Client(options))
   return triggers.create({triggerName: 'sample_rule_trigger'}).then(() => {
     return rules.create({ruleName: 'random_update_test', action: `/${NAMESPACE}/hello`, trigger: `/${NAMESPACE}/sample_rule_trigger`}).then(result => {
       t.is(result.name, 'random_update_test')
diff --git a/test/integration/triggers.test.js b/test/integration/triggers.test.js
index eea939b..d49f08c 100644
--- a/test/integration/triggers.test.js
+++ b/test/integration/triggers.test.js
@@ -6,8 +6,10 @@
 const test = require('ava')
 const Triggers = require('../../lib/triggers.js')
 const Client = require('../../lib/client.js')
+const Utils = require('./utils.js')
 
 const envParams = ['API_KEY', 'API_HOST', 'NAMESPACE']
+const options = Utils.autoOptions();
 
 // check that mandatory configuration properties are available
 envParams.forEach(key => {
@@ -20,7 +22,7 @@ envParams.forEach(key => {
 const NAMESPACE = process.env.__OW_NAMESPACE
 
 test('list all triggers using default namespace', t => {
-  const triggers = new Triggers(new Client())
+  const triggers = new Triggers(new Client(options))
   return triggers.list().then(result => {
     t.true(Array.isArray(result))
     result.forEach(trigger => {
@@ -34,7 +36,7 @@ test('list all triggers using default namespace', t => {
 })
 
 test('list all triggers using options namespace', t => {
-  const triggers = new Triggers(new Client())
+  const triggers = new Triggers(new Client(options))
   return triggers.list({namespace: NAMESPACE}).then(result => {
     t.true(Array.isArray(result))
     result.forEach(trigger => {
@@ -53,7 +55,7 @@ test('create, get and delete an trigger', t => {
     t.fail()
   }
 
-  const triggers = new Triggers(new Client())
+  const triggers = new Triggers(new Client(options))
   return triggers.create({triggerName: 'random_trigger_test'}).then(result => {
     t.is(result.name, 'random_trigger_test')
     t.is(result.namespace, NAMESPACE)
@@ -76,7 +78,7 @@ test('create and update an trigger', t => {
     t.fail()
   }
 
-  const triggers = new Triggers(new Client())
+  const triggers = new Triggers(new Client(options))
   return triggers.create({triggerName: 'random_create_update_test'}).then(result => {
     t.is(result.name, 'random_create_update_test')
     t.is(result.namespace, NAMESPACE)
@@ -97,7 +99,7 @@ test('fire a trigger', t => {
     t.fail()
   }
 
-  const triggers = new Triggers(new Client())
+  const triggers = new Triggers(new Client(options))
   return triggers.create({triggerName: 'random_fire_test'}).then(result => {
     return triggers.invoke({triggerName: 'random_fire_test'}).then(update_result => {
       t.true(update_result.hasOwnProperty('activationId'))
diff --git a/test/integration/utils.js b/test/integration/utils.js
new file mode 100644
index 0000000..42ff656
--- /dev/null
+++ b/test/integration/utils.js
@@ -0,0 +1,21 @@
+function getInsecureFlag(){
+  let npmConfigArgObj = process.env.npm_config_argv ? JSON.parse(process.env.npm_config_argv) : null;
+  if(npmConfigArgObj){
+    return npmConfigArgObj.original&&npmConfigArgObj.original[2]=="-i";
+  }
+  return false;
+}
+
+function autoOptions(){
+  var options = {};
+  if(getInsecureFlag()){
+    options.ignore_certs = true;
+    options.apigw_token = true;
+  }
+  return options;
+}
+
+module.exports = {
+  getInsecureFlag : getInsecureFlag,
+  autoOptions: autoOptions
+};
diff --git a/tools/travis/integration.sh b/tools/travis/integration.sh
new file mode 100755
index 0000000..039355e
--- /dev/null
+++ b/tools/travis/integration.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+set -e
+
+# Build script for Travis-CI.
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+ROOTDIR="$SCRIPTDIR/../.."
+WHISKDIR="$ROOTDIR/../openwhisk"
+
+# Install OpenWhisk
+cd $WHISKDIR/ansible
+
+ANSIBLE_CMD="ansible-playbook -i environments/local -e docker_image_prefix=openwhisk"
+
+$ANSIBLE_CMD setup.yml
+$ANSIBLE_CMD prereq.yml
+$ANSIBLE_CMD couchdb.yml
+$ANSIBLE_CMD initdb.yml
+$ANSIBLE_CMD apigateway.yml
+
+cd $WHISKDIR
+./gradlew :tools:cli:distDocker -PdockerImagePrefix=openwhisk
+
+cd $WHISKDIR/ansible
+
+$ANSIBLE_CMD wipe.yml
+$ANSIBLE_CMD openwhisk.yml
+$ANSIBLE_CMD postdeploy.yml
+
+cd $WHISKDIR
+cat whisk.properties
+
+# Set Environment
+export OPENWHISK_HOME=$WHISKDIR
+
+# Set up CLI tool used by prereq script
+sudo cp $WHISKDIR/bin/wsk /usr/bin/wsk
+
+edgehost=$(cat $WHISKDIR/whisk.properties | grep edge.host= | sed s/edge\.host=//)
+wsk property set --apihost $edgehost
+wsk property set --auth "$(cat $WHISKDIR/ansible/files/auth.guest)"
+
+# Test
+cd $ROOTDIR
+npm install
+./test/integration/prepIntegrationTests.sh guest
diff --git a/tools/travis/setup.sh b/tools/travis/setup.sh
new file mode 100755
index 0000000..d531131
--- /dev/null
+++ b/tools/travis/setup.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+HOMEDIR="$SCRIPTDIR/../../../"
+
+# install node and npm
+sudo apt-get -y install nodejs npm
+
+cd $HOMEDIR
+
+# shallow clone OpenWhisk repo.
+git clone --depth 1 https://github.com/apache/incubator-openwhisk.git openwhisk
+
+cd openwhisk
+./tools/travis/setup.sh
diff --git a/tools/travis/unit.sh b/tools/travis/unit.sh
index a5361e4..078d9e6 100755
--- a/tools/travis/unit.sh
+++ b/tools/travis/unit.sh
@@ -5,3 +5,4 @@ ROOTDIR="$SCRIPTDIR/../.."
 cd $ROOTDIR
 npm install
 npm run test
+exit $PIPESTATUS
diff --git a/tools/travis/unitsetup.sh b/tools/travis/unitsetup.sh
deleted file mode 100755
index 17cea1b..0000000
--- a/tools/travis/unitsetup.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-SCRIPTDIR=$(cd $(dirname "$0") && pwd)
-
-# install node and npm
-sudo apt-get -y install nodejs npm
-

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