CN113434384A - Pressure testing method and device - Google Patents

Pressure testing method and device Download PDF

Info

Publication number
CN113434384A
CN113434384A CN202010208778.7A CN202010208778A CN113434384A CN 113434384 A CN113434384 A CN 113434384A CN 202010208778 A CN202010208778 A CN 202010208778A CN 113434384 A CN113434384 A CN 113434384A
Authority
CN
China
Prior art keywords
data
data request
request
interface
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.)
Granted
Application number
CN202010208778.7A
Other languages
Chinese (zh)
Other versions
CN113434384B (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

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/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

Landscapes

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

Abstract

The invention discloses a pressure testing method and device, and relates to the technical field of internet. One embodiment of the method comprises: copying 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 according to the first data requests in the production environment by using a first filter; correspondingly storing the first data request and the first real response data; under a test environment, a press machine 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 method and the device can directly copy real data requests in a living environment and perform pressure testing, and accuracy and effectiveness of the pressure testing 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 internet users has increased to the level of millions or even billions, and in order to ensure good user experience, the internet system not only needs to operate continuously, but also needs to deal with the high concurrency condition that a large number of users access simultaneously. Therefore, in order to ensure the stability of the internet system, the internet system needs to be subjected to a stress test. At present, most of internet systems adopt distributed deployment, and all subsystems are often called through remote calling interfaces, so that the pressure test of the remote calling interfaces becomes a key in the pressure test of the internet systems.
At present, the following two methods are mainly used for testing the remote call interface: reading an online log or a historical record by using a scripting language to simulate and construct an online user request, and then simulating a multi-user request based on a multi-thread mode to perform a pressure test; some stress testing tools, such as JMeter, LoadRunner, etc., are used to simulate an online user request to perform a stress test.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: when a pressure test tool such as a scripting language or JMeter is used for testing, only a real online user request can be simulated, the real online user request cannot be directly used for pressure test, and further the problems in the system cannot be effectively found; a real internet system often needs thousands of machines to provide services at the same time, and when a pressure test is performed, such a plurality of machines cannot be deployed according to a real situation, an online environment needs to be simulated, and especially when an interface to be tested depends on one or more third-party interfaces, the online environment deployment during the pressure test is particularly complex.
Disclosure of Invention
In view of this, embodiments of the present invention provide a pressure test method and apparatus, which can directly copy a real data request in a living environment, perform a pressure test according to the real data request, and avoid problems such as 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 embodiments 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 and first real response data returned by the interface to be tested according to the first data requests in the production environment by using a first filter;
correspondingly storing the first data request and the first real response data;
under a test environment, a press machine 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.
Optionally, the method further comprises:
under the condition that one or more third-party interfaces need to be called by the interface to be tested, copying 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;
correspondingly storing the second data request and the second real response data;
and under the test environment, reading the stored second data request and the second real response data by using a simulator simulating the third-party interface, 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 the data request is copied 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 second real response data corresponding to the first data request or 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 batch, and sends the first data request to the interface to be tested through a producer/consumer mode.
Optionally, according to the time sequence indicated by the data request identifier, after the press sends the first data request to the interface to be tested, the simulator reads and caches the second data request and second real response data corresponding to the second data request in batch.
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 a first filter and the WebSocket server or a connection between a 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 request for starting or stopping data replication 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 embodiments of the present invention, there is provided a pressure testing apparatus including: the system comprises a data copying module, a data storage module and a pressure testing module; wherein the content of the first and second substances,
the data replication module is used for replicating 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 according to the first data requests in the production environment by using a first filter;
the data storage module is used for correspondingly storing the first data request and the first real response data;
the pressure testing module is used for reading the stored first data request by using a press machine under a testing 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 testing result.
Optionally, the data copying module is further configured to copy, 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, which are returned from the third-party interfaces, by using a second filter corresponding to the third-party interfaces;
the data storage module is further configured to correspondingly store the second data request and the second real response data;
the pressure testing module is further configured to read the stored second data request and the second real response data by using a simulator that simulates the third-party interface in a testing environment, where the simulator returns the second real response data when receiving the second data request in the testing environment.
Optionally, the data replication module is further configured to:
after the data request is copied 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 second real response data corresponding to the first data request or 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 test module is also used for
And according to the data request identification, the press machine reads and caches the first data request in batch, and sends the first data request to the interface to be tested through a producer/consumer mode.
Optionally, the pressure test module is also used for
And sending the first data request to the interface to be tested at the press according to the time sequence indicated by the data request identification, and reading and caching the second data request and second real response data corresponding to the second data request in batches by the simulator.
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 a first filter and the WebSocket server or the connection between a 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 request for starting or stopping data replication 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 embodiments of the present invention, there is provided a pressure test electronic device including: one or more processors; a storage device to store one or more programs that, when executed by the one or more processors, implement the method of any of the stress testing methods described above.
To achieve the above object, according to a fourth aspect of 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 any one of the stress testing methods described above.
The invention has the following advantages or beneficial effects: because the technical means of copying the first data request sent to the interface to be tested and the corresponding first real response data in the production environment by the first filter is adopted, the technical problem that the problem existing in the system cannot be really and effectively found by adopting a simulated online user request to carry out 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 by the simulator model is adopted, so that the technical problem that a large number of third party interfaces need to be deployed in a testing environment in the existing pressure test is solved, the complexity of the pressure test is reduced, and the efficiency of the pressure test is improved.
Further effects of the above-mentioned non-conventional alternatives will be 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 a main flow of a pressure testing method according to an embodiment of the 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 a 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 testing system in a testing environment according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a 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 employed;
fig. 8 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as 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 and first real response data returned by the interface to be tested according to the first data requests in the production environment by using a first filter.
The filter is a program or a component of a server program, and can intercept data requests and responses of an interface to be tested corresponding to a 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 to-be-tested interface executes a program after receiving the first data request, and the first data request and the first real response data have a one-to-one correspondence relationship.
Furthermore, the interfaces to be tested (remote call interfaces, such as RPC interfaces) in the existing internet systems often rely on one or more third party interfaces (i.e. other remote call interfaces), so that, in the case where the interfaces to be tested need to call one or more third party interfaces, one or more second data requests sent to the third party interfaces in the production environment and second real response data corresponding to the second data requests returned from the third party interfaces are copied by using the second filter corresponding to the third party interfaces.
On the basis, in order to ensure the one-to-one correspondence between a first data request and first real response data and the one-to-one correspondence between a second data request and a second real response data request, after the data request is copied to the first data request or the second data request, a data request identifier uniquely corresponding to the first data request or the second data request is generated; adding the data request identification to the first data request or the second data request so that the copied first real response data or second real response data corresponding to the first data request or 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. For example, the data request identifier is sequentially increased in time sequence, and the smaller the data corresponding to the data identifier is, the earlier the sequence in which the corresponding first data request or second data request is sent to the test interface or the simulator during the stress test is.
It can be understood that before copying one or more first data requests received by an 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 according to the data requests in the production environment, the first filter, the interface to be tested and a second filter are deployed into the same Java process by using a Java hot deployment technology, so as to reduce the influence of a network or other programs on data request copying. The Java hot deployment means that the change of the class file can be automatically detected under the condition that the Java virtual machine is not restarted, so that the class behavior during the operation is updated.
In addition, when the data request is replicated using the first filter or the second filter, the data request may be either single-threaded or multi-threaded. In this embodiment, it is considered that the single thread mode is preferentially adopted to copy the data request and the corresponding response result, so that the influence of the filter on the execution performance of the interface to be tested or the third-party interface can be reduced as much as possible, and the authenticity of the copied data request is strived for.
Step S102, correspondingly storing the first data request and the first real response data.
It can be understood that, in a case that the interface to be tested depends on one or more third-party interfaces, that is, in a case that the second filter corresponding to the third interface is used to copy the second data request and the second real response data, the method further includes: correspondingly storing the second data request and the second real response data.
Specifically, the first data request, the first real response data or the second data request, and the second real response data are sent to a WebSocket server by using a WebSocket connection corresponding to the first filter or the second filter, 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 is a full-duplex communication protocol, once a connection is established between a client and a server, all subsequent data communication is performed through the connection, and data in any format such as JSON, XML, HTML or pictures and the like can be mutually transmitted in the communication process. It is worth noting that, in order to ensure stability and continuity of the WebSocket connection, the first filter or the second filter transmits the data request and the real response result to the WebSocket server side in a single-thread long connection mode.
In addition, because the first filter is in bidirectional connection with the WebSocket server, a request for starting or stopping data replication can be sent to the first filter through the connection between the WebSocket server and the first filter.
Step S103, under a test environment, a 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.
Specifically, if the test response data is consistent with the first real response data, indicating that the pressure test is successful and recording the number of times of successful pressure test; and if the test response data is inconsistent with the first real response data, simultaneously recording the test response data and the first real response data so as to conveniently investigate the problem in the future. The simulator is used for simulating the third-party interface generated by using a Java dynamic byte code generation technology according to a preconfigured JAR packet corresponding to the third-party interface before a stored first data request is read by using a press and sent to the interface to be tested so as to perform pressure test on the interface to be tested.
In addition, under the condition that the interface to be tested depends on one or more third-party interfaces, that is, under the condition that the second data request and the second real response data are copied by using the second filter corresponding to the third interface, under the test environment, the method further includes: reading the stored second data request and the second real response data using a simulator that simulates the third party interface, wherein the simulator returns the second real response data when receiving the second data request in a test environment. Therefore, the simulator can be used for replacing one or more third-party testing interfaces on which the to-be-tested interfaces really need to depend, the simulator does not need to perform operation according to the second data request to obtain a response result, only second real response data corresponding to the stored second data request need to be sent to the to-be-tested interfaces, and a large number of third-party interfaces do not need to be deployed.
More specifically, in the test environment, in order to simulate the third-party interface truly by using the simulator, after reading the second true response result corresponding to the second data request, the simulator returns the corresponding second true response result to the interface to be tested according to the true response time corresponding to the second true response result returned by the third-party interface in the production environment under the condition of receiving the second data request sent by the interface to be tested. 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 arrived, if so, the simulator returns the second real response data, if not, the simulator suspends the program, and after the time consumed is reached, the simulator returns the second real response data.
In an optional embodiment, according to the data request identification, the press reads and caches the first data request in batch, and sends the first data request to the interface to be tested through a producer/consumer mode. Therefore, the speed of sending the first data request, namely the speed of sending the pressure during the pressure test can be controlled in a mode of controlling the number of threads of the press machine or consuming the first data request frequency by the interface to be tested. In addition, the interaction between the press and a storage engine for storing the first data request and the first real response data can be reduced in a mode that the press reads and caches the first data request in batches.
On the basis, according to the time sequence indicated by the data request identification, after the press sends the first data request to the interface to be tested, the simulator reads and caches the second data request and second real response data corresponding to the second data request in batch. Namely, the interaction between the press and a storage engine for storing the second data request and the second real response data is reduced in a mode that the simulator reads and caches the first data request.
Based on the embodiment, by adopting the technical means that the first filter is adopted to copy the first data request sent to the interface to be tested under the production environment and the corresponding first real response data, the technical problem that the pressure test by adopting the simulated on-line user request in the prior art cannot really and effectively find the system has problems 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 by the simulator model is adopted, so that the technical problem that a large number of third party interfaces need to be deployed in a testing environment in the existing pressure test is solved, 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 embodiment, the 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 device 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 an interface to be tested under a production environment, and first real response data returned by the interface to be tested under the production environment according to the data requests, and sending the first data requests and the first real response data to the WebSocket server through the 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 under the production environment and second real response data corresponding to the second data requests returned from the third-party interface, and sending the second data requests and the second real response data 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, an embodiment of the present invention provides a data request replication method in a production environment, where the method specifically includes the following steps:
step S301, a first filter copies 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 according to the first data requests in the production environment.
In order to ensure the one-to-one correspondence between a first data request and a first real response data request, after the first data request is copied, generating a data request identifier uniquely corresponding to the first data request, wherein the data request identifier is associated with time or is increased progressively according to a time sequence; adding the data request identification to the first data request so that the copied first real response data corresponding to the first data request has the data request identification.
Step S302, the first filter sends the first data request and the first real response data to the WebSocket server through the connection between the first filter and the WebSocket server.
In addition, the first filter establishes a bidirectional connection with the WebSocket server, and therefore, a request for starting or stopping data replication can be sent to the first filter through the connection between the WebSocket server and the first filter.
Step S303, the second filter copies 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 a second data request and a second real response data request, after the second data request is copied, generating a data request identifier uniquely corresponding to the second data request, wherein the data request identifier is associated with time or is increased in time sequence; adding the data request identification to the second data request so that the copied second real response data corresponding to the second data request has the data request identification.
Step S304, the second filter sends the second data request and the second real response data to the WebSocket server through the connection between the second filter and the WebSocket server.
Step S305, 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.
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 machine, an interface to be tested, a simulator and a storage engine; the press machine 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 receiving the second data request.
Referring to fig. 5, on the basis of the above embodiment, the embodiment of the present invention provides a method for testing pressure in a test environment, which may specifically include the following steps:
step S501, the press machine reads the stored first data request and sends the first data request to the interface to be tested.
Specifically, according to the data request identification, the press reads and caches the first data request in batch, and sends the first data request to the interface to be tested through a producer/consumer mode. Therefore, the speed of sending the first data request, namely the speed of sending the pressure during the pressure test can be controlled in a mode of controlling the number of threads of the press machine or consuming the first data request frequency by the interface to be tested. In addition, the interaction between the press and a storage engine for storing the first data request and the first real response data can be reduced in a mode that the press reads and caches the first data request in batches.
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 and second real response data corresponding to the second data request in batch. Namely, the interaction between the press and a storage engine for storing the second data request and the second real response data is reduced in a mode that the simulator reads and caches the first data request.
Step S503, when the simulator receives the second data request in the test environment, the simulator returns the second real response data.
More specifically, in the test environment, in order to simulate the third-party interface truly by using the simulator, after reading the second true response result corresponding to the second data request, the simulator returns the corresponding second true response result to the interface to be tested according to the true response time corresponding to the second true response result returned by the third-party interface in the production environment under the condition of receiving the second data request sent by the interface to be tested. 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 arrived, if so, the simulator returns the second real response data, if not, the simulator suspends the program, and after the time consumed is reached, the simulator returns the second real response data.
Step S504, the press machine receives 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 number of times of successful pressure test; and if the test response data is inconsistent with the first real response data, simultaneously recording the test response data and the first real response data so as to conveniently investigate the problem in the future.
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 content of the first and second substances,
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 according to the first data requests in the production environment;
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, in a testing environment, use a press to read the stored first data request, 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 optional embodiment, the data replication module 601 is further configured to, in a case that the interface to be tested needs to call one or more third-party interfaces, replicate, by using a second filter corresponding to the 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;
the data storage module is further configured to correspondingly store the second data request and the second real response data;
the pressure testing module is further configured to read the stored second data request and the second real response data by using a simulator that simulates the third-party interface in a testing environment, where the simulator returns the second real response data when receiving the second data request in the testing environment.
In an optional implementation manner, the data replication module 601 is further configured to:
after the data request is copied 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 second real response data corresponding to the first data request or 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 batch, 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 sending the first data request to the interface to be tested at the press according to the time sequence indicated by the data request identification, and reading and caching the second data request and second real response data corresponding to the second data request in batches by the simulator.
In an alternative embodiment, the data storage module 602 is configured to store data
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 a first filter and the WebSocket server or the connection between a 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 request for starting or stopping data replication 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, the system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 serves to provide a medium for communication links between the terminal devices 701, 702, 703 and the server 705. Network 704 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 701, 702, 703 to interact with a server 705 over a network 704, to receive or send messages or the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 701, 702, and 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 smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 705 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 701, 702, and 703. The background management server can analyze and process the received data such as the product information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that the pressure testing method provided by the embodiment of the present invention is generally executed by the server 705, and accordingly, the pressure testing apparatus 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, shown is a block diagram of a computer system 800 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments 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 in accordance with 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 necessary for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 808 including a hard disk and 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. A drive 810 is also connected to the I/O interface 805 as necessary. 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 necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the 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 illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 801.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present invention, 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, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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 flowchart 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 described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a data copying module, a data storage module and a pressure testing module. The names of these modules do not constitute a limitation to the module itself in some cases, for example, the data storage module may also be described as "a module for storing the first data request, the first real response data, respectively".
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 separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: copying one or more first data requests received by an interface to be tested under a production environment and first real response data returned by the interface to be tested under the production environment according to the data requests by using a first filter; correspondingly storing the first data request and the first real response data; under a test environment, a press machine 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.
According to the technical scheme of the embodiment of the invention, because the technical means of copying the first data request and the corresponding first real response data sent to the interface to be tested in the production environment by the first filter is adopted, the technical problem that the problem of the system cannot be really and effectively found out by adopting a simulated online user request to carry out 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 by the simulator model is adopted, so that the technical problem that a large number of third party interfaces need to be deployed in a testing environment in the existing pressure test is solved, the complexity of the pressure test is reduced, and the efficiency of the pressure test is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, 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 (12)

1. A pressure testing method, comprising:
copying 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 according to the first data requests in the production environment by using a first filter;
correspondingly storing the first data request and the first real response data;
under a test environment, a press machine 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.
2. The pressure testing method of claim 1, further comprising:
under the condition that one or more third-party interfaces need to be called by the interface to be tested, copying 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;
correspondingly storing the second data request and the second real response data;
and under the test environment, reading the stored second data request and the second real response data by using a simulator simulating the third-party interface, wherein the simulator returns the second real response data when receiving the second data request in the test environment.
3. The pressure testing method of claim 2, further comprising:
after the data request is copied 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 second real response data corresponding to the first data request or second data request has the data request identification.
4. A pressure testing method according to claim 3,
the data identification request indicates a temporal order of the first data request or the second data request.
5. A pressure testing method according to claim 2,
and the simulator returns the second real response data according to the stored real response time corresponding to the second data request.
6. A pressure testing method according to claim 4,
and according to the data request identification, the press machine reads and caches the first data request in batch, and sends the first data request to the interface to be tested through a producer/consumer mode.
7. A pressure testing method according to claim 4,
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 and second real response data corresponding to the second data request in batch.
8. A pressure testing method according to claim 2,
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 a first filter and the WebSocket server or the connection between a 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.
9. The pressure testing method of claim 8, further comprising:
and sending a request for starting or stopping data replication to the first filter through the connection between the WebSocket server and the first filter.
10. A pressure testing device, comprising: the system comprises a data copying module, a data storage module and a pressure testing module; wherein the content of the first and second substances,
the data replication module is used for replicating 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 according to the first data requests in the production environment by using a first filter;
the data storage module is used for correspondingly storing the first data request and the first real response data;
the pressure testing module is used for reading the stored first data request by using a press machine under a testing 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 testing result.
11. A pressure testing electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
the one or more programs, when executed by the one or more processors, implement the method of any of claims 1-9.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-9.
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 true CN113434384A (en) 2021-09-24
CN113434384B 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)

