Switch test method and device, electronic equipment and readable storage medium
By obtaining the test factor file of the switch and filtering mutually exclusive test cases using attribute identification, multiple test scripts are automatically generated, which solves the problem of excessive time-consuming writing test scripts in the existing technology, and achieves efficient test development.
Patent Information
- Application Number
- CN202411908737.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-23
AI Technical Summary
When the prior art covers the test development needs of various scenarios, it takes too long to manually write test scripts one by one, which seriously affects the testing efficiency.
By obtaining the switch's test factor file, multiple test scripts are automatically generated, and the attribute identification is used to filter mutually exclusive test cases to improve testing efficiency.
It realizes automated batch combination to generate different test cases and test scripts, covering most test scenarios, meeting diverse test development needs, and improving test development efficiency.
Smart Images

Figure CN119728509A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a switch testing method, device, electronic device and readable storage medium. Background Art
[0002] Ethernet switch products support more and more functions, and the demand for test scenarios of various configurations, operations, and traffic services is growing rapidly. In other words, switches need to be tested in various scenarios.
[0003] At present, the test cases required for each test scenario are manually written, and then the test scripts are written one by one according to the test cases. When it is necessary to cover the test development requirements of various scenarios, this method of manually writing test scripts one by one takes too long and seriously affects the test efficiency. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a switch testing method, an apparatus, an electronic device, and a readable storage medium, so as to automatically generate multiple test scripts, meet diverse test development requirements, and improve test efficiency.
[0005] The present invention provides a switch testing method, which includes:
[0006] Obtain a test factor file of the switch; the test factor file is set according to the test requirements of the switch, and the test factor file includes K test items, where K is greater than 1; any test item includes at least one test factor;
[0007] Take one of the K test items as the current test item, and take each test factor in the current test item as the current test factor;
[0008] Select a test factor from each of the remaining K-1 test items;
[0009] 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 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 moment;
[0010] The test script corresponding to each test case is tested 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 present application also provides a switch testing device, which includes:
[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, and the test factor file includes K test items, K is greater than 1; any test item includes at least one test factor;
[0013] A combination module is used to use one of the K test items as a current test item, and for each test factor in the current test item, use the 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 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 moment;
[0015] The test module is used to 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.
[0016] An embodiment of the present application also provides an electronic device, comprising: 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, enable the processor to execute the steps of the above method.
[0017] An embodiment of the present application also provides a machine-readable storage medium, which stores computer program instructions. When the computer program instructions are executed, the steps of the above method can be implemented.
[0018] It can be seen from the above technical scheme that in this embodiment, after obtaining the test factor file, one test item among the K test items is used as the current test item, and for each test factor in the current test item, the test factor is used as the current test factor; a test factor is selected from each of the remaining K-1 test items respectively, and when the attribute identifier of the selected K-1 test factors is different from the attribute identifier of the current test factor and each test factor in the attribute identifier of the K-1 test factors is also different from each other, the K-1 test factor and the current test factor are combined to obtain a test case; the K-1 test factor 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 moment, and the test script corresponding to each test case is determined based on the test function corresponding to each test factor in the test case, which can automatically combine and generate different test cases and test scripts of different test cases in batches, and test the test script corresponding to each test case, which can not only cover most test scenarios and meet diverse test development needs, but also improve test development efficiency.
[0019] Furthermore, when test cases are combined, exclusive and unreasonable test cases are directly filtered out through the judgment of attribute identification, which can eliminate the test interference caused by mutually exclusive and unreasonable test cases and improve the executability of automated testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of a process for a method provided in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of a test factor file provided in an embodiment of the present application;
[0022] Figure 3 A schematic diagram of obtaining a test case provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of the structure of the device provided in the embodiment of the present application;
[0024] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.
[0026] To facilitate understanding of this method, the existing technical problems are first elaborated in detail before describing this method:
[0027] Ethernet switch products support more and more functions, and the combination of various configurations, operations, and traffic services is growing rapidly. The traditional script development method for single, specific functions cannot effectively meet the test script development needs covering various combination scenarios. It is necessary to test the switch in various scenarios.
[0028] At present, the test cases required for each test scenario are manually written, and then the test scripts are written one by one according to the test cases. When it is necessary to cover the test development requirements of various scenarios, this method of manually writing test scripts one by one takes too long and seriously affects the test efficiency.
[0029] For example, in a typical application scenario, a certain model of switch will use three configurations A, B, and C (that is, configuration A, configuration B, and configuration C), and may also involve three operations D, E, and F (that is, 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] According to the permutations and combinations, there are 3*3*3=27 situations for sending three types of configurations according to different options. Similarly, there are 27 situations for three types of operations. Then, for each configuration, each operation is tested separately, and there will be 27*27=729 specific combinations of configurations and operations.
[0032] At present, the test cases for each situation are manually written, that is, the test scripts (i.e., test codes) for each test case need to be manually written. For example, if a test case performs operations D2, E, and F1 under configurations A1, B1, and C3, the test case and the test script for the test case need to be manually written. This method of manually writing test cases and test scripts for testing is very time-consuming and seriously affects the test efficiency.
[0033] Based on this, the embodiments of the present application provide a switch testing method, device, electronic device and medium, so as to automatically generate a variety of test scripts, which can not only meet the diverse test development needs, but also improve the test efficiency.
[0034] The method provided in the embodiment of the present application is described in detail below:
[0035] See also Figure 1 , Figure 1 A flow chart of the method provided in an embodiment of the present application.
[0036] like Figure 1 As shown, the process may include the following steps:
[0037] S101, obtaining a test factor file of a switch; the test factor file is set according to the test requirements of the switch, and the test factor file includes K test items, where K is greater than 1; any test item includes at least one test factor.
[0038] In this embodiment, the K test items include M configuration items and N operation items, where the test factors in the test items are called configuration factors, and the test factors in the operation items are called operation factors. For ease of explanation, configuration factors and operation factors are used for explanation in the following.
[0039] In this embodiment, any configuration item refers to a type of configuration for the switch, and each configuration factor under the configuration item corresponds to a configuration form under the configuration item. These configuration items cover multiple configurations such as the global configuration of the switch, the logical interface configuration, and the physical interface configuration. Any operation item refers to a type of operation for the switch, and each configuration factor under the operation item corresponds to an operation form under the operation item. The specific forms of the configuration items and operation items will be described later and will not be repeated here.
[0040] S102: Take one of the K test items as the current test item, and take each test factor in the current test item as the current test factor.
[0041] In this embodiment, the current test item is one of the K test items.
[0042] S103, 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 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 moment.
[0043] In this embodiment, the attribute identifier of any test factor is used to characterize whether the test factor is mutually exclusive with other test factors. The so-called mutual exclusive means that the test case composed of the test factor and other factors is unavailable and cannot be executed.
[0044] In specific implementation, attribute identification can be implemented in a variety of forms. For example, the implementation form of attribute identification can be background attribute labels, and mutually exclusive test factors are represented by the same background attribute labels. When the background attribute labels of the selected K-1 test factors and the current test factors are all different, the K-1 test factors and the current test factors are combined to obtain a test case. If the background attribute labels of at least two configuration factors of the selected K-1 test factors and the current test factors are the same, it is determined that the K-1 test factors and the current test factors are mutually exclusive and cannot be combined.
[0045] In this embodiment, a test factor is selected from each of the remaining K-1 test items, and 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. Then, the number of combinations of selecting a test factor from each of the remaining K-1 test items is 6*6*6*6*6*6*6*6=279936. These 279936 combinations need to be judged by attribute identification, and finally the total number of test cases corresponding to the current test factor is less than or equal to 279936.
[0046] In this embodiment, the specific implementation method of obtaining the test case will be described in detail below in the form of a specific embodiment and will not be repeated here.
[0047] S104, 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.
[0048] In this embodiment, the test functions corresponding to the test factors included in each test case constitute the test script of the test case, and running the test script of each test case can obtain the test results of each test case. In this embodiment, the specific implementation method of obtaining the test script of the test case will also be described in the following text in the form of a specific embodiment, and will not be repeated here.
[0049] It should be noted that the test script of the test case is an automated script executable by Python.
[0050] So far, completed Figure 1 The process shown.
[0051] pass Figure 1It can be seen from the shown process that in this embodiment, after obtaining the test factor file, one test item among the K test items is used as the current test item, and for each test factor in the current test item, the test factor is used as the current test factor; a test factor is selected from each of the remaining K-1 test items, and when the attribute identifier of the selected K-1 test factors is different from the attribute identifier of the current test factor and each test factor in the attribute identifier of the K-1 test factors is also different from each other, the K-1 test factor and the current test factor are combined to obtain a test case; the K-1 test factor 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 moment, and the test script corresponding to each test case is determined based on the test function corresponding to each test factor in the test case, which can automatically combine and generate different test cases and test scripts of different test cases in batches, and test the test script corresponding to each test case, which 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, exclusive and unreasonable test cases are directly filtered out through the judgment of attribute identification, which can eliminate the test interference caused by mutually exclusive and unreasonable test cases and improve the executability of automated testing.
[0053] Combine the following Figure 2 Detailed description of test items and configuration items:
[0054] Figure 2 A schematic diagram of a test factor file provided in an embodiment of the present application, such as Figure 2 As shown, the M configuration items include at least one of the following configuration items: traffic inlet type configuration item ( Figure 2 Configuration item 1), flow export 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 entry type configuration item include at least: real tunnel, virtual tunnel, Data Center Interconnect (DCI) tunnel, inter-peer link (IPL) tunnel, single attachment (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: real tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single access circuit AC port, inter-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 include at least: CPU protocol message ( Figure 2 Operation item 1), ordinary data message ( Figure 2 Operation item 2) Check the flow continuity operation item ( Figure 2 3), and check the traffic encapsulation operation item ( Figure 2 4) in the operation item.
[0059] The N operation items include at least one of the following operation items: an uplink route switching operation item, and a fault drill operation item.
[0060] The operation factors in the uplink route switching operation item include at least: equal-cost to non-equivalent, and non-equivalent to equal-cost.
[0061] The operation factors in the fault drill operation items at least include: distributed relay (DR) port failure and recovery, and IPL failure and recovery.
[0062] The operation factors in the flow-on / off check operation item at least include: flow-on / off check.
[0063] The operation factors in the check traffic encapsulation operation item at least include: check traffic encapsulation.
[0064] The above describes the test items and configuration items in detail.
[0065] Combine the following Figure 3 Detailed explanation of how to obtain test cases:
[0066] As an example, Figure 3 As shown in the figure, 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 respectively "DCI tunnel", "three-layer unicast", "ordinary data message", "equal to non-equivalent", "DR port failure and recovery", "check flow connection", and "check flow encapsulation". Figure 3 As shown, the background attribute labels of the eight test factors are all different, and the eight test factors can be combined into one test case.
[0067] As another example, Figure 3 As shown in the figure, the configuration factor "real tunnel" in configuration item 1 is the current test factor. 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 message", "equal to non-equivalent", "DR port failure and recovery", "check flow connection", and "check flow encapsulation". 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 the two are mutually exclusive items. Therefore, these 8 test factors will not be combined.
[0068] In this embodiment, mutually exclusive items with the same background are filtered out in the above manner, so that small-scale tests with relatively simple configuration and operation are refined, interference caused by issuing originally mutually exclusive and unreasonable operations is eliminated, and the executability of automated testing is improved.
[0069] Furthermore, for large-scale tests with relatively complex configurations and operations, by setting different typical configurations to be mutually exclusive, several typical scenarios (for example, by analyzing a large number of typical networking scenarios outside, extracting different routing solutions, network management solutions, link reliability solutions, etc., and filtering and combining them reasonably according to different solutions) can be targeted at the same group of operations (such as network management access, file operations, network shocks, configuration rollbacks, user migration, etc.) for one time. While achieving the above flexibility and convenience, the effective utilization rate of the automated material environment is greatly improved and the operating cost is reduced.
[0070] The above describes in detail how to obtain test cases.
[0071] The following is a detailed description of the test script for obtaining test cases:
[0072] As an embodiment, a test function corresponding to each test factor in a test case is obtained, and the obtained test functions are combined to obtain a test script of the test case.
[0073] For example,
[0074] . . .
[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)
[0087] . . .
[0088] Each line above corresponds to a configuration factor or operation factor, for example, tc.Config_swa(commandsa) corresponds to the "real tunnel" configuration factor of configuration item 1, and tc.Config_swi(commandsi) corresponds to the "equivalence to non-equivalence" operation factor of operation item 1. The test script of the test case is obtained by splicing the above test functions. By analogy, the test script of each test case can be obtained.
[0089] The above describes in detail the test script for obtaining the test case.
[0090] As an embodiment, after obtaining the test script of the test case using the above method, the test case is recorded in a test case document, and the test case document is stored in a designated storage location according to the storage path indicated by the environment variable file, so that when the test module is tested, 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.
[0091] For example, the final test case document is result.txt, and the test case document is run in the following way:
[0092] with open('. / result.txt','r')as f:
[0093] for line in f.readlines():
[0094] exec(line)
[0095] Finally, the test results are obtained and recorded in the local log file for the tester to view.
[0096] The method provided in the embodiment of the present application is described above. The device provided in the embodiment of the present application is described below:
[0097] See also Figure 4 , Figure 4 This is a diagram of the device structure provided in the embodiment of the present application. Figure 4 As shown, the device includes: an acquisition module 401, a combination module 402, and a testing module 403.
[0098] The acquisition module 401 is used to acquire a test factor file of the switch; the test factor file is set according to the test requirements of the switch, and the test factor file includes K test items, where K is greater than 1; any test item includes at least one test factor;
[0099] A combining module 402 is used to use one of the K test items as the current test item, and for each test factor in the current test item, use the test factor as the current test factor;
[0100] 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 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 moment;
[0101] The test module 403 is used to 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.
[0102] In this embodiment, by selecting a configuration factor from the configuration factors under each configuration item under N configuration items, and selecting an operation factor from the operation factors under each operation item under M operation items, multiple test cases are generated based on the N selected configuration factors and the M selected operation factors. This software can batch generate combined test automation scripts and can synchronously output corresponding test case documents, so that testers can obtain readable test cases and corresponding scripts, greatly improving the test case traversal efficiency in black box testing and other requirements.
[0103] Furthermore, in this embodiment, mutually exclusive items with the same background are filtered out, so that small-scale tests with relatively simple configuration and operation are refined, interference caused by issuing originally mutually exclusive and unreasonable operations is eliminated, and the executability of automated testing 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] Traffic inlet type configuration items, traffic outlet type configuration items, traffic encapsulation configuration items, and traffic content configuration items:
[0107] The test factors in the traffic entry type configuration item include at least: real tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single 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 AC port, cross-board AC port, virtual interface, routing interface, 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 packets and common data packets;
[0111] The N operation items include at least one of the following operation items:
[0112] Uplink route switching operation items and fault drill operation items;
[0113] The test factors in the uplink route switching operation item include at least: equivalent switching to non-equivalent switching, and non-equivalent switching to equivalent switching;
[0114] The test factors in the fault drill operation items include at least: DR port failure and recovery, and IPL failure and recovery.
[0115] As an embodiment, the N operation items further include: a flow on / off check operation item, and a flow encapsulation check operation item;
[0116] Among them, the test factors in the flow on / off check operation item at least include: flow on / off check;
[0117] The test factors in the check traffic encapsulation operation item at least include: check traffic encapsulation.
[0118] As an embodiment, the device further includes a storage module:
[0119] 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 requirements of the switch to be tested;
[0120] The test case is recorded in a test case document, and the test case document is stored in a designated storage location according to the storage path indicated by the environment variable file, so that the test scripts of each test case recorded in the test case document are called based on the storage path indicated by the environment variable file during the test.
[0121] As an embodiment, the test script of the test case is a Python executable automation script. Figure 4 Structural description of the device shown.
[0122] See also Figure 5 , Figure 5 This is a structural diagram of an electronic device provided in an embodiment of the present application. Figure 5 As shown, the hardware structure may include: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application.
[0123] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.
[0124] Exemplarily, the above-mentioned machine-readable storage medium can be any electronic, magnetic, optical or other physical storage device that can contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium can be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as CD, DVD, etc.), or similar storage medium, or a combination thereof.
[0125] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A switch testing method, characterized in that: The method comprises: Obtain a 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, K is greater than 1; any test item includes at least one test factor; Taking one of the K test items as the current test item, and taking each test factor in the current test item as the current test factor; Select a test factor from each of the remaining K-1 test items; 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 case obtained before the current moment; The test script corresponding to each test case is tested 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.
2. The method according to claim 1, characterized in that The K test items include M configuration items and N operation items; The M configuration items include at least one of the following configuration items: Traffic inlet type configuration items, traffic outlet type configuration items, traffic encapsulation configuration items, and traffic content configuration items: The test factors in the traffic entry type configuration item include at least: real tunnel, virtual tunnel, data center interconnect DCI tunnel, peer link IPL tunnel, single AC port, cross-board AC port, virtual interface, routing port, and routing sub-interface; The test factors in the traffic egress type configuration item include at least: real tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single access circuit AC port, cross-board AC port, virtual interface, routing interface, and routing sub-interface; The test factors in the traffic encapsulation configuration item include at least: broadcast, unknown unicast, multicast, layer 2 unicast, and layer 3 unicast; The test factors in the traffic content configuration item include at least: CPU protocol messages and ordinary data messages; The N operation items include at least one of the following operation items: Uplink route switching operation items and fault drill operation items; The test factors in the uplink route switching operation item include at least: equivalent to non-equivalent, and non-equivalent to equivalent; The test factors in the fault drill operation items include at least: distributed aggregation DR port failure and recovery, and IPL failure and recovery.
3. The method according to claim 2, characterized in that The N operation items also include: a flow on / off check operation item and a flow encapsulation check operation item; Among them, the test factors in the check flow on / off operation item at least include: check flow on / off; The test factors in the check traffic encapsulation operation item at least include: check traffic encapsulation.
4. The method according to claim 1, characterized in that: The method further comprises: Obtaining an environment variable file; wherein the environment variable file is set according to the test requirements 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 designated storage location according to the storage path indicated by the environment variable file, so that the test scripts of each test case recorded in the test case document are called based on the storage path indicated by the environment variable file when performing the test.
5. The method according to claim 1, characterized in that The test script of the test case is an automated script executable by Python.
6. A switch testing method and device, characterized in that: The device comprises: An acquisition module is used to acquire a test factor file of a switch; the test factor file is set according to the test requirements of the switch, the test factor file includes K test items, K is greater than 1; any test item includes at least one test factor; A combination module, configured to use one of the K test items as a current test item, and for each test factor in the current test item, use the test factor as the current test factor; 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 case obtained before the current moment; The test module is used to 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.
7. The device according to claim 6, characterized in that The K test items include M configuration items and N operation items; The M configuration items include at least one of the following configuration items: Traffic inlet type configuration items, traffic outlet type configuration items, traffic encapsulation configuration items, and traffic content configuration items: The test factors in the traffic entry type configuration item include at least: real tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single AC port, cross-board AC port, virtual interface, routing port, and routing sub-interface; The test factors in the traffic egress type configuration item include at least: real tunnel, virtual tunnel, DCI tunnel, IPL tunnel, single AC port, cross-board AC port, virtual interface, routing interface, and routing sub-interface; The test factors in the traffic encapsulation configuration item include at least: broadcast, unknown unicast, multicast, layer 2 unicast, and layer 3 unicast; The test factors in the traffic content configuration item include at least: CPU protocol messages and ordinary data messages; The N operation items include at least one of the following operation items: Uplink route switching operation items and fault drill operation items; The test factors in the uplink route switching operation item include at least: equivalent to non-equivalent, and non-equivalent to equivalent; The test factors in the fault drill operation items include at least: DR port failure and recovery, and IPL failure and recovery; and / or, The N operation items also include: a flow on / off check operation item and a flow encapsulation check operation item; Among them, the test factors in the check flow on / off operation item at least include: check flow on / off; The test factors in the check traffic encapsulation operation item at least include: check traffic encapsulation.
8. The device according to claim 6, characterized in that The device also includes a storage module: Used to obtain an environment variable file after obtaining the test script of the test case; the environment variable file is set according to the test requirements 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 designated storage location according to the 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 an automated script executable by Python.
9. An electronic device, characterized in that: The electronic device includes: Processor; and A computer-readable storage medium, wherein computer program instructions are stored in the computer-readable storage medium, and when the computer program instructions are executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by a processor, enable the processor to perform the steps of any one of the methods of claims 1 to 5.
Citation Information
Patent Citations
Method and device for generating test case
CN101984416A
Switch test method and related equipment
CN115695261A
Method and system for testing switch by using digital twinning technology
CN116633836A
Test case generation method and device, computing equipment and storage medium
CN117435455A
Generation and test methods of batch test cases, electronic equipment and storage medium
CN118132440A