CN114003451A - Interface test method, device, system and medium - Google Patents

Interface test method, device, system and medium Download PDF

Info

Publication number
CN114003451A
CN114003451A CN202111257281.5A CN202111257281A CN114003451A CN 114003451 A CN114003451 A CN 114003451A CN 202111257281 A CN202111257281 A CN 202111257281A CN 114003451 A CN114003451 A CN 114003451A
Authority
CN
China
Prior art keywords
interface
service
flow
test
user
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.)
Granted
Application number
CN202111257281.5A
Other languages
Chinese (zh)
Other versions
CN114003451B (en
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202111257281.5A priority Critical patent/CN114003451B/en
Publication of CN114003451A publication Critical patent/CN114003451A/en
Application granted granted Critical
Publication of CN114003451B publication Critical patent/CN114003451B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2273Test methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • 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)
  • General Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses an interface testing method, a device, a system and a medium, wherein the method comprises the following steps: acquiring user log data generated by a server cluster in the process of responding to user service operation; extracting interface request information of a service interface called by user service operation from user log data; acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows; configuring and packaging information of a target service interface in the interface path by using the interface request information to obtain corresponding interface flow to be detected; and respectively carrying out flow playback on the interface flow to be tested in the reference environment and the test environment to obtain a corresponding interface test result. According to the interface test method and the interface test system, the interface flow to be tested obtained based on the user log data is used as the source of the interface test case to complete the interface test, the interface test efficiency is improved, the labor cost and the time cost are saved, and the risk caused by the test case missing due to manual writing of the test case is avoided.

Description

