CN113434384B - Pressure testing method and device - Google Patents

Pressure testing method and device Download PDF

Info

Publication number
CN113434384B
CN113434384B CN202010208778.7A CN202010208778A CN113434384B CN 113434384 B CN113434384 B CN 113434384B CN 202010208778 A CN202010208778 A CN 202010208778A CN 113434384 B CN113434384 B CN 113434384B
Authority
CN
China
Prior art keywords
data
data request
interface
request
real response
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.)
Active
Application number
CN202010208778.7A
Other languages
Chinese (zh)
Other versions
CN113434384A (en
Inventor
王海龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202010208778.7A priority Critical patent/CN113434384B/en
Publication of CN113434384A publication Critical patent/CN113434384A/en
Application granted granted Critical
Publication of CN113434384B publication Critical patent/CN113434384B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/24Marginal checking or other specified testing methods not covered by G06F11/26, e.g. race tests
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Abstract

The invention discloses a pressure testing method and device, and relates to the technical field of Internet. One embodiment of the method comprises the following steps: copying one or more first data requests received by an interface to be tested in a production environment by using a first filter, and returning first real response data of the interface to be tested according to the first data requests in the production environment; correspondingly storing the first data request and the first real response data; and under a test environment, using a press to read the stored first data request, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result. According to the embodiment, the real data request in the environment can be directly copied and the pressure test can be performed, so that the accuracy and the effectiveness of the pressure test are improved.

Description

Pressure testing method and device
Technical Field
The invention relates to the technical field of Internet, in particular to a pressure testing method and device.
Background
With the development of internet technology, the number of interconnected users has increased to tens of millions or even hundreds of millions, so that in order to ensure good user experience, the internet system needs to operate continuously, and also needs to cope with the high concurrency situation that a large number of users access simultaneously. Therefore, in order to ensure the stability of the internet system, a stress test is required to be performed on the internet system. Because the internet system mostly adopts distributed deployment at present, each subsystem is frequently called through a remote call interface, and therefore the pressure test on the remote call interface becomes a key in the pressure test of the internet system.
At present, the methods for testing the remote call interface mainly comprise the following two methods: reading an online log or a history record by using a script language to simulate and construct an online user request, and then simulating a multi-user request based on a multi-thread mode to perform pressure test; some stress testing tools, such as JMeter, loadRunner, simulate an online user request to conduct stress testing.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art: when the testing tool such as a script language or a JMeter is used for testing, only real online user requests can be simulated, and the real online user requests cannot be directly used for pressure testing, so that the problems in the system cannot be effectively found; real internet systems often require thousands of machines to provide services simultaneously, and in the case of pressure testing, where multiple machines cannot be deployed as is the case, the online environment needs to be simulated, especially where the interface to be tested relies on one or more third party interfaces, the deployment of the online environment during pressure testing is particularly complex.
Disclosure of Invention
In view of the above, the embodiments of the present invention provide a pressure testing method and apparatus, which can directly replicate a real data request in an environment, perform a pressure test according to the real data request, and avoid the problem of needing to deploy a large number of third party interfaces on which interfaces to be tested depend.
To achieve the above object, according to a first aspect of an embodiment of the present invention, there is provided a pressure testing method, including:
copying one or more first data requests received by an interface to be tested in a production environment by using a first filter, and returning first real response data of the interface to be tested according to the first data requests in the production environment;
correspondingly storing the first data request and the first real response data;
and under a test environment, using a press to read the stored first data request, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result.
Optionally, the method further comprises:
Copying one or more second data requests sent to the third party interface in a production environment by using a second filter corresponding to the third party interface and second real response data corresponding to the second data requests returned from the third party interface under the condition that the interface to be tested needs to call one or more third party interfaces;
correspondingly storing the second data request and the second real response data;
and under a test environment, using a simulator simulating the third party interface to read the stored second data request and the second real response data, wherein the simulator returns the second real response data when receiving the second data request in the test environment.
Optionally, the method further comprises:
after copying to the first data request or the second data request, generating a data request identifier uniquely corresponding to the first data request or the second data request;
adding the data request identification to the first data request or the second data request so that the copied first real response data or the second real response data corresponding to the first data request or the second data request has the data request identification.
Optionally, the data identification request indicates a temporal order of the first data request or the second data request.
Optionally, the simulator returns the second real response data according to the stored real response time corresponding to the second data request.
Optionally, according to the data request identifier, the press reads and caches the first data request in batches, and sends the first data request to the interface to be tested through a producer/consumer mode.
Optionally, after the press sends the first data request to the interface to be tested according to the time sequence indicated by the data request identifier, the simulator reads and caches the second data request in batches, and second real response data corresponding to the second data request.
Optionally, the first data request, the first real response data or the second data request and the second real response data are sent to the WebSocket server by using a connection between the first filter and the WebSocket server or a connection between the second filter and the WebSocket server, so that the WebSocket server sends the first data request, the first real response data or the second data request and the second real response data to a storage engine through a message queue.
Optionally, the method further comprises:
and sending a data copying starting request or a data copying stopping request to the first filter through the connection between the WebSocket server and the first filter.
To achieve the above object, according to a second aspect of the embodiments of the present invention, there is provided a pressure testing apparatus including: the device comprises a data replication module, a data storage module and a pressure test module; wherein, the liquid crystal display device comprises a liquid crystal display device,
the data copying module is used for copying one or more first data requests received by the interface to be tested in a production environment by using a first filter, and first real response data returned by the interface to be tested in the production environment according to the first data requests;
the data storage module is used for correspondingly storing the first data request and the first real response data;
the pressure test module is used for reading the stored first data request by using a press machine under a test environment, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result.
Optionally, the data replication module is further configured to replicate, when the interface to be tested needs to call one or more third party interfaces, one or more second data requests sent to the third party interfaces in a production environment and second real response data corresponding to the second data requests returned from the third party interfaces by using a second filter corresponding to the third party interfaces;
the data storage module is further used for correspondingly storing the second data request and the second real response data;
the pressure test module is further configured to read the stored second data request and the second real response data using a simulator simulating the third party interface in a test environment, where the simulator returns the second real response data when receiving the second data request in the test environment.
Optionally, the data replication module is further configured to:
after copying to the first data request or the second data request, generating a data request identifier uniquely corresponding to the first data request or the second data request;
adding the data request identification to the first data request or the second data request so that the copied first real response data or the second real response data corresponding to the first data request or the second data request has the data request identification.
Optionally, the data identification request indicates a temporal order of the first data request or the second data request.
Optionally, the simulator returns the second real response data according to the stored real response time corresponding to the second data request.
Optionally, the pressure testing module is further used for
And according to the data request identification, the press machine reads and caches the first data request in batches, and sends the first data request to the interface to be tested through a producer/consumer mode.
Optionally, the pressure testing module is further used for
And according to the time sequence indicated by the data request identification, the first data request is sent to the interface to be tested in the press, and the simulator reads and caches the second data request and second real response data corresponding to the second data request in batches.
Optionally, the data storage module is used for
And sending the first data request, the first real response data or the second data request and the second real response data to the WebSocket server by using the connection between the first filter and the WebSocket server or the connection between the second filter and the WebSocket server, so that the WebSocket server sends the first data request, the first real response data or the second data request and the second real response data to a storage engine through a message queue.
Optionally, the data replication module is further configured to,
and sending a data copying starting request or a data copying stopping request to the first filter through the connection between the WebSocket server and the first filter.
To achieve the above object, according to a third aspect of the embodiments of the present invention, there is provided a pressure test electronic device including: one or more processors; and a storage means for storing one or more programs which, when executed by the one or more processors, implement any of the methods of pressure testing described above.
To achieve the above object, according to a fourth aspect of the embodiments of the present invention, there is provided a computer-readable medium having stored thereon a computer program which, when executed by a processor, implements the method of any one of the pressure test methods described above.
The invention has the following advantages or beneficial effects: because the first data request and the corresponding first real response data sent to the interface to be tested under the production environment are copied by adopting the first filter, the technical problem that the system has problems can not be truly and effectively found out by adopting the simulated online user request for pressure test in the prior art is solved, and the technical effects of improving the accuracy and the effectiveness of the pressure test are further achieved; in addition, the technical means of simulating one or more third party interfaces depending on the interface to be tested through the simulator model is adopted, so that the technical problem that a large number of third party interfaces need to be deployed in a test environment in the existing pressure test is avoided, the complexity of the pressure test is reduced, and the efficiency of the pressure test is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a pressure testing method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main structure of a data request replication system in a production environment according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main flow of a data request replication method in a production environment according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main structure of a pressure test system in a test environment according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the main flow of a pressure testing method in a testing environment according to an embodiment of the invention;
FIG. 6 is a schematic diagram of the main modules of a pressure testing apparatus according to an embodiment of the present invention;
FIG. 7 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 8 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of a pressure testing method according to an embodiment of the present invention, and as shown in fig. 1, the pressure testing method may specifically include the following steps:
step S101, copying one or more first data requests received by an interface to be tested in a production environment by using a first filter, and returning first real response data of the interface to be tested according to the first data requests in the production environment.
The filter refers to a section of program or a component of a server program, which can intercept data requests and responses of interfaces to be tested corresponding to the client and filter information of the data requests and responses. The production environment refers to an environment in which an actual user obtains services provided by an internet system through the internet, namely, a real environment, the first data request includes but is not limited to login, registration, access and the like sent by the user, the first real response data refers to a result obtained after the interface to be tested executes a program after receiving the first data request, and the first data request has a one-to-one correspondence with the first real response data.
Further, an interface to be tested (remote call interface, such as RPC interface) in an existing internet system often depends on one or more third party interfaces (i.e. other remote call interfaces), so that, in the case that the interface to be tested needs to call one or more third party interfaces, one or more second data requests sent to the third party interfaces in a production environment and second real response data returned from the third party interfaces corresponding to the second data requests are copied by using a second filter corresponding to the third party interfaces.
On the basis, in order to ensure the one-to-one correspondence between the first data request and the first real response data and the one-to-one correspondence between the second data request and the second real response data, generating a data request identifier uniquely corresponding to the first data request or the second data request after copying the first data request or the second data request; adding the data request identification to the first data request or the second data request so that the copied first real response data or the second real response data corresponding to the first data request or the second data request has the data request identification.
Still further, the data identification request indicates a temporal order of the first data request or the second data request. The data request identifiers are sequentially increased according to the time sequence, and the smaller the data corresponding to the data identifiers, the earlier the corresponding first data request or second data request is sent to the test interface or simulator when the pressure test is performed.
It can be appreciated that before the first filter is used to copy one or more first data requests received by the interface to be tested in the production environment and the first real response data returned by the interface to be tested according to the data requests in the production environment, the first filter, the interface to be tested and the second filter are deployed in the same Java process by using a Java hot deployment technology so as to reduce the influence of a network or other programs on the copying of the data requests. Java hot deployment refers to the behavior of class when updating the running class by automatically detecting the change of class file without restarting the Java virtual machine.
In addition, when the first filter or the second filter is used to copy the data request, either a single-threaded manner or a multi-threaded manner may be used. In this embodiment, the data request and the corresponding response result are considered to be copied in a single-thread mode, so that the influence of the execution performance of the filter on the interface to be tested or the third party interface itself can be reduced as much as possible, and the authenticity of the copied data request is striven for.
Step S102, storing the first data request and the first real response data correspondingly.
It may be appreciated that in the case where the interface to be tested depends on one or more third party interfaces, that is, in the case where the second data request and the second real response data are copied using the second filter corresponding to the third interface, the method further includes: correspondingly storing the second data request and the second real response data.
Specifically, the WebSocket connection corresponding to the first filter or the second filter is used for sending the first data request, the first real response data or the second data request and the second real response data to a WebSocket server, so that the WebSocket server sends the first data request, the first real response data or the second data request and the second real response data to a storage engine through a message queue. The WebSocket service refers to a full duplex communication protocol, and once a connection is established between a client and a server, all data communication is performed through the connection, and in the communication process, data in any format such as JSON, XML, HTML or pictures can be mutually sent. Notably, in order to ensure stability and persistence of WebSocket connection, the first filter or the second filter adopts a single-thread long connection mode to transmit data requests and real response results to the WebSocket server.
In addition, because the first filter is connected with the WebSocket server in a bidirectional manner, a data copying start request or a data copying stop request can be sent to the first filter through the connection between the WebSocket server and the first filter.
Step S103, under a test environment, using a press to read the stored first data request, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result.
Specifically, if the test response data is consistent with the first real response data, indicating that the pressure test is successful and recording the successful times of the pressure test; if the test response data is inconsistent with the first real response data, the test response data and the first real response data are recorded at the same time, so that the problem can be checked later. The simulator is used for simulating the generation of the third-party interface by using Java dynamic generation byte code technology according to a pre-configured JAR packet corresponding to the third-party interface before the stored first data request is read by using a press and sent to the interface to be tested to perform pressure test on the interface to be tested.
In addition, in the case that the interface to be tested depends on one or more third party interfaces, that is, in the case that the second data request and the second real response data are copied by using the second filter corresponding to the third interface, the method further includes, in the test environment: and using a simulator simulating the third party interface to read the stored second data request and the second real response data, wherein the simulator returns the second real response data when receiving the second data request in a test environment. Therefore, the simulator can replace one or more third party test interfaces on which the interfaces to be tested really need to depend, operation is not needed by the simulator according to the second data request to obtain a response result, and only the second real response data corresponding to the stored second data request is sent to the interfaces to be tested, so that a large number of third party interfaces are not needed to be deployed.
More specifically, in order to truly simulate the third party interface by using the simulator under the test environment, after the simulator reads the second real response result corresponding to the second data request, under the condition that the second data request sent by the interface to be tested is received, the simulator returns the corresponding second real response result to the interface to be tested according to the real response time corresponding to the second real response result of the third party interface under the production environment. That is, before returning the second real response result, the simulator determines whether the time consumed by the third party interface to execute the program according to the second data request has been reached, if so, the simulator returns the second real response data, if not, the simulator pauses the program, and after the consumed time is reached, the simulator returns the second real response data.
In an alternative embodiment, according to the data request identifier, the press reads and caches the first data request in batches, and sends the first data request to the interface to be tested through a producer/consumer mode. In this way, the speed of sending the first data request, that is, the speed of sending the pressure during the pressure test, can be controlled by controlling the number of threads of the press or the frequency of consuming the first data request by the interface to be tested. In addition, the interaction between the press and the storage engine for storing the first data request and the first real response data can be reduced by batch reading and caching of the first data request by the press.
On the basis, according to the time sequence indicated by the data request identification, after the press machine sends the first data request to the interface to be tested, the simulator reads and caches the second data request in batches and second real response data corresponding to the second data request. That is, the interaction between the press and the storage engine storing the second data request and the second real response data is reduced by the mode that the simulator reads and caches the first data request.
Based on the embodiment, the technical means that the first data request and the corresponding first real response data sent to the interface to be tested in the production environment are copied by adopting the first filter is adopted, so that the technical problem that the system has problems can not be truly and effectively found out by adopting the simulated online user request for pressure test in the prior art is overcome, and the technical effects of improving the accuracy and the effectiveness of the pressure test are further achieved; in addition, the technical means of simulating one or more third party interfaces depending on the interface to be tested through the simulator model is adopted, so that the technical problem that a large number of third party interfaces need to be deployed in a test environment in the existing pressure test is avoided, the complexity of the pressure test is reduced, and the efficiency of the pressure test is improved.
Referring to FIG. 2, on the basis of the above-described embodiments, an embodiment of the present invention provides a schematic diagram of the main structure of a data request replication system in a production environment; specifically, the data request replication system includes: the system comprises a first filter, an interface to be tested, one or more third party interfaces, one or more second filters corresponding to the third party interfaces, a WebSocket server, a message queue and a storage engine. The first filter is used for copying one or more first data requests received by the interface to be tested in a production environment, and the interface to be tested returns first real response data according to the data requests in the production environment, and the first data requests and the first real response data are sent to the WebSocket server through connection between the first filter and the WebSocket server; the second filter is used for copying one or more second data requests sent to the third party interface in the production environment and second real response data corresponding to the second data requests returned from the third party interface, and the second data requests and the second real response data are sent to the WebSocket server through connection between the second filter and the WebSocket server; the WebSocket server is used for sending the first data request, the first real response data or the second data request and the second real response data to a storage engine through a message queue; the storage engine is used for correspondingly storing the first data request, the first real response data or the second data request and the second real response data.
Referring to fig. 3, on the basis of the foregoing embodiment, the embodiment of the present invention provides a data request replication method in a production environment, where the method specifically may include the following steps:
in step S301, a first filter replicates one or more first data requests received by an interface to be tested in a production environment, and first real response data returned by the interface to be tested in the production environment according to the first data requests.
In order to ensure the one-to-one correspondence between the first data request and the first real response data request, generating a data request identifier uniquely corresponding to the first data request after copying the first data request, wherein the data request identifier is associated with time or is increased according to time sequence; the data request identification is added to the first data request, so that the copied first real response data corresponding to the first data request has the data request identification.
In step S302, the first filter sends the first data request and the first real response data to the WebSocket server through connection with the WebSocket server.
In addition, the first filter and the WebSocket server establish a bidirectional connection, so that a request for starting data replication or a request for stopping data replication can be sent to the first filter through the connection between the WebSocket server and the first filter.
In step S303, the second filter replicates one or more second data requests sent to the third party interface in the production environment, and second real response data corresponding to the second data table request returned from the third party interface.
In order to ensure the one-to-one correspondence between the second data request and the second real response data request, generating a data request identifier uniquely corresponding to the second data request after copying the second data request, wherein the data request identifier is associated with time or is increased according to time sequence; and adding the data request identifier to the second data request so that the copied second real response data corresponding to the second data request has the data request identifier.
And step S304, the second filter sends the second data request and the second real response data to the WebSocket server through connection with the WebSocket server.
In step S305, the WebSocket server sends the first data request, the first real response data, or the second data request, the second real response data to a storage engine through a message queue.
Referring to fig. 4, on the basis of the above embodiment, an embodiment of the present invention provides a pressure testing system in a testing environment, including: the device comprises a press, an interface to be tested, a simulator and a storage engine; the press is used for reading the stored first data request, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result; the simulator is used for reading the stored second data request and the second real response data, and returning the second real response data when the second data request is received.
Referring to fig. 5, on the basis of the above embodiment, the embodiment of the present invention provides a pressure testing method in a testing environment, where the method may specifically include the following steps:
in step S501, the press reads the stored first data request and sends the first data request to the interface to be tested.
Specifically, according to the data request identifier, the press reads and caches the first data request in batches, and sends the first data request to the interface to be tested through a producer/consumer mode. In this way, the speed of sending the first data request, that is, the speed of sending the pressure during the pressure test, can be controlled by controlling the number of threads of the press or the frequency of consuming the first data request by the interface to be tested. In addition, the interaction between the press and the storage engine for storing the first data request and the first real response data can be reduced by batch reading and caching of the first data request by the press.
Step S502, a simulator simulating the third party interface reads the stored second data request and the second real response data. And the simulator reads and caches the second data request in batches and second real response data corresponding to the second data request. That is, the interaction between the press and the storage engine storing the second data request and the second real response data is reduced by the mode that the simulator reads and caches the first data request.
In step S503, the simulator returns the second real response data when receiving the second data request in the test environment.
More specifically, in order to truly simulate the third party interface by using the simulator under the test environment, after the simulator reads the second real response result corresponding to the second data request, under the condition that the second data request sent by the interface to be tested is received, the simulator returns the corresponding second real response result to the interface to be tested according to the real response time corresponding to the second real response result of the third party interface under the production environment. That is, before returning the second real response result, the simulator determines whether the time consumed by the third party interface to execute the program according to the second data request has been reached, if so, the simulator returns the second real response data, if not, the simulator pauses the program, and after the consumed time is reached, the simulator returns the second real response data.
Step S504, the press receives the test response data returned by the interface to be tested according to the first data request, and compares the first real response data with the test response data to obtain a pressure test result.
Specifically, if the test response data is consistent with the first real response data, indicating that the pressure test is successful and recording the successful times of the pressure test; if the test response data is inconsistent with the first real response data, the test response data and the first real response data are recorded at the same time, so that the problem can be checked later.
Referring to fig. 6, on the basis of the above embodiment, an embodiment of the present invention provides a pressure testing apparatus 600, including: a data copying module 601, a data storage module 602, and a pressure testing module 603; wherein, the liquid crystal display device comprises a liquid crystal display device,
the data replication module 601 is configured to replicate, using a first filter, one or more first data requests received by an interface to be tested in a production environment, and first real response data returned by the interface to be tested in the production environment according to the first data requests;
the data storage module 602 is configured to correspondingly store the first data request and the first real response data;
The pressure testing module 603 is configured to read the stored first data request by using a press under a testing environment, send the first data request to the interface to be tested, receive test response data returned by the interface to be tested according to the first data request, and compare the first real response data with the test response data to obtain a pressure testing result.
In an alternative embodiment, the data replication module 601 is further configured to replicate, when the interface to be tested needs to call one or more third party interfaces, one or more second data requests sent to the third party interfaces in a production environment and second real response data corresponding to the second data requests returned from the third party interfaces, using a second filter corresponding to the third party interfaces;
the data storage module is further used for correspondingly storing the second data request and the second real response data;
the pressure test module is further configured to read the stored second data request and the second real response data using a simulator simulating the third party interface in a test environment, where the simulator returns the second real response data when receiving the second data request in the test environment.
In an alternative embodiment, the data replication module 601 is further configured to:
after copying to the first data request or the second data request, generating a data request identifier uniquely corresponding to the first data request or the second data request;
adding the data request identification to the first data request or the second data request so that the copied first real response data or the second real response data corresponding to the first data request or the second data request has the data request identification.
In an alternative embodiment, the data identification request indicates a temporal order of the first data request or the second data request.
In an alternative embodiment, the simulator returns the second real response data according to the stored real response time corresponding to the second data request.
In an alternative embodiment, the pressure testing module 603 is further configured to
And according to the data request identification, the press machine reads and caches the first data request in batches, and sends the first data request to the interface to be tested through a producer/consumer mode.
In an alternative embodiment, the pressure testing module 603 is further configured to
And according to the time sequence indicated by the data request identification, the first data request is sent to the interface to be tested in the press, and the simulator reads and caches the second data request and second real response data corresponding to the second data request in batches.
In an alternative embodiment, the data storage module 602 is configured to
And sending the first data request, the first real response data or the second data request and the second real response data to the WebSocket server by using the connection between the first filter and the WebSocket server or the connection between the second filter and the WebSocket server, so that the WebSocket server sends the first data request, the first real response data or the second data request and the second real response data to a storage engine through a message queue.
In an alternative embodiment, the data replication module 601 is further configured to,
and sending a data copying starting request or a data copying stopping request to the first filter through the connection between the WebSocket server and the first filter.
Fig. 7 illustrates an exemplary system architecture 700 to which the pressure testing method or pressure testing apparatus of embodiments of the present invention may be applied.
As shown in fig. 7, a system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 is the medium used to provide communication links between the terminal devices 701, 702, 703 and the server 705. The network 704 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 705 via the network 704 using the terminal devices 701, 702, 703 to receive or send messages or the like. Various communication client applications, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc., may be installed on the terminal devices 701, 702, 703.
The terminal devices 701, 702, 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 705 may be a server providing various services, such as a background management server providing support for shopping-type websites browsed by the user using the terminal devices 701, 702, 703. The background management server can analyze and other data of the received product information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that, the pressure testing method provided in the embodiment of the present invention is generally executed by the server 705, and accordingly, the pressure testing device is generally disposed in the server 705.
It should be understood that the number of terminal devices, networks and servers in fig. 7 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 8, there is illustrated a schematic diagram of a computer system 800 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 8 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 8, the computer system 800 includes a Central Processing Unit (CPU) 801 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, mouse, etc.; an output portion 807 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage section 808 including a hard disk or the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. The drive 810 is also connected to the I/O interface 805 as needed. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as needed so that a computer program read out therefrom is mounted into the storage section 808 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication section 809, and/or installed from the removable media 811. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 801.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor comprises a data copying module, a data storage module and a pressure testing module. The names of these modules do not in any way constitute a limitation of the module itself, for example, a data storage module may also be described as "a module for storing the first data request, the first real response data, correspondingly".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: copying one or more first data requests received by an interface to be tested in a production environment by using a first filter, and returning first real response data of the interface to be tested according to the data requests in the production environment; correspondingly storing the first data request and the first real response data; and under a test environment, using a press to read the stored first data request, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result.
According to the technical scheme provided by the embodiment of the invention, the technical means that the first data request and the corresponding first real response data sent to the interface to be tested in the production environment are copied by adopting the first filter is adopted, so that the technical problem that the system has problems can not be truly and effectively found out by adopting the simulated online user request for pressure test in the prior art is solved, and the technical effects of improving the accuracy and the effectiveness of the pressure test are further achieved; in addition, the technical means of simulating one or more third party interfaces depending on the interface to be tested through the simulator model is adopted, so that the technical problem that a large number of third party interfaces need to be deployed in a test environment in the existing pressure test is avoided, the complexity of the pressure test is reduced, and the efficiency of the pressure test is improved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (11)

1. A method of pressure testing, comprising:
copying one or more first data requests received by an interface to be tested in a production environment by using a first filter, and returning first real response data of the interface to be tested according to the first data requests in the production environment;
correspondingly storing the first data request and the first real response data;
under a test environment, using a press to read the stored first data request, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result;
Copying one or more second data requests sent to the third party interface in a production environment by using a second filter corresponding to the third party interface and second real response data corresponding to the second data requests returned from the third party interface under the condition that the interface to be tested needs to call one or more third party interfaces;
correspondingly storing the second data request and the second real response data;
and under a test environment, using a simulator simulating the third party interface to read the stored second data request and the second real response data, wherein the simulator returns the second real response data when receiving the second data request in the test environment.
2. The pressure testing method of claim 1, further comprising:
after copying to the first data request or the second data request, generating a data request identifier uniquely corresponding to the first data request or the second data request;
adding the data request identification to the first data request or the second data request so that the copied first real response data or the second real response data corresponding to the first data request or the second data request has the data request identification.
3. The method of pressure testing according to claim 2, wherein,
the data identification request indicates a temporal order of the first data request or the second data request.
4. The method of pressure testing according to claim 1, wherein,
and the simulator returns the second real response data according to the stored real response time corresponding to the second data request.
5. A pressure testing method according to claim 3, wherein,
and according to the data request identification, the press machine reads and caches the first data request in batches, and sends the first data request to the interface to be tested through a producer/consumer mode.
6. A pressure testing method according to claim 3, wherein,
and according to the time sequence indicated by the data request identification, after the press machine sends the first data request to the interface to be tested, the simulator reads and caches the second data request in batches and second real response data corresponding to the second data request.
7. The method of pressure testing according to claim 1, wherein,
And sending the first data request, the first real response data or the second data request and the second real response data to the WebSocket server by using the connection between the first filter and the WebSocket server or the connection between the second filter and the WebSocket server, so that the WebSocket server sends the first data request, the first real response data or the second data request and the second real response data to a storage engine through a message queue.
8. The pressure testing method of claim 7, further comprising:
and sending a data copying starting request or a data copying stopping request to the first filter through the connection between the WebSocket server and the first filter.
9. A pressure testing device, comprising: the device comprises a data replication module, a data storage module and a pressure test module; wherein, the liquid crystal display device comprises a liquid crystal display device,
the data copying module is used for copying one or more first data requests received by the interface to be tested in a production environment by using a first filter, and first real response data returned by the interface to be tested in the production environment according to the first data requests;
The data storage module is used for correspondingly storing the first data request and the first real response data;
the pressure test module is used for reading the stored first data request by using a press machine under a test environment, sending the first data request to the interface to be tested, receiving test response data returned by the interface to be tested according to the first data request, and comparing the first real response data with the test response data to obtain a pressure test result;
the interface to be tested is further used for copying one or more second data requests sent to the third party interface in a production environment by using a second filter corresponding to the third party interface and second real response data corresponding to the second data requests returned from the third party interface under the condition that the interface to be tested needs to call one or more third party interfaces; correspondingly storing the second data request and the second real response data; and under a test environment, using a simulator simulating the third party interface to read the stored second data request and the second real response data, wherein the simulator returns the second real response data when receiving the second data request in the test environment.
10. A pressure test electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
the one or more processors implement the method of any of claims 1-8 when the one or more programs are executed by the one or more processors.
11. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-8.
CN202010208778.7A 2020-03-23 2020-03-23 Pressure testing method and device Active CN113434384B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010208778.7A CN113434384B (en) 2020-03-23 2020-03-23 Pressure testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010208778.7A CN113434384B (en) 2020-03-23 2020-03-23 Pressure testing method and device

Publications (2)

Publication Number Publication Date
CN113434384A CN113434384A (en) 2021-09-24
CN113434384B true CN113434384B (en) 2023-09-22

Family

ID=77752599

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010208778.7A Active CN113434384B (en) 2020-03-23 2020-03-23 Pressure testing method and device

Country Status (1)

Country Link
CN (1) CN113434384B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116107913B (en) * 2023-04-06 2023-11-14 阿里云计算有限公司 Test control method, device and system of single-node server

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8325880B1 (en) * 2010-07-20 2012-12-04 Convergys Customer Management Delaware Llc Automated application testing
CN109165168A (en) * 2018-09-14 2019-01-08 杭州云创共享网络科技有限公司 A kind of method for testing pressure, device, equipment and medium
CN109271325A (en) * 2018-10-26 2019-01-25 携程旅游网络技术(上海)有限公司 Test method, system, electronic equipment and the storage medium of application
CN109446071A (en) * 2018-09-26 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, interface test device, electronic equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10592402B2 (en) * 2017-11-20 2020-03-17 International Business Machines Corporation Automated integration testing with mock microservices

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8325880B1 (en) * 2010-07-20 2012-12-04 Convergys Customer Management Delaware Llc Automated application testing
CN109165168A (en) * 2018-09-14 2019-01-08 杭州云创共享网络科技有限公司 A kind of method for testing pressure, device, equipment and medium
CN109446071A (en) * 2018-09-26 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, interface test device, electronic equipment and storage medium
CN109271325A (en) * 2018-10-26 2019-01-25 携程旅游网络技术(上海)有限公司 Test method, system, electronic equipment and the storage medium of application

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
自动化测试技术中Mock框架的建设与应用;孟燕;;武汉理工大学学报(信息与管理工程版)(第03期);全文 *

Also Published As

Publication number Publication date
CN113434384A (en) 2021-09-24

Similar Documents

Publication Publication Date Title
CN107133180B (en) Dynamic page testing method, testing device and storage medium
US8782215B2 (en) Performance testing in a cloud environment
CN107766509B (en) Method and device for static backup of webpage
CN111786939B (en) Method, device and system for testing management platform of Internet of things
CN104536890A (en) Testing system, method and device
CN110858172A (en) Automatic test code generation method and device
CN110737726B (en) Method and device for determining test data of interface to be tested
CN109218041B (en) Request processing method and device for server system
KR20230079348A (en) Cloud code development system, method, device, device and storage medium
CN113434384B (en) Pressure testing method and device
CN111800511B (en) Synchronous login state processing method, system, equipment and readable storage medium
CN115996179A (en) Service node testing method and device, readable medium and electronic equipment
US10432490B2 (en) Monitoring single content page application transitions
CN113127335A (en) System testing method and device
CN112131095B (en) Pressure testing method and device
CN111290873B (en) Fault processing method and device
CN112241332B (en) Interface compensation method and device
CN113760715A (en) Method and device for testing system
CN113282489A (en) Interface testing method and device
CN113132447A (en) Reverse proxy method and system
CN111124907A (en) Mobile phone game testing method and device and server
CN113031960B (en) Code compiling method, device, server and storage medium
CN116701158A (en) Test method and device
CN113342633B (en) Performance test method and device
CN113760886B (en) Method, apparatus, device and computer readable medium for providing data service

Legal Events

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