CN115964243A - Interface simulation method, device, electronic equipment and storage medium - Google Patents

Interface simulation method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115964243A
CN115964243A CN202211711219.3A CN202211711219A CN115964243A CN 115964243 A CN115964243 A CN 115964243A CN 202211711219 A CN202211711219 A CN 202211711219A CN 115964243 A CN115964243 A CN 115964243A
Authority
CN
China
Prior art keywords
request
interface
response data
data
mode
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
CN202211711219.3A
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.)
Jiangsu Weisheng Network Technology Co ltd
Original Assignee
Jiangsu Weisheng Network 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 Jiangsu Weisheng Network Technology Co ltd filed Critical Jiangsu Weisheng Network Technology Co ltd
Priority to CN202211711219.3A priority Critical patent/CN115964243A/en
Publication of CN115964243A publication Critical patent/CN115964243A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses an interface simulation method, an interface simulation device, electronic equipment and a storage medium. The method comprises the following steps: receiving a user request, wherein the user request comprises a request address, a request parameter and a request mode; under the condition that the user request is a standard request, matching the request address with the request mode in a memory to obtain a first data model, and generating interface response data based on the first data model; and under the condition that the user request is a non-standard request, splicing the request address and the request parameters to obtain a splicing request, matching in a memory based on the splicing request and the request mode to obtain a second data model, and generating interface response data based on the second data model. According to the technical scheme, the interface response data can be generated under various conditions, and the flexibility of generating the interface response data is improved.

Description

