Method for batch exporting encrypted parameters based on JMeter

By adding Beanshell sampler plug-in and Java requests to the Jmeter tool, combined with regular expression extractor, batch export of encryption parameters is realized, solving the encryption parameters problem of Jmeter tool when writing performance test scripts, improving writing efficiency and reducing memory utilization.

CN115186281BActive Publication Date: 2025-08-05GANSU WANWEI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210828087.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-15
Publication Date
2025-08-05
Estimated Expiration
2042-07-15

AI Technical Summary

Technical Problem

When writing performance test scripts, existing Jmeter tools cannot meet the batch encryption parameters requirements of the project's security requirements, resulting in increased difficulty in writing scripts and high memory utilization, and failure to complete performance test scripts.

Method used

By adding a Beanshell sampler plug-in that editable export fields in the Jmeter tool, the parameter writing process is simplified, and combined with Java requests and regular expression extractors, batch export of encryption parameters is realized, reducing Java code writing, and reducing memory dependencies.

Benefits of technology

Improves the efficiency and availability of writing performance test scripts, reduces memory utilization, and ensures the accuracy and simplicity of the parameter encryption process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 220715020126
    Figure 220715020126
Patent Text Reader

Abstract

The present invention belongs to the field of data testing technology, and specifically relates to a method for batch exporting encrypted parameters based on Jmeter. Through the above-mentioned Jmeter script batch exporting encrypted parameters method, first, when writing a test script to obtain encrypted parameters, there is no need to encrypt the parameters in the beansell sampler each time. An editable export file text box based on the beansell sampler plug-in is written for intuitive interface operation, eliminating the tediousness and complexity of writing Jmeter scripts and the memory dependence of the test load machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data testing, and in particular relates to a method for batch exporting encryption parameters based on JMeter. Background Art

[0002] We currently use JMeter to write performance test scripts. JMeter is a simple web performance testing tool that utilizes a variety of controls for writing performance test scripts. The most commonly used performance testing controls include the HTTP Header Manager, HTTP Request Defaults, HTTP Request, Java Request, and CSV Data File Settings. The most commonly used control for manually writing performance test scripts is the HTTP Request. Due to changing requirements, project security requirements are now extremely high. All project parameters are encrypted for our company's projects. Performance testing requires the creation of batch encryption parameters. To improve content security, we encrypt the BeanShell sampler during the testing phase, which requires writing Java code. This complicates performance test script writing, and HTTP requests alone cannot meet these encryption requirements. Therefore, using separate encryption methods for Java and HTTP requests cannot meet the current batch encryption requirements, making it impossible to complete the required performance test scripts.

[0003] In order to solve the above problems, we try to use the manual writing of test scripts. First, we add editable export fields to the pre-packaged beanshell sampler plug-in, so that script writers can directly enter editable content in the graphical text interface without writing Java code, which saves a lot of script writing time and test load machine memory. The above method can accurately and completely write performance test scripts according to the requirements. Summary of the Invention

[0004] To address the above issues, the present invention provides a method for batch exporting encrypted parameters in the Jmeter tool, eliminating the difficulty of writing Java code for the Beansell sampler each time within the script, thereby improving writing efficiency. Parameters are first imported in batches within the Java request, encrypted in batches within the Java code, and then exported by calling the Beansell sampler to edit the export file field contents. This significantly reduces the load machine's memory utilization during the writing process, improving the portability and usability of the test script.

[0005] The technical solution adopted by the present invention is: a method for batch exporting encryption parameters in a Jmeter tool, the method for batch exporting encryption parameters comprising the following steps:

[0006] The method for batch exporting encryption parameters based on JMeter includes the following steps:

[0007] Step 1. Import parameters into JMeter. Parameter name categories include ID number and login account. Write them into txt and csv files. Add csv sampler in JMeter tool and import parameter csv files into JMeter. Batch parameters include parameter extraction from project requirements. Extract project parameters and preset specified parameter values as parameter basis. Specified parameter formats include date format, numbers and letters, etc. Parameter files include csv and txt formats. Parameter files are required to be saved in ANSI encoding format.

