Method, device and storage medium for testing gateway device

By deploying the master node and child node terminal devices in the LAN, and remotely controlling the child nodes to execute test cases using the remote process call framework, the problems of manual intervention and low efficiency in traditional testing methods are solved, and automated testing and efficient gateway device quality evaluation are realized. .

CN118714059BActive Publication Date: 2024-12-03SICHUAN TIANYI COMHEART TELECOM
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411203674.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-03
Estimated Expiration
2044-08-30

AI Technical Summary

Technical Problem

The traditional PON gateway testing method requires frequent manual intervention, which is difficult to meet the requirements of rapidly developing communication technology for testing efficiency, and lacks automated testing solutions, so it is impossible to effectively evaluate the product quality of gateway equipment.

Method used

By deploying the master node terminal equipment and child node terminal equipment in the LAN, using the remote process call framework to establish a connection channel, remotely controlling the child node terminal equipment to execute preset test cases, and receiving test results to evaluate the product quality of the gateway equipment.

Benefits of technology

It realizes automated control of multiple terminals for testing, improves testing efficiency, reduces manual intervention, and can effectively evaluate the product quality of gateway equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118714059B_ABST
    Figure CN118714059B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and storage medium for testing a gateway device, and the present invention relates to the field of communication network testing technology, wherein the method comprises: establishing a connection thread according to the network address and port information broadcast by the received sub-node terminal device; establishing a connection channel between the main node terminal device and the sub-node terminal device through a preset remote procedure call framework based on the connection thread; calling a test function or a test class method from the sub-node terminal device through the connection channel, and executing a preset test case; receiving a test result corresponding to the preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device. The present invention aims to realize a scheme for automatically controlling multiple terminals to perform tests and obtain the test results of each terminal, thereby improving the test efficiency of the gateway device and reducing manual intervention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of communication network testing, and in particular to a method, device and storage medium for testing gateway equipment. Background Art

[0002] In modern communication networks, PON gateways are important devices for network access, and their performance and functional reliability are crucial. With the expansion of network scale and the increase of business types, testing tasks are becoming increasingly complex, and the defects of traditional methods for testing gateway devices are becoming more and more obvious.

[0003] Traditional methods for testing gateway devices, such as the PON gateway testing method, usually require frequent manual intervention, which is difficult to meet the testing efficiency requirements of gateway devices for the current rapidly developing communication technology. At the same time, there is no solution to test the product quality of gateway devices through multiple terminal automated testing. Summary of the invention

[0004] The main purpose of the present invention is to provide a method, device and storage medium for testing a gateway device, aiming to perform testing tasks for the gateway device by remotely controlling multiple terminals to obtain product quality evaluation results of the gateway device; at the same time, compared with existing testing methods, a solution for automatically controlling multiple terminals for testing and obtaining test results of each terminal is realized, thereby improving the testing efficiency of the gateway device and reducing manual intervention.

[0005] To achieve the above object, the present invention provides a method, which is applied to a master node terminal device in a preset local area network where a gateway device is located, wherein the preset local area network also includes at least two sub-node terminal devices, and a test function corresponding to a preset test case or a test class method corresponding to a preset test case is deployed in the sub-node terminal device, and the preset test case is used to detect the gateway device;

[0006] The method comprises:

[0007] Establishing a connection based on the network address and port information broadcast by the received sub-node terminal device;

[0008] Based on the connection thread, a connection channel between the master node terminal device and the sub-node terminal device is established through a preset remote procedure call framework;

[0009] Calling the test function or the test class method from the sub-node terminal device through the connection channel and executing the preset test case;

[0010] Receive a test result corresponding to a preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device.

[0011] Specifically, before establishing a connection according to the received network address and port information broadcast by the sub-node terminal device, the method further includes:

[0012] Creating a first text file, wherein the first text file is used to represent communication information between the master node terminal device and the sub-node terminal device;

[0013] Parsing the first text file to generate a first code file and a second code file, wherein the first code file is used to represent the data transmission interaction between the master node terminal device and the sub-node terminal device, and the second code file is used to represent the remote call between the master node terminal device and the sub-node terminal device;

[0014] Based on the first code file and the second code file, compile and generate a sub-node terminal device code file and a master node terminal device code file, wherein the sub-node terminal device code file is used to implement the logic of the sub-node terminal device, and the master node terminal device code file is used to implement the logic of the master node terminal device;

[0015] Based on the sub-node terminal device code file and the master node terminal device code file, generate a test execution program corresponding to the preset test case;

[0016] The master node terminal device and the sub-node terminal device are respectively deployed on a master node in a preset local area network and a sub-node in the preset local area network.

[0017] Specifically, the creating a first text file includes:

[0018] Creating an initial first text file;

[0019] Define the message structure and service interface through a preset programming language and generate definition text;

[0020] Based on the initial first text file and the definition text, the first text file is obtained.