Interface simulation method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to an interface simulation method and apparatus, an electronic device, and a storage medium.
Background
With the popularization and diversified application of the micro-service technology, the number of user groups faced by service providers providing data services is increasing, and the iteration speed of products is also increasing.
In the product testing stage, multifunctional and multidimensional testing and simulation of functional data (Mock) are required to be carried out on the product.
In the process of implementing the invention, the inventor finds that at least the following technical problems exist in the prior art: the problem of low flexibility exists in the existing interface simulation technical scheme.
Disclosure of Invention
The invention provides an interface simulation method, an interface simulation device, electronic equipment and a storage medium, which are used for generating interface response data under various conditions and improving the flexibility of data generation.
According to an aspect of the present invention, there is provided an interface simulation method, including:
receiving a user request, wherein the user request comprises a request address, a request parameter and a request mode;
under the condition that the user request is a standard request, matching the request address with the request mode in a memory to obtain a first data model, and generating interface response data based on the first data model;
and under the condition that the user request is a nonstandard request, splicing the request address and the request parameter to obtain a splicing request, matching in a memory based on the splicing request and the request mode to obtain a second data model, and generating interface response data based on the second data model.
According to another aspect of the present invention, there is provided an interface simulation apparatus including:
the request receiving module is used for receiving a user request, wherein the user request comprises a request address, request parameters and a request mode;
the standard request processing module is used for matching the request address with the request mode in a memory under the condition that the user request is a standard request to obtain a first data model, and generating interface response data based on the first data model;
and the nonstandard request processing module is used for splicing the request address and the request parameter to obtain a splicing request under the condition that the user request is a nonstandard request, matching in the memory based on the splicing request and the request mode to obtain a second data model, and generating interface response data based on the second data model.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor;
and a memory communicatively coupled to the at least one processor;
wherein the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the interface simulation method according to any of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement the interface simulation method according to any one of the embodiments of the present invention when the computer instructions are executed.
According to the technical scheme of the embodiment of the invention, under the condition that a user request is a standard request, a request address and a request mode are matched in a memory to obtain a first data model, and interface response data are generated based on the first data model; according to the technical scheme, the interface response data can be generated under the condition of various user requests, and the flexibility of interface response data generation is improved.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present invention, nor do they necessarily limit the scope of the invention. Other features of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic structural diagram of a distributed service interface simulation system according to the present invention;
fig. 2 is a schematic structural diagram of kubernets cluster deployment provided in the present invention;
FIG. 3 is a diagram illustrating data synchronization according to the present invention;
fig. 4 is a flowchart of an interface simulation method according to an embodiment of the present invention;
FIG. 5 is a flow chart of an interface emulation request according to an embodiment of the present invention;
FIG. 6 is a flow chart illustrating the generation of interface response data according to an embodiment of the present invention;
fig. 7 is a schematic diagram of an interface current limit according to an embodiment of the present invention;
FIG. 8 is a flowchart of an interface simulation method according to a second embodiment of the present invention;
FIG. 9 is a flowchart illustrating a multi-node data synchronization according to a second embodiment of the present invention;
fig. 10 is a flowchart illustrating a second gluc mode according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of an interface simulation apparatus provided in accordance with a third embodiment of the present invention;
fig. 12 is a schematic structural diagram of an electronic device implementing the interface simulation method according to the embodiment of the present invention.
Detailed Description
In order to make those skilled in the art better understand the technical solutions of the present invention, 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.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Before describing the specific embodiment, a distributed service interface simulation system for executing the interface simulation method is described, and fig. 1 is a schematic structural diagram of a distributed service interface simulation system according to the present invention. The distributed service interface simulation system can comprise service nodes, a Mock core module, a data verification module, a data layer and a running environment, wherein the service nodes can comprise Mock service nodes and Config service nodes, and the Mock service nodes can be used for generating interface response data; the Config service node may be used to visualize the presentation and interaction of the configuration page. The Mock core module can comprise an interface simulation unit, a response data simulation unit, an expansion integration unit, a multi-node data synchronization unit, an interface current limiting unit, a delay strategy unit and the like. The data verification module comprises a JSON analysis data model unit, a data model anti-repetition verification unit, an SPEL parameter analysis unit and the like. The data layer includes a Log and a Memory. The running environment may include linux or windows, JDK1.8, springBoot, and the like. The scheme can be deployed in a kubernets cluster, fig. 2 is a structural schematic diagram of kubernets cluster deployment provided by the invention, and fig. 3 is a schematic diagram of data synchronization provided by the invention.
Example one
Fig. 4 is a flowchart of an interface simulation method according to an embodiment of the present invention, where the method is applicable to a distributed data interface simulation situation, and the method may be executed by an interface simulation apparatus, where the interface simulation apparatus may be implemented in a form of hardware and/or software, and the interface simulation apparatus may be configured in a cloud server. As shown in fig. 4, the method includes:
s110, receiving a user request, wherein the user request comprises a request address, request parameters and a request mode.
For example, a Mock service node in the cloud server may receive a user request, where the user request may include a request address, a request parameter, a request manner, and the like. For example, the request address may be "/mock/cgi-bin/extra-nalcontact/group _ hat/GET", the request parameter may be "chat _ id", "need _ name", etc., and the request mode may be a GET request or a POST request, etc.
And S120, under the condition that the user request is a standard request, matching the request address with the request mode in a memory to obtain a first data model, and generating interface response data based on the first data model.
S130, under the condition that the user request is a non-standard request, the request address and the request parameter are spliced to obtain a splicing request, matching is carried out in a memory based on the splicing request and the request mode to obtain a second data model, and interface response data are generated based on the second data model.
Illustratively, fig. 5 is a flowchart of an interface emulation request provided in this embodiment. The standard request may be a standard RestFul request. The Mock service node receives a user request, if the user request is a standard RestFul request, a request address in the user request and a request mode are matched in a memory, and if the user request is matched with the standard RestFul request, interface response data are generated according to a response mode and a response type which are configured in a first data model in a simulation mode. And if the user request is not the standard RestFul request, splicing the request address and the request parameters to obtain a splicing request, further matching the splicing request and the request mode in a memory, and if the user request is matched with the second data model, simulating and generating interface response data according to a response mode and a response type configured in the second data model. If the match fails, an unconfigured data model exception may be responded to. If the request header of the user request received by the Mock service node contains multipart/form-data, responding to the file with the corresponding Type according to a preset rule, wherein the default Type of the file is a random response file. It should be noted that the first data model and the second data model may be the same data model or different data models, and are not limited herein.
In some optional embodiments, the method further comprises: if the generation mode of the response data is the SPEL expression, analyzing the request parameters to obtain interface response data; if the generation mode of the response data is a fixed value, determining the preset fixed value as the interface response data; if the generation mode of the response data is a regular expression, generating interface response data based on a pre-configured regular expression; and if the generation mode of the response data is not specified, generating the interface response data based on the response type.
Fig. 6 is a schematic flowchart of generating interface response data according to this embodiment. Analyzing json response data when the response parameters are configured, if the generation mode of the response data is an SPEL expression, analyzing the request parameters to obtain interface response data, and if the generation mode of the response data is a fixed value, determining the preset fixed value as the interface response data; if the generation mode of the response data is a regular expression, generating interface response data based on a pre-configured regular expression, and otherwise, returning corresponding configuration abnormal information; and if the generation mode of the response data is not specified, randomly generating interface response data based on the configured response type by default. The embodiment supports the SPEL expression and enriches the use scenes.
In some optional embodiments, the method further comprises: the simulation service node acquires a token from the configuration service node; and if the token quantity in the configuration service node meets the interface current limiting condition, starting an interface current limiting function.
In this embodiment, interface current limiting may be implemented by a token bucket algorithm, which can handle transient burst traffic and does not trigger current limiting frequently. Specifically, a corresponding number of tokens may be generated in the configuration service node to the memory according to the configured limited flow number. Considering the consistency of distributed current limiting data, the token number only exists in the configuration service node, when a user request reaches the simulation service node, the simulation service node can acquire the token from the configuration service node through a TCP long connection, if the token is taken, the request is continuously executed, and if the token number meets the interface current limiting condition, the interface current limiting function is started to refuse access. The interface current limit condition may be that the number of tokens is less than 0.
Fig. 7 is a schematic diagram of interface current limiting provided in this embodiment. Specifically, the first step is to judge whether the interface is limited, if so, the interface is directly returned, and if not, the second step is skipped; step two, judging whether a token bucket exists, if not, creating the token bucket and deducting the token to return, and if so, jumping to the step three; step three, judging whether tokens need to be put, if so, directly deducting the tokens, otherwise, delivering the tokens firstly and then deducting the tokens, and jumping to step four; and step four, judging whether the number of the tokens after deduction in the token bucket is less than 0, if so, starting an interface current limiting function, and if not, updating the number of the tokens in the token bucket to the memory.
According to the technical scheme of the embodiment of the invention, under the condition that the user request is a standard request, the request address and the request mode are matched in the memory to obtain a first data model, and interface response data are generated based on the first data model; according to the technical scheme, the interface response data can be generated under the condition of various user requests, and the flexibility of interface response data generation is improved.
Example two
Fig. 8 is a flowchart of an interface simulation method according to a second embodiment of the present invention, and the method according to this embodiment may be combined with each alternative in the interface simulation method provided in the foregoing embodiment. The interface simulation method provided by the embodiment is further optimized. Optionally, after receiving the user request, the method further includes: interface response data is returned based on the preconfigured delay time.
As shown in fig. 8, the method includes:
s210, receiving a user request, wherein the user request comprises a request address, request parameters and a request mode.
S220, under the condition that the user request is a standard request, matching the request address with the request mode in a memory to obtain a first data model, and generating interface response data based on the first data model.
S230, under the condition that the user request is a nonstandard request, the request address and the request parameter are spliced to obtain a splicing request, the splicing request is matched with the request mode in the memory to obtain a second data model, and interface response data are generated based on the second data model.
And S240, returning interface response data based on the preconfigured delay time.
In this embodiment, in order to simulate a real delay scenario of the third-party interface, a delay time is preconfigured to delay and return interface response data.
In some optional embodiments, the method further comprises: responding to the custom exception code to simulate the custom exception, wherein the custom exception comprises at least one of an IO exception, a parameter analysis exception, a service timeout exception and a system resource exhaustion exception.
Specifically, the embodiment may simulate the exception code (for example, 403, 404, 500, etc.), and may also simulate the network card network exception, where the network card network exception may include but is not limited to a normal network delay, a network jitter delay, a duplicate packet, a packet loss, a data packet disorder, and the like. In distributed service, in order to improve the interface simulation quality, the embodiment further supports a random exception policy, which specifically includes the following steps:
step one, writing a custom abnormal code in IDEA or WebGLUE; step two, the compiled custom exception code is edited in a GLUE mode; step three, responding to the user-defined abnormal code;
step four, selecting to turn on a random abnormal switch in the editing interface; and step five, circularly requesting to realize random response of abnormal information.
In some embodiments, the service interface can be exposed to the outside in a self-defined configuration mode, so that multi-language access use is supported, and the reuse rate of the system is improved.
In some optional embodiments, the method further comprises: carrying out heartbeat detection on the simulation service node in a long connection mode by configuring the service node; if the configuration data is received, the configuration data is synchronized to the simulation service node.
The configuration service node is a Config service node, and the simulation service node is a Mock service node.
For example, fig. 9 is a schematic flowchart of multi-node data synchronization provided in this embodiment. The Config service nodes can establish long connection with the Mock service nodes through Netty, and send configuration data to each Mock service node, so that the configuration data are stored in the memory of each Mock service node. The Mock service node may send heartbeats to the Config service node at preset time intervals, and perform data detection on the Config service node at preset time intervals to prevent data loss. It should be noted that, the configuration data is stored in the memory of the Mock service node, which can improve the data processing speed, so as to resist the situation of high concurrent flow rate during pressure measurement, and the Mock service node and the Config service node synchronize data based on the TCP long connection mode, which can reduce the network handshake overhead and improve the efficiency. In some embodiments, a Mock service node may be added for dynamic capacity expansion.
It should be noted that the Mock interface is not available during the data synchronization until the synchronization is finished. During data synchronization, the Mock service nodes are not synchronized due to abnormal fluctuation of the network, the Config service nodes can judge according to the number of the nodes successfully responding, and if the number of the nodes successfully responding is not consistent with the number of the nodes registered to the Config service nodes, resynchronization can be carried out according to configured interval time. In order to ensure the consistency of data, if the number of retries exceeding the set number is not synchronized successfully, the previously synchronized Mock interface data is removed, and abnormal information is responded so that the operation and maintenance can investigate the reason of the node abnormality.
In some optional embodiments, the method further comprises: acquiring an extended source code configured in a template; and calling a third-party interface based on the extended source code configured in the template, and analyzing the third-party interface to obtain a response analysis result.
Specifically, mock function extension can be realized through the following steps, specifically, in the first step, a GLUE template is selected, an extension source code is configured through the GLUE template, and a third-party interface is called based on the extension source code configured in the template; analyzing the third-party interface to obtain a response analysis result; step three, opening an interface testing tool and calling the configured interface; step four, after the test is successful, configuring a corresponding interface address in the service needing the Mock interface; and step five, executing a Mock flow.
Exemplarily, fig. 10 is a schematic flowchart of a GLUE mode provided in this embodiment. For the Config service node, after data entry is performed on a foreground, a resource code can be loaded through a GLUE mode, a data model can be customized locally through a LOCAL mode, and the data model can be stored in a memory. For the Mock service node, a data model can be matched in the memory, the self-defining configuration of the extended source code is carried out, the resource code can be executed through the GLUE mode, the data model can be locally defined through the LOCAL mode, and the data model can be stored in the memory.
In this embodiment, the parameter configuration may also be configured globally. By way of example, the global configuration may include, but is not limited to, a global Header information configuration, a global Param parameter configuration, a global Body configuration, a global Response configuration, an environment variable configuration, and the like. The priority of the configuration may be single, local and global in turn. The granularity of the configuration may in turn be a single interface, a single grouping, and an entire project.
EXAMPLE III
Fig. 11 is a schematic structural diagram of an interface simulation apparatus according to a third embodiment of the present invention. As shown in fig. 11, the apparatus includes:
a request receiving module 310, configured to receive a user request, where the user request includes a request address, a request parameter, and a request mode;
a standard request processing module 320, configured to, when the user request is a standard request, match the request address and the request manner in a memory to obtain a first data model, and generate interface response data based on the first data model;
the non-standard request processing module 330 is configured to, when the user request is a non-standard request, splice the request address and the request parameter to obtain a splicing request, match in the memory based on the splicing request and the request mode to obtain a second data model, and generate interface response data based on the second data model.
According to the technical scheme of the embodiment of the invention, under the condition that the user request is a standard request, the request address and the request mode are matched in the memory to obtain a first data model, and interface response data are generated based on the first data model; according to the technical scheme, the interface response data can be generated under the condition of various user requests, and the flexibility of interface response data generation is improved.
In some optional embodiments, the interface simulation apparatus further includes:
the SPEL expression processing module is used for analyzing the request parameter to obtain interface response data if the generation mode of the response data is the SPEL expression;
the fixed value processing module is used for determining a preset fixed value as the interface response data if the generation mode of the response data is the fixed value;
the regular expression processing module is used for generating interface response data based on a pre-configured regular expression if the generation mode of the response data is the regular expression;
and the unspecified processing module is used for generating the interface response data based on the response type if the generation mode of the response data is unspecified.
In some optional embodiments, the interface simulation apparatus further includes:
the token acquisition module is used for simulating the service node to acquire a token from the configuration service node;
and the interface current limiting module is used for starting an interface current limiting function if the number of the tokens in the configuration service node meets the interface current limiting condition.
In some optional embodiments, the interface simulation apparatus further comprises:
and the delay processing module is used for returning the interface response data based on the preconfigured delay time.
In some optional embodiments, the interface simulation apparatus further includes:
and the exception custom module is used for responding to custom exception codes to simulate custom exceptions, wherein the custom exceptions comprise at least one of IO exceptions, parameter analysis exceptions, service timeout exceptions and system resource exhaustion exceptions.
In some optional embodiments, the interface simulation apparatus further includes:
the data synchronization module is used for carrying out heartbeat detection on the simulation service node in a long connection mode through configuring the service node; and if the configuration data is received, synchronizing the configuration data to the simulation service node.
In some optional embodiments, the interface simulation apparatus further includes:
the extended source code acquisition module is used for acquiring extended source codes configured in the template;
and the interface analysis module is used for calling a third party interface based on the extended source code configured in the template and analyzing the third party interface to obtain a response analysis result.
The interface simulation device provided by the embodiment of the invention can execute the interface simulation method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
FIG. 12 illustrates a block diagram of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 12, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from a storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An I/O interface 15 is also connected to bus 14.
A number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
Processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. The processor 11 performs the various methods and processes described above, such as the interface emulation method, which includes:
receiving a user request, wherein the user request comprises a request address, a request parameter and a request mode;
under the condition that the user request is a standard request, matching the request address with the request mode in a memory to obtain a first data model, and generating interface response data based on the first data model;
and under the condition that the user request is a non-standard request, splicing the request address and the request parameters to obtain a splicing request, matching in a memory based on the splicing request and the request mode to obtain a second data model, and generating interface response data based on the second data model.
In some embodiments, the interface simulation method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the interface emulation method described above can be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the interface emulation method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
It should be understood that various forms of the flows shown above, reordering, adding or deleting steps, may be used. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired result of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for interface emulation, the method comprising:
receiving a user request, wherein the user request comprises a request address, a request parameter and a request mode;
under the condition that the user request is a standard request, matching the request address with the request mode in a memory to obtain a first data model, and generating interface response data based on the first data model;
and under the condition that the user request is a nonstandard request, splicing the request address and the request parameter to obtain a splicing request, matching in a memory based on the splicing request and the request mode to obtain a second data model, and generating interface response data based on the second data model.
2. The method of claim 1, further comprising:
if the generation mode of the response data is the SPEL expression, analyzing the request parameter to obtain interface response data;
if the generation mode of the response data is a fixed value, determining the preset fixed value as the interface response data;
if the generation mode of the response data is a regular expression, generating interface response data based on a pre-configured regular expression;
and if the generation mode of the response data is not specified, generating the interface response data based on the response type.
3. The method of claim 1, further comprising:
the simulation service node acquires a token from the configuration service node;
and if the number of the tokens in the configuration service node meets the interface current limiting condition, starting an interface current limiting function.
4. The method of claim 1, wherein after said receiving a user request, the method further comprises:
interface response data is returned based on the preconfigured delay time.
5. The method of claim 1, further comprising:
responding to the custom exception code to simulate a custom exception, wherein the custom exception comprises at least one of an IO exception, a parameter analysis exception, a service timeout exception and a system resource exhaustion exception.
6. The method of claim 1, further comprising:
carrying out heartbeat detection on the simulation service node in a long connection mode by configuring the service node; and if the configuration data is received, synchronizing the configuration data to the simulation service node.
7. The method of claim 1, further comprising:
acquiring an extended source code configured in a template;
and calling a third-party interface based on the extended source code configured in the template, and analyzing the third-party interface to obtain a response analysis result.
8. An interface emulation device, comprising:
the request receiving module is used for receiving a user request, wherein the user request comprises a request address, request parameters and a request mode;
the standard request processing module is used for matching the request address with the request mode in a memory under the condition that the user request is a standard request to obtain a first data model, and generating interface response data based on the first data model;
and the nonstandard request processing module is used for splicing the request address and the request parameter to obtain a splicing request under the condition that the user request is a nonstandard request, matching in the memory based on the splicing request and the request mode to obtain a second data model, and generating interface response data based on the second data model.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor;
and a memory communicatively coupled to the at least one processor;
wherein the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the interface simulation method of any one of claims 1-7.
10. A computer-readable storage medium storing computer instructions for causing a processor to perform the interface simulation method of any one of claims 1-7 when executed.
CN202211711219.3A 2022-12-29 2022-12-29 Interface simulation method, device, electronic equipment and storage medium Pending CN115964243A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211711219.3A CN115964243A (en) 2022-12-29 2022-12-29 Interface simulation method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211711219.3A CN115964243A (en) 2022-12-29 2022-12-29 Interface simulation method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115964243A true CN115964243A (en) 2023-04-14