[0008] Step 2: Java request batch parameter encryption. Add a new Java request and view the result tree in the thread rent based on the pre-packaged RSA encryption file dependency jar package. Store the dependent jar package file in the preset directory. Add a sampler Java request in the Jmeter tool, select the class name based on the packaged dependent jar package file, and then fill in the parameters. The parameters are combined with the parameter data in step 1 and named. The View Result Tree plug-in is the most commonly used listener in JMeter. Based on the View Result Tree plug-in, obtain the encrypted data in the Java request sampler.

[0009] Step 3: Extract parameters using regular expressions. Add a regular expression extractor, combine the encrypted data in the Java request sampler in step 2, select the batch parameter values in step 1, and extract the encrypted data in the Java request sampler based on the regular expression extractor.

[0010] Step 4. The Beanshell plug-in encapsulates batch export of encrypted parameters, encapsulates the export file code based on the beanshell sampler plug-in, and introduces dependent packages, including: JMeter test component model, beanshell sampler user interface, inherits the AbstractJavaSamplerClient abstract class to set the available parameter default value getDefaultParameters; modifies the static panel interface to add field export text name and variable name; initializes variables, and modifies the method in the AbstractJavaSamplerClient abstract class to the FileWriter file export main logic; exports the modified AbstractJavaSamplerClient abstract class as a jar package; and stores the jar package as the beanshell sampler plug-in in the preset directory;

[0011] Step 5: Add the BeanShell Sampler plug-in to export batch parameters. The BeanShell plug-in displays a graphical user interface with editable fields for export. These fields include at least the export file name, file encoding, and variable name. These editable text boxes support JMeter custom variables. Users can directly operate the interface and enter the export file path to export the file. Based on the encryption parameters selected in Step 3, add the BeanShell Sampler and enter the file name and path in the Export File text box. The parameters are exported as a CSV file.

[0012] In step 4, the default directory of the dependent jar package is the lib\ext directory of Jmeter.

[0013] In step 5, the file export formats based on the encapsulated Beanshell sampler plug-in request include CSV files, Excel files, and TXT files. If the generated file is a single CSV file, it is directly saved as a CSV file to the file path specified by the host. If there are multiple CSV files, the editable text names are separated by commas to output multiple files. If there are multiple editable variable names, they are specified to be separated by commas. If the exported file includes TXT files and CSV files in step 4, all batch encrypted files are saved in chronological order to the file path specified by the host.

[0014] The beneficial effects of the present invention are as follows: by using the above-mentioned method for batch exporting encrypted parameters using Jmeter scripts, firstly, in the process of writing test scripts to obtain encrypted parameters, there is no need to encrypt the parameters in the beansell sampler each time; instead, an editable export file text box based on the beansell sampler plug-in is written for intuitive interface operation, thereby eliminating the tediousness and complexity of writing Jmeter scripts and the memory dependency of the test load machine. Secondly, by simplifying the import of customized batch parameters, and because the actual project requirement parameter values are preset in the parameters, the batch encryption configuration of the relevant parameters can be completed quickly. Script errors caused by errors in the parameter encryption method are avoided. By using the method described in the present invention, encrypted parameters can be exported in batches quickly and accurately, and the usability and portability of the script are improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 Flowchart of the method for batch exporting encrypted parameters for JMeter scripts. DETAILED DESCRIPTION

[0016] The embodiment of the present invention is described in detail below with reference to the accompanying drawings, which is characterized by comprising the following steps:

[0017] S1. Import parameters into the JMeter method using the CSV file manager based on the JMeter tool, set the parameter name and parameter value for the parameter; set parameter attributes according to actual needs, such as parameter grouping and whether the parameter is required; if necessary, multiple operations in the parameter can be defined as the same parameter or parameter group;

[0018] S2. Encrypt Java request batch parameters, including the encryption test methods required for test execution. Encryption methods include MD5 encryption, RSA asymmetric encryption, and AES symmetric key encryption. Write and encapsulate the RSA encryption algorithm in a JAR package. Place the JAR package in the lib\ext directory of the JMeter file. Use the View Results Tree plug-in to obtain encrypted data from the Java Request Sampler.

[0019] S3. Import the batch parameters in JMeter and the encryption method designed in S2 according to S1, combine the parameters actually required by the project, and extract the parameters in the form of regular expressions;

[0020] S4, Batch export of encryption parameters. If S4 contains a single CSV file, it will be saved directly as a CSV file to the file path specified by the host. If S4 contains txt files and CSV files, all batch encrypted files will be saved in chronological order to the file path specified by the host.

