CN106681921B - Method and device for realizing data parameterization - Google Patents

Method and device for realizing data parameterization Download PDF

Info

Publication number
CN106681921B
CN106681921B CN201611229995.4A CN201611229995A CN106681921B CN 106681921 B CN106681921 B CN 106681921B CN 201611229995 A CN201611229995 A CN 201611229995A CN 106681921 B CN106681921 B CN 106681921B
Authority
CN
China
Prior art keywords
test
data
placeholder
parameter file
acquiring
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611229995.4A
Other languages
Chinese (zh)
Other versions
CN106681921A (en
Inventor
蒋艳锋
符阳辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201611229995.4A priority Critical patent/CN106681921B/en
Publication of CN106681921A publication Critical patent/CN106681921A/en
Application granted granted Critical
Publication of CN106681921B publication Critical patent/CN106681921B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to a method and a device for realizing data parameterization. The method comprises the following steps: acquiring a placeholder in a configured test case; determining the placeholder type; acquiring a corresponding preset parameterization strategy according to the placeholder type; and generating corresponding instantiation data of the placeholder by adopting the parameterization strategy. According to the data parameterization implementation method and device in the embodiment, the placeholder in the configured test case is obtained, the type of the placeholder is judged, the corresponding parameterization strategy is obtained according to the placeholder type, the placeholder is generated into corresponding instantiation data according to the parameterization strategy, the corresponding instantiation data can be dynamically generated due to the fact that the placeholder occupies the position, the corresponding instantiation data can be obtained according to different test scene adjustment parameters, different requirements are met, and the application range is expanded.

Description

Method and device for realizing data parameterization
Technical Field
The present invention relates to the field of data processing, and in particular, to a method and an apparatus for implementing data parameterization.
Background
With the improvement of internet coverage and terminal popularity, the user volume of internet services is very huge, and especially when some activities are popularized or some operations are performed in a centralized manner at a special moment, high concurrency access to services in a production environment is brought.
The test cases used by the traditional pressure test tool are generally fixed test cases in user requests, can only be used for a single test scene, cannot be expanded to other scenes, and are limited in application range.
Disclosure of Invention
Therefore, it is necessary to provide a method and a device for implementing data parameterization aiming at the problem that the traditional test case only aims at a single scene and has a limited application range, so that the method and the device can be applied to different scenes and the application range is expanded.
A method for realizing data parameterization comprises the following steps:
acquiring a placeholder in a configured test case;
determining the placeholder type;
acquiring a corresponding preset parameterization strategy according to the placeholder type;
and generating corresponding instantiation data of the placeholder by adopting the parameterization strategy.
An implementation device for data parameterization comprises:
the placeholder acquiring module is used for acquiring placeholders in the configured test cases;
a determination module to determine the placeholder type;
the parameterized policy acquisition module is used for acquiring a corresponding preset parameterized policy according to the placeholder type;
and the generation module is used for generating corresponding instantiation data from the placeholder by adopting the parameterization strategy.
According to the data parameterization implementation method and device in the embodiment, the placeholder in the configured test case is obtained, the type of the placeholder is judged, the corresponding parameterization strategy is obtained according to the placeholder type, the placeholder is generated into corresponding instantiation data according to the parameterization strategy, the corresponding instantiation data can be dynamically generated due to the fact that the placeholder occupies the position, the corresponding instantiation data can be obtained according to different test scene adjustment parameters, different requirements are met, and the application range is expanded.
Drawings
FIG. 1 is a diagram of an application environment of a method for implementing data parameterization in one embodiment;
fig. 2 is a schematic diagram of the internal structure of the terminal in one embodiment;
FIG. 3 is a flow diagram of a method for implementing data parameterization in one embodiment;
FIG. 4 is a schematic flow chart illustrating an embodiment of obtaining a target service under test and configuring a test case according to the target service under test;
FIG. 5 is a detailed flowchart illustrating an embodiment of obtaining a target service under test and configuring a test case according to the target service under test;
FIG. 6 is a flow chart of a method for performing data parameterization in another embodiment;
FIG. 7 is a diagram of a parameter file in one embodiment;
FIG. 8 is a block diagram showing an example of an apparatus for implementing data parameterization;
FIG. 9 is a block diagram showing an apparatus for implementing data parameterization according to another embodiment;
FIG. 10 is a block diagram showing an apparatus for implementing data parameterization according to another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
It will be understood that, as used herein, the terms "first," "second," and the like may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, a first client may be referred to as a second client, and similarly, a second client may be referred to as a first client, without departing from the scope of the present invention. Both the first client and the second client are clients, but they are not the same client.
FIG. 1 is a diagram illustrating an application environment of a method for implementing data parameterization in one embodiment. As shown in fig. 1, the application environment includes a terminal 110 and a server 120. The terminal 110 is in data communication with the server 120. The test tool running on the terminal 110 initiates an access request to the service on the server 120 using the test case, and the server 120 responds to the access request initiated by the test case. The terminal 110 analyzes the response and determines various performance index data such as the maximum concurrency amount and response time that can be processed by the service provided by the server 120. The terminal 110 may be a personal computer, a tablet computer, a personal digital assistant, a wearable device, a smartphone, or the like. The server 120 may be one or more computers or the like. The test case refers to data for detecting service performance of a certain service. The test cases correspond to services. Different services, different types of test cases, and different data contents.
Fig. 2 is a schematic diagram of an internal structure of the terminal in one embodiment. As shown in fig. 2, the terminal includes a processor, a nonvolatile storage medium, an internal memory, and a network interface, which are connected through a system bus. The non-volatile storage medium of the terminal stores an operating system and further comprises a data parameterization implementation device, and the data parameterization implementation device is used for implementing a data parameterization implementation method. The processor is used for providing calculation and control capability and supporting the operation of the whole terminal. The internal memory of the terminal provides an environment for the operation of the data parameterization implementation device in the nonvolatile storage medium, and the internal memory can store computer readable instructions which can be executed by the processor to cause the processor to execute a data parameterization implementation method. The network interface is used for performing network communication with the server, such as sending a test request to the server, receiving response data returned by the server, and the like. The terminal can be a mobile phone, a tablet computer, a personal digital assistant or a wearable device. Those skilled in the art will appreciate that the configuration shown in fig. 2 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation on the terminal to which the present application is applied, and that a particular terminal may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
FIG. 3 is a flow diagram of a method for performing data parameterization in one embodiment. As shown in fig. 3, an implementation method for parameterizing data, running on the terminal in fig. 1 and 2, includes:
step 302, acquiring placeholders in configured test cases.
In this embodiment, the test case refers to data used for detecting service performance of a certain service. The test cases correspond to services. Different services, different types of test cases, and different data contents. Such as order service, the test case may include log data, order data for unpaid status, and the like. The configured test case refers to a test case which is dynamically configured according to a parameterization strategy, and the configured test case contains a plurality of placeholders. Placeholders are symbols that are used to occupy a fixed location to indicate that the location will eventually be replaced. The placeholders may be preset as desired. For example, the placeholder may be% s, meaning that it may be replaced by a lower case character. Placeholders may be% 10d, meaning that they may be replaced by 10 decimal digits, etc.
Step 304, determine the placeholder type.
In this embodiment, the placeholder type is used to represent the placeholder category, and the placeholder type includes a format type and a modifier. Formatting types may include lowercase strings, uppercase strings, decimal, octal, hexadecimal lowercase, hexadecimal uppercase, fetching parameter files, and so forth. Wherein, the lower case character string can be represented by a first character, such as s; the uppercase string may be represented by a second character, such as S; decimal may be represented by d; octals can be represented by o; the hexadecimal lowercase may employ x; hexadecimal capitalization may be represented by X; the parameter file may be represented by a third character, such as p. The modifiers may include a first modifier (e.g., h) indicating a word length of 16 when the value type parameter is randomly generated, a second modifier (e.g., m) indicating a word length of 64 when the value type parameter is randomly generated or sequentially taken when the parameter file is taken, a third modifier (e.g., r) indicating that the random values are the same in the same iteration when the value is randomly generated, and a fourth modifier (e.g., I) indicating that the generated data is of an atom-increasing type. The modifier is based on the following formatting type and is a complement to the formatting type of the parameter. For example, a second modifier m is generally associated with the format type p, and if the modifier m is present, the sequential fetching is indicated, otherwise the random fetching indicates a line in the parameter file.
And step 306, acquiring a corresponding preset parameterization strategy according to the placeholder type.
In this embodiment, a correspondence between a placeholder type and a parameterized policy is pre-established. And finding the corresponding parameterized strategy from the corresponding relation between the placeholder type and the parameterized strategy according to the placeholder type. For example, if the placeholder type is a parameter file, the corresponding parameterization policy may be that the positions of multiple references to the parameter file in the same iteration are the same, or that 1 is added to each reference to the parameter file.
The placeholder type is% 010x, and the corresponding parameterization strategy is to generate fixed 10 lower case 16-ary characters. The placeholder type is% s, the corresponding parameterization strategy is to generate a random character string composed of lower case a to z, the length is random, and the like.
A parameterized policy refers to the way parameters are processed. The parameterization strategy can support the generation of fixed-length/random-length upper/lower-case character strings, random numbers with specified length, the generation of self-increment number sequences (such as 2-system, 8-system, 10-system, 16-system numbers and the like), the random or sequential reading of a row from a given parameter file as a parameter sequence, and the random values are the same or different and the sequential positions are the same or different in the same parameterization iteration. The random value can be controlled to be in the same iteration process, the parameterized values of the parameterized placeholders at multiple positions are the same, and the parameterized values of the parameterized placeholders at multiple positions can also be controlled to be different in the same iteration process. The sequence position can be controlled in the same iteration process, the positions of a plurality of reference parameter files are the same, and the positions of a plurality of reference parameter files in the same iteration process can also be controlled to be different.
And 308, generating corresponding instantiation data for the placeholder by adopting the parameterization strategy.
In this embodiment, data is acquired, a parameterization strategy is adopted to replace the placeholder with corresponding data, and the test case generates corresponding instantiation data.
In the embodiment, the method for implementing data parameterization includes acquiring the placeholder in the configured test case, judging the type of the placeholder, acquiring the corresponding parameterization strategy according to the placeholder type, and generating corresponding instantiation data from the placeholder according to the parameterization strategy.
In one embodiment, the method for implementing data parameterization further includes: and acquiring a tested target service, and configuring a test case according to the tested target service.
In this embodiment, the target service to be tested refers to a service whose performance needs to be tested. The test cases required for different services are different. And configuring a corresponding test case aiming at the tested target service.
Fig. 4 is a schematic flow chart illustrating a process of acquiring a target service to be tested and configuring a test case according to the target service to be tested in one embodiment. As shown in fig. 4, acquiring a target service to be tested, and configuring a test case according to the target service to be tested includes:
step 402, obtaining test attribute data of the tested target service.
In this embodiment, the test attribute data refers to data used for representing the identity of the service and the test terminal of the current test. The test attribute data of the target service under test may include a URL (Uniform resource Locator), a cookie (which may include a user identifier and an SSID), a post (content of transfer data), and the like of the target service under test. Cookie is a way in which a server or script can maintain information on a client workstation under the HTTP (Hypertext Transfer Protocol) Protocol. Cookies are text files that are saved by a web server on a user's browser and may contain information about the user. The SSID is a 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 an HTTP packet.
And the tester or other personnel configures the test attribute data of the tested target service through the terminal.
Step 404, obtaining the configured concurrency number, total request number, response result checking condition, parameter file and testing environment.
In this embodiment, the concurrency number refers to the total number of TCP (Transmission Control Protocol) linked by a server per second, where the client initiates a request to the server and establishes a TCP connection.
The total number of requests is the number of concurrencies multiplied by the number of single concurrent requests. The single concurrent request number refers to the number of single concurrent requests, i.e., a single concurrent number.
The response result check condition refers to a condition that a response result expected by the test needs to be satisfied. The response result checking condition can be configured as a regular expression, and the response result is matched with the regular expression. If the two are matched, the test in the iteration is considered to pass, otherwise, the test is considered to fail. The regular expression can be set according to requirements, such as length: [3-9].
The parameter file can comprise a test account number, a login state and other files. The test account is a trial account set for testing a required login state. The login state refers to a state in which login is performed through a registered account.
The test environment is a generic term for computer hardware, software, network devices, and historical data necessary to perform software testing.
In addition, press machines are also available. By pressing machine is meant a machine that simulates a client. The pressing machine corresponds to a test environment. The number of pressing machines is selected according to the test requirements.
And 406, configuring a test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file and the test environment.
In the embodiment, the test cases are configured according to the configured test attribute data, the concurrent number, the total request number, the response result condition, the parameter file and the like, the test cases are simple in structure, the test preparation time is shortened, and the pressure test task can be supported quickly and effectively.
In one embodiment, the test case may also be configured according to configured test attribute data, concurrency number, total request number, response result check condition, parameter file, test environment, and stressing machine configuration test case.
In one embodiment, the obtaining the target service to be tested and configuring the test case according to the target service to be tested further includes: acquiring a configured associated parameter file; and configuring test cases according to the test attribute data, the concurrent number, the total request number, the response result checking condition, the parameter file, the test environment and the associated parameter file.
In this embodiment, associating the parameter file refers to associating the order of the parameter file and the position of the parameter file when the placeholder in the parameterization refers to the parameter file. The adoption of the associated parameter file can support a plurality of parameter files, and the association of values in the plurality of parameter files can be ensured in one iteration, so that the use scene of a user can be simulated more truly.
In one embodiment, the obtaining the target service to be tested and configuring the test case according to the target service to be tested further includes: acquiring database data and a test attribute data template; and configuring a test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment, the associated parameter file, the database data and the parameterized data template.
In this embodiment, the database data may serve as a data source for replacing placeholders in test cases. The data in the configuration database refers to which data is configured for use by the test case. And constructing test data according to the database data and the parameterized data template, and generating a test case according to the constructed test data. A template refers to a fixed format for something. The parameterized data template refers to a fixed format for parameterizing data. The method can support a plurality of parameter files through the associated parameter files, can ensure the association of values in the parameter files in one iteration, more truly simulates the use scene of a user, and configures the test case by selecting the data in the database and the parameterized data template, so that the method is simpler and more convenient to operate, reduces the operation requirement on generating the test case, and saves the test preparation time.
In one embodiment, database data and test attribute data templates may also be obtained; and configuring a test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment, the pressure applying machine, the associated parameter file, the database data and the parameterized data template.
In one embodiment, the obtaining the target service to be tested and configuring the test case according to the target service to be tested further includes: acquiring database data and a test attribute data template; and configuring a test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment, the database data and the parameterized data template.
In this embodiment, the database data may serve as a data source for replacing placeholders in test cases. The data in the configuration database configures which data to use for the test case. A template refers to a fixed format for something. The parameterized data template refers to a fixed format for parameterizing data. The test case is configured by selecting the data in the database and the parameterized data template, so that the operation is simpler and more convenient, the operation requirement for generating the test case is reduced, and the test preparation time is saved.
In one embodiment, the test case may be further configured according to the test attribute data, the concurrency number, the total number of requests, the response result check condition, the parameter file, the test environment, the pressing machine, the database data, and the parameterized data template.
Fig. 5 is a detailed flowchart illustrating the steps of obtaining a target service under test and configuring a test case according to the target service under test in one embodiment. As shown in fig. 5, acquiring a target service to be tested, and configuring a test case according to the target service to be tested includes:
step 502, test attribute data of the tested target service is obtained.
In this embodiment, the test attribute data refers to data used for representing the identity of the service and the test terminal of the current test. The test attribute data of the target service under test may include a URL, a cookie, a post, and the like of the target service under test. cookies are a way in which a server or script can maintain information on a client workstation under the HTTP (hypertext Transfer Protocol) Protocol. A cookie is a text file saved by a web server on the user's browser that may contain information about the user. The SSID is a 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 an HTTP packet.
Step 504, obtaining the configured concurrency number, the total request number, the response result checking condition, the parameter file, the testing environment and the pressing machine.
In this embodiment, the concurrency number refers to the total number of TCP linked by the server per second, where the client initiates a request to the server and establishes a TCP connection. The total number of requests is the number of concurrencies multiplied by the number of single concurrent requests. The single concurrent request number refers to the number of single concurrent requests, i.e., a single concurrent number. The response result check condition refers to a condition that a response result expected by the test needs to be satisfied. The response result checking condition can be configured as a regular expression, and the response result is matched with the regular expression. If the two are matched, the test in the iteration is considered to pass, otherwise, the test is considered to fail. The regular expression can be set according to requirements, such as length: [3-9]. The parameter file may include a test account number, a login state cookie, and the like. The test account is a trial account set for testing a required login state. The login state refers to a state in which login is performed through a registered account. The test environment is a generic term for computer hardware, software, network devices, and historical data necessary to perform software testing. By pressing machine is meant a machine that simulates a client. The pressing machine corresponds to a test environment. The number of pressing machines is selected according to the test requirements.
Step 506, determine whether the configured parameter file needs to be associated, if yes, execute step 508, if no, execute step 510.
In this embodiment, it is determined whether the configured parameter file needs to be associated, if so, the parameter file is associated, if not, it is further determined whether database data is needed, if so, a parameterized data template is obtained, test data is constructed, and if not, a test case is configured.
Step 508, associate the parameter file, and then execute step 510.
Step 510, determine whether database data is needed, if yes, go to step 512, otherwise go to step 514.
Step 512, obtaining a parameterized data template, constructing test data, and then executing step 514.
Step 514, configuring the test case.
In the embodiment, the test cases are configured according to the configured test attribute data, the concurrent number, the total request number, the response result condition, the parameter file, the pressure applying machine and the like, the test cases are simple in structure, the test preparation time is shortened, and the pressure test task can be quickly and effectively supported; the adoption of the associated parameter file can support a plurality of parameter files, and the association of values in the plurality of parameter files can be ensured in one iteration, so that the use scene of a user can be simulated more truly; the test case is configured by selecting the data in the database and the parameterized data template, so that the operation is simpler and more convenient, the operation requirement for generating the test case is reduced, and the test preparation time is saved.
In other embodiments, the pressing machine in step 504 may be omitted.
FIG. 6 is a flow chart of a method for implementing data parameterization in another embodiment. As shown in fig. 6, in one embodiment, a method for implementing data parameterization includes the following steps:
step 602, obtaining the total amount of the test cases, and taking the total amount as the total number of iterations.
In this embodiment, the total number of test cases refers to the total number of test cases, and the total number of times of the stress test may be used as the total number of test cases. One test case is used in one iteration test, and the total number of the test cases is used as the total number of iterations.
And step 604, acquiring the set current iteration number.
In this embodiment, the current iteration number refers to a number of times that the iteration test is being performed in the iteration test, for example, the total number of iterations is N, which is recorded as 1 to N times, and if the current iteration number is L, L represents the L-th iteration.
Step 606, obtain the placeholders in the configured test cases.
In this embodiment, the placeholder is a symbol for occupying a fixed position to indicate that the position is to be replaced.
Step 608, determine the placeholder type.
In this embodiment, the placeholder type is a placeholder type for representing a placeholder category and includes a format type and a modifier.
And step 610, acquiring a corresponding preset parameterization strategy according to the placeholder type.
In this embodiment, a correspondence between a placeholder type and a parameterized policy is pre-established. And finding the corresponding parameterized strategy from the corresponding relation between the placeholder type and the parameterized strategy according to the placeholder type.
Step 612, generating corresponding instantiation data for the placeholder by using the parameterization strategy.
Step 614, judging whether the test case of the current iteration times has placeholders, if so, executing step 606, and if not, executing step 616.
Step 616, determining whether the current iteration number is greater than or equal to the total iteration number, if so, ending, otherwise, executing step 604.
In this embodiment, when it is determined that the current iteration number is smaller than the total iteration number, the set current iteration number is obtained again, and steps 606 to 616 are continuously performed until the current iteration number is equal to or greater than the total iteration number.
In the embodiment, the method for implementing data parameterization includes acquiring the placeholder in the configured test case, judging the type of the placeholder, acquiring the corresponding parameterization strategy according to the placeholder type, and generating corresponding instantiation data from the placeholder according to the parameterization strategy. By setting the total iteration times, whether the iteration test is completed or not is judged, the pressure test is realized, and the test is simple and convenient.
The implementation method of data parameterization is described below with reference to specific application scenarios. Two scenarios of user request and database data construction in the tested target service of the HTTP protocol are taken as an example for description.
Firstly, the implementation method of data parameterization is used for parameterizing URL, cookie and post content in a user request.
In this embodiment, a printf function in a format similar to that of c language, such as% 010d,% 010 x% s% p, is adopted, and specific parameterization policies are as follows: % 010d indicates that it is replaced by a 10-bit random number, less than 10 bits leading to 0, e.g., 0123456789. % 010x indicates that a fixed 10 lower case 16-ary character is generated, such as 123456789 a. % s indicates that a random, lowercase a to z string is generated, with random length. % p indicates that this is replaced by a random row in the parameter file. % mp indicates that the parameter file is replaced by the first line to the last line in the order in the parameter file at each iteration. % 0p indicates that the substitution is to take the contents of the first parameter file here. % 1p indicates that the alternative here is to take the content in the second parameter file. And an i parameter is supported, when two positions of% mp are parameterized, the two positions of% mp are replaced by the same line number in the two parameter files, and if the i parameter is not specified, the two positions of% mp are replaced, and the line number pointed by the second position of% mp is the line number of the first position of% mp plus 1.
In this embodiment, taking CGI (Common Gateway Interface) of a card shared by friends as an example, the URL content of the service is http:// abc. Xxx and packageid xxx; the cookie content is uin xxx and ssid xxx.
There are three variable parameters in URL and cookie, uin (unique identity name), packageid (card id), SSID (10-bit 10-digit random number). Since there is a limit to the number of cards picked up by the same friend, generally, the number is limited to only allow picking up once, so that a large number of cards (corresponding parameters packageids) compliant with different friends (corresponding parameters uin) need to be prepared to avoid the limitation of the number of picked up by a single friend to implement a stress test. Let us assume that uin is stored in the first parameter file abc _ uin.txt and that packageid is stored in the second parameter file package _ id.txt, as shown in fig. 7.
In the pressure test process, when the uin and the packageid are instantiated in each iteration, the one-to-one correspondence relationship between the packageid and the uin needs to be maintained, and the uin in the URL and the uin in the cookie are kept consistent, then the test case is configured as follows:
(1) the request URL content is set to:
http://chong.abc.com/tws/greetcard/GetCard?uin=%0lp&packageid=%1lp
(2) setting cookie content to uin ═ 0 mp; ssid ═ 010 d.
(3) Setting a first parameter file abc _ uin.txt and a second parameter file package _ id.txt as synchronous update parameter files, when a parameter is instantiated in the pressure test process, taking a value of the parameter uin from the first parameter file abc _ uin.txt, taking a value of the parameter packageid from the second parameter file package _ id.txt, taking values of the same row number in the two parameter files during each iteration, taking the same row value in abc _ uin.txt for each iteration of the uin in the URL and the cookie, and taking the SSID as a dynamically generated random number to obtain the following request data:
http://chong.adc.com/tws/greetcard/GetCard?uin=1195667267&packageid=test_pack775030785(cookie:uin=1195667267;ssid=7790620533)
http://chong.abc.com/tws/greetcard/GetCard?uin=1224507247&packageid=test_pack445595964(cookie:uin=1224507247;ssid=2365415897)
http://chong.abc.com/tws/greetcard/GetCard?uin=1274969732&packageid=test_pack966887652(cookie:uin=1274969732;ssid=5426589635)
......
when the number of the parameter files is more than 2, the relevance of values among a plurality of parameter files can be kept in a mode of associating the parameter files, and the values are the same when the same parameter file is quoted at a plurality of positions.
Secondly, data in the database is constructed according to a specified parameterization strategy.
In this embodiment, for the sub-library and sub-table parameterization strategy, the sub-library number and the sub-table number are filled in the parameterization data template. The database dividing number refers to the database dividing number. The number of partial tables means the number of data tables included in each partial library. And filling placeholders of the positions of the sub-library and sub-table fields in the data table in the sub-library and sub-table fields (namely, the placeholders belong to the second field in the data table, starting from 0 and do not divide the library and do not divide the table when the default is-1), and calculating a sub-library index value and a sub-table index value by the following formulas.
The index value of each database is equal to the field of each database and table/the number of each database
Index value of table division is%
Where,% represents the remainder.
Assume that a table structure of test data is to be constructed as shown in table 1.
TABLE 1
Figure BDA0001194335150000121
Figure BDA0001194335150000131
Wherein the uid refers to a unique identity credential and the name is a user name.
Assuming that the number of the sub-libraries is 128, the number of the sub-tables is 10, and uid is the sub-library and sub-table field, the placeholder of the sub-library and sub-table field is filled with 0, and the value of the uid field is taken as the field value of the sub-library and sub-table when constructing data, for example, the sub-libraries and sub-tables into which the data with uid of 1200000549 is classified are as follows:
index value of each database is 1200000549/10%, and 128 is 54
Index value of the table 1200000549%, 10 and 9
In this embodiment, for the parameterization policy of the field, a parameterization placeholder is used to represent a specific parameterization policy, the parameterization placeholder is represented by a format character in a format function similar to that in the c language, the format is% [ field _ width ] [ qualifier ] < format >, and the meaning and use rule examples of the three parts are as follows:
(1) field _ width: bit width, which is an integer number or x, and the length of the parameterized string or number character does not exceed the length indicated by the string or number character, such as: greater than 0, this indicates right alignment.
In this embodiment, field _ width defines bit width, starting from the parameter file, the initial value of the parameter, the initial value of the atom increment, etc.
(2) A qualifier: modifiers, such as:
h: the number generated is two bytes (short integer type)
I: the number generated is incremented by 1 from the last iteration and the initial value is specified in field _ width. ......
Wherein h represents that the word length is 16 when the numerical value type parameter is randomly generated; i indicates that the generated data is of an atomic auto-increment type.
(3) And (3) format: format types, such as:
s: generating a-z strings
p: a line in the parameter file is referenced. Wherein the specific referenced parameter file is specified by field _ width (first starting from 0). When the qualifier is m, the method refers to the loop from line 1 to line n of the parameter file in sequence, and when the qualifier is not m, the method refers to one line in the parameter file randomly.
......
After the data template of one table is added, when the data template of another associated table is added again, the associated fields between the two tables are expressed by% rd or% rx, and the two associated fields generate the same value of 10-system number or 16-system number in the data manufacturing process.
Example of parameterization effects:
% 010d indicates that a decimal number of up to 10 characters in length is generated, and if not more than 10 characters in length, the front is filled with 0.
% 0lp indicates that the first parameter file is referenced sequentially.
a ═ 010rX & b ═ 010rX means that both a and b values are the same randomly generated 16-ary numbers, but the second and first generated values are not the same.
% 10086Id represents an integer that will yield 10086 for the first iteration, 10087 for the second iteration, and so on.
Besides, the implementation method of the data parameterization can be applied to pressure tests and other scenes needing parameterization.
FIG. 8 is a block diagram showing an apparatus for implementing data parameterization according to an embodiment. As shown in fig. 8, an apparatus 800 for implementing data parameterization includes a placeholder acquiring module 802, a determining module 804, a parameterization policy acquiring module 806, and a generating module 808. Wherein:
the placeholder acquiring module 802 is configured to acquire placeholders in configured test cases.
The decision module 804 is used to decide the placeholder type.
The parameterized policy obtaining module 806 is configured to obtain a corresponding preset parameterized policy according to the placeholder type.
The generating module 808 is configured to generate corresponding instantiation data for the placeholder using the parameterized policy.
In the device and method for implementing data parameterization in the embodiment, after the placeholder type is judged by obtaining the placeholder in the configured test case, the corresponding parameterization strategy is obtained according to the placeholder type, the placeholder is generated into corresponding instantiation data according to the parameterization strategy, the corresponding instantiation data can be dynamically generated due to the adoption of the placeholder occupying position, the corresponding instantiation data can be obtained according to different test scene adjustment parameters, different requirements are met, and the application range is expanded.
FIG. 9 is a block diagram showing an apparatus for implementing data parameterization according to another embodiment. As shown in fig. 9, an apparatus 800 for implementing data parameterization includes a placeholder acquiring module 802, a determining module 804, a parameterization policy acquiring module 806, a generating module 808, and a configuring module 810. Wherein:
the configuration module 810 is configured to obtain a target service to be tested, and configure a test case according to the target service to be tested.
As shown in fig. 9, the configuration module 810 includes a first obtaining unit 8101, a second obtaining unit 8102, and a configuration unit 8103.
The first obtaining unit 8101 is configured to obtain test attribute data of a target service under test.
The second obtaining unit 8102 is configured to obtain the configured concurrency number, the total request number, the response result checking condition, the parameter file, the test environment, and the pressing machine.
The configuration unit 8103 is configured to configure the test case according to the test attribute data, the concurrency number, the total request number, the response result check condition, the parameter file, the test environment, and the pressing machine.
In the embodiment, the test cases are configured according to the configured test attribute data, the concurrent number, the total request number, the response result condition, the parameter file, the pressure applying machine and the like, the test cases are simple in structure, the test preparation time is shortened, and the pressure test task can be supported quickly and effectively.
Further, the configuration module 810 further includes a third obtaining unit 8104. The third obtaining unit 8104 is configured to obtain the configured associated parameter file.
The configuration unit 8103 is further configured to configure the test case according to the test attribute data, the concurrency number, the total request number, the response result check condition, the parameter file, the test environment, the pressing machine, and the associated parameter file.
Further, the configuration module 810 further includes a fourth obtaining unit 8105.
The fourth obtaining unit 8105 is configured to obtain database data and a test attribute data template.
The configuration unit 8103 is further configured to configure a test case according to the test attribute data, the concurrency number, the total request number, the response result check condition, the parameter file, the test environment, the pressing machine, the associated parameter file, the database data, and the parameterized data template.
Or, the configuration unit 8103 is further configured to configure the test case according to the test attribute data, the concurrency number, the total number of requests, the response result check condition, the parameter file, the test environment, the pressure applying machine, the database data, and the parameterized data template.
FIG. 10 is a block diagram showing an apparatus for implementing data parameterization according to another embodiment. As shown in fig. 10, an apparatus for implementing data parameterization includes, in addition to a placeholder obtaining module 802, a determining module 804, a parameterization policy obtaining module 806 and a generating module 808, a total iteration number obtaining module 812, a counting module 814 and a determining module 816. Wherein:
the total iteration number obtaining module 812 is configured to obtain a total number of test cases before obtaining the placeholders in the configured test cases, and use the total number as the total iteration number.
The counting module 814 is used for obtaining the set current iteration number.
The determining module 816 is configured to determine whether there is a placeholder in the test case of the current iteration count after the placeholder is generated into the corresponding instantiation data by using the parameterization policy, if so, the placeholder acquiring module performs the acquiring of the placeholder in the configured test case, if not, the determining module determines whether the current iteration count is greater than or equal to the total iteration count, if so, the determining module ends, and if not, the counting module is further configured to acquire the set current iteration count, and continue the iteration until the current iteration count is equal to or greater than the total iteration count.
In other embodiments, an apparatus for implementing data parameterization may include all possible combinations of the placeholder obtaining module 802, the determining module 804, the parameterization policy obtaining module 806, the generating module 808, the configuring module 810, the total iteration number obtaining module 812, the counting module 814 and the judging module 816.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), or the like.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (14)

