Block chain defect analysis method, electronic equipment and storage medium

By automatically extracting defect characteristics of blockchain test cases from operation logs and system logs, and matching them with the preset defect database to generate reports, the problem of high labor costs after blockchain automation testing is solved, and efficient defect analysis is achieved.

CN120276978APending Publication Date: 2025-07-08HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510168163.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-14
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

In the prior art, defect analysis of blockchain's automated testing requires a lot of manual intervention, resulting in high labor costs.

Method used

By obtaining test results of test cases, extract defect features from operation logs and system logs, and matching them with preset defect libraries to generate test reports to automatically analyze defects.

Benefits of technology

It reduces the workload of manual analysis, reduces labor costs, and improves the efficiency of defect analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120276978A_ABST
    Figure CN120276978A_ABST
Patent Text Reader

Abstract

The invention relates to a defect analysis method for a block chain, electronic equipment and a storage medium, and the method comprises the steps: obtaining a test result corresponding to each test case which is used for testing a to-be-tested block chain; according to the test results corresponding to the test cases, defect features corresponding to the test cases are obtained from an operation log and / or a system log, the operation log is used for recording operation information executed by the test cases on the to-be-tested block chain, and the operation information is stored in the system log; the system log is used for recording state information of the to-be-tested block chain in the process of executing each test case; the defect features corresponding to all the test cases are matched with defect features of all defects in a preset defect library, a test report is generated according to the matching result, and at least one defect and the defect features corresponding to the at least one defect are recorded in the preset defect library in advance. Therefore, the workload of manual analysis can be reduced, and the purpose of reducing the labor cost is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular, to a method for analyzing defects of a blockchain, an electronic device, and a storage medium. Background Art

[0002] Since the blockchain involves complex encryption algorithms, smart contracts, and distributed networks, it is necessary to conduct tests to ensure that its various functions can operate normally and verify whether it can meet the expected design requirements. In related technologies, the testing process of the blockchain has been basically automated. However, for the defects that appear in the test results after automated testing, manual analysis is still required one by one. Due to the high complexity of the blockchain system itself, a large amount of human cost is consumed. Therefore, how to reduce the human cost of blockchain defect analysis has become an urgent technical problem to be solved. Summary of the Invention

[0003] This application provides a method for analyzing defects of a blockchain, an electronic device, and a storage medium, so as to solve the problem in related technologies that manual analysis of the defects that appear in the blockchain testing process is required one by one, resulting in a large amount of human cost.

[0004] In a first aspect, an embodiment of this application provides a method for analyzing defects of a blockchain. The method includes:

[0005] Obtain the test results corresponding to each test case, where the test case is used to test the blockchain to be tested;

[0006] According to the test results corresponding to each test case, obtain the defect features corresponding to each test case from the operation log and / or the system log, where the operation log is used to record the operation information of each test case on the blockchain to be tested, and the system log is used to record the status information of the blockchain to be tested during the execution of each test case;

[0007] Match the defect features corresponding to each test case with the defect features of each defect in the preset defect library, and generate a test report according to the matching result, where at least one defect and the defect features corresponding to the at least one defect are pre-recorded in the preset defect library.

[0008] Optionally, the obtaining the defect features corresponding to each test case from the operation log and / or the system log according to the test results corresponding to each test case includes:

[0009] For the successful test cases with the test result being successful, obtain the system log content corresponding to each successful test case from the system log;

[0010] Filter the system log content corresponding to each successful test case based on a preset exception event to obtain a target exception event whose cumulative occurrence times is greater than or equal to a preset number of times;

[0011] Based on the target exception event, determine the defect features corresponding to each successful test case from the system log content corresponding to each successful test case.

[0012] Optionally, the obtaining the defect features corresponding to each test case from the operation log and / or the system log according to the test results corresponding to each test case includes:

[0013] For a failed test case whose test result is test failure, obtain the abnormal operation information corresponding to each failed test case from the operation log, where the abnormal operation information includes an abnormal object, an upstream operation of the abnormal object, and a time stamp corresponding to the upstream operation;

[0014] Based on the abnormal operation information corresponding to each failed test case, obtain the system log content corresponding to each failed test case from the system log, and determine whether there is an abnormal keyword in the system log content corresponding to each failed test case;

[0015] Based on the abnormal keywords corresponding to each first failed test case, determine the defect features corresponding to each first failed test case, or based on the abnormal operation information corresponding to each second failed test case, determine the defect features corresponding to each second failed test case, where the first failed test case is a failed test case with an abnormal keyword in the system log content, and the second failed test case is a failed test case without an abnormal keyword in the system log content.

