Method for initializing a sai thrift test environment
By initializing the SAI Thrift test environment, including deleting configuration files, setting port status and VLAN attributes, and issuing ACL rules, the problem of unexpected packets affecting test cases was resolved, and the stable and reliable execution of test cases was achieved.
Patent Information
- Application Number
- CN202211019827.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-24
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-08-24
AI Technical Summary
During SAI Thrift testing, unexpected protocol messages caused test case execution failures. Existing technologies have failed to effectively eliminate these effects, impacting the stability and reliability of test cases.
Initialize the SAI Thrift test environment, including deleting configuration files, setting port status and VLAN attributes, and issuing ACL rules to ensure that only test case-related messages are received, eliminating the impact of non-test cases and ensuring the purity of the test environment.
This effectively eliminates the impact of unexpected messages on test cases, ensuring the stable and reliable execution of test cases and improving the accuracy and reliability of test results.
Smart Images

Figure CN115357503B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of service deployment testing, and in particular to an initialization method for a SAI Thrift testing environment. Background Art
[0002] Thrift is a cross-language, cross-platform service deployment framework. It uses an interface definition language to define RPC interfaces and data types. The Thrift compiler then generates code in different languages, which implements the RPC (Remote Procedure Call) protocol and transport layers. RPC is a remote procedure call protocol that enables applications to call remote procedures or services as if they were local methods. It can be applied in many scenarios, including distributed services, distributed computing, and remote service calls.
[0003] SAI Thrift is a SAI functional testing framework based on Thrift technology, such as Figure 1 As shown, it consists of a server (Test Machine) and a device under test (DUT, DeviceUnderTest), where the server is also Figure 1 In the Switch, the server's network interface card is directly connected to the network port of the device under test (DUT). The DUT acts as the SAI Thrift test server, and the server Test Machine acts as the SAI Thrift test client. A SAI ServerContainer, also known as ThriftTestServer, runs on the DUT's Switch. A server with multiple INTF network interfaces is used as the Test Machine, also known as the SAI ThriftTestClient. The server interface is physically connected to the DUT. Test PTF scripts are executed on the SAI ThriftTestClient to test the DUT's functionality and performance. Currently, the test device and test server are interconnected using multiple network ports for functional testing. The Test Machine server first remotely calls the SAI external interface on the DUT to configure the device. The Test Machine server then constructs and assembles a message and sends it to the DUT via the network interface card. The Test Machine server then checks whether the network interface card has received the message from the DUT. If so, it further verifies that the message format meets expectations, thereby testing the DUT's message forwarding functionality.
[0004] During the practical application of SAI Thrift, unexpected protocol packets may sometimes be received. However, the test device still forwards the packets according to the default forwarding behavior. As a result, when the test server verifies the packet forwarding behavior of the tested device through the PTF script, it will receive unexpected packets, resulting in test case execution failure. Summary of the Invention
[0005] According to an embodiment of the present invention, a method for initializing a SAI Thrift test environment is provided, comprising the following steps:
[0006] Build the SAI Thrift testing framework;
[0007] Initialize the device under test of the SAI Thrift test framework to ensure that the device under test starts with an empty configuration;
[0008] Set the on / off status of the application port of the SAI Thrift test framework to eliminate the impact of non-test cases of the SAI Thrift test framework;
[0009] Set the VLAN attributes of the application port to eliminate the impact of the default VLAN forwarding behavior of the SAI Thrift test framework on the test cases of the SAI Thrift test framework;
[0010] The SAI Thrift test framework server sends two ACL rules to the device under test to ensure that only messages related to the test case are received;
[0011] The server executes the test cases;
[0012] Delete two ACL rules to obtain a clean test environment for the SAI Thrift test framework.
[0013] Furthermore, the device under test of the SAI Thrift test framework is initialized to ensure that the device under test starts with an empty configuration. This includes the following sub-steps:
[0014] Delete the config_db.json configuration file and the copp_cfg.json configuration file of the tested device;
[0015] Restart the device under test.
[0016] Furthermore, the on / off status of the interface of the SAI Thrift test framework is set to eliminate the impact of non-test cases of the SAI Thrift test framework, which includes the following sub-steps:
[0017] Close all application ports in the SAI Thrift test framework;
[0018] Get the list of ports used by the test cases of the SAI Thrift test framework;
[0019] Open application ports that match the port list to eliminate the impact of application ports not related to test cases on test cases.
[0020] Furthermore, set the VLAN attributes of the application port to eliminate the impact of the SAI Thrift test framework's default VLAN forwarding behavior on the test cases of the SAI Thrift test framework. This includes the following sub-steps:
[0021] Delete the default VLAN 1 configuration on the application port.
[0022] Furthermore, for test cases that do not explicitly apply the VLAN attributes of the port, the Layer 2 configuration attributes of the port are supplemented to clarify the test case.
[0023] Furthermore, the SAI Thrift test framework server sends two ACL rules to the device under test to ensure that only messages related to the test case can be received. This includes the following sub-steps:
[0024] The server sends a first ACL rule to the device under test, which is used to discard packets received by the test port.
[0025] Get the PTF packet format of the test case to match the message format specified by the test case;
[0026] The server sends a second ACL rule to the device under test for receiving packets.
[0027] Furthermore, the priority of the first ACL rule is low.
[0028] Furthermore, the priority of the second ACL rule is high.
[0029] The SAI Thrift test environment initialization method according to the embodiment of the present invention eliminates the influence of the test environment of the SAI Thrift test framework on the execution results of the test cases, and effectively ensures the stable and reliable execution of the test cases.
[0030] It is to be understood that both the foregoing general description and the following detailed description are exemplary, and are intended to provide further explanation of the technology as claimed. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 The schematic diagram of the SAI Thrift testing framework in the prior art is shown in FIG.
[0032] Figure 2Flowchart of the steps of the method for initializing the SAI Thrift test environment according to an embodiment of the present invention;
[0033] Figure 3 for Figure 2 Schematic diagram of the sub-steps of step S2;
[0034] Figure 4 for Figure 2 Schematic diagram of the sub-steps of step S3;
[0035] Figure 5 for Figure 2 Schematic diagram of the sub-steps of step S4;
[0036] Figure 6 for Figure 2 Schematic diagram of the sub-steps of step S5. DETAILED DESCRIPTION
[0037] The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings to further illustrate the present invention.
[0038] First, combine Figures 2 to 6 The present invention describes an initialization method for a SAI Thrift test environment according to an embodiment of the present invention, which is used to eliminate unexpected protocol message forwarding and has a wide range of application scenarios.
[0039] like Figure 2 As shown, the method for initializing the SAI Thrift test environment according to an embodiment of the present invention includes the following steps:
[0040] In S1, as Figure 2 As shown, build the SAI Thrift test framework.
[0041] In S2, as Figure 2 As shown, the device under test of the SAI Thrift test framework is initialized to ensure that the device under test starts with an empty configuration.
[0042] Furthermore, the device under test of the SAI Thrift test framework is initialized to ensure that the device under test starts with an empty configuration. This includes the following sub-steps:
[0043] In S21, if Figure 3 As shown in the following figure, delete the config_db.json configuration file and the copp_cfg.json configuration file of the tested device.
[0044] In S22, if Figure 3 As shown, restart the device under test to ensure that the device under test starts with an empty configuration, eliminating the impact of the configuration in the configuration file on the test case.
[0045] In S3, such as Figure 2 As shown, the on / off status of the application port of the SAI Thrift test framework is set to eliminate the influence of non-test cases of the SAI Thrift test framework.
[0046] Furthermore, the state of the interface of the SAI Thrift test framework is set to eliminate the impact of non-test cases of the SAI Thrift test framework, which includes the following sub-steps:
[0047] In S31, if Figure 4 As shown, close all application ports in the SAI Thrift test framework.
[0048] In S32, as Figure 4 As shown, get the port list used by the test cases of the SAI Thrift test framework.
[0049] In S33, as Figure 4 As shown in the figure, the application ports that match the port list are opened to exclude the impact of application ports related to non-test cases on the test cases.
[0050] In S4, as Figure 2 As shown in the figure, the VLAN attribute of the application port is set to eliminate the impact of the default VLAN forwarding behavior of the SAI Thrift test framework on the test cases of the SAI Thrift test framework.
[0051] Furthermore, set the VLAN attributes of the application port to eliminate the impact of the SAI Thrift test framework's default VLAN forwarding behavior on the test cases of the SAI Thrift test framework. This includes the following sub-steps:
[0052] In S41, if Figure 5 As shown in the figure, the default VLAN1 configuration in the application port is deleted, so that all packet forwarding depends on the explicitly delivered configuration.
[0053] Furthermore, for test cases that do not explicitly apply the VLAN attributes of the port, the Layer 2 configuration attributes of the port are supplemented to the test case. It is recommended that a test case for a feature be explicitly declared once, which can effectively eliminate the impact of the default VLAN forwarding behavior on the test case execution.
[0054] In S5, such as Figure 2 As shown in Figure 1, the server of the SAI Thrift test framework sends two ACL rules to the device under test to ensure that only messages related to the test case can be received.
[0055] Furthermore, the SAI Thrift test framework server sends two ACL rules to the device under test to receive messages related to the test case. This includes the following sub-steps:
[0056] In S51, if Figure 6 As shown, the service sends a first ACL rule to the device under test, which is used to discard the messages received by the test port.
[0057] Furthermore, the priority of the first ACL rule is low.
[0058] In S52, if Figure 6 As shown, the PTF packet format of the test case is obtained, which is used to match the format of the message specified by the test case and receive the message.
[0059] In S53, as Figure 6 As shown, the service sends a second ACL rule to the device under test for receiving the message specified by the test case, further eliminating the impact of unexpected messages on the test case execution result.
[0060] Furthermore, the priority of the second ACL rule is high.
[0061] In S6, as Figure 2 As shown, the server executes the test case, which is a standard test case used to test the functional correctness of the device under test.
[0062] In S7, such as Figure 2 As shown in the figure, after the test case is executed, the two ACL rules are deleted to obtain a pure test environment of the SAI Thrift test framework, ensuring the normal execution of subsequent test cases.
[0063] This embodiment effectively ensures the cleanliness and reliability of the test environment before executing the test case by eliminating the influence of problems such as configuration files, application ports related to non-test cases, default VLAN settings of application ports, and unexpected protocol messages, thereby further ensuring the stability and reliability of the test case execution.
[0064] Above, refer to Figures 2 to 6 The invention discloses an initialization method for a SAI Thrift test environment, which eliminates the influence of the test environment of the SAI Thrift test framework on the execution results of test cases and effectively ensures the stable and reliable execution of test cases.
[0065] It should be noted that, in this specification, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, elements defined by the phrase "comprising..." do not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the elements.
[0066] Although the present invention has been described in detail through the above preferred embodiments, it should be understood that the above description is not intended to limit the present invention. After reading the above description, various modifications and substitutions of the present invention will become apparent to those skilled in the art. Therefore, the scope of protection of the present invention should be defined by the appended claims.
Claims
1. A method for initializing a SAI Thrift test environment, characterized in that: The following steps are included: Build the SAI Thrift testing framework; Initializing the device under test of the SAI Thrift test framework to ensure that the device under test starts with an empty configuration; Setting the on / off status of the application port of the SAI Thrift test framework to eliminate the influence of non-test cases of the SAI Thrift test framework; Setting the VLAN attribute of the application port to eliminate the impact of the default VLAN forwarding behavior of the SAI Thrift test framework on the test cases of the SAI Thrift test framework; The server of the SAI Thrift test framework sends two ACL rules to the device under test to ensure that only messages related to the test case can be received; The server executes the test case; Delete the two ACL rules to obtain a clean test environment for the SAI Thrift test framework; Setting the VLAN attribute of the application port to eliminate the impact of the default VLAN forwarding behavior of the SAI Thrift test framework on the test case of the SAI Thrift test framework includes the following sub-steps: Delete the default VLAN1 configuration in the application port; For a test case that does not explicitly specify the VLAN attributes of the application port, the Layer 2 configuration attributes of the port are supplemented to specify the test case; The server of the SAI Thrift test framework sends two ACL rules to the device under test to ensure that only messages related to the test case can be received, including the following sub-steps: The server sends a first ACL rule to the device under test, for discarding messages received by the test port; the priority of the first ACL rule is low; Obtaining the PTF packet format of the test case to match the message format specified by the test case; The server sends a second ACL rule to the tested device for receiving the message; The priority of the second ACL rule is high.
2. The method for initializing the SAI Thrift test environment according to claim 1, wherein: Initializing the device under test of the SAIThrift test framework to ensure that the device under test starts with an empty configuration includes the following sub-steps: Delete the config_db.json configuration file of the tested device and the copp_cfg.json configuration file of the tested device; Restart the device under test.
3. The method for initializing the SAI Thrift test environment according to claim 1, wherein: Setting the on / off status of the interface of the SAI Thrift test framework to eliminate the influence of non-test cases of the SAI Thrift test framework includes the following sub-steps: Close all application ports in the SAI Thrift test framework; Obtain a list of ports used by the test cases of the SAI Thrift test framework; The application ports matching the port list are opened to eliminate the influence of the application ports not related to the test case on the test case.
Citation Information
Patent Citations
Automatic test framework based on embedded equipment
CN111190812A
Message processing method and module, detection method, switching equipment and storage medium
CN112995006A