Docs for using CSITs with docker and microk8s installations.
[policy/parent.git] / docs / development / devtools / testing / csit.rst
1 .. This work is licensed under a
2 .. Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
4
5 .. _policy-csit-label:
6
7 Policy Framework CSIT Testing
8 #############################
9
10 .. contents::
11     :depth: 3
12
13 The Continuous System and Integration Testing suites are run normally as a Jenkins job to assert
14 that common usage of Policy Framework services are running as expected.
15
16 This article provides the steps to run CSIT tests in a local environment, most commonly after a
17 significant code change.
18
19 .. note::
20   If building images locally, follow the instructions :ref:`here <building-pf-docker-images-label>`
21
22
23 First, clone policy/docker repo from gerrit:
24
25 .. code-block:: bash
26
27   git clone "https://gerrit.onap.org/r/policy/docker"
28
29 On this whole article, it's assumed the base folder for policy-docker repository is
30 `~/git/policy/docker`
31
32 Under the folder `~/git/policy/docker/csit`, there are two main scripts to run the tests:
33
34 * run-k8s-csit.sh
35 * run-project-csit.sh
36
37
38 Running CSIT in Docker environment
39 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40
41 If not familiar with the PF Docker structure, the detailed information can be found :ref:`here <docker-label>`
42
43 Running tests to validate code changes
44 --------------------------------------
45
46 After building image(s) locally, the compose file needs to be edited to use the local image when
47 bringing up the container. Open file `~/git/policy/docker/compose/docker-compose.yml` and remove the
48 tag `${CONTAINER_LOCATION}` from the image variable in the service description.
49 If change is GUI related, then `docker-compose.gui.yml` might need to be edited as well, although
50 there are no GUI related test suites.
51
52 For example, if testing against a PAP change, a new onap/policy-pap image with latest and
53 x.y.z-SNAPSHOT versions is available. When editing the docker-compose file, the following change
54 would be done:
55
56 From:
57
58 .. code-block:: yaml
59
60   pap:
61   image: ${CONTAINER_LOCATION}onap/policy-pap:${POLICY_PAP_VERSION}
62   container_name: policy-pap
63
64
65 To:
66
67 .. code-block:: yaml
68
69   pap:
70   image: onap/policy-pap:latest
71   container_name: policy-pap
72
73
74 .. note::
75    Make sure to do the same changes to any other components that are using locally built images.
76
77
78 After finished with edits in compose file, then use the `run-project-csit.sh` script to run the
79 test suite.
80
81
82 .. code-block:: bash
83
84   cd ~/git/policy/docker
85   ./csit/run-project-csit.sh <component>
86
87
88 The <component> input is any of the policy components available:
89
90  - api
91  - pap
92  - apex-pdp
93  - distribution
94  - drools-pdp
95  - drools-applications
96  - xacml-pdp
97  - policy-acm-runtime
98
99 Keep in mind that after the Robot executions, logs from docker-compose are printed and
100 test logs might not be available on console and the containers are teared down. The tests results
101 are available under `~/git/policy/docker/csit/archives/<component>/` folder.
102
103
104 Running tests for learning PF usage
105 -----------------------------------
106
107 In that case, no changes required on docker-compose files, but commenting the tear down of docker
108 containers might be required. For that, edit the file `run-project-csit.sh` script and comment the
109 following line:
110
111 .. code-block:: bash
112
113   # source_safely ${WORKSPACE}/compose/stop-compose.sh (currently line 36)
114
115
116 This way, the docker containers are still up and running for more investigation.
117
118 To tear them down, execute the `stop-compose.sh` script:
119
120 .. code-block:: bash
121
122   cd ~/git/policy/docker/compose
123   ./stop-compose.sh
124
125
126 Running CSIT in Micro K8S environment
127 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
128
129 The microk8s version of Policy Framework was brought up for integration test in PF as whole, such
130 as Stability and Performance tests, but can be used for CSIT validation as well. The helm charts
131 are under `~/git/policy/docker/helm` folder.
132
133
134 Running tests or installing one PF component
135 --------------------------------------------
136
137 If needed to install or run tests for an specific PF component, the `run-k8s-csit.sh` script can be
138 used to run the test suite or installation with the proper arguments.
139
140
141 .. code-block:: bash
142
143   cd ~/git/policy/docker
144   ./csit/run-k8s-csit.sh install <component>
145
146
147 The <component> input is any of the policy components available:
148
149  - api
150  - pap
151  - apex-pdp
152  - distribution
153  - drools-pdp
154  - xacml-pdp
155  - clamp
156
157
158 Different from Docker usage, the microk8s installation is not removed when tests finish.
159
160
161 Installing all available PF components
162 --------------------------------------
163
164 Use the `run-k8s-csit.sh` script to install PF components with Prometheus server available.
165
166 .. code-block:: bash
167
168   cd ~/git/policy/docker
169   ./csit/run-k8s-csit.sh install
170
171
172 In this case, no tests are executed and the environment can be used for other integration tests
173 such as Stability and Performance, Smoke tests or manual test.
174
175
176 Uninstall and clean up
177 ----------------------
178
179 If running the CSIT tests with microk8s environment, docker images for the tests suites are created.
180 To clean them up, user `docker prune <https://docs.docker.com/config/pruning/>`_ command.
181
182 To uninstall policy helm deployment and/or the microk8s cluster, use `run-k8s-csit.sh`
183
184
185 .. code-block:: bash
186
187   cd ~/git/policy/docker
188
189   # to uninstall deployment
190   ./csit/run-k8s-csit.sh uninstall
191
192   # to remove cluster
193   ./csit/run-k8s-csit.sh clean
194
195
196 End of document