Method and device for achieving data parameterization

A parameterization and data technology, applied in the field of data processing, can solve problems such as limited scope of application, and achieve the effect of expanding the scope of application

Active Publication Date: 2017-05-17
TENCENT TECH (SHENZHEN) CO LTD
7 Cites 9 Cited by

AI-Extracted Technical Summary

Problems solved by technology

[0004] Based on this, it is necessary to provide a data parameterization implementation method and device for the problem that traditional test cases ca...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Method used

In the present embodiment, according to configuration test case such as configuration test property data, concurrent number, total request number, response result condition and parameter file, test case structure is simple, has shortened test preparation time, can support pressure quickly and effectively test task.
In the present embodiment, configuration test cases such as test attribute data, concurrent number, total request number, response result condition, parameter file and pressure machine according to configuration, test case structure is simple, has shortened test preparation time, can quickly Effectively support stress testing tasks; multiple parameter files can be supported by using associated parameter files, and the correlation of values ​​in multiple parameter files can be guaranteed in one iteration, more realistically simulating the user's usage scenarios; by selecting Data and parameterized data templates configure test cases, which makes the operation easier, reduces the operational requirements for generating test cases, and saves test preparation time.
In the present embodiment, the implementation method of data parameterization, by obtaining the placeholder in the configured test case, after determining the placeholder type, obtain the corresponding parameterization strategy according to the placeholder type, according to the parameterization The strategy uses placeholders to generate corresponding instantiated data. Because placeholders are used to occupy positions, corresponding instantiated data can be dynamically generated, and corresponding instantiated data can be obtained by adjusting parameters according to different test scenarios to meet different needs and expand scope of application. By setting the total number of iterations, it is judged whether the iteration test is completed, and the pressure test is realized, and the test is simple.
[0059] In this embodiment, the ...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Abstract

The invention relates to a method and device for achieving data parameterization. The method comprises the following steps: obtaining a placeholder in a configured test case; judging the type of the placeholder; according to the type of the placeholder, obtaining a corresponding preset parameterization strategy; adopting the parameterization strategy to make the placeholder generate corresponding instantiation data. According to the method and device for achieving the data parameterization, the placeholder in the configured test case is obtained, after the type of the placeholder is judged, the corresponding parameterization strategy is obtained according to the type of the placeholder, and the corresponding instantiation data is generated according to the parameterization strategy; since placeholder occupying position is adopted, the corresponding instantiation data can be dynamically generated and is obtained by adjusting parameters according to different test scenes, different needs are met, and the application scope is expanded.

Application Domain

Technology Topic

Test caseTest scene

Image

  • Method and device for achieving data parameterization
  • Method and device for achieving data parameterization
  • Method and device for achieving data parameterization

Examples

  • Experimental program(1)

Example Embodiment

