# Take you to play JMeter serials easily through cases (46)

Posted by lobobr on Thu, 10 Feb 2022 14:26:07 +0100

3.2 execution of capacity load test We use the bisection approximation method to find the inflection point of capacity load test, inject data into the database with python script, and delete the data with delete SQL statement. The number of fixed online users is 100, and each test still runs for 10 minutes. If the test error percentage is within 5% (including 5%), the test is considered normal, otherwise the test is considered abnormal. Set the difference (precision) between the minimum value passed and the maximum value failed to be < 10000. 1) The following code is established to add data to the database.

```if __name__=='__main__':
db = DB()

db.connect()

tablename ="goods_goods"

for i in range(100000,200000):

j = i % 10

if j ==0:

values =str(i)+",'Tea',67.87,'/static/image/1.jpg','This is a good tea'"

elif j ==1:

values =str(i)+",'Ham sausage',100.47,'/static/image/2.jpg','This is a good ham sausage'"

elif j ==2:

values =str(i)+",'Spiced beans',100.47,'/static/image/2.jpg','This is a good spiced bean'"

elif j ==3:

values =str(i)+",'peanut',100.47,'/static/image/2.jpg','This is a good peanut'"

elif j ==4:

values =str(i)+",'Roasted Duck',100.47,'/static/image/2.jpg','This is a good roast duck'"

elif j ==5:

values =str(i)+",'melon seed',100.47,'/static/image/2.jpg','This is a good melon seed'"

elif j ==6:

values =str(i)+",'Platoon',100.47,'/static/image/2.jpg','This is a good big row'"

elif j ==7:

values =str(i)+",'barbecue',100.47,'/static/image/2.jpg','This is a good barbecue'"

elif j ==8:

values =str(i)+",'mutton shashlik',100.47,'/static/image/2.jpg','This is a good mutton kebab'"

elif j ==9:

values =str(i)+",'Sauteed Chicken Dices with Chili Peppers',100.47,'/static/image/2.jpg','This is a good spicy diced chicken'"

db.insert(tablename,values)

db.close()
```

2) Open ebussine with Jmeter_ old. JMX, set the throughput in the shopping cart throughput controller and view commodity details throughput controller to 0. 3) Set the throughput of the query commodity throughput controller to 100. In this way, you can only set the query items. 4) The number of thread group concurrency is changed to 100, and the others remain unchanged. 5) The cycle time of the cycle controller is 10. 6) Through the script, set the data in the product to 100000, run for 10 minutes, and the error percentage is 7.67%, exceeding the threshold of 5%. 7) Delete the data in the commodity through the SQL statement, so that the number is 70000, run for 10 minutes, and the error percentage is 1.87%, indicating that the inflection point of the capacity test is between 70000 and 100000. 8) Through the script, set the data in the commodity to 80000, run for 10 minutes, and the error percentage is 5.52%, indicating that the inflection point of the capacity test is between 70000 and 80000. 9) Through the script, set the data in the commodity to 75000, run for 10 minutes, and the error percentage is 1.75%, indicating that the inflection point of the capacity test is between 75000 and 80000. The difference between the two is 5000, which is lower than our preset accuracy < = 10000, so it is considered that the inflection point is 75000. 10) Open the monitoring tools of the pressure measuring end and the tested end (see Chapter 11 for details) to monitor the 10 minute test under the scenario of 75000 commodities. 11) The inflection point data jtl generated by the test is imported into various reports for analysis. 3.3 execution of fatigue test 1) Open ebussines with JMeter_ old. JMX or eBusiness JMX, set the number of threads in the thread group to 100, ramp_ The up time is set to 5 and the number of cycles is forever. Open the scheduler for 48 hours (606024 * 2 = 172800 seconds). The delayed start is 60 seconds. As shown in Figure 15.

Figure 15 thread group setting of fatigue test

2) If you open eBusiness JMX, the thread group (New) is also set according to the previous step. 3) The number of simulated users of the synchronization timer for querying goods is set to 50. 4) The synchronous timer for viewing product details simulates that the number of users is set to 30. 5) The synchronous timer for viewing product details simulates that the number of users is set to 20. 6) If you open eBusiness JMX, view the commodity details, and set the synchronization timer and commodity list synchronization timer to simulate the number of users to 50. 7) Open the program under test 8) Test to ensure that the setting is correct. 9) For example, start the monitoring program on the cluster + influ. DB in section 11. 10) Open the monitoring program of the tested end, such as Exporter + Prometheus + Grafana, which will be described in section 11.2. 11) Open the full link monitoring program as required, such as SkyWalking, which will be described in section 11.3. 12) Start the test. 13) Check the status of the monitoring software at any time during the test. 14) After the test, import the test jtl data into JMeter for analysis.