Server pressure test method and pressure test tool generation method
By obtaining and interpreting test scripts, converting them into server-side control instructions, and integrating communication protocols, the problem of inability to adapt to server-side changes in the existing technology is solved, and stress testing is realized for different servers, reducing costs and expanding the scope of use. .
Patent Information
- Application Number
- CN202411315359.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing server stress testing tools cannot adapt to server changes, have high usage costs and narrow usage range, so customized testing cannot be carried out for different servers.
Provide a server's stress testing method and generation method. By obtaining test scripts, interpreting and converting them into server-side control instructions, testing using pre-specified communication protocols, and integrating communication protocols into databases to achieve protocol conversion capabilities. , bind script interpreter to support multi-server testing.
Targeted stress testing is implemented according to different servers, reducing the cost of use, expanding the scope of use of test tools, and adapting to changes on the server.
Smart Images

Figure CN119276745A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of server stress testing, and in particular to a server stress testing method and a method for generating a stress testing tool. Background Art
[0002] In the operation of online games, there will be tens of thousands of users accessing the game server at the same time. The server may respond slowly or crash due to excessive load pressure, which seriously affects the user's gaming experience. Therefore, in the process of online game development, server stress testing is a very important link.
[0003] Existing stress testing tools are all developed using static languages, and they need to be recompiled each time they are tested on different games (servers). This is costly and cannot be customized. In addition, existing stress testing tools are integrated inside the server and can only be called by logging into the server and entering different commands, so their scope of use is narrow. Summary of the invention
[0004] The main technical problem solved by the present application is to provide a server stress testing method and a method for generating a stress testing tool, which can improve the problem that the stress testing methods and tools in the prior art cannot adapt to changes on the server side.
[0005] In order to solve the above technical problems, the present application provides a server stress testing method, which runs a server to be tested. The testing method includes: obtaining a test script; interpreting the test script; converting the interpretation content of the test script into a control instruction recognizable by the server according to a pre-specified communication protocol corresponding to the server; and sending the control instruction to the server.
[0006] To solve the above technical problems, the present application also provides a method for generating a server stress test tool, wherein the server runs a server to be tested. The generation method includes: extracting a communication protocol from the server; integrating the communication protocol into a communication database so that the stress test tool has the protocol conversion capability corresponding to the server; and binding a script interpreter so that the stress test tool has the ability to interpret the test script.
[0007] The beneficial effect of the present application is that, different from the prior art, the present application provides a server stress testing method and a method for generating a stress testing tool, wherein different servers can be tested according to the corresponding communication protocol pre-specified by the server to be tested. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0009] Figure 1 It is a flowchart of a first embodiment of a server stress testing method provided by the present application;
[0010] Figure 2 It is a flow chart of a second embodiment of the server stress testing method provided by the present application;
[0011] Figure 3 It is a flow chart of an embodiment of a method for generating a server stress testing tool provided by the present application. DETAILED DESCRIPTION
[0012] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0013] In the operation of online games, there will be tens of thousands of users accessing the game server at the same time. The server may respond slowly or crash due to excessive load pressure, which seriously affects the user's gaming experience. Therefore, in the process of online game development, server stress testing is a very important link.
[0014] See also Figure 1 , Figure 1 It is a flowchart of the first embodiment of the server stress testing method provided by the present application.
[0015] The server runs a server to be tested, and the test method includes:
[0016] Step 11: Get the test script.
[0017] A test script generally refers to a series of instructions containing test content, which can be executed. A test script is for a test process, and a test process often requires testing a large amount of data. If you need to use a test script to test multiple sets of data, you need to parameterize the test script and modify the fixed constants into variable variables.
[0018] Optionally, the test script includes the test content of an object to be tested, for example, a test script is written for an object to be tested.
[0019] Optionally, the test script includes test contents of multiple objects to be tested, and corresponding contents in the test script are selected according to the test requirements of the objects to be tested. For example, a test script including multiple test contents is written for a type of objects to be tested.
[0020] In this embodiment, a candidate script specified by the user is selected as a test script from a test set including multiple candidate scripts according to the user's specification, wherein the candidate script may include test content of one or a class of objects to be tested. According to the user's specification, if a content test is performed, a corresponding candidate script is selected as a test script from a test set including multiple candidate scripts; if multiple content tests are performed, multiple corresponding candidate scripts are selected as test scripts from a test set including multiple candidate scripts.
[0021] In this embodiment, the test script is located on the test end and is separated from the server end, which is convenient for modifying the test content and testing multiple servers.
[0022] Step 12: Explain the test script.
[0023] Optionally, the server is a game server. In the stress test of the game server, the test content may be a registration stress test, a login stress test, a team stress test, a combat stress test, a copy stress test, etc., or a combination of multiple test contents. The test script may include one or more of the above test contents, which exist in the form of code on the test side. These test contents need to be interpreted so that the user and / or the server side know what is being tested. The interpretation process is completed by the script interpreter.
[0024] Optionally, the test script is a Python script, which is a program code written based on the Python language, and of course it can also be other interpreted computer programming languages. Python is a high-level scripting language that combines interpretation, compilation, interactivity and object-oriented. Since Python is an interpreted language, it means that there is no compilation link in the development process.
[0025] Step 13: Convert the interpretation content of the test script into control instructions recognizable by the server according to a pre-specified communication protocol corresponding to the server.
[0026] Optionally, the server is a game server that provides services to users accessing the server.
[0027] A game corresponds to one or more servers. Users access the server to play the game. In turn, the server runs on the server to provide services to users who access the server. The test script contains one or more test contents, which can be registration, login, team formation, battle, dungeon, etc. These test contents need to be interpreted and converted into control instructions that can be recognized by the server, and then sent to the server based on the communication protocol corresponding to the server, so that they can be accepted and executed by the server.
[0028] Optionally, the control command recognizable by the server is a binary protocol, for example, 0x01 represents user registration, and 0x02 represents logging into the game.
[0029] Optionally, the communication protocol is the sproto protocol, which is a simplified version of the protobuf protocol, and has the characteristics of flexibility (convenient interface update), high efficiency (transmission efficiency is much higher than ordinary XML), ease of use (easily complete serialization and deserialization of business messages), and language support (native support for Python, Java, C++ and other language environments).
[0030] Step 14: Send the control command to the server.
[0031] The server stress test is a process that simulates thousands of users accessing one or more servers. User behavior is the process of accessing the server, such as registration, login, team formation, battle, dungeon, etc. These behaviors can only be achieved by accessing the server, and they are written into the test script in the form of test content. The test content of the test script is interpreted and converted into control instructions that can be recognized by the server. There is a corresponding relationship between these control instructions and user behavior. For example, 0x01 means user registration, and 0x02 means logging into the game. The control instructions are sent to the server, which is the process of users accessing the server. Sending thousands of control instructions to the server means thousands of users accessing the server. In this way, the load pressure that the server can withstand can be tested, that is, it can be simulated how many users access the server, and the server will respond slowly, crash, etc.
[0032] See also Figure 2 , Figure 2 It is a flow chart of the second embodiment of the server stress testing method provided by the present application.
[0033] The server runs a server to be tested, and the test method includes:
[0034] Step 21: Get the test script.
[0035] Step 22: Explain the test script.
[0036] Step 23: Extract the communication protocol from the server.
[0037] In this embodiment, the game can be developed based on the sproto protocol. There is a corresponding relationship between each game and the sproto protocol. The server runs on the server, so that when performing a stress test on the server, the corresponding server can be found by following the sproto protocol, that is, one or more servers running the game to be tested can be found from the many servers on the server.
[0038] Optionally, there are multiple servers running on the server, and the process of extracting the communication protocol from the server may be to extract the communication protocol from the server specified by the user according to the user's designation, or to extract the communication protocols of multiple servers in advance and select the corresponding communication protocol from them according to the user's designation. The above extraction process may be completed manually or automatically by setting a corresponding extraction program.
[0039] For example, there are servers A, B, and C running on the server. To test server A according to the user's specification, server A is found from the server and the corresponding sproto protocol is extracted; or the sproto protocols of servers A, B, and C are extracted in advance, and then the sproto protocol corresponding to server A is selected from them according to the user's specification. If server B needs to be tested according to the user's specification, the conversion from testing server A to testing server B is achieved by switching the sproto protocol, that is, server B is found from the server and the corresponding sproto protocol is extracted; or the sproto protocol corresponding to server B is selected from the sproto protocols of servers A, B, and C extracted in advance. Since there is a corresponding relationship between each game and the sproto protocol, the server runs on the server. In this way, a server running multiple servers to be tested can be stress tested.
[0040] Step 24: Integrate the communication protocol into the communication database.
[0041] Optionally, the communication database is the boost database, which is a portable, source code-provided C++ library.
[0042] In this embodiment, the test script is located at the test end, which is separate from the server end. The test end needs to communicate remotely with the server end and integrate the communication protocol into the communication database so that the communication database can convert the interpretation content into control instructions and send the control instructions.
[0043] Step 25: Convert the interpretation content of the test script into control instructions recognizable by the server according to a pre-specified communication protocol corresponding to the server.
[0044] Step 26: Send the control command to the server.
[0045] In this embodiment, the above test method can be run outside the server, and the control instruction is sent to the server through network communication, thereby avoiding the need to log in to the server and enter different call commands for each test, thereby increasing the scope of use.
[0046] See also Figure 3 , Figure 3 It is a flow chart of an embodiment of a method for generating a server stress testing tool provided by the present application.
[0047] Wherein, the server runs a server to be tested, and the generation method includes:
[0048] Step 31: Extract the communication protocol from the server.
[0049] Optionally, the communication protocol is the sproto protocol, which is a simplified version of the protobuf protocol, and has the characteristics of flexibility (convenient interface update), high efficiency (transmission efficiency is much higher than ordinary XML), ease of use (easily complete serialization and deserialization of business messages), and language support (native support for Python, Java, C++ and other language environments).
[0050] In this embodiment, the game can be developed based on the sproto protocol. There is a corresponding relationship between each game and the sproto protocol. The server runs on the server, so that when performing a stress test on the server, the corresponding server can be found by following the sproto protocol, that is, one or more servers running the game to be tested can be found from the many servers on the server.
[0051] Optionally, there are multiple servers running on the server, and the process of extracting the communication protocol from the server may be to extract the communication protocol from the server specified by the user according to the user's designation, or to extract the communication protocols of multiple servers in advance and select the corresponding communication protocol from them according to the user's designation. The above extraction process may be completed manually or automatically by setting a corresponding extraction program.
[0052] For example, there are servers A, B, and C running on the server. To test server A according to the user's specification, server A is found from the server and the corresponding sproto protocol is extracted; or the sproto protocols of servers A, B, and C are extracted in advance, and then the sproto protocol corresponding to server A is selected from them according to the user's specification. If server B needs to be tested according to the user's specification, the conversion from testing server A to testing server B is achieved by switching the sproto protocol, that is, server B is found from the server and the corresponding sproto protocol is extracted; or the sproto protocol corresponding to server B is selected from the sproto protocols of servers A, B, and C extracted in advance. Since there is a corresponding relationship between each game and the sproto protocol, the server runs on the server. In this way, a server running multiple servers to be tested can be stress tested.
[0053] Step 32: Integrate the communication protocol into the communication database.
[0054] Optionally, the communication database is the boost database, which is a portable, source code-provided C++ library.
[0055] In this embodiment, the test script is located on the test end, which is separate from the server end. The test end needs to communicate remotely with the server end and integrate the communication protocol into the communication database so that the stress testing tool has the protocol conversion capability corresponding to the server end.
[0056] Step 33: Bind the script interpreter.
[0057] In this embodiment, the stress testing tool needs to be bound to a script interpreter so that the stress testing tool has the ability to interpret the test script, that is, to interpret the test script so that the server can recognize the test content contained in the test script.
[0058] Optionally, the test script is a Python script, which is a program code written based on the Python language, and accordingly, the script interpreter is a Python interpreter.
[0059] In this embodiment, the stress testing tool interprets the test content of the test script and converts it into control instructions recognizable by the server, and then sends the control instructions to the server.
[0060] Optionally, the control command recognizable by the server is a binary protocol, for example, 0x01 represents user registration, and 0x02 represents logging into the game.
[0061] In this embodiment, the stress test tool can be run outside the server and send control instructions to the server in the form of network communication, thereby avoiding the need to log in to the server and enter different call commands each time the stress test tool is used, thereby increasing the scope of use.
[0062] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for stress testing a server, wherein the server runs a service end to be tested, characterized in that: The test method includes: Get the test script; Explaining the test script; Converting the interpretation content of the test script into control instructions recognizable by the server according to a pre-specified communication protocol corresponding to the server; The control instruction is sent to the server.
2. The testing method according to claim 1, characterized in that: The step of obtaining the test script includes: According to the user's specification, the candidate script specified by the user is selected from a test set including a plurality of candidate scripts as the test script.
3. The testing method according to claim 1, characterized in that: Before the step of converting the interpretation content of the test script into control instructions recognizable by the server according to a pre-specified communication protocol corresponding to the server, the method further comprises: Extracting the communication protocol from the server; The communication protocol is integrated into a communication database so that the communication database can convert the interpretation content into the control instruction and send the control instruction.
4. The testing method according to claim 3, characterized in that: The server runs a plurality of the service terminals; The step of extracting the communication protocol from the server comprises: Extracting the communication protocol from the server specified by the user according to the user's specification; Alternatively, multiple communication protocols of the server are extracted in advance, and a corresponding communication protocol is selected from them according to the user's designation.
5. The testing method according to claim 3, characterized in that: The communication protocol is the sproto protocol, the communication database is the boost database, and the test script is a Python script.
6. The testing method according to claim 1, characterized in that: The control instruction is sent to the server via network communication.
7. A method for generating a stress test tool for a server, wherein the server runs a service end to be tested, characterized in that: The generation method comprises: Extracting a communication protocol from the server; Integrate the communication protocol into the communication database so that the stress testing tool has the protocol conversion capability corresponding to the server; A script interpreter is bound so that the stress testing tool has the ability to interpret test scripts.
8. The generation method according to claim 7, characterized in that: The communication database after integrating the communication protocol can convert the interpretation content of the test script by the script interpreter into control instructions recognizable by the server and send them to the server.
9. The generation method according to claim 8, characterized in that: The communication protocol is the sproto protocol, the communication database is the boost database, and the test script is a Python script.
10. The generation method according to claim 8, characterized in that: The stress testing tool runs outside the server and sends the control instructions to the service end via network communication.