5ae58ff5b03f541b91cc58d4d8e5c9bf20610c47
[policy/parent.git] / docs / development / devtools / pap-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 .. _pap-s3p-label:
6
7 .. toctree::
8    :maxdepth: 2
9
10 Policy PAP component
11 ~~~~~~~~~~~~~~~~~~~~
12
13 72 Hours Stability Test of PAP
14 ++++++++++++++++++++++++++++++
15
16 Introduction
17 ------------
18
19 The 72 hour Stability Test for PAP has the goal of introducing a steady flow of transactions initiated from a test client server running JMeter for the duration of 72 hours.
20
21 Setup details
22 -------------
23
24 The stability test is performed on VM's running in OpenStack cloud environment.
25
26 There are 2 seperate VM's, one for running PAP & other one for running JMeter to simulate steady flow of transactions.
27
28 All the dependencies like mariadb, dmaap simulator, pdp simulator & policy/api component are installed in the VM having JMeter.
29
30 For simplicity lets assume
31
32 VM1 will be running JMeter, MariaDB, DMaaP simulator, PDP simulator & API component.
33
34 VM2 will be running only PAP component.
35
36 **OpenStack environment details**
37
38 Version: Mitaka
39
40 **PAP VM details (VM2)**
41
42 OS:Ubuntu 16.04 LTS
43
44 CPU: 4 core
45
46 RAM: 4 GB
47
48 HardDisk: 40 GB
49
50 Docker version 19.03.8
51
52 Java: openjdk version "11.0.7" 2020-04-14
53
54 **JMeter VM details (VM1)**
55
56 OS: Ubuntu 16.04 LTS
57
58 CPU: 4 core
59
60 RAM: 4 GB
61
62 HardDisk: 40 GB
63
64 Docker Version: 18.09.6
65
66 Java: openjdk version "11.0.7" 2020-04-14
67
68 JMeter: 5.2.1
69
70 Install Docker in VM1 & VM2
71 ---------------------------
72
73 Make sure to execute below commands in VM1 & VM2 both.
74
75 Make the etc/hosts entries
76
77 .. code-block:: bash
78
79     $ echo $(hostname -I | cut -d\  -f1) $(hostname) | sudo tee -a /etc/hosts
80
81 Make the DNS entries
82
83 .. code-block:: bash
84
85     $ echo "nameserver <PrimaryDNSIPIP>" >> /etc/resolvconf/resolv.conf.d/head
86     $ echo "nameserver <SecondaryDNSIP>" >> /etc/resolvconf/resolv.conf.d/head
87     $ resolvconf -u
88
89 Update the ubuntu software installer
90
91 .. code-block:: bash
92
93     $ apt-get update
94
95 Check and Install Java
96
97 .. code-block:: bash
98
99     $ apt-get install -y openjdk-11-jdk
100     $ java -version
101
102 Ensure that the Java version that is executing is OpenJDK version 8
103
104
105 Check and install docker
106
107 .. code-block:: bash
108
109     $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
110     $ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
111     $ apt-get update
112     $ apt-cache policy docker-ce
113     $ apt-get install -y docker-ce
114     $ systemctl status docker
115     $ docker ps
116
117 Change the permissions of the Docker socket file
118
119 .. code-block:: bash
120
121     $ chmod 777 /var/run/docker.sock
122     
123 Check the status of the Docker service and ensure it is running correctly
124
125 .. code-block:: bash
126
127     $ service docker status
128     $ docker ps
129
130 Install JMeter in VM1
131 ---------------------
132
133 Download & install JMeter
134
135 .. code-block:: bash
136
137     $ mkdir jMeter
138     $ cd jMeter
139     $ wget http://mirrors.whoishostingthis.com/apache//jmeter/binaries/apache-jmeter-5.2.1.zip
140     $ unzip apache-jmeter-5.2.1.zip
141
142 Run JMeter
143
144 .. code-block:: bash
145
146     $ /home/ubuntu/jMeter/apache-jmeter-5.2.1/bin/jmeter
147
148 The above command will load the JMeter UI. Then navigate to File ā†’ Open ā†’ Browse and select the test plan jmx file to open.
149 The jmx file is present in the policy/pap git repository.
150
151 Install simulators in VM1
152 -------------------------
153
154 Clone PAP to VM1 using the following command :
155
156 .. code-block:: bash
157
158     root@policytest-policytest-3-p5djn6as2477:~$ git clone http://gerrit.onap.org/r/policy/pap
159
160 For installing simulator, execute the script `setup_components.sh` as shown below:
161
162 .. code-block:: bash
163
164     root@policytest-policytest-3-p5djn6as2477:~$ ./pap/testsuites/stability/src/main/resources/simulatorsetup/setup_components.sh
165
166 After installation make sure that following 4 docker containers are up and running.
167
168 .. code-block:: bash
169
170     root@policytest-policytest-3-p5djn6as2477:~$ docker ps
171     CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
172     887efa8dac12        nexus3.onap.org:10001/onap/policy-api   "bash ./policy-api.sh"   6 days ago          Up 6 days           0.0.0.0:6969->6969/tcp   policy-api
173     0a931c0a63ac        pdp/simulator:latest                    "bash pdp-sim.sh"        6 days ago          Up 6 days                                    pdp-simulator
174     a41adcb32afb        dmaap/simulator:latest                  "bash dmaap-sim.sh"      6 days ago          Up 6 days           0.0.0.0:3904->3904/tcp   dmaap-simulator
175     d52d6b750ba0        mariadb:10.2.14                         "docker-entrypoint.sā€¦"   6 days ago          Up 6 days           0.0.0.0:3306->3306/tcp   mariadb
176
177 Install PAP in VM2
178 ------------------
179
180 Clone PAP to VM2 using the following command :
181
182 .. code-block:: bash
183
184     root@policytest-policytest-3-p5djn6as2477:~$ git clone http://gerrit.onap.org/r/policy/pap
185
186 For installing PAP, execute the script `setup_pap.sh` as shown below:
187
188 .. code-block:: bash
189
190     root@policytest-policytest-3-p5djn6as2477:~$ cd pap/testsuites/stability/src/main/resources/papsetup/
191     root@policytest-policytest-3-p5djn6as2477:~$ ./setup_pap.sh <VM2_IP> <VM1_IP>
192
193 After installation make sure that following docker container is up and running.
194
195 .. code-block:: bash
196
197     root@policytest-policytest-0-uc3y2h5x6p4j:~$ docker ps
198     CONTAINER ID        IMAGE                                                         COMMAND                  CREATED             STATUS              PORTS                                            NAMES
199     42ac0ed4b713        nexus3.onap.org:10001/onap/policy-pap:2.2.3-SNAPSHOT          "bash ./policy-pap.sh"   3 days ago          Up 3 days           0.0.0.0:6969->6969/tcp, 0.0.0.0:9090->9090/tcp   policy-pap
200
201 Install & configure visualVM in VM2
202 -----------------------------------
203
204 visualVM needs to be installed in the virtual machine having PAP. It will be used to monitor CPU, Memory, GC for PAP while stability test is running.
205
206 Install visualVM
207
208 .. code-block:: bash
209
210     $ sudo apt-get install visualvm
211
212 Run few commands to configure permissions
213
214 .. code-block:: bash
215
216     $ cd /usr/lib/jvm/java-11-openjdk-amd64/bin/
217     $ sudo touch visualvm.policy
218     $ sudo chmod 777 visualvm.policy
219
220     $ vi visualvm.policy
221
222     Add the following in visualvm.policy
223
224
225     grant codebase "file:/usr/lib/jvm/java-11-openjdk-amd64/lib/tools.jar" {
226        permission java.security.AllPermission;
227     };
228
229 Run following commands to start jstatd using port 1111
230
231 .. code-block:: bash
232
233     $ cd /usr/lib/jvm/java-11-openjdk-amd64/bin/
234     $ ./jstatd -p 1111 -J-Djava.security.policy=visualvm.policy  &
235
236 Run visualVM locally to connect to remote VM2
237
238 .. code-block:: bash
239
240     # On your windows machine or your linux box locally, launch visualVM
241     $ nohup visualvm
242
243 Connect to jstatd & remote apex-pdp JVM
244
245     1. Right click on "Remote" in the left panel of the screen and select "Add Remote Host..."
246     2. Enter the IP address of VM2.
247     3. Right click on IP address, select "Add JMX Connection..."
248     4. Enter the VM2 IP Address (from step 2) <IP address>:9090 ( for example -10.12.6.201:9090) and click OK.
249     5. Double click on the newly added nodes under "Remote" to start monitoring CPU, Memory & GC.
250
251 Sample Screenshot of visualVM
252
253 .. image:: images/pap-s3p-vvm-sample.png
254
255 Test Plan
256 ---------
257
258 The 72 hours stability test will run the following steps sequentially in a single threaded loop.
259
260 - **Create Policy Type** - creates an operational policy type using policy/api component
261 - **Create Policy defaultDomain** - creates an operational policy using the policy type created in the above step using policy/api component
262 - **Create Policy sampleDomain** - creates an operational policy using the policy type created in the above step using policy/api component
263 - **Check Health** - checks the health status of pap
264 - **Check Statistics** - checks the statistics of pap
265 - **Change state to ACTIVE** - changes the state of defaultGroup PdpGroup to ACTIVE
266 - **Check PdpGroup Query** - makes a PdpGroup query request and verifies that PdpGroup is in the ACTIVE state.
267 - **Deploy defaultDomain Policy** - deploys the policy defaultDomain in the existing PdpGroup
268 - **Create/Update PDP Group** - creates a new PDPGroup named sampleGroup.
269 - **OS Process Sampler** - OS Process Sampler to start a new Pdp Instance
270 - **Check PdpGroup Query** - makes a PdpGroup query request and verifies that 2 PdpGroups are in the ACTIVE state and defaultGroup has a policy deployed on it.
271 - **Deployment Update sampleDomain** - deploys the policy sampleDomain in sampleGroup PdpGroup using pap api
272 - **Check PdpGroup Query** - makes a PdpGroup query request and verifies that the defaultGroup has a policy defaultDomain deployed on it and sampleGroup has policy sampleDomain deployed on it.
273 - **Check Deployed Policies** - checks for all the deployed policies using pap api.
274 - **OS Process Sampler** - OS Process Sampler to stop the newly created Pdp Instance
275 - **Undeploy Policy sampleDomain** - undeploys the policy sampleDomain from sampleGroup PdpGroup using pap api
276 - **Undeploy Default Policy** - undeploys the policy defaultDomain from PdpGroup
277 - **Change state to PASSIVE(sampleGroup)** - changes the state of sampleGroup PdpGroup to PASSIVE
278 - **Delete PdpGroup SampleGroup** - delete the sampleGroup PdpGroup using pap api
279 - **Change State to PASSIVE(defaultGroup)** - changes the state of defaultGroup PdpGroup to PASSIVE
280 - **Check PdpGroup Query** - makes a PdpGroup query request and verifies that PdpGroup is in the PASSIVE state.
281 - **Delete Policy defaultDomain** - deletes the operational policy defaultDomain using policy/api component
282 - **Delete Policy sampleDomain** - deletes the operational policy sampleDomain using policy/api component
283 - **Delete Policy Type** - deletes the operational policy type using policy/api component
284
285 The following steps can be used to configure the parameters of test plan.
286
287 - **HTTP Authorization Manager** - used to store user/password authentication details.
288 - **HTTP Header Manager** - used to store headers which will be used for making HTTP requests.
289 - **User Defined Variables** -  used to store following user defined parameters.
290
291 ===========   ===================================================================
292  **Name**      **Description**
293 ===========   ===================================================================
294  PAP_HOST      IP Address or host name of PAP component
295  PAP_PORT      Port number of PAP for making REST API calls
296  API_HOST      IP Address or host name of API component
297  API_PORT      Port number of API for making REST API calls
298  DIR           Path where the pdp instance startup and stop script is placed
299  CONFIG_DIR    Path where the pdp default Config file is placed
300 ===========   ===================================================================
301
302 Screenshot of PAP stability test plan
303
304 .. image:: images/pap-s3p-testplan.png
305
306 Test Results
307 ------------
308
309 **Summary**
310
311 Stability test plan was triggered for 72 hours.
312
313 **Test Statistics**
314
315 =======================  =================  ==================  ==================================
316 **Total # of requests**  **Success %**      **Error %**         **Average time taken per request**
317 =======================  =================  ==================  ==================================
318 178208                   100 %              0 %                 76 ms
319 =======================  =================  ==================  ==================================
320
321 **VisualVM Screenshot**
322
323 .. image:: images/pap-s3p-vvm-1.png
324 .. image:: images/pap-s3p-vvm-2.png
325
326 **JMeter Screenshot**
327
328 .. image:: images/pap-s3p-jm-1.png
329 .. image:: images/pap-s3p-jm-1.png
330
331 Test Results Frankfurt release
332 -------------------------------
333
334 **Summary**
335
336 Stability test plan was triggered for 72 hours.
337
338 .. Note::
339
340               .. container:: paragraph
341
342                   Test cases for starting and stopping the PDP Instance has been included in the
343                   test plan. These test cases have resulted in a spike in the Average time taken per request.
344
345 **Test Statistics**
346
347 =======================  =================  ==================  ==================================
348 **Total # of requests**  **Success %**      **Error %**         **Average time taken per request**
349 =======================  =================  ==================  ==================================
350   29423                  100 %              0 %                 948 ms
351 =======================  =================  ==================  ==================================
352
353 **VisualVM Screenshot**
354
355 .. image:: images/pap-s3p-vvm-1_F.png
356 .. image:: images/pap-s3p-vvm-2_F.png
357
358 **JMeter Screenshot**
359
360 .. image:: images/pap-s3p-jm-1_F.png
361 .. image:: images/pap-s3p-jm-1_F.png
362
363 Performance Test of PAP
364 ++++++++++++++++++++++++
365
366 Introduction
367 ------------
368
369 Performance test of PAP has the goal of testing the min/avg/max processing time and rest call throughput for all the requests with multiple requests at the same time.
370
371 Setup Details
372 -------------
373
374 The performance test is performed on a similar setup as Stability test. The JMeter VM will be sending a large number of REST requests to the PAP component and collecting the statistics.
375
376 Test Plan
377 ---------
378
379 Performance test plan is the same as the stability test plan above except for the few differences listed below.
380
381 - Increase the number of threads up to 5 (simulating 5 users' behaviours at the same time).
382 - Reduce the test time to 2 hours.
383 - Usage of counters to create different groups by the 'Create/Update PDP Group' test case.
384 - Usage of If-Controller for 'Deploy defaultDomain Policy' and 'Undeploy defaultDomain Policy' test cases to install and uninstall the Default policy only in one thread.
385 - OS Process Sampler for starting and stopping the PDP Instance has been disabled in the performance test plan for a better performance check.
386
387 Run Test
388 --------
389
390 Running/Triggering the performance test will be the same as the stability test. That is, launch JMeter pointing to corresponding *.jmx* test plan. The *API_HOST* , *API_PORT* , *PAP_HOST* , *PAP_PORT* are already set up in *.jmx*.
391
392 Once the test execution is completed, execute the below script to get the statistics:
393
394 .. code-block:: bash
395
396     $ cd /home/ubuntu/pap/testsuites/performance/src/main/resources/testplans
397     $ ./results.sh /home/ubuntu/pap_perf/resultTree.log
398
399 Test Results
400 ------------
401
402 Test results are shown as below. Overall, the test was running smoothly and successfully. We do see some minor failed transactions, especially in the 'Deploy' and 'Undeploy' Pap API in a multi-threaded fashion .
403
404 **Test Statistics**
405
406 =======================  =================  ==================  ==================================  =======================
407 **Total # of requests**  **Success %**      **Error %**         **Average time taken per request**  **Requests/sec**
408 =======================  =================  ==================  ==================================  =======================
409   25743                  99.5 %              0.50 %                 397 ms                           5148
410 =======================  =================  ==================  ==================================  =======================
411
412 **JMeter Screenshot**
413
414 .. image:: images/pap-perf-jm-1_F.png
415 .. image:: images/pap-perf-jm-2_F.png