31dae4caa01e97c4d2ee95b255a0c2106322898d
[nonrtric.git] / test / cr / README.md
1 ## callback receiver - a stub interface to receive callbacks ##
2
3 The mrstub is intended for function tests to simulate a message router.
4 The mrstub exposes the read and write urls, used by the agent, as configured in consul.
5 In addition, request messages can be fed to the mrstub and the response messages can be read by polling.
6
7
8 ### Control interface ###
9
10 The control interface can be used by any test script.
11 The following REST operations are available:
12
13 >Send a message to MR<br>
14 This method puts a request message in the queue for the agent to pick up. The returned correlationId (auto generated by the mrstub) is used when polling for the reposone message of this particular request.<br>
15 ```URI and parameter, (GET): /get-event/<id>```<br><br>
16 ```response: message + 200 or 204```
17
18 >Receive a message response for MR for the included correlation id<br>
19 The method is for polling of messages, returns immediately containing the received response (if any) for the supplied correlationId.<br>
20 ```URI and payload, (PUT or POST): /callbacks/<id> <json array of response messages>```<br><br>
21 ```response: OK 200 or 500 for other errors```
22
23 >Metrics - counters<br>
24 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.
25 ```/counter/received_callbacks``` - The total number of received callbacks<br>
26 ```/counter/fetched_callbacks``` - The total number of fetched callbacks<br>
27 ```/counter/current_messages``` - The current number of callback messages waiting to be fetched<br>
28
29
30 ### Build and start ###
31
32 >Build image<br>
33 ```docker build -t callback-receiver .```
34
35 >Start the image<br>
36 ```docker run -it -p 8090:8090 callback-receiver```
37
38 The script ```crstub-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 agent, 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).
39 ```docker run -it -p 8090:8090 --network nonrtric-docker-net --name callback-receiver callback-receiver```
40
41
42 ### Basic test ###
43
44 Basic test is made with the script ```basic_test.sh``` 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.
45
46 ## License
47
48 Copyright (C) 2020 Nordix Foundation. All rights reserved.
49 Licensed under the Apache License, Version 2.0 (the "License");
50 you may not use this file except in compliance with the License.
51 You may obtain a copy of the License at
52
53      http://www.apache.org/licenses/LICENSE-2.0
54
55 Unless required by applicable law or agreed to in writing, software
56 distributed under the License is distributed on an "AS IS" BASIS,
57 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58 See the License for the specific language governing permissions and
59 limitations under the License.