Switch test method and device, electronic equipment and readable storage medium

By automating the generation of switch test cases and scripts, and using attribute identifiers in the test factor file to combine test items, the problem of excessively long switch testing time has been solved, improving testing efficiency and executability.

CN119728509BActive Publication Date: 2025-11-07NEW H3C TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411908737.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-11-07
Estimated Expiration
2044-12-23

AI Technical Summary

Technical Problem

In existing technologies, manually writing switch test cases and scripts is too time-consuming and cannot efficiently cover the needs of various switch testing scenarios, thus affecting testing efficiency.

Method used

By automatically generating test cases and scripts, and using attribute identifiers in the test factor file to determine and combine different test items, test cases and scripts covering diverse test scenarios are generated, while mutually exclusive and unreasonable test cases are eliminated.

Benefits of technology

It enables the rapid generation of various test cases and scripts, improving testing efficiency, reducing the time spent on manual writing, and enhancing the efficiency and executability of test development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728509B_ABST
    Figure CN119728509B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a switch test method and device, electronic equipment and a readable storage medium. Through the method of the embodiments, different test cases and test scripts of different test cases can be automatically and batch combined, which not only covers most test scenarios and meets diversified test development needs, but also improves test development efficiency. Moreover, when the test cases are combined, the test cases that are exclusive and unreasonable are directly filtered through the judgment of the attribute identifier, which can eliminate the test interference caused by exclusive and unreasonable test cases and improve the executability of automatic testing.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of communication, in particular to a switch testing method and device, an electronic device and a readable storage medium. BACKGROUND

[0002] Ethernet switch products support more and more functions, and the demand for test scenarios of various combinations of configurations, operations and traffic services is increasing sharply, that is, various scenarios of the switch need to be tested.

[0003] Currently, test cases required by each test scenario are manually written by an artificial, and then test scripts are written one by one according to the test cases. When various test development requirements need to be covered, the manual test script writing method takes too much time and seriously affects the test efficiency. SUMMARY

[0004] Therefore, the embodiments of the present application provide a switch testing method and device, an electronic device and a readable storage medium, so as to automatically generate multiple test scripts, meet diversified test development requirements and improve test efficiency.

[0005] The embodiments of the present application provide a switch testing method, which comprises:

[0006] obtaining a test factor file of a switch; the test factor file is set according to the test requirement of the switch, the test factor file comprises K test items, K is greater than 1, and each test item comprises at least one test factor;

[0007] taking one test item in the K test items as a current test item, taking each test factor in the current test item as a current test factor;

[0008] selecting one test factor from each of the remaining K-1 test items;

[0009] when the attribute identifier of the selected K-1 test factors is different from the attribute identifier of the current test factor and the attribute identifier of each test factor in the K-1 test factors is different from each other, combining the K-1 test factors and the current test factor to obtain a test case; the K-1 test factors and the current test factor are partially the same or completely different from the test factors used in the test case obtained before the current time;

[0010] testing the test script corresponding to each test case to obtain the test result of the test case; wherein the test script corresponding to each test case is determined based on the test function corresponding to each test factor in the test case.

[0011] The embodiments of the present application also provide a switch testing device, which comprises:

[0012] The acquisition module is used to acquire the test factor file of the switch. The test factor file is set according to the test requirements of the switch. The test factor file includes K test items, where K is greater than 1. Each test item includes at least one test factor.

[0013] The combination module is used to select one of the K test items as the current test item, and for each test factor in the current test item, select that test factor as the current test factor.

[0014] When the attribute identifiers of the selected K-1 test factors are different from the attribute identifier of the current test factor, and the attribute identifiers of each of the K-1 test factors are different from each other, the K-1 test factors and the current test factor are combined to obtain a test case; the K-1 test factors and the current test factor are partially the same as or completely different from the test factors used in the test cases obtained before the current time.

[0015] The testing module is used to test the test script corresponding to each test case and obtain the test result of the test case; wherein, the test script corresponding to each test case is determined based on the test function corresponding to each test factor in the test case.

[0016] This application also provides an electronic device, including: a processor and a computer-readable storage medium for storing computer program instructions, wherein the computer program instructions, when executed by the computer-readable storage medium, cause the processor to perform the steps of the above method.

