You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/11/17 22:53:10 UTC

[GitHub] rabbah closed pull request #2958: initial support for nodejs8

rabbah closed pull request #2958: initial support for nodejs8
URL: https://github.com/apache/incubator-openwhisk/pull/2958
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/actionRuntimes/nodejs8Action/Dockerfile b/actionRuntimes/nodejs8Action/Dockerfile
new file mode 100644
index 0000000000..9f2d40a0cc
--- /dev/null
+++ b/actionRuntimes/nodejs8Action/Dockerfile
@@ -0,0 +1,2 @@
+FROM openwhisk/action-nodejs-v8:1.0.0
+
diff --git a/actionRuntimes/nodejs8Action/build.gradle b/actionRuntimes/nodejs8Action/build.gradle
new file mode 100644
index 0000000000..aa07d2b5ef
--- /dev/null
+++ b/actionRuntimes/nodejs8Action/build.gradle
@@ -0,0 +1,10 @@
+apply plugin: 'eclipse'
+eclipse {
+    project {
+        natures 'org.eclipse.wst.jsdt.core.jsNature'
+        buildCommand 'org.eclipse.wst.jsdt.core.javascriptValidator'
+    }
+}
+
+ext.dockerImageName = 'action-nodejs-v8'
+apply from: '../../gradle/docker.gradle'
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index d25b84eb13..2fef4688cd 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -46,6 +46,11 @@ runtimesManifestDefault:
       image:
         name: "nodejs6action"
       deprecated: false
+    - kind: "nodejs:8"
+      default: false
+      image:
+        name: "action-nodejs-v8"
+      deprecated: false
     python:
     - kind: "python"
       image:
diff --git a/core/controller/src/main/resources/apiv1swagger.json b/core/controller/src/main/resources/apiv1swagger.json
index 3498997693..95f680c54c 100644
--- a/core/controller/src/main/resources/apiv1swagger.json
+++ b/core/controller/src/main/resources/apiv1swagger.json
@@ -1555,6 +1555,7 @@
                     "type": "string",
                     "enum": [
                         "nodejs:6",
+                        "nodejs:8",
                         "python:2",
                         "python:3",
                         "swift:3",
diff --git a/docs/actions.md b/docs/actions.md
index 38c1801c07..d11daf9af5 100644
--- a/docs/actions.md
+++ b/docs/actions.md
@@ -50,7 +50,8 @@ Review the following steps and examples to create your first JavaScript action.
   ```
   ok: created action hello
   ```
-
+  The CLI automatically infers the type of the action by using the source file extension. For `.js` source files, the action runs by using a Node.js 6 runtime. You can also create an action that runs with Node.js 8 by explicitly specifying the parameter `--kind nodejs:8`. For more information, see the Node.js 6 vs 8 [reference](./openwhisk_reference.html#openwhisk_ref_javascript_environments).
+  
 3. List the actions that you have created:
 
   ```
@@ -474,7 +475,7 @@ To create an OpenWhisk action from this package:
   wsk action create packageAction --kind nodejs:6 action.zip
   ```
 
-  Note that when creating an action from a `.zip` archive using the CLI tool, you must explicitly provide a value for the `--kind` flag.
+  When creating an action from a `.zip` archive with the CLI tool, you must explicitly provide a value for the `--kind` flag by using `nodejs:6` or `nodejs:8`.
 
 4. You can invoke the action like any other:
 
@@ -493,6 +494,90 @@ To create an OpenWhisk action from this package:
 
 Finally, note that while most `npm` packages install JavaScript sources on `npm install`, some also install and compile binary artifacts. The archive file upload currently does not support binary dependencies but rather only JavaScript dependencies. Action invocations may fail if the archive includes binary dependencies.
 
+### Package an action as a single bundle
+
+It is convenient to only include the minimal code into a single `.js` file that includes dependencies. This approach allows for faster deployments, and in some circumstances where packaging the action as a zip might be too large because it includes unnecessary files.
+
+You can use a JavaScript module bundler such as [webpack](https://webpack.js.org/concepts/). When webpack processes your code, it recursively builds a dependency graph that includes every module that your action needs.
+
+Here is a quick example using webpack:
+
+Taking the previous example `package.json` add `webpack` as a development depency and add some npm script commands.
+```json
+{
+  "name": "my-action",
+  "main": "dist/bundle.js",
+  "scripts": {
+    "build": "webpack --config webpack.config.js",
+    "deploy": "wsk action update my-action dist/bundle.js --kind nodejs:8"
+  },
+  "dependencies": {
+    "left-pad": "1.1.3"
+  },
+  "devDependencies": {
+    "webpack": "^3.8.1"
+  }
+}
+```
+
+Create the webpack configuration file `webpack.config.js`.
+```javascript
+var path = require('path');
+module.exports = {
+  entry: './index.js',
+  output: {
+    path: path.resolve(__dirname, 'dist'),
+    filename: 'bundle.js'
+  },
+  target: 'node'
+};
+```
+
+Set the variable `global.main` to the main function of the action.
+From the previous example:
+```javascript
+function myAction(args) {
+    const leftPad = require("left-pad")
+    const lines = args.lines || [];
+    return { padded: lines.map(l => leftPad(l, 30, ".")) }
+}
+global.main = myAction;
+```
+
+If your function name is `main`, use this syntax instead:
+```javascript
+global.main = main;
+```
+
+To build and deploy an OpenWhisk Action using `npm` and `webpack`:
+
+1. First, install dependencies locally:
+
+  ```
+  npm install
+  ```
+
+2. Build the webpack bundle:
+
+  ```
+  npm run build
+  ```
+
+  The file `dist/bundle.js` is created, and is used to deploy as the Action source code.
+
+3. Create the Action using the `npm` script or the CLI.
+  Using `npm` script:
+  ```
+  npm run deploy
+  ```
+  {: pre}
+  Using the CLI:
+  ```
+  wsk action update my-action dist/bundle.js
+  ```
+
+Finally, the bundle file that is built by `webpack` doesn't support binary dependencies but rather JavaScript dependencies. So Action invocations will fail if the bundle depends on binary dependencies, because this is not included with the file `bundle.js`.
+
 ## Creating action sequences
 
 You can create an action that chains together a sequence of actions.
diff --git a/docs/reference.md b/docs/reference.md
index b4e20ec69a..258abe5615 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -113,7 +113,7 @@ OpenWhisk JavaScript actions run in a Node.js runtime.
 
 Actions written in JavaScript must be confined to a single file. The file can contain multiple functions but by convention a function called `main` must exist and is the one called when the action is invoked. For example, the following is an example of an action with multiple functions.
 
-```
+```javascript
 function main() {
     return { payload: helper() }
 }
@@ -136,7 +136,7 @@ A JavaScript action's activation is **synchronous** if the main function exits u
 
 Here is an example of a synchronous action.
 
-```
+```javascript
 // an action in which each path results in a synchronous activation
 function main(params) {
   if (params.payload == 0) {
@@ -155,7 +155,7 @@ Start by instantiating a new Promise object and passing it a callback function.
 
 The following is an example on how to fulfill a Promise by calling the resolve function.
 
-```
+```javascript
 function main(args) {
      return new Promise(function(resolve, reject) {
        setTimeout(function() {
@@ -167,7 +167,7 @@ function main(args) {
 
 The following is an example on how to reject a Promise by calling the reject function.
 
-```
+```javascript
 function main(args) {
      return new Promise(function(resolve, reject) {
        setTimeout(function() {
@@ -179,7 +179,7 @@ function main(args) {
 
 It is possible for an action to be synchronous on some inputs and asynchronous on others. The following is an example.
 
-```
+```javascript
   function main(params) {
       if (params.payload) {
          // asynchronous activation
@@ -206,7 +206,12 @@ For the `whisk.error()` you can return a rejected Promise (i.e. Promise.reject).
 
 ### JavaScript runtime environments
 
-JavaScript actions are executed by default in a Node.js version 6.12.0 environment.  The 6.12.0 environment will also be used for an action if the `--kind` flag is explicitly specified with a value of 'nodejs:6' when creating/updating the action.
+JavaScript actions can be executed in Node.js version 6 or Node.js version 8.
+Currently actions are executed by default in a Node.js version 6.12.0 environment.  
+
+### Node.js version 6 environment
+The Node.js 6.12.0 environment will be used for an action if the `--kind` flag is explicitly specified with a value of 'nodejs:6' when creating/updating the action.
+
 The following packages are available to be used in the Node.js 6.12.0 environment:
 
 - [apn v2.1.2](https://www.npmjs.com/package/apn) - A Node.js module for interfacing with the Apple Push Notification service.
@@ -214,31 +219,31 @@ The following packages are available to be used in the Node.js 6.12.0 environmen
 - [btoa v1.1.2](https://www.npmjs.com/package/btoa) - A port of the browser's btoa function.
 - [cheerio v0.22.0](https://www.npmjs.com/package/cheerio) - Fast, flexible & lean implementation of core jQuery designed specifically for the server.
 - [cloudant v1.6.2](https://www.npmjs.com/package/cloudant) - This is the official Cloudant library for Node.js.
-- [commander v2.9.0](https://www.npmjs.com/package/commander) - The complete solution for node.js command-line interfaces.
+- [commander v2.9.0](https://www.npmjs.com/package/commander) - The complete solution for Node.js command-line interfaces.
 - [consul v0.27.0](https://www.npmjs.com/package/consul) - A client for Consul, involving service discovery and configuration.
 - [cookie-parser v1.4.3](https://www.npmjs.com/package/cookie-parser) - Parse Cookie header and populate req.cookies with an object keyed by the cookie names.
 - [cradle v0.7.1](https://www.npmjs.com/package/cradle) - A high-level, caching, CouchDB client for Node.js.
 - [errorhandler v1.5.0](https://www.npmjs.com/package/errorhandler) - Development-only error handler middleware.
-- [glob v7.1.1](https://www.npmjs.com/package/glob) - Match files using the patterns the shell uses, like stars and stuff.
+- [glob v7.1.1](https://www.npmjs.com/package/glob) - Match files by using patterns that the shell uses, like stars and stuff.
 - [gm v1.23.0](https://www.npmjs.com/package/gm) - GraphicsMagick and ImageMagick for Node.
 - [lodash v4.17.2](https://www.npmjs.com/package/lodash) - The Lodash library exported as Node.js modules.
-- [log4js v0.6.38](https://www.npmjs.com/package/log4js) - This is a conversion of the log4js framework to work with Node.
+- [log4js v0.6.38](https://www.npmjs.com/package/log4js) - A conversion of the log4js framework designed to work with Node.
 - [iconv-lite v0.4.15](https://www.npmjs.com/package/iconv-lite) - Pure JS character encoding conversion
-- [marked v0.3.6](https://www.npmjs.com/package/marked) - A full-featured markdown parser and compiler, written in JavaScript. Built for speed.
+- [marked v0.3.6](https://www.npmjs.com/package/marked) - A full-featured markdown parser and compiler, which is written in JavaScript. Built for speed.
 - [merge v1.2.0](https://www.npmjs.com/package/merge) - Merge multiple objects into one, optionally creating a new cloned object.
 - [moment v2.17.0](https://www.npmjs.com/package/moment) - A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
 - [mongodb v2.2.11](https://www.npmjs.com/package/mongodb) - The official MongoDB driver for Node.js.
-- [mustache v2.3.0](https://www.npmjs.com/package/mustache) - mustache.js is an implementation of the mustache template system in JavaScript.
-- [nano v6.2.0](https://www.npmjs.com/package/nano) - minimalistic couchdb driver for Node.js.
+- [mustache v2.3.0](https://www.npmjs.com/package/mustache) - Mustache.js is an implementation of the mustache template system in JavaScript.
+- [nano v6.2.0](https://www.npmjs.com/package/nano) - Minimalistic couchdb driver for Node.js.
 - [node-uuid v1.4.7](https://www.npmjs.com/package/node-uuid) - Deprecated UUID packaged.
 - [nodemailer v2.6.4](https://www.npmjs.com/package/nodemailer) - Send e-mails from Node.js ? easy as cake!
-- [oauth2-server v2.4.1](https://www.npmjs.com/package/oauth2-server) - Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in Node.js.
+- [oauth2-server v2.4.1](https://www.npmjs.com/package/oauth2-server) - Complete, compliant, and well tested module for implementing an OAuth2 Server/Provider with express in Node.js.
 - [openwhisk v3.10.0](https://www.npmjs.com/package/openwhisk) - JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs.
 - [pkgcloud v1.4.0](https://www.npmjs.com/package/pkgcloud) - pkgcloud is a standard library for Node.js that abstracts away differences among multiple cloud providers.
-- [process v0.11.9](https://www.npmjs.com/package/process) - require('process'); just like any other module.
+- [process v0.11.9](https://www.npmjs.com/package/process) - Require('process'); just like any other module.
 - [pug v2.0.0-beta6](https://www.npmjs.com/package/pug) - Implements the Pug templating language.
-- [redis v2.6.3](https://www.npmjs.com/package/redis) - This is a complete and feature rich Redis client for Node.js.
-- [request v2.79.0](https://www.npmjs.com/package/request) - Request is designed to be the simplest way possible to make HTTP calls.
+- [redis v2.6.3](https://www.npmjs.com/package/redis) - This is a complete and feature-rich Redis client for Node.js.
+- [request v2.79.0](https://www.npmjs.com/package/request) - Request is the simplest way possible to make HTTP calls.
 - [request-promise v4.1.1](https://www.npmjs.com/package/request-promise) - The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
 - [rimraf v2.5.4](https://www.npmjs.com/package/rimraf) - The UNIX command rm -rf for node.
 - [semver v5.3.0](https://www.npmjs.com/package/semver) - Supports semantic versioning.
@@ -247,10 +252,10 @@ The following packages are available to be used in the Node.js 6.12.0 environmen
 - [socket.io v1.6.0](https://www.npmjs.com/package/socket.io) - Socket.IO enables real-time bidirectional event-based communication.
 - [socket.io-client v1.6.0](https://www.npmjs.com/package/socket.io-client) - Client-side support for Socket.IO.
 - [superagent v3.0.0](https://www.npmjs.com/package/superagent) - SuperAgent is a small progressive client-side HTTP request library, and Node.js module with the same API, sporting many high-level HTTP client features.
-- [swagger-tools v0.10.1](https://www.npmjs.com/package/swagger-tools) - Tools related to working with Swagger, a way to document APIs.
+- [swagger-tools v0.10.1](https://www.npmjs.com/package/swagger-tools) - Tools that are related to working with Swagger, a way to document APIs.
 - [tmp v0.0.31](https://www.npmjs.com/package/tmp) - A simple temporary file and directory creator for node.js.
 - [twilio v2.11.1](https://www.npmjs.com/package/twilio) - A wrapper for the Twilio API, related to voice, video, and messaging.
-- [underscore v1.8.3](https://www.npmjs.com/package/underscore) - Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects.
+- [underscore v1.8.3](https://www.npmjs.com/package/underscore) - Underscore.js is a utility-belt library for JavaScript that supports the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects.
 - [uuid v3.0.0](https://www.npmjs.com/package/uuid) - Simple, fast generation of RFC4122 UUIDS.
 - [validator v6.1.0](https://www.npmjs.com/package/validator) - A library of string validators and sanitizers.
 - [watson-developer-cloud v2.29.0](https://www.npmjs.com/package/watson-developer-cloud) - Node.js client library to use the Watson Developer Cloud services, a collection of APIs that use cognitive computing to solve complex problems.
@@ -259,7 +264,19 @@ The following packages are available to be used in the Node.js 6.12.0 environmen
 - [ws v1.1.1](https://www.npmjs.com/package/ws) - ws is a simple to use, blazing fast, and thoroughly tested WebSocket client and server implementation.
 - [xml2js v0.4.17](https://www.npmjs.com/package/xml2js) - Simple XML to JavaScript object converter. It supports bi-directional conversion.
 - [xmlhttprequest v1.8.0](https://www.npmjs.com/package/xmlhttprequest) - node-XMLHttpRequest is a wrapper for the built-in http client to emulate the browser XMLHttpRequest object.
-- [yauzl v2.7.0](https://www.npmjs.com/package/yauzl) - yet another unzip library for node. For zipping.
+- [yauzl v2.7.0](https://www.npmjs.com/package/yauzl) - Yet another unzip library for node. For zipping.
+
+### Node.js version 8 environment
+The Node.js version 8.9.1 environment is used if the `--kind` flag is explicitly specified with a value of 'nodejs:8' when creating or updating an Action.
+
+The following packages are pre-installed in the Node.js version 8.9.1 environment:
+
+- [openwhisk v3.10.0](https://www.npmjs.com/package/openwhisk) - JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs.
+
+### Packaging npm packages with your actions
+For any `npm` packages that are not pre-installed in the Node.js environment, you can bundle them as dependencies when you create or update your action.
+
+For more information, see [Packaging an action as a Node.js module](./actions.md#packaging-an-action-as-a-nodejs-module) or [Packaging an action as a single bundle](./actions.md#packaging-an-action-as-a-single-bundle).
 
 ## Python actions
 OpenWhisk supports running Python actions using two different runtime versions.
diff --git a/settings.gradle b/settings.gradle
index 3d652a435b..200ff09100 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -3,6 +3,7 @@ include 'common:scala'
 include 'core:controller'
 include 'core:invoker'
 include 'actionRuntimes:nodejs6Action'
+include 'actionRuntimes:nodejs8Action'
 include 'actionRuntimes:actionProxy'
 include 'actionRuntimes:pythonAction'
 include 'actionRuntimes:python2Action'
diff --git a/tests/src/test/scala/actionContainers/NodeJs8ActionContainerTests.scala b/tests/src/test/scala/actionContainers/NodeJs8ActionContainerTests.scala
new file mode 100644
index 0000000000..8727a7f31d
--- /dev/null
+++ b/tests/src/test/scala/actionContainers/NodeJs8ActionContainerTests.scala
@@ -0,0 +1,54 @@
+/*
+ * 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 actionContainers
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import spray.json.JsObject
+
+@RunWith(classOf[JUnitRunner])
+class NodeJs8ActionContainerTests extends NodeJsActionContainerTests {
+
+  override lazy val nodejsContainerImageName = "action-nodejs-v8"
+
+  it should "support async and await" in {
+    withNodeJsContainer { c =>
+      val code = """
+                   | const util = require('util');
+                   | const fs = require('fs');
+                   |
+                   | const stat = util.promisify(fs.stat);
+                   |
+                   | async function main() {
+                   |   const stats = await stat('.');
+                   |   return stats
+                   | }
+                 """.stripMargin;
+
+      val (initCode, _) = c.init(initPayload(code))
+      initCode should be(200)
+
+      val (runCode, runRes) = c.run(runPayload(JsObject()))
+      runCode should be(200) // action writer returning an error is OK
+
+      runRes shouldBe defined
+      runRes.get.fields.get("uid") shouldBe defined
+    }
+  }
+
+}
diff --git a/tests/src/test/scala/actionContainers/NodeJsActionContainerTests.scala b/tests/src/test/scala/actionContainers/NodeJsActionContainerTests.scala
index 928118b16c..be45a52a46 100644
--- a/tests/src/test/scala/actionContainers/NodeJsActionContainerTests.scala
+++ b/tests/src/test/scala/actionContainers/NodeJsActionContainerTests.scala
@@ -260,13 +260,12 @@ class NodeJsActionContainerTests extends BasicActionRunnerTests with WskActorSys
     })
   }
 
-  it should "have ws and socket.io-client packages available" in {
+  it should "have openwhisk package available" in {
     // GIVEN that it should "error when requiring a non-existent package" (see test above for this)
     val (out, err) = withNodeJsContainer { c =>
       val code = """
                 | function main(args) {
-                |     require('ws');
-                |     require('socket.io-client');
+                |     require('openwhisk');
                 | }
             """.stripMargin
 
diff --git a/tests/src/test/scala/system/basic/WskBasicNode6Tests.scala b/tests/src/test/scala/system/basic/WskBasicNode6Tests.scala
new file mode 100644
index 0000000000..a97636f701
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskBasicNode6Tests.scala
@@ -0,0 +1,94 @@
+/*
+ * 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 system.basic
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.JsHelpers
+import common.TestHelpers
+import common.TestUtils
+import common.TestUtils.RunResult
+import common.BaseWsk
+import common.WskProps
+import common.WskTestHelpers
+import spray.json._
+
+@RunWith(classOf[JUnitRunner])
+abstract class WskBasicNode6Tests extends TestHelpers with WskTestHelpers with JsHelpers {
+
+  implicit val wskprops = WskProps()
+  val wsk: BaseWsk
+  val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+  lazy val currentNodeJsKind = "nodejs:6"
+
+  behavior of "Runtime $currentNodeJsKind"
+
+  it should "Ensure that NodeJS actions can have a non-default entrypoint" in withAssetCleaner(wskprops) {
+    (wp, assetHelper) =>
+      val name = "niamNpmAction"
+      val file = Some(TestUtils.getTestActionFilename("niam.js"))
+
+      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+        action.create(name, file, main = Some("niam"), kind = Some(currentNodeJsKind))
+      }
+
+      withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
+        val response = activation.response
+        response.result.get.fields.get("error") shouldBe empty
+        response.result.get.fields.get("greetings") should be(Some(JsString("Hello from a non-standard entrypoint.")))
+      }
+  }
+
+  it should "Ensure that zipped actions are encoded and uploaded as NodeJS actions" in withAssetCleaner(wskprops) {
+    (wp, assetHelper) =>
+      val name = "zippedNpmAction"
+      val file = Some(TestUtils.getTestActionFilename("zippedaction.zip"))
+
+      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+        action.create(name, file, kind = Some(currentNodeJsKind))
+      }
+
+      withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
+        val response = activation.response
+        response.result.get.fields.get("error") shouldBe empty
+        response.result.get.fields.get("author") shouldBe defined
+      }
+  }
+
+  it should "Ensure that returning an empty rejected Promise results in an errored activation" in withAssetCleaner(
+    wskprops) { (wp, assetHelper) =>
+    val name = "jsEmptyRejectPromise"
+
+    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+      action.create(name, Some(TestUtils.getTestActionFilename("issue-1562.js")), kind = Some(currentNodeJsKind))
+    }
+
+    withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
+      val response = activation.response
+      response.success should be(false)
+      response.result.get.fields.get("error") shouldBe defined
+    }
+  }
+
+  def convertRunResultToJsObject(result: RunResult): JsObject = {
+    val stdout = result.stdout
+    val firstNewline = stdout.indexOf("\n")
+    stdout.substring(firstNewline + 1).parseJson.asJsObject
+  }
+}
diff --git a/tests/src/test/scala/system/basic/WskBasicNode8Tests.scala b/tests/src/test/scala/system/basic/WskBasicNode8Tests.scala
new file mode 100644
index 0000000000..cbb772565b
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskBasicNode8Tests.scala
@@ -0,0 +1,26 @@
+/*
+ * 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 system.basic
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+abstract class WskBasicNode8Tests extends WskBasicNode6Tests {
+  override lazy val currentNodeJsKind = "nodejs:8"
+}
diff --git a/tests/src/test/scala/system/basic/WskBasicNodeTests.scala b/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
similarity index 61%
rename from tests/src/test/scala/system/basic/WskBasicNodeTests.scala
rename to tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
index 5904b934fc..e0e73169a6 100644
--- a/tests/src/test/scala/system/basic/WskBasicNodeTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
@@ -32,14 +32,14 @@ import spray.json._
 import spray.json.DefaultJsonProtocol._
 
 @RunWith(classOf[JUnitRunner])
-abstract class WskBasicNodeTests extends TestHelpers with WskTestHelpers with JsHelpers {
+abstract class WskBasicNodeDefaultTests extends TestHelpers with WskTestHelpers with JsHelpers {
 
   implicit val wskprops = WskProps()
   val wsk: BaseWsk
   val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
   val currentNodeJsDefaultKind = "nodejs:6"
 
-  behavior of "NodeJS runtime"
+  behavior of "NodeJS default runtime"
 
   it should "Map a kind of nodejs:default to the current default NodeJS runtime" in withAssetCleaner(wskprops) {
     (wp, assetHelper) =>
@@ -56,38 +56,6 @@ abstract class WskBasicNodeTests extends TestHelpers with WskTestHelpers with Js
       }
   }
 
-  it should "Ensure that NodeJS actions can have a non-default entrypoint" in withAssetCleaner(wskprops) {
-    (wp, assetHelper) =>
-      val name = "niamNpmAction"
-      val file = Some(TestUtils.getTestActionFilename("niam.js"))
-
-      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
-        action.create(name, file, main = Some("niam"))
-      }
-
-      withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
-        val response = activation.response
-        response.result.get.fields.get("error") shouldBe empty
-        response.result.get.fields.get("greetings") should be(Some(JsString("Hello from a non-standard entrypoint.")))
-      }
-  }
-
-  it should "Ensure that zipped actions are encoded and uploaded as NodeJS actions" in withAssetCleaner(wskprops) {
-    (wp, assetHelper) =>
-      val name = "zippedNpmAction"
-      val file = Some(TestUtils.getTestActionFilename("zippedaction.zip"))
-
-      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
-        action.create(name, file, kind = Some("nodejs:default"))
-      }
-
-      withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
-        val response = activation.response
-        response.result.get.fields.get("error") shouldBe empty
-        response.result.get.fields.get("author") shouldBe defined
-      }
-  }
-
   it should "Ensure that zipped actions cannot be created without a kind specified" in withAssetCleaner(wskprops) {
     (wp, assetHelper) =>
       val name = "zippedNpmActionWithNoKindSpecified"
@@ -117,21 +85,6 @@ abstract class WskBasicNodeTests extends TestHelpers with WskTestHelpers with Js
     }
   }
 
-  it should "Ensure that returning an empty rejected Promise results in an errored activation" in withAssetCleaner(
-    wskprops) { (wp, assetHelper) =>
-    val name = "jsEmptyRejectPromise"
-
-    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
-      action.create(name, Some(TestUtils.getTestActionFilename("issue-1562.js")))
-    }
-
-    withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
-      val response = activation.response
-      response.success should be(false)
-      response.result.get.fields.get("error") shouldBe defined
-    }
-  }
-
   def convertRunResultToJsObject(result: RunResult): JsObject = {
     val stdout = result.stdout
     val firstNewline = stdout.indexOf("\n")
diff --git a/tests/src/test/scala/system/basic/WskCliBasicNodeTests.scala b/tests/src/test/scala/system/basic/WskCliBasicNode6Tests.scala
similarity index 94%
rename from tests/src/test/scala/system/basic/WskCliBasicNodeTests.scala
rename to tests/src/test/scala/system/basic/WskCliBasicNode6Tests.scala
index 5c923b937c..9bcec867d1 100644
--- a/tests/src/test/scala/system/basic/WskCliBasicNodeTests.scala
+++ b/tests/src/test/scala/system/basic/WskCliBasicNode6Tests.scala
@@ -23,6 +23,6 @@ import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 
 @RunWith(classOf[JUnitRunner])
-class WskCliBasicNodeTests extends WskBasicNodeTests {
+class WskCliBasicNode6Tests extends WskBasicNode6Tests {
   override val wsk: Wsk = new Wsk
 }
diff --git a/tests/src/test/scala/system/basic/WskCliBasicNode8Tests.scala b/tests/src/test/scala/system/basic/WskCliBasicNode8Tests.scala
new file mode 100644
index 0000000000..a6beb9f336
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskCliBasicNode8Tests.scala
@@ -0,0 +1,28 @@
+/*
+ * 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 system.basic
+
+import common.Wsk
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+class WskCliBasicNode8Tests extends WskBasicNode8Tests {
+  override val wsk: Wsk = new Wsk
+}
diff --git a/tests/src/test/scala/system/basic/WskCliBasicNodeDefaultTests.scala b/tests/src/test/scala/system/basic/WskCliBasicNodeDefaultTests.scala
new file mode 100644
index 0000000000..80f25caba3
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskCliBasicNodeDefaultTests.scala
@@ -0,0 +1,28 @@
+/*
+ * 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 system.basic
+
+import common.Wsk
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+class WskCliBasicNodeDefaultTests extends WskBasicNodeDefaultTests {
+  override val wsk: Wsk = new Wsk
+}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNodeTests.scala b/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
similarity index 94%
rename from tests/src/test/scala/system/basic/WskRestBasicNodeTests.scala
rename to tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
index 7e08469594..ba23bd6670 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicNodeTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
@@ -23,6 +23,6 @@ import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 
 @RunWith(classOf[JUnitRunner])
-class WskRestBasicNodeTests extends WskBasicNodeTests {
+class WskRestBasicNode6Tests extends WskBasicNode6Tests {
   override val wsk: common.rest.WskRest = new WskRest
 }
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
new file mode 100644
index 0000000000..65a4428fc4
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
@@ -0,0 +1,28 @@
+/*
+ * 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 system.basic
+
+import common.rest.WskRest
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+class WskRestBasicNode8Tests extends WskBasicNode8Tests {
+  override val wsk: common.rest.WskRest = new WskRest
+}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala b/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
new file mode 100644
index 0000000000..43b2839ca7
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
@@ -0,0 +1,28 @@
+/*
+ * 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 system.basic
+
+import common.rest.WskRest
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+class WskRestBasicNodeDefaultTests extends WskBasicNodeDefaultTests {
+  override val wsk: common.rest.WskRest = new WskRest
+}
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeNodeTests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
similarity index 92%
rename from tests/src/test/scala/system/basic/WskRestUnicodeNodeTests.scala
rename to tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
index 875135fc06..5ebef6df91 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeNodeTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
@@ -25,7 +25,7 @@ import common.WskTestHelpers
 import common.rest.WskRest
 
 @RunWith(classOf[JUnitRunner])
-class WskRestUnicodeNodeTests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodeNode6Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
 
   override val wsk: common.rest.WskRest = new WskRest
   override lazy val actionKind = "nodejs:6"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
new file mode 100644
index 0000000000..48a2e4dc17
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
@@ -0,0 +1,34 @@
+/*
+ * 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 system.basic
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.JsHelpers
+import common.WskTestHelpers
+import common.rest.WskRest
+
+@RunWith(classOf[JUnitRunner])
+class WskRestUnicodeNode8Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+
+  override val wsk: common.rest.WskRest = new WskRest
+  override lazy val actionKind = "nodejs:8"
+  override lazy val actionSource = "unicode.js"
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services