blob: 97c18a243216905c0ba05de25ffaabd3f2e76cf6 [file] [log] [blame]
Tommy Carpenter42493982019-11-06 07:27:16 -05001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
Tommy Carpentercc2250a2019-05-30 15:06:37 -04003
Lott, Christopher (cl778h)14d016e2020-04-27 10:45:47 -04004A1 Developer Guide
5==================
Tommy Carpenter42493982019-11-06 07:27:16 -05006
7.. contents::
8 :depth: 3
9 :local:
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040010
11Tech Stack
Tommy Carpenter42493982019-11-06 07:27:16 -050012----------
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040013
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040014The A1 Mediator is implemented in Python, currently 3.8, and depends on these third-party packages
15and technologies:
16
17- OpenAPI3
18- Connexion
19- Flask with Gevent serving
20- Swagger
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040021
Lott, Christopher (cl778h)14d016e2020-04-27 10:45:47 -040022Version bumping A1
23------------------
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040024
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040025This project follows semver. When the version string changes, these files must be updated:
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040026
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040027#. ``setup.py``
28#. ``container-tag.yaml``
29#. ``integration_tests/a1mediator/Chart.yaml``
30#. ``docs/release-notes.rst``
31#. ``a1/openapi.yaml`` But note this is an API version, not a software version; there's no need to bump on non-API changes.
32#. And over in the ric-plt/ric-dep repo that contains the A1 Mediator helm chart, files ``values.yaml`` and ``Chart.yaml``.
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040033
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040034It's convenient to use the Python utility `bumpversion` to maintain the first three items.
35After setup (``pip install bumpversion``) you can change the patch version like this::
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040036
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040037 bumpversion --verbose patch
Tommy Carpenter810fcb72019-06-05 12:42:52 -040038
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040039Or change the minor version like this::
Tommy Carpenter18dcbc32019-06-04 10:20:30 -040040
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040041 bumpversion --verbose minor
Tommy Carpenter5ad8f032019-05-30 14:33:21 -040042
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040043After the `bumpversion` utility has modified the files, update the release notes then commit.
Tommy Carpenter971c91c2019-06-12 09:25:48 -040044
Lott, Christopher (cl778h)d5024702019-08-20 15:22:45 -040045
Lott, Christopher (cl778h)14d016e2020-04-27 10:45:47 -040046Version bumping RMR
Tommy Carpenter78ba2732020-02-07 14:06:20 -050047-------------------
Lott, Christopher (cl778h)14d016e2020-04-27 10:45:47 -040048
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040049A1 (Dockerfile), Dockerfile-Unit-Test, and all three integration test receivers use an Alpine
50base image and install RMR from a base builder image. Must update and rebuild all 5 containers
51in the A1 repo (or just A1 itself for production usage).
Tommy Carpenter102b8952020-03-20 10:02:46 -040052
Lott, Christopher (cl778h)d26734f2020-04-27 17:25:05 -040053In addition these items in this repo must be kept in sync:
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040054
55#. ``rmr-version.yaml`` controls what rmr gets installed for unit testing in Jenkins
56#. ``integration_tests/install_rmr.sh`` is a useful script for a variety of local testing.
Lott, Christopher (cl778h)d5024702019-08-20 15:22:45 -040057
Lott, Christopher (cl778h)14d016e2020-04-27 10:45:47 -040058Version bumping Python
59----------------------
60
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040061If you want to update the version of python; for example this was recently done to move
62from 3.7 to 3.8, update these files:
Tommy Carpenter8bcc51a2019-10-21 16:07:31 -040063
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -040064#. ``Dockerfile``
65#. ``Dockerfile-Unit-Test``
66#. ``tox.ini``
Lott, Christopher (cl778h)d5024702019-08-20 15:22:45 -040067
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -040068Unit Testing
Tommy Carpenter42493982019-11-06 07:27:16 -050069------------
Lott, Christopher (cl778h)14d016e2020-04-27 10:45:47 -040070
Lott, Christopher (cl778h)fe30c172020-04-29 15:23:28 -040071Running the unit tests requires the python packages ``tox`` and ``pytest``.
72
73The RMR library is also required during unit tests. If running directly from tox
74(outside a Docker container), install RMR using the script in the integration_tests
75directory: ``install_rmr.sh``.
76
77Upon completion, view the test coverage like this:
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -040078
79::
80
81 tox
82 open htmlcov/index.html
83
Lott, Christopher (cl778h)d26734f2020-04-27 17:25:05 -040084Alternatively, you can run the unit tests in Docker (this is somewhat
85less nice because you don't get the pretty HTML)
Tommy Carpenter296f8de2019-08-07 11:38:44 -040086
87::
88
Lott, Christopher (cl778h)fe30c172020-04-29 15:23:28 -040089 docker build --no-cache -f Dockerfile-Unit-Test .
Tommy Carpenter296f8de2019-08-07 11:38:44 -040090
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -040091Integration testing
Tommy Carpenter42493982019-11-06 07:27:16 -050092-------------------
Lott, Christopher (cl778h)14d016e2020-04-27 10:45:47 -040093
Lott, Christopher (cl778h)d26734f2020-04-27 17:25:05 -040094This tests A1s external API with three test receivers. This requires
95docker, kubernetes and helm.
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -040096
Lott, Christopher (cl778h)75d92b72020-04-24 11:52:42 -040097Build all the images:
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -040098
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -040099::
100
Lott, Christopher (cl778h)75d92b72020-04-24 11:52:42 -0400101 docker build -t a1:latest .
102 cd integration_tests/testxappcode
103 docker build -t delayreceiver:latest -f Dockerfile-delay-receiver .
104 docker build -t queryreceiver:latest -f Dockerfile-query-receiver .
105 docker build -t testreceiver:latest -f Dockerfile-test-receiver .
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -0400106
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -0400107
Tommy Carpenter9d5ad712019-12-02 11:02:01 -0500108Then, run all the tests from the root (this requires the python packages ``tox``, ``pytest``, and ``tavern``).
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -0400109
Tommy Carpenter7dbbfbc2019-06-18 09:58:55 -0400110::
111
112 tox -c tox-integration.ini
113
114This script:
Lott, Christopher (cl778h)2222dfa2020-05-04 09:39:20 -0400115
116#. Deploys 3 helm charts (5 containers) into a local kubernetes installation
117#. Port forwards a pod ClusterIP to localhost
118#. Uses “tavern” to run some tests against the server
119#. Barrages the server with Apache bench
120#. Tears everything down