[0017] This application also provides a machine-readable storage medium storing computer program instructions that, when executed, enable the implementation of the steps described above.

[0018] It can be seen from the above technical solution that in the embodiment, after obtaining the test factor file, one test item in the K test items is taken as a current test item, for each test factor in the current test item, the test factor is taken as a current test factor; one test factor is selected from each of the remaining K-1 test items, when the attribute identifier of the selected K-1 test factors is different from the attribute identifier of the current test factor and each of the attribute identifiers of the K-1 test factors is different from each other, the K-1 test factors and the current test factor are combined to obtain a test case; the K-1 test factors and the current test factor are partially the same or all different from the test factors used by the test case obtained before the current time, and the test script corresponding to each test case is determined based on the test functions corresponding to the test factors in the test case. This can automatically and batch generate different test cases and test scripts of different test cases, and test the test script corresponding to each test case. This not only can cover most test scenarios and meet diversified test development needs, but also can improve test development efficiency.

[0019] Further, when the test case is combined, the exclusion and unreasonable test case is directly filtered through the attribute identifier, which can exclude the test interference caused by the exclusion and unreasonable test case, and improve the executability of the automatic test. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 A flowchart of the method provided by the embodiment of the present application is provided.

[0021] Figure 2 A schematic diagram of the test factor file provided by the embodiment of the present application is provided.

[0022] Figure 3 A schematic diagram of obtaining a test case provided by the embodiment of the present application is provided.

[0023] Figure 4 A structural schematic diagram of the device provided by the embodiment of the present application is provided.

[0024] Figure 5 A structural schematic diagram of the electronic device provided by the embodiment of the present application is provided. DETAILED DESCRIPTION

[0025] In order to make those skilled in the art better understand the technical solutions provided by the embodiments of the present application, and make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application are further described in detail below with reference to the drawings.

[0026] In order to facilitate understanding of the method, before describing the method, the existing technical problems are described in detail:

[0027] Ethernet switches support an increasing number of functions, and the combinations of various configurations, operations, and traffic services are growing rapidly. Traditional script development methods that focus on single, specific functions cannot effectively meet the needs of developing test scripts that cover various combined scenarios. Therefore, it is necessary to test switches in various scenarios.

[0028] Currently, test cases for each test scenario are manually written, and then test scripts are written one by one based on the test cases. When test development needs to cover various scenarios, this method of manually writing test scripts one by one is too time-consuming and seriously affects testing efficiency.

[0029] For example, in a typical application scenario, a certain type of switch might use three configurations: A, B, and C (i.e., configuration A, configuration B, and configuration C), and might also involve three operations: D, E, and F (i.e., operation D, operation E, and operation F). Each configuration and operation has three different options:

[0030] Configuration A Configuration B Configuration C Operation D Operation E Operation F A1 B1 C1 D1 E1 F1 A2 B2 C2 D2 E2 F2 A3 B3 C3 D3 E3 F3

[0031] Based on permutations and combinations, there are a total of 3*3*3=27 possible configurations for the three types of configurations issued under different options. Similarly, there are also a total of 27 possible operations for the three types of operations. Therefore, if each configuration is tested for each operation, there will be 27*27=729 specific combinations of configurations and operations.

[0032] Currently, test cases for each scenario are written manually, meaning that the test scripts (i.e., test code) for each test case need to be written manually. For example, if a test case involves executing operations D2, E, and F1 under configurations A1, B1, and C3, then both the test cases and their test scripts need to be written manually. This method of manually writing test cases and test scripts is extremely time-consuming and severely impacts testing efficiency.

[0033] Based on this, embodiments of this application provide a switch testing method, apparatus, electronic device, and medium, which can automatically generate various test scripts, thereby meeting diverse test development needs and improving testing efficiency.

[0034] The method provided in the embodiments of this application is described in detail below:

[0035] See Figure 1 , Figure 1 This is a flowchart illustrating the method provided in an embodiment of this application.

[0036] like Figure 1 As shown, the process may include the following steps:

[0037] S101, acquire a test factor file of the switch; the test factor file is set according to test requirements of the switch, the test factor file includes K test items, K is greater than 1; at least one test factor is included in any test item.

[0038] In the embodiment, the K test items include M configuration items and N operation items, here, the test factor in the test item is referred to as a configuration factor, and the test factor in the operation item is referred to as an operation factor. For convenience of description, the configuration factor and the operation factor are used for description hereinafter.