Interface test method, device, system and medium
Technical Field
The present invention relates to the field of automated interface testing, and in particular, to a method, an apparatus, a system, and a medium for testing an interface.
Background
Currently, in the field of interface automation testing, the following test steps are commonly used to complete interface testing: manual combing test requirements; compiling a test case according to requirements; compiling an interface test script according to the test case and the interface design; and running the interface test script for testing. However, when the test system is complex, for example, some large-scale applications may include hundreds of core applications and thousands of interfaces, and the implementation of the interfaces is also complex, if the interface test is completed by manually writing a test script by a tester, huge labor cost and time cost are consumed, and the efficiency is extremely low. Moreover, the test scenario written in this way is monotonous, and the interface test can not be completed completely by the system due to the absence of the test case, thereby bringing risks to the system.
In summary, how to perform a complete interface test and improve the efficiency in the test process is a problem to be solved at present.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a method, an apparatus, a system and a medium for testing an interface, which can perform a complete interface test and improve efficiency in a test process. The specific scheme is as follows:
in a first aspect, the present application discloses an interface testing method, including:
acquiring user log data generated by a server cluster in the process of responding to user service operation;
extracting interface request information of a service interface called by the user service operation from the user log data;
acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows;
performing information configuration and packaging on a target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow;
and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
Optionally, the obtaining user log data generated by the server cluster in the process of responding to the user service operation includes:
creating a preset user log obtaining rule according to the time period and/or the service name;
and acquiring user log data generated by the server cluster in the process of responding to the user service operation by using the preset user log acquisition rule.
Optionally, the extracting interface request information of the service interface called by the user service operation from the user log data includes:
and extracting any one or more of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information.
Optionally, the generating a corresponding interface path based on the target service interface through which the custom service flow flows includes:
and generating a corresponding interface path by taking an initial service interface in a preset interface path template as a path starting point and based on a target service interface corresponding to a service node in the user-defined service flow, wherein when the service interface corresponding to any service node in the user-defined service flow is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node as the target service interface corresponding to the service node.
Optionally, the interface testing method further includes:
and creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces to obtain the preset interface path template.
Optionally, the performing flow playback on the interface flow to be tested in the reference environment and the test environment respectively to obtain a corresponding interface test result includes:
respectively carrying out flow playback on the flow of the interface to be tested in a reference environment and a test environment to obtain a first test result and a second test result, and carrying out result comparison on the first test result and the second test result;
if the first test result is consistent with the second test result, directly storing the flow of the interface to be tested in a first local flow library;
and if the first test result is inconsistent with the second test result, marking the flow of the interface to be tested as failure, and storing the flow in a second local flow library.
Optionally, after the marking the interface traffic to be tested as a failure and storing the failure in the second local traffic library, the method further includes:
generating a test report based on the interface traffic to be tested marked as failure;
and if the reason for the characterization failure of the test report is that the interface path cannot be found by the interface flow to be tested, removing the interface flow to be tested from the second local flow library.
In a second aspect, the present application discloses an interface testing apparatus, comprising:
the data acquisition module is used for acquiring user log data generated by the server cluster in the process of responding to the user service operation;
the information extraction module is used for extracting interface request information of a service interface called by the user service operation from the user log data;
the path generation module is used for acquiring a custom service flow and generating a corresponding interface path based on a target service interface through which the custom service flow flows;
the flow acquisition module is used for carrying out information configuration and packaging on a target service interface in the interface path by using the interface request information so as to obtain corresponding interface flow to be detected;
and the flow playback module is used for performing flow playback on the interface flow to be tested in a reference environment and a test environment respectively to obtain a corresponding interface test result.
In a third aspect, the present application discloses a computer device comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the interface testing method disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program realizes the steps of the interface testing method disclosed in the foregoing when being executed by a processor.
The method comprises the steps of firstly, acquiring user log data generated by a server cluster in the process of responding to user service operation; extracting interface request information of a service interface called by the user service operation from the user log data; then obtaining a user-defined service flow, and generating a corresponding interface path based on a target service interface through which the user-defined service flow flows; performing information configuration and packaging on a target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow; and finally, respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result. Therefore, the method and the device have the advantages that the obtained user log data are subjected to relevant analysis and editing to obtain the interface flow to be tested, and the flow of the interface flow to be tested is played back to obtain the corresponding interface test result. By the method, whether the flow of the interface to be tested can be used as the test case to complete the automatic interface test can be determined based on the interface test result, and the real log data of the online user is adopted, so that a tester does not need to manually write the test case, the automatic interface test efficiency is improved, the labor cost and the time cost are saved, and the risk problem of system loss caused by the fact that the test case is manually written is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart of an interface testing method disclosed herein;
FIG. 2 is a flow chart of a particular interface testing method disclosed herein;
FIG. 3 is a flow chart of a specific interface testing method disclosed herein;
FIG. 4 is a flow chart of a specific interface test disclosed herein;
FIG. 5 is a schematic structural diagram of an interface testing apparatus disclosed in the present application;
FIG. 6 is a block diagram of a computer device disclosed herein.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Currently, in the field of interface automation test, interface test is usually completed by manually writing test scripts by a tester. However, when the test system is complicated, if the interface test is completed by manually writing the test script by the tester, huge labor cost and time cost are consumed, and the efficiency is extremely low. Moreover, the test scenario written in this way is monotonous, and the interface test can not be completed completely by the system due to the absence of the test case, thereby bringing risks to the system. Therefore, the embodiment of the invention discloses an interface test method which can carry out complete interface test and improve the efficiency in the test process.
Referring to fig. 1, an embodiment of the present invention discloses an interface testing method, including:
step S11: and acquiring user log data generated by the server cluster in the process of responding to the user service operation.
In this embodiment, the obtaining of the user log data generated by the server cluster in the process of responding to the user service operation specifically may include: creating a preset user log obtaining rule according to the time period and/or the service name; and acquiring user log data generated by the server cluster in the process of responding to the user service operation by using the preset user log acquisition rule. It can be understood that, in this embodiment, when obtaining the user log data generated by the server cluster in the process of responding to the user online service operation, the user log data is mainly obtained according to the time period information and/or the service name information, that is, in this embodiment, all the user log data generated by the server cluster in the process of responding to the user service operation are not obtained, but the user log data is obtained according to the preset user log obtaining rule, so as to obtain the user log data meeting the requirement. For example, when a shopping platform has shopping activities in 20:00 to 22:00, the user log data of the platform in the time period may be selected to be pulled, or the user log data corresponding to the business operation of purchasing commodities by the user may be pulled.
Step S12: and extracting interface request information of a service interface called by the user service operation from the user log data.
In this embodiment, the extracting interface request information of the service interface called by the user service operation from the user log data may specifically include: and extracting any one or more of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information. It can be understood that, after the user log data is obtained, in this embodiment, interface request information of a service interface called by a user service operation needs to be extracted from the obtained user log data, and the interface request information needs to be stored in a local database according to a format required by an interface test. It should be noted that, in the above extraction process, the user identification data in the user log data may be configured as a uniform numerical value, the user identification data may include, but is not limited to, token, name, and phone, and the interface request information may include, but is not limited to, a request method, a request path, a request parameter, and request header information.
Step S13: and acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows.
In this embodiment, it should be noted that, first, a custom service flow is obtained, and one or more corresponding interface paths are randomly generated based on a target service interface through which the custom service flow flows.
Step S14: and performing information configuration and packaging on the target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow.
In this embodiment, after the interface path is generated, the interface request information obtained in step S12, that is, any one or more of the request method, the request path, the request parameter, and the request header information, needs to be used to perform information configuration and parameter encapsulation on the target service interface in the interface path, so as to obtain the interface traffic to be measured.
Step S15: and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
In this embodiment, the obtained flow of the interface to be tested needs to be tested in an offline testing environment, where the offline testing environment includes two parts, one is a reference environment of the trunk branch code, and the other is a testing environment of the personal branch, and the reference environment can be understood as a very ideal environment, which is an agreed environment for correcting and comparing the testing results in other testing environments, and the testing environment is an environment conforming to a real testing scenario. Therefore, the final interface test result is obtained by respectively carrying out flow playback on the flow of the interface to be tested in the reference environment and the test environment.
Therefore, in the embodiment of the application, user log data generated by a server cluster in the process of responding to user service operation is firstly obtained; extracting interface request information of a service interface called by the user service operation from the user log data; then obtaining a user-defined service flow, and generating a corresponding interface path based on a target service interface through which the user-defined service flow flows; performing information configuration and packaging on a target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow; and finally, respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result. Therefore, the method and the device have the advantages that the obtained user log data are subjected to relevant analysis and editing to obtain the interface flow to be tested, and the flow of the interface flow to be tested is played back to obtain the corresponding interface test result. By the method, whether the flow of the interface to be tested can be used as the test case to complete the automatic interface test can be determined based on the interface test result, and the real log data of the online user is adopted, so that a tester does not need to manually write the test case, the automatic interface test efficiency is improved, the labor cost and the time cost are saved, and the risk problem of system loss caused by the fact that the test case is manually written is avoided.
Referring to fig. 2, the embodiment of the present invention discloses a specific interface testing method, and compared with the previous embodiment, the present embodiment further describes and optimizes the technical solution. The method specifically comprises the following steps:
step S21: and acquiring user log data generated by the server cluster in the process of responding to the user service operation.
Step S22: and extracting interface request information of a service interface called by the user service operation from the user log data.
Step S23: obtaining a self-defined service flow, and generating a corresponding interface path by taking an initial service interface in a preset interface path template as a path starting point and based on a target service interface corresponding to a service node in the self-defined service flow, wherein when the service interface corresponding to any service node in the self-defined service flow is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node as the target service interface corresponding to the service node.
In this embodiment, the interface testing method further includes: and creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces to obtain the preset interface path template. It can be understood that there is a specified calling sequence between different service interfaces, and therefore, a tester needs to edit the calling sequence of all the service interfaces in the server cluster and create an interface path template.
After the interface path template is obtained, an initial service interface in the template, namely the service interface called first, is taken as a path starting point, and a corresponding interface path is generated based on a target service interface corresponding to a service node in the self-defined service flow. It should be noted that there may be a plurality of service interfaces corresponding to a plurality of service nodes in the customized service flow, that is, the node has a plurality of selectable services, and when such a situation is encountered, one service interface is randomly selected from the plurality of service interfaces as a target service interface corresponding to the service node. Therefore, by means of the method for randomly selecting the service interface, after the whole flow of the customized service flow is finished, a plurality of random interface paths can be generated, so that the test scenes can be covered as much as possible, and the problem of test missing is reduced.
Step S24: and performing information configuration and packaging on the target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow.
Step S25: and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
For more specific processing procedures of the steps S21, S22, S24, and S25, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
It can be seen that, in the embodiment of the present application, a service interface is randomly selected when an interface path is generated, so as to approach the real service operation scenario of a user to the maximum extent, achieve the purpose of covering the test service interface as much as possible, and enable generation the interface flow to be tested is also the random interface flow to be tested corresponding to the interface path, thereby reducing the problem of test omission that occurs because the number of interface test scripts written by a tester is limited, and improving the safety of the system.
Referring to fig. 3, the embodiment of the present invention discloses a specific interface testing method, and compared with the previous embodiment, the present embodiment further describes and optimizes the technical solution. The method specifically comprises the following steps:
step S31: and acquiring user log data generated by the server cluster in the process of responding to the user service operation.
Step S32: and extracting interface request information of a service interface called by the user service operation from the user log data.
Step S33: and acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows.
Step S34: and performing information configuration and packaging on the target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow.
Step S35: and respectively carrying out flow playback on the flow of the interface to be tested in a reference environment and a test environment to obtain a first test result and a second test result, and carrying out result comparison on the first test result and the second test result. And if the first test result is consistent with the second test result, directly storing the flow of the interface to be tested in a first local flow library.
In this embodiment, the flow of the interface to be tested is respectively subjected to flow playback in the reference environment and the test environment to obtain a first test result and a second test result, which are compared. When the comparison result is consistent, the interface flow to be tested is stored in the first local flow library, that is, the interface flow to be tested is shown to be in accordance with the real scene, so that the interface flow to be tested stored in the first local flow library can be directly used as an interface test case for system test at a later stage.
It should be noted that, if the first test result and the second test result are inconsistent, the interface traffic to be tested is marked as a failure, and is stored in the second local traffic library. After the marking of the interface traffic to be tested as a failure and storing the interface traffic to be tested in the second local traffic library, the method further includes: generating a test report based on the interface traffic to be tested marked as failure; and if the reason for the characterization failure of the test report is that the interface path cannot be found by the interface flow to be tested, removing the interface flow to be tested from the second local flow library. In this implementation, if the second test result obtained in the test environment is not consistent with the first test result obtained in the reference environment, it is indicated that the flow of the interface to be tested may have a problem in the test environment, so the flow of the interface to be tested may be marked as a failure and separately stored in the second local flow library, and the flow of the interface to be tested marked as a failure may be generated into a test report for a tester to analyze and confirm whether the flow of the interface to be tested really has a problem, where if the failure is caused by that the flow of the interface to be tested cannot find a corresponding interface path, the flow of the interface to be tested is removed from the second local flow library. It can be understood that, because a randomized process is used in the generation process of the interface path, which is equivalent to that the interface traffic to be tested is also randomly generated, some interface traffic to be tested that does not conform to the real scene may occur, that is, the corresponding interface path cannot be found, so that an error occurs in the playback of the traffic in the test environment. And for the situations, removing the interface flow to be detected from the second local flow library. It should be noted that the interface traffic marked as failure, which is finally stored in the second local traffic library in this embodiment, is probably caused by a problem occurring in the corresponding function in the test environment. Therefore, the interface traffic marked as failure is stored, so that the interface traffic can be conveniently analyzed and checked later to find out the reason causing the abnormal function problem and determine the corresponding solution. In addition, after the above abnormal function problem is solved by means, whether the corresponding abnormal function problem is successfully solved or not can be further verified by executing the above interface flow.
For more specific processing procedures of the steps S31, S32, S33, and S34, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
Therefore, in the embodiment of the application, the first test result and the second test result obtained by respectively performing flow playback on the interface flow to be tested in the reference environment and the test environment are compared, and whether the interface flow to be tested can be used as the interface test case for the later system test is determined based on the comparison result. By the method, interface testing is completed without manually compiling a test script by a tester, so that the automatic testing efficiency of the interface is improved, the labor cost and the time cost are saved, and the risk problem of system loss caused by test case missing possibly caused by manually compiling the test case is avoided.
Referring to fig. 4, an embodiment of the present invention discloses a specific interface testing flowchart, where the flowchart includes: firstly, user log data generated in a server cluster response online user service operation is obtained and online log storage is carried out; pulling time period information and service name information of online user log data, extracting a request method, a request path, a request parameter and request header information of a service interface called during online user service operation from the pulled user log data as interface request information, and performing local log storage on the interface request information; then, intelligently analyzing and editing the stored log data to generate interface flow to be tested and storing the interface flow to a local flow library; and finally, respectively carrying out flow playback on the flow of the interface to be tested in the reference environment and the test environment to obtain respective corresponding test results, removing improper flow from a local flow library according to the test results, and simultaneously solidifying the flow.
Referring to fig. 5, an embodiment of the present invention further discloses an interface testing apparatus, including:
the data acquisition module 11 is configured to acquire user log data generated by the server cluster in a process of responding to a user service operation;
an information extraction module 12, configured to extract interface request information of a service interface called by the user service operation from the user log data;
a path generating module 13, configured to obtain a custom service flow, and generate a corresponding interface path based on a target service interface through which the custom service flow flows;
a traffic obtaining module 14, configured to perform information configuration and encapsulation on the target service interface in the interface path by using the interface request information, so as to obtain corresponding interface traffic to be detected;
and the flow playback module 15 is configured to perform flow playback on the interface flow to be tested in the reference environment and the test environment respectively to obtain a corresponding interface test result.
Therefore, the method includes the steps that firstly, user log data generated by a server cluster in the process of responding to user service operation are obtained; extracting interface request information of a service interface called by the user service operation from the user log data; then obtaining a user-defined service flow, and generating a corresponding interface path based on a target service interface through which the user-defined service flow flows; performing information configuration and packaging on a target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow; and finally, respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result. Therefore, the method and the device have the advantages that the obtained user log data are subjected to relevant analysis and editing to obtain the interface flow to be tested, and the flow of the interface flow to be tested is played back to obtain the corresponding interface test result. By the method, whether the flow of the interface to be tested can be used as the test case to complete the automatic interface test can be determined based on the interface test result, and the real log data of the online user is adopted, so that a tester does not need to manually write the test case, the automatic interface test efficiency is improved, the labor cost and the time cost are saved, and the risk problem of system loss caused by the fact that the test case is manually written is avoided.
In some specific embodiments, the data obtaining module 11 further includes:
the rule creating unit is used for creating a preset user log obtaining rule according to the time period and/or the service name;
and the log data acquisition unit is used for acquiring the user log data generated by the server cluster in the process of responding to the user service operation by using the preset user log acquisition rule.
In some specific embodiments, the information extraction module 12 further includes:
and the request information extraction unit is used for extracting any one or more of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information.
In some specific embodiments, the path generating module 13 further includes:
and an interface path generating unit, configured to use an initial service interface in a preset interface path template as a path starting point and generate a corresponding interface path based on a target service interface corresponding to a service node in the user-defined service stream, where when a service interface corresponding to any service node in the user-defined service stream is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node as the target service interface corresponding to the service node.
In some specific embodiments, the interface testing apparatus may further include:
and the template creating unit is used for creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces so as to obtain the preset interface path template.
In some specific embodiments, the traffic playback module 15 further includes:
the result comparison unit is used for respectively carrying out flow playback on the flow of the interface to be tested in a reference environment and a test environment so as to obtain a first test result and a second test result, and carrying out result comparison on the first test result and the second test result;
the first flow storage unit is used for directly storing the flow of the interface to be tested in a first local flow library if the first test result is consistent with the second test result;
and the second flow storage unit is used for marking the flow of the interface to be tested as failure and storing the flow in a second local flow library if the first test result is inconsistent with the second test result.
In some embodiments, the second traffic holding unit may further include;
a report generating unit, configured to generate a test report based on the to-be-tested interface traffic marked as failure;
and the flow eliminating unit is used for eliminating the interface flow to be detected from the second local flow library if the reason for the characterization failure of the test report is that the interface path cannot be found by the interface flow to be detected.
Fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present invention. The method specifically comprises the following steps: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein, the memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the interface testing method executed by the computer device disclosed in any of the foregoing embodiments.
In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the computer device 20; the communication interface 24 can create a data transmission channel between the computer device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol applicable to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to obtain external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 21 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor for processing a calculation operation related to machine learning.
In addition, the storage 22 is used as a carrier for storing resources, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., the resources stored thereon include an operating system 221, a computer program 222, data 223, etc., and the storage may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling each hardware device and the computer program 222 on the computer device 20, so as to realize the operation and processing of the mass data 223 in the memory 22 by the processor 21, which may be Windows, Unix, Linux, or the like. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the interface testing method performed by the computer device 20 disclosed in any of the foregoing embodiments. The data 223 may include data received by the computer device and transmitted from an external device, data collected by the input/output interface 25, and the like.
Furthermore, an embodiment of the present invention further discloses a storage medium, where a computer program is stored in the storage medium, and when the computer program is loaded and executed by a processor, the method steps executed in the interface testing process disclosed in any of the foregoing embodiments are implemented.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The interface testing method, device, equipment and storage medium provided by the invention are described in detail, and the principle and the implementation mode of the invention are explained by applying specific examples, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. An interface testing method, comprising:
acquiring user log data generated by a server cluster in the process of responding to user service operation;
extracting interface request information of a service interface called by the user service operation from the user log data;
acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows;
performing information configuration and packaging on a target service interface in the interface path by using the interface request information to obtain corresponding to-be-detected interface flow;
and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
2. The interface testing method according to claim 1, wherein the obtaining of the user log data generated by the server cluster in the process of responding to the user service operation comprises:
creating a preset user log obtaining rule according to the time period and/or the service name;
and acquiring user log data generated by the server cluster in the process of responding to the user service operation by using the preset user log acquisition rule.
3. The interface testing method according to claim 1, wherein the extracting interface request information of the service interface called by the user service operation from the user log data includes:
and extracting any one or more of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information.
4. The interface testing method according to claim 1, wherein the generating a corresponding interface path based on the target service interface through which the custom service flow flows comprises:
and generating a corresponding interface path by taking an initial service interface in a preset interface path template as a path starting point and based on a target service interface corresponding to a service node in the user-defined service flow, wherein when the service interface corresponding to any service node in the user-defined service flow is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node as the target service interface corresponding to the service node.
5. The interface testing method of claim 4, further comprising:
and creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces to obtain the preset interface path template.
6. The interface testing method according to any one of claims 1 to 5, wherein the performing flow playback on the interface flow to be tested in the reference environment and the test environment respectively to obtain corresponding interface testing results comprises:
respectively carrying out flow playback on the flow of the interface to be tested in a reference environment and a test environment to obtain a first test result and a second test result, and carrying out result comparison on the first test result and the second test result;
if the first test result is consistent with the second test result, directly storing the flow of the interface to be tested in a first local flow library;
and if the first test result is inconsistent with the second test result, marking the flow of the interface to be tested as failure, and storing the flow in a second local flow library.
7. The interface testing method according to claim 6, wherein after marking the interface traffic to be tested as failed and saving it in the second local traffic library, further comprising:
generating a test report based on the interface traffic to be tested marked as failure;
and if the reason for the characterization failure of the test report is that the interface path cannot be found by the interface flow to be tested, removing the interface flow to be tested from the second local flow library.
8. An interface testing apparatus, comprising:
the data acquisition module is used for acquiring user log data generated by the server cluster in the process of responding to the user service operation;
the information extraction module is used for extracting interface request information of a service interface called by the user service operation from the user log data;
the path generation module is used for acquiring a custom service flow and generating a corresponding interface path based on a target service interface through which the custom service flow flows;
the flow acquisition module is used for carrying out information configuration and packaging on a target service interface in the interface path by using the interface request information so as to obtain corresponding interface flow to be detected;
and the flow playback module is used for performing flow playback on the interface flow to be tested in a reference environment and a test environment respectively to obtain a corresponding interface test result.
9. A computer device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to carry out the steps of the interface testing method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program realizes the steps of the interface testing method according to any one of claims 1 to 7 when executed by a processor.
CN202111257281.5A 2021-10-27 2021-10-27 Interface testing method, device, system and medium Active CN114003451B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111257281.5A CN114003451B (en) 2021-10-27 2021-10-27 Interface testing method, device, system and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111257281.5A CN114003451B (en) 2021-10-27 2021-10-27 Interface testing method, device, system and medium