[0021] The specific plan is as follows:

[0022] Step 1. Import parameters into jmeter. Parameter name classification includes but is not limited to ID card number and login account. Write them into txt and csv files. Add a csv sampler in the jmeter tool and import the parameter csv file into Jmeter. Batch parameters include but are not limited to parameter extraction in project requirements. Parameters in the project include project codes such as A1001...A1999. Project parameters are written according to actual needs. Project codes can be, but are not limited to, auto-incremental. Extract project parameters and preset specified parameter values as parameter basis. Specified parameter formats include but are not limited to date formats, numbers, and letters. Parameter files include but are not limited to csv and txt formats. If the parameter value is displayed as an ID card number, the specified format must be 18 digits and converted to text format in the csv file; if it is a parameter value composed of numbers and letters, the specified format must be consistent with the default data of the project system. Fill in the specified parameter data into the csv file, fill in the data in each column according to the parameter name, and save the specified parameter file in the encoding format ANSI.

[0023] Step 2: Encrypt Java request batch parameters. Currently, the most commonly used encryption methods are MD5 and RSA asymmetric encryption algorithms. RSA is an asymmetric encryption algorithm that is highly reliable. The longer the key, the harder it is to crack. The longest RSA key that has been cracked is 768 bits. Asymmetric encryption uses two keys (public and private) to encrypt and decrypt data. The public key is used for encryption, and the private key is used for decryption. In this embodiment, based on the pre-packaged RSA encryption file dependency JAR package, a Java request and View Result Tree are added to the thread. The dependent JAR package file is stored in the preset directory, which is the JMeter lib\ext directory. In JMeter, add a sampler Java request, select the class name based on the packaged dependent JAR package file, and then enter the parameters. The parameters are combined with the parameter data in Step 1 and named using the format ${name}. The View Result Tree plugin is the most commonly used listener in JMeter, which allows you to view the request sent and returned information. Using the View Result Tree plugin, retrieve the encrypted data from the Java request sampler.

[0024] Step 3: Extract parameters using regular expressions. Add a regular expression extractor. Combine the encrypted data in the Java request sampler in step 2, select the batch parameter values in step 1, and extract the encrypted data in the Java request sampler based on the regular expression extractor.

[0025] Step 4: The Beanshell plug-in encapsulates batch export of encrypted parameters and encapsulates the export file code based on the beanshell sampler plug-in. The encapsulation is implemented by: introducing a dependent package, which includes: the JMeter test component model, the beanshell sampler user interface, inheriting the AbstractJavaSamplerClient abstract class to set the available parameter default values getDefaultParameters; modifying the static panel interface to add field export text names and variable names. Initialize variables and modify the methods in the AbstractJavaSamplerClient abstract class to the FileWriter file export main logic; export the modified AbstractJavaSamplerClient abstract class as a jar package; and store the jar package as the beanshell sampler plug-in in the preset directory. The preset directory is the lib\ext directory of Jmeter.

[0026] Step 5. Add a beanshell sampler plug-in to export batch parameters. The graphical user interface displayed by the beanshell plug-in includes an editable field export function. The editable fields include at least: editable file export name, editable file encoding, and editable variable name. The editable text boxes all support Jmeter custom variables. Allow users to directly operate the interface, enter the export file path, and the file can be exported. According to the encryption parameters selected in step 3, add the beansell sampler, and enter the file name and path in the export file text box. The file name and path include but are not limited to formats such as: . / name.csv, . / name.txt; the file encoding specifies the utf-8 format; the variable name specifies the ${usname} format. The final exported parameters are csv files.

[0027] Preferably, the batch parameters in step 1 are actual parameters that meet the project requirements. Random parameters can also be created based on functions. Random parameter construction methods include but are not limited to setting the auto-increment method from 1 to 9999 based on the JMeter built-in function _Random and expanding it. The parameter import method is based on the CSV file manager in JMeter.

[0028] Preferably, after setting the batch parameter encryption method in step 2, sequential and random combination strategies can be simultaneously implemented for the batch extracted parameters. Sequential combinations include, but are not limited to, for example: given the actual project requirements, the encryption parameters are composed of the timestamp 201209012 and the field name project code A10001, with the order corresponding one-to-one according to the time and project code, such as the combination of 20120912_A1001. Random combinations include, but are not limited to, the combination of the variable name organization code format AWQQ2333 and the location name test street, with the variable order randomly composed, such as test street AWQQ2333 or AWQQ2333 test street. Sequential combination parameters are encrypted and encapsulated according to the actual project requirements, and random combination parameters are encrypted and encapsulated.

