You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,3 +114,4 @@ This will return the following runtime images with the following names: `action-
114
114
```
115
115
./gradlew :tests:test
116
116
```
117
+
An update about the details of verifying a standalone container can be found [here](https://github.com/apache/openwhisk-runtime-nodejs/pull/227/files#diff-c115bfeccd5f4a2e984d66e08ad3b677350baecacc248bc20d7585c2b6fe11e8)
Copy file name to clipboardExpand all lines: tests/src/test/standalone/README.md
+38-6Lines changed: 38 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,32 +26,64 @@ The following example shows how to generate a Docker image for the Node.js 18 ru
26
26
```
27
27
./gradlew core:nodejs18Action:distDocker
28
28
```
29
-
This will return the following runtime image with the name `action-nodejs-v18`
29
+
This will return the following runtime image with the name `action-nodejs-v18`, which should be listed after using the `docker images`
30
30
31
31
## Running the Container
32
-
For the purpose of the test. We are going to access the the runner container via `localhost`.
33
-
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`:
32
+
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.
33
+
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):
34
34
```
35
35
docker run --publish 3008:8080 -i -t action-nodejs-v18:latest
36
36
```
37
+
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`
37
38
38
39
## Testing
39
40
This example has prepared a `helloworld.json` file to post using `curl`.
The json file contains a simple JavaScript function, which is the actual payload.
40
52
41
53
### Initialze the Runtime
42
-
Initialize the runtime with by invoking the ```/init``` endpoint.
54
+
Before issuing the action against the runtime, we first initialize the function with by invoking the ```/init``` endpoint.
43
55
```
44
56
curl -H "Content-Type:application/json" -X POST --data '@openwhisk-runtime-nodejs/tests/src/test/standalone/helloworld/helloworld.json' http://localhost:3008/init
45
57
46
58
{"OK":true}
47
59
```
60
+
being the expected response.
61
+
62
+
As mentioned above, if `port 80` on `localhost` was used, the command could simply be
63
+
```
64
+
curl -H "Content-Type:application/json" -X POST --data '@openwhisk-runtime-nodejs/tests/src/test/standalone/helloworld/helloworld.json' http://localhost/init
65
+
```
48
66
49
67
#### Run the function
50
68
51
-
Execute the function using the ```/run``` endpoint.
69
+
Invoke the function using the ```/run``` endpoint.
52
70
53
71
```
54
72
curl -H ""Content-Type:application/json" -X POST --data '@openwhisk-runtime-nodejs/tests/src/test/standalone/helloworld/helloworld.json' http://localhost:3008/run
73
+
```
55
74
75
+
The JavaScript function in this example is one without arguments. Using the same json file as during initialization won't be a problem. Strictly speaking, we should have provided another json file with the arguments. In our case, it should simply be
0 commit comments