Family

ID=87352472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211711219.3A Pending CN115964243A (en) 2022-12-29 2022-12-29 Interface simulation method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115964243A (en)

Similar Documents

Publication Publication Date Title
CN107733708B (en) Equipment parameter configuration method and device, computer equipment and storage medium
CN107800565B (en) Inspection method, inspection device, inspection system, computer equipment and storage medium
CN109245908B (en) Method and device for switching master cluster and slave cluster
CN114157701B (en) Task testing method, device, equipment and storage medium
CN112527397A (en) Method and device for modifying basic input output system options and computer equipment
CN113377665B (en) Container technology-based testing method and device, electronic equipment and storage medium
CN115373861B (en) GPU resource scheduling method and device, electronic equipment and storage medium
CN113806037A (en) Service calling method and device, storage medium and electronic equipment
CN109062820A (en) A kind of software performance testing method and device
CN114389969A (en) Client test method and device, electronic equipment and storage medium
CN114070889B (en) Configuration method, traffic forwarding device, storage medium, and program product
CN115599438A (en) Method, device, equipment and medium for constructing application program publishing package
CN114116487B (en) Pressure testing method and device, electronic equipment and storage medium
CN115964243A (en) Interface simulation method, device, electronic equipment and storage medium
CN115567431A (en) Network stability testing method and device, tested equipment and storage medium
CN112256500B (en) Storage system test server configuration method, system, terminal and storage medium
CN112994976A (en) Gateway testing method and device, electronic equipment and storage medium
CN113656268B (en) Performance test method and device for business service, electronic equipment and storage medium
CN115967638A (en) Equipment simulation system, method, equipment and storage medium
CN112131095A (en) Pressure testing method and device
CN115150310B (en) Request generation method, request processing device, electronic equipment and storage medium
CN116136813B (en) Method, device and storage medium for simulating adaptive multi-model avionics signals
CN115470193A (en) Radar data simulation method, device, equipment and medium
CN115665005A (en) Equipment test method, device, equipment and medium
CN116049311A (en) Data synchronization method and device, electronic 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