CN116795700A - Prepositioning method and device for abnormal faults of interface program - Google Patents

Prepositioning method and device for abnormal faults of interface program Download PDF

Info

Publication number
CN116795700A
CN116795700A CN202310744080.0A CN202310744080A CN116795700A CN 116795700 A CN116795700 A CN 116795700A CN 202310744080 A CN202310744080 A CN 202310744080A CN 116795700 A CN116795700 A CN 116795700A
Authority
CN
China
Prior art keywords
development
code
fault
label
verification
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310744080.0A
Other languages
Chinese (zh)
Inventor
楚朝伟
王志强
郭银利
胡晓东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Technology Information Technology Co Ltd
Original Assignee
Jingdong Technology Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingdong Technology Information Technology Co Ltd filed Critical Jingdong Technology Information Technology Co Ltd
Priority to CN202310744080.0A priority Critical patent/CN116795700A/en
Publication of CN116795700A publication Critical patent/CN116795700A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3608Software analysis for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a prepositioning method and device for abnormal faults of an interface program, and relates to the technical field of big data. The specific implementation mode of the method comprises the following steps: acquiring development codes of an interface program; detecting the development codes by using a code analysis tool according to a preset tag library, and positioning one or more tags to be verified in the development codes; executing an interface program to intercept a label to be checked in the development code; and matching a target verification template from the pre-constructed verification templates according to the label type of the label to be verified, verifying the development code, and determining the abnormal fault in the development code. According to the method and the device, fault exposure can be advanced to the development period, interface abnormality is found in time and repaired in the development period, so that the fault rate in the test period is reduced, the test efficiency is improved, the test cost consumption is reduced, the interface online flow is shortened, the influence of interface development on the platform is reduced, and the normal online and operation of the platform are ensured.

Description