[0026] In order to make the objectives, technical solutions and advantages of the present invention clearer, the following further describes the present invention in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.
[0027] It can be understood that the terms "first", "second", etc. used in the present invention can be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element. For example, without departing from the scope of the present invention, the first client may be referred to as the second client, and similarly, the second client may be referred to as the first client. Both the first client and the second client are clients, but they are not the same client.
[0028] figure 1 It is a schematic diagram of the application environment of the implementation method of data parameterization in an embodiment. Such as figure 1 As shown, the application environment includes a terminal 110 and a server 120. The terminal 110 and the server 120 perform data communication. The test tool running on the terminal 110 uses the test case to initiate an access request to the service on the server 120, and the server 120 responds to the access request initiated by the test case. The terminal 110 analyzes the response, and determines the maximum concurrency that can be processed by the service provided on the server 120, the response time, and other performance index data. The terminal 110 may be a personal computer, a tablet computer, a personal digital assistant, a wearable device, a smart phone, etc. The server 120 may be one or more computers, etc. Among them, the test case refers to the data used to detect the service performance of a certain service. The test case corresponds to the service. Different services have different types of test cases and different data content.
[0029] figure 2 It is a schematic diagram of the internal structure of the terminal in an embodiment. Such as figure 2 As shown, the terminal includes a processor, a nonvolatile storage medium, an internal memory, and a network interface connected through a system bus. Wherein, the non-volatile storage medium of the terminal stores an operating system, and also includes a data parameterization realization device, and the data parameterization realization device is used to realize a data parameterization realization method. The processor is used to provide computing and control capabilities to support the operation of the entire terminal. The internal memory in the terminal provides an environment for the operation of the device for realizing data parameterization in the non-volatile storage medium. The internal memory can store computer-readable instructions. When the computer-readable instructions are executed by the processor, The processor can be made to execute a method for realizing data parameterization. The network interface is used for network communication with the server, such as sending a test request to the server, and receiving response data returned by the server. The terminal can be a mobile phone, a tablet computer, or a personal digital assistant or a wearable device. Those skilled in the art can understand, figure 2 The structure shown in is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the terminal to which the solution of the present application is applied. The specific terminal may include more or less than that shown in the figure. , Or combine certain components, or have different component arrangements.
[0030] image 3 It is a flowchart of a method for realizing data parameterization in an embodiment. Such as image 3 As shown, an implementation method of data parameterization runs on figure 1 with figure 2 In the terminal, including:
[0031] Step 302: Obtain a placeholder in the configured test case.
[0032] In this embodiment, the test case refers to data used to detect the service performance of a certain service. The test case corresponds to the service. Different services have different types of test cases and different data content. For example, order service, the test case can include login data, order data of unpaid status, etc. Configured test cases refer to test cases that are dynamically configured according to a parameterized strategy, and some placeholders are included in the configured test cases. A placeholder is a symbol used to occupy a fixed position to indicate that this position will eventually be replaced. The placeholder can be preset as needed. For example, the placeholder can be %s, which means that it can be replaced by lowercase characters. The placeholder can be %10d, which means that it can be replaced by 10 decimal digits.
[0033] Step 304: Determine the type of placeholder.
[0034] In this embodiment, the placeholder type is used to represent the placeholder category, and the placeholder type includes formatting type and modifier. Formatting types can include lowercase character string, uppercase character string, decimal, octal, hexadecimal lowercase, hexadecimal uppercase, parameter file access, etc. Among them, the lowercase string can be represented by the first character, such as s; the uppercase string can be represented by the second character, such as S; decimal can be represented by d; octal can be represented by o; hexadecimal lowercase can be represented by x; The hexadecimal uppercase can be represented by X; the parameter file can be represented by the third character, such as p. Modifiers can include the first modifier (such as h) that indicates that the word length is 16 when randomly generating numeric type parameters, the second modifier that indicates that the word length is 64 when randomly generating numeric type parameters, or the second modifier that is taken in order when taking parameter files (such as m). Represents the third modifier (such as r) with the same random value in the same iteration when the value is randomly generated, and the fourth modifier (such as I) that indicates that the generated data is an atomic self-increment type. The modifier is determined according to the format type that follows, and is a supplement to the format type of the parameter. For example, the second modifier m generally cooperates with the formatting type p. If there is a modifier m, it means the order is taken, otherwise it means to take a line in the parameter file randomly.
[0035] Step 306: Obtain a corresponding preset parameterized strategy according to the type of placeholder.
[0036] In this embodiment, the corresponding relationship between the placeholder type and the parameterized strategy is pre-established. According to the placeholder type, the corresponding parameterized strategy can be found from the corresponding relationship between the placeholder type and the parameterized strategy. For example, if the placeholder type is parameter file, the corresponding parameterization strategy can be that the position of the parameter file is the same in multiple places in the same iteration, or the position is increased by 1 each time the parameter file is referenced.
[0037] The placeholder type is %010x, and the corresponding parameterization strategy is to generate fixed 10 lowercase hexadecimal characters. The placeholder type is %s, and the corresponding parameterization strategy is to generate a random string composed of lowercase a to z, and the length is random.
[0038] Parameterized strategy refers to the way to process parameters. The parameterized strategy can support the generation of fixed-length/random-length uppercase/lowercase strings, random but specified length numbers, and support the generation of self-increasing number sequences (such as binary, octal, decimal, hexadecimal, etc.) ), support to read one line randomly or sequentially from a given parameter file as a parameter sequence, support in the same parameterization iteration, the random value is the same or different, and the sequence position is the same or different. Among them, the random value can be controlled in the same iteration process, and the parameterized values ​​of multiple parameterized placeholders are the same, or it can be controlled in the same iteration process, and the parameterized values ​​of multiple parameterized placeholders are different. . The sequence position can be controlled in the same iteration process, when the parameter file is referenced in multiple places, the position is the same, and it can also be controlled in the same iteration process, when the parameter file is referenced in multiple places, the position is different.
[0039] Step 308: Use the parameterization strategy to generate corresponding instantiation data for the placeholder.
[0040] In this embodiment, data is acquired, a parameterized strategy is used to replace placeholders with corresponding data, and corresponding instantiation data is generated for the test case.
[0041] In this embodiment, the implementation method of data parameterization is to obtain the placeholders in the configured test cases, and after determining the type of the placeholder, obtain the corresponding parameterization strategy according to the type of the placeholder. Placeholders generate corresponding instantiation data. Because placeholders occupy positions, corresponding instantiation data can be dynamically generated, and corresponding instantiation data can be obtained by adjusting parameters according to different test scenarios to meet different needs and expand the scope of application.
[0042] In an embodiment, the method for realizing the above-mentioned data parameterization further includes: obtaining a tested target service, and configuring a test case according to the tested target service.
[0043] In this embodiment, the target service to be tested refers to a business service whose performance needs to be tested. Different services require different test cases. Configure corresponding test cases for the target service under test.
[0044] Figure 4 To obtain the tested target service in one embodiment, a schematic flow chart of configuring a test case according to the tested target service. Such as Figure 4 As shown, obtaining the tested target service, and configuring the test case according to the tested target service includes:
[0045] Step 402: Obtain test attribute data of the tested target service.
[0046] In this embodiment, the test attribute data refers to data used to represent the service of this test and the identity of the test terminal. The test attribute data of the tested target service may include the URL (Uniform Resoure Locator, uniform resource locator) of the tested target service, cookie (may include user identification and SSID), post (transmission data content), etc. Cookie is a way for the server or script to maintain information on the client workstation under the HTTP (Hyper Text Transfer Protocol) protocol. A cookie is a text file saved by a web server on the user's browser and can contain information about the user. SSID refers to Service Set Identifier, which is used to indicate the name of a local area network. Post places the transmitted data in the body of the HTTP packet.
[0047] The tester or other personnel configure the test attribute data of the tested target service through the terminal.
[0048] Step 404: Acquire the configured concurrent number, total number of requests, response result check conditions, parameter file and test environment.
[0049] In this embodiment, the number of concurrency refers to the total number of TCPs connected to the server per second when the client initiates a request to the server and establishes a TCP (Transmission Control Protocol) connection.
[0050] The total number of requests is the number of concurrent times multiplied by the number of single concurrent requests. The number of single concurrent requests refers to the number of single concurrent requests, that is, the number of single concurrent requests.
[0051] The response result check condition refers to the condition that the test expects to obtain the response result that needs to meet. The response result check condition can be configured as a regular expression, and the response result can be matched with a regular expression. If there is a match, the test is considered to be passed in this iteration, otherwise the test is considered to be failed. The regular expression can be set as required, such as length: [3-9].
[0052] The parameter file may include files such as test account and login status. The test account refers to the trial account set in the login state for testing. The login state refers to the state of logging in through a registered account.
[0053] Test environment refers to the general term for computer hardware, software, network equipment, and historical data necessary to complete software testing.
[0054] In addition, pressure machines are also available. The pressure machine refers to the machine that simulates the client. The pressure machine corresponds to the test environment. The number of pressure machines is selected according to the test requirements.
[0055] Step 406: Configure test cases according to the test attribute data, the number of concurrent requests, the total number of requests, the response result check condition, the parameter file and the test environment.
[0056] In this embodiment, the test cases are configured according to the configured test attribute data, the number of concurrency, the total number of requests, response result conditions, and parameter files. The test case structure is simple, the test preparation time is shortened, and the stress test task can be quickly and effectively supported.
[0057] In an embodiment, the test case can also be configured according to the configured test attribute data, the number of concurrency, the total number of requests, the response result check condition, the parameter file, the test environment, and the pressure machine.
[0058] In one embodiment, the obtaining the tested target service, configuring the test case according to the tested target service, further includes: obtaining the configured associated parameter file; according to the test attribute data, the number of concurrency, the total number of requests, and the response Results check conditions, parameter files, test environment and associated parameter files to configure test cases.
[0059] In this embodiment, the associated parameter file refers to the sequence of the parameter file and the position association when the placeholder in the parameterization refers to the parameter file. The use of associated parameter files can support multiple parameter files, and the correlation of values ​​in multiple parameter files can be guaranteed in one iteration, which more realistically simulates the user's use scenario.
[0060] In one embodiment, said obtaining the target service under test, configuring test cases according to the target service under test, further includes: obtaining database data and test attribute data templates; according to the test attribute data, the number of concurrency, and the total number of requests , Response result check conditions, parameter files, test environment, associated parameter files, database data and parameterized data template configuration test cases.
[0061] In this embodiment, the database data can be used as a data source for replacing placeholders in the test case. The data in the configuration database refers to which data is configured for test cases. Construct test data based on database data and parameterized data templates, and then generate test cases based on the constructed test data. A template refers to a fixed format of something. A parameterized data template refers to a fixed format for parameterization of data. Multiple parameter files can be supported by associating parameter files, and the relevance of values ​​in multiple parameter files can be guaranteed in one iteration, which more realistically simulates the user's use scenario, by selecting data in the database and parameterized data template configuration Test cases are easier to operate, which reduces the operational requirements for generating test cases and saves test preparation time.
[0062] In one embodiment, database data and test attribute data templates can also be obtained; according to the test attribute data, the number of concurrent requests, the total number of requests, the response result check condition, the parameter file, the test environment, the pressure machine, the associated parameter file, Database data and parameterized data template configuration test cases.
[0063] In one embodiment, said obtaining the target service under test, configuring test cases according to the target service under test, further includes: obtaining database data and test attribute data templates; according to the test attribute data, the number of concurrency, and the total number of requests , Response result check conditions, parameter files, test environment, database data and parameterized data template configuration test cases.
[0064] In this embodiment, the database data can be used as a data source for replacing placeholders in the test case. Configure the data in the database to configure which data is used by the test case. A template refers to a fixed format of something. A parameterized data template refers to a fixed format for parameterization of data. By selecting the data in the database and the parameterized data template to configure the test cases, the operation is easier, the operation requirements for generating test cases are reduced, and the test preparation time is saved.
[0065] In an embodiment, test cases can also be configured according to the test attribute data, the number of concurrency, the total number of requests, the response result check condition, the parameter file, the test environment, the pressure machine, the database data, and the parameterized data template.
[0066] Figure 5 To obtain a tested target service in an embodiment, a detailed flow diagram of configuring a test case according to the tested target service. Such as Figure 5 As shown, obtaining the tested target service, and configuring the test case according to the tested target service includes:
[0067] Step 502: Obtain test attribute data of the tested target service.
[0068] In this embodiment, the test attribute data refers to data used to represent the service of this test and the identity of the test terminal. The test attribute data of the tested target service may include the URL, cookie and post of the tested target service. Cookie is a way in which the server or script can maintain information on the client workstation under the HTTP (Hyper Text Transfer Protocol) protocol. A cookie is a text file saved by a web server on the user's browser and can contain information about the user. SSID refers to Service Set Identifier, which is used to indicate the name of a local area network. Post is to place the transmitted data in the body of the HTTP packet.
[0069] Step 504: Obtain the configured concurrent number, total number of requests, response result check conditions, parameter file, test environment and pressure machine.
[0070] In this embodiment, the number of concurrency refers to the total number of TCP connections to the server per second when the client initiates a request to the server and establishes a TCP connection. The total number of requests is the number of concurrent times multiplied by the number of single concurrent requests. The number of single concurrent requests refers to the number of single concurrent requests, that is, the number of single concurrent requests. The response result check condition refers to the condition that the test expects to obtain the response result that needs to meet. The response result check condition can be configured as a regular expression, and the response result can be matched with a regular expression. If there is a match, the test is considered to be passed in this iteration, otherwise the test is considered to be failed. The regular expression can be set as required, such as length: [3-9]. The parameter file may include files such as test account and login state cookie. The test account refers to the trial account set in the login state for testing. The login state refers to the state of logging in through a registered account. Test environment refers to the general term for computer hardware, software, network equipment, and historical data necessary to complete software testing. The pressure machine refers to the machine that simulates the client. The pressure machine corresponds to the test environment. The number of pressure machines is selected according to the test requirements.
[0071] In step 506, it is determined whether the configured parameter file needs to be associated, if so, step 508 is executed, and if not, step 510 is executed.
[0072] In this embodiment, it is determined whether the configured parameter file needs to be associated, if it is, then the parameter file is associated, if it is not, then it is further judged whether database data is needed, and if it is, the parameterized data template is obtained, and the test data is constructed. If necessary, configure test cases.
[0073] Step 508: Associate the parameter file, and then perform step 510.
[0074] In step 510, it is determined whether database data is needed, if so, step 512 is executed, and if not, step 514 is executed.
[0075] Step 512, obtain a parameterized data template, construct test data, and then execute step 514.
[0076] Step 514: Configure test cases.
[0077] In this embodiment, the test case is configured according to the configured test attribute data, number of concurrency, total number of requests, response result conditions, parameter file and pressure machine, etc. The test case structure is simple, the test preparation time is shortened, and the test preparation time can be quickly and effectively supported. Stress test tasks; the use of associated parameter files can support multiple parameter files, and the correlation of values ​​in multiple parameter files can be guaranteed in one iteration, which more realistically simulates the user's use scenario; by selecting data and parameters in the database The data template configuration test case is easier to operate, which reduces the operational requirements for generating test cases and saves test preparation time.
[0078] In other embodiments, the pressing machine in step 504 may be omitted.
[0079] Image 6 It is a flowchart of a method for implementing data parameterization in another embodiment. Such as Image 6 As shown, in one embodiment, a method for realizing data parameterization includes the following steps:
[0080] Step 602: Obtain the total amount of test cases, and use the total amount as the total number of iterations.
[0081] In this embodiment, the total number of test cases refers to the total number of test cases, and the total number of stress tests can be used as the total number of test cases. An iterative test uses one test case, and the total number of test cases is the total number of iterations.
[0082] Step 604: Obtain the set current iteration number.
[0083] In this embodiment, the current iteration number refers to the number of iteration tests being performed in the iteration test. For example, the total number of iterations is N, recorded as 1 to N times, and the current iteration number is L, so L represents the Lth iteration.
[0084] Step 606: Obtain a placeholder in the configured test case.
[0085] In this embodiment, the placeholder refers to a symbol used to occupy a fixed position and to indicate that the position will eventually be replaced.
[0086] Step 608: Determine the type of placeholder.
[0087] In this embodiment, the placeholder type is a placeholder type used to indicate a placeholder category, including formatting types and modifiers.
[0088] Step 610: Obtain a corresponding preset parameterized strategy according to the type of placeholder.
[0089] In this embodiment, the corresponding relationship between the placeholder type and the parameterized strategy is pre-established. According to the placeholder type, the corresponding parameterized strategy can be found from the corresponding relationship between the placeholder type and the parameterized strategy.
[0090] Step 612: Use the parameterization strategy to generate corresponding instantiation data for the placeholder.
[0091] In step 614, it is judged whether there is a placeholder in the test case of the current iteration number, if so, step 606 is executed, and if not, step 616 is executed.
[0092] Step 616: Determine whether the current number of iterations is greater than or equal to the total number of iterations; if yes, end; if not, execute step 604.
[0093] In this embodiment, when it is determined that the current number of iterations is less than the total number of iterations, the set current number of iterations is obtained, and steps 606 to 616 are continued to be executed until the current number of iterations is equal to or greater than the total number of iterations.
[0094] In this embodiment, the implementation method of data parameterization is to obtain the placeholders in the configured test cases, and after determining the type of the placeholder, obtain the corresponding parameterization strategy according to the type of the placeholder. Placeholders generate corresponding instantiation data. Because placeholders occupy positions, corresponding instantiation data can be dynamically generated, and corresponding instantiation data can be obtained by adjusting parameters according to different test scenarios to meet different needs and expand the scope of application. By setting the total number of iterations, it is judged whether the iterative test is completed, and the stress test is realized, and the test is simple.
[0095] The following describes the implementation method of data parameterization in conjunction with specific application scenarios. Two scenarios of user request and database data construction in the tested target service of HTTP protocol are taken as examples to describe.
[0096] First, use the aforementioned data parameterization method to parameterize the URL, cookie, and post content in the user request.
[0097] In this embodiment, the format is similar to the printf function in the c language, such as %010d, %010x%s%p, and the specific parameterization strategy is as follows: %010d means that this will be replaced with a 10-digit random number, which is less than 10 Leading 0 for bit hour, for example 0123456789. %010x means to generate fixed 10 lowercase hexadecimal characters, such as 123456789a. %S means to generate a random string consisting of lowercase a to z, with a random length. %P means that this will be replaced with a random line in the parameter file. %Mp means that every iteration here will be replaced with the first line to the last line in the parameter file. %0p means that the replacement here is to take the content in the first parameter file. %1p means that the replacement here is to take the content in the second parameter file. In addition, it also supports the -i parameter. When there are two %mps in the parameterization, they will be replaced with the same line number in the two parameter files. If the -i parameter is not specified, the two %mps are being replaced At the time, the line number pointed to by the second %mp is the line number of the first %mp plus 1.
[0098] In this embodiment, taking the CGI (Common Gateway Interface) of the card shared by friends as an example, the URL content of the service is http://abc.com/tws/greetcard/GetCard? uin=xxx&packageid=xxx; cookie content is uin=xxx, ssid=xxx.
[0099] There are three variable parameters in URL and cookie: uin (unit identity name, unique identity credential), packageid (card id), and SSID (10-digit decimal random number). Since there is a limit to the number of cards received by the same friend, it is generally limited to only once. Therefore, when stress testing the CGI, a large number of cards (corresponding to the parameter packageid) that belong to different friends (corresponding to the parameter uin) need to be prepared to avoid a single friend’s Receipt quantity limit to realize stress test. Suppose uin is stored in the first parameter file abc_uin.txt, and packageid is stored in the second parameter file package_id.txt, such as Figure 7 Shown.
[0100] In the stress test process, each iteration of instantiating uin and packageid needs to maintain the one-to-one correspondence between packageid and uin, and keep the uin in the URL consistent with the uin in the cookie, the test case configuration is as follows:
[0101] (1) Set the request URL content as:
[0102] http://chong.abc.com/tws/greetcard/GetCard? uin=%0lp&packageid=%1lp
[0103] (2) Set the cookie content as uin=%0mp; ssid=%010d.
[0104] (3) Set the first parameter file abc_uin.txt and the second parameter file package_id.txt as the synchronous update parameter file. When the parameters are instantiated during the stress test, the parameter uin takes the value from the first parameter file abc_uin.txt , Packageid takes the value from the second parameter file package_id.txt, and takes the value of the same line number in the two parameter files for each iteration, and the uin in the URL and cookie takes the same line value in abc_uin.txt for each iteration. SSID is a dynamically generated random number, and the following request data is obtained:
[0105] http://chong.adc.com/tws/greetcard/GetCard? uin=1195667267&packageid=test_pack775030785(cookie:uin=1195667267; ssid=7790620533)
[0106] http://chong.abc.com/tws/greetcard/GetCard? uin=1224507247&packageid=test_pack445595964(cookie:uin=1224507247; ssid=2365415897)
[0107] http://chong.abc.com/tws/greetcard/GetCard? uin=1274969732&packageid=test_pack966887652 (cookie: uin=1274969732; ssid=5426589635)
[0108]......
[0109] When the number of parameter files is greater than 2, the method of associating parameter files can also be used to maintain the correlation of values ​​between multiple parameter files and the same value when the same parameter file is referenced in multiple places.
[0110] Second, construct the data in the database according to the specified parameterization strategy.
[0111] In this embodiment, for the parameterization strategy of sub-database and sub-tables, fill in the number of sub-libraries and sub-tables in the parameterized data template. Among them, the number of sub-libraries refers to the number of sub-libraries of the database. The number of sub-tables refers to the number of data tables contained in each sub-database. In the sub-database sub-table field, fill in the placeholder for the position of the sub-data table field in the data table (that is, which field belongs to in the data table, starting from 0, the default is -1 when there is no database and no table), The sub-library index value and sub-table index value are calculated by the following formula.
[0112] Sub-library index value = sub-library sub-table field/sub-table number% sub-library number
[0113] Sub-table index value = sub-database sub-table field% sub-table number
[0114] Among them,% means to take the remainder.
[0115] Suppose the table structure of the test data needs to be constructed as shown in Table 1.
[0116] Table 1
[0117]
[0118]
[0119] Among them, uid refers to the unique identity credential, and name is the user name.
[0120] Assuming that the number of sub-databases is 128, the number of sub-tables is 10, and the uid is used as the sub-database sub-table field, fill in the sub-database sub-table field placeholder with 0, and the value of the uid field will be taken as the sub-database sub-table field value when constructing the data For example, the data with uid of 1200000549 will be divided into sub-databases and sub-tables as follows:
[0121] Sub-library index value = 1200000549/10% 128 = 54
[0122] Sub-table index value = 1200000549% 10 = 9
[0123] In this embodiment, for the parameterization strategy of the field, a parameterized placeholder is used to indicate the specific parameterization strategy, and the parameterized placeholder is expressed by a formatter similar to the format function in the C language, and the format is %[ field_width][qualifier] , The meaning of the three parts and examples of usage rules are as follows:
[0124] (1) field_width: bit width, an integer number or *, the length of the string or number after parameterization does not exceed the length indicated by it, for example: when it is greater than 0, it means right justification...
[0125] In this embodiment, field_width defines the bit width, which parameter file starts from, the initial value of the parameter, the initial value when the atom is incremented, and so on.
[0126] (2) qualifier: modifier, such as:
[0127] h: The generated number is two bytes (short integer)
[0128] I: The generated number is increased by 1 from the previous iteration, and the initial value is specified by field_width. ......
[0129] Among them, h indicates that the word length is 16 when randomly generating a numeric type parameter; I indicates that the generated data is an atomic self-increment type.
[0130] (3) format: format type, such as:
[0131] s: Generate a-z string
[0132] p: Quote a line in the parameter file. Among them, the specific reference number of the parameter file is specified by field_width (the first one starts from 0). When the qualifier is m, it means to quote the first line to the nth line of the parameter file in turn. If there is no qualifier, it means to quote a line in the parameter file randomly.
[0133]......
[0134] After adding a data template of a table, when adding another data template of a related table, the related fields between the two are represented by %rd or %rx. During the data creation process, the two related fields generate decimal numbers Or the same as the hexadecimal number.
[0135] Examples of parametric effects:
[0136] %010d means to generate a decimal number with a length of up to 10 characters. If it is less than 10 characters long, it will be filled with 0 in front.
[0137] %0lp means to reference the first parameter file in sequence.
[0138] a=%010rX&b=%010rX means that the values ​​of a and b are the same randomly generated hexadecimal numbers, but the values ​​generated for the second time and the first time are different.
[0139] %10086Id means that an integer of 10086 will be generated in the first iteration, 10087 will be generated in the second iteration, and so on.
[0140] In addition, the above-mentioned data parameterization method can be applied to other scenarios that require parameterization in addition to being applied to stress testing.
[0141] Figure 8 It is a structural block diagram of a device for realizing data parameterization in an embodiment. Such as Figure 8 As shown, a device 800 for realizing data parameterization includes a placeholder acquisition module 802, a determination module 804, a parameterization strategy acquisition module 806, and a generation module 808. among them:
[0142] The placeholder acquiring module 802 is used to acquire the placeholder in the configured test case.
[0143] The determining module 804 is used to determine the type of the placeholder.
[0144] The parameterized strategy obtaining module 806 is configured to obtain a corresponding preset parameterized strategy according to the placeholder type.
[0145] The generating module 808 is configured to use the parameterized strategy to generate corresponding instantiation data for the placeholder.
[0146] In this embodiment, the method for implementing data parameterization is to obtain the placeholders in the configured test cases, and after determining the type of the placeholder, obtain the corresponding parameterization strategy according to the type of the placeholder. The placeholder generates the corresponding instantiation data. Because the placeholder is used to occupy the position, the corresponding instantiation data can be dynamically generated. The corresponding instantiation data can be adjusted according to different test scenarios to meet different needs and expand the scope of application .
[0147] Picture 9 It is a block diagram of a device for realizing data parameterization in another embodiment. Such as Picture 9 As shown, a device 800 for realizing data parameterization includes a placeholder acquisition module 802, a determination module 804, a parameterization strategy acquisition module 806, and a generation module 808, and also includes a configuration module 810. among them:
[0148] The configuration module 810 is used to obtain the tested target service, and configure test cases according to the tested target service.
[0149] Such as Picture 9 As shown, the configuration module 810 includes a first obtaining unit 8101, a second obtaining unit 8102, and a configuration unit 8103.
[0150] The first obtaining unit 8101 is used to obtain test attribute data of the tested target service.
[0151] The second obtaining unit 8102 is used to obtain the configured concurrent number, total number of requests, response result check conditions, parameter files, test environment and pressure machine.
[0152] The configuration unit 8103 is configured to configure test cases according to the test attribute data, the number of concurrent requests, the total number of requests, the response result check condition, the parameter file, the test environment and the pressure machine.
[0153] In this embodiment, the test case is configured according to the configured test attribute data, number of concurrency, total number of requests, response result conditions, parameter file and pressure machine, etc. The test case structure is simple, the test preparation time is shortened, and the test preparation time can be quickly and effectively supported. Stress test task.
[0154] Further, the configuration module 810 further includes a third acquiring unit 8104. The third obtaining unit 8104 is configured to obtain the associated parameter file of the configuration.
[0155] The configuration unit 8103 is further configured to configure test cases according to the test attribute data, the number of concurrent requests, the total number of requests, the response result check condition, the parameter file, the test environment, the pressure machine, and the associated parameter file.
[0156] Further, the configuration module 810 further includes a fourth obtaining unit 8105.
[0157] The fourth obtaining unit 8105 is used to obtain database data and test attribute data templates.
[0158] The configuration unit 8103 is also used to configure the test according to the test attribute data, the number of concurrency, the total number of requests, the response result check condition, the parameter file, the test environment, the pressure machine, the associated parameter file, the database data, and the parameterized data template. Example.
[0159] Alternatively, the configuration unit 8103 is further configured to configure test cases according to the test attribute data, the number of concurrency, the total number of requests, the response result check condition, the parameter file, the test environment, the pressure machine, the database data and the parameterized data template.
[0160] Picture 10 It is a block diagram of a device for realizing data parameterization in another embodiment. Such as Picture 10 As shown, a device for realizing data parameterization includes a placeholder acquisition module 802, a determination module 804, a parameterization strategy acquisition module 806, and a generation module 808, as well as a total iteration number acquisition module 812, a counting module 814, and a judgment module. Module 816. among them:
[0161] The total number of iterations obtaining module 812 is configured to obtain the total number of test cases before obtaining the placeholders in the configured test cases, and use the total number as the total number of iterations.
[0162] The counting module 814 is used to obtain the set current iteration number.
[0163] The judging module 816 is configured to, after the use of the parameterization strategy to generate the corresponding instantiation data for the placeholder, determine whether there is a placeholder in the test case of the current iteration number, and if so, then The placeholder acquisition module executes the acquisition of the placeholders in the configured test case, if not, it is determined whether the current iteration number is greater than or equal to the total iteration number, if yes, it ends, if not , The counting module is also used to obtain the set current iteration number, and continue to iterate until the current iteration number is equal to or greater than the total iteration number.
[0164] In other embodiments, a device for realizing data parameterization may include a placeholder acquisition module 802, a determination module 804, a parameterization strategy acquisition module 806, a generation module 808, a configuration module 810, and a total iteration number acquisition module 812, All possible combinations of counting module 814 and judging module 816.
[0165] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through a computer program. The program can be stored in a non-volatile computer readable storage medium. Here, when the program is executed, it may include the procedures of the above-mentioned method embodiments. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), etc.
[0166] The above-mentioned embodiments only express several implementation modes of the present invention, and their description is more specific and detailed, but they should not be interpreted as a limitation on the patent scope of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can be made, and these all fall within the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention should be subject to the appended claims.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Similar technology patents

Classification and recommendation of technical efficacy words

Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products