a745529d9592255df159d2f60aaff117ebb512c5
[nonrtric.git] / test / cr / README.md
1 # callback receiver - a stub interface to receive callbacks
2
3 The callback receiver is intended for function tests to simulate a RAPP.
4 The callback receiver exposes the read and write urls, used by the a1pms, as configured in service.
5 The callback receiver receives notifications from A1PMS when synchronization happens between A1PMS and RICs. However, the callback receiver can be uses to receive any json payload from any source.
6
7 ## Ports and certificates
8
9 The CR normally opens the port 8090 for http. If a certificate and a key are provided the simulator will also open port 8091 for https.
10 The certificate and key shall be placed in the same dir and the dir shall be mounted to /usr/src/app/cert in the container.
11
12 | Port     | Protocol |
13 | -------- | ----- |
14 | 8090     | http  |
15 | 8091     | https |
16
17 The dir cert contains a self-signed cert. Use the script generate_cert_and_key.sh to generate a new certificate and key. The password of the certificate must be set 'test'.
18 The same urls are available on both the http port 8090 and the https port 8091. If using curl and https, the flag -k shall be given to make curl ignore checking the certificate.
19
20 ### Control interface
21
22 The control interface can be used by any test script.
23 The following REST operations are available:
24
25 >Send a message to CR<br>
26 This method puts a request message from A1PMS to notify that sychronization between A1PMS and certain RIC happens.<br>
27 ```URI and payload, (PUT or POST): /callbacks/<id> <json messages>```<br>
28 ```response: OK 200 or 500 for other errors```
29
30 >Fetch one message for an id from CR<br>
31 This method fetches the oldes message for an id, and removes the message.<br>
32 ```URI and payload, (GET): /get-event/<id>```<br>
33 ```response:  <json messages> 200 or 500 for other errors```
34
35 >Fetch all messages for an id from CR<br>
36 This method fetches all message in an array for an id, and removes all messages.<br>
37 ```URI and payload, (GET): /get-all-events/<id>```<br>
38 ```response:  <json array of json messages> 200 or 500 for other errors```
39
40 >Dump all currently wating callback messages in CR<br>
41 This method fetches all message in an array for an id. Messages are left intact in the CR.<br>
42 ```URI and payload, (GET): /db```<br>
43 ```response:  <json> 200```
44
45 >Metrics - counters<br>
46 There are a number of counters that can be read to monitor the message processing. Do a http GET on any of the current counters and an integer value will be returned with http response code 200.
47 ```/counter/received_callbacks``` - The total number of received callbacks<br>
48 ```/counter/fetched_callbacks``` - The total number of fetched callbacks<br>
49 ```/counter/current_messages``` - The current number of callback messages waiting to be fetched<br>
50 All counters also support the query parameter "id" to fetch counter for one individual id, eg ```/counter/current_messages?id=my-id```
51 An additional counter is available to log remote hosts calling the server
52 ```/counter/remote_hosts``` - Lists all unique ip/host name that has sent messages on the callback endpoint<br>
53
54 ### Build and start
55
56 >Build image<br>
57 ```docker build --build-arg NEXUS_PROXY_REPO=nexus3.onap.org:10001/ -t callback-receiver .```
58
59 >Start the image on both http and https<br>
60 ```docker run --rm -it -p 8090:8090 -p 8091:8091 callback-receiver```
61
62 It will listen to http 8090 port and https 8091 port(using default certificates) at the same time.
63
64 By default, this image has default certificates under /usr/src/app/cert
65 file "cert.crt" is the certificate file
66 file "key.crt" is the key file
67 file "generate_cert_and_key.sh" is a shell script to generate certificate and key
68 file "pass" stores the password when you run the shell script
69
70 This certificates/key can be overriden by mounting a volume when using "docker run" or "docker-compose"
71 In 'docker run', use field:<br>
72 >```-v "$PWD/certificate:/usr/src/app/cert"```<br/>
73
74 eg:
75 >```docker run --rm -it -p 8090:8090 -p 8091:8091 -v "/PATH_TO_CERT/cert:/usr/src/app/cert" callback-receiver```
76
77 In 'docker-compose.yml', use field:
78 >```volumes: - ./certificate:/usr/src/app/cert:ro```
79
80 The script ```cr-build-start.sh``` do the above two steps in one go. This starts the callback-receiver container in stand-alone mode for basic test.<br>If the callback-receiver should be executed manually with the a1pms, replace docker run with this command to connect to the docker network with the correct service name (--name shall be aligned with the other components, i.e. the host named given in all callback urls).
81 >```docker run --rm -it -p 8090:8090 -p 8091:8091 --network nonrtric-docker-net --name callback-receiver callback-receiver```
82
83 >Start the image on http only<br>
84 ```docker run --rm -it -p 8090:8090 callback-receiver```
85
86 ### Basic test
87
88 Basic test is made with the script ```basic_test.sh nonsecure|secure``` which tests all the available urls with a subset of the possible operations. Use the script ```cr-build-start.sh``` to start the callback-receiver in a container first.
89
90 ## License
91
92 Copyright (C) 2020 Nordix Foundation. All rights reserved.
93 Licensed under the Apache License, Version 2.0 (the "License");
94 you may not use this file except in compliance with the License.
95 You may obtain a copy of the License at
96
97      http://www.apache.org/licenses/LICENSE-2.0
98
99 Unless required by applicable law or agreed to in writing, software
100 distributed under the License is distributed on an "AS IS" BASIS,
101 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
102 See the License for the specific language governing permissions and
103 limitations under the License.