Disclosure of Invention
Aiming at the problems in the related art, the invention provides a cluster remote communication test method and a cluster remote communication test system, which can simulate the complete process of Websocket communication between a user browser and a cluster client.
The technical scheme of the invention is realized as follows:
according to an aspect of the present invention, there is provided a cluster telecommunication testing method, including:
the method comprises the steps that a Jmeter client side obtains a websocket connection Token from a server side, wherein the websocket connection Token comprises cluster user identity information of a login user;
after receiving a websocket connection Token returned by the server, the Jmeter client initiates a websocket connection request to the server, wherein the websocket connection Token is used as a request parameter of the websocket connection request;
the server establishes a websocket connection in response to the websocket connection request and transmits a channel ID and cluster user information of the established websocket connection to the Jmeter client,
after a Jmeter client side initiates an HTTP request for logging in a cluster client side, a server side initiates a cluster user login instruction according to cluster user information;
and the server returns the execution result of the login executed by the cluster client to the Jmeter client according to the channel ID.
According to the embodiment of the invention, the server side also returns the login result to the Jmeter client side through HTTP.
According to the embodiment of the invention, the server comprises a web server and a websocket server, wherein the web server returns websocket connection Token to the Jmeter client, the websocket server establishes websocket connection in response to a websocket connection request, and the websocket server initiates a cluster user login instruction and returns an execution result.
According to the embodiment of the invention, after the Jmeter client receives the websocket connection Token, whether the web server responds correctly is judged according to the received corresponding parameters, and if the web server responds correctly, the websocket connection Token is extracted from the corresponding parameters.
According to another aspect of the present invention, there is provided a cluster telecommunication test system, comprising a meter client, a server and a cluster client, wherein: the method comprises the steps that a Jmeter client side obtains a websocket connection Token from a server side, wherein the websocket connection Token comprises cluster user identity information of a login user; after receiving a websocket connection Token returned by the server, the Jmeter client initiates a websocket connection request to the server, wherein the websocket connection Token is used as a request parameter of the websocket connection request; the server side responds to the websocket connection request to establish websocket connection and sends a channel ID and cluster user information of the established websocket connection to the Jmeter client side, and after the Jmeter client side initiates an HTTP request for logging in the cluster client side, the server side initiates a cluster user login instruction according to the cluster user information; and the server returns the execution result of the login executed by the cluster client to the Jmeter client according to the channel ID.
According to the embodiment of the invention, the server side also returns the login result to the Jmeter client side through HTTP.
According to the embodiment of the invention, the server comprises a web server and a websocket server, wherein the web server returns websocket connection Token to the Jmeter client, the websocket server establishes websocket connection in response to a websocket connection request, and the websocket server initiates a cluster user login instruction and returns an execution result.
According to the embodiment of the invention, after the Jmeter client receives the websocket connection Token, whether the web server responds correctly is judged according to the received corresponding parameters, and if the web server responds correctly, the websocket connection Token is extracted from the corresponding parameters.
According to the invention, the Jmeter is used for simulating the interaction between the user browser and the cluster client, so that the complete process of Websocket communication between the user browser and the cluster client can be smoothly simulated. In the complex process of establishing WebSocket communication, whether each step is normally completed or not can be independently monitored. The effect of more accurate positioning problem is achieved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present invention.
The invention provides an automatic executable test method for a real-time interaction process of a specific cluster client and a user browser through WebSocket. The method transmits through the middle server, establishes long connection through Websocket protocol, and transmits data through the connection after mutual authentication between the server and the cluster client as well as between the server and the user browser. The testing method provided by the invention selects a Jmeter (Java-based pressure testing tool) as a testing tool, and uses the Jmeter to simulate the interaction between a user browser and a cluster client. FIG. 1 is a flow chart of a cluster telecommunication testing method according to an embodiment of the present invention.
It should be noted that the communication subject involved in the testing process of the present invention includes a user browser, a server and a cluster client. The user logged in from the user browser end has a corresponding cluster user on the cluster. When the cluster normally works, the established WebSocket long connection exists between the cluster client and the server. As shown in fig. 1, the cluster telecommunication test method of the present invention may include the steps of:
s11, the Jmeter client acquires a websocket connection Token (Token) from the server, wherein the Token comprises the cluster user identity information of the login user.
S12, after receiving a Token returned by the server, the Jmeter client initiates a websocket connection request to the server, wherein the Token is used as a request parameter of the websocket connection request;
s13, the server establishes the websocket connection in response to the websocket connection request and sends the channel ID and the cluster user information of the established websocket connection to the Jmeter client. Wherein, a Client ID (the Client ID may be abbreviated as CID) may be transmitted to the meter Client, and the channel ID and the cluster user information are included in the CID. Thus, a direct WebSocket long connection between the Jmeter client and the server is established.
S14, after the Jmeter client initiates the HTTP request of logging in the cluster client, the server initiates a cluster user login instruction according to the cluster user information;
s15, the server side returns the execution result of the cluster client side executing login to the Jmeter client side according to the channel ID. Wherein, the Netty framework can be adopted to write the server and the cluster client. Thus, indirect WebSocket communication between the meter client and the cluster client is established.
According to the technical scheme, the Jmeter is used for simulating the interaction between the user browser and the cluster client, so that the complete process of Websocket communication between the user browser and the cluster client can be smoothly simulated. In the complex process of establishing WebSocket communication, whether each step is normally completed or not can be independently monitored. The effect of more accurate positioning problem is achieved.
Fig. 2 is a flow chart of a cluster telecommunication testing method according to another embodiment of the present invention. In the embodiment shown in fig. 2, the Server is specifically divided into two parts, namely a Web Server and a WebSocket Server. In this embodiment, the specific process of the test method of the present invention is as follows:
the method comprises the steps that 1, a Jmeter client obtains WebSocket connection Token from a Web Server of a Server through an HTTP interface. The Token comprises the identity information of the cluster user corresponding to the login user in the meter client.
2. The Web Server of the Server side receives the request of the Jmeter client side, queries the corresponding cluster user of the login user of the Jmeter client side in the database, generates a string of Token with cluster user information, and returns the string of Token with the cluster user information to the Jmeter client side. In the meter, whether the Web Server responds correctly or not can be judged according to the received response parameters, and if the Web Server is judged to be correct, a post processor-regular expression extractor can be used in the meter to extract Token in the response parameters.
And 3, after receiving the WebSocket connection Token returned by the Web Server, the Jmeter client initiates a WebSocket connection request to the WebSocket Server of the Server and attaches the Token extracted in the step 2 as a request parameter.
And 4, after receiving the WebSocket connection request sent by the Jmeter client, the WebSocket Server verifies Token, establishes WebSocket connection after the verification is passed, and sends CID to the Jmeter client, wherein the CID contains the channel ID and the cluster user information of the WebSocket connection established by the WebSocket Server and the Jmeter client. Similarly, in the meter client, whether the WebSocket Server responds correctly or not can be judged according to the received response parameters, and if the WebSocket Server is judged to be correct, a post-processor-regular expression extractor can be used in the meter to extract the CID in the response parameters.
And at this moment, establishing the direct WebSocket long connection between the Jmeter client and the server.
And 5, initiating an HTTP request for logging in the cluster client by the Jmeter client, and attaching the CID obtained in the step 4. After receiving the request, the Web Server transmits a message to the WebSocket Server inside the Server. And the WebSocket Server receives the message and initiates a cluster user login instruction appointed in the CID to the cluster client.
6. And the cluster client executes login and returns an execution result to the WebSocket Server through the WebSocket. And the WebSocket Server returns the execution result to the Jmeter client through the specified channel according to the WebSocket channel ID established with the Jmeter client in the CID. Similarly, in the meter, whether the cluster client correctly executes the login instruction or not can be judged according to the received response parameters, and a result is returned. And, when the login result reaches the Server side, the Web Server also returns the login result to the Jmeter client through HTTP.
And establishing indirect communication between the Jmeter client and the WebSocket of the cluster client.
In summary, the testing method provided by the invention can smoothly simulate the complete process of Websocket communication between the user browser and the cluster client. In the complex process of establishing WebSocket communication, whether each step is normally completed or not can be independently monitored, so that the effect of more accurately positioning the problem is achieved. Moreover, the use case of the test method provided by the invention can be integrated into an integration tool such as Jenkins and the like, can be automatically executed at regular time, and realizes daily real-time monitoring of the function.
According to an embodiment of the present invention, there is also provided a cluster telecommunication testing system, including a meter client, a server, and a cluster client, wherein: the method comprises the steps that a Jmeter client side obtains websocket connection Token from a server side, wherein the Token comprises cluster user identity information of login users; after receiving a Token returned by the server, the Jmeter client initiates a websocket connection request to the server, wherein the Token is used as a request parameter of the websocket connection request; the server side responds to the websocket connection request to establish websocket connection and sends a channel ID and cluster user information of the established websocket connection to the Jmeter client side, and after the Jmeter client side initiates an HTTP request for logging in the cluster client side, the server side initiates a cluster user login instruction according to the cluster user information; and the server returns the execution result of the login executed by the cluster client to the Jmeter client according to the channel ID.
The test system provided by the invention can smoothly simulate the complete process of Websocket communication between the user browser and the cluster client. In the complex process of establishing WebSocket communication, whether each step is normally completed or not can be independently monitored, so that the effect of more accurately positioning the problem is achieved.
According to the embodiment of the invention, the server side also returns the login result to the Jmeter client side through HTTP.
According to the embodiment of the invention, the server comprises a web server and a websocket server, wherein the web server returns Token to the Jmeter client, the websocket server establishes websocket connection in response to a websocket connection request, and the websocket server initiates a cluster user login instruction and returns an execution result.
According to the embodiment of the invention, after the meter client receives the Token, whether the web server responds correctly is judged according to the received corresponding parameters, and if the web server responds correctly, the Token is extracted from the corresponding parameters.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.