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