[0021] Specifically, the parsing of the first text file to generate a first code file and a second code file includes:

[0022] In response to the preset compilation instruction, the first code file and the second code file are compiled and generated by the compiler of the preset remote procedure call framework.

[0023] Specifically, compiling and generating a sub-node terminal device code file and a master node terminal device code file based on the first code file and the second code file includes:

[0024] Based on the first code file and the second code file, a sub-node terminal device code file is compiled and generated through the preset remote procedure call framework;

[0025] Based on the first code file and the second code file, the master node terminal device code file is compiled and generated through the preset remote procedure call framework.

[0026] Specifically, the compiling and generating the sub-node terminal device code file based on the first code file and the second code file through the preset remote procedure call framework includes:

[0027] Based on the first code file and the second code file, define a service class corresponding to the sub-node terminal device;

[0028] Based on the first code file and the second code file, define a master node terminal device request corresponding to a sub-node terminal device;

[0029] Based on the first code file and the second code file, a startup function is written, where the startup function is used to start a server corresponding to a preset remote procedure call framework;

[0030] Based on the first code file and the second code file, write a registration function, wherein the registration function is used to register the service class on the server;

[0031] Based on the first code file and the second code file, a broadcast function is written, where the broadcast function is used to broadcast the network address of the sub-node terminal device;

[0032] The sub-node terminal device code file is compiled and generated based on the service class, the master node terminal device request and the local network address of the server.

[0033] Specifically, the compiling and generating the master node terminal device code file based on the first code file and the second code file through the preset remote procedure call framework includes:

[0034] Based on the first code file and the second code file, write a receiving function, wherein the receiving function is used to receive the network address of the sub-node terminal device;

[0035] Based on the first code file and the second code file, write a master node terminal device decorator corresponding to the master node terminal device, wherein the master node terminal device decorator is used to encapsulate the connection management logic of the master node terminal device;

[0036] Based on the first code file and the second code file, write a master node terminal device decorator execution function, wherein the master node terminal device decorator execution function is used to use the master node terminal device decorator to process the connection between the master node terminal device and the sub-node terminal device;

[0037] Based on the receiving function, the master node terminal device decorator and the master node terminal device decorator execution function, the master node terminal device code file is compiled and generated.

[0038] Specifically, the generating of the test execution program corresponding to the preset test case based on the sub-node terminal device code file and the master node terminal device code file includes:

[0039] Based on the sub-node terminal device code file and the master node terminal device code file, write and generate a packaging instruction;

[0040] In response to the packaging instruction, the code of the sub-node terminal device code file and the code of the main node terminal device code file are packaged into the test execution program through a preset packaging tool.

[0041] To achieve the above object, the present invention further provides an apparatus for testing a gateway device, which is applied to a master node terminal device in a preset local area network where the gateway device is located, wherein the preset local area network also includes at least two sub-node terminal devices, wherein a test function corresponding to a preset test case or a test class method corresponding to a preset test case is deployed in the sub-node terminal device, and the preset test case is used to detect the gateway device;

[0042] The device comprises:

[0043] The first unit is used to establish a connection thread according to the network address and port information broadcast by the received sub-node terminal device;

[0044] A second unit is used to establish a connection channel between the master node terminal device and the sub-node terminal device through a preset remote procedure call framework based on the connection thread;

[0045] A third unit is used to call the test function or the test class method from the sub-node terminal device through the connection channel and execute the preset test case;

[0046] The fourth unit is used to receive the test result corresponding to the preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device.

[0047] To achieve the above objective, the present invention further provides a storage medium, wherein the storage medium stores a plurality of instructions, wherein the instructions are suitable for loading by a processor to execute the steps in any one of the methods provided by the present invention.

[0048] A method, device and storage medium for testing a gateway device provided by the present invention are applied to a main node terminal device in a local area network where the gateway device is located, wherein the preset local area network also includes at least two sub-node terminal devices, and the sub-node terminal devices are deployed with a test function corresponding to a preset test case or a test class method corresponding to a preset test case, and the preset test case is used to detect the gateway device; the method includes the following contents: first, the main node terminal device creates a connection thread according to the network address broadcast by the received sub-node terminal device; then, based on the connection thread, a connection channel between the main node terminal device and the sub-node terminal device is established through a preset remote procedure call framework; then, through the connection channel, the main node terminal calls the test function or the test class method from the sub-node terminal device and executes the preset test case; finally, a test result corresponding to the preset test case returned by the sub-node terminal device is received, and the test result is used to characterize the product quality of the gateway device.

[0049] The present invention can realize remote control of sub-node terminal devices corresponding to multiple terminals by the main node terminal device to execute test cases by respectively deploying the main node terminal device and the sub-node terminal device on nodes corresponding to different terminals in the local area network, and simulate the topological relationship of the gateway device by presetting the local area network, and finally obtain the test results corresponding to the test cases, and evaluate the product quality of the gateway device through the test results. Compared with the existing testing technology, this testing process realizes a solution for automatically controlling multiple terminals to perform tests and obtain the test results of each terminal, thereby improving the efficiency of testing and reducing manual intervention. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A schematic diagram of a process flow provided by an embodiment of the present invention;