[0039] In the embodiment, any configuration item refers to a type of configuration of the switch, and each configuration factor under the configuration item corresponds to a configuration form under the type of configuration. The configuration items cover configurations in multiple aspects such as global configuration, logical interface configuration, and physical interface configuration. Any operation item refers to a type of operation of the switch, and each configuration factor under the operation item corresponds to an operation form under the type of operation. The specific forms of the configuration item and the operation item will be described hereinafter, and will not be described here again.

[0040] S102, take one test item in the K test items as a current test item, and take each test factor in the current test item as a current test factor.

[0041] In the embodiment, the current test item is one of the K test items.

[0042] S103, when the attribute identifier of the selected K-1 test factors is different from the attribute identifier of the current test factor, and the attribute identifier of each test factor in the K-1 test factors is different from each other, combine the K-1 test factors and the current test factor to obtain a test case; the K-1 test factors and the current test factor are partially same or all different from the test factors used in the test case obtained before the current time.

[0043] In the embodiment, the attribute identifier of any test factor is used to represent whether the test factor is repulsive to other test factors, and the so-called repulsion refers to that the test case composed of the test factor and other factors is unusable and cannot be executed.

[0044] In a specific implementation, the attribute identifier can be implemented in various forms. For example, the attribute identifier can be implemented in the form of a background attribute label. The mutually exclusive test factors are represented by the same background attribute label. When the background attribute labels of the selected K-1 test factors and the current test factor are all different, the K-1 test factors and the current test factor are combined to obtain a test case. If the background attribute labels of the selected K-1 test factors and the current test factor are the same, it is determined that there is mutual exclusion among the K-1 test factors and the current test factor, and the K-1 test factors and the current test factor cannot be combined.

[0045] In the embodiment, one test factor is selected from each of the remaining K-1 test items. The number of combinations of the K-1 test factors is related to the number of test factors in each of the remaining K-1 test items. For example, K = 8, and the number of test factors in each of the remaining 7 test items is 6. Therefore, the number of combinations of one test factor selected from each of the remaining K-1 test items is 6*6*6*6*6*6*6 = 279936. The 279936 combinations are subjected to attribute identification. Finally, the total number of test cases corresponding to the current test factor is less than or equal to 279936.

[0046] In the embodiment, the specific implementation of obtaining the test case will be described in the form of a specific embodiment in the following description, and will not be described here.

[0047] S104, test the test script corresponding to each test case to obtain the test result of the test case; wherein the test script corresponding to each test case is determined based on the test function corresponding to each test factor in the test case.

[0048] In the embodiment, the test function corresponding to each test factor included in each test case constitutes the test script of the test case. The test script of each test case is run to obtain the test result of each test case. In the embodiment, the specific implementation of obtaining the test script of the test case will also be described in the form of a specific embodiment in the following description, and will not be described here.

[0049] It should be noted that the test script of the test case is a Python executable automation script.

[0050] At this point, the process shown in Figure 1 is completed.

[0051] By Figure 1As shown in the flowchart, in this embodiment, after obtaining the test factor file, one of the K test items is taken as the current test item. For each test factor in the current test item, this test factor is taken as the current test factor. From each of the remaining K-1 test items, one test factor is selected. When the attribute identifiers of the selected K-1 test factors are different from the attribute identifiers of the current test factor, and each test factor in the K-1 test factor attribute identifiers is also different from each other, the K-1 test factors and the current test factor are combined to obtain a test case. The K-1 test factors and the current test factor are partially the same as or completely different from the test factors used in the test cases obtained before the current time. The test script corresponding to each test case is determined based on the test functions corresponding to each test factor in the test case. This can automatically generate different test cases and test scripts for different test cases in batches, and test the test script corresponding to each test case. This can not only cover most test scenarios and meet diverse test development needs, but also improve test development efficiency.

[0052] Furthermore, when test cases are combined, exclusionary and unreasonable test cases are directly filtered out by judging attribute identifiers. This can eliminate test interference caused by mutually exclusive and unreasonable test cases and improve the executability of automated testing.

[0053] The following is combined Figure 2 A detailed explanation of the test items and configuration items is provided:

[0054] Figure 2 A schematic diagram of the test factor file provided in the embodiments of this application, such as Figure 2 As shown, the M configuration items include at least one of the following: traffic ingress type configuration item ( Figure 2 Configuration item 1), Traffic outbound type configuration item ( Figure 2 Configuration item 2), Traffic encapsulation configuration item ( Figure 2 Configuration item 3), and traffic content configuration item ( Figure 2 Configuration item 4).

[0055] The configuration factors in the traffic ingress type configuration item include at least: physical tunnel, virtual tunnel, data center interconnect (DCI) tunnel, inter-peer link (IPL) tunnel, attachment circuit (AC) port, cross-board AC port, virtual interface, routing port, and routing sub-interface.

[0056] The configuration factors in the traffic egress type configuration item include at least: physical tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single-connection access circuit AC port, cross-board AC port, virtual interface, routing interface, and routing sub-interface.

[0057] The configuration factors in the traffic encapsulation configuration item include at least: broadcast, unknown unicast, multicast, layer 2 unicast, and layer 3 unicast.

[0058] The configuration factors in the traffic content configuration item should include at least: CPU protocol messages ( Figure 2 Operation item 1) Ordinary data message ( Figure 2 Operation item 2), Check flow continuity operation item ( Figure 2 Operation item 3), and the operation item for checking traffic encapsulation ( Figure 2 Operation item 4 in the middle).

[0059] The N operation items include at least one of the following operation items: uplink route switching operation item and fault drill operation item.

[0060] The operation factors in the uplink route switching operation item include at least: switching from equivalent to non-equivalent, and switching from non-equivalent to equivalent.

[0061] The operational factors in the fault drill operation items include at least: distributed relay (DR) interface fault and recovery, and IPL fault and recovery.

[0062] The operation factors in the "Check Flow On / Off" operation item must include at least: Check Flow On / Off.

[0063] The operation factors in the "Check traffic encapsulation" operation item must include at least: Check traffic encapsulation.

[0064] The test items and configuration items have been explained in detail above.

[0065] The following is combined with Figure 3 A detailed explanation of how to obtain test cases is provided:

[0066] As an example, such as Figure 3 As shown, the configuration factor "Real Tunnel" in configuration item 1 is the current test factor. The test factors selected from configuration items 2, 3, and 4, operation item 1, operation item 2, operation item 3, and operation item 4 are respectively "DCI Tunnel", "Layer 3 Unicast", "Ordinary Data Packet", "Equivalent to Non-equivalent", "DR Port Fault and Recovery", "Check Traffic Connectivity", and "Check Traffic Encapsulation". Figure 3 As shown, the background color attribute labels of these 8 test factors are all different, and the above 8 test factors can be combined into a test case.

[0067] As another embodiment, as shown in Figure 3 the configuration factor "real tunnel" in configuration item 1 is the current test factor, and the test factors selected from configuration item 2, configuration item 3, configuration item 4, operation item 1, operation item 2, operation item 3, and operation item 4 are divided into "real tunnel", "three-layer unicast", "normal data packet", "equivalent cut non-equivalent", "DR port fault and recovery", "check traffic continuity", and "check traffic encapsulation" respectively, Figure 3 the background color attribute label of "real tunnel" in configuration item 1 and "real tunnel" in configuration item 2 is the same, so they are mutually exclusive items, and therefore, the eight test factors will not be combined.

[0068] In this embodiment, by the above-mentioned manner, the mutually exclusive items with the same background color are filtered out, so that the small-scale test with relatively simple configuration and operation is refined, the interference caused by the unreasonable operation of the mutually exclusive items is excluded, and the executability of the automatic test is improved.

[0069] Further, for the large-scale test with relatively complex configuration and operation, by setting different typical configurations as mutually exclusive, a plurality of typical scenarios (such as different routing schemes, network management schemes, and link reliability schemes, which are extracted by analyzing a large number of typical networking scenarios outside, and reasonably filtered and combined according to different schemes) can be traversed once for the same plurality of groups of operations (such as network management access, file operation, network shock, configuration rollback, user migration, and the like). While obtaining the above flexibility and convenience, the effective utilization rate of the automatic material environment is greatly improved, and the operation cost is reduced.

[0070] The above describes in detail how to obtain the test case.

[0071] The following describes in detail the test script for obtaining the test case:

