X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=test%2Fmrstub%2FREADME.md;h=171b4f43fcf2a09aae3fdb9ae8c8aed00f60ac64;hb=refs%2Fchanges%2F50%2F6250%2F2;hp=6a69930a3f9b7d2172bc457dd187380db2f2d6c4;hpb=acdd3f361ff7af58b0276789cc5148180a06e552;p=nonrtric.git
diff --git a/test/mrstub/README.md b/test/mrstub/README.md
index 6a69930a..171b4f43 100644
--- a/test/mrstub/README.md
+++ b/test/mrstub/README.md
@@ -1,11 +1,37 @@
-## mrstub - stub interface to interact with the policy agent over Dmaap ##
+# mrstub - stub interface to interact with the policy agent over Dmaap
The mrstub is intended for function tests to simulate a message router.
The mrstub exposes the read and write urls, used by the agent, as configured in consul.
In addition, request messages can be fed to the mrstub and the response messages can be read by polling.
+## Ports and certificates
-### Control interface ###
+The MR normally opens the port 3905 for http. If a certificate and a key are provided the simulator will also open port 3906 for https.
+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.
+
+| Port | Protocol |
+| -------- | ----- |
+| 3905 | http |
+| 3906 | https |
+
+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'.
+The same urls are availables on both the http port 3905 and the https port 3906. If using curl and https, the flag -k shall be given to make curl ignore checking the certificate.
+
+### Message Router interface
+
+Messages from the MR can be read using this url using http(s) GET:
+```events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=&limit=```
+Both 'timeout' and 'limit' are optional.
+|Parameter|Description|
+|---------|--------------------|
+|limit|Optional parameter to limit the maximum number of messages to return. A value 0 < limit < 4096. If limit is not given, the limit is set to 4096.|
+|timeout|Optional parameter to control the max length of the poll. A value in milliseconds 0 < timeout < 60000. If timeout is not given, the timeout is 10 seconds. If not messages are available when the poll starts, the poll will end as soon as there is at least one message available|
+
+Messages to the MR can be written using this url http(s) POST/PUT:
+```/events/A1-POLICY-AGENT-WRITE```
+One or more messages can be written in the same operation.
+
+### Control interface
The control interface can be used by any test script.
The following REST operations are available:
@@ -29,19 +55,54 @@ There are a number of counters that can be read to monitor the message processin
```/counter/current_requests``` - The current number of requests waiting to be picked up by the agent
```/counter/current_responses``` - The current number of responses waiting to be picked up by the application
-
-### Build and start ###
+### Build and start
>Build image
-```docker build -t mrstub .```
+```docker build --build-arg NEXUS_PROXY_REPO=nexus3.onap.org:10001/ -t mrstub .```
+
+>Start the image on http only
+```docker run --rm -it -p 3905:3905 mrstub```
+
+>Start the image on http and https
+By default, this image has default certificates under /usr/src/app/cert
+file "cert.crt" is the certificate file
+file "key.crt" is the key file
+file "generate_cert_and_key.sh" is a shell script to generate certificate and key
+file "pass" stores the password when you run the shell script
+
+>Start the a1-interface container without specifing external certificates:
+```docker run --rm -it -p 3905:3905 -p 3906:3906 mrstub```
+
+It will listen to http 3905 port and https 3906 port(using default certificates) at the same time.
+
+This certificates/key can be overriden by mounting a volume when using "docker run" or "docker-compose"
+In 'docker run', use field:
+>```-v "$PWD/certificate:/usr/src/app/cert"```
+
+eg:
+>```docker run --rm -it -p 3905:3905 -p 3906:3906 -v "/PATH_TO_CERT/cert:/usr/src/app/cert" mrstub```
+
+In 'docker-compose.yml', use field:
+>```volumes: - ./certificate:/usr/src/app/cert:ro```
+
+The script ```mrstub-build-start.sh``` do the build and docker run in one go. This starts the stub container in stand-alone mode for basic test.
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).
+>```docker run --rm -it -p 3905:3905 --network nonrtric-docker-net --name message-router mrstub```
+
+### Basic test
->Start the image
-```docker run -it -p 3905:3905 mrstub```
+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. Choose nonsecure for http and secure for https. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first.
-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.
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).
-```docker run -it -p 3905:3905 --network nonrtric-docker-net --name message-router mrstub```
+## License
+Copyright (C) 2020 Nordix Foundation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
-### Basic test ###
+ http://www.apache.org/licenses/LICENSE-2.0
-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.
\ No newline at end of file
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.