CN115168203A - Interface simulation method, device, system, computer equipment and storage medium - Google Patents

Interface simulation method, device, system, computer equipment and storage medium Download PDF

Info

Publication number
CN115168203A
CN115168203A CN202210782518.XA CN202210782518A CN115168203A CN 115168203 A CN115168203 A CN 115168203A CN 202210782518 A CN202210782518 A CN 202210782518A CN 115168203 A CN115168203 A CN 115168203A
Authority
CN
China
Prior art keywords
interface
simulation
target
message data
information
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
CN202210782518.XA
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210782518.XA priority Critical patent/CN115168203A/en
Publication of CN115168203A publication Critical patent/CN115168203A/en
Pending legal-status Critical Current

Links

Images

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/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0876Aspects of the degree of configuration automation
    • H04L41/0886Fully automatic configuration
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/14Network analysis or design

Abstract

The application relates to an interface simulation method, an interface simulation device, an interface simulation system, computer equipment, a storage medium and a computer program product, relates to the technical field of intelligent operation and maintenance, and can be used in the field of financial science and technology or other related fields. The method comprises the following steps: acquiring test message data of each interface successfully called by a target application system in a test process; determining simulation message data corresponding to each interface information according to the test message data, and establishing a corresponding relation between the interface information and the simulation message data; responding to an interface simulation request sent by an application server, and determining target simulation message data according to target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data; and generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting an agent service corresponding to the target service based on the program information. The method can improve the interface simulation efficiency.

Description

