9575277c999a892dad6118c1d91f039bcba11efc
[policy/parent.git] / docs / development / devtools / apex-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 .. _apex-s3p-label:
6
7 .. toctree::
8    :maxdepth: 2
9
10 Policy APEX PDP component
11 ~~~~~~~~~~~~~~~~~~~~~~~~~
12
13 Both the Stability and the Performance tests were executed in a full ONAP OOM deployment in Nordix lab.
14
15 Setup Details
16 +++++++++++++
17
18 Deploying ONAP using OOM
19 ------------------------
20
21 APEX-PDP along with all policy components are deployed as part of a full ONAP OOM deployment.
22 At a minimum, the following ONAP components are needed: policy, mariadb-galera, aai, cassandra, aaf, and dmaap.
23
24 Before deploying, the values.yaml files are changed to use NodePort instead of ClusterIP for policy-api,
25 policy-pap, and policy-apex-pdp, so that they are accessible from jmeter::
26
27   policy-apex-pdp              NodePort    10.43.70.176    <none>        6969:30237/TCP
28   policy-api                   NodePort    10.43.2.99      <none>        6969:30240/TCP
29   policy-pap                   NodePort    10.43.203.178   <none>        6969:30442/TCP
30
31 The node ports (30237, 30240 and 30442 above) are used in JMeter. The HOSTNAME for JMeter is set to the IP returned by running kubectl cluster-info.
32
33 Set up policy-models-simulator
34 ------------------------------
35
36 Policy-models-simulator is deployed to use CDS and DMaaP simulators during policy execution.
37     Simulator configurations used are available in apex-pdp repository:
38       testsuites/apex-pdp-stability/src/main/resources/simulatorConfig/
39
40 It is run as a docker image from a node accessible to the kubernetes cluster::
41
42   docker run -d --rm --publish 6680:6680 --publish 31054:3905 \
43     --volume "apex-pdp/testsuites/apex-pdp-stability/src/main/resources/simulatorConfig:/opt/app/policy/simulators/etc/mounted" \
44     nexus3.onap.org:10001/onap/policy-models-simulator:2.6-SNAPSHOT-latest
45
46 The published ports 6680 and 31054 are used in JMeter for CDS and DMaaP simulators.
47
48 Creation of VNF & PNF in AAI
49 ----------------------------
50
51 In order for APEX-PDP engine to fetch the resource details from AAI during runtime execution, we need to create dummy
52 VNF & PNF entities in AAI. In a real control loop flow, the entities in AAI will be either created during orchestration
53 phase or provisioned in AAI separately.
54
55 Download & execute the steps in postman collection for creating the entities along with it’s dependencies.
56 The steps needs to be performed sequentially one after another. And no input is required from user.
57
58 :download:`Create VNF & PNF in AAI for Apex S3P  <postman/create-vnf-pnf-aai-for-apex-s3p.postman_collection.json>`
59
60 Make sure to skip the delete VNF & PNF steps.
61
62 JMeter Tests
63 ------------
64
65 Two APEX policies are executed in the APEX-PDP engine, and are triggered by multiple threads during the tests.
66 Both tests were run via jMeter.
67
68     Stability test script is available in apex-pdp repository:
69       testsuites/apex-pdp-stability/src/main/resources/apexPdpStabilityTestPlan.jmx
70
71     Performance test script is available in apex-pdp repository:
72       testsuites/performance/performance-benchmark-test/src/main/resources/apexPdpPerformanceTestPlan.jmx
73
74 .. Note::
75    Policy executions are validated in a stricter fashion during the tests.
76    There are test cases where up to 80 events are expected on the DMaaP topic.
77    DMaaP simulator is used to keep it simple and avoid any message pickup timing related issues.
78
79 Stability Test of APEX-PDP
80 ++++++++++++++++++++++++++
81
82 Test Plan
83 ---------
84
85 The 72 hours stability test ran the following steps.
86
87 Setup Phase
88 """""""""""
89
90 Policies are created and deployed to APEX-PDP during this phase. Only one thread is in action and this step is done only once.
91
92 - **Create Policy onap.policies.apex.Simplecontrolloop** - creates the first APEX policy using policy/api component.
93       This is a sample policy used for PNF testing.
94 - **Create Policy onap.policies.apex.Example** - creates the second APEX policy using policy/api component.
95       This is a sample policy used for VNF testing.
96 - **Deploy Policies** - Deploy both the policies created to APEX-PDP using policy/pap component
97
98 Main Phase
99 """"""""""
100
101 Once the policies are created and deployed to APEX-PDP by the setup thread, five threads execute the below tests for 72 hours.
102
103 - **Healthcheck** - checks the health status of APEX-PDP
104 - **Prometheus Metrics** - checks that APEX-PDP is exposing prometheus metrics
105 - **Test Simplecontrolloop policy success case** - Send a trigger event to *unauthenticated.DCAE_CL_OUTPUT* DMaaP topic.
106     If the policy execution is successful, 3 different notification events are sent to *APEX-CL-MGT* topic by each one of the 5 threads.
107     So, it is checked if 15 notification messages are received in total on *APEX-CL-MGT* topic with the relevant messages.
108 - **Test Simplecontrolloop policy failure case** - Send a trigger event with invalid pnfName to *unauthenticated.DCAE_CL_OUTPUT* DMaaP topic.
109     The policy execution is expected to fail due to AAI failure response. 2 notification events are expected on *APEX-CL-MGT* topic by a thread in this case.
110     It is checked if 10 notification messages are received in total on *APEX-CL-MGT* topic with the relevant messages.
111 - **Test Example policy success case** - Send a trigger event to *unauthenticated.DCAE_POLICY_EXAMPLE_OUTPUT* DMaaP topic.
112     If the policy execution is successful, 4 different notification events are sent to *APEX-CL-MGT* topic by each one of the 5 threads.
113     So, it is checked if 20 notification messages are received in total on *APEX-CL-MGT* topic with the relevant messages.
114 - **Test Example policy failure case** - Send a trigger event with invalid vnfName to *unauthenticated.DCAE_POLICY_EXAMPLE_OUTPUT* DMaaP topic.
115     The policy execution is expected to fail due to AAI failure response. 2 notification events are expected on *APEX-CL-MGT* topic by a thread in this case.
116     So, it is checked if 10 notification messages are received in total on *APEX-CL-MGT* topic with the relevant messages.
117 - **Clean up DMaaP notification topic** - DMaaP notification topic which is *APEX-CL-MGT* is cleaned up after each test to make sure that one failure doesn't lead to cascading errors.
118
119
120 Teardown Phase
121 """"""""""""""
122
123 Policies are undeployed from APEX-PDP and deleted during this phase.
124 Only one thread is in action and this step is done only once after the Main phase is complete.
125
126 - **Undeploy Policies** - Undeploy both the policies from APEX-PDP using policy/pap component
127 - **Delete Policy onap.policies.apex.Simplecontrolloop** - delete the first APEX policy using policy/api component.
128 - **Delete Policy onap.policies.apex.Example** - delete the second APEX policy also using policy/api component.
129
130 Test Configuration
131 ------------------
132
133 The following steps can be used to configure the parameters of test plan.
134
135 - **HTTP Authorization Manager** - used to store user/password authentication details.
136 - **HTTP Header Manager** - used to store headers which will be used for making HTTP requests.
137 - **User Defined Variables** - used to store following user defined parameters.
138
139 ===================  ===============================================================================
140  **Name**            **Description**
141 ===================  ===============================================================================
142  HOSTNAME            IP Address or host name to access the components
143  PAP_PORT            Port number of PAP for making REST API calls such as deploy/undeploy of policy
144  API_PORT            Port number of API for making REST API calls such as create/delete of policy
145  APEX_PORT           Port number of APEX for making REST API calls such as healthcheck/metrics
146  SIM_HOST            IP Address or hostname running policy-models-simulator
147  DMAAP_PORT          Port number of DMaaP simulator for making REST API calls such as reading notification events
148  CDS_PORT            Port number of CDS simulator
149  wait                Wait time if required after a request (in milliseconds)
150  threads             Number of threads to run test cases in parallel
151  threadsTimeOutInMs  Synchronization timer for threads running in parallel (in milliseconds)
152 ===================  ===============================================================================
153
154 Run Test
155 --------
156
157 The test was run in the background via "nohup", to prevent it from being interrupted:
158
159 .. code-block:: bash
160
161     nohup ./apache-jmeter-5.4.3/bin/jmeter.sh -n -t apexPdpStabilityTestPlan.jmx -l stabilityTestResults.jtl
162
163 Test Results
164 ------------
165
166 **Summary**
167
168 Stability test plan was triggered for 72 hours. There were no failures during the 72 hours test.
169
170
171 **Test Statistics**
172
173 =======================  =================  ==================  ==================================
174 **Total # of requests**  **Success %**      **Error %**         **Average time taken per request**
175 =======================  =================  ==================  ==================================
176 430331                    100 %             0.00 %              152 ms
177 =======================  =================  ==================  ==================================
178
179 .. Note::
180
181    There were no failures during the 72 hours test.
182
183 **JMeter Screenshot**
184
185 .. image:: apex-s3p-results/apex_stability_jmeter_results.png
186
187 **Memory and CPU usage**
188
189 The memory and CPU usage can be monitored by running "top" command in the APEX-PDP pod.
190 A snapshot is taken before and after test execution to monitor the changes in resource utilization.
191 Prometheus metrics is also collected before and after the test execution.
192
193 Memory and CPU usage before test execution:
194
195 .. image:: apex-s3p-results/apex_top_before_72h.png
196
197 :download:`Prometheus metrics before 72h test  <apex-s3p-results/apex_metrics_before_72h.txt>`
198
199 Memory and CPU usage after test execution:
200
201 .. image:: apex-s3p-results/apex_top_after_72h.png
202
203 :download:`Prometheus metrics after 72h test  <apex-s3p-results/apex_metrics_after_72h.txt>`
204
205 Performance Test of APEX-PDP
206 ++++++++++++++++++++++++++++
207
208 Introduction
209 ------------
210
211 Performance test of APEX-PDP is done similar to the stability test, but in a more extreme manner using higher thread count.
212
213 Setup Details
214 -------------
215
216 The performance test is performed on a similar setup as Stability test.
217
218
219 Test Plan
220 ---------
221
222 Performance test plan is the same as the stability test plan above except for the few differences listed below.
223
224 - Increase the number of threads used in the Main Phase from 5 to 20.
225 - Reduce the test time to 2 hours.
226
227 Run Test
228 --------
229
230 .. code-block:: bash
231
232     nohup ./apache-jmeter-5.4.3/bin/jmeter.sh -n -t apexPdpPerformanceTestPlan.jmx -l perftestresults.jtl
233
234
235 Test Results
236 ------------
237
238 Test results are shown as below.
239
240 **Test Statistics**
241
242 =======================  =================  ==================  ==================================
243 **Total # of requests**  **Success %**      **Error %**         **Average time taken per request**
244 =======================  =================  ==================  ==================================
245 47586                    100 %              0.00 %              163 ms
246 =======================  =================  ==================  ==================================
247
248 **JMeter Screenshot**
249
250 .. image:: apex-s3p-results/apex_perf_jmeter_results.png
251
252 Summary
253 +++++++
254
255 Multiple policies were executed in a multi-threaded fashion for both stability and performance tests.
256 Both tests ran smoothly without any issues.