[0016] Optionally, after determining whether there is an abnormal keyword in the system log content corresponding to each failed test case, the method further includes:

[0017] Determine the event flow information from the system log content corresponding to each second failed test case, where the event flow information is used to characterize the key events existing in each layer of the blockchain to be tested and the association relationship between the key events, and the layers in the blockchain to be tested include a network layer, a storage layer, and a consensus layer.

[0018] Optionally, after determining the defect features corresponding to each first failed test case based on the abnormal keywords corresponding to each first failed test case, or determining the defect features corresponding to each second failed test case based on the abnormal operation information corresponding to each second failed test case, the method further includes:

[0019] Collect the environmental information in the blockchain to be tested based on the defect features corresponding to each first failure test case and the defect features corresponding to each second failure test case, where the environmental information includes at least one of the central processing unit usage rate, disk read efficiency, network connectivity, and file directory permissions.

[0020] Optionally, the method of matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report based on the matching results includes:

[0021] Calculate the similarity between the defect features corresponding to each test case and the defect features of each defect in the preset defect library, where the defect features include at least one of the defect type, the abnormal event corresponding to the defect, the test case number corresponding to the defect, and the abnormal keyword corresponding to the defect;

[0022] According to the calculation results, determine the matching results corresponding to each test case, and generate a test report based on the matching results corresponding to each test case. The first display area of the test report is used to display the defects that match successfully, and the second display area of the test report is used to display the defects that match unsuccessfully. The defects that match successfully refer to the defects with a similarity greater than or equal to the first preset threshold, and the defects that match unsuccessfully refer to the defects with a similarity less than the first preset threshold. The first display area and the second display area are two different areas on the test report.

[0023] Optionally, after the method of matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report based on the matching results, the method further includes:

[0024] Receive an operation instruction for the target button in the test report;

[0025] In response to the operation instruction, determine whether the defect corresponding to the position of the target button is repeated with the defects in the preset defect library;

[0026] In the case where the defect corresponding to the position of the target button is not repeated with the defects in the preset defect library, update the defect and defect features corresponding to the position of the target button to the preset defect library.

[0027] Optionally, before the method of matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report based on the matching results, the method further includes:

[0028] Based on the preset matching rules, classify the defect features corresponding to each test case, and remove duplicates from the defect features with a similarity higher than the second preset threshold that belong to the same defect classification.

[0029] In a second aspect, an embodiment of the present application further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0030] The memory is used to store a computer program;

[0031] The processor is configured to implement the blockchain defect analysis method described in the first aspect when executing the program stored on the memory.

[0032] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the blockchain defect analysis method described in the first aspect.

[0033] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: In the method provided by the embodiments of the present application, by obtaining the test results corresponding to each test case, where the test case is used to test the blockchain to be tested; according to the test results corresponding to each test case, defect features corresponding to each test case are obtained from the operation log and / or the system log, where the operation log is used to record the operation information of each test case on the blockchain to be tested, and the system log is used to record the status information of the blockchain to be tested during the execution of each test case; the defect features corresponding to each test case are matched with the defect features of each defect in the preset defect library, and a test report is generated according to the matching result, where at least one defect and the defect features corresponding to the at least one defect are pre-recorded in the preset defect library. In the above manner, it is possible to automatically obtain the defect features corresponding to each test case from the operation log and / or the system log according to the test results corresponding to each test case, then automatically match the defect features corresponding to each test case with the defect features of each defect in the preset defect library, and generate a test report according to the matching result, so that it is not necessary to rely on manual analysis of each defect that appears during the blockchain testing process, thereby reducing the workload of manual analysis and achieving the purpose of reducing labor costs. Description of the Drawings

[0034] The drawings here are incorporated into the description and form a part of this description, showing embodiments consistent with the present invention and used together with the description to explain the principles of the present invention.

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained according to these drawings without creative efforts.

[0036] Figure 1 A flowchart of a method for analyzing defects in a blockchain provided in an embodiment of the present application;

[0037] Figure 2 A flowchart of another method for analyzing defects in a blockchain provided in an embodiment of the present application;

[0038] Figure 3 A schematic diagram of the structure of a blockchain defect analysis device provided in an embodiment of the present application;

[0039] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0041] See also Figure 1 , Figure 1 A flowchart of a method for analyzing blockchain defects provided in an embodiment of the present application. Figure 1 As shown, the defect analysis method of the blockchain may include the following steps:

[0042] Step S102: Obtain the test results corresponding to each test case, where the test case is used to test the blockchain to be tested.

