8e3e1a04f054313ed864767d6ae089c104c47fc4
[policy/parent.git] / docs / development / devtools / distribution-s3p.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 .. _distribution-s3p-label:
6
7 Policy Distribution component
8 #############################
9
10 72h Stability and 4h Performance Tests of Distribution
11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
13 VM Details
14 ----------
15
16 The stability and performance tests are performed on VM's running in the OpenStack cloud
17 environment in the ONAP integration lab. There are two separate VMs, one for running backend policy
18 services which policy distribution needs, and the other for the policy distribution service itself
19 and Jmeter.
20
21 **OpenStack environment details**
22
23 - Version: Windriver Titanium
24
25 **Policy Backend VM details (VM1)**
26
27 - OS: Ubuntu 18.04.5 LTS
28 - CPU: 8 core, Intel Xeon E3-12xx v2 (Ivy Bridge), 2693.668 MHz, 16384 kB cache
29 - RAM: 32 GB
30 - HardDisk: 200 GB
31 - Docker version 19.03.8, build afacb8b7f0
32 - Java: openjdk 11.0.8 2020-07-14
33
34
35 Common Setup
36 ------------
37
38 Update the ubuntu software installer
39
40 .. code-block:: bash
41
42     sudo apt update
43
44 Install Java
45
46 .. code-block:: bash
47
48     sudo apt install -y openjdk-11-jdk
49
50 Ensure that the Java version that is executing is OpenJDK version 11
51
52 .. code-block:: bash
53
54     $ java --version
55     openjdk 11.0.8 2020-07-14
56     OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
57     OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)
58
59 Install Docker and Docker Compose
60
61 .. code-block:: bash
62
63     # Add docker repository
64     curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
65
66     echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
67     $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
68
69     sudo apt update
70
71     # Install docker
72     sudo apt-get install docker-ce docker-ce-cli containerd.io
73
74 Change the permissions of the Docker socket file
75
76 .. code-block:: bash
77
78     sudo chmod 666 /var/run/docker.sock
79
80 Check the status of the Docker service and ensure it is running correctly
81
82 .. code-block:: bash
83
84     systemctl status --no-pager docker
85     docker.service - Docker Application Container Engine
86        Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
87        Active: active (running) since Wed 2020-10-14 13:59:40 UTC; 1 weeks 0 days ago
88        # ... (truncated for brevity)
89
90     docker ps
91     CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
92
93 Install and verify docker-compose
94
95 .. code-block:: bash
96
97     # Install compose
98     sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
99     sudo chmod +x /usr/local/bin/docker-compose
100
101     # Check if install was successful
102     docker-compose --version
103
104 Clone the policy-distribution repo to access the test scripts
105
106 .. code-block:: bash
107
108     git clone https://gerrit.onap.org/r/policy/distribution
109
110 .. _setup-distribution-s3p-components:
111
112 Start services for MariaDB, Policy API, PAP and Distribution
113 ------------------------------------------------------------
114
115 Navigate to the main folder for scripts to setup services:
116
117 .. code-block:: bash
118
119     cd ~/distribution/testsuites/stability/src/main/resources/setup
120
121 Modify the versions.sh script to match all the versions being tested.
122
123 .. code-block:: bash
124
125     vi ~/distribution/testsuites/stability/src/main/resources/setup/versions.sh
126
127 Ensure the correct docker image versions are specified - e.g. for Istanbul-M4
128
129 - export POLICY_DIST_VERSION=2.6.1-SNAPSHOT
130
131 Run the start.sh script to start the components. After installation, script will execute
132 ``docker ps`` and show the running containers.
133
134 .. code-block:: bash
135
136     ./start.sh
137
138     Creating network "setup_default" with the default driver
139     Creating policy-distribution ... done
140     Creating mariadb             ... done
141     Creating simulator           ... done
142     Creating policy-db-migrator  ... done
143     Creating policy-api          ... done
144     Creating policy-pap          ... done
145
146     CONTAINER ID   IMAGE                                                               COMMAND                  CREATED         STATUS                  PORTS                NAMES
147     f91be98ad1f4   nexus3.onap.org:10001/onap/policy-pap:2.5.1-SNAPSHOT                "/opt/app/policy/pap…"   1 second ago    Up Less than a second   6969/tcp             policy-pap
148     d92cdbe971d4   nexus3.onap.org:10001/onap/policy-api:2.5.1-SNAPSHOT                "/opt/app/policy/api…"   1 second ago    Up Less than a second   6969/tcp             policy-api
149     9a019f5d641e   nexus3.onap.org:10001/onap/policy-db-migrator:2.3.1-SNAPSHOT        "/opt/app/policy/bin…"   2 seconds ago   Up 1 second             6824/tcp             policy-db-migrator
150     108ba238edeb   nexus3.onap.org:10001/mariadb:10.5.8                                "docker-entrypoint.s…"   3 seconds ago   Up 1 second             3306/tcp             mariadb
151     bec9b223e79f   nexus3.onap.org:10001/onap/policy-models-simulator:2.5.1-SNAPSHOT   "simulators.sh"          3 seconds ago   Up 1 second             3905/tcp             simulator
152     74aa5abeeb08   nexus3.onap.org:10001/onap/policy-distribution:2.6.1-SNAPSHOT       "/opt/app/policy/bin…"   3 seconds ago   Up 1 second             6969/tcp, 9090/tcp   policy-distribution
153
154
155 .. note::
156     The containers on this docker-compose are running with HTTP configuration. For HTTPS, ports
157     and configurations will need to be changed, as well certificates and keys must be generated
158     for security.
159
160
161 Install JMeter
162 --------------
163
164 Download and install JMeter
165
166 .. code-block:: bash
167
168     # Install required packages
169     sudo apt install -y wget unzip
170
171     # Install JMeter
172     mkdir -p jmeter
173     cd jmeter
174     wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.4.1.zip
175     unzip -q apache-jmeter-5.4.1.zip
176     rm apache-jmeter-5.4.1.zip
177
178
179 Install & configure visualVM
180 --------------------------------------
181
182 VisualVM needs to be installed in the virtual machine running Distribution. It will be used to
183 monitor CPU, Memory and GC for Distribution while the stability tests are running.
184
185 .. code-block:: bash
186
187     sudo apt install -y visualvm
188
189 Run these commands to configure permissions
190
191 .. code-block:: bash
192
193     # Set globally accessable permissions on policy file
194     sudo chmod 777 /usr/lib/jvm/java-11-openjdk-amd64/bin/visualvm.policy
195
196     # Create Java security policy file for VisualVM
197     sudo cat > /usr/lib/jvm/java-11-openjdk-amd64/bin/visualvm.policy << EOF
198     grant codebase "jrt:/jdk.jstatd" {
199        permission java.security.AllPermission;
200     };
201     grant codebase "jrt:/jdk.internal.jvmstat" {
202        permission java.security.AllPermission;
203     };
204     EOF
205
206 Run the following command to start jstatd using port 1111
207
208 .. code-block:: bash
209
210     /usr/lib/jvm/java-11-openjdk-amd64/bin/jstatd -p 1111 -J-Djava.security.policy=/usr/lib/jvm/java-11-openjdk-amd64/bin/visualvm.policy &
211
212 Run visualVM to connect to POLICY_DISTRIBUTION_IP:9090
213
214 .. code-block:: bash
215
216     # Get the Policy Distribution container IP
217     echo $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-distribution)
218
219     # Start visual vm
220     visualvm &
221
222 This will load up the visualVM GUI
223
224 Connect to Distribution JMX Port.
225
226     1. Right click on "Local" in the left panel of the screen and select "Add JMX Connection"
227     2. Enter the Distribution container IP and Port 9090. This is the JMX port exposed by the
228        distribution container
229     3. Double click on the newly added nodes under "Local" to start monitoring CPU, Memory & GC.
230
231 Example Screenshot of visualVM
232
233 .. image:: images/distribution/distribution-s3p-vvm-sample.png
234
235
236 Stability Test of Policy Distribution
237 +++++++++++++++++++++++++++++++++++++
238
239 Introduction
240 ------------
241
242 The 72 hour Stability Test for policy distribution has the goal of introducing a steady flow of
243 transactions initiated from a test client server running JMeter. The policy distribution is
244 configured with a special FileSystemReception plugin to monitor a local directory for newly added
245 csar files to be processed by itself. The input CSAR will be added/removed by the test client
246 (JMeter) and the result will be pulled from the backend (PAP and PolicyAPI) by the test client
247 (JMeter).
248
249 The test will be performed in an environment where Jmeter will continuously add/remove a test csar
250 into the special directory where policy distribution is monitoring and will then get the processed
251 results from PAP and PolicyAPI to verify the successful deployment of the policy. The policy will
252 then be undeployed and the test will loop continuously until 72 hours have elapsed.
253
254
255 Test Plan Sequence
256 ------------------
257
258 The 72h stability test will run the following steps sequentially in a single threaded loop.
259
260 - **Delete Old CSAR** - Checks if CSAR already exists in the watched directory, if so it deletes it
261 - **Add CSAR** - Adds CSAR to the directory that distribution is watching
262 - **Get Healthcheck** - Ensures Healthcheck is returning 200 OK
263 - **Get Statistics** - Ensures Statistics is returning 200 OK
264 - **CheckPDPGroupQuery** - Checks that PDPGroupQuery contains the deployed policy
265 - **CheckPolicyDeployed** - Checks that the policy is deployed
266 - **Undeploy Policy** - Undeploys the policy
267 - **Delete Policy** - Deletes the Policy for the next loop
268 - **Check PDP Group for Deletion** - Ensures the policy has been removed and does not exist
269
270 The following steps can be used to configure the parameters of the test plan.
271
272 - **HTTP Authorization Manager** - used to store user/password authentication details.
273 - **HTTP Header Manager** - used to store headers which will be used for making HTTP requests.
274 - **User Defined Variables** -  used to store following user defined parameters.
275
276 ==========  ===============================================
277  **Name**    **Description**
278 ==========  ===============================================
279  PAP_HOST     IP Address or host name of PAP component
280  PAP_PORT     Port number of PAP for making REST API calls
281  API_HOST     IP Address or host name of API component
282  API_PORT     Port number of API for making REST API calls
283  DURATION     Duration of Test
284 ==========  ===============================================
285
286 Screenshot of Distribution stability test plan
287
288 .. image:: images/distribution/distribution-s3p-testplan.png
289
290
291 Running the Test Plan
292 ---------------------
293
294 Check if the /tmp/policydistribution/distributionmount exists as it was created during the start.sh
295 script execution. If not, run the following commands to create folder and change folder permissions
296 to allow the testplan to insert the CSAR into the /tmp/policydistribution/distributionmount folder.
297
298 .. code-block:: bash
299
300     sudo mkdir -p /tmp/policydistribution/distributionmount
301     sudo chmod -R a+trwx /tmp
302
303
304 Navigate to the stability test folder.
305
306 .. code-block:: bash
307
308     cd ~/distribution/testsuites/stability/src/main/resources/testplans/
309
310 Execute the run_test.sh
311
312 .. code-block:: bash
313
314     ./run_test.sh
315
316
317 Test Results
318 ------------
319
320 **Summary**
321
322 - Stability test plan was triggered for 72 hours.
323 - No errors were reported
324
325 **Test Statistics**
326
327 .. image:: images/distribution/dist_stability_statistics.png
328 .. image:: images/distribution/dist_stability_threshold.png
329
330 **VisualVM Screenshots**
331
332 .. image:: images/distribution/dist_stability_monitor.png
333 .. image:: images/distribution/dist_stability_threads.png
334
335
336 Performance Test of Policy Distribution
337 +++++++++++++++++++++++++++++++++++++++
338
339 Introduction
340 ------------
341
342 The 4h Performance Test of Policy Distribution has the goal of testing the min/avg/max processing
343 time and rest call throughput for all the requests when the number of requests are large enough to
344 saturate the resource and find the bottleneck.
345
346 It also tests that distribution can handle multiple policy CSARs and that these are deployed within
347 30 seconds consistently.
348
349
350 Setup Details
351 -------------
352
353 The performance test is based on the same setup as the distribution stability tests.
354
355
356 Test Plan Sequence
357 ------------------
358
359 Performance test plan is different from the stability test plan.
360
361 - Instead of handling one policy csar at a time, multiple csar's are deployed within the watched
362   folder at the exact same time.
363 - We expect all policies from these csar's to be deployed within 30 seconds.
364 - There are also multithreaded tests running towards the healthcheck and statistics endpoints of
365   the distribution service.
366
367
368 Running the Test Plan
369 ---------------------
370
371 Check if /tmp folder permissions to allow the Testplan to insert the CSAR into the
372 /tmp/policydistribution/distributionmount folder.
373 Clean up from previous run. If necessary, put containers down with script `down.sh` from setup
374 folder mentioned on :ref:`Setup components <setup-distribution-s3p-components>`
375
376 .. code-block:: bash
377
378     sudo mkdir -p /tmp/policydistribution/distributionmount
379     sudo chmod -R a+trwx /tmp
380
381 Navigate to the testplan folder and execute the test script:
382
383 .. code-block:: bash
384
385     cd ~/distribution/testsuites/performance/src/main/resources/testplans/
386     ./run_test.sh
387     
388
389 Test Results
390 ------------
391
392 **Summary**
393
394 - Performance test plan was triggered for 4 hours.
395 - No errors were reported
396
397 **Test Statistics**
398
399 .. image:: images/distribution/performance-statistics.png
400 .. image:: images/distribution/performance-threshold.png
401
402 **VisualVM Screenshots**
403
404 .. image:: images/distribution/performance-monitor.png
405 .. image:: images/distribution/performance-threads.png