[0072] As an embodiment, the test functions corresponding to each test factor in the test case are obtained, and the obtained test functions are combined to obtain the test script of the test case.

[0073] For example, ...

[0075] tc.Config_swa(commandsa)

[0076] tc.Config_swd(commandsd)

[0077] tc.Config_swf(commandsf)

[0078] tc.Config_swi(commandsi)

[0079] tc.Config_swk(commandsk)

[0080] tc.Config_swo(commandso)

[0081] tc.Config_swa(commandsa)

[0082] tc.Config_swd(commandsd)

[0083] tc.Config_swf(commandsf)

[0084] tc.Config_swi(commandsi)

[0085] tc.Config_swk(commandsk)

[0086] tc.Config_swn(commandsn) ...

[0088] Each of the above lines corresponds to a configuration factor or an operation factor, for example, tc.Config_swa(commandsa) corresponds to the "real tunnel" configuration factor of configuration item 1, tc.Config_swi(commandsi) corresponds to the "equivalent cut non-equivalent" operation factor of operation item 1, and the test functions are spliced to obtain the test script of the test case. By analogy, the test scripts of various test cases can be obtained.

[0089] The test scripts of the test cases are described in detail above.

[0090] As an embodiment, after obtaining the test script of the test case by the above method, the test case is recorded in a test case document, and the test case document is stored at a specified storage location according to the storage path indicated by the environment variable file, so that the test scripts of various test cases recorded in the test case document are called based on the storage path indicated by the environment variable file when the test module is tested.

[0091] For example, the finally obtained test case document is result.txt, and the test case document is run by the following method:

[0092] with open('. / result.txt','r')as f:

[0093] for line in f.readlines():

[0094] exec(line)

[0095] The test result is finally obtained and recorded in a local log file for a tester to view.

[0096] The method provided by the embodiments of the present application is described above, and the device provided by the embodiments of the present application is described below.

[0097] Referring to Figure 4 , Figure 4 The device structure diagram provided by the embodiments of the present application is shown in FIG. 4. As shown in FIG. 4, the device includes an obtaining module 401, a combination module 402, and a testing module 403. Figure 4 The obtaining module 401 is configured to obtain a test factor file of a switch. The test factor file is set according to a test requirement of the switch. The test factor file includes K test items, and K is greater than 1. Each test item includes at least one test factor.

[0098] The combination module 402 is configured to take one test item of the K test items as a current test item, and take each test factor in the current test item as a current test factor.

[0099] When the attribute identifiers of the selected K-1 test factors and the current test factor are different, and the attribute identifiers of each test factor in the K-1 test factors are different from each other, the K-1 test factors and the current test factor are combined to obtain a test case. The K-1 test factors and the current test factor are partially the same as or completely different from the test factors used in the test case obtained before the current time.

[0100] The testing module 403 is configured to test a test script corresponding to each test case to obtain a test result of the test case. The test script corresponding to each test case is determined based on test functions corresponding to the test factors in the test case.

[0101] In this embodiment, one configuration factor is selected from each configuration factor under N configuration items, one operation factor is selected from each operation factor under M operation items, and a plurality of test cases are generated based on the N selected configuration factors and the M selected operation factors. This can batch generate a software of a combined test automation script, can synchronously output a corresponding test case document, and can make a tester obtain a test case with good readability and a corresponding script, thereby greatly improving test case traversal efficiency in a black box test requirement.

[0102]

[0103] ​Further, in the embodiment, the mutually exclusive items with the same background color are filtered out, so that the small-scale test is refined with relatively simple configuration and operation, the interference caused by the unreasonable operation of the mutually exclusive items is excluded, and the executable of the automatic test is improved.

[0104] As an embodiment, the K test items include M configuration items and N operation items;

[0105] The M configuration items include at least one of the following configuration items:

[0106] The traffic ingress type configuration item, the traffic egress type configuration item, the traffic encapsulation configuration item, and the traffic content configuration item:

[0107] The test factors in the traffic ingress type configuration item include at least: real tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single-hung AC port, cross-board AC port, virtual interface, routing port, and routing sub-interface;

[0108] The test factors in the traffic egress type configuration item include at least: real tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single-hung AC port, cross-board AC port, virtual interface, routing port, and routing sub-interface;