[0043] Specifically, the above test cases refer to the test cases for testing the blockchain to be tested, which can be test cases in the blockchain integration test or test cases in various test items of the blockchain, and this application does not make specific restrictions. The test result corresponding to each test case can be any one of a successful test and a failed test, where a successful test means that the execution result of the test case is consistent with the expected result, and a failed test means that the execution result of the test case is inconsistent with the expected result.

[0044] The method for obtaining the test results corresponding to each test case can be to obtain them sequentially during the execution of each test case, or to obtain them all at once after all test cases are executed. The embodiment of the present application does not make any specific limitation.

[0045] Step S104: Obtain the defect features corresponding to each test case from the operation log and / or system log according to the test results corresponding to each test case. The operation log is used to record the operation information of each test case on the blockchain to be tested, and the system log is used to record the status information of the blockchain to be tested during the execution of each test case.

[0046] Specifically, the above operation log can be used to record the operation information of each test case on the blockchain to be tested. For example, it records when a certain test case executes what operation instructions, request instructions, or query instructions on a certain node in the blockchain to be tested. The above system log can be used to record the status information of the blockchain to be tested during the execution of each test case. For example, during the execution of a certain test case, information such as the network connection status, request response status, and storage status of clusters or nodes in the blockchain. The above defect features refer to the feature information extracted from the operation log and / or system log. The above defect features may include, but are not limited to, one or more of the defect type, the abnormal event corresponding to the defect, the test case number corresponding to the defect, and the abnormal keyword corresponding to the defect. Among them, the defect type here may include, but is not limited to, network failure, consensus failure, storage failure, environmental failure, etc.; the abnormal event corresponding to the defect may include, but is not limited to, node downtime, response timeout, abnormal node status, etc.; the test case number corresponding to the defect refers to the unique identifier corresponding to each test case, such as case001, case002, etc.; the abnormal keyword corresponding to the defect may include, but is not limited to, text such as error stack information, request error code, and log error message.

[0047] In this step, the defect features corresponding to each test case can be obtained from the operation log and / or system log according to the test results corresponding to each test case. As an optional implementation manner, the defect features corresponding to the test cases with test success and test failure can be obtained from the system log; as another optional implementation manner, the defect features corresponding to the test cases with test success can be obtained from the system log, and the defect features corresponding to the test cases with test failure can be obtained from the operation log and the system log. The embodiments of the present application do not make specific limitations.

[0048] Step S106: Match the defect features corresponding to each test case with the defect features of each defect in the preset defect library, and generate a test report according to the matching results. The preset defect library pre-records at least one defect and the defect features corresponding to at least one defect.

[0049] Specifically, at least one defect and the defect features corresponding to at least one defect are pre-recorded in the above-mentioned preset defect library. The defect features corresponding to each defect may also include, but are not limited to, one or more of the defect type, the abnormal event corresponding to the defect, the test case number corresponding to the defect, and the abnormal keyword corresponding to the defect. As an alternative implementation, the record items included in each defect in the preset defect library may be as shown in the following table:

[0050]

[0051] Through the above method, the defect features corresponding to each test case can be automatically obtained from the operation log and / or system log according to the test results corresponding to each test case, and then the defect features corresponding to each test case are automatically matched with the defect features of each defect in the preset defect library, and a test report is generated according to the matching result. In this way, there is no need to rely on manual analysis of each defect that appears in the blockchain testing process, thereby reducing the workload of manual analysis and achieving the purpose of reducing labor costs.

[0052] In an alternative embodiment, the above step S104, obtaining the defect features corresponding to each test case from the operation log and / or system log according to the test results corresponding to each test case, includes:

[0053] For the successful test cases with the test result of successful testing, obtain the system log content corresponding to each successful test case from the system log;

[0054] Filter the system log content corresponding to each successful test case based on the preset abnormal event to obtain the target abnormal event whose cumulative occurrence times is greater than or equal to the preset number of times;

[0055] Based on the target abnormal event, determine the defect features corresponding to each successful test case from the system log content corresponding to each successful test case.

[0056] Specifically, the above-mentioned preset abnormal event refers to the preset abnormal event, such as network disconnection, consensus change of master, etc. The above-mentioned preset number of times can be set according to actual needs, such as 5 times, 10 times, etc. The above-mentioned cumulative occurrence times may refer to the cumulative occurrence times of a certain abnormal event of a certain successful test case during the test process, or may refer to the cumulative occurrence times of a certain abnormal event of multiple successful test cases in a certain test scenario. The present application does not make specific limitations.

[0057] For the successful test cases with successful test results, the system log content corresponding to each successful test case can be obtained from the system log, and then the system log content corresponding to each successful test case can be filtered based on a preset exception event to obtain a target exception event with an accumulated occurrence frequency greater than or equal to a preset number of times. Then, based on the target exception event, the defect characteristics corresponding to each successful test case can be determined from the system log content corresponding to each successful test case.

[0058] By setting a preset number of times (i.e., setting a tolerance threshold) for each preset exception event, the tolerance for occasional exception events in the blockchain to be tested can be flexibly adjusted. In this way, only when the occurrence frequency of the preset exception event is greater than or equal to the tolerance threshold will it be recorded and submitted to the downstream for processing.

[0059] In an alternative embodiment, the above step S104, obtaining the defect characteristics corresponding to each test case from the operation log and / or system log according to the test results corresponding to each test case, includes:

[0060] For the failed test cases with test results of test failure, obtain the abnormal operation information corresponding to each failed test case from the operation log, where the abnormal operation information includes the abnormal object, the upstream operation of the abnormal object, and the timestamp corresponding to the upstream operation;

[0061] Based on the abnormal operation information corresponding to each failed test case, obtain the system log content corresponding to each failed test case from the system log, and determine whether there is an abnormal keyword in the system log content corresponding to each failed test case;

[0062] Based on the abnormal keywords corresponding to each first failed test case, determine the defect characteristics corresponding to each first failed test case, or based on the abnormal operation information corresponding to each second failed test case, determine the defect characteristics corresponding to each second failed test case, where the first failed test case is a failed test case with an abnormal keyword in the system log content, and the second failed test case is a failed test case without an abnormal keyword in the system log content.

[0063] Specifically, the above abnormal keywords can be set according to actual needs, such as texts like "error" and "panic". The above abnormal operation information can include but is not limited to the abnormal object, the upstream operation of the abnormal object, and the timestamp corresponding to the upstream operation, etc. The acquisition method of the above abnormal operation information is to first introduce a structured logging framework during the testing process to facilitate the preliminary parsing of the log structure, and then locate the abnormal situation and the abnormal object from back to front. Operation logs can generally be divided into three categories: operation type, request type, and query type. Among them, when an abnormality occurs in the operation type and the request type, the operation or request object can be directly marked as the abnormal object, but for the query type, the abnormal object needs to be marked according to the query result. Finally, continue to extract the upstream operation associated with the abnormal object upwards and record the timestamp corresponding to the upstream operation. The following takes two scenarios of request response failure and status verification failure as examples for illustration.

[0064] When the request response fails, assume that the last operation parsed from the operation log is: sending a certain request to node A, and the result is a response timeout, which belongs to a request exception. Then the abnormal object is node A. At this time, the relevant operations of node A can be further searched upwards from the operation log. Assume that the relevant operation of node A is to replace the certificate file and restart, then record the timestamp corresponding to this operation. When the status verification fails, assume that the last operation parsed from the operation log is: querying the system status from node A, and the result is a successful query, and the query result is that the status of node B is abnormal. Then the abnormal object is node B. At this time, the relevant operations of node B can be further searched upwards from the operation log and record the timestamp corresponding to this operation.

[0065] For the failed test cases with the test result of test failure, the abnormal operation information corresponding to each failed test case can be obtained from the operation log in the above manner. After obtaining the abnormal operation information corresponding to each failed test case, based on the abnormal operation information corresponding to each failed test case, the system log content corresponding to each failed test case can be obtained from the system log (that is, the system log content between the timestamp when each abnormal object in each failed test case is found and the timestamp corresponding to the upstream operation of the abnormal object), and then it is judged whether there are abnormal keywords in the system log content corresponding to each failed test case. For the first failed test cases with abnormal keywords in the system log content, the defect characteristics corresponding to each first failed test case can be determined based on the abnormal keywords corresponding to each first failed test case; for the second failed test cases with no abnormal keywords in the system log content, the defect characteristics corresponding to each second failed test case can be determined based on the abnormal operation information corresponding to each second failed test case.

[0066] By obtaining the abnormal operation information corresponding to each failed test case, the system log content corresponding to each failed test case can be more accurately obtained from the system log, which is conducive to using the system log content corresponding to each failed test case to obtain the defect characteristics corresponding to each failed test case.

[0067] In an optional embodiment, after the above step of determining whether there are abnormal keywords in the system log content corresponding to each failed test case, the method further includes:

[0068] Determine the event flow information from the system log content corresponding to each second failed test case, where the event flow information is used to characterize the key events existing in each layer of the blockchain to be tested and the association relationship between each key event. The layers in the blockchain to be tested include the network layer, the storage layer, and the consensus layer.

[0069] Specifically, for the second failed test case where there are no abnormal keywords in the system log content, the event flow information can also be determined from the system log content corresponding to each second failed test case. Here, the event flow information can be used to characterize the key events existing in each layer of the blockchain to be tested and the association relationship between each key event. The layers in the blockchain to be tested include the network layer, the storage layer, and the consensus layer, etc. In this way, the event flow information can be used as the detailed information of the corresponding second failed test case and displayed in the test report, which is convenient for personnel to provide a reference basis when conducting defect analysis.

[0070] In an optional embodiment, after the above step of determining the defect characteristics corresponding to each first failed test case based on the abnormal keywords corresponding to each first failed test case, or determining the defect characteristics corresponding to each second failed test case based on the abnormal operation information corresponding to each second failed test case, the method further includes:

[0071] Collect the environment information in the blockchain to be tested based on the defect characteristics corresponding to each first failed test case and the defect characteristics corresponding to each second failed test case, where the environment information includes at least one of the central processing unit usage rate, disk read efficiency, network connectivity, and file directory permissions.

[0072] Specifically, after determining the defect characteristics corresponding to each first failed test case and the defect characteristics corresponding to each second failed test case, the environment information in the blockchain to be tested can be collected based on the defect characteristics corresponding to each first failed test case and the defect characteristics corresponding to each second failed test case. Here, the environment information refers to the relevant information of the node environment or cluster environment in the blockchain to be tested, and it can include at least one of the central processing unit usage rate, disk read efficiency, network connectivity, and file directory permissions. As an optional implementation method, the environmental collection information corresponding to common defects is shown in the following table:

[0073] Common defects Environmental collection information Consensus - Node data lag CPU usage / Disk efficiency Network - Node connection failure Network connectivity Storage - File operation failure File directory permissions

[0074] In this way, the environmental information can be used as the detailed information of the corresponding failed test cases and displayed on the test report, which is convenient for personnel to provide a reference basis when conducting defect analysis.

[0075] In an optional embodiment, the above step 106 of matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report according to the matching result includes:

[0076] Calculating the similarity between the defect features corresponding to each test case and the defect features of each defect in the preset defect library, where the defect features include at least one of a defect type, an abnormal event corresponding to the defect, a test case number corresponding to the defect, and an abnormal keyword corresponding to the defect;

[0077] According to the calculation result, determining the matching result corresponding to each test case, and generating a test report according to the matching result corresponding to each test case. The first display area of the test report is used to display the defects that match successfully, and the second display area of the test report is used to display the defects that match failed. The defects that match successfully refer to the defects with a similarity greater than or equal to the first preset threshold, and the defects that match failed refer to the defects with a similarity less than the first preset threshold. The first display area and the second display area are two different areas on the test report.

[0078] Specifically, when matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library, the similarity between the defect features corresponding to each test case and the defect features of each defect in the preset defect library can be calculated first. Among them, the defect features here can include one or more of the defect type, the abnormal event corresponding to the defect, the test case number corresponding to the defect, and the abnormal keyword corresponding to the defect. When there are multiple defect features, different defect features are set with different weight values. By summing the weights, the similarity between the defect features corresponding to each test case and the defect features of each defect in the preset defect library can be calculated. Then, the calculated similarity can be compared with the first preset threshold. If the similarity is greater than or equal to the first preset threshold, it can be considered that the defect matches the preset defect library successfully. At this time, the defect can be displayed in the first display area of the test report; if the similarity is less than the first preset threshold, it can be considered that the defect fails to match the preset defect library. At this time, the defect is displayed in the second display area of the test report. That is to say, the successfully matched defects and the failed-matched defects in the test report can be displayed in different areas respectively to facilitate personnel to view them classified. The second display area is used to display the defects that fail to match during the test process and the defect details. The defect details display the defect features. If an abnormal event is filtered, the abnormal event is directly displayed; otherwise, the event stream information and / or environmental information obtained from the log parsing are displayed. The first display area is used to display the defects that match successfully during the test process and the defect details. Compared with the defect details of the defects that fail to match, the defect details can also display the feature information and occurrence frequency of the corresponding defects in the defect library, and also support viewing the influence range of the defects from the dimension of the blockchain version.

[0079] Of course, the test report can also display all the defects in one display area, that is, in the global overview area. In this way, all the defects that occur during the test process can be displayed from the test case dimension, which is convenient for viewing the details of each defect.

