Information extraction method, device, electronic device and readable storage medium
By obtaining log files from the software runtime and extracting the function implementation situation, the problem of the impact of additional test code is solved, fast and accurate function status monitoring is achieved, and the quality of software delivery is improved.
Patent Information
- Application Number
- CN202110550011.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-20
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-05-20
AI Technical Summary
The additional test code in the prior art will have an unpredictable impact on the software operation, making it difficult to quickly and accurately grasp the code execution and function implementation of the software version.
By obtaining the log file from the software runtime, extracting the values of the first and second fields according to the predetermined record format, indicating the implementation of the function respectively, obtaining a collection of successful implementation and failure, without adding test code to the source code.
It realizes the implementation of the function of the software running without any impact, improves the quality of software delivery, and avoids the impact of additional test code on operation.
Smart Images

Figure CN113159971B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of financial technology, and in particular to an information extraction method, device, electronic device and readable storage medium. Background Art
[0002] With the acceleration of the current software product iteration cycle, limited testing time and a large number of test cases, how to quickly and accurately grasp the code execution and function implementation of the software version in order to further improve the quality of software delivery has become a growing concern for enterprises.
[0003] Currently, statistics on the source code execution and function implementation status corresponding to software versions are concentrated in the unit testing and integration testing stages. Most of them use an intrusive approach to the source code, that is, it is necessary to use a "probe" to place in the source code corresponding to the software to be tested to conduct statistics on uncovered business.
[0004] However, these additional test codes may have unpredictable effects on the operation of the software program. Summary of the invention
[0005] The purpose of the embodiments of this specification is to provide an information extraction method, device, electronic device and readable storage medium to solve the problem in the prior art that adding additional code will have unpredictable effects on software operation.
[0006] To solve the above technical problems, the implementation mode of this specification provides an information extraction method, including: obtaining a log file generated when the software is running; at least one record in the log file follows a predetermined record format; determining the positions of a first field and a second field in the predetermined record format; the value of the first field is an identifier representing the function implemented after the software is executed, and the value of the second field is used to mark the implementation status of the function; according to the predetermined record format, extracting the information in the record where the value of the second field represents a successful implementation, to obtain a first set; and / or extracting the information in the record where the value of the second field represents a failed implementation, to obtain a second set; wherein the extracted information includes at least the value of the first field.
[0007] The information extraction method provided in the embodiments of this specification extracts business information from the log files generated during the software operation process, and then extracts the set of functions that are successfully implemented and the set of functions that fail to be implemented. There is no need to add additional test code to the source code corresponding to the software to be tested, which will not affect the operation of the software. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some implementation methods recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0009] Figure 1 A schematic diagram of a scenario of an information extraction method provided in an embodiment of this specification is shown;
[0010] Figure 2 A flowchart of an information extraction method provided by an embodiment of this specification is shown;
[0011] Figure 3 A flowchart of another information extraction method provided in an embodiment of this specification is shown;
[0012] Figure 4A A flowchart of a method for extracting information corresponding to functions implemented after software is run from a log file provided in an embodiment of this specification is shown;
[0013] Figure 4B A flowchart showing another method for extracting information corresponding to functions implemented after software is run from a log file provided in an embodiment of this specification;
[0014] Figure 5A A flowchart of a method for further extracting information corresponding to functions implemented after software is run from a first set provided by an embodiment of this specification is shown;
[0015] Figure 5B A flowchart showing another method for extracting information corresponding to functions implemented after software is run from a log provided by an embodiment of this specification;
[0016] Figure 6 A principle block diagram of an information extraction device provided in an embodiment of this specification is shown;
[0017] Figure 7 A principle block diagram of another information extraction device provided in an embodiment of this specification is shown;
[0018] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of this specification is shown. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0020] Figure 1 A scenario diagram of the information extraction method provided by the embodiment of this specification is shown. The software development process includes the writing of source code, the testing of source code and executable files corresponding to the source code, which usually requires the collaboration of multiple people. For this reason, it is necessary to use code version control software to manage the source code written by each coder. The code version control software includes server-side software and client-side software, and each coding terminal (such as a computer) used by each coder or each test terminal (such as a computer) used by each tester each runs a client software. The version control software can be, for example, Git, SVN, CVS.
[0021] After the coder has written the source code of a module on the coding terminal, he / she submits the module source code to the code version control server through the client software. The server will merge the source codes encoded by different coders into a code version and number the code version. It will also modify the code version number according to the modification of the source code.
[0022] When the tester needs to test the software source code, he obtains the source code from the code version control software through the client software, obtains the required log files from the test server, uses the software testing tools written by himself to test, and obtains the test results.
[0023] When the source code on the code version control server is relatively well written or modified, someone will compile, link, and package the software source code stored on the server into an executable file and deploy it to the software purchaser's server (for example, if a software system is written for a bank, the bank is the purchaser of the software and the unit that writes the source code is the supplier). The executable file is the software. The software running process can realize the functions expressed by the corresponding source code.
[0024] Before the software is deployed to the purchaser's server, that is, before delivery, in order to test the operation of the software in the actual production environment, a test environment server is often deployed in the supplier's test environment. This server simulates the operation of the purchaser's server in the actual production environment. During the test, the software is put on the test server to run, thereby simulating its use in the actual production environment.
[0025] The code in the embodiments of this specification refers to the source code of the software, that is, an uncompiled text file written in accordance with certain programming language specifications, which is a series of human-readable computer instructions. The source code writing specifications can be programming language specifications such as C, C++, C#, java, jsp, html, javascript, etc., and the source code file suffix can be ".c", ".cpp", ".cs", ".java", ".jsp", ".html", ".js". The ultimate goal of computer source code is to translate human-readable text into binary instructions that can be executed by the computer. This process is called compilation and is completed by a compiler. The code segments in this specification are multiple lines of source code that appear continuously in the source code file.
[0026] The information extraction method provided in the embodiments of this specification will be specifically introduced below.
[0027] Figure 2 A flowchart of an information extraction method according to an embodiment of this specification is shown. The method can be used for Figure 1 The test terminal in , and implement Figure 1 The method comprises the following steps:
[0028] S11: Obtain a log file generated when the software is running, wherein at least one record in the log file complies with a predetermined record format.
[0029] In some embodiments, the log file can be obtained from the server through network transmission methods such as the Internet, local area network, Bluetooth, etc., or copied from the server through a mobile storage device (such as a mobile hard disk or a USB flash drive), or someone else can obtain the log file from the server and then transmit it to the test terminal device through communication software.
[0030] Log files can be generated when the software is running on a test environment server built by the software supplier, or they can be generated on the software purchaser's server after the software is actually put into production.
[0031] The software in this application refers to the executable file formed after the source code is compiled, linked, packaged, etc., and the executable file automatically runs after being triggered and implements the function expressed by its corresponding source code. The function may be implemented successfully or unsuccessfully.
[0032] In the process of writing source code, considering that it is necessary to understand the execution of the functions expressed by the source code during testing, source code for writing logs will be added at the required location in the source code, so that the source code execution status is saved to the log file for easy viewing during testing. The log file can be a text log or a database log. Text logs include files in the ".txt" format and files in the ".log" format in the mobile phone file management.
[0033] S12: Determine the positions of the first field and the second field in the predetermined record format; the value of the first field is an identifier representing the function implemented after the software is executed, and the value of the second field is used to mark the implementation status of the function.
[0034] In some embodiments, the value of the first field may be the name of a function in the source code. For example, according to the function name PayMessagePasswordACS, it can be known that the function implemented by the function is to verify the payment password, and this function name can be used as the value of the first field.
[0035] In some embodiments, a source program file is used to implement a function, and the value of the first field can also be the name of the source program file. For example, "new face-swiping transaction function" will modify the page, and its corresponding source code adds a related page file clientNew_facewithdrawn_index.jsp. If the new face-swiping transaction function is implemented, the clientNew_facewithdrawn_index.jsp file must be executed. At this time, this file name can be used as the value of the first field.
[0036] In some embodiments, the value of the first field may also be the "function that can be implemented by the adjacent code segment" expressed in the code segment used to write the log. For example, there is a code segment that performs the function of "sending a family card", and there is a code segment adjacent to the code segment that is used to write a log to the database log, and the record written is (030302001153116777519268456, '2020-09-01 14:22:18', 'Send a family card', 'Customer information', '0', ...). Usually, the "function that can be implemented by the adjacent code segment" of the code segment used to write the log also has corresponding comments in the source code file.
[0037] Of course, the value of the first field may also be determined in other ways, which cannot be exhaustively listed in this specification.
[0038] The logs usually contain "transaction successful", "transaction failed", "successful sending", "failed sending", "OK", "PASS", "failed", "error code 404", "Error", "passed", "failed" and other similar information, which are used to mark the implementation status of the function. For example, "transaction successful", "successful sending", "OK", "PASS", "passed", etc. indicate that the function has been successfully implemented. "transaction failed", "failed sending", "failed", "error code 404", "Error", "failed", etc. indicate that the function has failed to be implemented.
[0039] In a log file, there may be multiple records that follow a predetermined record format, that is, the predetermined record format is used to define the distinction between various fields of each record, the distinction between adjacent different records, and the proximity relationship between various fields.
[0040] For example, in a text log file, the fields of a record are separated by #, and different records are separated by line breaks. For example, the format of each record is: "timestamp#session information#log level#time number#service name#call service method#message information", etc., where the service name is the description of the function implemented after the software is executed, and the identification of whether the function is successfully implemented is often included in the message information. For example, the service name is PayMessagePasswordACS, and the service represented by the service name is defined as implementing the function of "verifying whether the transaction password is correct". The message of the record contains "transaction successful" and "transaction failed". For the record of this service, the value of the first field is PayMessagePasswordACS, and the value of the second field is "transaction successful" or "transaction failed". Of course, the second field can also be a conventional symbol used to indicate the status of function implementation. For example, the character "1" is used to mark the status of "transaction successful", and the character 0 is used to mark the status of "transaction failed".
[0041] For a database file, there may also be multiple records, and the storage method is standardized like a table, which is convenient for distinguishing different records and different fields in each record. In this case, the predetermined record format is mainly used to define the proximity relationship between the fields of each record. For example, the fields included in each record are, in order, a unique number for a function to be realized (for example, a transaction number), the time of function realization (for example, the transaction time), the identifier of the function (for example, the transaction code), the name of the function (for example, the transaction name), and the identifier of the failure of the function to be realized (for example, the transaction error code).
[0042] In some embodiments, the predetermined recording format of the log may be one, and the predetermined recording format may be used to extract information from all acquired log files.
[0043] In some embodiments, the predetermined record format of the log may be a log file with a suffix name corresponding to a predetermined record format. When extracting information, it is necessary to first find the corresponding predetermined record format based on the suffix of the log file, and then use the predetermined record format to extract information from the log file.
[0044] In some embodiments, there may be multiple predetermined record formats for a log, and these predetermined record formats are numbered, and the same position of the log (for example, the first line or the first character) is used to represent the number of the predetermined record format corresponding to the log. Then, after obtaining the log file, the content at the same position in the log is first read to obtain the number of the predetermined record format corresponding to the log, and then the predetermined record format corresponding to the number is found, and then the predetermined record format is used to read information from the log file.
[0045] S13: Extracting information from records where the value of the second field represents successful implementation according to a predetermined record format to obtain a first set; and / or extracting information from records where the value of the second field represents failed implementation to obtain a second set; wherein the extracted information includes at least the value of the first field.
[0046] When extracting information from a record, at least the value of the first field should be extracted. In addition, information from other fields can be extracted according to specific needs to facilitate testers or coders to locate the code segment corresponding to the function or understand the software running situation. In some embodiments, the information in other fields can be information such as timestamp, recipient address, message content, etc.
[0047] Since the log is generated during the software operation, the ability to extract a function means that the code segment in the source code corresponding to the software for implementing the function has been executed (it can also be called the code segment has been overwritten), that is, the function has been implemented, but the function may fail to be implemented due to external (referring to the server's external) environmental reasons such as external input or incorrect recipient address sent, or differences between the test server and the buyer's server. Testers and coders often need to find out the reasons for the failure of the function implementation, and then determine whether to modify the source code and how to modify the source code. At this time, you can refer to the second set.
[0048] When extracting the information in the record according to the predetermined record format, only the information in the record where the value of the second field represents successful implementation can be extracted to obtain the first set as the set of successfully implemented functions, which is convenient for testers and coders to understand which functions have been successfully implemented. In some embodiments, testers or coders want to know which functions have failed to be implemented, so that the source code file can be further adjusted for these failed functions. In this case, only the information in the record where the value of the second field represents failed implementation can be extracted to obtain the second set as the set of failed functions. Alternatively, in some embodiments, the set of successfully implemented functions and the set of failed functions will be extracted separately and provided to testers and coders for reference. Alternatively, in some embodiments, the value of the second field can be not distinguished, and all the information in each record can be extracted, that is, the union of the first set and the second set can be obtained, and the information in the extracted record includes at least the values of the first field and the second field, which is also convenient for further extracting the set of successfully implemented functions and the set of failed functions from the union.
[0049] In this step, for other contents related to "extracting information in the record according to a predetermined record format", please refer to the description of step S12 and will not be repeated here.
[0050] The above information extraction method extracts business information from the log files generated during the software operation process, and then extracts the set of successfully implemented functions and the set of failed functions. There is no need to add additional test code to the source code corresponding to the software to be tested, which will not affect the operation of the software.
[0051] In the regression testing and adaptive testing phases before the software is put into production, testers often need to know which functions of the source code that can be implemented have not been implemented, so that they can design test cases to test these functions and allow coders to check whether the source code they wrote has not been implemented due to coding errors. In this regard, based on the above method, the embodiments of this specification further provide the following steps, such as Figure 3 shown.
[0052] S14: Obtain a source code file corresponding to the software, where the source code file contains at least one comment, and the comment follows a predetermined comment format.
[0053] In some embodiments, the code can be obtained from the code version control server through network transmission methods such as the Internet, local area network, Bluetooth, etc., or the log file can be copied from the code version control server or the coding terminal device used by the coder through a mobile storage device (such as a mobile hard disk or a USB flash drive). Alternatively, someone else can obtain the source code file from the code version control server or the coding terminal device used by the coder and then transmit it to the test terminal device through communication software.
[0054] The source code file can be a page file (jsp file, html file), js file, database script file (sql file), or server-side file (java file).
[0055] Comments are the content in the source code file that explains the functions that a code segment can achieve, the coder, the code, and the modification time.
[0056] Programming languages provide special comment symbols to distinguish source code that needs to be compiled and executed from comment content that does not need to be compiled and executed. For example, the comment symbol can be " / / ", which means that the symbol and the content following it in each line will not be compiled and executed; or it can be " / *" and "* / ", which are suitable for the case of multiple consecutive lines of comments. This pair of symbols and the content between them will not be compiled and executed.
[0057] The content of the comment follows a predetermined comment format, that is, the predetermined comment format is used to define the distinction between the various fields of each comment, the distinction between adjacent different comments, and the proximity relationship between various fields. The predetermined comment format includes at least a third field, the value of which is an identifier of the function that can be implemented when the code segment corresponding to the comment is executed. In addition, the comment format may also include fields such as the code segment modification date and the code modifier.
[0058] Take the following comment as an example. The comment format can be: the special symbol "*@" in the comment symbol is used as an identifier for the beginning of a field, and the content after the special symbol "*@" and before the ":" is used as the field name, and the content after the ":" is used as the value of this field. Adjacent fields are separated by line breaks. The comment example is shown below.
[0059] / ***
[0060] *@desctription: Save the family card data to the NOS storage system
[0061] *@function: send a family card
[0062] *@CreateDate: 20xx-xx-x1
[0063] *@className:SaveFamilyCardDataOpStep.class
[0064] *@author: Zhang San
[0065] *@modifyAuthor: Li Si
[0066] *@modify:20xx-xx-x2
[0067] * @modifyDate: 20xx-xx-x3
[0068] * @version: 1.0
[0069] * /
[0070] S15: Determine the position of the third field in the predetermined comment format; the value of the third field is an identifier of the function that can be implemented when the code segment corresponding to the comment is executed.
[0071] In some embodiments, the source code files have a predetermined comment format, and the predetermined comment format can be used to extract information from all source code files.
[0072] In some embodiments, the predetermined comment format of the source code file can be a source code file with a suffix name corresponding to a predetermined comment format. Therefore, when extracting information, it is necessary to first find the corresponding predetermined comment format according to the suffix of the source code file, and then use the predetermined comment format to extract information from the source code file.
[0073] In some embodiments, there may be multiple predetermined comment formats, and these predetermined comment formats are numbered. Different comment segments in the same source code file use the same predetermined comment format, and at least the same position of the first comment content (for example, the first line or the first field or the first character) is used to represent the predetermined comment format corresponding to the source code file. Then, after obtaining a source code file, when the first comment content is read, the content at the same position (for example, the first line or the first field or the first character) is first read to determine the number of the predetermined comment format corresponding to the source code file, and then the predetermined comment format corresponding to the number is found, and then the predetermined comment format is used to extract information from all comment segments of the source code file.
[0074] In some embodiments, there may be multiple predetermined comment formats, and different comment segments in the same source code file may use different predetermined comment formats, and these predetermined comment formats are numbered, and the same position of the comment content (for example, the first line or the first field or the first character) is used to represent the predetermined comment format corresponding to the segment of comment. Then, after obtaining a source code file, when reading the comment content, first read the content at the same position (for example, the first line or the first field or the first character) to determine the number of the predetermined comment format corresponding to the segment of comment, then find the predetermined comment format corresponding to the number, and then use the predetermined comment format to extract information from the segment of comment.
[0075] S16: Extracting comment information in the source code file according to a predetermined comment format, wherein the extracted information at least includes a value of a third field, and obtaining a third set as a set of functions to be tested.
[0076] When extracting the annotation information, in addition to extracting the value of the third field, other information can also be extracted according to specific needs so that the tester or coder can understand the relevant information of the code segment. In some embodiments, the other information can be the coder, coding time, modification personnel, modification time, etc.
[0077] The extracted annotation information should also be stored in a predetermined format. For example, the predetermined storage format may be: ('Program name 1', 'Modifier', 'Code segment modification date', 'Modification content', 'Functions that can be achieved when the code segment is executed', 'Date of creation of this storage record', 'Date of last update of this storage record').
[0078] For example, the above annotation content can extract the information corresponding to a function: ('SaveFamilyCardDataOpStep.class', 'Li Si', '20xx-xx-x1', '20xx-xx-x2', 'Send Family Card', '2020-08-30 14:22:18').
[0079] In this step, for other contents related to “extracting annotation information according to a predetermined annotation format”, please refer to the description of step S15 and will not be repeated here.
[0080] When necessary information (such as the name of a function) cannot be extracted from a comment by using a corresponding predetermined comment format or all predetermined comment formats, the source code file containing the comment can be pushed to coders to complete the comment information.
[0081] S17: when the elements in the first set and the second set are obtained, a set of functions that can be realized by the unexecuted code segments in the source code file is obtained according to the elements in the first set, the second set and the third set.
[0082] In the embodiments provided in the embodiments of this specification, the function identifier in the comment corresponding to a code segment in the source code file is the same as the identifier of the function that can be implemented when the code segment is executed. This function identifier can usually be found in the first field of a record in the log file.
[0083] In some embodiments, the form of "obtaining elements in the first set and the second set" can be to obtain the elements in the two sets respectively. Accordingly, step S17 can be implemented by the following method: find out the function identifier that belongs to the third set but does not belong to the first set and does not belong to the second set, put the information corresponding to the found function identifier into the fourth set, and use the fourth set as the set of functions that can be implemented by the unexecuted code segments in the source code file. When it is possible to perform set operations, step S17 can also be implemented by the following method: according to the field whose value is the function identifier, find the union of the first set and the second set, and then find the complement or difference of the union in the third set to obtain the fourth set.
[0084] In some embodiments, the form of "obtaining elements in the first set and the second set" can be to extract elements in both sets at the same time when extracting information, that is, regardless of whether the function is successfully implemented, the information in each record is extracted to obtain the fifth set (that is, the union of the first set and the second set). Accordingly, step S17 can be implemented by the following method: find the function identifier that belongs to the third set but not to the fifth set, and put the information corresponding to the found function identifier into the fourth set. When set operations can be performed, step S17 can also be implemented by the following method: according to the field whose value is the function identifier, find the complement or difference of the fifth set in the first set to obtain the fourth set.
[0085] The above-mentioned information extraction method extracts the comment information of the source code file according to a predetermined comment format, and the extracted information at least includes the identification of the function that can be realized when the code segment corresponding to the comment is executed, and obtains the third set as the set of functions to be tested. There is no need to add additional test code to the source code, so that it will not affect the operation of the software; the above-mentioned method also obtains the set of functions that can be realized by the code segment that has not been executed based on this set of functions to be tested and the set of functions realized after the code is executed (including the situations of successful implementation and failed implementation) extracted from the log file, so as to provide continuous testing guidance to testers in the regression testing phase.
[0086] In some embodiments, the names of the functions implemented after the software is running are not clearly stored in any field in the log. At this time, these functions cannot be extracted from the log file according to the predetermined record format of the log file. Only coders who have a deep understanding of the code know what keywords or other identifiers to look for in the log file to determine whether these functions are successfully implemented. In this case, the coder can tell the tester his or her customized keywords or other identifiers, the functions that can be determined based on the retrieval of these identifiers, and the correspondence between the identifiers and the functions, or put the correspondence between the identifiers and the functions in a rule set, and the tester obtains these customized rules from the rule set. Based on these customized rules, the information corresponding to the functions implemented after the software is running can be extracted from the log file through the following steps. Figure 4A shown.
[0087] S18: Acquire a predetermined function identifier and its corresponding predetermined identifier, wherein the predetermined function identifier is an identifier indicating a function that can be realized after the software is executed; and the predetermined identifier is associated with the function indicated by the predetermined function identifier.
[0088] The "predetermined function identifier" can refer to the description of the function identifier in step S12. The predetermined identifier can be a protocol identifier, a function name, a software version number, an identifier of a branch service, etc. Of course, other identifiers determined by coders can also be used, which cannot be exhaustively listed in this specification.
[0089] S19: Retrieve a predetermined identifier in the log file.
[0090] This step is not limited to searching in a certain field when searching, that is, the search can be performed in all fields.
[0091] S20: When the predetermined identifier is retrieved, determine that the function represented by the predetermined function identifier has been successfully implemented; and extract the information corresponding to the predetermined identifier from the log file and put it into the first set, or combine new elements and put them into the first set, the new elements at least include the function identifier and the extracted information.
[0092] The extracted information corresponding to the predetermined identifier may include an identifier of a function implemented after the software is run, and the function identifier is inconsistent with the predetermined function identifier.
[0093] As the reverse side of step S20, when the predetermined identifier is not retrieved, it is possible that the function represented by the predetermined function identifier fails to be implemented, or part of the code segment corresponding to the function represented by the predetermined function identifier is not executed.
[0094] Through the above steps S18 to S20, information can be extracted from the log file through coding and test personnel's customized rules, thereby making up for the shortcomings of the log preset record format extraction method.
[0095] In some embodiments, it is also possible to Figure 4A The embodiment shown is improved to obtain Figure 4B The embodiment shown. Specifically, a predetermined state identifier corresponding to the predetermined function identifier is also pre-set to mark whether the function represented by the predetermined function identifier is successfully implemented; when the predetermined identifier is retrieved, it is determined that the function represented by the predetermined identifier is in the state marked by the predetermined state identifier, and the information corresponding to the predetermined identifier is extracted from the log file; when the predetermined state identifier indicates successful implementation, a new element is combined and put into the first set, and the new element at least includes the predetermined function identifier and the extracted information; when the predetermined state identifier indicates failure of implementation, a new element is combined and put into the second set, and the new element at least includes the predetermined function identifier and the extracted information.
[0096] In some embodiments, the method of pre-recording the log format and the method of steps S18 to S20 (i.e., the elements in the first set) are not sufficient to determine whether certain functions are implemented. The identifiers of these functions may be recorded in the log file; or the identifiers of the functions are not recorded in the log file, but the identifiers of the functions are associated with the function identifiers in the first set. In this regard, this specification provides the following method steps for further determining whether these functions are implemented. Figure 5A shown.
[0097] S25: Determine a first function identifier, a second function identifier and their corresponding predetermined identifiers; wherein the first function identifier and the second function identifier are identifiers of different functions that can be implemented after the software is executed, and the predetermined identifier is associated with the function represented by the second function identifier.
[0098] The “first function identifier” and “second function identifier” can refer to the description of the function identifier in step S12. In addition, the function represented by the second function identifier is the function that needs to be further determined whether to be implemented.
[0099] The predetermined identifier may be a protocol identifier, a function name, a software version number, an identifier of a branch business, etc. Of course, it may also be other identifiers determined by coders, which cannot be listed in this specification.
[0100] S26: Search the first set for an element having a first function identifier.
[0101] S27: Retrieve a predetermined identifier from the found elements.
[0102] S28: When the predetermined identifier is retrieved, it is determined that the function represented by the second function identifier has been successfully implemented, and information corresponding to the predetermined identifier is extracted from the first set.
[0103] Since the second function identifier may not exist in the log file record, it is necessary to extract information from the first set according to the predetermined identifier. The information extracted from the first set may be all or part of the information in the element where the predetermined identifier is located.
[0104] S29: Combining a new element and putting it into the first set, the new element at least includes the second function identifier and the extracted information.
[0105] In some embodiments, it is also possible to Figure 5A The embodiment shown is improved to obtain Figure 5B The embodiment shown. Specifically, a predetermined state identifier corresponding to the second function identifier is also pre-set to mark whether the function represented by the second function identifier is successfully implemented; when the predetermined identifier is retrieved, it is determined that the function represented by the predetermined identifier is in the state marked by the predetermined state identifier, and the information corresponding to the predetermined identifier is extracted from the first set; when the predetermined state identifier indicates successful implementation, a new element is combined and put into the first set, and the new element at least includes the second function identifier and the extracted information; when the predetermined state identifier indicates failure of implementation, a new element is combined and put into the second set, and the new element at least includes the second function identifier and the extracted information.
[0106] Figure 4B and Figure 5B The "predetermined status identifier" can be "transaction successful", "successful sending", "OK", "PASS", "passed" and other identifiers indicating that the function has been successfully implemented, or it can be "transaction failed", "sending failed", "failed", "error code 404", "Error", "failed" and other identifiers indicating that the function has failed to be implemented.
[0107] The above steps S25 to S29, for example, can be that the coder can insert his own custom rules into the rule set: ('1', 'oper.log', 'CheckMediumNo', 'protocolType:16020', 'PASS', 'CheckMediumNo.class', 'Card medium check adds 16020 processing branch business', 'Modifier', 'Rule insertion date', 'Rule last update date'), this rule means: in the text log (1 represents the text log) oper.log, by retrieving and calling the CheckMediumNo service, the message contains "protocolType:16020", then it can be determined that the card medium check adds 16020 processing branch business has been successfully implemented, and the source code file CheckMediumNo.class has been executed; otherwise, the function implementation fails or at least part of the code corresponding to the function is not executed. The information extracted according to this rule can be stored in a certain format as follows: ('', 'CheckMediumNo', 'CheckMediumNo.class', 'Pass', '2021-03-30 14:22:18', 'Message content', '2021-03-30 20:12:18'). In this example, the first function identifier is CheckMediumNo, the predetermined identifier is protocolType:16020, the second function identifier is the card medium check newly added 16020 processing branch business, and the predetermined status identifier is PASS (i.e., successfully implemented).
[0108] For example, in another embodiment, the mobile banking domestic transfer and remittance part page has compatibility issues for the old client display, so the page is modified through client_remit_quick_transfer_index.jsp to make it compatible with the mobile client version 3.0.1.3. For this reason, the coder can insert his custom rule into the rule set: ('2', 'wappb_tl_log', 'clientuseragent', '', '3.0.1.3', 'PASS', 'client_remit_quick_transfer_index.jsp', 'domestic transfer and remittance compatibility modification', 'modifier', 'rule insertion date', 'rule last update date'), this rule means: in the database log (2 means database log), by searching the log table wappb_tl_log for the record whose function is "domestic transfer and remittance", the database field clientuseragent matches the keyword 3.0.1.3, then it can be determined that the client_remit_quick_transfer_index.jsp source code file has been executed. In this example, the first function identifier is domestic remittance, the predetermined identifier is 3.0.1.3, and the second function identifier is client_remit_quick_transfer_index.jsp.
[0109] The embodiment of this specification also provides an information extraction device, which can be used to implement Figure 2 The information extraction method of the corresponding embodiment. Figure 6 As shown, the device includes a first acquisition module 11, a first determination module 12 and a first extraction module 13.
[0110] The first acquisition module 11 is used to obtain the log file generated when the software is running; at least one record in the log file follows a predetermined record format. The first determination module 12 is used to determine the position of the first field and the second field in the predetermined record format; the value of the first field is an identifier representing the function implemented after the software is executed, and the value of the second field is used to mark the implementation status of the function. The first extraction module 13 is used to extract the information in the record where the value of the second field represents successful implementation according to the predetermined record format, and obtain a first set; and / or, extract the information in the record where the value of the second field represents failed implementation, and obtain a second set; wherein the extracted information includes at least the value of the first field.
[0111] For related descriptions and technical effects, please refer to Figure 2 The corresponding embodiments are not described in detail.
[0112] In some embodiments, Figure 7As shown, the information extraction device may further include a second acquisition module 14, a second determination module 15, a second extraction module 16 and an acquisition module 17. The device may be used to implement Figure 3 The information extraction method of the corresponding embodiment.
[0113] The second acquisition module 14 is used to obtain the source code file corresponding to the software, and the source code file contains at least one comment, and the comment follows a predetermined comment format. The second determination module 15 is used to determine the position of the third field in the predetermined comment format; the value of the third field is an identifier of the function that can be realized when the code segment corresponding to the comment is executed. The second extraction module 16 is used to extract the comment information in the source code file according to the predetermined comment format, and the extracted information includes at least the value of the third field, and obtains a third set as a set of functions to be tested. The acquisition module 17 is used to obtain the set of functions that can be realized by the code segment that has not been executed in the source code file according to the elements in the first set and the second set and the third set when the elements in the first set and the second set are obtained.
[0114] For related descriptions and technical effects, please refer to Figure 3 The corresponding embodiments are not described in detail.
[0115] The present application also provides an electronic device that can be used as Figure 1 The test terminal or information extraction tool shown in . Figure 8 As shown, the electronic device may include a processor 801 and a memory 802, wherein the processor 801 and the memory 802 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0116] The processor 801 may be a central processing unit (CPU). The processor 801 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0117] The memory 802 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the information extraction method in the embodiments of the specification (for example, Figure 6The processor 801 executes various business applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory 802, that is, the information extraction method in the above method embodiment is implemented.
[0118] The memory 802 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required by at least one business; the data storage area may store data created by the processor 801, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 802 may optionally include a memory remotely arranged relative to the processor 801, and these remote memories may be connected to the processor 801 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0119] One or more modules are stored in the memory 802 , and when executed by the processor 801 , implement the information extraction method in the above embodiment.
[0120] The specific details of the above electronic device can be understood by referring to the relevant descriptions and effects shown in the above embodiments, and will not be repeated here.
[0121] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, the processes in the embodiments of the above-mentioned methods can be implemented. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk (HDD) or a solid state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.
[0122] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. An information extraction method, characterized in that: include: Get the log files generated when the software is running; At least one record in the log file follows a predetermined record format; Determine the positions of the first field and the second field in the predetermined record format; the value of the first field is an identifier representing the function implemented after the software is executed, and the value of the second field is used to mark the implementation status of the function; Extracting information from records where the value of the second field represents successful implementation according to the predetermined record format to obtain a first set; and / or extracting information from records where the value of the second field represents failed implementation to obtain a second set; wherein the extracted information includes at least the value of the first field; The method further comprises: Obtaining a source code file corresponding to the software, wherein the source code file contains at least one comment, and the comment follows a predetermined comment format; the comment is a content in the source code file that describes at least one of the following contents: a function that can be realized by the code segment, a coder, a coding time, and a modification time, and the comment content in the source code file will not be compiled or executed; Determine the position of a third field in the predetermined comment format; the value of the third field is an identifier of a function that can be implemented when the code segment corresponding to the comment is executed; Extracting comment information in the source code file according to the predetermined comment format, wherein the extracted information at least includes the value of the third field, and obtaining a third set as a set of functions to be tested; When the elements in the first set and the second set are obtained, a set of functions that can be realized by the unexecuted code segments in the source code file is obtained according to the elements in the first set and the second set and the third set.
2. The information extraction method according to claim 1, characterized in that: The step of obtaining a set of functions that can be implemented by the unexecuted code segment according to the elements in the first set, the second set and the third set when the elements in the first set and the second set are obtained includes: Find out the identifiers of functions that belong to the third set but do not belong to the first set and do not belong to the second set, and put the information corresponding to the identifiers of the found functions into a fourth set, wherein the fourth set serves as a set of functions that can be implemented by the code segments that are not executed in the source code file.
3. The information extraction method according to claim 1, characterized in that: When the first set is obtained, the method further includes: Acquire a predetermined function identifier and its corresponding predetermined identifier, wherein the predetermined function identifier is an identifier indicating a function that can be realized after the software is executed; and the predetermined identifier is associated with the function indicated by the predetermined function identifier; retrieving the predetermined identifier in a log file; When the predetermined identifier is retrieved, it is determined that the function represented by the predetermined function identifier has been successfully implemented; and the information corresponding to the predetermined identifier is extracted from the log file and put into the first set, or a new element is combined and put into the first set, and the new element at least includes the function identifier and the extracted information.
4. The information extraction method according to claim 1, characterized in that: When the first set is obtained, the method further includes: Obtaining a predetermined function identifier and its corresponding predetermined identifier and predetermined status identifier, wherein the predetermined function identifier is used to indicate the function that can be realized after the software is executed; the predetermined identifier is associated with the function represented by the predetermined function identifier; and the predetermined status identifier is used to mark whether the function represented by the function identifier is successfully realized; retrieving the predetermined identifier in a log file; When the predetermined identifier is retrieved, determining that the function represented by the predetermined function identifier is the state marked by the predetermined state identifier, and extracting information corresponding to the predetermined identifier from the log file; When the predetermined status identifier indicates successful implementation, a new element is combined and put into the first set, and the new element at least includes the predetermined function identifier and the extracted information; when the predetermined status identifier indicates failed implementation, a new element is combined and put into the second set, and the new element at least includes the predetermined function identifier and the extracted information.
5. The information extraction method according to claim 1, characterized in that: When the first set is obtained, the method further includes: Determine a first function identifier, a second function identifier and a corresponding predetermined identifier; wherein the first function identifier and the second function identifier are identifiers of different functions that can be implemented after the software is executed, and the predetermined identifier is associated with the function represented by the second function identifier; Searching the first set for an element having the first function identifier; Retrieving the predetermined identifier from the found elements; When the predetermined identifier is retrieved, determining that the function represented by the second function identifier has been successfully implemented, and extracting information corresponding to the predetermined identifier from the first set; A new element is combined and put into the first set, where the new element at least includes the second function identifier and the extracted information.
6. The information extraction method according to claim 1, characterized in that: When the first set is obtained, the method further includes: Determine a first function identifier, a second function identifier and their corresponding predetermined identifier and predetermined status identifier; wherein the first function identifier and the second function identifier are used to indicate different functions that can be implemented after the software is executed, and the predetermined identifier is associated with the function represented by the second function identifier, and the predetermined status identifier is used to mark whether the function represented by the second function identifier is successfully implemented; Searching the first set for an element having the first function identifier; Retrieving the predetermined identifier from the found elements; When the predetermined identifier is retrieved, determining that the function represented by the second function identifier is the state marked by the predetermined state identifier, and extracting information corresponding to the predetermined identifier from the first set; When the predetermined status identifier indicates successful implementation, a new element is combined and put into the first set, and the new element includes at least the second function identifier and the extracted information; when the predetermined status identifier indicates failed implementation, a new element is combined and put into the second set, and the new element includes at least the second function identifier and the extracted information.
7. An information extraction device, characterized in that: include: The first acquisition module is used to acquire the log files generated when the software is running; At least one record in the log file follows a predetermined record format; A first determination module is used to determine the positions of the first field and the second field in the predetermined record format; the value of the first field is an identifier representing the function implemented after the software is executed, and the value of the second field is used to mark the implementation status of the function; a first extraction module, configured to extract, according to the predetermined record format, information from records in which the value of the second field indicates successful implementation, to obtain a first set; and / or to extract information from records in which the value of the second field indicates failed implementation, to obtain a second set; wherein the extracted information includes at least the value of the first field; The device also includes: The second acquisition module is used to acquire a source code file corresponding to the software, wherein the source code file contains at least one comment, and the comment follows a predetermined comment format; the comment is a content in the source code file that describes at least one of the following contents: a function that can be realized by the code segment, a coder, a coding time, and a modification time, and the comment content in the source code file will not be compiled or executed; A second determination module is used to determine the position of a third field in the predetermined comment format; the value of the third field is an identifier of a function that can be realized when the code segment corresponding to the comment is executed; A second extraction module is used to extract comment information in the source code file according to the predetermined comment format, the extracted information at least includes the value of the third field, and obtain a third set as a set of functions to be tested; The acquisition module is used to obtain a set of functions that can be realized by the unexecuted code segments in the source code file according to the elements in the first set, the second set and the third set when the elements in the first set and the second set are obtained.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the steps of the method according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed, the steps of the method according to any one of claims 1 to 6 are implemented.