Cited By (1)

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

Citations (5)

* 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
US20190156199A1 (en) * 2017-11-20 2019-05-23 International Business Machines Corporation Method for automated integration testing with mock microservices

Patent Citations (5)

* 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
US20190156199A1 (en) * 2017-11-20 2019-05-23 International Business Machines Corporation Method for automated integration testing with mock microservices
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框架的建设与应用", 武汉理工大学学报(信息与管理工程版), no. 03 *

Cited By (2)

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

Also Published As

Publication number Publication date
CN113434384B (en) 2023-09-22

Similar Documents

Publication Publication Date Title
CN107766509B (en) Method and device for static backup of webpage
CN110858172A (en) Automatic test code generation method and device
CN111786939B (en) Method, device and system for testing management platform of Internet of things
CN109656799B (en) Test method and device
CN110737726B (en) Method and device for determining test data of interface to be tested
CN110083341A (en) A kind of front end development platform, front end development approach and page display method
CN115996179A (en) Service node testing method and device, readable medium and electronic equipment
CN111800511B (en) Synchronous login state processing method, system, equipment and readable storage medium
CN113434384B (en) Pressure testing method and device
CN111382058B (en) Service testing method and device, server and storage medium
CN111338928A (en) Chrome-based browser testing method and device
CN112131095B (en) Pressure testing method and device
CN115454666A (en) Data synchronization method and device among message queue clusters
CN112241332B (en) Interface compensation method and device
CN111290873B (en) Fault processing method and device
CN110768855B (en) Method and device for testing linkmzation performance
CN111382057B (en) Test case generation method, test method and device, server and storage medium
CN113778709A (en) Interface calling method, device, server and storage medium
CN113760715B (en) Method and device for testing system
CN113760693A (en) Method and apparatus for local debugging of microservice systems
CN113132447A (en) Reverse proxy method and system
CN111163156A (en) Data processing method, device and storage medium based on block chain
CN112988560A (en) Method and device for testing system robustness
CN111124907A (en) Mobile phone game testing method and device and server
CN113031960B (en) Code compiling method, device, server 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
GR01 Patent grant
GR01 Patent grant