Test dependent data generation method, device, server and storage medium
By building a data generation interface in the server under test, and using existing interface definitions and stress test vocabulary to generate test dependency data, the problem of high test dependency data generation costs is solved, and efficient and low-cost test dependency data generation is achieved.
Patent Information
- Application Number
- CN202111014571.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-31
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-08-31
AI Technical Summary
Existing tests rely on data generation methods that are costly, require a lot of development manpower and scenario resources, and rely on independent tools and mock services, resulting in high generation costs.
Build a data generation interface in the server under test, obtain the test requirement information of the target interface under test, and generate test dependency data through the data generation interface. Use existing interface definitions and stress test vocabulary to reduce development costs and resource investment.
By reusing the basic information of the server under test, the cost of test-dependent data generation is reduced, the dependence on independent tools and mock services is avoided, the generation efficiency and efficiency are improved, and the testing process is simplified.
Smart Images

Figure CN113868116B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, server and storage medium for generating test dependency data. Background Art
[0002] With the development of the Internet, the iteration cycle of various application services is getting shorter and shorter, and urgent changes in requirements have become the norm, which has put forward higher and higher requirements on the coverage scenarios and implementation efficiency of service performance stress testing. To meet the above requirements, the importance of testing data-dependent structures has become increasingly prominent.
[0003] In the related art, the current method for generating test-dependent data is generally to construct the required data by developing independent tools, and inject the data into the mock service in the corresponding DB service to complete the construction of the test-dependent data; however, the development of data construction tools requires a high investment in development manpower, and the mock service requires a high development cost, and the mock service needs to be configured with mock data. When the data volume and scene richness are large, more scene resources, longer operation time and higher operation cost are required, resulting in a high cost for generating test-dependent data. Summary of the invention
[0004] The present disclosure provides a method, device, server and storage medium for generating test dependent data, so as to at least solve the problem of high generation cost of test dependent data in related technologies. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a method for generating test dependency data is provided, comprising:
[0006] Constructing a data generation interface in the server to be tested; the data generation interface is used to generate test dependency data of the interface to be tested in the server to be tested, the test dependency data being dependency data used when testing the interface to be tested;
[0007] Obtaining test requirement information of a target interface to be tested in the server to be tested;
[0008] According to the test requirement information, the data generation interface is called to generate test dependency data of the target interface to be tested.
[0009] In an exemplary embodiment, constructing a data generation interface in the server to be tested includes:
[0010] Obtaining existing interface definition information of the server to be tested;
[0011] According to the existing interface definition information, an interface for generating test dependency data of the interface to be tested in the server to be tested is constructed, and the interface is used as the data generation interface.
[0012] In an exemplary embodiment, calling the data generation interface to generate the test dependency data of the target interface to be tested according to the test requirement information includes:
[0013] Determine the test dependent data type of the target interface to be tested according to the test requirement information;
[0014] The test dependency data type is sent to the data generation interface, test dependency data corresponding to the test dependency data type is generated through the data generation interface, and the test dependency data is used as the test dependency data of the target interface to be tested.
[0015] In an exemplary embodiment, sending the test dependency data type to the data generation interface, and generating test dependency data corresponding to the test dependency data type through the data generation interface, includes:
[0016] Acquire multiple account identifiers from the stress testing vocabulary of the target interface to be tested; the stress testing vocabulary includes access requests of multiple accounts for the target interface to be tested, each access request corresponding to an account identifier;
[0017] generating a batch request according to the multiple account identifiers and the test-dependent data type;
[0018] The batch request is sent to the data generation interface, the batch request is responded to through the data generation interface, a dependency data generation rule corresponding to the test dependency data type is determined, and dependency data of the multiple account identifiers are generated based on the dependency data generation rule, and the dependency data of the multiple account identifiers are all used as test dependency data corresponding to the test dependency data type.
[0019] In an exemplary embodiment, before sending the batch request to the data generation interface, the method further includes:
[0020] Obtaining the network type of the batch request;
[0021] If the network type is a preset network type, confirming that the batch request verification is passed;
[0022] The sending the batch request to the data generation interface includes:
[0023] If the batch request passes the verification, the batch request is sent to the data generation interface.
[0024] In an exemplary embodiment, after calling the data generation interface to generate the test dependency data of the target interface to be tested according to the test requirement information, the method further includes:
[0025] Obtaining the data storage format of the test-dependent data of the target interface to be tested;
[0026] According to the data storage format, the test dependency data of the target interface to be tested is stored in a database corresponding to the server to be tested; the test dependency data of the target interface to be tested is configured with a corresponding data identifier and a lifetime, the data identifier is used to identify the test dependency data as dependency data for testing, and the lifetime time is used to identify the storage period of the test dependency data in the database.
[0027] In an exemplary embodiment, the method further comprises:
[0028] Acquiring test dependency data of the target interface to be tested from the database according to a test request for the target interface to be tested;
[0029] The target interface to be tested is tested according to the stress testing vocabulary and test dependency data of the target interface to be tested.
[0030] According to a second aspect of an embodiment of the present disclosure, there is provided a device for generating test dependency data, comprising:
[0031] The interface generation unit is configured to execute the construction of a data generation interface in the server to be tested; the data generation interface is used to generate test dependency data of the interface to be tested in the server to be tested, and the test dependency data is dependency data used when testing the interface to be tested;
[0032] An information acquisition unit, configured to acquire test requirement information of a target interface to be tested in the server to be tested;
[0033] The data generation unit is configured to call the data generation interface to generate test dependency data of the target interface to be tested according to the test requirement information.
[0034] In an exemplary embodiment, the interface generation unit is also configured to execute acquisition of existing interface definition information of the server to be tested; based on the existing interface definition information, construct an interface for generating test dependency data of the interface to be tested in the server to be tested, and use the interface as the data generation interface.
[0035] In an exemplary embodiment, the data generation unit is further configured to determine the test dependency data type of the target interface to be tested based on the test requirement information; send the test dependency data type to the data generation interface, generate test dependency data corresponding to the test dependency data type through the data generation interface, and use the test dependency data as the test dependency data of the target interface to be tested.
[0036] In an exemplary embodiment, the data generation unit is further configured to execute the acquisition of multiple account identifiers from the stress testing vocabulary of the target interface to be tested; the stress testing vocabulary includes access requests of multiple accounts for the target interface to be tested, and each access request corresponds to an account identifier; batch requests are generated according to the multiple account identifiers and the test dependency data type; the batch requests are sent to the data generation interface, the batch requests are responded to through the data generation interface, the dependency data generation rules corresponding to the test dependency data type are determined, and the dependency data of the multiple account identifiers are generated based on the dependency data generation rules, and the dependency data of the multiple account identifiers are all used as test dependency data corresponding to the test dependency data type.
[0037] In an exemplary embodiment, the data generation unit is further configured to execute obtaining the network type of the batch request; if the network type is a preset network type, confirming that the batch request verification is passed; if the batch request verification is passed, sending the batch request to the data generation interface.
[0038] In an exemplary embodiment, the device also includes a data storage unit, which is configured to execute the data storage format of obtaining the test dependency data of the target interface to be tested; according to the data storage format, the test dependency data of the target interface to be tested is stored in a database corresponding to the server to be tested; the test dependency data of the target interface to be tested is configured with a corresponding data identifier and a life time, the data identifier is used to identify the test dependency data as dependency data for testing, and the life time is used to identify the storage period of the test dependency data in the database.
[0039] In an exemplary embodiment, the device also includes an interface testing unit, which is configured to execute a test request for the target interface to be tested, obtain test dependency data of the target interface to be tested from the database; and test the target interface to be tested according to the stress testing vocabulary and test dependency data of the target interface to be tested.
[0040] According to a third aspect of an embodiment of the present disclosure, a server is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a method for generating test dependency data as described in any one of the embodiments of the first aspect.
[0041] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, comprising: when instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the method for generating test dependency data described in any one of the embodiments of the first aspect.
[0042] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium, at least one processor of a device reading and executing the computer program from the computer-readable storage medium, so that the device executes the method for generating test dependency data described in any one of the embodiments of the first aspect.
[0043] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0044] By constructing a data generation interface in the server to be tested; the data generation interface is used to generate test dependency data of the interface to be tested in the server to be tested, and the test dependency data is the dependency data used when testing the interface to be tested; then the test requirement information of the target interface to be tested in the server to be tested is obtained, and finally according to the test requirement information, the data generation interface is called to generate the test dependency data of the target interface to be tested; in this way, constructing the data generation interface in the server to be tested is conducive to making full use of the existing basic information of the server to be tested, greatly reducing the development cost, and there is no need to invest high development manpower and scenario resources, so that the cost of subsequently generating the test dependency data of the target interface to be tested through the data generation interface is also reduced, thereby reducing the generation cost of the test dependency data, and avoiding the defect of high generation cost of the test dependency data by developing an independent data generation tool and combining the mock service to complete the construction of the test dependency data.
[0045] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0047] Figure 1The present invention is an application environment diagram of a method for generating test dependency data according to an exemplary embodiment.
[0048] Figure 2 The figure is a flowchart of a method for generating test dependency data according to an exemplary embodiment.
[0049] Figure 3 The figure is a flowchart showing steps of generating test dependency data according to an exemplary embodiment.
[0050] Figure 4 The figure is a flowchart of another method for generating test dependency data according to an exemplary embodiment.
[0051] Figure 5 The flowchart of another method for generating test dependency data is shown according to an exemplary embodiment.
[0052] Figure 6 The invention is a block diagram of a device for generating test dependency data according to an exemplary embodiment.
[0053] Figure 7 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0054] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0055] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0056] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0057] The method for generating test dependent data provided by the present disclosure can be applied to Figure 1In the application environment shown in FIG. 1 , the server to be tested 110 includes a data generation interface 120 and a target to be tested interface 130. Figure 1 , the server to be tested 110 first constructs a data generation interface 120 inside it; the data generation interface 120 is used to generate test dependency data of the interface to be tested in the server to be tested 110, and the test dependency data is the dependency data used when testing the interface to be tested; then the test requirement information of the target interface to be tested 130 in the server to be tested 110 is obtained, and finally, according to the test requirement information, the data generation interface 120 is called to generate the test dependency data of the target interface to be tested 130. Among them, the server 110 can be implemented by an independent server or a server cluster composed of multiple servers, and the data generation interface 120 and the target interface to be tested 130 both refer to interfaces that provide services.
[0058] Figure 2 is a flow chart of a method for generating test dependency data according to an exemplary embodiment. Figure 2 As shown, the test dependency data generation method is used as follows Figure 1 The server to be tested shown includes the following steps:
[0059] In step S210, a data generation interface is constructed in the server to be tested; the data generation interface is used to generate test dependency data of the interface to be tested in the server to be tested, and the test dependency data is dependency data used when testing the interface to be tested.
[0060] Among them, the server to be tested refers to a server that contains one or more interfaces to be tested; the data generation interface refers to a test dependency data generation interface, which is used to generate test dependency data used when testing the interfaces to be tested in the server to be tested; the interface to be tested refers to the interface that needs to be tested in the server to be tested, such as a payment interface, a qualification determination interface, a verification interface, a release interface, etc.
[0061] Among them, test dependency data refers to the underlying dependency data needed to test the interface to be tested. Its essence is a kind of dependency data, not test data; for example, on the basis of test data, it is necessary to combine test dependency data to test the interface to be tested. In actual scenarios, when testing the payment interface, test dependency data refers to necessary information such as balance information, payment qualification information, and credit information, while test data refers to payment requests initiated by users. When testing the qualification determination interface, test dependency data refers to necessary information such as user credit history, while test data refers to qualification determination requests initiated by users.
[0062] It should be noted that the server under test includes existing interface definition information, such as data definition information, interface creation method, etc. By reusing the existing interface definition information in the server under test, a data generation interface can be quickly created in the server under test, thereby reducing the development cost of the data generation interface.
[0063] Specifically, the server under test obtains the existing interface definition information inside it, and creates an interface for generating test dependency data of the interface under test in the server under test based on the existing interface definition information, and uses the interface as the data generation interface to facilitate the subsequent generation of test dependency data required for the interface under test through the data generation interface.
[0064] In step S220, the test requirement information of the target interface to be tested in the server to be tested is obtained.
[0065] The target interface to be tested refers to the interface to be tested selected from the interfaces to be tested in the server to be tested. The test requirement information is used to indicate the test scenario information of the target interface to be tested, such as a qualification determination scenario, a payment scenario, etc.
[0066] It should be noted that the test dependent data type of the target interface to be tested can be determined through the test scenario information; for example, for the qualification determination scenario, it can be determined that the required test dependent data type is the reputation history data type.
[0067] Specifically, the server to be tested receives a test request for a target interface to be tested, and parses the test request for the target interface to be tested to obtain test requirement information of the target interface to be tested.
[0068] In step S230, according to the test requirement information, the data generation interface is called to generate the test dependency data of the target interface to be tested.
[0069] Specifically, the server under test parses the test requirement information to obtain test scenario information; determines the corresponding test dependency data type based on the test scenario information; generates a test dependency data generation request based on the test dependency data type, and sends the test dependency data generation request to the data generation interface; the data generation interface generates test dependency data for the target interface under test by responding to the test dependency data generation request.
[0070] For example, in the qualification determination scenario, the data generation interface constructs a diverse account credit history based on the account ID.
[0071] In the above-mentioned method for generating test dependency data, a data generation interface is constructed in the server to be tested; the data generation interface is used to generate test dependency data of the interface to be tested in the server to be tested, and the test dependency data is the dependency data used when testing the interface to be tested; then the test requirement information of the target interface to be tested in the server to be tested is obtained, and finally, according to the test requirement information, the data generation interface is called to generate the test dependency data of the target interface to be tested; in this way, constructing the data generation interface in the server to be tested is conducive to making full use of the existing basic information of the server to be tested, greatly reducing the development cost, and there is no need to invest high development manpower and scenario resources, so that the cost of subsequently generating the test dependency data of the target interface to be tested through the data generation interface is also reduced, thereby reducing the generation cost of the test dependency data, and avoiding the defect of high generation cost of the test dependency data caused by developing an independent data generation tool and combining the mock service to complete the construction of the test dependency data.
[0072] In an exemplary embodiment, in step S210, a data generation interface is constructed in the server to be tested, including: obtaining existing interface definition information of the server to be tested; constructing an interface for generating test dependency data of the interface to be tested in the server to be tested according to the existing interface definition information, and using the interface as the data generation interface.
[0073] The existing interface definition information is used to represent the basic information for interface creation, such as data definition information, existing interface creation methods, and the like.
[0074] Specifically, the server under test obtains existing interface definition information in the server under test through preset interface definition information acquisition instructions; generates interface creation instructions based on the existing interface definition information of the server under test; according to the interface creation instructions, constructs an interface in the server under test for generating test dependency data of the interface under test in the server under test, and uses the interface as the data generation interface.
[0075] For example, the server under test uses the basic interface creation information such as the data definition information of the server under test and the existing interface creation method to quickly create a test dependency data generation interface in the server under test through methods such as package introduction, so as to generate the underlying dependency data required for testing the interface under test through the test dependency data generation interface.
[0076] The technical solution provided by the embodiment of the present disclosure can quickly create a data generation interface in the server to be tested by reusing the existing interface definition information in the server to be tested, thereby reducing the development cost and development manpower of the data generation interface, and further reducing the cost of subsequently generating test-dependent data for the target interface to be tested through the data generation interface.
[0077] In an exemplary embodiment, in step S230, based on the test requirement information, a data generation interface is called to generate test dependency data of the target interface to be tested, including: determining the test dependency data type of the target interface to be tested based on the test requirement information; sending the test dependency data type to the data generation interface, generating test dependency data corresponding to the test dependency data type through the data generation interface, and using the test dependency data as the test dependency data of the target interface to be tested.
[0078] Among them, the test dependent data type is used to represent the data type of the required test dependent data, such as the credit history data type, the payment qualification data type, etc.
[0079] Specifically, the server under test queries the correspondence between the test requirement information and the test dependency data type based on the test requirement information, obtains the test dependency data type corresponding to the test requirement information, and uses the test dependency data type as the test dependency data type of the target interface under test; generates a test dependency data generation request based on the test dependency data type of the target interface under test, and sends the test dependency data generation request to the data generation interface; the data generation interface parses the received test dependency data generation request to obtain the test dependency data type, generates test dependency data corresponding to the test dependency data type through a test dependency data generation instruction corresponding to the test dependency data type, and uses the test dependency data as the test dependency data of the target interface under test.
[0080] For example, assuming that the test requirement information is to test the qualification determination interface, indicating that the test scenario is a qualification determination scenario, then the test dependent data type is the reputation history data type, and the reputation history data type is sent to the data generation interface through the server to be tested. The data generation interface generates reputation history data for multiple users based on the received reputation history data type.
[0081] The technical solution provided by the embodiment of the present disclosure utilizes the data generation interface in the server to be tested to generate test dependency data of the target interface to be tested in the server to be tested, thereby avoiding the defect of completing the construction of test dependency data by developing an independent data generation tool, which leads to a high generation cost of the test dependency data, and further reduces the generation cost of the test dependency data.
[0082] In an exemplary embodiment, if Figure 3 As shown, the test dependency data type is sent to the data generation interface, and the test dependency data corresponding to the test dependency data type is generated through the data generation interface, specifically including the following steps:
[0083] In step S310, multiple account identifiers are obtained from the stress testing vocabulary of the target interface to be tested; the stress testing vocabulary includes access requests of multiple accounts for the target interface to be tested, and each access request corresponds to an account identifier.
[0084] The stress test word list is a word list used to store access requests of accounts for interfaces (such as target interfaces to be tested), and the access requests can be repeatedly executed through the stress test word list. The account identifier refers to the identity information of the account, such as the account name, account ID, etc.
[0085] Specifically, the server to be tested obtains the stress testing vocabulary of the target interface to be tested by querying the correspondence between the interface and the stress testing vocabulary; and extracts multiple account identifiers, such as multiple user IDs, from the stress testing vocabulary of the target interface to be tested.
[0086] In step S320, a batch request is generated according to the multiple account identifiers and the test-dependent data types.
[0087] Among them, the batch request is used to request the generation of batch test dependency data.
[0088] Specifically, the server to be tested obtains a batch request template for test-dependent data of the target interface to be tested, and imports multiple account identifiers and test-dependent data types into corresponding positions in the batch request template to obtain a batch request for test-dependent data.
[0089] For example, the server under test reuses some data such as account ID in the stress test vocabulary, and combines it with the test dependency data type to obtain a batch request for requesting the data generation interface to generate batch test dependency data in a short time.
[0090] In step S330, the batch request is sent to the data generation interface, the batch request is responded to through the data generation interface, the dependency data generation rule corresponding to the test dependency data type is determined, and based on the dependency data generation rule, dependency data of multiple account identifiers are generated, and the dependency data of multiple account identifiers are all used as test dependency data corresponding to the test dependency data type.
[0091] The dependency data generation rules refer to the generation rules of the test dependency data, such as the reputation history data generation rules; different types of test dependency data have different corresponding dependency data generation rules.
[0092] Specifically, the server to be tested sends a batch request to the data generation interface; the data generation interface parses the batch request to obtain multiple account identifiers and test dependency data types, and obtains the dependency data generation rules corresponding to the test dependency data type from the dependency data generation rules corresponding to the multiple test dependency data types stored locally; according to the dependency data generation rules, dependency data of multiple account identifiers are generated, and these dependency data are used as test dependency data of the target interface to be tested.
[0093] For example, the data generation interface generates diversified reputation history data of multiple account IDs according to the reputation history data generation rules, and uses the diversified reputation history data of multiple account IDs as test dependency data of the qualification determination interface.
[0094] The technical solution provided by the embodiment of the present disclosure reuses some data such as account identification of the stress testing vocabulary and batch requests the data generation interface in the server to be tested, so that the data generation interface can complete the construction of batch test dependency data in a shorter time, thereby reducing the generation time of test dependency data and further improving the generation efficiency of test dependency data; at the same time, by making full use of the stress testing vocabulary and combining the dependency data generation rules, it is convenient to construct various dependency data, which is conducive to quickly meeting the needs of scenario richness.
[0095] In an exemplary embodiment, before sending the batch request to the data generation interface, it also includes: obtaining the network type of the batch request; if the network type is a preset network type, confirming that the batch request verification is passed; then, sending the batch request to the data generation interface, specifically including: if the batch request verification is passed, sending the batch request to the data generation interface.
[0096] Among them, the network type of the batch request refers to the network type of the network used to transmit the batch request, such as the intranet, extranet, etc.; the preset network type refers to the intranet, ensuring that the data generation interface can only be accessed through the intranet.
[0097] Specifically, the server under test obtains the network type of the batch request through the network type acquisition instruction; matches the network type of the batch request with the preset network type. If the match is successful, it means that the network type of the batch request is the preset network type, and then confirms that the batch request verification is passed, and sends the batch request to the data generation interface.
[0098] For example, the server to be tested identifies the network type of the batch request. If it is identified that the network type of the batch request is an intranet, it confirms that the batch request has been verified and sends the batch request to the data generation interface.
[0099] The technical solution provided by the embodiment of the present disclosure sends batch requests to the data generation interface only when the batch request verification is passed, thereby ensuring that only requests that meet the network requirements can be sent to the data generation interface, which is beneficial to improving the security of the test-dependent data generation process, thereby improving the security of the generated test-dependent data, and avoiding the defect of data pollution caused by malicious requests that do not meet the network requirements being sent to the data generation interface.
[0100] In an exemplary embodiment, after calling the data generation interface to generate the test dependency data of the target interface to be tested according to the test requirement information, it also includes: obtaining the data storage format of the test dependency data of the target interface to be tested; storing the test dependency data of the target interface to be tested in a database corresponding to the server to be tested according to the data storage format; the test dependency data of the target interface to be tested is configured with a corresponding data identifier and a life time, the data identifier is used to identify the test dependency data as dependency data for testing, and the life time is used to identify the storage period of the test dependency data in the database.
[0101] The data storage format is used to indicate the storage method of the test dependency data, such as key-value pair storage; the data identifier is used to distinguish whether the dependency data is normal dependency data or test dependency data. Normal dependency data refers to the dependency data that already exists online.
[0102] Specifically, the server under test stores each test dependency data in a database corresponding to the server under test according to the data storage format of the test dependency data of the target interface under test, and configures the data identifier and lifetime of each test dependency data according to the configuration instruction.
[0103] For example, in the qualification determination scenario, the server to be tested uses the account ID as the key and the reputation history data as the value, which are written into the redis database connected to the server to be tested. When storing test dependency data, in order to distinguish normal dependency data and reduce space usage, the prefix of normal dependency data is marked as pro, and the prefix of test dependency data is marked as test. At the same time, the storage time of normal dependency data is configured to be 7 days, and the storage time of test dependency data is configured to be 6 hours.
[0104] The technical solution provided by the embodiment of the present disclosure stores the generated test dependency data of the target interface to be tested in a database corresponding to the server to be tested, so that when the target interface to be tested is subsequently tested, the test dependency data of the target interface to be tested can be directly obtained from the database. There is no need to generate the test dependency data separately during the test process, and there is no need to invest much development time to develop independent data generation tools. This is conducive to simplifying the test process of the target interface to be tested and further improving the test efficiency of the target interface to be tested.
[0105] In an exemplary embodiment, the test dependency data generation method provided by the present disclosure also includes the step of testing the target interface to be tested, specifically including the following contents: according to the test request for the target interface to be tested, obtaining the test dependency data of the target interface to be tested from the database; testing the target interface to be tested according to the stress testing vocabulary and test dependency data of the target interface to be tested.
[0106] Specifically, the server under test receives a test request for a target interface under test, and based on the test request for the target interface under test, obtains test dependency data whose interface identifier is the same as the target interface under test identifier from a database, and uses the test dependency data as the test dependency data of the target interface under test; obtains a stress testing vocabulary of the target interface under test, and tests the target interface under test based on access requests to the target interface under test from accounts in the stress testing vocabulary and the test dependency data of the target interface under test.
[0107] For example, during the formal test, the server under test obtains the account's access request to the qualification determination interface from the stress testing vocabulary, and reads the account's credit history data and other test dependency data from the database corresponding to the server under test based on the account's access request to the qualification determination interface; based on the account's access request to the target interface under test and the account's credit history data and other test dependency data, the target interface under test is tested to determine whether the function of the target interface under test is normal.
[0108] The technical solution provided by the embodiment of the present disclosure directly reuses the access request of the account in the stress testing vocabulary to the qualification determination interface when testing the target interface to be tested, and directly obtains the test dependency data of the target interface to be tested from the database. There is no need to generate access requests and test dependency data separately during the testing process, which is beneficial to improving the testing efficiency of the target interface to be tested.
[0109] Figure 4 is a flowchart of another method for generating test dependency data according to an exemplary embodiment. Figure 4 As shown, the test dependency data generation method is used as follows Figure 1 The server to be tested shown includes the following steps:
[0110] In step S410, existing interface definition information of the server to be tested is obtained; according to the existing interface definition information, an interface for generating test dependency data of the interface to be tested in the server to be tested is constructed, and the interface is used as a data generation interface.
[0111] In step S420, the test requirement information of the target interface to be tested in the server to be tested is obtained.
[0112] In step S430, the test dependent data type of the target interface to be tested is determined according to the test requirement information.
[0113] In step S440, multiple account identifiers are obtained from the stress testing vocabulary of the target interface to be tested; the stress testing vocabulary includes access requests of multiple accounts for the target interface to be tested, and each access request corresponds to an account identifier;
[0114] In step S450, a batch request is generated according to the multiple account identifiers and the test-dependent data types.
[0115] In step S460, the network type of the batch request is obtained; if the network type is a preset network type, it is confirmed that the batch request verification is passed.
[0116] In step S470, if the batch request verification passes, the batch request is sent to the data generation interface, the batch request is responded to through the data generation interface, the dependency data generation rule corresponding to the test dependency data type is determined, and based on the dependency data generation rule, dependency data of multiple account identifiers are generated as test dependency data corresponding to the target interface to be tested.
[0117] The above-mentioned method for generating test-dependent data constructs a data generation interface in the server to be tested, which is conducive to making full use of the existing basic information of the server to be tested, greatly reducing the development cost, and does not require high investment in development manpower and scenario resources, so that the cost of subsequently generating test-dependent data of the target interface to be tested through the data generation interface is also reduced, thereby reducing the cost of generating test-dependent data, and at the same time avoiding the defect of high cost of generating test-dependent data by developing independent tools and combining mock services to complete the construction of test-dependent data.
[0118] In order to more clearly illustrate the method for generating test dependency data provided by the embodiment of the present disclosure, the method for generating test dependency data is specifically described below with a specific embodiment. Figure 5 As shown, the present disclosure also provides another method for generating test dependency data, which specifically includes the following contents:
[0119] (1) Developing data construction interfaces in the service being tested
[0120] By leveraging the data definition and existing methods of the service under test, a stress testing data construction interface is quickly developed in the service under test through package introduction and other methods, so as to construct the underlying dependency data required for stress testing the service under test.
[0121] (2) Implement the construction method of test dependent data in the dependent data construction interface
[0122] In the stress test dependency data construction interface, based on the input information, data construction rules, test requirements, etc., the dependency data that the tested interface needs to use during stress testing is constructed and written to the storage DB. For example, based on the user id, a reputation history of diverse composite rules is constructed and written to the storage DB that matches it. When storing, configurable stress test dependency data tags and time to live (TTL) are supported to distinguish normal data and reduce space usage. Data security is guaranteed by the configuration of the upstream access layer. Specifically, access rights management can be performed through the upper layer Nginx, etc. to ensure that only intranet requests can access the dependency data construction interface, avoiding malicious intrusion of external network traffic and causing data pollution.
[0123] (3) This interface for batch request cluster services performs dependent data construction
[0124] You can use stress testing tools and reuse part of the data in the stress testing vocabulary to batch-request the dependency data construction interface of the tested service with high concurrency, so as to complete the construction of dependency data in a short time for use in stress testing. Figure 5 As shown, during the formal stress test, the tested service can read the user's corresponding credit history and other dependent information in the storage DB. For example, the stress test object is a judgment interface for a certain qualification of a service user, and its corresponding stress test vocabulary has been fully recorded. At this time, it is necessary to fill a large amount of necessary information such as the credit history of the test user into the storage DB in advance, that is, the stress test dependent data, as a basis for judgment. This solution uses partial data such as the user id of the stress test vocabulary as parameters, requests the dependency data construction interface, constructs the corresponding user id's credit history and other dependent information through the interface, and writes it into the storage DB, thereby completing the construction of the dependent data.
[0125] The above-mentioned method for generating test dependency data can achieve the following technical effects: (1) by reusing the existing foundation of the stressed service and developing a data construction interface, the development cost is greatly reduced; (2) by using the existing stress testing platform and service cluster for data construction, the data construction time is greatly reduced; (3) by making full use of the stress testing vocabulary, it is convenient to construct various dependency data, which can quickly meet the needs of scenario richness.
[0126] It should be understood that although Figure 2-Figure 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-Figure 4At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0127] It can be understood that the same / similar parts between the various embodiments of the above method in this specification can refer to each other, and each embodiment focuses on the differences from other embodiments. For related points, please refer to the description of other method embodiments.
[0128] Figure 6 is a block diagram of a device for generating test dependency data according to an exemplary embodiment. Figure 6 , the device includes an interface generating unit 610, an information acquiring unit 620 and a data generating unit 630.
[0129] The interface generation unit 610 is configured to execute the construction of a data generation interface in the server under test; the data generation interface is used to generate test dependency data of the interface under test in the server under test, and the test dependency data is the dependency data used when testing the interface under test.
[0130] The information acquisition unit 620 is configured to acquire the test requirement information of the target interface to be tested in the server to be tested.
[0131] The data generating unit 630 is configured to call a data generating interface to generate test dependency data of a target interface to be tested according to the test requirement information.
[0132] In an exemplary embodiment, the interface generation unit 610 is further configured to execute acquisition of existing interface definition information of the server under test; construct an interface for generating test dependency data of the interface under test in the server under test according to the existing interface definition information, and use the interface as a data generation interface.
[0133] In an exemplary embodiment, the data generation unit 630 is also configured to determine the test dependency data type of the target interface to be tested according to the test requirement information; send the test dependency data type to the data generation interface, generate test dependency data corresponding to the test dependency data type through the data generation interface, and use the test dependency data as the test dependency data of the target interface to be tested.
[0134] In an exemplary embodiment, the data generation unit 630 is further configured to execute obtaining multiple account identifiers from the stress testing vocabulary of the target interface to be tested; the stress testing vocabulary includes access requests of multiple accounts to the target interface to be tested, and each access request corresponds to an account identifier; batch requests are generated according to the multiple account identifiers and the test dependency data type; the batch requests are sent to the data generation interface, the batch requests are responded to through the data generation interface, the dependency data generation rules corresponding to the test dependency data type are determined, and dependency data of the multiple account identifiers are generated based on the dependency data generation rules, and the dependency data of the multiple account identifiers are all used as test dependency data corresponding to the test dependency data type.
[0135] In an exemplary embodiment, the data generation unit 630 is further configured to execute obtaining the network type of the batch request; if the network type is a preset network type, confirming that the batch request verification is successful; if the batch request verification is successful, sending the batch request to the data generation interface.
[0136] In an exemplary embodiment, the test dependency data generating device also includes a data storage unit, which is configured to execute the data storage format of the test dependency data of the target interface to be tested; according to the data storage format, the test dependency data of the target interface to be tested is stored in a database corresponding to the server to be tested; the test dependency data of the target interface to be tested is configured with a corresponding data identifier and a life time, the data identifier is used to identify the test dependency data as dependency data for testing, and the life time is used to identify the storage period of the test dependency data in the database.
[0137] In an exemplary embodiment, the test dependency data generating device also includes an interface testing unit, which is configured to execute a test request for the target interface to be tested, obtain the test dependency data of the target interface to be tested from a database; and test the target interface to be tested according to the stress testing vocabulary and test dependency data of the target interface to be tested.
[0138] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0139] Figure 7 is a block diagram of a device 700 for executing a method for generating test dependency data according to an exemplary embodiment. For example, the device 700 may be a server. Figure 7, the device 700 includes a processing component 720, which further includes one or more processors, and a memory resource represented by a memory 722 for storing instructions, such as applications, that can be executed by the processing component 720. The application stored in the memory 722 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 720 is configured to execute the instructions to perform the above method.
[0140] The device 700 may also include a power supply component 724 configured to perform power management of the device 700, a wired or wireless network interface 726 configured to connect the device 700 to a network, and an input / output (I / O) interface 728. The device 700 may operate based on an operating system stored in the memory 722, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, or the like.
[0141] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 722 including instructions, which can be executed by a processor of the device 700 to perform the above method. The storage medium can be a computer-readable storage medium, for example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0142] In an exemplary embodiment, a computer program product is also provided. The computer program product includes instructions, and the instructions can be executed by the processor of the device 700 to implement the above method.
[0143] It should be noted that the above-mentioned devices, electronic devices, computer-readable storage media, computer program products, etc. may also include other implementation methods according to the description of the method embodiments. The specific implementation methods can refer to the description of the relevant method embodiments, which will not be described one by one here.
[0144] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0145] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for generating test dependent data, characterized in that: include: Build a data generation interface in the server to be tested; The data generation interface is used to generate test dependency data of the interface to be tested in the server to be tested, wherein the test dependency data is underlying dependency data required to be used when testing the interface to be tested, and the test dependency data is non-test data; Obtaining test requirement information of a target interface to be tested in the server to be tested; According to the test requirement information, calling the data generation interface to generate test dependency data of the target interface to be tested; The step of constructing a data generation interface in the server to be tested includes: Obtaining existing interface definition information of the server to be tested; According to the existing interface definition information, an interface for generating test dependency data of the interface to be tested in the server to be tested is constructed, and the interface is used as the data generation interface.
2. The method for generating test dependency data according to claim 1, characterized in that: The step of calling the data generation interface to generate the test dependency data of the target interface to be tested according to the test requirement information includes: Determine the test dependent data type of the target interface to be tested according to the test requirement information; The test dependency data type is sent to the data generation interface, test dependency data corresponding to the test dependency data type is generated through the data generation interface, and the test dependency data is used as the test dependency data of the target interface to be tested.
3. The method for generating test dependency data according to claim 2, characterized in that: The sending the test dependency data type to the data generation interface, and generating test dependency data corresponding to the test dependency data type through the data generation interface, includes: Acquire multiple account identifiers from the stress testing vocabulary of the target interface to be tested; the stress testing vocabulary includes access requests of multiple accounts for the target interface to be tested, each access request corresponding to an account identifier; generating a batch request according to the multiple account identifiers and the test-dependent data type; The batch request is sent to the data generation interface, the batch request is responded to through the data generation interface, a dependency data generation rule corresponding to the test dependency data type is determined, and dependency data of the multiple account identifiers are generated based on the dependency data generation rule, and the dependency data of the multiple account identifiers are all used as test dependency data corresponding to the test dependency data type.
4. The method for generating test dependency data according to claim 3, characterized in that: Before sending the batch request to the data generation interface, the method further includes: Obtaining the network type of the batch request; If the network type is a preset network type, confirming that the batch request verification is passed; The sending the batch request to the data generation interface includes: If the batch request passes the verification, the batch request is sent to the data generation interface.
5. The method for generating test dependency data according to claim 1, characterized in that: After calling the data generation interface to generate the test dependency data of the target interface to be tested according to the test requirement information, the method further includes: Obtaining the data storage format of the test-dependent data of the target interface to be tested; According to the data storage format, the test dependency data of the target interface to be tested is stored in a database corresponding to the server to be tested; the test dependency data of the target interface to be tested is configured with a corresponding data identifier and a lifetime, the data identifier is used to identify the test dependency data as dependency data for testing, and the lifetime time is used to identify the storage period of the test dependency data in the database.
6. The method for generating test dependency data according to claim 5, characterized in that: The method further comprises: Acquiring test dependency data of the target interface to be tested from the database according to a test request for the target interface to be tested; The target interface to be tested is tested according to the stress testing vocabulary and test dependency data of the target interface to be tested.
7. A device for generating test dependent data, characterized in that: include: An interface generation unit is configured to execute the construction of a data generation interface in the server to be tested; The data generation interface is used to generate test dependency data of the interface to be tested in the server to be tested, wherein the test dependency data is underlying dependency data required to be used when testing the interface to be tested, and the test dependency data is non-test data; An information acquisition unit, configured to acquire test requirement information of a target interface to be tested in the server to be tested; A data generating unit is configured to call the data generating interface to generate test dependency data of the target interface to be tested according to the test requirement information; The interface generation unit is further configured to obtain existing interface definition information of the server to be tested; construct an interface for generating test dependency data of the interface to be tested in the server to be tested according to the existing interface definition information, and use the interface as the data generation interface.
8. The device for generating test dependency data according to claim 7, characterized in that: The data generating unit is further configured to determine the test dependent data type of the target interface to be tested according to the test requirement information; The test dependency data type is sent to the data generation interface, test dependency data corresponding to the test dependency data type is generated through the data generation interface, and the test dependency data is used as the test dependency data of the target interface to be tested.
9. The device for generating test dependency data according to claim 8, characterized in that: The data generating unit is further configured to obtain multiple account identifiers from the stress testing vocabulary of the target interface to be tested; the stress testing vocabulary includes access requests of multiple accounts for the target interface to be tested, and each access request corresponds to an account identifier; generating a batch request according to the multiple account identifiers and the test-dependent data type; The batch request is sent to the data generation interface, the batch request is responded to through the data generation interface, a dependency data generation rule corresponding to the test dependency data type is determined, and dependency data of the multiple account identifiers are generated based on the dependency data generation rule, and the dependency data of the multiple account identifiers are all used as test dependency data corresponding to the test dependency data type.
10. The device for generating test dependency data according to claim 9, characterized in that: The data generation unit is further configured to execute obtaining the network type of the batch request; if the network type is a preset network type, confirming that the batch request verification is passed; if the batch request verification is passed, sending the batch request to the data generation interface.
11. The device for generating test dependency data according to claim 7, characterized in that: The device also includes a data storage unit configured to execute a data storage format for obtaining the test dependency data of the target interface to be tested; store the test dependency data of the target interface to be tested in a database corresponding to the server to be tested according to the data storage format; The test dependency data of the target interface to be tested is configured with a corresponding data identifier and a life time, wherein the data identifier is used to identify the test dependency data as dependency data for testing, and the life time is used to identify the storage period of the test dependency data in the database.
12. The device for generating test dependency data according to claim 11, characterized in that: The device further comprises an interface testing unit configured to execute, according to a test request for the target interface to be tested, acquiring test dependency data of the target interface to be tested from the database; The target interface to be tested is tested according to the stress testing vocabulary and test dependency data of the target interface to be tested.
13. A server, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method for generating test dependency data according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the method for generating test dependency data according to any one of claims 1 to 6.
15. A computer program product, comprising instructions, characterized in that: When the instruction is executed by a processor of a server, the server is enabled to execute the method for generating test dependency data as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Pressure testing method and system
CN106708818A
Interface testing method and interface testing device
CN110032511A