[0051] Figure 2 A test topology diagram provided for an embodiment of the present invention;

[0052] Figure 3 A schematic diagram of the structure of an apparatus for testing a gateway device provided by an embodiment of the present invention;

[0053] Reference numerals: first unit - 301 , second unit - 302 , third unit - 303 , fourth unit - 304 . DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0055] Since traditional multi-terminal testing of gateway devices, represented by the PON gateway testing method, usually requires frequent manual intervention, it is difficult to meet the testing efficiency requirements of gateway devices in the current rapidly developing communication technology.

[0056] Therefore, the embodiments of the present invention provide a method, an apparatus and a storage medium for testing a gateway device to solve practical technical problems.

[0057] In some embodiments, the device may be specifically integrated into an electronic device, and the electronic device may be a terminal, a server, or other device.

[0058] In some embodiments, the server may also be implemented in the form of a terminal.

[0059] Among them, the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.

[0060] The terminal may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, and the present invention does not limit this.

[0061] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.

[0062] An embodiment of the present invention provides a method for testing a gateway device. The method can execute a test task for the gateway device by remotely controlling multiple terminals to obtain a product quality evaluation result of the gateway device. At the same time, compared with existing testing methods, the test efficiency of the gateway device is improved and manual intervention is reduced.

[0063] In some embodiments, the method is applied to a main node terminal device in a preset local area network where a gateway device is located. The preset local area network also includes at least two sub-node terminal devices. Test functions corresponding to preset test cases or test class methods corresponding to preset test cases are deployed in the sub-node terminal devices. The preset test cases are used to detect the gateway device.

[0064] Specifically, the topological relationship of the gateway device under test can be simulated by presetting the arrangement of terminal devices in the local area network, and the preset test cases can be executed by remotely controlling multiple terminal devices to improve the test efficiency, thereby meeting the current large-scale communication testing needs.

[0065] In some embodiments, the gateway device may be a PON gateway, which is a test object of the method. The PON gateway is a product combining software and hardware, and is also a network device for providing network access to users.

[0066] like Figure 1 As shown, the specific process of the method can be as follows:

[0067] S110. Establish a connection thread according to the network address and port information broadcast by the received sub-node terminal device.

[0068] In some embodiments, the sub-node terminal device can automatically broadcast the network address and port information after startup, and the main node terminal device can automatically discover all sub-node terminal devices in the preset local area network after startup. When the main node terminal device receives the network address of one of the sub-node terminal devices, it can create a connection thread until the connection threads corresponding to all sub-node terminal devices are created.

[0069] Specifically, the connection thread is responsible for processing network I / O operations, such as sending requests, receiving responses, etc. The connection thread can be blocking or non-blocking.

[0070] In some embodiments, the sub-node terminal device may create a thread for broadcasting network address and port information, and the master node establishes a connection based on the RPC protocol according to the network address and port broadcast by the received sub-node terminal device.

[0071] S120. Based on the connection thread, a connection channel between the master node terminal device and the sub-node terminal device is established through a preset remote procedure call framework.

[0072] In some embodiments, the preset remote procedure call framework may be a gRPC framework. The gRPC framework is a high-performance, open source, and general remote procedure call (RPC) framework developed and maintained by Google. The gRPC framework is based on the HTTP / 2 protocol and supports multiple programming languages, such as C++, Java, Python, Go, etc. It is widely used in microservice architecture, cloud-native applications, and cross-platform communications.

[0073] S130. Call the test function or the test class method from the sub-node terminal device through the connection channel, and execute the preset test case.

[0074] In some embodiments, a remote procedure call (RPC) can be initiated from a master node terminal device to a sub-node terminal device through the connection channel to execute a test function or a method of a test class and run a preset test case.

[0075] In some embodiments, the test case can be a document written by a person in accordance with the specification requirements provided by the operator. The document describes the test environment, test steps, and test standards. The test is performed according to the case document to check whether the various tests of the gateway device meet the specification requirements.

[0076] S140. Receive a test result corresponding to a preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device.

[0077] In some embodiments, before establishing a connection thread according to the received network address and port information broadcast by the sub-node terminal device, the method further includes steps T110 to T150 as shown below:

[0078] T110. Create a first text file, where the first text file is used to represent communication information between the master node terminal device and the sub-node terminal device.

[0079] In some embodiments, the first text file may be a *.proto file, and the communication protocol is the rules and format agreed upon when computers or devices communicate with each other, which is used to ensure that data can be correctly transmitted and interpreted.

