Add documentation for API s3p tests
[policy/parent.git] / docs / development / devtools / testing / s3p / api-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 .. _api-s3p-label:
6
7 .. toctree::
8    :maxdepth: 2
9
10 Policy API S3P Tests
11 ####################
12
13
14 72 Hours Stability Test of Policy API
15 +++++++++++++++++++++++++++++++++++++
16
17 Introduction
18 ------------
19
20 The 72 hour stability test of policy API has the goal of verifying the stability of running policy design API REST
21 service by ingesting a steady flow of transactions in a multi-threaded fashion to
22 simulate multiple clients' behaviours.
23 All the transaction flows are initiated from a test client server running JMeter for the duration of 72 hours.
24
25 Setup Details
26 -------------
27
28 The stability test was performed on a default Policy docker installation in the Nordix Lab environment.
29 JMeter was installed on a separate VM to inject the traffic defined in the
30 `API stability script
31 <https://git.onap.org/policy/api/tree/testsuites/stability/src/main/resources/testplans/policy_api_stability.jmx>`_
32 with the following command:
33
34 .. code-block:: bash
35
36     nohup apache-jmeter-5.6.2/bin/jmeter -n -t policy_api_stability.jmx -l stabilityTestResultsPolicyApi.jtl &
37
38 The test was run in the background via “nohup” and “&”, to prevent it from being interrupted.
39
40 Test Plan
41 ---------
42
43 The 72+ hours stability test will be running the following steps sequentially
44 in multi-threaded loops. Thread number is set to 5 to simulate 5 API clients'
45 behaviours (they can be calling the same policy CRUD API simultaneously).
46 Each thread creates a different version of the policy types and policies to not
47 interfere with one another while operating simultaneously.  The point version
48 of each entity is set to the running thread number.
49
50 **Setup Thread (will be running only once)**
51
52 - Get policy-api Healthcheck
53 - Get Preloaded Policy Types
54
55 **API Test Flow (5 threads running the same steps in the same loop)**
56
57 - Create a new Monitoring Policy Type with Version 6.0.#
58 - Create a new Monitoring Policy Type with Version 7.0.#
59 - Create a new Optimization Policy Type with Version 6.0.#
60 - Create a new Guard Policy Type with Version 6.0.#
61 - Create a new Native APEX Policy Type with Version 6.0.#
62 - Create a new Native Drools Policy Type with Version 6.0.#
63 - Create a new Native XACML Policy Type with Version 6.0.#
64 - Get All Policy Types
65 - Get All Versions of the new Monitoring Policy Type
66 - Get Version 6.0.# of the new Monitoring Policy Type
67 - Get Version 6.0.# of the new Optimization Policy Type
68 - Get Version 6.0.# of the new Guard Policy Type
69 - Get Version 6.0.# of the new Native APEX Policy Type
70 - Get Version 6.0.# of the new Native Drools Policy Type
71 - Get Version 6.0.# of the new Native XACML Policy Type
72 - Get the Latest Version of the New Monitoring Policy Type
73 - Create Version 6.0.# of Node Template
74 - Create Monitoring Policy Ver 6.0.# w/Monitoring Policy Type Ver 6.0.#
75 - Create Monitoring Policy Ver 7.0.# w/Monitoring Policy Type Ver 7.0.#
76 - Create Optimization Policy Ver 6.0.# w/Optimization Policy Type Ver 6.0.#
77 - Create Guard Policy Ver 6.0.# w/Guard Policy Type Ver 6.0.#
78 - Create Native APEX Policy Ver 6.0.# w/Native APEX Policy Type Ver 6.0.#
79 - Create Native Drools Policy Ver 6.0.# w/Native Drools Policy Type Ver 6.0.#
80 - Create Native XACML Policy Ver 6.0.# w/Native XACML Policy Type Ver 6.0.#
81 - Create Version 6.0.# of PNF Example Policy with Metadata
82 - Get Node Template
83 - Get All TCA Policies
84 - Get All Versions of Monitoring Policy Type
85 - Get Version 6.0.# of the new Monitoring Policy
86 - Get Version 6.0.# of the new Optimization Policy
87 - Get Version 6.0.# of the new Guard Policy
88 - Get Version 6.0.# of the new Native APEX Policy
89 - Get Version 6.0.# of the new Native Drools Policy
90 - Get Version 6.0.# of the new Native XACML Policy
91 - Get the Latest Version of the new Monitoring Policy
92 - Delete Version 6.0.# of the new Monitoring Policy
93 - Delete Version 7.0.# of the new Monitoring Policy
94 - Delete Version 6.0.# of the new OptimizationPolicy
95 - Delete Version 6.0.# of the new Guard Policy
96 - Delete Version 6.0.# of the new Native APEX Policy
97 - Delete Version 6.0.# of PNF Example Policy having Metadata
98 - Delete Version 6.0.# of the new Native Drools Policy
99 - Delete Version 6.0.# of the new Native XACML Policy
100 - Delete Monitoring Policy Type with Version 6.0.#
101 - Delete Monitoring Policy Type with Version 7.0.#
102 - Delete Optimization Policy Type with Version 6.0.#
103 - Delete Guard Policy Type with Version 6.0.#
104 - Delete Native APEX Policy Type with Version 6.0.#
105 - Delete Native Drools Policy Type with Version 6.0.#
106 - Delete Native XACML Policy Type with Version 6.0.#
107 - Delete Node Template
108 - Get Policy Metrics
109
110 **TearDown Thread (will only be running after API Test Flow is completed)**
111
112 - Get policy-api Healthcheck
113 - Get Preloaded Policy Types
114
115
116 Test Results
117 ------------
118
119 **Summary**
120
121 No errors were found during the 72 hours of the Policy API stability run.
122 The load was performed against a non-tweaked Policy docker deployment.
123
124 **Test Statistics**
125
126 =======================  =============  ===========  ===============================  ===============================  ===============================
127 **Total # of requests**  **Success %**    **TPS**    **Avg. time taken per request**  **Min. time taken per request**  **Max. time taken per request**
128 =======================  =============  ===========  ===============================  ===============================  ===============================
129     730178                    100%         2.8              1766 ms                               127 ms                          107029 ms
130 =======================  =============  ===========  ===============================  ===============================  ===============================
131
132 .. image:: api-s3p-results/api-s3p-jm-1_J.png
133
134 **JMeter Results**
135
136 The following graphs show the response time distributions.   The "Get Policy Types" API calls are the most expensive calls that
137 average a 8.6 seconds plus response time.
138
139 .. image:: api-s3p-results/api-response-time-distribution_J.png
140 .. image:: api-s3p-results/api-response-time-overtime_J.png
141
142 **Memory and CPU usage**
143
144 The memory and CPU usage can be monitored by running "docker stats" command in the policy-api container.
145 A snapshot is taken before and after test execution to monitor the changes in resource utilization.
146
147 Memory and CPU usage before test execution:
148
149 .. image:: api-s3p-results/api_stat_before_72h.png
150
151 Memory and CPU usage after test execution:
152
153 .. image:: api-s3p-results/api_stat_after_72h.png
154
155
156 Performance Test of Policy API
157 ++++++++++++++++++++++++++++++
158
159 Introduction
160 ------------
161
162 Performance test of policy-api has the goal of testing the min/avg/max processing time and rest call throughput for all the requests when the number of requests are large enough to saturate the resource and find the bottleneck.
163
164 Setup Details
165 -------------
166
167 The performance test was performed on a default Policy docker installation in the Nordix Lab environment.
168 JMeter was installed on a separate VM to inject the traffic defined in the
169 `API performance script
170 <https://git.onap.org/policy/api/tree/testsuites/performance/src/main/resources/testplans/policy_api_performance.jmx>`_
171 with the following command:
172
173 .. code-block:: bash
174
175     nohup apache-jmeter-5.6.2/bin/jmeter -n -t policy_api_performance.jmx -l performanceTestResultsPolicyApi.jtl &
176
177 The test was run in the background via “nohup” and “&”, to prevent it from being interrupted.
178
179 Test Plan
180 ---------
181
182 Performance test plan is the same as stability test plan above.
183 Only differences are, in performance test, we increase the number of threads up to 20 (simulating 20 users' behaviours at the same time) whereas reducing the test time down to 2.5 hours.
184
185 Run Test
186 --------
187
188 Running/Triggering performance test will be the same as stability test. That is, launch JMeter pointing to corresponding *.jmx* test plan. The *API_HOST* and *API_PORT* are already set up in *.jmx*.
189
190 **Test Statistics**
191
192 =======================  =============  ===========  ===============================  ===============================  ===============================
193 **Total # of requests**  **Success %**    **TPS**    **Avg. time taken per request**  **Min. time taken per request**  **Max. time taken per request**
194 =======================  =============  ===========  ===============================  ===============================  ===============================
195     56740                     100%           6.3              6340 ms                              72 ms                          65557 ms
196 =======================  =============  ===========  ===============================  ===============================  ===============================
197
198 .. image:: api-s3p-results/api-s3p-jm-2_J.png
199
200 Test Results
201 ------------
202
203 The following graphs show the response time distributions.
204
205 .. image:: api-s3p-results/api-response-time-distribution_performance_J.png
206 .. image:: api-s3p-results/api-response-time-overtime_performance_J.png
207
208
209
210