Interface simulation method, device, system, computer equipment and storage medium
Technical Field
The present application relates to the field of intelligent operation and maintenance technologies, and in particular, to an interface simulation method, apparatus, system, computer device, storage medium, and computer program product.
Background
With the development of internet finance, various financial application systems appear. When a financial application system is used for handling business, a server of the application system is generally required to interact with each external connection system to realize corresponding business functions, and specifically, interaction is realized by calling each interface.
Because of the particularity of the financial field, the stability of the financial application system is very important, so that the fatigue test of the application system is often required to verify the stability performance of the application system under the average business pressure or the performance of the application system under the peak business pressure. Generally, fatigue testing needs to be continued for hours or even days, and if an interface is in an unavailable state due to a failure of an external connection system and other reasons in the testing process, the testing process is affected.
In the related art, in order to avoid affecting the test process, an interface simulation (Mock) method may be used to simulate a required interface for testing. However, in the interface simulation method in the related art, it is necessary to manually collect interface information to be simulated in advance and set interface simulation data of each interface, and then manually configure a simulation interface (or simulation service) based on the interface simulation data and a simulation service code, so as to return interface simulation data by acting on a real service in a test process. Namely, the interface simulation method needs to manually collect interface data and manually configure a simulation interface, and has the problem of low interface simulation efficiency.
Disclosure of Invention
In view of the above, it is necessary to provide an interface simulation method, apparatus, system, computer device, computer readable storage medium, and computer program product capable of improving interface simulation efficiency.
In a first aspect, the present application provides an interface simulation method. The method comprises the following steps:
acquiring test message data of each interface successfully called by the application server in the test process of the target application system; the test message data comprises interface information;
determining simulation message data corresponding to the interface information according to the test message data, and establishing a corresponding relation between the interface information and the simulation message data;
responding to an interface simulation request aiming at a target interface sent by the application server, and determining target simulation message data corresponding to the target interface information according to target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data;
and generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information.
In one embodiment, the interface information comprises interface basic information and upper-sending message abstract information; the test message data comprises uploading message data and return message data corresponding to the uploading message data;
the determining the simulation message data corresponding to each interface information according to the test message data includes:
extracting interface basic information and submitted message abstract information from the submitted message data to obtain the interface information;
classifying the test message data according to the interface information to obtain return message data corresponding to the interface information;
and performing format processing on the returned message data corresponding to each interface information to obtain the simulated message data corresponding to each interface information.
In one embodiment, after the starting of the proxy service corresponding to the target service based on the program information, the method further includes:
sending start success information for successfully starting the proxy service corresponding to the target service to the application server, wherein the start success information is used for indicating the application server to send an access request aiming at the target service to the simulation server;
and responding to an access request which is sent by the application server and aims at the target service, and returning the target simulation message data to the application server.
In one embodiment, in a case that the type of the target interface is an HTTP interface, the start success information is further used to instruct the application server to execute an agent command according to the start success information;
after the sending the start success information of the agent service corresponding to the target service successfully started to the application server, the method further includes:
monitoring the state of the target interface, when the target interface is in an available state, releasing the proxy service, and when the type of the target interface is an HTTP interface, sending a release instruction for releasing the proxy service to the application server, so that the application server cancels the execution of the proxy command according to the release instruction.
In one embodiment, after the starting of the proxy service corresponding to the target service based on the program information, the method further includes:
and sending a registration request to a registration center of the distributed service under the condition that the type of the target interface is a distributed service interface, wherein the registration request is used for registering the simulation server as a provider of the target service.
In one embodiment, after sending the registration request to the registry of the distributed service, the method further includes:
and monitoring the state of the target interface, and sending a deregistration request to a registry of the distributed service when the target interface is in an available state, wherein the deregistration request is used for cancelling the simulation server as a providing end of the target service.
In a second aspect, the present application further provides an interface simulation system. The interface simulation system comprises a simulation server and an application server of a target application system, wherein:
the simulation server is used for acquiring test message data of each interface successfully called by the application server in the test process of the target application system; the test message data comprises interface information; determining simulation message data corresponding to the interface information according to the test message data, and establishing a corresponding relation between the interface information and the simulation message data;
the application server is used for sending an interface simulation request aiming at a target interface to the simulation server;
the simulation server is also used for determining target simulation message data corresponding to the target interface information according to the target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data; and generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information.
In one embodiment, the application server is further configured to collect test packet data of each interface called by the target application system in a test process, and send the test packet data of each interface successfully called to the simulation server.
In one embodiment, the application server is further configured to determine test message data with failed interface invocation according to the test message data with the failed interface invocation, count the number of invocation failures of each interface according to the test message data with failed interface invocation, and determine the interface with the number of invocation failures reaching a preset threshold as the target interface.
In a third aspect, the present application further provides an interface simulation apparatus. The device comprises:
the acquisition module is used for acquiring test message data of each interface successfully called by the application server in the test process of the target application system; the test message data comprises interface information;
the establishing module is used for determining the simulation message data corresponding to the interface information according to the test message data and establishing the corresponding relation between the interface information and the simulation message data;
the determining module is used for responding to an interface simulation request aiming at a target interface sent by the application server, and determining target simulation message data corresponding to the target interface information according to target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data;
and the starting module is used for generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information.
In one embodiment, the interface information comprises interface basic information and upper-sending message abstract information; the test message data comprises uploading message data and return message data corresponding to the uploading message data; the establishing module is specifically configured to:
extracting interface basic information and submitted message abstract information from the submitted message data to obtain the interface information; classifying the test message data according to the interface information to obtain return message data corresponding to the interface information; and performing format processing on the returned message data corresponding to each interface information to obtain the simulated message data corresponding to each interface information.
In one embodiment, the apparatus further comprises:
a first sending module, configured to send, to the application server, start success information for successfully starting the proxy service corresponding to the target service, where the start success information is used to instruct the application server to send an access request for the target service to the simulation server;
and the return module is used for responding to the access request aiming at the target service sent by the application server and returning the target simulation message data to the application server.
In one embodiment, in the case that the type of the target interface is an HTTP interface, the start success information is further used to instruct the application server to execute a proxy command according to the start success information;
the device also comprises a second sending module, which is used for monitoring the state of the target interface, releasing the proxy service when the target interface is in an available state, and sending a release instruction for releasing the proxy service to the application server under the condition that the type of the target interface is an HTTP interface, so that the application server cancels the execution of the proxy command according to the release instruction.
In one embodiment, the apparatus further includes a third sending module, configured to send, if the type of the target interface is a distributed service interface, a registration request to a registry of distributed services, where the registration request is used to register the simulation server as a provider of the target service.
In one embodiment, the apparatus further includes a fourth sending module, configured to monitor a state of the target interface, and send a deregistration request to a registry of the distributed service when the target interface is in an available state, where the deregistration request is used to cancel the proxy service from being used as the provider of the target service.
In a fourth aspect, the application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of the method of the first aspect when executing the computer program.
In a fifth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method of the first aspect.
In a sixth aspect, the present application further provides a computer program product. The computer program product comprising a computer program which, when executed by a processor, performs the steps of the method of the first aspect.
According to the interface simulation method, the device, the system, the computer equipment, the storage medium and the computer program product, the test message data of each interface is successfully called by the application server in the test process of the target application system, the simulation message data corresponding to each interface information is determined according to the test message data of each interface which is successfully called, the corresponding relation between the interface information and the simulation message data is further established, then the interface simulation request which is sent by the application server and aims at the target interface is responded, the target simulation message data corresponding to the target interface information is determined according to the target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data, and the target simulation message data is the interface simulation data. And further generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting an agent service corresponding to the target service based on the program information. In the method, the interface simulation data can be automatically generated according to the test message data in the test process of the application system, the program information of the target service can be automatically generated according to the target interface information and the target simulation message data, the proxy service is automatically started based on the program information, and the automatic generation of the interface simulation data and the automatic configuration of the simulation interface are realized. Compared with manual collection of interface data and manual configuration of a simulation interface, the method can improve the interface simulation efficiency.
Drawings
FIG. 1 is a schematic diagram of an exemplary interface simulation system;
FIG. 2 is a schematic flow chart diagram illustrating a method for interface emulation according to one embodiment;
FIG. 3 is a flow diagram illustrating the determination of simulated message data according to one embodiment;
FIG. 4 is a schematic flow chart of an interface simulation method according to another embodiment;
FIG. 5 is a signaling diagram of a specific example interface emulation method;
FIG. 6 is a block diagram showing the structure of an interface simulation apparatus according to an embodiment;
FIG. 7 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
First, before specifically describing the technical solution of the embodiment of the present application, a technical background or a technical evolution context on which the embodiment of the present application is based is described. With the development of internet finance, various financial application systems are developed, so that users can perform business transactions such as online transactions through clients of the financial application systems. When a client using a financial application system transacts business (such as account inquiry, account transfer, and financial product purchase), a server of the application system generally needs to interact with other business systems of the financial institution or business systems of third-party institutions (which may be collectively referred to as an external connection system) to realize corresponding business functions, and specifically, the interaction is realized by calling each interface (the interface and the service have a corresponding relationship). Due to the particularity of the financial field, the stability of the financial application system is very important, and as the number of users and financial behaviors increases, the performance of the application system is required to be higher and higher, so that the fatigue test of the application system is often required. Fatigue testing belongs to one of performance tests, and is generally divided into the following two test scenarios:
(1) And finishing the traffic in a certain period on the production under the average pressure level, and observing the running condition of the application system. Traffic volume of 24 hours or a week is generally used as an observation criterion. This test scenario focuses on verifying the stability of the application system.
(2) And operating for a period of time under the pressure level or the maximum processing capacity of the traffic peak, and comprehensively analyzing the transaction execution index and the system monitoring index. This test scenario focuses on verifying the performance of the application system at high intensity. This fatigue test scenario runs for a minimum of 3 hours. After the 3-hour test scene is completed, the test result needs to be analyzed, and if a certain performance counter has a rising trend, the test needs to be continued for 6-hour or 12-hour scenes.
It can be seen that a fatigue test generally needs to last for hours or even days, and in order to ensure the test effect and the reliability of the test result, a real environment needs to be connected as much as possible in the fatigue test process, that is, a real external connection service needs to be accessed as much as possible. However, if some interface is in an unavailable state due to some external system failure or other reasons during the test process, the test process will be affected.
In the related art, in order to avoid affecting the test process, a Mock tool may be generally used to simulate a required interface (or simulate a required service (Server)), so as to return interface simulation data instead of a real service during the test process. However, in the interface simulation method in the related art, it is necessary to manually collect interface information to be simulated in advance and set interface simulation data of each interface, and then manually configure a simulation interface (or simulation service) based on the interface simulation data and a simulation service code, which has a problem of low interface simulation efficiency, and particularly, when there are many involved interfaces, the efficiency problem is more obvious. In addition, the interface simulation method generally starts the simulation interface in the whole test process after the simulation interface is configured in advance. In order to ensure the reliability of the test effect or the test result, the fatigue test process needs to be connected with the real environment as much as possible, and the available state of the real interface is uncontrollable, namely, randomness exists, so that the fatigue test also has randomness on the requirements of the simulation interface. If the simulation interface is started in the whole process, the method is not suitable for the requirements of randomness, flexibility and discontinuity of the simulation interface for fatigue testing. Based on the background, the applicant provides the interface simulation method through long-term research and development and experimental verification, so that interface simulation data can be automatically generated, a simulation interface can be automatically configured, and the interface simulation efficiency is improved. In addition, the method can automatically start or cancel the simulation interface according to the state of each interface in the test process so as to meet the requirements of randomness, flexibility and discontinuity of the simulation interface for fatigue test and give consideration to the test effect and the test progress. In addition, it should be noted that the applicant has paid a lot of creative efforts in finding the technical problems of the present application and the technical solutions described in the following embodiments.
The interface simulation method provided by the embodiment of the present application can be applied to the interface simulation system 100 shown in fig. 1. The interface simulation system 100 includes an application server 102 and a simulation server 104 of a target application system. The target application system is an application system to be tested, and the application server 102 communicates with the simulation server 104 through a network. It will be appreciated that both the application server 102 and the simulation server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In one embodiment, as shown in fig. 2, an interface simulation method is provided, which is described by taking the method as an example applied to the simulation server 104 in fig. 1, and includes the following steps:
step 201, obtaining test message data of each interface successfully called by the application server in the test process of the target application system.
Wherein the test message data includes interface information. The test message data refers to test message data generated when the application server calls an interface for accessing each external connection service in the test process of the application system (such as test transaction through the application system). The test message data for calling each interface generally includes a sent message data and a returned message data, the sent message data refers to the message data of the access request for the external connection service sent by the application server to the external connection system, and the returned message data refers to the message data returned by the external connection system according to the sent message data. If the application server successfully calls a certain interface, the corresponding return message data is received.
In implementation, the simulation server may obtain test message data of each interface successfully called by the application server in the test process of the target application system. For example, the application server may collect test packet data for calling each interface in the test process, determine test packet data for which the interface is successfully called according to the test packet data (for example, it may be determined according to whether corresponding return packet data is received), and then send the test packet data for which each interface is successfully called to the simulation server, so that the simulation server may receive the test packet data for successfully calling each interface.
In one example, the application server may store the collected test packet data in a memory queue and then asynchronously send the test packet data of the successfully called interface to the simulation server via a Kafka (Kafka).
Step 202, determining the simulation message data corresponding to each interface information according to the test message data, and establishing the corresponding relation between the interface information and the simulation message data.
In implementation, the simulation server may determine the simulation message data corresponding to the interface information according to the test message data successfully calling each interface acquired in step 201. The interface information may include interface basic information and other key information, the interface basic information may include information such as an interface type, an interface name, a version to which the interface belongs, an application to which the interface belongs, and the like, the other key information may be information such as a customer information number, a mobile phone number, a name, a group number, an account number, and the like, and the related information may be obtained from the test message data. The simulation server may also obtain the simulation message data according to the return message data in the test message data, for example, the return message data may be directly used as the simulation message data, or the simulation message data may be obtained after performing other processing. One interface information may uniquely correspond to one piece of analog message data. Then, the simulation server can correspondingly store the interface information and the simulation message data, and can establish the corresponding relation between the interface information and the simulation message data.
Step 203, in response to the interface simulation request for the target interface sent by the application server, determining target simulation message data corresponding to the target interface information according to the target interface information included in the interface simulation request and the corresponding relationship between the interface information and the simulation message data.
In implementation, the application server continuously collects the test message data calling each interface in the test process, and determines the test message data (if the corresponding return message data is not received) with which the interface calling fails according to the test message data calling each interface, the interface with which the calling fails is the target interface, and the application server can further determine the interface information of the target interface according to the test message data with which the interface calling fails. The application server may then send an interface emulation request for the target interface to the emulation server, where the interface emulation request contains target interface information. The simulation server may respond to the interface simulation request, and match the target simulation packet data corresponding to the target interface information in the correspondence between the interface information and the simulation packet data established in step 202 according to the target interface information included in the interface simulation request. The target simulation message data is the interface simulation data of the target interface.
In an example, the process of determining the target interface by the application server may be to determine an interface with a failed call according to test message data for calling each interface, count the number of call failures of the interface, and determine the interface as the target interface when the number of call failures reaches a preset threshold. The application server can extract the target interface information according to the test message data (only including the uploading message data due to the calling failure) calling the target interface.
And 204, generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting an agent service corresponding to the target service based on the program information.
The target service is a service deployed in a real external system, and can be accessed by calling a target interface. The proxy service is a service module used for proxy of the target service in the simulation server and used for providing the same business function as the target service.
In implementation, the simulation server may generate program information corresponding to the target service according to the target simulation message data, the target interface information, and a preset simulation service generation rule, and start the proxy service corresponding to the target service based on the program information. The preset simulation service generation rule is a preset rule, for example, the preset simulation service generation rule may include a program code data format requirement, a program information template, a template content replacement rule, and the like, and the simulation server may determine the corresponding program code data format requirement and the program information template according to the target interface information (such as an interface type, an application to which the simulation server belongs, and the like), and generate the program information (i.e., the program code) corresponding to the target service meeting the requirement according to the target simulation message data, the target interface information, and the corresponding program information template and the template content replacement rule. The program information can be run through a container (Mock container) in the simulation server, and then the proxy service corresponding to the starting target service can be realized. The application server can send the access request aiming at the target service to the simulation server in the later testing process, and after receiving the access request, the simulation server can return target simulation message data to the application server so as to facilitate the test to be continued and avoid influencing the test progress.
In the interface simulation method, test message data of each interface successfully called by an application server in the test process of a target application system are obtained, simulation message data corresponding to each interface information is determined according to the test message data of each interface successfully called, a corresponding relation between the interface information and the simulation message data is further established, then, in response to an interface simulation request for the target interface sent by the application server, target simulation message data corresponding to the target interface information is determined according to the target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data, and the target simulation message data is the interface simulation data. And generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information. In the method, the interface simulation data can be automatically generated according to the test message data in the test process of the application system, the program information of the target service can be automatically generated according to the target interface information and the target simulation message data, the proxy service is automatically started based on the program information, and the automatic generation of the interface simulation data and the automatic configuration of the simulation interface are realized. Compared with manual collection of interface data and manual configuration of a simulation interface, the method can remarkably improve the efficiency of interface simulation. In addition, the method can automatically start the corresponding simulation interface according to the state of each interface in the test process (the unavailable interface is determined as the target interface), and can meet the requirements of randomness, flexibility and discontinuity of the simulation interface for fatigue test so as to take the test effect and the test progress into consideration.
In one embodiment, the interface information includes interface basic information and a report digest information, and the test message data includes report data and return message data corresponding to the report data. As shown in fig. 3, the process of determining the analog packet data corresponding to each interface information in step 202 specifically includes the following steps:
step 301, extracting interface basic information and upper-sent message abstract information from the upper-sent message data to obtain the interface information.
The returned message data refers to the message data returned by the external connection service according to the reported message data. The corresponding fields of the uploaded message data comprise interface basic information (such as interface type, interface name, affiliated version, affiliated application and the like) and other key information (such as customer information number, mobile phone number, name, group number, account number and the like).
In an implementation, the simulation server may determine the basic interface information according to the report message data, for example, the basic interface information and the other key information (which may be referred to as report digest information) may be extracted from the report message data by using a preset extraction policy. The basic information of the interface and the information of the abstract of the sent message form the information of the interface. One test message data corresponds to one interface information.
It can be understood that the corresponding field of the return message data may also contain the interface basic information, so the simulation server may also extract the interface basic information from the return message data. In addition, the target interface information included in the interface simulation request in step 203 may be extracted by the application server from the upload message data corresponding to the target interface by using the same extraction policy, so as to obtain the target interface information.
Step 302, classifying the test message data according to the interface information to obtain the return message data corresponding to each interface information.
In implementation, the simulation server may classify each test packet data according to interface information extracted from each test packet data, that is, the test packet data corresponding to the same interface information is classified into the same category, and then may perform deduplication on the test packet data in the same category and retain the return packet data in the test packet data, so that the return packet data corresponding to each interface information may be obtained.
Step 303, performing format processing on the returned message data corresponding to each interface information to obtain the simulated message data corresponding to each interface information.
In implementation, the simulation server may perform format processing on the return packet data corresponding to each interface information to obtain the simulation packet data corresponding to each interface information. For example, the simulation server may format a portion of the fields of the return message data to distinguish between the actual return message data and the interface simulation data.
In this embodiment, interface basic information and upper message digest information are extracted from upper message data to obtain interface information, format processing is further performed on return message data corresponding to each interface information to obtain analog message data corresponding to each interface information, and the analog message data can be used as interface analog data for standby.
In one embodiment, as shown in FIG. 4, after step 204, the method further comprises the steps of:
step 401, sending the start success information of the proxy service corresponding to the successful start target service to the application server.
The starting success information is used for indicating the application server to send an access request aiming at the target service to the simulation server.
In implementation, after the simulation server starts the proxy service corresponding to the target service based on the program information, if the start is successful, the simulation server may send start success information that the proxy service is successfully started to the application server. After receiving the start success information, the application server may send an access request for the target service to the simulation server in a subsequent testing process.
Step 402, in response to the access request for the target service sent by the application server, returning the target simulation message data to the application server.
In an implementation, the simulation server may return the target simulation message data to the application server in response to an access request for the target service sent by the application server. Wherein, the access request corresponds to the message data.
Optionally, the simulation server may also calculate a time difference between the sending time of the test message data, the sending time of the upload message data, and the sending time of the return message data, which correspond to each interface information, as the time consumption corresponding to the interface information. After receiving an access request aiming at the target service sent by the application server, the simulation server can determine the return time of returning the target simulation message data according to the consumed time corresponding to the target interface information, and return the target simulation message data to the application server at the return time. The time consumption can also be automatically executed by directly writing the program information of the proxy service. Therefore, the method can keep consistent with the return efficiency of the real service, and the test environment is close to the real environment as much as possible.
In this embodiment, after the proxy service is started, the simulation server may send start success information to the application server, so that the application server sends an access request for the target service to the simulation server, and further returns target simulation message data to the application server in a case where the access request is received, thereby realizing automatic start of the simulation interface for test use, and avoiding influence on test progress due to unavailability of the original interface.
In one embodiment, in case the type of the target interface is an HTTP interface, the launch success information further instructs the application server to execute the proxy command according to the launch success information.
Correspondingly, after sending the startup success information to the application server in step 401, the method further includes the following steps: monitoring the state of the target interface, releasing the proxy service when the target interface is in an available state, and sending a release instruction for releasing the proxy service to the application server under the condition that the type of the target interface is an HTTP interface, so that the application server cancels the execution of the proxy command according to the release instruction.
The HTTP interface is an interface based on a hypertext Transfer Protocol (HTTP Protocol), and is an agreement for interaction between systems.
In implementation, if the type of the target interface is the HTTP interface, after the application server receives the start success information sent by the simulation server, the application server may execute the proxy command, so as to forward the access request to be sent to the target service to the proxy service in the subsequent test process. Accordingly, the simulation server may monitor the status of the target interface after sending the start success information. In particular, the simulation server may directly access the source address of the request (i.e., the address to access the target service). If the source address can be accessed normally, namely the target interface is recovered to be in an available state, the simulation server can remove the proxy service, namely stop running the program information in the Mock container, and send a removal instruction for removing the proxy service to the application server. After receiving the release instruction, the application server can cancel the execution of the agent command and restore the test environment.
In this embodiment, the simulation server may monitor the state of the target interface after sending the start success information, and if the type of the target interface is the HTTP interface, when it is monitored that the target interface is in an available state, send a release instruction for releasing the proxy service to the application server, so that the application server cancels execution of the proxy command according to the release instruction, thereby automatically canceling the proxy service according to the state of the interface, meeting the requirements of the fatigue test on randomness, flexibility, and discontinuity of the simulation interface, and taking into account the test effect and the test progress.
In one embodiment, after the proxy service is initiated in step 204, the method further comprises the steps of: and under the condition that the type of the target interface is a distributed service interface, sending a registration request to a registration center of the distributed service, wherein the registration request is used for registering the simulation server as a providing end of the target service.
The distributed service interface refers to an interface provided based on a distributed service framework, and may be, for example, a Dubbo service interface. The Dubbo service interface is an interface provided based on a Dubbo distributed service framework, and uses a provider (provider) mode and a consumer (consumer) mode to perform service, and a consumer end (consumer) does not need to pay attention to how the provider end (provider) is realized, and can request service from a corresponding server only by subscribing in a registration center.
In implementation, if the type of the target interface is a distributed service interface, after the simulation server successfully starts the proxy service, a registration request may be sent to a registry of the distributed service, so as to register the simulation server as a provider of the target service. And when the proxy service provider is successfully registered, disabling other providers of the target service. Therefore, when the application server sends an access request aiming at the target service to the distributed service, the distributed service takes the scheduling simulation server as a service providing end, and the simulation server returns target simulation message data to the application server.
In this embodiment, the type of the target interface may be a distributed service interface, and the simulation server may send a registration request to a registration center of the distributed service, so as to register the simulation server as a provider of the target service, thereby implementing automatic start of the proxy service.
In one embodiment, after the simulation server sends the registration request to the registry of the distributed service, the method further comprises the steps of: and monitoring the state of the target interface, and sending a registration cancellation request to a registration center of the distributed service when the target interface is in an available state, wherein the registration cancellation request is used for canceling the simulation server from serving the target service.
In an implementation, the simulation server may monitor the status of the target interface after registering as a provider of the target service. If the type of the target interface is a distributed service interface, the simulation server can access other forbidden target service providing terminals (namely the real target service providing terminals in the real environment) one by one, and if the other target service providing terminals are recovered, a registration cancellation request is sent to a registration center of the distributed service so as to cancel the simulation server as the target service providing terminal and restart the other target service providing terminals. Alternatively, the simulation server may send a cancellation notification to the application server after canceling the proxy service.
In this embodiment, the simulation server may monitor the state of the target interface, send a registration cancellation request to the registration center of the distributed service when the target interface is available, cancel the provision of the target service by the simulation server, and recover the true provision of the target service, thereby achieving automatic cancellation of the proxy service, satisfying the requirements of the fatigue test on randomness, flexibility, and discontinuity of the simulation interface, and considering the test effect and the test progress.
In a specific example, as shown in fig. 5, an example of an interface simulation method is provided, which includes the following steps:
step 501, an application server collects test message data of each interface called by a target application system in a test process.
Specifically, the application server may determine whether the interface is successfully called according to the test packet data, and determine the test packet data that the interface is successfully called and the test packet data that the interface is unsuccessfully called.
Step 502, the application server sends the test message data with successfully called interface to the simulation server.
Step 503, the simulation server determines interface information corresponding to each test message data according to the test message data successfully called by the interface, classifies, deduplicates and formats the test message data according to the interface information to obtain simulation message data corresponding to each interface information, and establishes a corresponding relationship between the interface information and the simulation message data.
The interface information comprises interface basic information and uploading message abstract information.
Step 504, the application server determines the test message data of the interface calling failure according to the test message data of each calling interface, counts the calling failure times of each interface, and determines the interface with the calling failure times reaching a preset threshold value as a target interface.
Step 505, the application server sends an interface simulation request for the target interface to the simulation server.
Wherein the interface emulation request includes target interface information. Specifically, the application server may extract the interface basic information and the upload message digest information according to the test message data (specifically, the upload message data) when the calling of the target interface fails, and use the interface basic information and the upload message digest information as the target interface information.
Step 506, the simulation server determines target simulation message data corresponding to the target interface information according to the target interface information included in the interface simulation request and the corresponding relationship between the interface information and the simulation message data.
And 507, generating program information corresponding to the target service by the simulation server according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information.
Step 508, the simulation server sends the information of successful start of the start agent service to the application server.
It is understood that if the start fails, start failure information may be sent to enable the application server to record a failure log.
In step 509, after receiving the start success information, the application server executes a corresponding operation according to the type of the target interface.
Specifically, if the type of the target interface is the HTTP interface, the application server may execute the proxy instruction, and send an access request for calling the target service to the simulation server.
If the type of the target interface is a distributed service interface such as Dubbo, the application server does not need to execute other operations, and correspondingly, the simulation server sends a registration request to the distributed service through the registration center of the distributed service, wherein the registration request is used for registering the simulation server as a provider of the target service and forbidding other providers of the target service.
Step 510, the simulation server monitors the state of the target interface, and sends a release instruction for releasing the proxy service to the application server when the target interface is in an available state.
And 511, after receiving the release instruction, the application server executes corresponding operation according to the type of the target interface.
Specifically, if the type of the target interface is the HTTP interface, the application server may cancel executing the proxy instruction, and restore the environment, that is, send an access request for calling the target service to the original target service.
If the type of the target interface is a distributed service interface such as Dubbo, the application server does not need to execute other operations, and correspondingly, the simulation server sends a registration cancellation request to the distributed service through the registration center of the distributed service, wherein the registration cancellation request is used for canceling the registration of the simulation server as a providing end of the target service and starting other providing ends of the target service.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the embodiments described above may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution order of the steps or stages is not necessarily sequential, but may be rotated or alternated with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the present application further provides an interface simulation system for implementing the above-mentioned interface simulation method. The implementation scheme for solving the problem provided by the system is similar to the implementation scheme described in the above method, so that specific limitations in one or more embodiments of the interface simulation system provided below may refer to limitations of the above interface simulation method, and details are not described herein.
In one embodiment, there is provided an interface simulation system comprising a simulation server and an application server of a target application system, wherein:
the simulation server is used for acquiring test message data of each interface successfully called by the application server in the test process of the target application system; the test message data comprises interface information; and determining the simulation message data corresponding to each interface information according to the test message data, and establishing the corresponding relation between the interface information and the simulation message data.
And the application server is used for sending an interface simulation request aiming at the target interface to the simulation server.
The simulation server is also used for determining target simulation message data corresponding to the target interface information according to the target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data; and generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting an agent service corresponding to the target service based on the program information.
In one embodiment, the application server is further configured to collect test packet data of each interface called by the target application system in the test process, and send the test packet data of each interface successfully called to the simulation server.
In one embodiment, the application server is further configured to determine test message data with failed interface invocation according to the test message data with the failed interface invocation, count the number of times of invocation failure of each interface according to the test message data with the failed interface invocation, and determine the interface with the number of times of invocation failure reaching a preset threshold as the target interface.
Based on the same inventive concept, the embodiment of the present application further provides an interface simulation apparatus for implementing the above-mentioned interface simulation method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so specific limitations in one or more embodiments of the interface simulation device provided below can refer to the limitations on the interface simulation method in the above, and details are not described here.
In one embodiment, as shown in FIG. 6, there is provided an interface simulation apparatus 600 comprising: an obtaining module 601, an establishing module 602, a determining module 603, and a starting module 604, wherein:
an obtaining module 601, configured to obtain test packet data of each interface successfully called by an application server in a test process of a target application system; the test message data contains interface information.
The establishing module 602 is configured to determine, according to the test message data, analog message data corresponding to each interface information, and establish a corresponding relationship between the interface information and the analog message data.
The determining module 603 is configured to, in response to an interface simulation request for a target interface sent by an application server, determine target simulation packet data corresponding to target interface information according to target interface information included in the interface simulation request and a correspondence between the interface information and the simulation packet data.
The starting module 604 is configured to generate program information corresponding to the target service according to the target simulation message data, the target interface information, and a preset simulation service generation rule, and start an agent service corresponding to the target service based on the program information.
In one embodiment, the interface information comprises interface basic information and uploading message abstract information; the test message data comprises the uploading message data and the return message data corresponding to the uploading message data.
Correspondingly, the establishing module 602 is specifically configured to extract interface basic information and the submitted message abstract information from the submitted message data to obtain interface information; classifying the test message data according to the interface information to obtain return message data corresponding to the interface information; and carrying out format processing on the returned message data corresponding to each interface information to obtain the simulated message data corresponding to each interface information.
In one embodiment, the apparatus further comprises a first sending module and a returning module, wherein:
the first sending module is used for sending successful starting information of the proxy service corresponding to the successfully started target service to the application server, and the successful starting information is used for indicating the application server to send an access request aiming at the target service to the simulation server.
And the return module is used for responding to an access request aiming at the target service sent by the application server and returning the target simulation message data to the application server.
In one embodiment, in the case that the type of the target interface is an HTTP interface, the start success information is further used to instruct the application server to execute the proxy command according to the start success information.
Correspondingly, the device also comprises a second sending module, which is used for monitoring the state of the target interface, releasing the proxy service when the target interface is in an available state, and sending a release instruction for releasing the proxy service to the application server under the condition that the type of the target interface is the HTTP interface, so that the application server can cancel the execution of the proxy command according to the release instruction.
In one embodiment, the apparatus further includes a third sending module, configured to send a registration request to a registry of the distributed service, where the type of the target interface is a distributed service interface, and the registration request is used to register the simulation server as a provider of the target service.
In one embodiment, the apparatus further includes a fourth sending module, configured to monitor a state of the target interface, and send a deregistration request to a registry of the distributed service when the target interface is in an available state, where the deregistration request is used to deregister a provider that simulates the server as the target service.
The modules in the interface simulation device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The database of the computer device is used for storing data required or generated for executing the interface simulation method. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an interface emulation method.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the above-described method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, carries out the steps in the method embodiments described above.
The application provides an interface simulation method, an interface simulation device, an interface simulation system, computer equipment, a computer readable storage medium and a computer program product, relates to the technical field of computers, can be used in the field of financial science and technology or other related fields, and is not limited to the application field.
It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high-density embedded nonvolatile Memory, resistive Random Access Memory (ReRAM), magnetic Random Access Memory (MRAM), ferroelectric Random Access Memory (FRAM), phase Change Memory (PCM), graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), for example. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing based data processing logic devices, etc., without limitation.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims (11)