Prepositioning method and device for abnormal faults of interface program
Technical Field
The present invention relates to the field of big data technologies, and in particular, to a method and an apparatus for prepositioning an abnormal fault of an interface program.
Background
In the platform development process, interfaces of different scenes usually correspond to different specific logics except for basic logics, different functions need to be designed, for example, idempotent verification needs to be designed for an ordering interface, concurrency and current limiting control needs to be designed for a second killing interface, transaction consistency needs to be designed for a transfer interface and the like.
In the existing interface development process, a developer usually designs the function of interface logic based on personal experience, and then a tester uses test data to test the interface designed by the developer.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
because personal experience of research personnel is limited, abnormality of an interface usually appears during testing and in the process of online operation of the interface, for example, idempotent verification failure of a next interface, overdriving of a second killing interface prize and the like, on one hand, the interface abnormally blocks the testing progress; on the other hand, the testers need to communicate with the research and development staff about fault details and a reproduction method; furthermore, the repaired interface needs to be retested, and the test cost is greatly increased due to the above steps, however, compared with the research and development period, the fault positioning and repairing cost in the test period is greatly different, so that the test consumption is relatively high, the online progress of the platform is blocked, and the operation of the platform is influenced.
Disclosure of Invention
In view of the above, embodiments of the present invention provide a method and an apparatus for prepositioning an abnormal fault of an interface program, which can advance fault exposure to a development period, discover interface abnormality in time and repair the interface abnormality in the development period, thereby reducing a fault rate in a test period, improving test efficiency, reducing test cost consumption, shortening an interface online process, reducing an influence of interface development on a platform, and ensuring normal online and operation of the platform.
To achieve the above object, according to an aspect of the embodiments of the present invention, there is provided a method for pre-locating an abnormal fault of an interface program, including:
acquiring development codes of the interface program;
detecting the development codes by using a code analysis tool according to a preset tag library, and positioning one or more tags to be verified in the development codes;
executing the interface program to intercept the label to be checked in the development code;
and matching a target verification template from a pre-constructed verification template according to the label type of the label to be verified, verifying the development code, and determining an abnormal fault in the development code.
Optionally, the detecting the development code with a code analysis tool, locating one or more tags to be verified in the development code, includes:
Converting the development code to obtain a byte code file of the development code;
detecting the byte code file, and searching one or more entry methods in the byte code file;
analyzing a method function included in each calling link under each entry method;
and comparing the entry method, the method function and each keyword in the tag library, and marking the entry method and/or the method function which are the same as the keywords in the tag library as a mark to be verified of the development code.
Optionally, the generating of the tag library includes:
acquiring abnormal fault data of a history interface program; wherein the abnormal fault data includes a fault code of an abnormal fault;
analyzing the context dependency relationship in the fault code, and extracting keywords and verification strategies in the fault code; wherein the keywords include fault entry methods, and/or fault method functions;
and generating the tag library according to the corresponding relation between the extracted keywords and the tag types of the verification policies.
Optionally, the tag type includes an idempotent checking tag, a transaction consistency tag, a boundary checking tag and a database and table updating checking tag, and the checking template includes an idempotent checking template, a transaction consistency template, a boundary checking template and a database and table updating checking template.
Optionally, the verifying the development code, determining an abnormal fault in the development code includes:
acquiring a plurality of execution results corresponding to the label to be checked in the repeated execution process of the interface program for a plurality of times;
judging whether a plurality of execution results are equal or not;
and under the condition that the execution results of the same execution are different, determining that the verification result is idempotent verification failure, and positioning the abnormal faults in the development code.
Optionally, the verifying the development code, determining an abnormal fault in the development code includes:
acquiring node positions corresponding to a plurality of transaction nodes and the label to be checked in the execution process of the interface program;
judging whether node values of the plurality of transaction nodes and the node positions corresponding to the tags to be checked are equal or not;
and under the condition that node values of the same node positions of a plurality of transaction nodes are different, determining that the verification result is the transaction consistency verification failure, and positioning the abnormal faults in the development codes.
Optionally, the verifying the development code, determining an abnormal fault in the development code includes:
acquiring a parameter type corresponding to the label to be checked in the execution process of the interface program;
Judging whether the parameter value of the label to be checked meets the requirement of the boundary value according to the boundary value of the parameter type;
and under the condition that the parameter value of the input parameter or the output parameter of the label to be tested is larger than the maximum value or smaller than the minimum value, determining that the verification result is the failure of the boundary checking and the abnormal fault in the development code is positioned.
Optionally, the verifying the development code, determining an abnormal fault in the development code includes:
acquiring a sub-table identification of a database corresponding to the label to be checked in the execution process of the interface program;
inserting a plurality of pieces of random data into a database sub-table corresponding to the sub-table identification in the database; wherein the random data comprises a data identifier and a data value;
judging whether repeated data identification appears in a database sub-table corresponding to the sub-table identification, under the condition that repeated data identification appears in the database sub-table corresponding to the sub-table identification, executing update SQL on a data value corresponding to the repeated data identification, and receiving the influence line number returned by the database;
judging whether the influence line number is larger than or equal to a line number threshold value, and determining that the verification result is that the updating and checking of the database and the table fails under the condition that the influence line number is larger than or equal to 1, and positioning the abnormal faults in the development codes.
According to still another aspect of the embodiment of the present invention, there is provided a prepositioning device of an abnormal failure of an interface program, including:
the acquisition module is used for acquiring the development code of the interface program;
the detection module is used for detecting the development codes by utilizing a code analysis tool according to a preset tag library and positioning one or more tags to be verified in the development codes;
the interception module is used for executing the interface program and intercepting the label to be checked in the development code;
and the verification module is used for matching a target verification template from a pre-constructed verification template according to the label type of the label to be verified, verifying the development code and determining abnormal faults in the development code.
According to another aspect of an embodiment of the present invention, there is provided an electronic device for prepositioning abnormal faults of an interface program, including:
one or more processors;
storage means for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the prepositioning method of the abnormal faults of the interface program.
According to still another aspect of the embodiment of the present invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the method for pre-locating an abnormal failure of an interface program provided by the present invention.
One embodiment of the above invention has the following advantages or benefits: because the historical fault data of the historical interface program under different scenes are combed, keywords and verification strategies in the historical fault data are extracted, when a new interface program is developed subsequently, in a development stage, the keywords in the development code are detected by using a code analysis tool, the to-be-verified labels are determined, one or more verification templates of the development code are matched according to the label types of the to-be-verified labels, the interface program is executed, parameters such as parameter entering and parameter exiting of the to-be-verified labels in the development code are intercepted, verification is carried out by using the verification templates, and the technical means of determining abnormal faults in the development code are overcome, so that the defects that the personal experience of research and development personnel is limited, the faults existing in the interface are usually revealed during the test, and the fault errors are required to be retested by the interface, and the test personnel need to communicate fault details and the recurrence method, and the repaired interface need to be retested, the test cost is greatly increased, the test consumption is greatly, the platform is blocked, the platform is prevented from being on line, the platform is influenced, the fault is exposed to the development stage in time, the abnormal faults are found out in the interface, the interface is repaired in the stage, the abnormal fault is guaranteed, the abnormal fault line is guaranteed, the fault condition is reduced, the fault line is stable on the test process is stable, and the test efficiency is reduced, and the normal running the test process is influenced on the test platform, and the test process is stable, and the test cost is required to be tested on the interface.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a method for pre-locating an abnormal failure of an interface program according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main flow of a tag library generation method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main flow of a method for determining a tag to be verified according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main flow of a verification method of an idempotent check template according to an embodiment of the invention;
FIG. 5 is a schematic diagram of the main flow of a method of verifying a transaction consistency template according to an embodiment of the invention;
FIG. 6 is a schematic diagram of the main flow of a verification method of a boundary-check template according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of the main flow of a verification method for updating a checking template of a database and a table according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of the main modules of a pre-positioning device for abnormal faults of an interface program according to an embodiment of the present invention;
FIG. 9 illustrates an exemplary system architecture diagram of a prepositioning method of abnormal faults or prepositioning apparatus of abnormal faults of an interface program suitable for application to an embodiment of the present invention;
fig. 10 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that, in the technical solution of the present disclosure, the related aspects of collecting, updating, analyzing, processing, using, transmitting, storing, etc. of the personal information of the user all conform to the rules of the related laws and regulations, and are used for legal purposes without violating the public order colloquial. Necessary measures are taken for the personal information of the user, illegal access to the personal information data of the user is prevented, and the personal information security, network security and national security of the user are maintained.
jdk: java Development Kit, a software development kit in the Java language.
proxy: proxy software or proxy servers may also be considered a network access mode.
cglib: the open source project is a strong, high-performance and high-quality Code generation class library, can expand Java classes and realize Java interfaces in the running period, is widely used by a plurality of AOP frameworks, and can provide the interception of the method.
Idempotent: repeated execution does not affect the final result.
Transaction consistency: one functional module includes multiple operations, all of which succeed or fail together.
Boundary: the boundary values of the program logic, such as the maximum and minimum values of the integer type.
The existing interface program abnormal fault positioning is usually in a testing stage, and the whole process of communicating fault details with research and development personnel, how to reproduce, repair faults, re-test and the like is needed to go through again, so that the repair cost required in the testing stage is far higher than that in the development stage.
By the prepositioning method of the abnormal faults of the interface program, the prepositioning of the abnormal faults of the interface program to a development stage, and the research personnel can directly repair the faults, especially make up the functional defects of the interface program, so that the integrity and the accuracy of the interface program are improved higher, the testing and the online time of the interface program are shortened, and the testing efficiency and the running stability of a platform are improved.
Fig. 1 is a schematic diagram of a main flow of a prepositioning method of an abnormal fault of an interface program according to an embodiment of the present invention, as shown in fig. 1, the prepositioning method of an abnormal fault of an interface program of the present invention includes the following steps:
in the embodiment of the invention, the prepositioning method of the abnormal faults of the interface program is applied to the development stage rather than the test stage of the interface program, so that the prepositioning exposure of the abnormal faults of the interface program is realized, a researcher immediately repairs the abnormal faults after finding the abnormal faults, the stages of waiting for test results, performing fault reproduction, tester repair, retesting and the like through communication between testers and the researcher are not needed, the test cost is greatly reduced, and the troubleshooting of the abnormal faults of the interface program is prepositioned to the development stage, so that the test efficiency is improved.
Step S101, acquiring development codes of the interface program.
In the embodiment of the invention, development codes of interface programs under different scenes are acquired, wherein the scenes can be a next scene, a second killing scene, a payment scene, a purchasing scene and the like. The development code may be in any programming language, such as C language, C++, C#, java, PHP, and the like.
Step S102, detecting the development codes by using a code analysis tool according to a preset tag library, and positioning one or more tags to be verified in the development codes.
In the embodiment of the invention, before the prepositioning method of the abnormal fault of the interface program is used, the keywords to be checked and the check strategies thereof are combed to construct a tag library, and then when the prepositioning method of the abnormal fault of the interface program is used, the keywords which are the same as the tag library in the development codes corresponding to the interface program are searched for as the tags to be checked according to the tag library, and the check strategies are utilized to check the tags to be checked, as shown in fig. 2, the generating method of the tag library comprises the following steps:
step S201, obtaining abnormal fault data of a history interface program; wherein the abnormal fault data includes a fault code of an abnormal fault.
In the embodiment of the invention, the frequent abnormal faults of the historical interface program are combed, and the corresponding fault codes are obtained.
Step S202, analyzing the context dependency relationship in the fault code, and extracting keywords and verification strategies in the fault code; wherein the keywords include fault entry methods, and/or fault method functions.
In the embodiment of the invention, the context dependency relationship refers to the dependency relationship between each entry method and/or method function in the code paragraph, and the key words and the verification policy in the code can be obtained by analyzing the entry parameters and the exit parameters of each entry method and/or method function. The method can be a Jacf interface implementation class, a message queue consumer, a timing task and the like, the method function can be database writing (or called Input function), database reading (or called Output) and the like, and the method function can be selectively set according to actual needs. The check policy may be an idempotent check policy, a transaction consistency policy, a boundary check policy, a per-bank per-table update check policy, a concurrency policy, a cache expiration time check policy, a anti-replay policy, an SQL injection check policy, a slow SQL check policy, a demotion policy, etc.
For example, taking the example that the verification policy is an idempotent checking policy, the fault entry method may be a consumer of the message queue; or the fault method functions comprise database writing, database reading, database inquiry and database insertion, wherein the database reading of the input parameters is required to depend on the database writing of the input parameters and the database checking of the input parameters are required to be checked to be the same, the database inquiry of the input parameters is required to depend on the database reading of the output parameters and the database checking of the input parameters are required to be checked to be the same, the database inserting of the input parameters is required to depend on the database inquiry of the output parameters and the database checking of the input parameters are required to be checked to be the same, and the database writing of the input parameters and the database checking of the input parameters to be written into the database are required to be the same; or the fault method function is database inquiry and database update, the database update is based on the output parameters of the database inquiry, and the database update is updated by the database update under the condition that whether the output parameters of the database update are consistent with the output parameters of the database inquiry are required to be compared during verification; or the fault method function is database writing and operation caching, the operation caching is dependent on the writing caching time of the database, whether the writing caching time of the database is larger than a caching time threshold or not is needed to be judged during verification, and the operation caching can be executed under the condition that the writing caching time of the database is larger than the caching time threshold; or, checking whether only one failure method function is included in the call link of the failure entry method, etc.
For another example, taking the example that the verification policy is a transaction consistency policy, the fault method function is @ transaction annotation, and the @ transaction annotation needs to be verified when verification exists.
For another example, taking the checking policy as an updating checking policy of the database sub-table as an example, the fault entry method is CSD database sub-table, the fault method function is updated sql, and it is required to check whether the type of the database sub-table in the database connection information in the configuration file is CSD database sub-table during checking, if so, it is checked whether the sql beginning with update is included.
It should be noted that the entry method and the method function are merely examples, and in the actual development stage, the keywords may be selectively set according to the content of the actual development code.
Step S203, generating the tag library according to the corresponding relation between the extracted keywords and the tag types of the verification policies.
In the embodiment of the invention, the entry method and/or the method function corresponding to the frequently occurring abnormal faults are stored as keywords to the tag library on the designated storage medium (such as a database or a cache) and the tag type corresponding to the keywords is stored to the tag library. The tag types correspond to different verification policies, for example, the tag types can be idempotent check tags, transaction consistency tags, boundary check tags, database and table update check tags, concurrency tags, cache expiration time check tags, anti-replay and anti-brush tags, SQL injection check tags, slow SQL check tags, degradation tags and the like.
According to the method for generating the tag library, disclosed by the embodiment of the invention, the historical abnormal fault data is utilized, the fault entry method and the fault method function in the code are combed, the keywords are extracted from the historical abnormal fault data, the context relation of the code is combed, the verification strategy corresponding to the keywords is determined, and the tag library is dropped, so that the code analysis in the subsequent development period is facilitated, the abnormal fault is positioned and repaired in time, the test cost is reduced, and the online efficiency and the operation stability of the program are improved.
In the embodiment of the invention, the code analysis tool can locate the label to be verified in the development code according to the keyword and the corresponding label type which are stored in the label library and need to be verified, so that the development code can be verified based on the label type matching verification template of the label to be verified, and whether the development code has abnormal faults or not can be determined. Wherein the code analysis tool may be a static code analyzer.
In the embodiment of the present invention, as shown in fig. 3, the method for determining the tag to be verified according to the present invention includes the following steps:
step S301, converting the development code to obtain a byte code file of the development code.
In embodiments of the present invention, the code analysis tool may analyze source code developed in any type of programming language. The input of the code analysis tool is a source code (i.e. development code) which can be compiled, and the code analysis tool can convert the source code into a byte code file conforming to the semantic model of the code analysis tool according to the difference of the semantic model adopted by the code analysis tool so as to analyze the byte code file.
Step S302, detecting the byte code file, and searching one or more entry methods in the byte code file.
In the embodiment of the invention, the code analysis tool detects the byte code file and searches all entry methods in the byte code file.
Step S303, analyzing the method functions included in each calling link under each entry method.
In the embodiment of the invention, the code analysis tool analyzes the call links under each entry method in the byte code file and determines the method functions included in each call link.
And step S304, comparing the entry method, the method function and each keyword in the tag library, and marking the entry method and/or the method function which are the same as the keywords in the tag library as the tags to be verified of the development code.
In the embodiment of the invention, the code analysis tool compares each entry method searched in the step S302 with the keywords in the tag library, determines the entry method in the byte code file which is the same as the keywords in the tag library, and marks the entry method as the tag to be verified; and/or the code analysis tool compares each method function found in the step S303 with the keywords in the tag library, determines the method function in the byte code file which is the same as the keywords in the tag library, and marks the method function as the tag to be verified.
For example, taking the check policy as an idempotent checking policy as an example, the code analysis tool detects an entry of the byte code file acquisition class, and marks the entry method as a label to be checked when the entry method is a keyword in the label library, specifically, one call link is "a (consumer of the message queue) - > B- > C", the mark a method is the label to be checked, the corresponding label type is the idempotent checking label, and the B, C method may not be marked. Or the code analysis tool detects keywords in a calling link of the byte code file, when the method function is the keywords in the tag library, the method function is marked as a tag to be verified, specifically, the parameter outputting of the database reading depends on the parameter inputting written in the database, and the database writing and the database reading are marked as the tag to be verified; the entering of the database query depends on the exiting of the database reading, and the database query and the database reading are marked as the tags to be checked; the database insertion and database query are marked as labels to be checked; cross-database writing depends on the out-parameter of the database query of the database to be read and the in-parameter of the database writing of the database to be written, and the database query of the database to be read and the database writing of the database to be written are marked as the label to be checked; the input of the database update depends on the output of the database query, and the database update and the database query are marked as tags to be checked; marking the operation cache and the cache time written by the database as a label to be checked; checking whether the calling link of the entry method only comprises one method function, and marking the entry method and the method function as labels to be checked.
For another example, take the example that the verification policy is a transaction consistency policy, the @ transaction annotation is marked.
For another example, taking the example that the verification policy is a database-partition-table update checking policy, the entry method and the method function are marked, specifically, the type of the database-partition table, and the sql beginning with update are marked.
According to the method for determining the label to be verified, disclosed by the embodiment of the invention, the newly developed code can be detected and analyzed, and the label to be verified and the label type of the developed code are determined based on the keywords of the label library, so that the abnormal faults of the developed code can be positioned by using the verification template in the follow-up process, the test cost is reduced, and the stability of an interface program is improved.
Further, the obtained label to be verified can be stored, so that later reading and verification are facilitated.
And step S103, executing the interface program and intercepting the label to be verified in the development code.
In the embodiment of the invention, in a development period or a development stage, compiling a development code into a byte code file which can be identified by a computer, executing the byte code file to execute an interface program, intercepting a label to be checked in the development code of the interface program by utilizing a dynamic proxy, wherein the dynamic proxy can be a jdk self-contained proxy, invocationhandler mode or a mode based on a byte code technology cglib, and can intercept an entry method and/or a method function to obtain the method type of the entry method, the entry and exit parameters of the method function and the like.
Further, the dynamic proxy may intercept the entry method type and entry, exit, etc. of the method function of the entry method from the bytecode file using the wrap-around enhancement method.
Step S104, matching a target verification template from a pre-constructed verification template according to the label type of the label to be verified, verifying the development code, and determining an abnormal fault in the development code.
In the embodiment of the invention, the verification templates comprise an idempotent verification template, a transaction consistency template, a boundary verification template, a database and table updating query template, a database and table inserting verification template, a database and table deleting verification template, a concurrency template, a cache expiration time verification template, a weight-proof and brushing-proof template, an SQL injection verification template, a slow SQL verification template, a degradation template and the like, and different verification templates use different verification strategies, as shown in fig. 4, the verification method of the idempotent verification template comprises the following steps:
step S401, obtaining a plurality of execution results corresponding to the label to be verified in the repeated execution process of the interface program.
Step S402, judging whether a plurality of execution results are equal, if so, turning to step S403; if not, go to step S404.
In the embodiment of the invention, the idempotency checking template is used for judging whether the execution results of multiple identical executions are identical.
Step S403, determining that the verification result is successful idempotent verification.
In the embodiment of the invention, the success of the idempotent verification is determined under the condition that the execution results of the same execution are the same.
Step S404, determining that the verification result is that the idempotent verification fails, and sending out an alarm prompt.
In the embodiment of the invention, under the condition that the execution results of the same execution are different, the idempotent verification is determined to fail, and the warning prompt is sent out, so that a developer can analyze and repair the abnormal faults.
In the embodiment of the present invention, as shown in fig. 5, the verification method of the transaction consistency template of the present invention includes the following steps:
step S501, obtaining node positions corresponding to the to-be-verified labels of the plurality of transaction nodes in the executing process of the interface program.
In the embodiment of the invention, the transaction node can be a plurality of database copies, for example, the node position and the node value of the execution results of the plurality of database copies corresponding to the @ transaction annotation are obtained.
Step S502, determining whether node values of the node positions corresponding to the transaction nodes and the tags to be verified are equal, and if yes, turning to step S503; if not, go to step S504.
In the embodiment of the invention, the transaction consistency template is used for judging whether the node values of the same node positions of a plurality of transaction nodes are the same or not.
Step S503, determining that the check result is that the transaction consistency check is successful.
In the embodiment of the invention, the success of the transaction consistency check is determined under the condition that the node values of the same node positions of a plurality of transaction nodes are the same.
Step S504, determining that the check result is that the transaction consistency check fails, and sending out an alarm prompt.
In the embodiment of the invention, under the condition that the node values of the same node positions of a plurality of transaction nodes are different, the transaction consistency check fails, and an alarm prompt is sent out, so that a developer can analyze and repair the abnormal faults.
In the embodiment of the present invention, as shown in fig. 6, the verification method of the boundary checking template of the present invention includes the following steps:
step S601, obtaining a parameter type corresponding to the tag to be verified in the execution process of the interface program.
In the embodiment of the invention, the boundary checking template automatically generates a corresponding boundary value according to the parameter type of the entry method and/or the entry parameter or the exit parameter of the method function. For example, the parameter type is Integer Integer, and the generated boundary VALUEs may be a maximum VALUE (MAX_VALUE) and a minimum VALUE (MIN_VALUE).
Step S602, determining whether the parameter value of the label to be inspected meets the requirement of the boundary value according to the boundary value of the parameter type, and if yes, going to step S603; if not, go to step S604.
In the embodiment of the invention, the boundary checking template is used for detecting whether the parameter value of the input parameter or the output parameter is smaller than or equal to the maximum value and larger than or equal to the minimum value.
Step S603, determining that the checking result is that the boundary checking check is successful.
In the embodiment of the invention, the success of the boundary checking check is determined under the condition that the parameter value of the input parameter or the output parameter is smaller than or equal to the maximum value and larger than or equal to the minimum value.
Step S604, determining that the checking result is that the boundarity checking check fails, and sending out an alarm prompt.
In the embodiment of the invention, under the condition that the parameter value of the input parameter or the output parameter is larger than the maximum value or smaller than the minimum value, the failure of the boundary checking and checking is determined, and the warning prompt is sent out, so that a developer can analyze and repair the abnormal fault.
In the embodiment of the present invention, as shown in fig. 7, the checking method of the database and table update checking template of the present invention includes the following steps:
step S701, obtaining a sub-table identifier of the database corresponding to the tag to be verified in the execution process of the interface program.
In the embodiment of the invention, the sub-table number of the database is divided according to the data size, and the sub-table identification corresponds to the sub-table number.
Step S702, inserting a plurality of pieces of random data into a database sub-table corresponding to the sub-table identification in the database; wherein the random data includes a data identification and a data value.
In the embodiment of the invention, the data size of the random data can be selectively set according to the requirement, for example, the maximum data size of the database is 2 times.
Step S703, judging whether repeated data identification appears in the database sub-table corresponding to the sub-table identification, if so, step S704; if not, go to step S702.
Step S704, executing the update SQL on the data value corresponding to the repeated data identifier.
In the embodiment of the invention, under the condition that repeated data identifications appear in the database sub-table corresponding to the sub-table identifications, the SQL is updated on the data value corresponding to the repeated data identifications.
Step S705, receiving the update result of the update SQL.
In an embodiment of the invention, the updated results include an impact on the number of rows.
Step S706, judging whether the number of the influence lines is larger than or equal to a line number threshold value, if so, step S707; if not, go to step S708.
In the embodiment of the invention, the database and table updating checking template is used for judging the number of the influence lines for executing the updating SQL.
Step S707, determining that the checking result is that the updating check of the sub-database sub-table fails, and sending out an alarm prompt.
In the embodiment of the invention, under the condition that the number of the influence lines is greater than or equal to 1, the failure of executing the update SQL is indicated, and the SQL is possibly inserted or deleted, and an alarm prompt is sent out, so that a developer can analyze and repair the abnormal faults.
Step S708, determining that the checking result is that the database and table updating check is successful.
In the embodiment of the invention, under the condition that the number of the influence lines is smaller than 1, the execution of the update SQL is successful.
Step S709, deleting the random data.
In the embodiment of the invention, under the condition that the checking of the database and table updating is successful, the random data used for checking is deleted.
In the embodiment of the invention, the verification method of the templates such as the idempotent checking template, the transaction consistency template, the boundary checking template, the database and table updating checking template and the like is exemplified, and in the actual development stage, the verification template can be constructed according to the frequently-occurring keywords of the abnormal faults and the corresponding verification strategies which are carded out by the historical fault data, so that the verification execution of the idempotent strategies, the transaction consistency strategies, the boundary checking strategies, the database and table updating checking strategies and other strategies is realized, and the possible frequent abnormal faults in the development code are checked and repaired in the development stage, thereby reducing the test cost.
In the embodiment of the invention, the development code of the interface program is obtained; detecting the development codes by using a code analysis tool according to a preset tag library, and positioning one or more tags to be verified in the development codes; executing the interface program to intercept the label to be checked in the development code; according to the label type of the label to be checked, a target checking template is matched from a pre-constructed checking template, the development code is checked, abnormal faults in the development code are determined, and the like, so that the fault exposure can be advanced to a development period, interface abnormality can be timely found and repaired in the development period, the fault rate in a test period is reduced, the test efficiency is improved, the test cost consumption is reduced, the interface online process is shortened, the influence of interface development on the platform is reduced, and the normal online and operation of the platform are ensured.
Fig. 8 is a schematic diagram of main modules of an exception fault pre-positioning apparatus for an interface program according to an embodiment of the present invention, and as shown in fig. 8, an exception fault pre-positioning apparatus 800 for an interface program of the present invention includes:
an obtaining module 801, configured to obtain development code of the interface program.
The detection module 802 is configured to detect the development code by using a code analysis tool according to a preset tag library, and locate one or more tags to be verified in the development code.
And the interception module 803 is used for executing the interface program and intercepting the label to be checked in the development code.
And the verification module 804 is configured to match a target verification template from the pre-constructed verification templates according to the label type of the label to be verified, verify the development code, and determine an abnormal fault in the development code.
In the embodiment of the invention, the fault exposure can be advanced to the development period through the acquisition module, the detection module, the interception module, the verification module and other modules, and the interface abnormality can be found and repaired in time in the development period, so that the fault rate in the test period is reduced, the test efficiency is improved, the test cost consumption is reduced, the interface online flow is shortened, the influence of interface development on the platform is reduced, and the normal online and operation of the platform are ensured.
Fig. 9 shows an exemplary system architecture diagram of a prepositioning method of an abnormal failure of an interface program or a prepositioning device of an abnormal failure of an interface program, which is suitable for application to an embodiment of the present invention, as shown in fig. 9, and includes:
As shown in fig. 9, system architecture 900 may include terminal devices 901, 902, 903, a network 904, and a server 905. The network 904 is the medium used to provide communications links between the terminal devices 901, 902, 903 and the server 905. The network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 905 over the network 904 using the terminal devices 901, 902, 903 to receive or send messages, etc. Various communication client applications such as a malfunction alert class application, a shopping class application, a web browser application, a search class application, an instant messaging tool, a mailbox client, social platform software, etc., may be installed on the terminal devices 901, 902, 903.
Terminal devices 901, 902, 903 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 905 may be a server providing various services, such as a background management server providing support for a malfunction alerting class website browsed by a user using the terminal apparatuses 901, 902, 903. The background management server may analyze and the like the received data such as the development code, and may feed back the processing result (abnormal failure of the development code) to the terminal apparatuses 901, 902, 903.
It should be noted that, the method for pre-locating an abnormal fault of an interface program provided in the embodiment of the present invention is generally executed by the server 905, and accordingly, the pre-locating device for an abnormal fault of an interface program is generally disposed in the server 905.
It should be understood that the number of terminal devices, networks and servers in fig. 9 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 10 is a schematic structural diagram of a computer system suitable for a terminal device or a server for implementing an embodiment of the present invention, and as shown in fig. 10, a computer system 1000 of a terminal device or a server of an embodiment of the present invention includes:
a Central Processing Unit (CPU) 1001, which can execute various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM1003, various programs and data required for the operation of the system 1000 are also stored. The CPU1001, ROM1002, and RAM1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output portion 1007 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk or the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The drive 1010 is also connected to the I/O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is installed as needed in the drive 1010, so that a computer program read out therefrom is installed as needed in the storage section 1008.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 1009, and/or installed from the removable medium 1011. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 1001.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: the processor comprises an acquisition module, a detection module, an interception module and a verification module. The names of these modules do not form a limitation on the module itself in some cases, for example, the verification module may also be described as "a module that matches a target verification template from a pre-constructed verification template according to the tag type of the tag to be verified, verifies the development code, and determines an abnormal fault in the development code".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: acquiring development codes of the interface program; detecting the development codes by using a code analysis tool according to a preset tag library, and positioning one or more tags to be verified in the development codes; executing the interface program to intercept the label to be checked in the development code; and matching a target verification template from a pre-constructed verification template according to the label type of the label to be verified, verifying the development code, and determining an abnormal fault in the development code.
According to the technical scheme provided by the embodiment of the invention, the label to be checked is detected by using the code analysis tool, and the label to be checked is matched with the check template for checking, so that the fault exposure can be advanced to the development period, and the interface abnormality can be found and repaired in time in the development period, thereby reducing the fault rate in the test period, improving the test efficiency, reducing the test cost consumption, shortening the interface online flow, reducing the influence of interface development on the platform, and ensuring the normal online and operation of the platform.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (11)