[0080] In some embodiments, the communication protocol represented by the first text file may be the HTTP / 2 protocol (HyperText Transfer Protocol). HTTP / 2 is an important version of the HTTP protocol, which is designed to improve Web performance and optimize user experience. Compared with the previous HTTP / 1.x version, HTTP / 2 has obvious advantages in data transmission efficiency, performance optimization and security.

[0081] In some embodiments, the communication protocol represented by the first text file may also be the TCP / IP protocol (Transmision Control Protocol / Internet Protocol). The TCP / IP protocol is the basic protocol for Internet communication. TCP provides reliable, connection-oriented data transmission, while IP is responsible for addressing and routing data packets in the network.

[0082] In some embodiments, the communication protocol includes a message structure and a service interface.

[0083] Specifically, the message structure is a format and rules followed by both parties of the communication protocol to effectively exchange information. The message structure defines how data is organized, packaged, transmitted, and parsed by the recipient, ensuring the accuracy and efficient transmission of data. The service interface refers to the interface at the software level defined in the communication protocol. The service interface provides a set of rules and methods for applications or systems to access communication services. The service interface enables high-level applications to interact with remote entities through standardized calls without having to worry about the complex communication details of the underlying layer. Through the service interface, the communication protocol hides the complex implementation details of the underlying layer and provides an abstract, easy-to-use communication environment for upper-level applications, thereby simplifying network programming and system integration.

[0084] In some embodiments, the creating of the first text file includes steps T111 to T113 as shown below:

[0085] T111. Create the initial first text file.

[0086] T112. Define the message structure and service interface through the preset programming language and generate the definition text.

[0087] In some embodiments, the service interface and message structure may be defined by the Protocol Buffers (ProtoBuf) language.

[0088] T113. Obtain the first text file based on the initial first text file and the definition text.

[0089] T120. Parse the first text file to generate a first code file and a second code file, wherein the first code file is used to represent the data transmission interaction between the master node terminal device and the sub-node terminal device, and the second code file is used to represent the remote call between the master node terminal device and the sub-node terminal device.

[0090] In some embodiments, the parsing of the first text file to generate the first code file and the second code file includes the following specific process:

[0091] In response to the preset compilation instruction, the first code file and the second code file are compiled and generated by the compiler of the preset remote procedure call framework.

[0092] Specifically, the preset remote procedure call framework may be gRPC, which is a high-performance, open source remote procedure call (RPC) framework developed and released as open source by Google. It aims to simplify and accelerate communication between services in a distributed system.

[0093] The first code file and the second code file may be *_pb2.py and *.pb2_grpc.py files, respectively.

[0094] The compiler of the preset remote procedure call framework can be a protoc compiler, which is a core component in Google's Protocol BufferT serialization framework. After defining .proto files to describe data structures and interfaces, the protoc compiler is needed to convert these .proto files into source code of the target programming language.

[0095] T130. Based on the first code file and the second code file, compile and generate a sub-node terminal device code file and a main node terminal device code file, wherein the sub-node terminal device code file is used to implement the logic of the sub-node terminal device, and the main node terminal device code file is used to implement the logic of the main node terminal device.

[0096] In some embodiments, the compiling and generating of the sub-node terminal device code file and the master node terminal device code file based on the first code file, the second code file and the preset test scenario includes the steps T131 to T132 as shown below:

[0097] T131. Based on the first code file and the second code file, a sub-node terminal device code file is compiled and generated through the preset remote procedure call framework.

[0098] T132. Based on the first code file and the second code file, the master node terminal device code file is compiled and generated through the preset remote procedure call framework.

[0099] Specifically, the sub-node terminal device code file is compiled and generated based on the first code file and the second code file through the preset remote procedure call framework, including the steps T1311 to T1316 as shown below:

[0100] T1311. Based on the first code file and the second code file, define the service class corresponding to the sub-node terminal device.

[0101] In some embodiments, the service class may be defined in gRPC.

[0102] T1312. Based on the first code file and the second code file, define the master node terminal device request corresponding to the sub-node terminal device.

[0103] In some embodiments, the processing logic of the main node terminal device request can be implemented by writing the sub-node terminal device code, including extracting the function name and parameters.

[0104] T1313. Based on the first code file and the second code file, write a startup function, where the startup function is used to start a server corresponding to a preset remote procedure call framework.

[0105] In some embodiments, the gRPC server can be started by writing code.

[0106] T1314. Based on the first code file and the second code file, write a registration function, where the registration function is used to register the service class on the server.

[0107] In some embodiments, the service class may be registered with the server and the server may be started on a specified port.

[0108] T1315. Based on the first code file and the second code file, write a broadcast function, where the broadcast function is used to broadcast the network address of the sub-node terminal device.

[0109] In some embodiments, a UDP socket can be used by writing a function and configured in broadcast mode to obtain a local network address and send messages through a broadcast loop so that the master node terminal device can obtain the network address of the sub-node terminal device.

[0110] T1316. Compile and generate the sub-node terminal device code file based on the service class, the master node terminal device request and the local network address of the server.

[0111] Specifically, based on the first code file and the second code file, the master node terminal device code file is compiled and generated through the preset remote procedure call framework, including the steps T1321 to T1324 as shown below:

[0112] T1321. Based on the first code file and the second code file, write a receiving function, where the receiving function is used to receive the network address of the sub-node terminal device.

[0113] In some embodiments, the receive_ip_address function in the master node terminal device code can be written to create a UDP socket using socket and bind it to a specified port to listen to broadcast messages on all network cards and parse the network address sent by the child node terminal device.

[0114] T1322. Based on the first code file and the second code file, write a master node terminal device decorator corresponding to the master node terminal device, and the master node terminal device decorator is used to encapsulate the connection management logic of the master node terminal device.

[0115] In some embodiments, the master node terminal device decorator refers to a design pattern used in programming, especially in object-oriented programming languages, to enhance or modify the calling function of the master node terminal device. The design pattern of the decorator allows new responsibilities or behaviors to be dynamically added to the object without modifying the original class code. Specifically, the master node terminal device decorator creates a MyServiceStub instance each time a function or method is called for calling a remote method.

[0116] T1323. Based on the first code file and the second code file, write a master node terminal device decorator execution function, wherein the master node terminal device decorator execution function is used to use the master node terminal device decorator to process the connection between the master node terminal device and the sub-node terminal device.

[0117] In some embodiments, you can write an rpc_client_exec function, use a decorator to handle the gRPC master node terminal device connection, build a FunctionRequet message containing the function name and parameters, and call the remote method ExecuteFunction. At the same time, you can also print the return result and use the recode_log function to record the result in the log.

[0118] T1324. Based on the receiving function, the master node terminal device decorator and the master node terminal device decorator execution function, compile and generate the master node terminal device code file.

[0119] T140. Generate a test execution program corresponding to a preset test scenario based on the sub-node terminal device code file and the master node terminal device code file.

[0120] In some embodiments, the test execution program corresponding to the preset test scenario is generated based on the sub-node terminal device code file and the master node terminal device code file, including the steps T141 to T142 as shown below:

[0121] T141. Based on the sub-node terminal device code file and the master node terminal device code file, write and generate packaging instructions.

[0122] T142. In response to the packaging instruction, the code of the sub-node terminal device code file and the code of the main node terminal device code file are packaged into the test execution program through a preset packaging tool.

[0123] In some embodiments, the main node terminal device code file and the sub-node terminal device code file may be packaged into an exe executable file using the pyinstaller tool.

[0124] T150. Deploy the main node terminal device and the sub-node terminal device on the main node corresponding to the first terminal in the preset local area network and the sub-node corresponding to the second terminal in the preset local area network respectively, and start the test execution program so that the user can remotely control the sub-node terminal device through the main node terminal device to test the test content in the preset test scenario.

[0125] In some embodiments, the sub-node terminal device is deployed to each sub-node (real PC or virtual machine), the sub-node terminal device is enabled, the main node terminal device is deployed to the main node PC, and the main node terminal device is enabled. Each sub-node and the main node are in the same local area network. After the sub-node terminal device is started, the sub-node terminal device IP address is automatically broadcast. After the main node terminal device is started, all sub-node terminal devices in the local area network are automatically discovered. When the main node terminal device detects the network address of a sub-node terminal device, it creates a thread, uses gRPC to establish a channel and execute test content, outputs test results and generates record logs.

[0126] The embodiment of the present invention first creates a first text file, wherein the first text file is used to characterize the communication protocol between the master node terminal device and the sub-node terminal device, the number of the master node terminal device is 1, and the number of the sub-node terminal device is at least 1, so as to realize the connection between one master node terminal device and multiple terminals; then, the first text file is parsed to generate a first code file and a second code file, wherein the first code file is used to characterize the data transmission interaction between the master node terminal device and the sub-node terminal device, and the second code file is used to characterize the remote call between the master node terminal device and the sub-node terminal device; then, based on the first code file, the second code file and the preset test scenario, the sub-node terminal device code file and the master node terminal device code file are compiled and generated. Terminal device code file, wherein the sub-node terminal device code file is used to implement the logic of the sub-node terminal device and the test logic of the preset test scenario, and the main node terminal device code file is used to implement the logic of the main node terminal device, so as to improve the development efficiency of the test scenario and improve the connection stability between the main node terminal device and the sub-node terminal device; then, based on the sub-node terminal device code file and the main node terminal device code file, a test execution program corresponding to the preset test scenario is generated; finally, the main node terminal device and the sub-node terminal device are respectively deployed on the main node corresponding to the first terminal in the preset local area network and the sub-node corresponding to the second terminal in the preset local area network, and the test execution program is started to realize remote control of multiple terminals to perform test tasks.

[0127] In order to further illustrate the present invention, a specific embodiment is described below:

[0128] In this embodiment, the following processing is performed to achieve remote control of the sub-node terminal devices corresponding to multiple terminals by the main node terminal device to perform test tasks, improve the efficiency of the test and reduce manual intervention:

[0129] 1. Define the Proto file:

[0130] First, create a *.proto file to define the service interface and message structure. In this file, use the Protocol Buffers (ProtoBuf) language to define the service interface and message structure. The content of this file determines the communication protocol between the master node terminal device and the server, including the format of the request and response messages and the methods of the service interface.

[0131] File contents of *.proto file:

[0132] The file header declares the ProtoBuf syntax version;

[0133] Define the request message, the name of the function to be executed, and the function parameters;

[0134] Define response message and function execution result;

[0135] Define the service interface. MyService is a gRPC service that contains two RPC methods. ExecuteFunction accepts a request of type FunctionRequest and returns a response of type FunctionResponse. TransferLogFile receives an empty message as input and uses streaming RPC to return multiple LogChunk messages as output.

[0136] Through this *.proto file, the gRPC tool chain can be used to generate the code for the master node terminal device and the server, so that remote calls can be made efficiently between different platforms and languages.

[0137] (ii) Generate *_pb2.py files and *.pb2_grpc.py files:

[0138] By using the protoc compiler of gRPC, the corresponding *_pb2.py file and *.pb2_grpc.py file are generated according to the *.proto file defined above. The *_pb2.py file is used to interact with protobuf data, and the *.pb2_grpc.py file is used to interact with gRPC. This file defines the RPC class, including the request parameters and response of the class, etc., so it can be directly instantiated and called with Python.

[0139] (III) Write the sub-node terminal device code:

[0140] The sub-node terminal device code contains all the necessary steps to implement the gRPC sub-node terminal device, including defining the service class, processing the master node terminal device request, starting the server, and broadcasting the server IP address. Through the broadcast_ip_address function, use socket to create a UDP socket and configure it in broadcast mode, obtain the local IP address and add specific fields to send messages through the broadcast loop for the master node terminal device to obtain the sub-node terminal device address. Through the try_decode function, try to decode the byte content and support multiple encoding formats. MyServiceServicer is the gRPC service implementation class. Through the ExecuteFunction method, receive the master node terminal device request, extract the function name and parameters, and call the corresponding function. Through the serve function, start the gRPC service, create a thread for broadcasting the IP address, build a gRPC server and register the MyServiceServicer service to the server, start the server at the specified port, and wait for the termination signal. Through the TransferLogFile function, transfer the log content to the master node terminal device. The TransferLogFile function uses streaming RPC, so that data can be sent block by block during file transfer. In the MyServiceServicer class, you can define functions or methods related to the test logic for remote calls by the master node terminal device (here you can define the encapsulated test logic according to the specific test scenario, such as simulating users accessing web pages through a browser, pinging the external network, performing performance testing through iperf, or stability testing scenarios).

[0141] (IV) Write the master node terminal device code:

[0142] The master node terminal device code includes the following contents:

[0143] The receive_ip_address function uses socket to create a UDP socket and bind it to the specified port, listens to broadcast messages on all network cards, and parses the IP address sent by the child node terminal device;

[0144] The rpc_client function is a gRPC master node terminal device decorator, which is used to handle the gRPC master node terminal device connection. The master node terminal device will create a MyServiceStub instance for each function or method called to call the remote method;

[0145] The rpc_client_exec function uses a decorator to process the gRPC master node terminal device connection, builds a FunctionRequest message containing the function name and parameters, calls the remote method ExecuteFunction, prints the return result, and uses the record_log function to record the result in the log.

[0146] (V) Deployment:

[0147] Use the pyinstaller tool to package the code files of the main node terminal device and the sub-node terminal device into an exe executable file. Deploy the sub-node terminal device to each sub-node (real PC or virtual machine) of the preset local area network, enable the sub-node terminal device, deploy the main node terminal device to the main node PC of the preset local area network, and enable the main node terminal device.

[0148] Test topology diagram Figure 2 As shown, each sub-node and the main node are in the same preset local area network. After the sub-node terminal device is started, the sub-node terminal device IP address and port number are automatically broadcast. After the main node terminal device is started, all sub-node terminal devices in the preset local area network are automatically discovered. When the main node terminal device detects a sub-node terminal device address, it creates a thread, uses gRPC to establish a channel and executes the test content, outputs the test results and generates a record log. The test results are used to characterize the product quality of the gateway device. The gateway device is a PON gateway to be tested. The PON gateway is connected to the switch network in the preset local area network. The presence of the switch in the preset local area network can increase the number of terminals in the preset local area network.

