RIC:1060: Change in PTL
[ric-plt/a1.git] / docs / developer-guide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 Developer Guide
5 ===============
6
7 .. contents::
8    :depth: 3
9    :local:
10
11 Tech Stack
12 ----------
13
14 The A1 Mediator is implemented in Golang.
15
16
17 Running A1 Standalone
18 ---------------------
19
20 The A1 container can be run standalone, which means using an in-memory mock
21 version of SDL and a static route table. The host machine must have the RMR
22 library and the environment must define the variable `prometheus_multiproc_dir`
23 with a value like /tmp.  Alternately, use the following command to run A1 as
24 a Docker container, using a route table mounted as a file from this git
25 repository and exposing the server's HTTP port on the Docker host::
26
27     docker run -e USE_FAKE_SDL=True -p 10000:10000 -v `pwd`:/opt/route [DOCKER_IMAGE_ID_HERE]
28
29 Then test the server with an invocation such as this::
30
31     curl localhost:10000/A1-P/v2/healthcheck
32
33
34 Integration testing
35 -------------------
36
37 This tests A1’s external API with three test receivers. This requires
38 docker, kubernetes and helm.
39
40 Build all the images:
41
42 ::
43
44     docker build  -t a1:latest .
45     cd integration_tests/testxappcode
46     docker build -t delayreceiver:latest -f Dockerfile-delay-receiver .
47     docker build -t queryreceiver:latest -f Dockerfile-query-receiver .
48     docker build -t testreceiver:latest  -f Dockerfile-test-receiver  .
49
50
51 Then, run all the tests from the root (this requires the python packages ``tox``, ``pytest``, and ``tavern``).
52
53 ::
54
55    tox -c tox-integration.ini
56
57 This script:
58
59 #. Deploys 3 helm charts (5 containers) into a local kubernetes installation
60 #. Port forwards a pod ClusterIP to localhost
61 #. Uses “tavern” to run some tests against the server
62 #. Barrages the server with Apache bench
63 #. Tears everything down