[0109] The test factors in the traffic encapsulation configuration item include at least: broadcast, unknown unicast, multicast, layer-2 unicast, and layer-3 unicast;

[0110] The test factors in the traffic content configuration item include at least: CPU protocol packet, and normal data packet;

[0111] The N operation items include at least one of the following operation items:

[0112] The uplink routing switching operation item, and the fault simulation operation item;

[0113] The test factors in the uplink routing switching operation item include at least: equivalent switching non-equivalent, and non-equivalent switching equivalent;

[0114] The test factors in the fault simulation operation item include at least: DR port fault and recovery, and IPL fault and recovery.

[0115] As an embodiment, the N operation items further include: the check traffic continuity operation item, and the check traffic encapsulation operation item;

[0116] The test factors in the check traffic continuity operation item include at least: check traffic continuity;

[0117] The test factors in the check traffic encapsulation operation item include at least: check traffic encapsulation.

[0118] As an embodiment, the apparatus further includes a storage module:

[0119] obtaining an environment variable file after obtaining the test script of the test case; the environment variable file is set according to the test requirement of the switch to be tested;

[0120] recording the test case in a test case document, and storing the test case document in a specified storage location according to a storage path indicated by the environment variable file, so as to call the test script of each test case recorded in the test case document based on the storage path indicated by the environment variable file when performing the test.

[0121] As an embodiment, the test script of the test case is a Python executable automation script. Figure 4 The structural description of the device is shown.

[0122] Referring to Figure 5 , Figure 5 The electronic device structure diagram provided by the embodiment of the application is shown. Figure 5 As shown in the figure, the hardware structure can include a processor and a machine readable storage medium, the machine readable storage medium stores machine executable instructions capable of being executed by the processor, and the processor is used to execute the machine executable instructions to realize the method disclosed in the above examples of the application.

[0123] Based on the same application concept as the above method, the embodiment of the application further provides a machine readable storage medium, the machine readable storage medium stores a plurality of computer instructions, and the computer instructions are executed by the processor to realize the method disclosed in the above examples of the application.