[0149] In summary, the present invention provides a method for testing a gateway device. By respectively deploying a main-node terminal device and a sub-node terminal device on nodes corresponding to different terminals in a local area network, the main-node terminal device can remotely control the sub-node terminal devices corresponding to multiple terminals to execute test cases. The topological relationship of the gateway device is simulated by presetting the local area network, and finally the test results corresponding to the test cases are obtained, and the product quality of the gateway device is evaluated by the test results. Compared with the existing testing technology, this testing process realizes a solution for automatically controlling multiple terminals for testing and obtaining the test results of each terminal, thereby improving the testing efficiency and reducing manual intervention.

[0150] In order to better implement the above method, an embodiment of the present invention further provides a device for testing a gateway device, which can be integrated in an electronic device, and the electronic device can be a terminal, a server, etc. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.

[0151] For example, in this embodiment, the method of the embodiment of the present invention is described in detail by taking the apparatus for testing the gateway device as an example in which the apparatus is specifically integrated into the terminal.

[0152] For example, Figure 3 As shown, the device is applied to a main node terminal device in a preset local area network where the gateway device is located, and the preset local area network also includes at least two sub-node terminal devices, and the sub-node terminal devices are deployed with a test function corresponding to a preset test case or a test class method corresponding to a preset test case, and the preset test case is used to detect the gateway device; the device for testing the gateway device may include a first unit 301, a second unit 302, a third unit 303 and a fourth unit 304, as follows:

[0153] The first unit 301 is used to establish a connection thread according to the network address and port information broadcast by the received sub-node terminal device;

[0154] The second unit 302 is used to establish a connection channel between the master node terminal device and the sub-node terminal device through a preset remote procedure call framework based on the connection thread;

[0155] The third unit 303 is used to call the test function or the test class method from the sub-node terminal device through the connection channel and execute the preset test case;

[0156] The fourth unit 304 is used to receive a test result corresponding to a preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device.

[0157] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0158] From the above, it can be seen that the embodiments of the present invention can realize remote control of sub-node terminal devices corresponding to multiple terminals by the main node terminal device to perform test tasks by respectively deploying the main node terminal device and the sub-node terminal device on nodes corresponding to different terminals in the local area network, thereby improving the test efficiency and reducing manual intervention.

[0159] It can be seen from the above that the embodiments of the present invention can realize remote control of multiple terminals to execute test tasks, improve test efficiency and reduce manual intervention.

[0160] A person skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a storage medium and loaded and executed by a processor.

[0161] To this end, an embodiment of the present invention provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any method of testing a gateway device provided in an embodiment of the present invention. For example, the instructions can execute the following steps:

[0162] Establish a connection thread according to the network address and port information broadcast by the received sub-node terminal device;

[0163] Based on the connection thread, a connection channel between the master node terminal device and the sub-node terminal device is established through a preset remote procedure call framework;

[0164] Calling the test function or the test class method from the sub-node terminal device through the connection channel and executing the preset test case;

[0165] Receive a test result corresponding to a preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device.

[0166] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0167] According to one aspect of the present invention, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a storage medium. A processor of a computer device reads the computer instructions from the storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the various optional implementations provided in the above embodiments.

[0168] Since the instructions stored in the storage medium can execute the steps in any method for testing a gateway device provided in the embodiments of the present invention, the beneficial effects that can be achieved by any method for testing a gateway device provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0169] The above is a detailed introduction to a method, device and storage medium for testing a gateway device provided in an embodiment of the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for testing a gateway device, characterized in that: A master node terminal device applied to a preset local area network where a gateway device is located, wherein the preset local area network also includes at least two sub-node terminal devices, wherein a test function corresponding to a preset test case or a test class method corresponding to a preset test case is deployed in the sub-node terminal device, and the preset test case is used to detect the gateway device; The method comprises: Establish a connection thread according to the network address and port information broadcast by the received sub-node terminal device; Based on the connection thread, a connection channel between the master node terminal device and the sub-node terminal device is established through a preset remote procedure call framework; Calling the test function or the test class method from the sub-node terminal device through the connection channel and executing the preset test case; Receiving a test result corresponding to a preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device; Before establishing a connection thread according to the received network address and port information broadcast by the sub-node terminal device, the method further includes: Creating a first text file, wherein the first text file is used to represent communication information between the master node terminal device and the sub-node terminal device; Parsing the first text file to generate a first code file and a second code file, wherein the first code file is used to represent the data transmission interaction between the master node terminal device and the sub-node terminal device, and the second code file is used to represent the remote call between the master node terminal device and the sub-node terminal device; Based on the first code file and the second code file, compile and generate a sub-node terminal device code file and a master node terminal device code file, wherein the sub-node terminal device code file is used to implement the logic of the sub-node terminal device, and the master node terminal device code file is used to implement the logic of the master node terminal device; Based on the sub-node terminal device code file and the master node terminal device code file, generate a test execution program corresponding to the preset test case; The master node terminal device and the sub-node terminal device are respectively deployed on a master node in a preset local area network and a sub-node in the preset local area network.