Publications (2)

Publication Number Publication Date
CN114003451A true CN114003451A (en) 2022-02-01
CN114003451B CN114003451B (en) 2023-08-25

Family

ID=79924396

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111257281.5A Active CN114003451B (en) 2021-10-27 2021-10-27 Interface testing method, device, system and medium

Country Status (1)

Country Link
CN (1) CN114003451B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device
CN117555809A (en) * 2024-01-09 2024-02-13 舟谱数据技术南京有限公司 Automatic testing method and related device based on flow replication playback
CN117931681A (en) * 2024-03-22 2024-04-26 云筑信息科技(成都)有限公司 Interface diff test method based on API gateway log playback

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111221743A (en) * 2020-03-18 2020-06-02 时时同云科技(成都)有限责任公司 Automatic testing method and system
CN111552633A (en) * 2020-03-27 2020-08-18 深圳壹账通智能科技有限公司 Interface abnormal call testing method and device, computer equipment and storage medium
CN112559361A (en) * 2020-12-22 2021-03-26 京东数字科技控股股份有限公司 Flow playback method, device, equipment and computer readable medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111221743A (en) * 2020-03-18 2020-06-02 时时同云科技(成都)有限责任公司 Automatic testing method and system
CN111552633A (en) * 2020-03-27 2020-08-18 深圳壹账通智能科技有限公司 Interface abnormal call testing method and device, computer equipment and storage medium
CN112559361A (en) * 2020-12-22 2021-03-26 京东数字科技控股股份有限公司 Flow playback method, device, equipment and computer readable medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device
CN116627851B (en) * 2023-07-24 2023-10-20 恒生电子股份有限公司 Interface testing method and device
CN117555809A (en) * 2024-01-09 2024-02-13 舟谱数据技术南京有限公司 Automatic testing method and related device based on flow replication playback
CN117555809B (en) * 2024-01-09 2024-03-22 舟谱数据技术南京有限公司 Automatic testing method and related device based on flow replication playback
CN117931681A (en) * 2024-03-22 2024-04-26 云筑信息科技(成都)有限公司 Interface diff test method based on API gateway log playback