1. A method for realizing data parameterization comprises the following steps:
acquiring test attribute data of a tested target service;
acquiring the configured concurrency number, the total request number, the response result checking condition, the parameter file and the testing environment;
acquiring a configured associated parameter file; the associated parameter file refers to the order of the parameter file and the position association when the placeholder in the parameterization refers to the parameter file;
configuring a test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment and the associated parameter file;
acquiring a placeholder in a configured test case; the placeholder is used for occupying a fixed position to represent a symbol which is finally replaced;
determining the placeholder type; the placeholder type comprises a formatting type and a modifier;
acquiring a corresponding preset parameterization strategy according to the placeholder type;
and acquiring data, replacing the placeholder with corresponding data by adopting the parameterization strategy, and generating corresponding instantiation data for the test case.
2. The method of claim 1, further comprising:
obtaining a pressing machine;
the configuring of the test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment and the associated parameter file comprises the following steps:
and configuring a test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment, the associated parameter file and the pressing machine.
3. The method of claim 1, wherein the obtaining of the corresponding preset parameterized policy according to the placeholder type comprises:
and finding the corresponding parameterized strategy from the corresponding relation between the placeholder type and the parameterized strategy according to the placeholder type.
4. The method of claim 1, wherein the obtaining the target service under test and configuring the test case according to the target service under test further comprises:
acquiring database data and a test attribute data template;
and configuring a test case according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment, the associated parameter file, the database data and the parameterized data template.
5. The method of claim 1, wherein prior to the obtaining placeholders in configured test cases, the method further comprises:
acquiring the total amount of test cases, and taking the total amount as the total number of iterations;
and acquiring the set current iteration number.
6. The method of claim 5, wherein after the employing the parameterized policy to generate the placeholders into corresponding instantiation data, the method further comprises:
judging whether the test case of the current iteration times has placeholders, if so, executing the step of acquiring the placeholders in the configured test case, if not, judging whether the current iteration times is more than or equal to the total iteration times, if so, finishing, if not, acquiring the set current iteration times, and continuing the iteration until the current iteration times is more than or equal to the total iteration times.
7. An apparatus for implementing data parameterization, comprising:
the configuration module comprises a first acquisition unit, a second acquisition unit, a third acquisition unit and a configuration unit;
the first acquisition unit is used for acquiring test attribute data of a tested target service;
the second obtaining unit is used for obtaining the configured concurrency number, the total request number, the response result checking condition, the parameter file and the testing environment;
the third obtaining unit is configured to obtain the configured associated parameter file;
the configuration unit is used for configuring test cases according to the test attribute data, the concurrent number, the total request number, the response result checking condition, the parameter file, the test environment and the associated parameter file;
the placeholder acquiring module is used for acquiring placeholders in the configured test cases; the placeholder is used for occupying a fixed position to represent a symbol which is finally replaced;
a determination module to determine the placeholder type; the placeholder type comprises a formatting type and a modifier;
the parameterized policy acquisition module is used for acquiring a corresponding preset parameterized policy according to the placeholder type;
and the generating module is used for acquiring data, replacing the placeholder with corresponding data by adopting the parameterization strategy and generating corresponding instantiation data of the test case.
8. The apparatus of claim 7,
the second acquisition unit is also used for acquiring a pressing machine;
the configuration unit is further configured to configure the test case according to the test attribute data, the concurrency number, the total request number, the response result check condition, the parameter file, the test environment, the associated parameter file, and the pressing machine.
9. The apparatus of claim 7, wherein the parameterized policy acquisition module is further configured to find a corresponding parameterized policy from the corresponding relationship between the placeholder type and the parameterized policy according to the placeholder type.
10. The apparatus of claim 7, wherein the configuration module further comprises:
the fourth acquisition unit is used for acquiring database data and a test attribute data template;
the configuration unit is also used for configuring the test cases according to the test attribute data, the concurrency number, the total request number, the response result checking condition, the parameter file, the test environment, the associated parameter file, the database data and the parameterized data template.
11. The apparatus of claim 7, further comprising:
an iteration total number obtaining module, configured to obtain a total number of test cases before obtaining the placeholders in the configured test cases, and taking the total number as an iteration total number;
and the counting module is used for acquiring the set current iteration times.
12. The apparatus of claim 11, further comprising:
and the judging module is used for judging whether the test case of the current iteration times has placeholders after the placeholders are generated into corresponding instantiation data by adopting the parameterization strategy, if so, executing the acquisition of the placeholders in the configured test case by the placeholder acquiring module, if not, judging whether the current iteration times is more than or equal to the total iteration times, if so, ending, otherwise, further using the counting module to acquire the set current iteration times and continuing the iteration until the current iteration times is more than or equal to the total iteration times.
13. A terminal comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 6.
14. A computer-readable storage medium, storing a computer program which, when executed by a processor, causes the processor to carry out the steps of the method according to any one of claims 1 to 6.
CN201611229995.4A 2016-12-27 2016-12-27 Method and device for realizing data parameterization Active CN106681921B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611229995.4A CN106681921B (en) 2016-12-27 2016-12-27 Method and device for realizing data parameterization

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611229995.4A CN106681921B (en) 2016-12-27 2016-12-27 Method and device for realizing data parameterization