[0080] Through the above method, the defect features corresponding to each test case can be matched with the defect features of each defect in the preset defect library, and the matching results corresponding to each test case can be accurately determined. Furthermore, a test report can be generated according to the matching results corresponding to each test case, which is convenient for personnel to view and perform further analysis and processing.

[0081] In an optional embodiment, after the above step 106 of matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report according to the matching results, the method further includes:

[0082] Receiving an operation instruction for the target button in the test report;

[0083] In response to an operation instruction, determine whether the defect corresponding to the position of the target button duplicates a defect in a preset defect library;

[0084] In the case where the defect corresponding to the position of the target button does not duplicate a defect in the preset defect library, update the defect and defect features corresponding to the position of the target button to the preset defect library.

[0085] Specifically, after generating a test report, an operation instruction for the target button in the test report can be received. In response to the operation instruction, determine whether the defect corresponding to the position of the target button duplicates a defect in the preset defect library. If the defect corresponding to the position of the target button does not duplicate a defect in the preset defect library, the defect and defect features corresponding to the position of the target button can be updated to the preset defect library. In this way, the defects in the preset defect library can be dynamically updated, avoiding personnel investment in the same defect, and continuously expanding the coverage and accuracy of the defect library.

[0086] In an alternative embodiment, before step 106 above, that is, matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report according to the matching result, the method further includes:

[0087] Based on a preset matching rule, classify the defect features corresponding to each test case, and remove duplicates from the defect features with a similarity higher than a second preset threshold in the same defect classification.

[0088] Specifically, the above preset matching rule and the above second preset threshold can be set according to actual needs and are not limited herein.

[0089] Before matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library, the defect features corresponding to each test case can also be classified based on a preset matching rule, and duplicates can be removed from the defect features with a similarity higher than a second preset threshold in the same defect classification. This can effectively prevent the same defect from being repeatedly matched with the preset defect library, thereby improving the matching efficiency and reducing the resource occupancy rate.

[0090] In an alternative embodiment, the defect analysis process of the blockchain provided in the embodiments of the present application can be as follows Figure 2As shown in the figure, it mainly includes two stages: log analysis and defect matching. In the log analysis stage, different processing logics can be used for successful test cases and failed test cases. The former aims to identify non-direct abnormal events that may cause defects, while the latter tries to find the reasons for the failure of test cases by tracing the event link. Among them, for successful test cases, log analysis needs to be carried out through the system log filter to determine the existing defects and defect characteristics. The system log filter here is used to filter the system log content corresponding to each successful test case based on preset abnormal events. For failed test cases, log analysis needs to be carried out through the operation log analyzer, system log analyzer, and resource collector in sequence to determine the existing defects and defect characteristics. The operation log analyzer here is used to obtain the abnormal operation information corresponding to each failed test case from the operation log. The system log analyzer here is used to obtain the system log content corresponding to each failed test case from the system log based on the abnormal operation information corresponding to each failed test case, and determine whether there are abnormal keywords in the system log content corresponding to each failed test case. The resource collector here is used to collect the environmental information in the blockchain to be tested. In the defect matching stage, the defects found in the log analysis can be classified and marked, and then matched with the existing defects in the defect library through keyword matching and fuzzy matching to determine the matching results, and finally integrated into a test report.

[0091] In this way, the processes of defect extraction, classification, and matching in the blockchain testing process can be automatically completed, greatly reducing the time for manual troubleshooting, significantly reducing the workload of R & D personnel in defect analysis, and improving the analysis efficiency; moreover, based on the matching and feedback mechanism of the defect library, investment in the same defect can be avoided, and the coverage and accuracy of the defect library can be continuously expanded; in addition, the establishment of the defect library can intuitively help testers understand the occurrence frequency and influence range of defects.

[0092] See Figure 3 , Figure 3 which is a schematic structural diagram of a defect analysis device for a blockchain provided by an embodiment of the present application. As Figure 3 shown, the defect analysis device 300 for the blockchain includes:

[0093] A first acquisition module 302, configured to acquire the test results corresponding to each test case, where the test case is used to test the blockchain to be tested;

[0094] A second acquisition module 304, configured to acquire the defect characteristics corresponding to each test case from the operation log and / or system log according to the test results corresponding to each test case, where the operation log is used to record the operation information executed by each test case on the blockchain to be tested, and the system log is used to record the state information of the blockchain to be tested during the execution of each test case;

[0095] A matching and generating module 306, configured to match the defect features corresponding to each test case with the defect features of each defect in a preset defect library, and generate a test report according to the matching result, where at least one defect and the defect features corresponding to at least one defect are pre-recorded in the preset defect library.

[0096] Further, the second obtaining module 304 includes:

[0097] A first obtaining sub-module, configured to obtain the system log content corresponding to each successful case from the system log for the successful cases with a test result of successful;

[0098] A filtering sub-module, configured to filter the system log content corresponding to each successful case based on preset abnormal events to obtain target abnormal events whose cumulative occurrence times are greater than or equal to a preset number of times;

[0099] A first determining sub-module, configured to determine the defect features corresponding to each successful case from the system log content corresponding to each successful case based on the target abnormal events.

[0100] Further, the second obtaining module 304 further includes:

[0101] A second obtaining sub-module, configured to obtain the abnormal operation information corresponding to each failed case from the operation log for the failed cases with a test result of failed, where the abnormal operation information includes an abnormal object, the upstream operation of the abnormal object, and the time stamp corresponding to the upstream operation;

[0102] A third obtaining sub-module, configured to obtain the system log content corresponding to each failed case from the system log based on the abnormal operation information corresponding to each failed case, and determine whether there are abnormal keywords in the system log content corresponding to each failed case;

[0103] A second determining sub-module, configured to determine the defect features corresponding to each first failed case based on the abnormal keywords corresponding to each first failed case, or determine the defect features corresponding to each second failed case based on the abnormal operation information corresponding to each second failed case, where a first failed case is a failed case in which there are abnormal keywords in the system log content, and a second failed case is a failed case in which there are no abnormal keywords in the system log content.

[0104] Further, the second obtaining module 304 further includes:

[0105] A third determining sub-module, configured to determine event flow information from the system log content corresponding to each second failed case, where the event flow information is used to characterize the key events existing in each layer of the blockchain to be tested and the association relationship between each key event, and the layers in the blockchain to be tested include a network layer, a storage layer, and a consensus layer.

[0106] Further, the second acquisition module 304 further includes:

[0107] An acquisition sub-module, configured to collect environment information in the blockchain to be tested based on the defect features corresponding to each first failed test case and the defect features corresponding to each second failed test case, where the environment information includes at least one of the central processing unit usage rate, disk read efficiency, network connectivity, and file directory permissions.

[0108] Further, the matching and generating module 306 includes:

[0109] A calculation sub-module, configured to calculate the similarity between the defect features corresponding to each test case and the defect features of each defect in the preset defect library, where the defect features include at least one of the defect type, the abnormal event corresponding to the defect, the test case number corresponding to the defect, and the abnormal keyword corresponding to the defect;

[0110] A fourth determination sub-module, configured to determine the matching result corresponding to each test case according to the calculation result, and generate a test report according to the matching result corresponding to each test case, where the first display area of the test report is used to display the defects that match successfully, the second display area of the test report is used to display the defects that match unsuccessfully, the defects that match successfully refer to the defects whose similarity is greater than or equal to the first preset threshold, the defects that match unsuccessfully refer to the defects whose similarity is less than the first preset threshold, and the first display area and the second display area are two different areas on the test report.

[0111] Further, the defect analysis device 300 of the blockchain further includes:

[0112] A receiving module, configured to receive an operation instruction for a target button in the test report;

[0113] A judgment module, configured to judge whether the defect corresponding to the position of the target button is repeated with the defect in the preset defect library in response to the operation instruction;

[0114] An update module, configured to update the defect and the defect features corresponding to the position of the target button to the preset defect library when the defect corresponding to the position of the target button is not repeated with the defect in the preset defect library.

[0115] Further, the defect analysis device 300 of the blockchain further includes:

[0116] A duplicate removal processing module, configured to classify the defect features corresponding to each test case based on a preset matching rule, and perform duplicate removal processing on the defect features with a similarity higher than a second preset threshold in the same defect classification.

[0117] It should be noted that the blockchain defect analysis device 300 can implement the steps of the blockchain defect analysis method provided in the foregoing method embodiments, and can achieve the same technical effects, which will not be elaborated herein one by one.

[0118] As Figure 4 shown, an embodiment of the present application further provides an electronic device, including a processor 411, a communication interface 412, a memory 413, and a communication bus 414. Among them, the processor 411, the communication interface 412, and the memory 413 complete mutual communication through the communication bus 414.

[0119] The memory 413 is used to store a computer program.

[0120] In an embodiment of the present application, when the processor 411 executes the program stored on the memory 413, it implements the steps of the blockchain defect analysis method provided in any of the foregoing method embodiments.

[0121] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the blockchain defect analysis method provided in any of the foregoing method embodiments.

[0122] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.