Also Published As

Publication number Publication date
CN114003451B (en) 2023-08-25

Similar Documents

Publication Publication Date Title
CN114003451B (en) Interface testing method, device, system and medium
CN111159049B (en) Automatic interface testing method and system
WO2020155777A1 (en) Ui automated function testing method, testing device, testing apparatus, and storage medium
CN107608874A (en) Method of testing and device
CN106933729A (en) A kind of method of testing and system based on cloud platform
CN113760730B (en) Automatic test method and device
CN112380255A (en) Service processing method, device, equipment and storage medium
CN105760300B (en) A kind of automated testing method and test macro of STK/UTK business
CN109966742A (en) The method and device of rendering performance data is obtained in game running
CN108874649A (en) Generation method, device and its computer equipment of automatic test script
CN103049374B (en) Automatic testing method and device
CN113590454A (en) Test method, test device, computer equipment and storage medium
CN111708712A (en) User behavior test case generation method, flow playback method and electronic equipment
CN111176974B (en) Disaster tolerance testing method and device, computer readable medium and electronic equipment
CN111897737A (en) Omission detection method and device for program test of micro-service system
CN114143235A (en) NFV automatic test method, device, equipment and storage medium
CN113220561A (en) Test case management method, device, equipment and medium
CN115987821A (en) Gateway routing test method and device
CN109857576A (en) RPC interface call method and device
CN115511317A (en) Wind control strategy configuration method and device
CN115291938A (en) Component configuration method and system for electronic evidence analysis
CN110738384B (en) Event sequence checking method and system
CN114253867B (en) Automatic testing method, device and system based on neural network model
CN118261143B (en) Json data analysis method, device, equipment and medium in Unity environment
CN113238934B (en) Method for automatically judging data acquisition result of test system

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
GR01 Patent grant
GR01 Patent grant