1. A method for prepositioning an abnormal failure of an interface program, comprising:
acquiring development codes of the interface program;
detecting the development codes by using a code analysis tool according to a preset tag library, and positioning one or more tags to be verified in the development codes;
executing the interface program to intercept the label to be checked in the development code;
and matching a target verification template from a pre-constructed verification template according to the label type of the label to be verified, verifying the development code, and determining an abnormal fault in the development code.
2. The method of claim 1, wherein the detecting the development code with a code analysis tool locates one or more tags to be verified in the development code, comprising:
Converting the development code to obtain a byte code file of the development code;
detecting the byte code file, and searching one or more entry methods in the byte code file;
analyzing a method function included in each calling link under each entry method;
and comparing the entry method, the method function and each keyword in the tag library, and marking the entry method and/or the method function which are the same as the keywords in the tag library as a mark to be verified of the development code.
3. The method of claim 2, wherein the generating of the tag library comprises:
acquiring abnormal fault data of a history interface program; wherein the abnormal fault data includes a fault code of an abnormal fault;
analyzing the context dependency relationship in the fault code, and extracting keywords and verification strategies in the fault code; wherein the keywords include fault entry methods, and/or fault method functions;
and generating the tag library according to the corresponding relation between the extracted keywords and the tag types of the verification policies.
4. The method of claim 1, wherein the tag types include an idempotent check tag, a transaction consistency tag, a border check tag, a split library and split table update check tag, and wherein the verification templates include an idempotent check template, a transaction consistency template, a border check template, a split library and split table update check template.
5. The method of claim 4, wherein the verifying the development code to determine an exception fault in the development code comprises:
acquiring a plurality of execution results corresponding to the label to be checked in the repeated execution process of the interface program for a plurality of times;
judging whether a plurality of execution results are equal or not;
and under the condition that the execution results of the same execution are different, determining that the verification result is idempotent verification failure, and positioning the abnormal faults in the development code.
6. The method of claim 4, wherein the verifying the development code to determine an exception fault in the development code comprises:
acquiring node positions corresponding to a plurality of transaction nodes and the label to be checked in the execution process of the interface program;
judging whether node values of the plurality of transaction nodes and the node positions corresponding to the tags to be checked are equal or not;
and under the condition that node values of the same node positions of a plurality of transaction nodes are different, determining that the verification result is the transaction consistency verification failure, and positioning the abnormal faults in the development codes.
7. The method of claim 4, wherein the verifying the development code to determine an exception fault in the development code comprises:
Acquiring a parameter type corresponding to the label to be checked in the execution process of the interface program;
judging whether the parameter value of the label to be checked meets the requirement of the boundary value according to the boundary value of the parameter type;
and under the condition that the parameter value of the input parameter or the output parameter of the label to be tested is larger than the maximum value or smaller than the minimum value, determining that the verification result is the failure of the boundary checking and the abnormal fault in the development code is positioned.
8. The method of claim 4, wherein the verifying the development code to determine an exception fault in the development code comprises:
acquiring a sub-table identification of a database corresponding to the label to be checked in the execution process of the interface program;
inserting a plurality of pieces of random data into a database sub-table corresponding to the sub-table identification in the database; wherein the random data comprises a data identifier and a data value;
judging whether repeated data identification appears in a database sub-table corresponding to the sub-table identification, under the condition that repeated data identification appears in the database sub-table corresponding to the sub-table identification, executing update SQL on a data value corresponding to the repeated data identification, and receiving the influence line number returned by the database;
Judging whether the influence line number is larger than or equal to a line number threshold value, and determining that the verification result is that the updating and checking of the database and the table fails under the condition that the influence line number is larger than or equal to 1, and positioning the abnormal faults in the development codes.
9. A prepositioning device for abnormal faults of an interface program, comprising:
the acquisition module is used for acquiring the development code of the interface program;
the detection module is used for detecting the development codes by utilizing a code analysis tool according to a preset tag library and positioning one or more tags to be verified in the development codes;
the interception module is used for executing the interface program and intercepting the label to be checked in the development code;
and the verification module is used for matching a target verification template from a pre-constructed verification template according to the label type of the label to be verified, verifying the development code and determining abnormal faults in the development code.
10. An electronic device for prepositioning abnormal faults of an interface program, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-8.
11. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-8.
CN202310744080.0A 2023-06-21 2023-06-21 Prepositioning method and device for abnormal faults of interface program Pending CN116795700A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310744080.0A CN116795700A (en) 2023-06-21 2023-06-21 Prepositioning method and device for abnormal faults of interface program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310744080.0A CN116795700A (en) 2023-06-21 2023-06-21 Prepositioning method and device for abnormal faults of interface program