Publications (2)

Publication Number Publication Date
CN106681921A CN106681921A (en) 2017-05-17
CN106681921B true CN106681921B (en) 2020-11-10

Family

ID=58871718

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611229995.4A Active CN106681921B (en) 2016-12-27 2016-12-27 Method and device for realizing data parameterization

Country Status (1)

Country Link
CN (1) CN106681921B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108388548B (en) * 2018-02-24 2021-08-31 浪潮软件股份有限公司 Method and device for realizing script parameterization
CN109241039B (en) * 2018-09-19 2023-05-26 江苏人加信息科技有限公司 Method, system, server and storage medium for realizing global unique parameterized file
CN109446099A (en) * 2018-11-09 2019-03-08 贵州医渡云技术有限公司 Automatic test cases generation method, device, medium and electronic equipment
CN110297774B (en) * 2019-07-02 2022-08-19 四川长虹电器股份有限公司 Automatic interface testing method based on python
CN111459824B (en) * 2020-04-01 2021-09-14 腾讯科技(深圳)有限公司 Test case processing method and device for concurrent service
CN112114893B (en) * 2020-08-14 2021-08-03 中国科学院电子学研究所苏州研究院 Process-oriented service configuration management and integration tool and method
CN113407457B (en) * 2021-07-08 2023-11-07 软子数字软件(广州)有限公司 Multi-data type parameterized definition and program reference processing method and system
CN113778889A (en) * 2021-09-16 2021-12-10 行云智网络科技(北京)有限公司 Dynamic parameter setting method and system for automatic test

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102665231B (en) * 2012-05-23 2015-02-18 北京中创信测科技股份有限公司 Method of automatically generating parameter configuration file for LTE (Long Term Evolution) system
CN102722437B (en) * 2012-05-29 2015-12-16 北京空间飞行器总体设计部 A kind of spacecraft-testing system based on assembly and script and method of testing
CN103544107A (en) * 2013-11-01 2014-01-29 深圳市通力科技开发有限公司 Method and device for generating test case document
CN103746885A (en) * 2014-01-28 2014-04-23 中国人民解放军信息安全测评认证中心 Test system and test method oriented to next-generation firewall
CN104616682B (en) * 2015-03-09 2017-06-09 广东欧珀移动通信有限公司 Blu-ray player method of testing and smart machine, Blu-ray player
US9740590B2 (en) * 2015-03-27 2017-08-22 International Business Machines Corporation Determining importance of an artifact in a software development environment
CN105262644B (en) * 2015-11-03 2018-08-21 株洲南车时代电气股份有限公司 A kind of universal test system and test method based on protocol configuration