1. An interface simulation method, applied to a simulation server in an interface simulation system, the interface simulation system further including an application server of a target application system, the method comprising:
acquiring test message data of each interface successfully called by the application server in the test process of the target application system; the test message data comprises interface information;
determining simulation message data corresponding to the interface information according to the test message data, and establishing a corresponding relation between the interface information and the simulation message data;
responding to an interface simulation request aiming at a target interface sent by the application server, and determining target simulation message data corresponding to the target interface information according to target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data;
and generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information.
2. The method of claim 1, wherein the interface information comprises interface basic information and upper message digest information; the test message data comprises uploading message data and return message data corresponding to the uploading message data;
the determining the simulation message data corresponding to each interface information according to the test message data includes:
extracting interface basic information and submitted message abstract information from the submitted message data to obtain the interface information;
classifying the test message data according to the interface information to obtain return message data corresponding to the interface information;
and performing format processing on the returned message data corresponding to each interface information to obtain the simulated message data corresponding to each interface information.
3. The method of claim 1, wherein after the starting of the proxy service corresponding to the target service based on the program information, the method further comprises:
sending, to the application server, start success information for successfully starting the proxy service corresponding to the target service, where the start success information is used to instruct the application server to send an access request for the target service to the simulation server;
and responding to an access request aiming at the target service sent by the application server, and returning the target simulation message data to the application server.
4. The method according to claim 3, wherein in the case that the type of the target interface is an HTTP interface, the start success information is further used for instructing the application server to execute a proxy command according to the start success information;
after the sending the start success information of the agent service corresponding to the target service successfully started to the application server, the method further includes:
monitoring the state of the target interface, when the target interface is in an available state, releasing the proxy service, and sending a release instruction for releasing the proxy service to the application server under the condition that the type of the target interface is an HTTP interface, so that the application server cancels the execution of the proxy command according to the release instruction.
5. The method of claim 3, wherein after the initiating the proxy service corresponding to the target service based on the program information, further comprising:
and sending a registration request to a registration center of the distributed service under the condition that the type of the target interface is the distributed service interface, wherein the registration request is used for registering the simulation server as a provider of the target service.
6. The method of claim 5, wherein after sending the registration request to the registry of distributed services, further comprising:
and monitoring the state of the target interface, and sending a deregistration request to a registry of the distributed service when the target interface is in an available state, wherein the deregistration request is used for cancelling the simulation server as a providing end of the target service.
7. An interface simulation system, comprising a simulation server and an application server of a target application system, wherein:
the simulation server is used for acquiring test message data of each interface successfully called by the application server in the test process of the target application system; the test message data comprises interface information; determining simulation message data corresponding to the interface information according to the test message data, and establishing a corresponding relation between the interface information and the simulation message data;
the application server is used for sending an interface simulation request aiming at a target interface to the simulation server;
the simulation server is further used for determining target simulation message data corresponding to the target interface information according to the target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data; and generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information.
8. An interface emulation device, comprising:
the acquisition module is used for acquiring test message data of each interface successfully called by the application server in the test process of the target application system; the test message data comprises interface information;
the establishing module is used for determining the simulation message data corresponding to the interface information according to the test message data and establishing the corresponding relation between the interface information and the simulation message data;
the determining module is used for responding to an interface simulation request aiming at a target interface sent by the application server, and determining target simulation message data corresponding to the target interface information according to target interface information contained in the interface simulation request and the corresponding relation between the interface information and the simulation message data;
and the starting module is used for generating program information corresponding to the target service according to the target simulation message data, the target interface information and a preset simulation service generation rule, and starting the proxy service corresponding to the target service based on the program information.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
11. A computer program product comprising a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 6 when executed by a processor.
CN202210782518.XA 2022-07-05 2022-07-05 Interface simulation method, device, system, computer equipment and storage medium Pending CN115168203A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210782518.XA CN115168203A (en) 2022-07-05 2022-07-05 Interface simulation method, device, system, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210782518.XA CN115168203A (en) 2022-07-05 2022-07-05 Interface simulation method, device, system, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115168203A true CN115168203A (en) 2022-10-11

