Jmeter calls Python scripts to pass parameters to each other

In the interface performance test, the interface request parameters are spliced ​​according to certain rules and then MD5 encryption is carried out before parameter transmission. Therefore, with the help of python script implementation, the test efficiency can be effectively improved.
1. Analysis parameter encryption rules: NonceStr: timestamp + a random number less than 1000;
Sign: "UserID=" + UserID+ "&" + "NonceStr=" + NonceStr + "fixed string";
where UserID is thousands
Two different data have been parameterized in CSV file; 2. Write python script.
Insert picture description here
Insert picture description here
2. Newly added .bat file, specific command: python D:\python-study\epg_test\test0708.py %1 (%1 means passing 1 parameter UserID to the python file to generate the NonceStr, Sign required by the interface parameter).

3. Reading the batch file through the OS Process Sampler component of JMeter is actually executing the written python script.
Insert picture description here

4. Add regular expressions, extract the two parameters generated by the python script, and provide them to the interface.
Insert picture description here

5. Set parameterization in the interface request and read the automatically generated parameters in the python script (multiple parameters in the interface have been parameterized in the CSV file);
Insert picture description here

6. Run the jmeter script and view the results.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44848764/article/details/112967159