1 .. This work is licensed under a
2 .. Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
10 Policy APEX PDP component
11 ~~~~~~~~~~~~~~~~~~~~~~~~~
13 Setting up Stability Tests in APEX
14 ++++++++++++++++++++++++++++++++++
19 The 72 hour Stability Test for apex-pdp has the goal of introducing a steady flow of transactions initiated from a test client server running JMeter. The pdp is configured to start a rest server inside it and take input from rest clients (JMeter) and send back output to the rest clients (JMeter).
21 The input events will be submitted through rest interface of apex-pdp and the results are verified using the rest responses coming out from apex-pdp.
23 The test will be performed in a multi-threaded environment where 20 threads running in JMeter will keep sending events to apex-pdp in every 500 milliseconds for the duration of 72 hours.
28 The stability test is performed on VM's running in OpenStack cloud environment. There are 2 seperate VM's, one for running apex pdp & other one for running JMeter to simulate steady flow of transactions.
30 **OpenStack environment details**
34 **apex-pdp VM details**
44 Docker Version: 19.03.8, build afacb8b7f0
46 Java: openjdk version "11.0.7"
58 Java: openjdk version "11.0.7"
62 Install JMeter in virtual machine
63 ---------------------------------
65 Make the etc/hosts entries
69 echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /etc/hosts
75 echo "nameserver <PrimaryDNSIPIP>" >> sudo /etc/resolvconf/resolv.conf.d/head
77 echo "nameserver <SecondaryDNSIP>" >> sudo /etc/resolvconf/resolv.conf.d/head
81 Update the ubuntu software installer
91 apt-get install -y openjdk-11-jdk
95 Download & install JMeter
105 wget http://mirrors.whoishostingthis.com/apache//jmeter/binaries/apache-jmeter-5.2.1.zip
108 unzip apache-jmeter-5.2.1.zip
110 Install apex-pdp in virtual machine
111 -----------------------------------
113 We will be running apex-pdp as docker container. So we need to first install docker and then create the container hosting apex-pdp by pulling the image from ONAP repository.
115 **Docker Installation**
117 1. Make the etc/hosts entries
121 echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /etc/hosts
123 2. Make the DNS entries
127 echo "nameserver <PrimaryDNSIPIP>" >> sudo /etc/resolvconf/resolv.conf.d/head
128 echo "nameserver <SecondaryDNSIP>" >> sudo /etc/resolvconf/resolv.conf.d/head
131 3. Update the ubuntu software installer
137 4. Check and Install Java
141 apt-get install -y openjdk-11-jdk
144 Ensure that the Java version that is executing is OpenJDK version 8
146 5. Check and install docker
150 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
151 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
153 sudo apt-cache policy docker-ce
154 sudo apt-get install -y docker-ce
155 sudo systemctl enable docker
156 sudo systemctl start docker
157 sudo usermod -aG docker <your user id>
159 6. Logout and re-login to ensure the ``usermod`` command takes effective
161 7. Check the status of the Docker service and ensure it is running correctly
169 Run the below command to create the container hosting apex-pdp by pulling the image from ONAP repository.
173 docker run -d --name apex -p 12561:12561 -p 23324:23324 -p 9911:9911 nexus3.onap.org:10001/onap/policy-apex-pdp:2.3.1 /bin/bash -c "/opt/app/policy/apex-pdp/bin/apexApps.sh jmx-test -c /opt/app/policy/apex-pdp/examples/config/SampleDomain/RESTServerJsonEvent.json"
176 Note: If you observe that requests from JMeter client is failing due to timeout, then modify the "RESTServerJsonEvent.json" mentioned in the above command and increase the "synchronousTimeout" property as per needed.
178 Install & Configure VisualVM
179 ----------------------------
181 VisualVM needs to be installed in the virtual machine having apex-pdp. It will be used to monitor CPU, Memory, GC for apex-pdp while stability test is running.
187 sudo apt-get install visualvm
189 Login to VM using graphical interface in separate terminal window.
193 ssh -X <user>@<VM-IP-ADDRESS>
201 Connect to apex-pdp JVM's JMX agent
202 1. Right click on "Local" in the left panel of the screen and select "Add Local JMX Connection..."
203 2. Enter localhost:9911 for "Connection", and click OK
204 3. Double click on the newly added nodes under "Local" to start monitoring CPU, Memory & GC.
206 Sample Screenshot of visualVM
208 .. image:: images/stability-visualvm1.PNG
209 .. image:: images/stability-visualvm2.PNG
214 The 72 hours stability test will run the following steps in 20 threaded loop.
216 - **Send Input Event** - sends an input message to rest interface of apex-pdp.
217 - **Assert Response Code** - assert the response code coming from apex-pdp.
218 - **Assert Response Message** - assert the response message coming from apex-pdp.
220 The following steps can be used to configure the parameters of test plan.
222 - **HTTP Header Manager** - used to store headers which will be used for making HTTP requests.
223 - **HTTP Request Defaults** - used to store HTTP request details like Server Name or IP, Port, Protocol etc.
224 - **User Defined Variables** - used to store following user defined parameters.
226 ================== ============================================================================ ============================
227 **Name** **Description** **Default Value**
228 ================== ============================================================================ ============================
229 wait Wait time after each request (in milliseconds) 500
230 threads Number of threads to run test cases in parallel. 20
231 threadsTimeOutInMs Synchronization timer for threads running in parallel (in milliseconds). 5000
232 ================== ============================================================================ ============================
235 Download and update the jmx file presented in the apex-pdp git repository - `jmx file path <https://gerrit.onap.org/r/gitweb?p=policy/apex-pdp.git;a=tree;f=testsuites/apex-pdp-stability/src/main/resources;h=99d373033a190a690d4e05012bc3a656cae7bc3f;hb=refs/heads/master>`_.
237 - HTTPSampler.domain - The ip address of VM which the apex container is running
238 - HTTPSampler.port - The listening port, here is 23324
239 - ThreadGroup.druation - Set the duration to 72 hours (in seconds)
241 Use the CLI mode to start the test
245 ./jmeter.sh -n -t ~/apexPdpStabilityTestPlan.jmx -Jusers=1 -l ~/stability.log
247 Stability Test Result
248 ---------------------
252 Stability test plan was triggered for 72 hours injecting input events to apex-pdp from 20 client threads running in JMeter.
254 After the test stop, we can generate a HTML test report via command
258 ~/jMeter/apache-jmeter-5.2.1/bin/jmeter -g stability.log -o ./result/
260 ============================================== =================================================== ================================ ============= ============
261 **Number of Client Threads running in JMeter** **Number of Server Threads running in Apex engine** **Total number of input events** **Success %** **Error %**
262 ============================================== =================================================== ================================ ============= ============
264 ============================================== =================================================== ================================ ============= ============
266 .. image:: images/stability-jmeter.PNG
268 :download:`result.zip <zip/result.tar>`
270 Setting up Performance Tests in APEX
271 ++++++++++++++++++++++++++++++++++++
273 The apex-pdp has built in support for performance testing. A special performance testing REST server is available in the code base for performance testing.
274 It is in the module `performance-benchmark-test <https://github.com/onap/policy-apex-pdp/tree/master/testsuites/performance/performance-benchmark-test>`_.
275 To execute a benchmark test, you start the REST server, and then configure and run APEX against the server.
276 There are example configurations for running tests in the `resources of this module <https://github.com/onap/policy-apex-pdp/tree/master/testsuites/performance/performance-benchmark-test/src/main/resources/examples/benchmark>`_.
278 In order to run the test for 72 hours, set the batch count in the `EventGeneratorConfig.json <https://github.com/onap/policy-apex-pdp/blob/master/testsuites/performance/performance-benchmark-test/src/main/resources/examples/benchmark/EventGeneratorConfig.json>`_ file to zero, which causes the REST server to generate batches forever.
280 Here is an example of how to do this:
282 1. Clone and build the apex-pdp git repo
284 2. Go into the performance-benchmark-test module and run the REST server
288 cd testsuites/performance/performance-benchmark-test
289 mvn exec:java -Dexec.mainClass="org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.EventGenerator" -Dexec.args="-c src/main/resources/examples/benchmark/EventGeneratorConfig.json"
291 3. Separately, create a local directory and unzip the APEX tarball
297 tar zxvf ~/git/onap/policy/apex-pdp/packages/apex-pdp-package-full/target/*gz
299 4. Run APEX with a configuration that runs against the benchmark REST server, select the configuration that is appropriate for the number of threads for the number of cores on the host on which APEX is running. For example on a 32 core machine, select the "32" configuration, on an 8 core machine, select the "08" configuration.
303 bin/apexApps.sh engine -c ~/git/onap/policy/apex-pdp/testsuites/performance/performance-benchmark-test/src/main/resources/examples/benchmark/Javascript64.json
305 5. To get the test results, Issue the following command using CURL or from a browser(also can store the result into a file by setting outfile in the `EventGeneratorConfig.json <https://github.com/onap/policy-apex-pdp/blob/master/testsuites/performance/performance-benchmark-test/src/main/resources/examples/benchmark/EventGeneratorConfig.json>`_ file, statistics would be written into this file after event generator terminated)
309 curl http://localhost:32801/EventGenerator/Stats
311 The results are similar to those below:
313 :download:`Example APEX performance metrics <json/example-apex-perf.json>`
315 Performance Test Result Frankfurt
316 ---------------------------------
320 Performance test was triggered for 2 hours on a 4 core, 4GB RAM virtual machine.
324 :download:`Attached result log <json/frankfurt-apex-perf.json>`
326 =============== ============= ================= ============== ===================== ================== ============= ===========
327 **batchNumber** **batchSize** **eventsNotSent** **eventsSent** **eventsNotReceived** **eventsReceived** **Success %** **Error %**
328 =============== ============= ================= ============== ===================== ================== ============= ===========
329 -1 431250 0 431250 0 431250 100 % 0 %
330 =============== ============= ================= ============== ===================== ================== ============= ===========
332 ======================== ========================= ========================
333 **averageRoundTripNano** **shortestRoundTripNano** **longestRoundTripNano**
334 ======================== ========================= ========================
335 148965724 20169907 429339393
336 ======================== ========================= ========================
338 ============================ ============================= ============================
339 **averageApexExecutionNano** **shortestApexExecutionNano** **longestApexExecutionNano**
340 ============================ ============================= ============================
341 62451899 3901010 354528579
342 ============================ ============================= ============================