Family

ID=83491945

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210782518.XA Pending CN115168203A (en) 2022-07-05 2022-07-05 Interface simulation method, device, system, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115168203A (en)

Similar Documents

Publication Publication Date Title
CN109901949B (en) Application disaster recovery system and method for double-activity data center
CN112073269B (en) Block chain network testing method, device, server and storage medium
US9367379B1 (en) Automated self-healing computer system
CN111245900B (en) Distributed message sending processing system and processing method thereof
CN102833281B (en) It is a kind of distributed from the implementation method counted up, apparatus and system
US11567756B2 (en) Causality determination of upgrade regressions via comparisons of telemetry data
CN110647460B (en) Test resource management method and device and test client
CN113672350B (en) Application processing method and device and related equipment
CN113656149A (en) Application processing method and device and related equipment
CN112162925A (en) Test method and system based on service virtualization
CN111628903B (en) Monitoring method and monitoring system for transaction system running state
CN112527564A (en) Database data recovery drilling method and device and storage medium
CN114895879B (en) Management system design scheme determining method, device, equipment and storage medium
CN111324583B (en) Service log classification method and device
CN115168203A (en) Interface simulation method, device, system, computer equipment and storage medium
CN113902415A (en) Financial data checking method and device, computer equipment and storage medium
CN113905105B (en) Method and device for establishing application dependency relationship
CN112882893A (en) Method for real-time monitoring application service log generated by mobile terminal
CN116361369A (en) Data extraction and loading method and system
CN117394975A (en) E-Token loss report supplementing method and device, computer equipment and storage medium
CN116401132A (en) Log checking method, device, equipment and storage medium
CN114625626A (en) Project management data statistical method and device
CN116302652A (en) System alarm information processing method and device and electronic equipment
CN117931735A (en) File processing system, method, device and equipment
CN115426248A (en) Service management method, device, equipment and storage medium

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