A test system, method, device, equipment and medium
By establishing a short connection between the server and the client for testing, the problem of long connections occupying system resources is solved, and testing efficiency and flexibility are improved.
Patent Information
- Application Number
- CN202411924226.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, a long connection is needed between the server and the client for testing, resulting in a large system resource occupancy and weak stability, which reduces the testing efficiency.
Testing is carried out by establishing a short connection. The client receives the test command and then sends a short connection request to the server. After the server receives the test command and obtains the corresponding data information, it returns the data information to the client and disconnects the connection in time to release system resources.
It realizes rapid and flexible testing, and disconnects in time after the test is completed, releasing system resources, improving testing efficiency and flexibility.
Smart Images

Figure CN119766684A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a test system, method, device, equipment and medium. Background Art
[0002] In the related art, when monitoring, debugging, fault injection and other testing are performed on the services provided by the server, a long connection usually needs to be established between the client and the server. The client and the server can maintain the connection for a long time after the connection is established so as to send and receive messages in real time.
[0003] However, maintaining a long connection will occupy system resources and is prone to disconnection due to abnormal conditions such as the network. Corresponding exception handling is required on both the client and the server, which has poor stability and reduces test efficiency.
[0004] Therefore, there is an urgent need for a technical solution that can improve testing efficiency. Summary of the invention
[0005] The present application provides a testing system, method, apparatus, device and medium for improving testing efficiency.
[0006] In a first aspect, the present application provides a testing system, the system comprising:
[0007] The client is used to receive a test command for the server and send a short connection request to the server;
[0008] The server is used to accept the short connection request and establish a short connection with the client;
[0009] The client is further used to send the test command to the server;
[0010] The server is further configured to receive the test command, obtain data information corresponding to the test command, and return the data information to the client;
[0011] The client is further used to receive the data information and disconnect the short connection with the server;
[0012] The server is also used to disconnect the short connection with the client.
[0013] Through the above method, compared with establishing a long connection between the server and the client, which occupies more system resources and has lower testing efficiency, in the embodiment of the present application, a short connection can be established between the server and the client to quickly and flexibly perform the corresponding testing process on the server. After the test, the connection can be disconnected in time to release (recycle) system resources in time, which can improve the testing flexibility and efficiency.
[0014] In a possible implementation, the server is further used to:
[0015] Determining whether the test command is a compliance command;
[0016] If yes, then proceed to the step of obtaining data information corresponding to the test command;
[0017] If not, a prompt message indicating that the command is not compliant is sent to the client, and the short connection with the client is disconnected.
[0018] Through the above method, since the server can detect whether the test command is a preset compliance command when receiving the test command, if the test command is a preset compliance command, the process of obtaining the corresponding data information of the test command can be performed; if the test command is not a preset compliance command, a prompt message indicating that the command is not compliant can be sent to the client and the short connection with the client can be disconnected to terminate the test process, thereby improving the accuracy and efficiency of the test.
[0019] At the same time, compared with pre-storing test commands for users to choose from in the client, which takes up more resources and reduces efficiency, the present application adopts a method in which users enter test commands containing command keywords in the client according to the test instructions, and the server then checks whether the test commands input by the user are compliant. This method does not require occupying more resources, can improve the lightweight design level of the client, and improve the testing efficiency to a certain extent.
[0020] In a possible implementation, the client is specifically used to:
[0021] receiving a data header in the data information, and allocating a corresponding first memory space for the data information in the client according to a data length in the data header;
[0022] Receive data in the data information, and save the data in the first memory space.
[0023] In the above manner, since the data header in the data information can be received first, and appropriate memory space can be allocated to the data according to the data length indicated in the data header to cache (save) the corresponding data, the flexibility of data storage can be improved and the utilization rate of memory space can be improved.
[0024] In a possible implementation, the server is further used to:
[0025] If the test command sent by the client is not received within the set time after the short connection is established with the client, a command reception failure prompt message is sent to the client, and the short connection with the client is disconnected.
[0026] Through the above method, since the server can send a command reception failure prompt message to the client and disconnect the short connection with the client when it does not receive the test command sent by the client within the set time after establishing a short connection with the client, it can release and recycle resources in time and improve the test accuracy.
[0027] In a possible implementation, the server is specifically used to:
[0028] Determine the target callback function corresponding to the command keyword in the test command according to the correspondence between the pre-registered command keyword and the callback function;
[0029] Based on the target callback function, data information corresponding to the test command is obtained.
[0030] Through the above method, since the target callback function corresponding to the command keyword in the test command can be quickly determined based on the correspondence between the pre-saved (registered) command keyword and the callback function, the data information corresponding to the test command can be quickly and accurately obtained based on the target callback function.
[0031] In addition, since the command keywords and callback functions (also called processing functions) corresponding to the services (also called service modules) on the server side can be flexibly configured, the flexibility of the test can be improved. At the same time, users can issue (trigger) test commands by inputting command keywords, etc., which can improve the convenience of users issuing test commands.
[0032] In a possible implementation, the server is specifically used to:
[0033] Performing loop processing based on the target callback function to obtain each sub-data corresponding to the test command respectively;
[0034] For each of the sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, reconfigure the third memory space corresponding to the test command according to the size of the second memory space, wherein the third memory space is larger than the second memory space;
[0035] Each sub-data is saved in the third memory space.
[0036] Through the above method, for each sub-data corresponding to the test command, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, the server can re-configure a third memory space with a larger space for the test command according to the size of the second memory space, and save each sub-data of the test command in the third memory space, so that memory resources can be flexibly and reasonably utilized and test accuracy can be improved.
[0037] In a possible implementation, the server is further used to:
[0038] Determine whether the number of times the memory space is reconfigured for the test command exceeds a set number threshold;
[0039] If not, then performing a step of reconfiguring the third memory space corresponding to the test command;
[0040] If so, a prompt message indicating that data acquisition failed is sent to the client.
[0041] Through the above method, since it is possible to determine whether the number of times the memory space is reconfigured for the test command exceeds the set number threshold before reconfiguring the memory space for the test command, if it does not exceed the set number threshold, the memory space corresponding to the test command is expanded, and if it exceeds the set number threshold, the memory space corresponding to the test command is no longer expanded, and a prompt message indicating that data acquisition failure has occurred is directly sent to the client to end the test process. This can improve test accuracy and efficiency on the basis of maximizing the rational use of memory space.
[0042] In a possible implementation, the client is further used for:
[0043] Determine whether the test command contains any illegal characters;
[0044] If yes, a prompt message indicating that the test command is not compliant is output;
[0045] If not, the step of sending a short connection request to the server is performed.
[0046] Through the above method, since the client can first detect whether the test command contains any illegal characters after receiving the test command, if it contains illegal characters, it can output a prompt message that the test command is not compliant without performing the subsequent test process of sending a short connection request to the server. Only when the test command does not contain illegal characters, the subsequent test process of sending a short connection request to the server is performed, which can improve the test efficiency.
[0047] In a possible implementation, the client is further used for:
[0048] If the data information sent by the server is not received within the set time after the short connection is established with the server, a data reception failure prompt message is sent to the server, and the short connection with the server is disconnected.
[0049] Through the above method, since the client can send a data reception failure prompt message to the server when it fails to receive the data information sent by the server within the set time after establishing a short connection with the server, and disconnect the short connection with the server, it can release and recycle resources in time and improve the test accuracy.
[0050] In a second aspect, the present application provides a testing method, which is applied to a server and includes:
[0051] Receiving a short connection request sent by a client, and establishing a short connection with the client;
[0052] Receive the test command sent by the client, obtain data information corresponding to the test command, and return the data information to the client;
[0053] Disconnect the short connection with the client.
[0054] In a third aspect, the present application provides a testing method, which is applied to a client and includes:
[0055] Receive a test command for the server, and send a short connection request to the server;
[0056] Based on the short connection established between the server and the client, sending the test command to the server;
[0057] Receive data information corresponding to the test command returned by the server, and disconnect the short connection with the server.
[0058] In a fourth aspect, the present application provides a testing device, which is applied to a server, and includes:
[0059] A connection module, used to receive a short connection request sent by a client and establish a short connection with the client;
[0060] An acquisition module, used for receiving a test command sent by the client, acquiring data information corresponding to the test command, and returning the data information to the client;
[0061] The disconnection module is used to disconnect the short connection with the client.
[0062] In a fifth aspect, the present application provides a testing device, which is applied to a client and includes:
[0063] A request module, used for receiving a test command for a server and sending a short connection request to the server;
[0064] A sending module, used for sending the test command to the server based on the short connection established between the server and the client;
[0065] The receiving module is used to receive the data information corresponding to the test command returned by the server and disconnect the short connection with the server.
[0066] In a sixth aspect, the present application further provides an electronic device, comprising at least a processor and a memory, wherein the processor is configured to implement the steps of the test method described in any one of the second and third aspects when executing a computer program stored in the memory.
[0067] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer performs the steps of the test method described in any one of the second and third aspects.
[0068] In an eighth aspect, an embodiment of the present application provides a computer program product, which includes: a computer program code, which, when executed on a computer, enables the computer to execute the steps of the test method described in any one of the second and third aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the implementation methods in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technology descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0070] Figure 1 A schematic diagram of a test system provided in an embodiment of the present application;
[0071] Figure 2 A schematic diagram of a test process provided in an embodiment of the present application;
[0072] Figure 3 Another test process schematic diagram provided for an embodiment of the present application;
[0073] Figure 4 A schematic diagram of another test process provided in an embodiment of the present application;
[0074] Figure 5 A schematic diagram of another test process provided in an embodiment of the present application;
[0075] Figure 6 A schematic diagram of another test process provided in an embodiment of the present application;
[0076] Figure 7 A schematic diagram of another test process provided in an embodiment of the present application;
[0077] Figure 8 A schematic diagram of another test process provided in an embodiment of the present application;
[0078] Fig. 9 A schematic diagram of the structure of a testing device provided in an embodiment of the present application;
[0079] Fig.10 A schematic diagram of another test device structure provided in an embodiment of the present application;
[0080] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0081] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0082] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0083] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.
[0084] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0085] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0087] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
[0088] The embodiment of the present application provides a test system, method, device, equipment and medium. In the method, after receiving the test command for the server, the client can send a short connection request to the server. When the server receives the short connection request, it can establish a short connection with the client; after the client recognizes that a short connection is established between the server and the client, it can send the test command to the server; after receiving the test command, the server can obtain the data information corresponding to the test command and return the data information to the client. After receiving the data information, the client disconnects the short connection between the client and the server. Compared with the long connection between the server and the client, which occupies more system resources and has lower test efficiency, in the embodiment of the present application, the server and the client can quickly and flexibly perform the corresponding test process on the server by establishing a short connection. After the test is completed, the connection can be disconnected in time, and the system resources can be released (recycled) in time, which can improve the flexibility and efficiency of the test.
[0089] Embodiment 1:
[0090] Figure 1 A schematic diagram of a test system provided in an embodiment of the present application, the system comprising:
[0091] The client 11 is used to receive a test command for the server 12 and send a short connection request to the server 12;
[0092] The server 12 is used to accept the short connection request and establish a short connection with the client 11;
[0093] The client 11 is further used to send the test command to the server 12;
[0094] The server 12 is further configured to receive the test command, obtain data information corresponding to the test command, and return the data information to the client 11;
[0095] The client 11 is also used to receive the data information and disconnect the short connection with the server 12;
[0096] The server 12 is also used to disconnect the short connection with the client 11.
[0097] In a possible implementation, when it is necessary to test the service provided by the server 12, the user can trigger a test command for the server 12 (also referred to as the service server) in the client 11. For example, the client 11 can receive the IP address, port number and other identification information of the server 12 input by the user, and can receive the command keyword (also referred to as the -c parameter), service parameters (arguments, args, also referred to as the -a parameter) and the like input by the user for testing the service provided by the server 12, and can consider that the test command triggered by the user is received when it is recognized that the test button and the like are clicked. For example, the command keyword can include the corresponding service name (ModuleName) and the keyword information (CmdKey) for executing the corresponding command of the service, and the service parameters can include the time period information, data format information and the like of the acquired data information. The present application does not specifically limit the command keywords, service parameters and the like, and can be flexibly set according to service requirements.
[0098] In a possible implementation, when the client 11 receives a test command for a server 12, it can identify the IP address, port number and other identification information of the server 12 carried in the test command, and send a short connection request to the server 12 according to the IP address, port number and other identification information of the server 12. The server 12 can wait (listen) for the connection request (short connection request) from the client in a non-blocking loop at a set time interval (for example, every 10ms) by delivering a listening coroutine (the listening coroutine can also be called a resident receiving connection coroutine). After the server 12 receives the short connection request sent by the client 11 based on its listening coroutine, it can establish a short connection with the client 11. Specifically, a socket short connection can be established between the server 12 and the client 11, which will not be repeated here.
[0099] After a short connection is established between the server 12 and the client 11, the client 11 can send a test command to the server 12, and the server 12 can receive the test command sent by the client 11. In one possible implementation, the server 12 can receive the test command sent by the client 11 based on the transceiver communication coroutine (also referred to as a transceiver coroutine or a temporary communication coroutine) created by it. In one possible implementation, the server 12 can simultaneously and concurrently receive test commands sent by multiple clients 11 by delivering multiple transceiver communication coroutines, and support concurrent processing of multiple test processes. For ease of understanding, the embodiments of the present application take any test process as an example to explain the test process provided by the present application.
[0100] In a possible implementation, the server 12 can initialize the process environment and the command hash table during the startup process. As each business process is started, the command keywords, command parameters, processing functions (callback functions), etc. pre-registered for each business can be imported into the command hash table. After receiving the test command, the server 12 can obtain the data information corresponding to the test command and return the data information to the client 11. Among them, when the server 12 obtains the data information corresponding to the test command, it can identify the command keyword carried in the test command, and can query the pre-registered command hash table, and determine the target callback function corresponding to the command keyword in the test command according to the correspondence between the command keyword recorded (registered) in the command hash table and the callback function, and obtain the data information corresponding to the test command based on the target callback function. Among them, the callback function can include the CmdProc callback function, and the data information corresponding to the test command can be obtained by cyclically executing the callback function, which will not be repeated here.
[0101] Since the present application can quickly determine the target callback function corresponding to the command keyword in the test command according to the correspondence between the pre-saved (registered) command keyword and the callback function, based on the target callback function, the data information corresponding to the test command can be quickly and accurately obtained.
[0102] In addition, the application can flexibly configure the command keywords and callback functions (processing functions) corresponding to the services (service modules) on the server side, which can improve the flexibility of the test. At the same time, the user can issue (trigger) the test command by inputting the command keywords, which can improve the convenience of the user in issuing the test command.
[0103] When the server 12 sends data information to the client 11, the client 11 can receive the data information sent by the server 12. In a possible implementation, when the client 11 receives the data information sent by the server 12, it can receive the data information in two steps. Specifically, the first step: the client 11 can first receive the data header in the data information, identify the data length contained in the data header, and allocate a first memory space suitable for the data information in the client 11 according to the data length; wherein the size of the first memory space is not less than the size of the data length. The second step: the client 11 receives the data in the data information, and saves the data in the first memory space allocated for the data information.
[0104] Since the present application can first receive the data header in the data information and allocate appropriate memory space to cache (save) the corresponding data according to the data length indicated in the data header, the flexibility of data storage can be improved and the utilization rate of memory space can be improved.
[0105] In a possible implementation, after receiving and saving the data (also referred to as the echo information) in the data information, the client 11 may print and echo the data, etc., which is not specifically limited in this application. Afterwards, the client 11 may disconnect the short connection with the server 12 and release (recycle) the corresponding resources (system resources) involved in this test process in a timely manner.
[0106] In a possible implementation, when a client 11 sends a short connection request to a server 12 and a short connection is established between the server 12 and the client 11, the server 12 can create (deliver) a transceiver communication coroutine, and can perform subsequent processes such as receiving a test command sent by the client 11, parsing the command keywords and command parameters contained in the test command, determining the target callback function corresponding to the command keywords in the test command, and sending the acquired test command data information to the client 11 based on the transceiver communication coroutine. After the client 11 receives the data information and disconnects the short connection with the server 12, the server 12 can first release the transceiver communication coroutine, and then disconnect the short connection with the client 11, so as to release resources in time.
[0107] In an embodiment of the present application, after receiving a test command for the server, the client can send a short connection request to the server. When receiving the short connection request, the server can establish a short connection with the client; after the client recognizes that a short connection is established with the server, it can send a test command to the server; after receiving the test command, the server can obtain data information corresponding to the test command and return the data information to the client. After receiving the data information, the client disconnects the short connection between the client and the server. Compared with the long connection between the server and the client, which occupies more system resources and has lower test efficiency, in an embodiment of the present application, the server and the client can quickly and flexibly perform the corresponding test process on the server by establishing a short connection. After the test is completed, the connection can be disconnected in time, and the system resources can be released (recycled) in time, which can improve the flexibility and efficiency of the test.
[0108] Embodiment 2:
[0109] In order to improve the test efficiency, based on the above embodiment, in the embodiment of the present application, the client 11 is further used for:
[0110] Determine whether the test command contains any illegal characters;
[0111] If yes, a prompt message indicating that the test command is not compliant is output;
[0112] If not, the step of sending a short connection request to the server 12 is performed.
[0113] In a possible implementation, in order to improve the test efficiency, after receiving the test command triggered by the user, the client 11 can first conduct a preliminary review (inspection) of the test command. Specifically, the client 11 can determine whether the test command contains preset illegal characters. If the test command contains preset illegal characters, it can be considered that the user may have an input error, and a prompt message that the test command is not compliant can be output, prompting the user to modify the information in the test command. If the test command does not contain the preset illegal characters, the client 11 can preliminarily believe that the test command is compliant, and can then perform the above-mentioned step of sending a short connection request to the server 12, which will not be repeated here. Among them, the preset illegal characters can be flexibly set according to demand. Exemplarily, the illegal characters can be $, ◎, etc., and this application does not make specific limitations on this.
[0114] After receiving the test command, the client 11 can first detect whether the test command contains any illegal characters. If illegal characters are contained, a prompt message indicating that the test command is not compliant can be output without performing the subsequent test process of sending a short connection request to the server 12. The test process of sending a short connection request to the server 12 is performed only when the test command does not contain illegal characters, thereby improving the test efficiency.
[0115] In a possible implementation, when the client 11 determines that the test command does not contain illegal characters, it sends a short connection request to the server 12, and a short connection is established between the server 12 and the client 11. When the client 11 sends the test command to the server 12, in order to improve the test efficiency, after receiving the test command, the server 12 may conduct a secondary review of the test command before obtaining the corresponding data information of the test command. Specifically, the server may determine whether the test command is a compliant command, for example, it may determine whether the command keywords, command parameters, etc. in the test command are the command keywords and command parameters in the compliant command set corresponding to the corresponding business in the pre-registered command hash table. If so, the test command may be considered to be a compliant command, and the step of obtaining the corresponding data information of the test command may be performed.
[0116] In a possible implementation, if the command keywords, command parameters, etc. in the test command are not the command keywords and command parameters in the pre-saved compliance command set corresponding to the corresponding business, it can be considered that the test command is not a compliance command in the preset compliance command set, and the server 12 can send a prompt message indicating that the command is not compliant to the client 11 to prompt the user to re-enter a compliant test command. At this time, the server 12 can disconnect the short connection with the client 11 and end the test process.
[0117] Since the server can detect whether the test command is a preset compliant command when receiving the test command, if the test command is the preset compliant command, the process of obtaining the corresponding data information of the test command can be carried out; if the test command is not the preset compliant command, a prompt message indicating that the command is not compliant can be sent to the client and the short connection with the client can be disconnected to terminate the test process, thereby improving the accuracy and efficiency of the test.
[0118] At the same time, compared with pre-storing test commands for users to choose from in the client, which takes up more resources and reduces efficiency, the present application adopts a method in which users enter test commands containing command keywords in the client according to the test instructions, and the server then checks whether the test commands input by the user are compliant. This method does not require occupying more resources, can improve the lightweight design level of the client, and improve the testing efficiency to a certain extent.
[0119] For ease of understanding, the test process provided by this application is explained below through a specific embodiment. Figure 2 , Figure 2 A schematic diagram of a test process provided by some embodiments is shown, and the process includes the following steps:
[0120] S201: The client receives a test command for the server and determines whether the test command contains any illegal characters. If so, proceed to S202; if not, proceed to S203.
[0121] S202: The client outputs a prompt message indicating that the test command is not compliant.
[0122] S203: The client sends a short connection request to the server.
[0123] S204: The server accepts the short connection request and establishes a short connection with the client.
[0124] S205: The client sends a test command to the server.
[0125] S206: The server receives the test command and determines whether the test command is a compliant command. If not, proceed to S207; if so, proceed to S208.
[0126] S207: The server sends a prompt message to the client indicating that the command is not compliant, and disconnects the short connection with the client.
[0127] S208: The server obtains data information corresponding to the test command and returns the data information to the client.
[0128] S209: The client receives the data information and disconnects the short connection with the server.
[0129] S210: The server disconnects the short connection with the client.
[0130] In a possible implementation, the server 12 can use an external loop function of the Socket to cyclically monitor whether the test command sent by the client 11 is received at a set time interval. If the test command sent by the client 11 is not received within the set time after the short connection is established with the client 11, the corresponding loop function can be jumped out, and a prompt message of command reception failure is sent to the client 11, and the corresponding transceiver communication coroutine is released, and the short connection between the client 11 and the client 11 is disconnected, so as to release and recycle resources in time and improve the test accuracy. After receiving the prompt message of command reception failure sent by the server 12, the client 11 can display the prompt message, prompting the user to re-trigger the test command, re-perform the above test process, etc., and this application does not make specific restrictions on this. Among them, the set time length (also known as the connection timeout, -T parameter) can be flexibly set according to demand. For example, the set time length can be 30 seconds, etc., and this application does not make specific restrictions on this.
[0131] Since the server of this application can send a command reception failure prompt message to the client and disconnect the short connection with the client when it does not receive the test command sent by the client within the set time after establishing a short connection with the client, it can release and recycle resources in time and improve test accuracy.
[0132] In a possible implementation, after establishing a short connection with the server 12, the client 11 can also use the external loop function of the Socket to cyclically monitor whether the data information sent by the server 12 is received at a set time interval. If the data information sent by the server 12 is still not received within the set time after the short connection is established with the server 12, the corresponding loop function can be jumped out, and a prompt message of data reception failure is sent to the server 12, and the short connection with the server 11 is disconnected, so as to release and recycle resources in time and improve the test accuracy. After receiving the prompt message of data reception failure sent by the client 12, the server 12 can stop this test process, release the corresponding transceiver communication coroutine, and disconnect the short connection with the client 11 to recycle resources in time.
[0133] Since the client of this application can send a data reception failure prompt message to the server and disconnect the short connection with the server when it fails to receive data information sent by the server within a set time after establishing a short connection with the server, it can release and recycle resources in time and improve test accuracy.
[0134] For ease of understanding, the test process provided by this application is explained below through a specific embodiment. Figure 3 , Figure 3 Another test process schematic diagram provided by some embodiments is shown, and the process includes the following steps:
[0135] S301: The client receives a test command for the server and determines whether the test command contains any illegal characters. If so, proceed to S302; if not, proceed to S303.
[0136] S302: The client outputs a prompt message indicating that the test command is not compliant.
[0137] S303: The client sends a short connection request to the server.
[0138] S304: The server accepts the short connection request and establishes a short connection with the client.
[0139] S305: The server determines whether it has received a test command sent by the client within a set time after establishing a short connection with the client. If not, proceed to S306; if yes, proceed to S307.
[0140] S306: The server sends a command reception failure prompt message to the client, and disconnects the short connection with the client.
[0141] S307: The server determines whether the test command is a compliant command. If not, proceed to S308; if yes, proceed to S309.
[0142] S308: The server sends a prompt message to the client indicating that the command is not compliant, and disconnects the short connection with the client.
[0143] S309: The server obtains data information corresponding to the test command and returns the data information to the client.
[0144] S310: The client receives data information and disconnects the short connection with the server.
[0145] S311: The server disconnects the short connection with the client.
[0146] For ease of understanding, the test process provided by this application is explained below through a specific embodiment. Figure 4 , Figure 4 A schematic diagram of another test process provided by some embodiments is shown, and the process includes the following steps:
[0147] S401: The client receives a test command for the server and determines whether the test command contains any illegal characters. If so, proceed to S402; if not, proceed to S403.
[0148] S402: The client outputs a prompt message indicating that the test command is not compliant.
[0149] S403: The client sends a short connection request to the server.
[0150] S404: The server accepts the short connection request and establishes a short connection with the client.
[0151] S405: The client sends a test command to the server.
[0152] S406: If the client fails to receive data information sent by the server within the set time after establishing the short connection with the server, the client sends a data reception failure prompt message to the server and disconnects the short connection with the server.
[0153] S407: The server disconnects the short connection with the client.
[0154] Embodiment 3:
[0155] In order to flexibly and reasonably utilize memory resources and improve test accuracy, based on the above embodiments, in the embodiment of the present application, when the server 12 obtains data information corresponding to the test command based on the target callback function, the server 12 is specifically used to:
[0156] Performing loop processing based on the target callback function to obtain each sub-data corresponding to the test command respectively;
[0157] For each of the sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, reconfigure the third memory space corresponding to the test command according to the size of the second memory space, wherein the third memory space is larger than the second memory space;
[0158] Each sub-data is saved in the third memory space.
[0159] In a possible implementation, the target callback function can be repeatedly executed in a loop, and each sub-data corresponding to the test command can be obtained respectively by looping based on the target callback function. In order to flexibly and reasonably use memory resources, a memory space of a set size can be pre-configured for the test command (for ease of description, it is called the second memory space, which can also be called buf size, or WatchCmdAck response structure memory), wherein the application does not specifically limit the size of the second memory space, and it can be flexibly set according to demand. For example, the initial size of the second memory space can be 256K, etc. For each sub-data obtained, the sub-data can be saved in the second memory space.
[0160] In one possible implementation, when each sub-data corresponding to the test command is obtained based on the target callback function and each sub-data is successfully saved in the second memory space, the loop of the target callback function can be jumped out, and the server 12 can perform the step of returning the data information corresponding to the test command to the client 11, which is not repeated here.
[0161] In a possible implementation, for each acquired sub-data, when saving the sub-data to the second memory space, if the server 12 finds that the data size of the sub-data exceeds the remaining storage space size of the second memory space, each sub-data of the test command can be saved by expanding the second memory space. Specifically, the server 12 can reconfigure a memory space larger than the second memory space for the test command according to the size of the second memory space (for ease of description, referred to as the third memory space), and can re-execute the target callback function again to save each sub-data of the test command to the third memory space. Among them, the present application does not specifically limit the size of the memory space increased by the third memory space compared to the second memory space. For example, the third memory space can be a set multiple of the second memory space (such as 2 times, etc.), and the third memory space can also be 256K larger than the second memory space. The space size can be set, which can be flexibly set according to demand.
[0162] In a possible implementation, when reconfiguring the third memory space corresponding to the test command, the size of the memory space (second memory space) currently configured for the test command can be updated according to the size of the third memory space, that is, the memory space currently configured for the test command can be updated from the second memory space to the third memory space. If the number of sub-data acquired by the target callback function increases subsequently, for a certain sub-data, if the data size of the sub-data exceeds the remaining storage space size of the memory space (second memory space) currently configured for the test command when storing the sub-data, the above-mentioned expansion process of the second memory space can be performed again. That is, if the total length (date length) of the data information of the acquired test command exceeds the size (buf size) of the second memory space, the above-mentioned expansion process of the second memory space can be performed again.
[0163] Since the present application targets each sub-data corresponding to a test command, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, the server can reconfigure a third memory space with a larger space for the test command based on the size of the second memory space, and save each sub-data of the test command into the third memory space, thereby flexibly and reasonably utilizing memory resources and improving test accuracy.
[0164] In a possible implementation, considering that if the size of the data information of the test command is too large, there may be some anomalies and may also cause some pressure on data transmission. Before each expansion process of the second memory space, the server 12 can determine whether the number of times the memory space is reconfigured for the test command exceeds the set number threshold. If it has not exceeded the set number threshold, the expansion process of the third memory space corresponding to the reconfiguration test command can be performed. If the number of times the memory space is reconfigured for the test command exceeds the set number threshold, the expansion process can no longer be performed. A prompt message of data acquisition failure can be directly sent to the client 11, the test process ends, and the short connection with the client 11 is disconnected to release (recycle) resources in time. Among them, the prompt message of data acquisition failure may include the total number of times the above expansion process is performed for the test command (expansion times), the size of the memory space for the last expansion, and other information, which is not specifically limited in this application. The set number threshold can be flexibly set according to demand. For example, the number threshold can be 10 times, etc., which is not specifically limited in this application.
[0165] Since the present application can determine whether the number of times the memory space is reconfigured for the test command exceeds a set threshold before reconfiguring the memory space for the test command, if it does not exceed the set threshold, the memory space corresponding to the test command is expanded, and if it exceeds the set threshold, the memory space corresponding to the test command is no longer expanded, and a prompt message indicating that data acquisition failure has occurred is directly sent to the client to end the test process. This can improve test accuracy and efficiency on the basis of maximizing the rational use of memory space.
[0166] For ease of understanding, the test process provided by this application is explained below through a specific embodiment. Figure 5 , Figure 5 Another test process schematic diagram provided by some embodiments is shown, and the process includes the following steps:
[0167] S501: The client receives a test command for the server and sends a short connection request to the server.
[0168] S502: The server accepts the short connection request from the client based on the monitoring coroutine and establishes a short connection with the client.
[0169] S503: The client sends a test command to the server.
[0170] S504: When the server receives the test command sent by the client based on the transceiver communication coroutine and obtains the data information corresponding to the test command, it can perform loop processing based on the target callback function to obtain each sub-data corresponding to the test command respectively; for each sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, and the number of times the memory space is reconfigured for the test command does not exceed the number threshold, then the third memory space corresponding to the test command can be reconfigured according to the size of the second memory space, wherein the third memory space is larger than the second memory space, and the target callback function is re-executed to save each sub-data in the third memory space. After that, the acquired data information corresponding to the test command can be returned to the client.
[0171] S505: The client receives the data information and disconnects the short connection with the server.
[0172] S506: The server releases the corresponding sending and receiving communication coroutines and disconnects the short connection with the client.
[0173] Embodiment 4:
[0174] For ease of understanding, the test process provided by this application is explained below through a specific embodiment. Figure 6 , Figure 6 A schematic diagram of another test process provided in an embodiment of the present application, the process includes the following steps:
[0175] S600A: When the client receives the test command, it can perform a preliminary check on the test command. Specifically, the client can parse the server IP address (-I parameter), the Port port (-P parameter) of the Socket connection, the log save path (-L parameter), the command keyword (-c parameter), the command parameter (-a parameter), etc. contained in the test command based on the parameter parsing function, and can save the corresponding parameter values in the WatchCmdParam global structure. After that, the parameter parsing function in the client can parse and fill the WatchCmdReq structure according to the WatchCmdParam global structure, and extract (fill) the command keyword (-c parameter) and the command parameter (-a parameter). When performing a preliminary check on the test command, it can be determined whether the parameter information in the test command contains preset illegal characters. If the test command contains preset illegal characters, a prompt message indicating that the test command is not compliant can be output. If the test command does not contain preset illegal characters, it can be preliminarily considered that the test command is compliant, and the client can start (initialize) recording the client's operation log to facilitate subsequent problem location.
[0176] S600B: During the startup process, the server can initialize the process environment and initialize the command hash table. As each business process is started, the command keywords, command parameters, processing functions (callback functions), etc. pre-registered for each business can be imported into the command hash table. In a possible implementation, the server provides a unified interface in the form of a watch microservice for each business port to call. Applicable command keywords, command parameters, and callback functions (processing functions) can be configured (registered) for each business, thereby improving the flexibility of the test process. At the same time, the server can also initialize the thread pool and the memory pool (also called the WatchCmdAck response structure memory pool) for caching (saving) the data information (echo information) of the test command. The server supports concurrent processing of multiple test processes, such as the default concurrent processing of 32 test processes. The server can create an FD and listen to short connection requests from the client. Exemplarily, the server can start (deliver) a resident connection acceptance coroutine (listening coroutine) to wait (listen) for connection requests (short connection requests) from the client in a non-blocking loop at a set time interval (e.g., every 10ms).
[0177] S601: The client may create a file descriptor (FD) and send a short connection request to the server.
[0178] Among them, FD is mainly used to handle the connection and data exchange between the client and the server. Through FD, the client can establish a stable communication channel with the server to perform data read and write operations. Specifically, when the client sends a short connection request to the server, it can first initialize the Socket connection, create a Socket based on the parsed IP address and Port number, and initiate a short connection (connet) request to the business process server with the same port number. At the same time, the client can identify the command keywords, command parameters and other information carried in the test command according to the preset command keywords, command parameters and other field identifiers.
[0179] S602: After monitoring (receiving) a short connection request from the client, the server may establish a Socket short connection with the client.
[0180] The server can initialize the Transmission Control Protocol (TCP) Socket of the server according to the different port numbers allocated to each business process, and establish a short Socket connection with the client based on the TCP Socket. The server can be configured to make the Socket reusable, non-blocking, and listen to short connection requests from clients of all IP addresses, which will not be described in detail here.
[0181] S603: After establishing a short connection with the client, the server can start (deliver) a temporary communication coroutine (transceiver communication coroutine). If the test command sent by the client is not received within the set time after the short connection is established with the client, a command reception failure prompt message can be sent to the client, and the temporary communication coroutine can be released to disconnect the short connection with the client. Among them, the listening coroutine (also known as the resident receiving connection coroutine or the resident listening connection coroutine) and the temporary communication coroutine can both be non-blocking background operations, and the number of transceiver communication coroutines can be multiple, supporting concurrent processing of multiple test processes, which will not be repeated here.
[0182] If the server receives a test command sent by the client based on the temporary communication coroutine within the set time after establishing a short connection with the client, the server can parse the command keywords, command parameters and other information contained in the test command based on the temporary communication coroutine, and determine whether the test command is a compliant command, for example, determine whether the command keywords, command parameters, etc. in the test command are the command keywords and command parameters in the compliant command set corresponding to the corresponding business. If so, the step of obtaining the corresponding data information of the test command can be performed. Otherwise, it can be considered that the test command is not a compliant command, and a prompt message indicating that the command is not compliant can be sent to the client, and the temporary communication coroutine can be released to disconnect the short connection with the client.
[0183] When obtaining data information corresponding to the test command, the server may determine the target callback function corresponding to the command keyword in the test command according to the pre-saved correspondence between the command keyword and the callback function; and obtain data information corresponding to the test command based on the target callback function.
[0184] Among them, based on the target callback function, in the process of obtaining the data information corresponding to the test command, the expansion process introduced in the above embodiment can also be performed, that is: based on the target callback function, each sub-data corresponding to the test command is obtained separately; for each sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, and the number of times the memory space is reconfigured for the test command does not exceed the set number threshold, the third memory space corresponding to the test command can be reconfigured according to the size of the second memory space, wherein the third memory space is larger than the second memory space; each sub-data corresponding to the test command is saved in the third memory space, which will not be repeated here.
[0185] S604: After the server obtains the data information corresponding to the test command, it can send the data information to the client.
[0186] S605: The client receives the data information sent by the server.
[0187] Among them, when the client receives data information, it can receive the data length (data header) and echo data in a non-blocking manner in two steps. The first step is to receive the data header in the data information. If the first reception of the data header information is successful, first determine whether the error code identifier in the data header is 0. If the error code is not 0, it can be considered that the server processing failed and returned an error, and the corresponding error information and error code can be printed for user reference. If the error code is 0, it can be considered that the server processing was successful without returning an error, and the client's system memory (first memory space) can be allocated as a cache according to the data length in the data header, and then the second step is to receive the echo data (also called the echo information string) sent by the server. In other words, the server sends the data header + data information at a time, and the client receives the data header first and then receives the data information. Among them, the data header (also called the confirmation character, Acknowledge character, ACK header) may include information such as data length, error code identifier, echo information cache first address pointer, etc., and this application does not make specific restrictions on this.
[0188] If the client fails to receive data information sent by the server within a set time after establishing a short connection with the server, it can send a data reception failure prompt message to the server and disconnect the short connection with the server.
[0189] S606: After receiving the data and printing and displaying the data, the client can disconnect the short connection with the server to release and recycle resources in time.
[0190] S607: After the server recognizes that the client has disconnected the short connection, it can release the temporary communication coroutine, and then disconnect the short connection with the client, so as to release and recycle resources in time.
[0191] In addition, both the client and the server can provide logging functions to log the command issuance process, short connection establishment process, and information sending and receiving process, which is convenient for subsequent review and problem location.
[0192] In the embodiment of the present application, the service testing process can be completed by establishing a short Socket connection between the server and the client, so as to achieve the purpose of quickly and flexibly monitoring, debugging, fault injection, and automatic test script verification of the service on the server. In addition, the test method provided by the present application can be used as a very efficient test method to test the service function in each stage of the development, debugging, and maintenance of each service function module.
[0193] Embodiment 5:
[0194] Based on the same technical concept, on the basis of the above embodiments, the present application provides a testing method, which is applied to the server. Figure 7A schematic diagram of another test process provided in the embodiment of the present application is as follows: Figure 7 As shown, the process includes:
[0195] S701: receiving a short connection request sent by a client, and establishing a short connection with the client;
[0196] S702: receiving a test command sent by the client, acquiring data information corresponding to the test command, and returning the data information to the client;
[0197] S703: Disconnect the short connection with the client.
[0198] In a possible implementation, after receiving the test command sent by the client and before acquiring data information corresponding to the test command, the method further includes:
[0199] Determining whether the test command is a compliance command;
[0200] If yes, then proceed to the step of obtaining data information corresponding to the test command;
[0201] If not, a prompt message indicating that the command is not compliant is sent to the client, and the short connection with the client is disconnected.
[0202] In a possible implementation, after establishing the short connection with the client, the method further includes:
[0203] If the test command sent by the client is not received within the set time after the short connection is established with the client, a command reception failure prompt message is sent to the client, and the short connection with the client is disconnected.
[0204] In a possible implementation, the acquiring data information corresponding to the test command includes:
[0205] Determine the target callback function corresponding to the command keyword in the test command according to the pre-saved correspondence between the command keyword and the callback function;
[0206] Based on the target callback function, data information corresponding to the test command is obtained.
[0207] In a possible implementation, obtaining data information corresponding to the test command based on the target callback function includes:
[0208] Based on the target callback function, obtaining each sub-data corresponding to the test command respectively;
[0209] For each of the sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, reconfigure the third memory space corresponding to the test command according to the size of the second memory space, wherein the third memory space is larger than the second memory space;
[0210] Each sub-data is saved in the third memory space.
[0211] In a possible implementation, for each sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, before reconfiguring the third memory space corresponding to the test command, the method further includes:
[0212] Determine whether the number of times the memory space is reconfigured for the test command exceeds a set number threshold;
[0213] If not, then performing a step of reconfiguring the third memory space corresponding to the test command;
[0214] If so, a prompt message indicating that data acquisition failed is sent to the client.
[0215] Based on the same technical concept, on the basis of the above embodiments, the present application provides a testing method, which is applied to the client. Figure 8 Another test process schematic diagram provided in the embodiment of the present application is as follows: Figure 8 As shown, the process includes:
[0216] S801: receiving a test command for a server, and sending a short connection request to the server;
[0217] S802: Sending the test command to the server based on the short connection established between the server and the client;
[0218] S803: Receive data information corresponding to the test command returned by the server, and disconnect the short connection with the server.
[0219] In a possible implementation, the receiving data information corresponding to the test command returned by the server includes:
[0220] receiving a data header in the data information, and allocating a corresponding first memory space for the data information in the client according to a data length in the data header;
[0221] In one possible implementation, after receiving the test command for the server and before sending the short connection request to the server, the method further includes:
[0222] Determine whether the test command contains any illegal characters;
[0223] If yes, a prompt message indicating that the test command is not compliant is output;
[0224] If not, the step of sending a short connection request to the server is performed.
[0225] In a possible implementation, after sending the test command to the server based on the short connection established between the server and the client, the method further includes:
[0226] If the data information sent by the server is not received within the set time after the short connection is established with the server, a data reception failure prompt message is sent to the server, and the short connection with the server is disconnected.
[0227] Embodiment 6:
[0228] Based on the same technical concept, on the basis of the above embodiments, the present application provides a testing device, which is applied to the server. Fig. 9 A schematic diagram of a test device structure provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the device comprises:
[0229] The connection module 901 is used to receive a short connection request sent by a client and establish a short connection with the client;
[0230] The acquisition module 902 is used to receive the test command sent by the client, acquire the data information corresponding to the test command, and return the data information to the client;
[0231] The disconnection module 903 is used to disconnect the short connection with the client.
[0232] In a possible implementation, the acquisition module 902 is further configured to:
[0233] Determine whether the test command is a compliant command, and if so, perform a step of obtaining data information corresponding to the test command.
[0234] In a possible implementation, the disconnection module 903 is further configured to:
[0235] If the test command is not a compliant command, a prompt message indicating that the command is not compliant is sent to the client, and the short connection with the client is disconnected.
[0236] In a possible implementation, the disconnection module 903 is further configured to:
[0237] If the test command sent by the client is not received within the set time after the short connection is established with the client, a command reception failure prompt message is sent to the client, and the short connection with the client is disconnected.
[0238] In a possible implementation, the acquisition module 902 is specifically configured to:
[0239] Determine the target callback function corresponding to the command keyword in the test command according to the pre-saved correspondence between the command keyword and the callback function;
[0240] Based on the target callback function, data information corresponding to the test command is obtained.
[0241] In a possible implementation, the acquisition module 902 is specifically configured to:
[0242] Based on the target callback function, obtaining each sub-data corresponding to the test command respectively;
[0243] For each of the sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, reconfigure the third memory space corresponding to the test command according to the size of the second memory space, wherein the third memory space is larger than the second memory space;
[0244] Each sub-data is saved in the third memory space.
[0245] In a possible implementation, the acquisition module 902 is further configured to:
[0246] Determine whether the number of times the memory space is reconfigured for the test command exceeds a set number threshold;
[0247] If not, then performing a step of reconfiguring the third memory space corresponding to the test command;
[0248] If so, a prompt message indicating that data acquisition failed is sent to the client.
[0249] Based on the same technical concept, on the basis of the above embodiments, the present application provides a testing device, which is applied to a client. Fig.10 Another structural diagram of a test device provided in an embodiment of the present application is shown in FIG. Fig.10As shown, the device comprises:
[0250] The request module 1001 is used to receive a test command for the server and send a short connection request to the server;
[0251] A sending module 1002, configured to send the test command to the server based on the short connection established between the server and the client;
[0252] The receiving module 1003 is used to receive the data information corresponding to the test command returned by the server, and disconnect the short connection with the server.
[0253] In a possible implementation, the receiving module 1003 is specifically configured to:
[0254] receiving a data header in the data information, and allocating a corresponding first memory space for the data information in the client according to a data length in the data header;
[0255] Receive data in the data information, and save the data in the first memory space.
[0256] In a possible implementation, the request module 1001 is further configured to:
[0257] Determine whether the test command contains any illegal characters;
[0258] If yes, a prompt message indicating that the test command is not compliant is output;
[0259] If not, the step of sending a short connection request to the server is performed.
[0260] In a possible implementation, the receiving module 1003 is further configured to:
[0261] If the data information sent by the server is not received within the set time after the short connection is established with the server, a data reception failure prompt message is sent to the server, and the short connection with the server is disconnected.
[0262] Embodiment 7:
[0263] Based on the same technical concept, the present application also provides an electronic device, Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig.11 As shown, it includes: a processor 1101, a communication interface 1102, a memory 1103 and a communication bus 1104, wherein the processor 1101, the communication interface 1102, and the memory 1103 communicate with each other through the communication bus 1104;
[0264] The memory 1103 stores a computer program, and when the program is executed by the processor 1101, the processor 1101 implements any of the above embodiments. Since the principle of solving the problem by the electronic device is similar to the testing method, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0265] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0266] The communication interface 1102 is used for communication between the above electronic device and other devices.
[0267] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0268] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0269] Embodiment 8:
[0270] Based on the same technical concept, the embodiment of the present application provides a computer-readable storage medium, in which a computer program executable by an electronic device is stored, and when the program is run on the electronic device, the electronic device implements any of the above embodiments when executing. Since the principle of solving the problem by the computer-readable storage medium is similar to that of the test method, the implementation of the computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0271] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CD, DVD, BD, HVD, etc., and semiconductor storage such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD), etc.
[0272] Based on the same technical concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the above embodiments. Since the principle of solving the problem by the above computer program product is similar to that of the test method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0273] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0274] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0275] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0276] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0277] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A testing system, characterized in that: The system comprises: The client is used to receive a test command for the server and send a short connection request to the server; The server is used to accept the short connection request and establish a short connection with the client; The client is further used to send the test command to the server; The server is further configured to receive the test command, obtain data information corresponding to the test command, and return the data information to the client; The client is further used to receive the data information and disconnect the short connection with the server; The server is also used to disconnect the short connection with the client.
2. The system according to claim 1, characterized in that The server is also used for: Determining whether the test command is a compliance command; If yes, then proceed to the step of obtaining data information corresponding to the test command; If not, a prompt message indicating that the command is not compliant is sent to the client, and the short connection with the client is disconnected.
3. The system according to claim 1, characterized in that The client is specifically used for: receiving a data header in the data information, and allocating a corresponding first memory space for the data information in the client according to a data length in the data header; Receive data in the data information, and save the data in the first memory space.
4. The system according to claim 1, characterized in that The server is also used for: If the test command sent by the client is not received within the set time after the short connection is established with the client, a command reception failure prompt message is sent to the client, and the short connection with the client is disconnected.
5. The system according to claim 1, characterized in that The server is specifically used for: Determine the target callback function corresponding to the command keyword in the test command according to the correspondence between the pre-registered command keyword and the callback function; Based on the target callback function, data information corresponding to the test command is obtained.
6. The system according to claim 5, characterized in that The server is specifically used for: Performing loop processing based on the target callback function to obtain each sub-data corresponding to the test command respectively; For each of the sub-data, if the data size of the sub-data exceeds the remaining storage space size of the second memory space currently configured for the test command, reconfigure the third memory space corresponding to the test command according to the size of the second memory space, wherein the third memory space is larger than the second memory space; Each sub-data is saved in the third memory space.
7. The system according to claim 6, characterized in that The server is also used for: Determine whether the number of times the memory space is reconfigured for the test command exceeds a set number threshold; If not, then performing a step of reconfiguring the third memory space corresponding to the test command; If so, a prompt message indicating that data acquisition failed is sent to the client.
8. The system according to claim 1, characterized in that The client is also used for: Determine whether the test command contains any illegal characters; If yes, a prompt message indicating that the test command is not compliant is output; If not, the step of sending a short connection request to the server is performed.
9. The system according to claim 1, characterized in that The client is also used for: If the data information sent by the server is not received within the set time after the short connection is established with the server, a data reception failure prompt message is sent to the server, and the short connection with the server is disconnected.
10. A testing method, characterized in that: The method comprises: Receiving a short connection request sent by a client, and establishing a short connection with the client; Receive the test command sent by the client, obtain data information corresponding to the test command, and return the data information to the client; Disconnect the short connection with the client.