Test case data acquisition method and device, electronic equipment and medium
By automatically retrieving test case data from the log data of the business system, the problems of high cost and low efficiency of obtaining test case data in the prior art are solved, and automated acquisition and efficient coverage are achieved.
Patent Information
- Application Number
- CN202310769882.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-27
- Publication Date
- 2024-12-27
AI Technical Summary
In the prior art, the labor cost of obtaining test case data is high, and the acquisition efficiency and coverage are insufficient.
By obtaining the log data of the business system and creating scene rules based on the test scenario, we automatically retrieve test case data from the log data, and automatically obtain test case data.
It reduces labor costs in the process of obtaining test cases data, improves acquisition efficiency and data coverage, supports project code non-invasiveness, and can be expanded to any test scenario.
Smart Images

Figure CN119201663A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the computer field, and in particular to a method, device, electronic device and medium for acquiring test case data. Background Art
[0002] Online regression testing is an indispensable part of modern software engineering.
[0003] At present, the test case data used in online regression testing mainly comes from data manually configured by the business side or manually found.
[0004] In the process of implementing the present invention, the inventors found that the prior art has the following technical problems: the labor cost of acquiring test case data is high and needs to be improved. Summary of the invention
[0005] The embodiments of the present invention provide a method, device, electronic device and medium for acquiring test case data, so as to realize automatic acquisition of test case data, thereby reducing labor costs.
[0006] According to one aspect of the present invention, a method for acquiring test case data is provided, which may include:
[0007] Obtain log data from business systems;
[0008] Obtaining scenario rules, wherein the scenario rules are created for a test scenario corresponding to a business system, and the scenario rules are used to describe test case data that conforms to the test scenario;
[0009] Based on scenario rules, test case data is extracted from log data to test the business system in the test scenario based on the test case data.
[0010] According to another aspect of the present invention, a device for acquiring test case data is provided, which may include:
[0011] Log data acquisition module, used to obtain log data of business systems;
[0012] A scenario rule acquisition module is used to acquire scenario rules, wherein the scenario rules are created for a test scenario corresponding to a business system, and the scenario rules are used to describe test case data that conforms to the test scenario;
[0013] The test case data extraction module is used to extract the test case data from the log data based on the scenario rules, so as to test the business system in the test scenario based on the test case data.
[0014] According to another aspect of the present invention, there is provided an electronic device, which may include:
[0015] at least one processor; and
[0016] a memory communicatively connected to at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor implements the method for acquiring test case data provided by any embodiment of the present invention when executing the computer program.
[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, on which computer instructions are stored, and the computer instructions are used to enable a processor to implement the method for acquiring test case data provided by any embodiment of the present invention when executed.
[0019] The technical solution of the embodiment of the present invention obtains the log data of the business system, and creates the scenario rules for the test scenario corresponding to the business system, and the scenario rules are used to describe the test case data that conforms to the test scenario; further, based on the scenario rules, the test case data can be extracted from the log data, so that the business system can be tested in the test scenario based on the test case data. The above technical solution can automatically extract the test case data that conforms to the test scenario from the log data of the business system through the scenario rules created for the test scenario, and the test case data can be used to test the business system in the test scenario, thereby realizing the automatic acquisition of the test case data, thereby reducing the manpower cost consumed in the acquisition of the test case data.
[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 is a flowchart of a method for acquiring test case data provided by an embodiment of the present invention;
[0023] Figure 2 is a flowchart of another method for acquiring test case data provided by an embodiment of the present invention;
[0024] Figure 3is a flowchart of another method for acquiring test case data provided by an embodiment of the present invention;
[0025] Figure 4 is a flowchart of another method for acquiring test case data provided by an embodiment of the present invention;
[0026] Figure 5a is a timing diagram of an optional example of another method for acquiring test case data provided by an embodiment of the present invention;
[0027] Figure 5b is a flowchart of an example of log data collection in another method for acquiring test case data provided by an embodiment of the present invention;
[0028] Figure 5c is a flowchart of an example of extracting test case data in another method for acquiring test case data provided by an embodiment of the present invention;
[0029] Figure 6 is a structural block diagram of a device for acquiring test case data provided according to an embodiment of the present invention;
[0030] Figure 7 It is a schematic diagram of an electronic device for implementing the method for acquiring test case data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention 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 interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. The situations of "target", "original", etc. are similar and will not be repeated here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] Figure 1 It is a flowchart of a method for acquiring test case data provided in an embodiment of the present invention. This embodiment can be applied to the case of automatically acquiring test case data, and in particular, can be applied to the case of automatically extracting test case data that meets the test scenario from the log data of the business system. The method can be executed by the test case data acquisition device provided in an embodiment of the present invention, and the device can be implemented by software and / or hardware. The device can be integrated on an electronic device, and the electronic device can be various user terminals or servers, and in particular, it can be a server deployed with a business system.
[0034] See also Figure 1 The method of the embodiment of the present invention specifically includes the following steps:
[0035] S110. Obtain log data of the business system.
[0036] Among them, the business system can be understood as a system that can perform business processing, that is, execute business logic, and in particular, it can be a server-side system. In combination with the application scenarios that may be involved in the embodiments of the present invention, the business system can be the server of an application (Application, App), that is, a server-side application; it can also be the server of a sub-application (that is, a service or method) in the application, for example, it can be the server of the settlement, order or homepage in the shopping program, etc.; and so on, which are not specifically limited here. The number of business systems can be one, two or more, which can be set according to actual needs, and is not specifically limited here. In actual applications, optionally, when there are at least two business systems, these business systems can be deployed on the same server or on different servers, which is not specifically limited here. Optionally, in combination with the application scenarios that may be involved in the embodiments of the present invention, the above-mentioned business system can also be called business SOA, where SOA is the abbreviation of service-oriented architecture.
[0037] Log data can be understood as log data generated during the operation of the business system, for example, log data generated when a user accesses the business system; or log data generated when a method in the business system is executed; etc., which are not specifically limited here. The number of log data can be one, two or more, which is related to the actual situation and is not specifically limited here.
[0038] S120: Obtain scenario rules, wherein the scenario rules are created for a test scenario corresponding to the business system, and the scenario rules are used to describe test case data that conforms to the test scenario.
[0039] The test scenario can be understood as a scenario corresponding to the business system and having a test requirement, specifically, a scenario that may be involved in the operation of the business system and has a test requirement. For example, here, taking the business system as a calculator as an example, the test scenario can be an addition scenario, a subtraction scenario, a multiplication scenario, or a division scenario, etc., which is not specifically limited here.
[0040] Scenario rules can be understood as rules created for test scenarios, and can be used to describe test case data that conforms to the test scenarios. For example, they can be target expressions, which can be used to characterize the value-taking rules of node values of test case data under the target node; they can be the system identifier of the business system, and / or the interface identifier of the test interface with test requirements in the business system; they can also be the data acquisition quantity and data acquisition cycle; etc., which are not specifically limited here.
[0041] Test case data can be understood as the data in the test case. The test case can be understood as the use case set up to implement the testing process of the business system under the test scenario. Specifically, it can be understood as a description of the testing task for the business system. In actual applications, it may include test objectives, test environment, input data, test steps, expected results and test scripts, etc., and finally form a document.
[0042] S130. Extract test case data from the log data based on the scenario rules, so as to test the business system in the test scenario based on the test case data.
[0043] Among them, based on the scenario rules, test case data that meets the test scenario is extracted from the log data, so that the business system can be tested in the test scenario based on the test case data.
[0044] It should be noted that the above technical solution can automatically extract test case data from log data through scenario rules, which has at least the following advantages:
[0045] 1. Automatic capture of test case data is achieved. On this basis, on the one hand, there is no need for manual configuration or manual search of test case data, which reduces labor costs and improves the efficiency of obtaining test case data; on the other hand, a sufficient amount of test case data can be obtained, thereby ensuring the comprehensive coverage of test case data for various situations.
[0046] 2. Support non-intrusive project code, that is, there is no need to obtain test case data through hard coding, thereby reducing the difficulty of obtaining test case data.
[0047] 3. It can be extended to any test scenario, improving the versatility of the test case data acquisition process.
[0048] 4. By extracting test case data from log data, the data source is simple and the cost is low.
[0049] The technical solution of the embodiment of the present invention obtains the log data of the business system, and creates the scenario rules for the test scenario corresponding to the business system, and the scenario rules are used to describe the test case data that conforms to the test scenario; further, based on the scenario rules, the test case data can be extracted from the log data, so that the business system can be tested in the test scenario based on the test case data. The above technical solution can automatically extract the test case data that conforms to the test scenario from the log data of the business system through the scenario rules created for the test scenario, and the test case data can be used to test the business system in the test scenario, thereby realizing the automatic acquisition of the test case data, thereby reducing the manpower cost consumed in the acquisition of the test case data.
[0050] On this basis, an optional technical solution is that after the scene rules are created, they are synchronized to the preset path of the preset server;
[0051] Get scene rules, including:
[0052] Detect the scene rules synchronized to the preset path;
[0053] When a new scene rule is detected under the preset path, the new scene rule is acquired from the preset path.
[0054] The preset server may be understood as a server pre-set for storing scene rules, and the preset path may be understood as a path (Path) pre-set in the preset server for storing scene rules. In combination with the application scenarios that may be involved in the embodiments of the present invention, the preset server may be a server deployed with a distributed application coordination service (Zookeeper).
[0055] After creating the scene rules, the scene rules can be synchronized to the preset server, so that the scene rules are stored in the preset path of the preset server. On this basis, the preset path can be detected in real time, that is, the scene rules synchronized to the preset path can be detected in real time, and when the newly added scene rules are detected, that is, when the new scene rules are stored in the preset path, the newly added scene rules can be obtained from the preset path, thereby achieving the effect of obtaining the latest scene rules in real time.
[0056] Another optional technical solution is that log data is generated during the online operation of the business system. The advantage of this setting is that the test case data obtained is real data generated during the online operation process. It is inherently operational and can directly run the test case data without the need to import the test case data through scripts or run it manually, thereby improving the test efficiency. In addition, it can also support the rapid acquisition of real test case data in large-scale distributed microservice systems.
[0057] Figure 2 It is a flowchart of another method for obtaining test case data provided in an embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, the scenario rule includes at least a target expression, and the target expression is used to characterize the value-taking rule of the node value of the test case data under the target node; based on the scenario rule, the test case data is extracted from the log data, including: the log data whose node value under the target node in the log data meets the value-taking rule is used as the test case data. Among them, the explanation of the terms that are the same or corresponding to the above-mentioned embodiments will not be repeated here.
[0058] See also Figure 2 The method of this embodiment may specifically include the following steps:
[0059] S210: Obtain log data of the business system.
[0060] S220. Obtain scenario rules, wherein the scenario rules are created for the test scenarios corresponding to the business system, the scenario rules are used to describe the test case data that conforms to the test scenarios, and the scenario rules include at least a target expression, and the target expression is used to characterize the value-taking rule of the node value of the test case data under the target node.
[0061] Among them, the target expression can be understood as an expression for characterizing the value-taking rule of the node value of the test case data under the target node. In combination with the application scenarios that may be involved in the embodiments of the present invention, it can be a JSONPath expression, and the log data can be data of a JSON structure. The target node can be understood as the node involved in the test case data. Taking the above-mentioned subtraction operation scenario as an example, the target node may include a minuend and a subtrahend. The value-taking rule can be understood as the rule that the node value of the test case data under the target node must meet in terms of value taking. For example, assuming that the test scenario is a subtraction operation scenario within ten, the value-taking rule can be that the node value under the minuend is within ten and the node value under the subtrahend is within ten.
[0062] S230. Use the log data whose node values under the target node meet the value selection rules as test case data, so as to test the business system in the test scenario based on the test case data.
[0063] Among them, according to the above analysis, for all log data, the log data whose node value under the target node meets the value selection rule meets the relevant requirements of the test case data, and can therefore be used as test case data. In practical applications, optionally, the above process of matching log data by the target expression can also be understood as the process of processing log data according to the target expression, thereby obtaining test case data that meets the target expression.
[0064] The technical solution of the embodiment of the present invention can accurately match the test case data that meets the test scenario from the log data by using the target expression.
[0065] On this basis, an optional technical solution is that the test scenario specifically corresponds to the test interface in the business system, and the scenario rule also includes the interface identifier of the test interface; the log data whose node value under the target node meets the value selection rule is used as the test case data, including:
[0066] The log data generated when the test interface represented by the interface identifier is called and the node value under the target node meets the value rule is used as the test case data;
[0067] Based on the test case data, the business system is tested in the test scenario, including:
[0068] Based on the test case data, the test interface is tested in the test scenario.
[0069] Among them, the test interface can be understood as an interface with test requirements among multiple interfaces exposed to the outside by the business system, and the interface identifier can be used to uniquely characterize the test interface. In order to make the retrieved test case data available for testing the test interface, the scenario rules created for the test scenario corresponding to the test interface may also include an interface identifier, so as to determine the interface corresponding to the test case data to be retrieved among the multiple interfaces of the business system based on the interface identifier. Specifically, using the scenario rules, the test case data generated when the test interface is called and whose node value under the target node meets the value rules are matched from the log data, thereby realizing effective testing of the test interface in the test scenario based on the test case data.
[0070] In actual applications, optionally, when the number of business systems is at least two, that is, the acquired log data comes from at least two business systems, for a test scenario corresponding to a business system among the at least two business systems, the scenario rules of the test scenario may also include the system identifier of the business system, that is, binding the scenario rules to the business system and the test interface in the business system, so that the test case data obtained can effectively realize the effective testing of the test interface in the business system.
[0071] Based on any of the above technical solutions, optionally, the scenario rule at least includes the data collection quantity and the data collection cycle;
[0072] Based on scenario rules, test case data is extracted from log data, including:
[0073] Extract the test case data of the data extraction quantity from the log data;
[0074] The method for obtaining the test case data further includes:
[0075] When the test case data of the data acquisition quantity is acquired, the acquisition of the test case data is stopped;
[0076] When the current time meets the data extraction cycle, re-extract the test case data of the data extraction quantity from the log data;
[0077] Based on the newly retrieved test case data, the historically retrieved test case data is updated.
[0078] The data extraction quantity can be used to represent the amount of test case data that needs to be extracted in each data extraction cycle. Test case data of the data extraction quantity is extracted from the log data, and after a sufficient amount of test case data is extracted, the extraction can be stopped, and the data extraction process ends.
[0079] The data retrieval cycle can be used to characterize the time interval between two data retrieval processes, for example, it can be 1 hour, half a day or 1 day, etc. In combination with the application scenarios that may be involved in the embodiments of the present invention, considering that some test case data, such as the user's membership status, may have timeliness, and the log data can be updated in real time as the business system runs, in order to ensure the timeliness of the test case data, when the current time satisfies the data retrieval cycle, that is, the time interval between the current time and the start time of the last data retrieval process is the data retrieval cycle, the test case data of the data retrieval quantity can be re-retrieved from the log data, and based on the re-retrieved test case data, the historical (i.e., last) retrieved test case data can be updated.
[0080] The above technical solution can effectively ensure the timeliness of the test case data of the current application by periodically extracting the test case data from the log data, thereby ensuring the accuracy of subsequent tests.
[0081] Figure 3 It is a flowchart of another method for acquiring test case data provided in an embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, after extracting the test case data from the log data based on the scenario rules, the above-mentioned method for acquiring the test case data also includes: returning the test case data to the management system, so as to manage the test case data on the management system based on the test scenario. Among them, the explanations of the terms that are the same or corresponding to the above-mentioned embodiments are not repeated here.
[0082] See also Figure 3 The method of this embodiment may specifically include the following steps:
[0083] S310: Obtain log data of the business system.
[0084] S320: Obtain scenario rules, wherein the scenario rules are created for a test scenario corresponding to the business system, and the scenario rules are used to describe test case data that conforms to the test scenario.
[0085] S330. Based on the scenario rules, test case data is extracted from the log data, so as to test the business system in the test scenario based on the test case data.
[0086] S340: Return the test case data to the management system so that the test case data can be managed on the management system based on the test scenario.
[0087] The management system can be understood as a pre-developed system for implementing test case data management, and on this basis, can also be understood as a system for implementing scenario rule management. In practical applications, the above management system can also be optionally referred to as a management platform.
[0088] The test case data is returned to the management system, so that the test case data can be managed through the management system based on the test scenario. That is to say, on the one hand, the test case data extracted for different test scenarios are maintained in their respective test scenarios. On the other hand, the test case data in different test scenarios are managed uniformly through the management system, which makes it unnecessary for different relevant personnel to manually find places (such as websites, documents or Excel tables, etc.) to manage their respective test case data. The above two aspects cooperate with each other to reduce the difficulty of managing test case data.
[0089] The technical solution in the embodiment of the present invention, through a unified management system, maintains all test case data retrieved for the same test scenario under the test scenario, that is, based on the test scenario, the test case data under different test scenarios are managed separately, thereby reducing the difficulty of managing the test case data.
[0090] On this basis, an optional technical solution is to obtain scenario rules, including: obtaining scenario rules created by a management system, wherein the scenario rules are managed by the management system.
[0091] In other words, relevant personnel can create scenario rules through the management system so that the management system can simultaneously manage the scenario rules and the test case data retrieved according to the scenario rules, thereby achieving convenient management of relevant data involved in the testing process.
[0092] Figure 4 It is a flowchart of another method for obtaining test case data provided in an embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, obtaining the log data of the business system may include: obtaining the log data of the business system from a log database, wherein the log data is written into the log database after being collected from the business system. Among them, the explanations of the terms that are the same or corresponding to the above-mentioned embodiments are not repeated here.
[0093] See also Figure 4 The method of this embodiment may specifically include the following steps:
[0094] S410 . Obtain log data of the business system from a log database, wherein the log data is written into the log database after being collected from the business system.
[0095] Among them, according to the above description, on the one hand, log data can be generated during the operation of the business system, which means that log data can be collected from the business system. On the other hand, when there are two or more business systems, in order to quickly obtain log data from different business systems, the log data collected from these business systems can be written into the log database, so that the log data of these business systems can be uniformly obtained from the log database.
[0096] In combination with the application scenarios that may be involved in the embodiments of the present invention, optionally, the above-mentioned log database can be ElasticSearch (ie ES) or Hbase, and such a log database can also be called a log system; of course, it can also be other types of log databases, such as MySQL, etc., which are not specifically limited here.
[0097] It should be noted that the server used to obtain log data of the business system from the log database and the server used to collect log data from the business system and write the collected log data into the log database may be the same or different, and no specific limitation is made here.
[0098] S420: Obtain scenario rules, wherein the scenario rules are created for a test scenario corresponding to the business system, and the scenario rules are used to describe test case data that conforms to the test scenario.
[0099] S430. Extract test case data from the log data based on the scenario rules, so as to test the business system in the test scenario based on the test case data.
[0100] The technical solution of the embodiment of the present invention improves the convenience of obtaining log data by uniformly obtaining log data from a log database.
[0101] On this basis, an optional technical solution is to process the log data through the following steps:
[0102] Use log collection tools to collect log data from the business system and write the log data to the topic storage area under the log topic through the message queue;
[0103] Use the log storage tool that subscribes to the log topic to read the log data from the topic storage area and write the log data to the log database.
[0104] Among them, the log collection tool can be understood as a tool for collecting log data from the business system. On this basis, it can also cooperate with the log storage tool to write the collected log data into the log database through the message queue (MessageQueue, MQ) method. Combined with the application scenarios that may be involved in the embodiments of the present invention, optionally, the above-mentioned log collection tool can be implemented through Rsyslog; optionally, the server used to deploy the business system and the server used to deploy the log collection tool can be the same or different servers, which is not specifically limited here.
[0105] Specifically, log data is collected from the business system using a log collection tool, and then the collected log data is written to the topic storage area under the log topic (Topic) through MQ. The topic storage area can be understood as an area for storing MQ messages corresponding to the log topic, and the MQ message can be generated based on the collected log data. Furthermore, for the log storage tool that has subscribed to the log topic, the log storage tool is used to read the log data from the topic storage area. Specifically, the MQ message can be read, and then the log data is extracted from the MQ message; then, the read log data is written to the log database, thereby achieving effective storage of the log data.
[0106] On this basis, optionally, the method for obtaining the test case data further includes:
[0107] Generate log data based on the input and output parameters of the call request for calling the business system, and print the log data to the system storage area of the business system;
[0108] Use log collection tools to collect log data from business systems, including:
[0109] Use the log collection tool to collect log data from the system storage area.
[0110] Among them, the call request can be understood as a request for calling a business system. On this basis, the input parameter can be understood as the input parameter of the call request, and the output parameter can be understood as the output parameter of the call request. Based on the input and output parameters of the call request, log data is generated. In actual applications, optionally, in addition to referring to the input and output parameters of the call request, the input and output parameters of the method requested to be called by the call request in the business system can also be combined to jointly generate log data. Optionally, the interface exposed by the business system may involve two or more methods, and respective tracking identifiers (TracerId) can be set for these interfaces respectively, so that the log data related to the interface can be connected in series based on the TracerId, thereby realizing the correlation between the log data.
[0111] Furthermore, the log data is printed to the system storage area of the business system, which can be understood as an area on the business system for storing relevant data, such as a disk. On this basis, a log collection tool can be used to collect log data from the system storage area, thereby achieving effective collection of log data.
[0112] In combination with the application scenarios that may be involved in the embodiments of the present invention, the above-mentioned log data generation process and printing process can be implemented through a pre-developed log tracking software development kit (SDK) that has been connected to the business system. On this basis, optionally, the log tracking SDK can be connected to the business system using an Agent access method, and the bytecode is enhanced at startup to perform corresponding operations to implement the log data generation process and printing process.
[0113] In order to better understand the above-mentioned technical solutions as a whole, the following is an exemplary description of the above-mentioned technical solutions in combination with specific examples. Figure 5a As shown, the test engineer creates scenario rules for different test scenarios on the management system, so that the scenario rules are managed through the management system, and the scenario rules are synchronized to the data extraction worker, which can be understood as the server end for executing the above-mentioned test case data acquisition method. Through the MQ method, the log data generated during the online operation of the business system is sent to the log processing worker, so that the received log data is written into the log database such as ES or Hbase through the log processing worker. The log processing worker can be understood as the above-mentioned log storage tool. The log data is obtained from the log database through the data extraction worker, that is, the log data stored in the log database is synchronized to the data extraction worker, so that the log data can be processed according to the scenario rules through the data extraction worker, that is, the test case data is extracted from these log data, and the extracted test case data is returned to the management system. Thus, the test case data can be managed through the management system, for example, the test case data can be displayed to the test engineer.
[0114] For further example, see Figure 5b , through the log tracking SDK, print the log data generated during the online operation of the business system to the disk; then, through Rsyslog, collect the log data from the disk, and send the collected log data to the log processing Worker through MQ; then, through the log processing Worker, write the received log data to the log database (such as Hbase or ES).
[0115] For further example, see Figure 5c, through the management system, save the created scenario rules to MySQL, and synchronize the scenario rules to the preset path of Zookeeper. Through the data extraction Worker, the preset path is detected in real time, and when the new scenario rules are detected, the new scenario rules are loaded from the preset path, and the log data obtained from Hbase / ES is filtered according to the JSONPath expression in the scenario rules, and the test case data that meets the test scenario is extracted, and the test case data is returned to the management system, so that the received test case data is saved to MySQL through the management system.
[0116] Figure 6 This is a structural block diagram of a device for acquiring test case data provided in an embodiment of the present invention. The device is used to execute the method for acquiring test case data provided in any of the above embodiments. The device and the method for acquiring test case data in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the device for acquiring test case data, please refer to the embodiment of the method for acquiring test case data. Figure 6 The device may specifically include: a log data acquisition module 510, a scenario rule acquisition module 520 and a test case data acquisition module 530.
[0117] The log data acquisition module 510 is used to acquire log data of the business system;
[0118] A scenario rule acquisition module 520 is used to acquire a scenario rule, which is created for a test scenario corresponding to a business system, and is used to describe test case data that conforms to the test scenario;
[0119] The test case data extraction module 530 is used to extract the test case data from the log data based on the scenario rules, so as to test the business system in the test scenario based on the test case data.
[0120] Optionally, the scenario rule may include at least a target expression, where the target expression is used to represent a value-taking rule of a node value under a target node of the test case data;
[0121] The test case data retrieval module 530 includes:
[0122] The first test case data extraction unit is used to use the log data whose node value under the target node in the log data meets the value selection rule as the test case data.
[0123] On this basis, optionally, the test scenario specifically corresponds to a test interface in the business system, and the scenario rule further includes an interface identifier of the test interface;
[0124] The first test case data retrieval unit is specifically used for:
[0125] The log data generated when the test interface represented by the interface identifier is called and the node value under the target node meets the value rule is used as the test case data;
[0126] The test case data retrieval module 530 further includes:
[0127] The test unit is used to test the test interface in the test scenario based on the test case data.
[0128] Optionally, the scenario rule includes at least the data collection quantity and the data collection cycle;
[0129] The test case data retrieval module 530 includes:
[0130] The second test case data extraction unit is used to extract the test case data of the data extraction quantity from the log data;
[0131] The above-mentioned device for acquiring test case data also includes:
[0132] A test case data stopping acquisition module is used to stop acquiring test case data when the test case data of the data acquisition quantity is acquired;
[0133] The test case data re-retrieval module is used to re-retrieve the test case data of the data retrieval quantity from the log data when the current time meets the data retrieval cycle;
[0134] The test case data updating module is used to update the test case data retrieved historically based on the test case data retrieved again.
[0135] Optionally, the device for acquiring the test case data further includes:
[0136] The test case data return module is used to return the test case data to the management system after extracting the test case data from the log data based on the scenario rules, so that the test case data can be managed on the management system based on the test scenario.
[0137] On this basis, optionally, the scene rule acquisition module 520 is specifically used to:
[0138] A scenario rule created by the management system is acquired, wherein the scenario rule is managed by the management system.
[0139] Optionally, after the scene rules are created, they are synchronized to the preset path of the preset server;
[0140] The scene rule acquisition module 520 is specifically used for:
[0141] Detect the scene rules synchronized to the preset path;
[0142] When a new scene rule is detected under the preset path, the new scene rule is acquired from the preset path.
[0143] Optionally, the log data acquisition module 510 is specifically used to:
[0144] The log data of the business system is obtained from the log database, wherein the log data is written into the log database after being collected from the business system.
[0145] On this basis, optionally, log data is processed by the following modules:
[0146] The first log data writing module is used to collect log data from the business system using a log collection tool, and write the log data to a topic storage area under a log topic through a message queue;
[0147] The second log data writing module is used to read the log data from the topic storage area using the log storage tool that subscribes to the log topic, and write the log data into the log database.
[0148] Optionally, based on the above-mentioned device for acquiring test case data, the device further includes:
[0149] A log data printing module, used to generate log data based on input parameters and output parameters of a call request for calling a business system, and print the log data to a system storage area of the business system;
[0150] The first log data writing module includes:
[0151] The log data collection unit is used to collect log data from the system storage area using a log collection tool.
[0152] Optionally, log data is generated during the online operation of the business system.
[0153] The device for acquiring test case data provided by the embodiment of the present invention acquires the log data of the business system and the scenario rules created for the test scenario corresponding to the business system through the cooperation of the log data acquisition module and the scenario rules, and the scenario rules can be used to describe the test case data that conforms to the test scenario; further, the test case data can be retrieved from the log data based on the scenario rules through the test case data retrieval module, so that the business system can be tested under the test scenario based on the test case data. The above device can automatically retrieve the test case data that conforms to the test scenario from the log data of the business system through the scenario rules created for the test scenario, and the test case data can be used to test the business system under the test scenario, thereby realizing the automatic acquisition of the test case data, thereby reducing the manpower cost consumed in the acquisition of the test case data.
[0154] The apparatus for acquiring test case data provided in the embodiment of the present invention can execute the method for acquiring test case data provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0155] It is worth noting that in the embodiment of the above-mentioned test case data acquisition device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0156] Figure 7 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0157] like Figure 7As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0158] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0159] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a method for acquiring test case data.
[0160] In some embodiments, the method for acquiring test case data may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for acquiring test case data described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method for acquiring test case data in any other appropriate manner (e.g., by means of firmware).
[0161] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0162] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0163] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0164] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0165] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0166] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0167] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0168] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for acquiring test case data, characterized in that: include: Obtain log data from business systems; Obtaining a scenario rule, wherein the scenario rule is created for a test scenario corresponding to the business system, and the scenario rule is used to describe test case data that conforms to the test scenario; Based on the scenario rule, the test case data is retrieved from the log data, so as to test the business system in the test scenario based on the test case data.
2. The method according to claim 1, characterized in that The scenario rule at least includes a target expression, and the target expression is used to represent the value rule of the node value of the test case data under the target node; The extracting the test case data from the log data based on the scenario rule includes: The log data whose node value under the target node conforms to the value-taking rule in the log data is used as the test case data.
3. The method according to claim 2, characterized in that The test scenario specifically corresponds to a test interface in the business system, and the scenario rule further includes an interface identifier of the test interface; The step of using the log data, in which the node value under the target node conforms to the value-taking rule, as the test case data includes: The log data in the log data, which is generated when the test interface represented by the interface identifier is called and the node value under the target node conforms to the value-taking rule, is used as the test case data; The testing of the business system in the test scenario based on the test case data includes: Based on the test case data, the test interface is tested in the test scenario.
4. The method according to claim 1, characterized in that The scenario rules at least include the data collection quantity and the data collection cycle; The extracting the test case data from the log data based on the scenario rule includes: Extracting the test case data of the data extraction quantity from the log data; The method further comprises: When the test case data of the data acquisition quantity are acquired, stopping acquiring the test case data; When the current time satisfies the data retrieval cycle, retrieving the test case data of the data retrieval quantity from the log data; Based on the newly retrieved test case data, the test case data retrieved historically is updated.
5. The method according to claim 1, characterized in that After extracting the test case data from the log data based on the scenario rule, the method further includes: The test case data is returned to a management system so that the test case data can be managed on the management system based on the test scenario.
6. The method according to claim 5, characterized in that The obtaining of scene rules includes: A scenario rule created by the management system is acquired, wherein the scenario rule is managed by the management system.
7. The method according to claim 1, characterized in that After being created, the scene rules are synchronized to a preset path of a preset server; The obtaining of scene rules includes: Detecting the scene rules synchronized to the preset path; In the case where a newly added scenario rule is detected under the preset path, the newly added scenario rule is acquired from the preset path.
8. The method according to claim 1, characterized in that: Obtain log data from business systems, including: The log data of the business system is acquired from a log database, wherein the log data is written into the log database after being collected from the business system.
9. The method according to claim 8, characterized in that The log data is processed through the following steps: Using a log collection tool, the log data is collected from the business system, and the log data is written to a topic storage area under a log topic through a message queue; The log data is read from the subject storage area using a log storage tool that subscribes to the log subject, and the log data is written into the log database.
10. The method according to claim 9, characterized in that Also includes: generating the log data based on the input parameters and output parameters of the call request for calling the business system, and printing the log data to the system storage area of the business system; The log data is collected from the business system using a log collection tool, including: The log data is collected from the system storage area using a log collection tool.
11. The method according to claim 1, characterized in that The log data is generated during the online operation of the business system.
12. A device for acquiring test case data, characterized in that: include: Log data acquisition module, used to obtain log data of business systems; A scenario rule acquisition module, used to acquire scenario rules, wherein the scenario rules are created for a test scenario corresponding to the business system, and the scenario rules are used to describe test case data that conforms to the test scenario; The test case data extraction module is used to extract the test case data from the log data based on the scenario rule, so as to test the business system in the test scenario based on the test case data.
13. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor executes the method for acquiring test case data according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for acquiring test case data as described in any one of claims 1 to 11 when executed.