[0029] Preferably, the encryption parameter format extracted by the regular expression in step 3 is extracted according to parameter_g1, parameter_g2, etc.

[0030] Preferably, the preset directory of the dependent jar package in step 4 includes but is not limited to the lib\ext directory of Jmeter.

[0031] Preferably, the file export format in the encapsulated Beanshell sampler plug-in request in step 5 includes but is not limited to csv files, excel files, and txt files. If the generated file is a single csv file, it is directly saved in the form of a csv file to the file path specified by the host; if it is multiple csv files, the editable text name is separated by commas and multiple files are output. If there are multiple editable variable names, it is specified that they are separated by commas. If the exported file includes txt files and CSV files in step 4, all batch encrypted files are saved in the file path specified by the host in chronological order.

Claims

1. The method of batch exporting encryption parameters based on jmeter is characterized by The steps include: Step 1. Import parameters into jmeter. Parameter name categories include ID number and login account. Write them into txt and csv files. Add csv sampler in jmeter tool and import parameter csv files into jmeter. Batch parameters include parameter extraction from project requirements. Extract project parameters and preset specified parameter values as parameter basis. Specified parameter formats include date format, numbers and letters. Parameter files include csv and txt formats. Parameter files are required to be saved in ANSI encoding format. Step 2: Java request batch parameter encryption. Add a new Java request and View Result Tree in the thread group based on the pre-packaged RSA encryption file dependency jar package. Store the dependent jar package file in the preset directory. Add a sampler java request in the JMeter tool, select the class name based on the packaged dependent jar package file, and then fill in the parameters. The parameters are combined with the parameter data in step 1 and named. The View Result Tree plug-in is the most commonly used listener in JMeter. Based on the View Result Tree plug-in, obtain the encrypted data in the Java request sampler. Step 3: Extract parameters using regular expressions. Add a regular expression extractor, combine the encrypted data in the Java request sampler in step 2, select the batch parameter values in step 1, and extract the encrypted data in the Java request sampler based on the regular expression extractor. Step 4. The beanshell sampler plug-in encapsulates batch export of encrypted parameters, encapsulates the export file code based on the beanshell sampler plug-in, and introduces the dependent package, which includes: the jmeter test component model, the beanshell sampler plug-in user interface, inherits the AbstractJavaSamplerClient abstract class to set the available parameter default value getDefaultParameters; modifies the static panel interface to add field export text name and variable name; initializes variables, and modifies the method in the AbstractJavaSamplerClient abstract class to the FileWriter file export main logic; exports the modified AbstractJavaSamplerClient abstract class as a jar package; and stores the jar package as the beanshell sampler plug-in in the preset directory; Step 5. Add a beanshell sampler plug-in to export batch parameters. The graphical user interface displayed by the beanshell sampler plug-in includes an editable field export function. The editable fields include at least: editable file export name, editable file encoding, and editable variable name; the editable text boxes all support jmeter custom variables; allowing users to directly operate the interface, enter the export file path, and the file can be exported; according to the encryption parameters selected in step 3, add the beansell sampler plug-in, enter the file name and path in the export file text box, and finally the exported parameters are csv files.

2. The method for batch exporting encryption parameters based on jmeter according to claim 1 is characterized in that In step 4, the default directory of the dependent jar package is the lib\ext directory of jmeter.

3. The method for batch exporting encryption parameters based on jmeter according to claim 1 is characterized in that In step 5, the file export formats based on the encapsulated beanshell sampler plug-in request include CSV files, Excel files, and TXT files. If the generated file is a single CSV file, it is directly saved as a CSV file to the file path specified by the host; if it is multiple CSV files, the editable text name can be separated by commas to output multiple files; If there are multiple editable variable names, they must be separated by commas. Export Files If a txt file and a CSV file are included in step 4, all batch encrypted files are saved in chronological order to the file path specified by the host.

Citation Information

Patent Citations

  • Automatic method and system for uploading files in batches

    CN112860640A

  • WAF rule automatic test method and system, storage medium and terminal equipment

    CN113656302A