mrutkows commented on code in PR #227:
URL: 
https://github.com/apache/openwhisk-runtime-nodejs/pull/227#discussion_r1020331542


##########
tests/src/test/standalone/README.md:
##########
@@ -0,0 +1,88 @@
+<!--
+#
+# 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.
+#
+-->
+
+# Tests for OpenWhisk NodeJS Runtime as Standalone Container
+## Building the Runtime Container
+After a runtime container is built, one should be able to run it as a 
standalone container.
+The following example shows how to generate a Docker image for the Node.js 18 
runtime version and test the standalone runtime using the `curl` command. 
Testing other runtime versions can be done in the same manner.
+
+- Run the `distDocker` command to generate the local Docker image for the 
desired runtime version.

Review Comment:
   There is a typo here where the list (bullet) contains a code section 
(completion) but not a start



##########
tests/src/test/standalone/README.md:
##########
@@ -0,0 +1,88 @@
+<!--
+#
+# 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.
+#
+-->
+
+# Tests for OpenWhisk NodeJS Runtime as Standalone Container
+## Building the Runtime Container
+After a runtime container is built, one should be able to run it as a 
standalone container.
+The following example shows how to generate a Docker image for the Node.js 18 
runtime version and test the standalone runtime using the `curl` command. 
Testing other runtime versions can be done in the same manner.
+
+- Run the `distDocker` command to generate the local Docker image for the 
desired runtime version.
+```
+./gradlew core:nodejs18Action:distDocker
+```
+This will return the following runtime image with the name 
`action-nodejs-v18`, which should be listed after using the `docker images`
+
+## Running the Container
+For the purpose of the test. We are going to start the container that has a 
web service running inside it built using Node/Express. In order to access this 
service within the container from the outside, as we are about to do using 
`curl`, port mapping needs to be done next. As a result, we can now access the 
web service inside docker by first reaching an IP port on `localhost`, which 
subsequently forwards the request to the docker container's designated port.
+In our example, the `Action` container exposes `port 8080` (see the Dockerfile 
for the associated Docker image), thus we publish the container's `port 8080` 
to the `localhost` (here, `port 3008` on `localhost` is chosen arbitrarily, as 
long as the port is not already assigned for something else):
+```
+docker run --publish 3008:8080 -i -t action-nodejs-v18:latest
+```
+A simpler way is to map `port 80` on `localhost` to the container's `port 
8080`. The port number assigned to the HTTP protocol is `80` Since we will be 
sending actions against the runtime using HTTP, using this number will allow us 
to omit the port in the request later. Without loss of generality, the 
following examples will use the arbitrarily chosen `port 3008`
+
+## Testing
+This example has prepared a `helloworld.json` file to post using `curl`.
+```json
+{
+  "value": {
+    "name" : "nodejs-helloworld",
+    "main" : "main",
+    "binary": false,
+    "code" : "function main() {return {payload: 'Hello World!'};}"
+  }
+}
+```
+The json file contains a simple JavaScript function, which is the actual 
payload.
+
+### Initialze the Runtime
+Before issuing the action against the runtime, we first initialize the 
function with by invoking the ```/init``` endpoint.

Review Comment:
   ... "with the `helloworld.json` payload"



##########
docs/users/standalone/README.md:
##########
@@ -0,0 +1,174 @@
+<!--
+#
+# 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.
+#
+-->
+
+# Tests for OpenWhisk NodeJS Runtime as Standalone Container
+This README walks you through how to build, customise and test Apache 
OpenWhisk Node.js runtime images.
+## Pre-requisites
+- [Gradle](https://gradle.org/)
+- [Docker](https://www.docker.com/)
+- [curl](https://curl.se/)
+## Building the Runtime Container
+Choose a NodeJS version. All build files reside inside 
`core/nodejsActionBase`. If you take a look into 
`core/nodejsActionBase/Dockerfile` you’ll see a line that looks like:
+```
+FROM node:lts-stretch
+```
+This will use the latest NodeJS version. But we want to be more specific. Now 
if you look into each of the Dockerfile within `core/nodejs14Action`, 
`core/nodejs16Action`, `core/nodejs18Action`, you’ll notice different NodeJS 
versions. Let’s go ahead with the 18 version. We are going to use this version 
throughout the README, for the others, you merely have to modify the version 
number.
+
+Gradle will a create `build` folder that will contain all the necessary files 
to build our NodeJS container. Next, it will copy the NodeJS application 
(server used to implement the [action 
interface](https://github.com/apache/openwhisk/blob/master/docs/actions-new.md#action-interface))
 as well as the target Dockerfile with the NodeJS version 18.
+
+What Gradle does is equivalent to running these commands
+```
+mkdir build
+cp -r core/nodejsActionBase/* build
+cp core/nodejs18Action/Dockerfile build
+```
+
+Now, run the `distDocker` command to generate a local Docker image for the 
chosen runtime version. (Make sure docker daemon is running)
+
+```
+./gradlew core:nodejs18Action:distDocker
+```
+
+This will return the following runtime image with the name 
`action-nodejs-v18`. Since a docker image is created, you can check the `IMAGE 
ID` for `nodejs-action-v18`
+```
+docker images
+```
+## Running the Container
+For the testing purpose, we are going to start the container locally that has 
Node.js app server inside. The Apache OpenWhisk platform uses this server to 
inject action code into the runtime and fire invocation requests. In order to 
access this service within the container from the outside, as we are about to 
do using `curl`, port mapping needs to be done next. As a result, we can now 
access the web service inside docker by first reaching an IP port on 
`localhost`, which subsequently forwards the request to the docker container's 
designated port.
+In our example, the `Action` container exposes `port 8080` (see the Dockerfile 
for the associated Docker image), thus we publish the container's `port 8080` 
to the `localhost` (here, `port 3008` on `localhost` is chosen arbitrarily, as 
long as the port is not already used for something else):
+```
+docker run --publish 3008:8080 --name=bloom_whisker -i -t 
action-nodejs-v18:latest
+```
+A simpler way is to map `port 80` on `localhost` to the container's `port 
8080`. The port number assigned to the HTTP protocol is `80`. Since we will be 
sending actions against the runtime using HTTP, using this number will allow us 
to omit the port in the request later. Oftentimes, `port 80` could already be 
occupied by another process. Without loss of generality, the following examples 
will use the arbitrarily chosen `port 3008`.
+
+Lists all running containers
+```
+docker ps
+```
+or
+```
+docker ps -a
+```
+You should see a container named `bloom_whisker` being run.
+
+## Create your function
+A container can only hold one function. This first example prepared a 
`js-init.json` file which contains the function.
+```json
+{
+  "value": {
+    "name" : "nodejs-helloworld",
+    "main" : "main",
+    "binary": false,
+    "code" : "function main() {return {payload: 'Hello World!'};}"
+  }
+}
+```
+The json file contains a simple JavaScript (the target runtime language) 
function, which is the actual payload.
+
+## Initialze the Runtime
+Before issuing the action against the runtime, we first initialize the 
function with by invoking the ```/init``` endpoint.
+```
+curl -H "Content-Type:application/json" -X POST --data 
'@/$FILEPATH/js-init.json' http://localhost:3008/init

Review Comment:
   Please eliminate the $FILEPATH as it adds complexity to each example.  
Instead, formulate examples using the actual test files relative to where a 
developer's clone of the repo. would be.



##########
tests/src/test/standalone/README.md:
##########
@@ -0,0 +1,88 @@
+<!--
+#
+# 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.
+#
+-->
+
+# Tests for OpenWhisk NodeJS Runtime as Standalone Container
+## Building the Runtime Container
+After a runtime container is built, one should be able to run it as a 
standalone container.
+The following example shows how to generate a Docker image for the Node.js 18 
runtime version and test the standalone runtime using the `curl` command. 
Testing other runtime versions can be done in the same manner.
+
+- Run the `distDocker` command to generate the local Docker image for the 
desired runtime version.
+```
+./gradlew core:nodejs18Action:distDocker
+```
+This will return the following runtime image with the name 
`action-nodejs-v18`, which should be listed after using the `docker images`
+
+## Running the Container
+For the purpose of the test. We are going to start the container that has a 
web service running inside it built using Node/Express. In order to access this 
service within the container from the outside, as we are about to do using 
`curl`, port mapping needs to be done next. As a result, we can now access the 
web service inside docker by first reaching an IP port on `localhost`, which 
subsequently forwards the request to the docker container's designated port.
+In our example, the `Action` container exposes `port 8080` (see the Dockerfile 
for the associated Docker image), thus we publish the container's `port 8080` 
to the `localhost` (here, `port 3008` on `localhost` is chosen arbitrarily, as 
long as the port is not already assigned for something else):
+```
+docker run --publish 3008:8080 -i -t action-nodejs-v18:latest
+```
+A simpler way is to map `port 80` on `localhost` to the container's `port 
8080`. The port number assigned to the HTTP protocol is `80` Since we will be 
sending actions against the runtime using HTTP, using this number will allow us 
to omit the port in the request later. Without loss of generality, the 
following examples will use the arbitrarily chosen `port 3008`
+
+## Testing
+This example has prepared a `helloworld.json` file to post using `curl`.
+```json
+{
+  "value": {
+    "name" : "nodejs-helloworld",
+    "main" : "main",
+    "binary": false,
+    "code" : "function main() {return {payload: 'Hello World!'};}"
+  }
+}
+```
+The json file contains a simple JavaScript function, which is the actual 
payload.
+
+### Initialze the Runtime
+Before issuing the action against the runtime, we first initialize the 
function with by invoking the ```/init``` endpoint.
+```
+curl -H "Content-Type:application/json" -X POST --data 
'@openwhisk-runtime-nodejs/tests/src/test/standalone/helloworld/helloworld.json'
 http://localhost:3008/init
+
+{"OK":true}
+```
+being the expected response.
+
+As mentioned above, if `port 80` on `localhost` was used, the command could 
simply be ```

Review Comment:
   The "```" needs to start on a newline and be sep. by a an empty line.  In 
addition, it is good practice to annotate the type of "code".  For example 
"```json"  or "```bash".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to