Skip to content

Commit 0830562

Browse files
committed
Merge branch 'klpanagi_documentation' into devel (closes #343)
* klpanagi_documentation: Code documentation fixes for rapp_web_services Updates rapp_testing_tools README.md Updates rapp_testing_tools README.md [ci skip] Update web services package documentation [ci skip]
2 parents 135c8dd + 2e7e151 commit 0830562

File tree

50 files changed

+966
-2268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+966
-2268
lines changed

rapp_testing_tools/README.md

Lines changed: 22 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -6,109 +6,60 @@ RAPP Testing Tools
66

77
Testing tools used for RAPP Platform integration tests.
88

9-
All tests use the RappCloud python module,[python-rapp-api](https://github.com/rapp-project/rapp-api/tree/master/python), to communicate with RAPP Platform AI modules.
9+
All tests use the Python implementation of the RAPP Platform API,[rapp-platform-api/python](https://github.com/rapp-project/rapp-api/tree/master/python), to request for .
1010

11+
Test classes inherit from Python unit testing framework, [unittest](https://docs.python.org/2.7/library/unittest.html)
1112

1213
## Tests Directory
1314

14-
By default, this package containes basic, out-of-the-box, integration tests. These tests are located
15+
By default, this package containes out-of-the-box, integration tests. These tests are located
1516
under:
1617

17-
```shell
18+
```bash
1819
$ <rapp_testing_tools_package_path>/scripts/default_tests
1920
```
2021

2122

2223
## Executing Tests
2324

2425
The rapp_run_test.py script is used in order to execute developed tests.
26+
The script accept the following arguments:
2527

26-
##### Execution time arguments:
27-
- [ **-i** ] : Give as input, the test name, to execute.
28+
- [ **-i** ] : Test filepath, to execute. If empty, all tests under the **default_tests** directory will be executed.
2829

29-
```shell
30-
$ ./rapp_run_test_.py -i face_detection_test_1.py
30+
```bash
31+
$ ./rapp_run_test_.py -i default_tests/face_detection_tests.py
3132
```
3233

33-
- [ **-n** ] : Give number of execution of test(s).
34+
- [ **-n** ] : Number of times of test(s) execution.
3435

35-
```shell
36-
$ ./rapp_run_test.py -i face_detection_test_1.py -n 10
36+
```bash
37+
$ ./rapp_run_test.py -i default_tests/face_detection_tests.py -n 10
3738
```
3839

39-
- [ **-t** ] : Run the test in threaded mode which means that multible invocations can be done, simultaneous. Each test execution is handled by a standalone thread.
40+
- [ **-t** ] : Run the test in threaded mode. Multible invocations can be done, simultaneous. Each test execution is handled by a single thread.
4041

41-
```shell
42-
$ ./rapp_run_test.py -i face_detection_test_1.py -n 10 -t
42+
```bash
43+
$ ./rapp_run_test.py -i default_tests/face_detection_tests.py -n 10 -t
4344
```
4445

45-
46-
- [ **-c** ] : Test classes can be used to execute a spesific family of tests. Using test classes all tests, under this class, will be executed. In most cases a test class is named after the relevant RAPP Platform ROS-Package; [ **face-detection, qr-detection, speech-detection, speech-detection-sphinx4, speech-detection-google, ontology, cognitive, tts** ]
47-
48-
```shell
49-
$ ./rapp_run_test.py -c face-detection
50-
```
51-
52-
5346
**Note:**
54-
If no test_name is provided as argument, all tests located under tests paths
55-
are executed!!
56-
57-
There are two ways of executing developed tests:
58-
- Execute directly.
59-
- Execute under the ROS framework.
60-
61-
### Using the python executable, directly.
62-
63-
The below example executes the qr_detection_test_1, five times in sequential
64-
mode.
65-
66-
```shell
67-
$ ./rapp_run_test.py -i qr_detection_test_1.py -n 5
68-
```
69-
70-
### Using ROS framework
71-
72-
The below example executes all tests, once.
73-
74-
```shell
75-
$ rosrun rapp_testing_tools rapp_run_test.py
76-
```
47+
If no test_name is provided as argument, all tests are executed!!
7748

7849

7950
## Developing Tests
8051

81-
A template.py is located under the [default_tests](https://github.com/rapp-project/rapp-platform/tree/master/rapp_testing_tools/scripts/default_tests) directory of the rapp_testing_tools package.
52+
A template_test.py is located under the [default_tests](https://github.com/rapp-project/rapp-platform/tree/master/rapp_testing_tools/scripts/default_tests) directory of the rapp_testing_tools package.
8253

83-
```shell
84-
$ <path_to_rapp_testing_tools_package>/scripts/default_tests
54+
```bash
55+
$ <path_to_rapp_testing_tools_package>/scripts/default_tests/
8556
```
8657

87-
Also several tests have already been developed, located under the default_tests
88-
directory. Those can be used as a reference for developing new tests.
89-
90-
91-
### Where to store developed tests
58+
Also, several tests have already been developed, located under the default_tests
59+
directory. Those can be used as a reference/examples for developing new tests.
9260

93-
By default, developed tests are stored under the scripts/default_tests directory.
94-
95-
To define external tests directories, developers have to append that path
96-
into the params.yaml configuration file. This file is located under the config/
97-
directory in this package.
98-
99-
Lets say for example that you want to store tests under:
100-
101-
```shell
102-
$ ${HOME}/rapp_integration_tests_external
103-
```
104-
105-
You can extend the path directories used by the test-engine to search under for python test source files. Just write down custom directory paths into the [params.yaml]([params.yaml](https://github.com/rapp-project/rapp-platform/blob/master/rapp_testing_tools/config/params.yaml)) file.
106-
107-
```yaml
108-
tests_path:
109-
- '~/rapp_integration_tests_external'
110-
```
11161

62+
A Section in the [Wiki](https://github.com/rapp-project/rapp-platform/wiki/How-to-implement-an-integration-test%3F) exists that guides through developing integration tests for the RAPP Platform.
11263

11364
## Contributors
11465

@@ -117,4 +68,5 @@ tests_path:
11768

11869

11970
## Contact
71+
12072
- Konstantinos Panayiotou, [[email protected]]

rapp_web_services/.jshintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"esversion": 6
3+
}

rapp_web_services/Gruntfile.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,32 @@ module.exports = function(grunt) {
77
// Task configuration.
88
jsdoc: {
99
services: {
10-
src: ['services/*.js', 'services/README.md'],
10+
src: [
11+
'services/**/svc.js',
12+
'!services/templates/*.js',
13+
'services/README.md'
14+
],
1115
options: {
1216
destination: 'doc/services',
1317
template: "node_modules/ink-docstrap/template",
1418
configure: "config/jsdoc/jsdoc-services.conf.json"
1519
}
1620
},
1721
commons: {
18-
src: ['modules/common/*.js', 'modules/common/README.md'],
22+
src: [
23+
'src/**/*.js'
24+
],
1925
options: {
2026
destination: 'doc/commons',
2127
template: "node_modules/ink-docstrap/template",
2228
configure: "config/jsdoc/jsdoc-commons.conf.json"
2329
}
2430
},
2531
templates: {
26-
src: ['services/templates/*.js', 'services/templates/README.md'],
32+
src: [
33+
'services/templates/*.js',
34+
'services/templates/README.md'
35+
],
2736
options: {
2837
destination: 'doc/templates',
2938
template: "node_modules/ink-docstrap/template",

rapp_web_services/README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,30 @@ Currently, HOP-Server is configured to act as an HTTP/HTTPS Web Server (**Does n
2929

3030
On a fresh clone you will first need to install required dependencies:
3131

32-
```shell
32+
```bash
3333
$ npm install
3434
```
3535

3636
For initiating HOP Web Server (and HOP Web Services), a grunt task exists:
3737

38-
```shell
38+
```bash
3939
$ grunt init-hop
4040
```
4141

4242
Or execute the **run.sh** script directly:
4343

44-
```shell
44+
```bash
4545
$ ./run.sh
4646
```
4747

4848

49+
We also provide [pm2](https://github.com/Unitech/pm2) configuration file for the web server to launch. If you have pm2 installed on the machine hosting the RAPP Platform, simply execute:
50+
51+
```bash
52+
pm2 start server.yaml
53+
```
54+
55+
4956
**Note**: Do not change HOP Server configuration parameters, unless you know what you are doing!!
5057

5158

@@ -69,32 +76,32 @@ This package's source-code is documented using the [JSDoc](https://github.com/js
6976

7077
Generate documentation for HOP Web Services ONLY!:
7178

72-
```shell
79+
```bash
7380
$ grunt jsdoc:services
7481
```
7582

7683
Generate documentation for service-creation-templates ONLY!:
7784

78-
```shell
85+
```bash
7986
$ grunt jsdoc:templates
8087
```
8188

8289
Generate documentation for commons ONLY!:
8390

84-
```shell
91+
```bash
8592
$ grunt jsdoc:commons
8693
```
8794

8895
Gererate documentation for ALL:
8996

90-
```shell
97+
```bash
9198
$ grunt jsdoc
9299
```
93100

94101

95102
Generated doc files are stored under the **doc/** directory, or under:
96103

97-
```shell
104+
```bash
98105
$ ${HOME}/rapp_platform_files/
99106
```
100107

rapp_web_services/init.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@ var path = require('path');
3434

3535
const ENV = require( path.join(__dirname, 'env.js') );
3636
const PKG_DIR = ENV.PATHS.PKG_DIR;
37-
const INCLUDE_DIR = ENV.PATHS.INCLUDE_DIR;
37+
const INCLUDES = ENV.PATHS.INCLUDE_DIR;
3838
const SERVICES_CACHE_DIR = ENV.PATHS.SERVICES_CACHE_DIR;
3939
const SERVER_CACHE_DIR = ENV.PATHS.SERVER_CACHE_DIR;
4040
/* --------------------------------------------------------------- */
4141

42-
var hostname = hop.hostname;
43-
var port = hop.port;
42+
const hostname = hop.hostname;
43+
const port = hop.port;
4444
var workers = require('./config/services/workers.json');
4545

46-
var Fs = require( path.join(INCLUDE_DIR, 'common', 'fileUtils.js') );
47-
var logger = new (require( path.join(INCLUDE_DIR, 'common', 'logger.js') ))(
48-
{console: true, file: false, ns: ''});
46+
var Fs = require( path.join(INCLUDES, 'common', 'fileUtils.js') );
47+
const logger = new (require( path.join(INCLUDES, 'common', 'logger.js') ))(
48+
{debug: false, file: false, ns: ''});
4949
if( createCacheDir(SERVICES_CACHE_DIR) ){
5050
logger.info('...Services caching in ' + SERVICES_CACHE_DIR);
51-
}else{
51+
} else {
5252
logger.error('Failed to create cache directories: ' + SERVICES_CACHE_DIR);
5353
}
5454

55-
var srvHandler = new ( require( path.join(INCLUDE_DIR, 'servicehandler',
56-
'service_handler.js') ))({logger: logger});
55+
var core = require(path.join(INCLUDES, 'serverCore.js'));
56+
core.applyLogger(logger);
5757

5858

5959
launchWorkers(workers);
@@ -62,7 +62,7 @@ launchWorkers(workers);
6262
/** ---------------------- [Util functions] --------------------- */
6363
/** ------------------------------------------------------------- */
6464

65-
function createCacheDir( dir ){
65+
function createCacheDir(dir){
6666
if( dir === undefined || dir === '' )
6767
{
6868
return false;
@@ -74,14 +74,14 @@ function createCacheDir( dir ){
7474
}
7575

7676

77-
function launchWorkers( workers ){
77+
function launchWorkers(workers) {
7878
for(var w in workers){
7979
if( (workers[w].launch === true) || ( workers[w].launch) === undefined ){
8080
var worker = {
8181
file: path.join(__dirname, workers[w].path),
8282
name: w,
8383
};
84-
srvHandler.registerWorker( worker );
84+
core.registerWorker(worker);
8585
}
8686
}
8787
}
@@ -95,7 +95,7 @@ process.stdin.resume();
9595
process.on('SIGTERM',
9696
function(){
9797
console.log('Exiting with code: ');
98-
srvHandler.terminate();
98+
core.terminate();
9999
}
100100
);
101101

rapp_web_services/services/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Otherwise, use *application/x-www-form-urlencoded*.
8181
All data, except files, have to be be send under a field named **json**.
8282
In case of using *application/x-www-form-urlencoded* type this will look like:
8383

84-
```
84+
```http
8585
POST /hop/ontology_subclasses_of HTTP/1.1
8686
Connection: keep-alive
8787
...
@@ -92,7 +92,7 @@ json=%7B%22query%22%3A+%22Oven%22%7D
9292

9393
and in case of multipart/form-data:
9494

95-
```
95+
```http
9696
POST /hop/face_detection HTTP/1.1
9797
Connection: keep-alive
9898
...
@@ -1174,7 +1174,7 @@ where *story* object is:
11741174

11751175
Developed tests and testing tools are currently located under the [rapp_testing_tools](https://github.com/rapp-project/rapp-platform/tree/master/rapp_testing_tools) package:
11761176

1177-
```shell
1177+
```bash
11781178
$ <path_to_rapp_platform_repo>/rapp_testing_tools/
11791179
```
11801180

0 commit comments

Comments
 (0)