Also Published As

Publication number Publication date
CN106681921A (en) 2017-05-17

Similar Documents

Publication Publication Date Title
CN106681921B (en) Method and device for realizing data parameterization
CN108153670B (en) Interface testing method and device and electronic equipment
JP6626211B2 (en) Method and apparatus for processing short link and short link server
US10225145B2 (en) Method and device for updating client
CN109815013A (en) Business data processing method, device, computer equipment and storage medium
WO2019019649A1 (en) Method and apparatus for generating investment portfolio product, storage medium and computer device
CN105450461A (en) Shunting method and network equipment
CN110661829B (en) File downloading method and device, client and computer readable storage medium
CN108776587B (en) Data acquisition method and device, computer equipment and storage medium
CN112306881A (en) Simulation data generation method, device, equipment and storage medium
CN112988608B (en) Data testing method and device, computer equipment and storage medium
CN109815112B (en) Data debugging method and device based on functional test and terminal equipment
CN109788029A (en) Gray scale call method, device, terminal and the readable storage medium storing program for executing of micro services
CN111144402A (en) OCR recognition accuracy calculation method, device, equipment and storage medium
CN110347946A (en) A kind of page display method, device, computer equipment and storage medium
CN109902251A (en) Scheme Choice method, apparatus, terminal and readable storage medium storing program for executing based on decision tree
CN109377383A (en) Product data synchronous method, device, computer equipment and storage medium
CN108415998B (en) Application dependency relationship updating method, terminal, device and storage medium
CN106878311B (en) HTTP message rewriting method and device
CN115543479A (en) Interface calling analysis method and device suitable for dynamic parameters
CN113360300B (en) Interface call link generation method, device, equipment and readable storage medium
CN112887451B (en) Domain name resolution method and device and computer equipment
CN108776665B (en) Data processing method and device
CN114253436B (en) Page display method, device and storage medium
CN109669678A (en) Template engine integration method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant