1 ## mrstub - stub interface to interact with the policy agent over Dmaap ##
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.
8 ### Control interface ###
10 The control interface can be used by any test script.
11 The following REST operations are available:
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 parameters (GET): /send-request?operation=<GET|PUT|POST|DELETE>&url=<url>```<br><br>
16 ```response: <correlation-id> (http 200) or 400 for parameter error or 500 for other errors```
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 parameter, (GET): /receive-response?correlationId=<correlationid>```<br><br>
21 ```response: <json-array of 1 response> 200 or empty 204 or other errors 500```
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/requests_submitted``` - The total number of requests sent from the application<br>
26 ```/counter/requests_fetched``` - The total number of requests picked up by the agent<br>
27 ```/counter/responses_submitted``` - The total number of responses written by the agent<br>
28 ```/counter/responses_fetched``` - The total number of responses picked up by the application<br>
29 ```/counter/current_requests``` - The current number of requests waiting to be picked up by the agent<br>
30 ```/counter/current_responses``` - The current number of responses waiting to be picked up by the application<br>
33 ### Build and start ###
36 ```docker build -t mrstub .```
39 ```docker run -it -p 3905:3905 mrstub```
41 The script ```mrstub-build-start.sh``` do the above two steps in one go. This starts the stub container in stand-alone mode for basic test.<br>If the mrstub 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 the same as configured in consul for the read and write streams).
42 ```docker run -it -p 3905:3905 --network nonrtric-docker-net --name message-router mrstub```
47 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 ```mrstub-build-start.sh``` to start the mrstub in a container first.