2. The method according to claim 1, characterized in that The step of creating a first text file comprises: Creating an initial first text file; Define the message structure and service interface through a preset programming language and generate definition text; Based on the initial first text file and the definition text, the first text file is obtained.

3. The method according to claim 1, characterized in that The step of parsing the first text file to generate a first code file and a second code file includes: In response to the preset compilation instruction, the first code file and the second code file are compiled and generated by the compiler of the preset remote procedure call framework.

4. The method according to claim 3, characterized in that The compiling and generating a sub-node terminal device code file and a master node terminal device code file based on the first code file and the second code file includes: Based on the first code file and the second code file, a sub-node terminal device code file is compiled and generated through the preset remote procedure call framework; Based on the first code file and the second code file, the master node terminal device code file is compiled and generated through the preset remote procedure call framework.

5. The method according to claim 4, characterized in that The compiling and generating a sub-node terminal device code file based on the first code file and the second code file through the preset remote procedure call framework includes: Based on the first code file and the second code file, define a service class corresponding to the sub-node terminal device; Based on the first code file and the second code file, define a master node terminal device request corresponding to a sub-node terminal device; Based on the first code file and the second code file, a startup function is written, where the startup function is used to start a server corresponding to a preset remote procedure call framework; Based on the first code file and the second code file, write a registration function, wherein the registration function is used to register the service class on the server; Based on the first code file and the second code file, a broadcast function is written, where the broadcast function is used to broadcast the network address of the sub-node terminal device; The sub-node terminal device code file is compiled and generated based on the service class, the master node terminal device request and the local network address of the server.

6. The method according to claim 4, characterized in that The compiling and generating the master node terminal device code file based on the first code file and the second code file through the preset remote procedure call framework includes: Based on the first code file and the second code file, write a receiving function, wherein the receiving function is used to receive the network address of the sub-node terminal device; Based on the first code file and the second code file, write a master node terminal device decorator corresponding to the master node terminal device, wherein the master node terminal device decorator is used to encapsulate the connection management logic of the master node terminal device; Based on the first code file and the second code file, write a master node terminal device decorator execution function, wherein the master node terminal device decorator execution function is used to use the master node terminal device decorator to process the connection between the master node terminal device and the sub-node terminal device; Based on the receiving function, the master node terminal device decorator and the master node terminal device decorator execution function, the master node terminal device code file is compiled and generated.

7. The method according to claim 1, characterized in that The generating a test execution program corresponding to the preset test case based on the sub-node terminal device code file and the master node terminal device code file includes: Based on the sub-node terminal device code file and the master node terminal device code file, write and generate a packaging instruction; In response to the packaging instruction, the code of the sub-node terminal device code file and the code of the main node terminal device code file are packaged into the test execution program through a preset packaging tool.

8. A device for testing a gateway device, characterized in that: A master node terminal device applied to a preset local area network where a gateway device is located, wherein the preset local area network also includes at least two sub-node terminal devices, wherein a test function corresponding to a preset test case or a test class method corresponding to a preset test case is deployed in the sub-node terminal device, and the preset test case is used to detect the gateway device; The device comprises: The first unit is configured to establish a connection thread according to the network address and port information broadcast by the received sub-node terminal device; before establishing the connection thread according to the network address and port information broadcast by the received sub-node terminal device, the method further includes: Creating a first text file, wherein the first text file is used to represent communication information between the master node terminal device and the sub-node terminal device; Parsing the first text file to generate a first code file and a second code file, wherein the first code file is used to represent the data transmission interaction between the master node terminal device and the sub-node terminal device, and the second code file is used to represent the remote call between the master node terminal device and the sub-node terminal device; Based on the first code file and the second code file, compile and generate a sub-node terminal device code file and a master node terminal device code file, wherein the sub-node terminal device code file is used to implement the logic of the sub-node terminal device, and the master node terminal device code file is used to implement the logic of the master node terminal device; Based on the sub-node terminal device code file and the master node terminal device code file, generate a test execution program corresponding to the preset test case; Deploying the master node terminal device and the sub-node terminal device on a master node in a preset local area network and a sub-node in the preset local area network respectively; A second unit is used to establish a connection channel between the master node terminal device and the sub-node terminal device through a preset remote procedure call framework based on the connection thread; A third unit is used to call the test function or the test class method from the sub-node terminal device through the connection channel and execute the preset test case; The fourth unit is used to receive the test result corresponding to the preset test case returned by the sub-node terminal device, wherein the test result is used to characterize the product quality of the gateway device.

9. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Unit test method which is automatically generated based on a path coverage test case

    CN108710575A

  • Automated testing method, device and system, medium and electronic equipment

    CN109933519A

  • Gateway terminal test method and device and storage medium

    CN114448852A

  • Intelligent application manager of wireless access network

    CN117897980A

  • JMeter cluster pressure measurement method, system, device and medium

    CN118093380A