[0124] For example, the machine readable storage medium can be RAM (Random Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state disk, any type of storage disk (such as optical disk, dvd, etc.), or similar storage medium, or combination thereof.

[0125] The above only describes the embodiments of the application and is not used to limit the application. The application can have various changes and modifications for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the application shall be included in the scope of claims of the application.

Claims

1. A method of testing a switch, the method comprising: The method comprises: obtaining a test factor file of a switch; the test factor file is set according to test requirements of the switch, the test factor file comprises K test items, and K is greater than 1; at least one test factor is included in any test item; taking one test item in the K test items as a current test item, taking each test factor in the current test item as a current test factor; selecting one test factor from each of the remaining K-1 test items respectively; when attribute identifiers of the selected K-1 test factors are different from an attribute identifier of the current test factor and the attribute identifiers of the K-1 test factors are different from each other, combining the K-1 test factors and the current test factor to obtain a test case; the K-1 test factors and the current test factor are partially the same as or completely different from test factors used in a test case obtained before a current time; testing a test script corresponding to each test case to obtain a test result of the test case; wherein the test script corresponding to each test case is determined based on test functions corresponding to the test factors in the test case.

2. The method of claim 1, wherein, The K test items comprise M configuration items and N operation items; the M configuration items comprise at least one of the following configuration items: a traffic entry type configuration item, a traffic exit type configuration item, a traffic encapsulation configuration item, and a traffic content configuration item: wherein the test factors in the traffic entry type configuration item at least include: a real tunnel, a virtual tunnel, a data center interconnection DCI tunnel, a peer-to-peer link IPL tunnel, a single-hung AC port, a cross-board AC port, a virtual interface, a routing port, and a routing sub-interface; the test factors in the traffic exit type configuration item at least include: a real tunnel, a virtual tunnel, a DCI tunnel, an IPL tunnel, a single-hung access circuit AC port, a cross-board AC port, a virtual interface, a routing interface, and a routing sub-interface; the test factors in the traffic encapsulation configuration item at least include: broadcast, unknown unicast, multicast, layer 2 unicast, and layer 3 unicast; the test factors in the traffic content configuration item at least include: CPU protocol packets, and ordinary data packets; the N operation items comprise at least one of the following operation items: an uplink routing switching operation item, and a fault simulation operation item; the test factors in the uplink routing switching operation item at least include: equivalent switching non-equivalent, and non-equivalent switching equivalent; the test factors in the fault simulation operation item at least include: distributed aggregation DR port fault and recovery, and IPL fault and recovery.

3. The method of claim 2, wherein, The N operation items further comprise: a check traffic continuity operation item, and a check traffic encapsulation operation item; wherein the test factors in the check traffic continuity operation item at least include: checking traffic continuity; the test factors in the check traffic encapsulation operation item at least include: checking traffic encapsulation.

4. The method of claim 1, wherein, The method further comprises: obtaining an environment variable file; the environment variable file is set according to test requirements of a switch to be tested; The test case is recorded in a test case document, and the test case document is stored in a specified storage location according to a storage path indicated by the environment variable file, so that when the test is performed, the test scripts of each test case recorded in the test case document are called according to the storage path indicated by the environment variable file.

5. The method of claim 1, wherein, The test script of the test case is a Python executable automation script.

6. A method of testing a switch, the method comprising: The device comprises: An acquisition module, configured to acquire a test factor file of a switch; the test factor file is set according to a test requirement of the switch; the test factor file comprises K test items, and K is greater than 1; each test item comprises at least one test factor; A combination module, configured to take one test item in the K test items as a current test item, take each test factor in the current test item as a current test factor, select one test factor from each of the remaining K-1 test items, and combine the K-1 test factors and the current test factor to obtain a test case when the attribute identifiers of the selected K-1 test factors and the current test factor are different from each other and the attribute identifiers of the K-1 test factors are different from each other; the K-1 test factors and the current test factor are partially the same as or totally different from the test factors used in a test case obtained before the current time. A test module, configured to test a test script corresponding to each test case to obtain a test result of the test case; the test script corresponding to each test case is determined based on test functions corresponding to the test factors in the test case.

7. The device of claim 6, wherein The K test items comprise M configuration items and N operation items; The M configuration items comprise at least one of the following configuration items: a traffic ingress type configuration item, a traffic egress type configuration item, a traffic encapsulation configuration item, and a traffic content configuration item; The test factors in the traffic ingress type configuration item at least include a real tunnel, a virtual tunnel, a DCI tunnel, an IPL tunnel, a single-hung AC port, a cross-board AC port, a virtual interface, a routing port, and a routing sub-interface; The test factors in the traffic egress type configuration item at least include a real tunnel, a virtual tunnel, a DCI tunnel, an IPL tunnel, a single-hung AC port, a cross-board AC port, a virtual interface, a routing port, and a routing sub-interface; The test factors in the traffic encapsulation configuration item at least include broadcast, unknown unicast, multicast, layer-2 unicast, and layer-3 unicast; The test factors in the traffic content configuration item at least include a CPU protocol packet and a normal data packet; The N operation items comprise at least one of the following operation items: an uplink routing switching operation item and a fault simulation operation item; The test factors in the uplink routing switching operation item at least include equivalent switching non-equivalent and non-equivalent switching equivalent; The test factors in the fault simulation operation item at least include DR port fault and recovery and IPL fault and recovery; and / or ​ ​ The N operation items further include: a check flow continuity operation item and a check flow encapsulation operation item; The test factor in the check flow continuity operation item at least includes: check flow continuity. The test factor in the check flow encapsulation operation item at least includes: check flow encapsulation.

8. The apparatus of claim 6, wherein, The device further includes a storage module: After obtaining the test script of the test case, an environment variable file is obtained; the environment variable file is set according to the test requirement of the switch to be tested; The test case is recorded in a test case document, and the test case document is stored in a specified storage location according to a storage path indicated by the environment variable file, so that the test script of each test case recorded in the test case document is called based on the storage path indicated by the environment variable file when the test is performed; And / or, the test script of the test case is a Python executable automation script.

9. An electronic device, comprising: The electronic device includes: a processor; and a computer readable storage medium having stored therein computer program instructions, which when executed by the processor, cause the processor to perform the steps of the method of any one of claims 1 to 5.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium has stored thereon computer program instructions, which when executed by a processor, cause the processor to perform the steps of the method of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for generating test case

    CN101984416A

  • Switch test method and related equipment

    CN115695261A