[0123] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for defect analysis of a blockchain, characterized in that, The method includes: Obtaining test results corresponding to each test case, where the test case is used to test a blockchain to be tested; According to the test results corresponding to each test case, obtaining defect features corresponding to each test case from the operation log and / or system log, where the operation log is used to record operation information of each test case on the blockchain to be tested, and the system log is used to record status information of the blockchain to be tested during the execution of each test case; Matching the defect features corresponding to each test case with the defect features of each defect in a preset defect library, and generating a test report according to the matching result, where at least one defect and the defect features corresponding to the at least one defect are pre-recorded in the preset defect library.

2. The method according to claim 1, wherein The obtaining defect features corresponding to each test case from the operation log and / or system log according to the test results corresponding to each test case includes: For successful cases with a test result of successful testing, obtaining the system log content corresponding to each successful case from the system log; Filtering the system log content corresponding to each successful case based on a preset abnormal event to obtain a target abnormal event whose cumulative occurrence times is greater than or equal to a preset number of times; Based on the target abnormal event, determining the defect features corresponding to each successful case from the system log content corresponding to each successful case.

3. The method according to claim 1, wherein The obtaining defect features corresponding to each test case from the operation log and / or system log according to the test results corresponding to each test case includes: For failed cases with a test result of failed testing, obtaining abnormal operation information corresponding to each failed case from the operation log, where the abnormal operation information includes an abnormal object, an upstream operation of the abnormal object, and a time stamp corresponding to the upstream operation; Based on the abnormal operation information corresponding to each failed case, obtaining the system log content corresponding to each failed case from the system log, and determining whether there is an abnormal keyword in the system log content corresponding to each failed case; Determining the defect features corresponding to each first failed case based on the abnormal keywords corresponding to each first failed case, or determining the defect features corresponding to each second failed case based on the abnormal operation information corresponding to each second failed case, where the first failed case is a failed case with an abnormal keyword in the system log content, and the second failed case is a failed case without an abnormal keyword in the system log content.

4. The method according to claim 3, characterized in that, After determining whether there is an abnormal keyword in the system log content corresponding to each failed case, the method further includes: Determining event flow information from the system log content corresponding to each second failed case, where the event flow information is used to represent key events existing in each layer of the blockchain to be tested and the association relationship between the key events, and the layers in the blockchain to be tested include a network layer, a storage layer, and a consensus layer.

5. The method according to claim 3, wherein After determining the defect features corresponding to each first failure case based on the exception keywords corresponding to each first failure case, or determining the defect features corresponding to each second failure case based on the exception operation information corresponding to each second failure case, the method further includes: Collecting environment information in the blockchain to be tested based on the defect features corresponding to each first failure case and the defect features corresponding to each second failure case, where the environment information includes at least one of central processing unit usage rate, disk read efficiency, network connectivity, and file directory permissions.

6. The method according to claim 1, wherein The matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report according to the matching results includes: Calculating the similarity between the defect features corresponding to each test case and the defect features of each defect in the preset defect library, where the defect features include at least one of defect type, exception event corresponding to the defect, test case number corresponding to the defect, and exception keyword corresponding to the defect; According to the calculation results, determining the matching results corresponding to each test case, and generating a test report according to the matching results corresponding to each test case, where the first display area of the test report is used to display the defects that match successfully, the second display area of the test report is used to display the defects that match unsuccessfully, the defects that match successfully refer to the defects with the similarity greater than or equal to the first preset threshold, the defects that match unsuccessfully refer to the defects with the similarity less than the first preset threshold, and the first display area and the second display area are two different areas on the test report.

7. The method according to claim 1, characterized in that, After the matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report according to the matching results, the method further includes: Receiving an operation instruction for a target button in the test report; In response to the operation instruction, determining whether the defect corresponding to the position of the target button is repeated with the defect in the preset defect library; In the case where the defect corresponding to the position of the target button is not repeated with the defect in the preset defect library, updating the defect and the defect features corresponding to the position of the target button to the preset defect library.

8. The method according to claim 1, wherein Before the matching the defect features corresponding to each test case with the defect features of each defect in the preset defect library and generating a test report according to the matching results, the method further includes: Classifying the defect features corresponding to each test case based on a preset matching rule, and removing duplicates from the defect features with a similarity higher than a second preset threshold in the same defect classification.

9. An electronic device, characterized in that, Including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used for storing a computer program; The processor is used for implementing the defect analysis method of the blockchain according to any one of claims 1-8 when executing the program stored on the memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program, when executed by the processor, implements the defect analysis method of the blockchain according to any one of claims 1-8.

Citation Information

Cited By

  • Log processing method and device, electronic equipment and computer readable storage medium

    CN120448283A