Publications (1)

Publication Number Publication Date
CN116795700A true CN116795700A (en) 2023-09-22

Family

ID=88035780

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310744080.0A Pending CN116795700A (en) 2023-06-21 2023-06-21 Prepositioning method and device for abnormal faults of interface program

Country Status (1)

Country Link
CN (1) CN116795700A (en)

Similar Documents

Publication Publication Date Title
US20230281012A1 (en) Systems and methods for automating and monitoring software development operations
US6185583B1 (en) Parallel rule-based processing of forms
US9235410B2 (en) Tracking software package dependencies using a graph model
US11307975B2 (en) Machine code analysis for identifying software defects
CN110858172A (en) Automatic test code generation method and device
CN111507086A (en) Automatic discovery of translation text location in localized applications
US20150089296A1 (en) Derivation of generalized test cases
CN114201408A (en) Regression testing method, device, computer equipment and storage medium
CN111597069A (en) Program processing method, program processing apparatus, electronic device, and storage medium
CN113448869B (en) Method and device for generating test case, electronic equipment and computer readable medium
US20180314683A1 (en) Method and device for processing natural language
CN112988578A (en) Automatic testing method and device
Lavoie et al. A case study of TTCN-3 test scripts clone analysis in an industrial telecommunication setting
US11971802B2 (en) Method, electronic device, and computer program product for code defect detection
CN111309585A (en) Log data testing method, device and system, electronic equipment and storage medium
CN116795700A (en) Prepositioning method and device for abnormal faults of interface program
CN112748950B (en) Software code examination method and device
CN114840429A (en) Method, apparatus, device, medium and program product for identifying version conflicts
CN113672512A (en) Code inspection rule generating method, code inspection method, device and medium
CN110633204B (en) Program defect detection method and device
CN113360365A (en) Flow testing method and flow testing system
CN113157558B (en) System testing method and device
CN116452208B (en) Method, device, equipment and medium for determining change transaction code
US11347722B2 (en) Big data regression verification method and big data regression verification apparatus
CN117112435B (en) Vulnerability linkage detection result fusion method, storage medium and electronic equipment

Legal Events

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