A network card automatic test script generation method, device, equipment and medium
By determining the optimal number of processes and threads of the network card and generating corresponding test scripts, the problem of not being able to effectively obtain the maximum bandwidth of the network card in the existing technology is solved, and high-accurate network card performance testing is achieved.
Patent Information
- Application Number
- CN202211199115.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-09-29
AI Technical Summary
The prior art cannot effectively obtain the maximum bandwidth of the network card, especially when the network card rate is greater than 30G/s, the test data is prone to distortion.
By determining the optimal number of processes and the optimal number of threads, a test script is generated for the network card maximization performance test. The specific steps include adjusting the number of processes when the number of threads remains unchanged and measuring the number of processes corresponding to the maximum bandwidth value; adjusting the number of threads when the number of processes remains unchanged and measuring the number of threads corresponding to the maximum bandwidth value; determining the test configuration information based on the optimal number of processes, the optimal number of threads and the preset error value; finally generating a test script to achieve maximum performance testing of the network card.
It accurately obtains the maximum bandwidth of the network card under the optimal configuration state of the network card, improves the accuracy and efficiency of network card performance testing, and avoids test data distortion caused by network congestion.
Smart Images

Figure CN115604165B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automated testing technology, and in particular to a method, device, equipment and medium for generating an automatic test script for a network card. Background Art
[0002] The network card rates of current server configurations are generally distributed in 30G / s, 50G / s, and 100G / s, while the mainstream network performance testing tools iperf and netperf have a maximum test rate of 30G / s. In order to obtain the maximum performance bandwidth of the network card on the server, the number of processes and threads of the test program must be continuously adjusted, which provides the necessity for automated testing of the network card.
[0003] At present, the following two solutions are mainly used for network card automation testing: 1. First, query the network card information of the test system, search the local database to obtain the performance test configuration of the corresponding network card; then configure the test system according to the obtained configuration and start the test. 2. Always start the netserver service at the remote end of the test system, and start the test at the other end according to the needs when the test starts. The above solution 1 is based on the best solution configuration obtained from previous debugging, but different servers have different network card links, CPU architectures, and memory capacities. It is not accurate to reuse the test data of other models. Secondly, this solution is not applicable to the network card introduced for the first time, and manual testing is still required to enter the local database. The above solution 2 does not take into account the bottlenecks of performance tests such as netperf, and is only applicable to network card tests with a rate less than 30G / s. When the rate of the network card is greater than 30G / s, the data will be distorted.
[0004] Therefore, the above two solutions cannot obtain the maximum bandwidth of the network card of the test object. Summary of the invention
[0005] The purpose of the present invention is to provide a method, device, equipment and medium for generating an automatic test script for a network card, so as to improve the problem in the prior art that the maximum bandwidth of the network card of the test object cannot be obtained.
[0006] In a first aspect, an embodiment of the present application provides a method for generating an automatic test script for a network card, comprising the following steps:
[0007] Determine the optimal number of processes and threads. The optimal number of processes is the number of processes corresponding to the maximum bandwidth value when different numbers of processes are input into the test system while the number of threads remains unchanged. The optimal number of threads is the number of threads corresponding to the maximum bandwidth value when different numbers of threads are input into the test system while the number of processes remains unchanged.
[0008] Determine test configuration information according to the optimal number of processes, the optimal number of threads and the preset error value;
[0009] Generate a test script for maximizing network card performance testing based on the test configuration information.
[0010] Based on the first aspect, in some embodiments of the present invention, determining the optimal number of processes includes the following steps:
[0011] Determine the common value of the number of threads;
[0012] Get the initial number of processes and the step value of the number of processes;
[0013] Starting from the initial process number, the process number is increased in sequence according to the process number step value, and the obtained new process number and thread number common values are input into the test system for testing, so as to obtain a plurality of first bandwidth values;
[0014] The number of processes corresponding to the maximum value among the multiple first bandwidth values is taken as the optimal number of processes.
[0015] Based on the first aspect, in some embodiments of the present invention, before the step of taking the number of processes corresponding to the maximum value among the multiple first bandwidth values as the optimal number of processes, the following steps are also included:
[0016] Recording the first bandwidth value in real time, and obtaining a real-time change trend of the first bandwidth value according to the first bandwidth value;
[0017] When the real-time change trend of the first bandwidth value reaches an inflection point, the test is stopped to obtain multiple first bandwidth values.
[0018] Based on the first aspect, in some embodiments of the present invention, determining the optimal number of threads includes the following steps:
[0019] Determine the common value of the number of processes;
[0020] Get the initial number of threads and the thread number step value;
[0021] Starting from the initial number of threads, the number of threads is increased in sequence according to the step value of the number of threads, and the obtained new number of threads and the common value of the number of threads are input into the test system for testing, so as to obtain a plurality of second bandwidth values;
[0022] The number of threads corresponding to the maximum value of the multiple second bandwidth values is used as the optimal number of threads.
[0023] Based on the first aspect, in some embodiments of the present invention, determining test configuration information according to the optimal number of processes, the optimal number of threads and a preset error value includes the following steps:
[0024] Determine the range of process number and thread number according to the optimal number of processes, the optimal number of threads and the preset error value;
[0025] According to the value range of the number of processes and the value range of the number of threads, the number of processes and the number of threads are combined to obtain multiple groups of configuration information, and the multiple groups of configuration information are used as test configuration information.
[0026] Based on the first aspect, in some embodiments of the present invention, the following steps are further included:
[0027] Add delay commands at both ends of the test script to obtain a new test script;
[0028] Send the new test script to the remote end for testing.
[0029] Based on the first aspect, in some embodiments of the present invention, sending a new test script to a remote end for testing includes the following steps:
[0030] Use the scp command to copy the new test script to the remote end;
[0031] The control end and the remote end simultaneously start a new test script for testing.
[0032] In a second aspect, an embodiment of the present application provides a network card automatic test script generation device, comprising:
[0033] The parameter determination module is used to determine the optimal number of processes and the optimal number of threads. The optimal number of processes is the number of processes corresponding to the maximum bandwidth value measured by inputting different numbers of processes into the test system when the number of threads remains unchanged. The optimal number of threads is the number of threads corresponding to the maximum bandwidth value measured by inputting different numbers of threads into the test system when the number of processes remains unchanged.
[0034] A test configuration information determination module, used to determine the test configuration information according to the optimal number of processes, the optimal number of threads and a preset error value;
[0035] The script generation module is used to generate a test script for maximizing the performance of the network card according to the test configuration information.
[0036] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory for storing one or more programs and a processor. When the one or more programs are executed by the processor, any method in the first aspect is implemented.
[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method as described in any one of the first aspects above.
[0038] The embodiments of the present invention have at least the following advantages or beneficial effects:
[0039] The embodiment of the present invention provides a method, device, equipment and medium for generating an automatic test script for a network card. By determining the optimal number of processes and the optimal number of threads, the optimal number of processes is input into a test system with different numbers of processes when the number of threads remains unchanged, and the number of processes corresponding to the maximum bandwidth value is measured, and the optimal number of threads is input into a test system with different numbers of threads when the number of processes remains unchanged, and the number of threads corresponding to the maximum bandwidth value is measured, so that the optimal configuration state of the network card can be determined; then, according to the optimal number of processes, the optimal number of threads and the preset error value, the test configuration information is determined, and by adding the error value, the number of processes and the number of threads are within a certain range, and then a variety of configuration combinations can be obtained, and the maximum bandwidth of the network card is obtained by traversing the number of processes and the number of threads, so that the test is more refined; finally, a test script for maximizing the performance test of the network card is generated according to the test configuration information, and the test script is obtained under the optimal configuration state of the network card, and contains a refined configuration combination, and the maximum bandwidth of the network card can be accurately obtained by executing the test script, so as to achieve the maximization performance test. The generated test script automatically traverses the number of processes and the number of threads without manual testing, thereby improving the work efficiency and accuracy of the staff in the network card performance test. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0041] Figure 1 A flow chart of a method for generating a network card automatic test script provided by an embodiment of the present invention;
[0042] Figure 2 A schematic diagram of a structure for determining the optimal number of processes provided by an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of a structure for determining the optimal number of threads provided by an embodiment of the present invention;
[0044] Figure 4 A schematic diagram of a maximum bandwidth test structure provided by an embodiment of the present invention;
[0045] Figure 5 A flow chart of a test execution scheme for avoiding network congestion problems provided by an embodiment of the present invention;
[0046] Figure 6 A structural block diagram of a network card automatic test script generation device provided by an embodiment of the present invention;
[0047] Figure 7A structural block diagram of an electronic device provided by an embodiment of the present invention.
[0048] Icons: 110 - parameter determination module; 120 - test configuration information determination module; 130 - script generation module; 101 - memory; 102 - processor; 103 - communication interface. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0050] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0051] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0052] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0053] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0054] The network card rates of current server configurations are generally distributed in 30G / s, 50G / s, and 100G / s, while the mainstream network performance testing tools iperf and netperf have a maximum test rate of 30G / s. In order to obtain the maximum performance bandwidth of the network card on the server, the number of processes and threads of the test program must be continuously adjusted, which provides the necessity for automated testing of the network card.
[0055] The embodiment of the present invention provides a method for generating a network card automatic test script. Figure 1 and Figure 4 , Figure 1 A flow chart of a method for generating a network card automatic test script provided by an embodiment of the present invention, Figure 4 The maximum bandwidth test structure diagram provided by the embodiment of the present invention. The network card automatic test script generation method comprises the following steps:
[0056] Step S110: Determine the optimal number of processes and the optimal number of threads. The optimal number of processes is to input different numbers of processes into the test system when the number of threads remains unchanged, and measure the number of processes corresponding to the maximum bandwidth value. The optimal number of threads is to input different numbers of threads into the test system when the number of processes remains unchanged, and measure the number of threads corresponding to the maximum bandwidth value. A process is an independent unit for resource allocation and scheduling, and a thread is a basic unit for CPU scheduling. The same process can include multiple threads, and the threads share the resources of the entire process. A process includes at least one thread. To measure the maximum performance of the network card, it is mainly necessary to adjust two parameters: the number of processes and the number of threads of the test program. The number of processes plays a major role. By determining the optimal number of processes and the optimal number of threads, the configuration is determined according to the actual network card, ensuring the accuracy of the test data.
[0057] In this embodiment, the above-mentioned optimal number of processes and the optimal number of threads can be determined by testing the network card, or the tester can obtain the optimal number of processes and the optimal number of threads of the network card based on experience or other means. To measure the maximum performance of the network card, it is necessary to adjust two parameters, the number of processes and the number of threads in the test program, and the number of processes plays a major role. By determining the optimal number of processes and the optimal number of threads, the number of processes and the number of threads of the network card at the optimal configuration can be known.
[0058] Among them, in order to accurately determine the optimal number of processes and the optimal number of threads that actually need to be tested for the network card, the network card that actually needs to be tested can be tested. When the number of threads remains unchanged, different numbers of processes can be input into the test system, and the number of processes corresponding to the maximum bandwidth value can be measured, which is the optimal number of processes; when the number of processes remains unchanged, different numbers of threads can be input into the test system, and the number of threads corresponding to the maximum bandwidth value can be measured, which is the optimal number of threads.
[0059] Please see Figure 2 , Figure 2 A schematic diagram of a structure for determining the optimal number of processes provided by an embodiment of the present invention. Specifically, determining the optimal number of processes includes the following steps:
[0060] First, determine the common value of the number of threads; the common value of the number of threads is a common value, which can be determined according to the actual type of network card. For example, the common value of the number of threads is 3. For CPU-intensive computing scenarios, theoretically, the number of threads = the number of CPU cores is the most appropriate. However, in engineering, the number of threads is generally set to the number of CPU cores + 1. In this way, when a thread is blocked due to occasional memory page failure or other reasons, this extra thread can take over, thereby ensuring CPU utilization.
[0061] Then, obtain the initial number of processes and the step value of the number of processes; the above initial number of processes can be set by the tester, or calculated based on the nominal rate of the network card. The specific calculation process is: divide the nominal rate of the network card by 30 and then round up to an integer. For example: if the nominal rate of the network card to be tested is 50G / s, then divide 50 by 30 to get 1.66, and then round up to get the initial number of processes as 2. The above step value of the number of processes refers to the number of processes that are incremented. This value is a positive integer and can be set by the tester according to the actual situation. The smaller the step value of the number of processes, the finer the value of the number of processes, making the test more refined, and thus making the optimal number of processes more accurate.
[0062] Then, starting from the initial process number, the process number is increased in sequence according to the process number step value, and the obtained new process number and thread number common values are input into the test system for testing, so as to obtain a plurality of first bandwidth values;
[0063] Since bandwidth often increases first and then decreases as the number of processes increases, the same is true for the number of threads. Therefore, in order to quickly find the maximum bandwidth value, the first bandwidth value can be recorded in real time, and the real-time change trend of the first bandwidth value can be obtained based on the first bandwidth value; when the real-time change trend of the first bandwidth value has an inflection point, the test is stopped to obtain multiple first bandwidth values. The above-mentioned real-time change trend of the first bandwidth value refers to comparing the current first bandwidth value with the previous first bandwidth value to determine the direction of the first bandwidth value. If it has been increasing before and the current first bandwidth value decreases, it means that an inflection point has occurred, then the test can be stopped to obtain multiple first bandwidth values.
[0064] Finally, the number of processes corresponding to the maximum value among the multiple first bandwidth values is taken as the optimal number of processes. For example, if the initial number of processes is N, then starting from N, the number of processes is increased according to the step value to obtain multiple different numbers of processes, and the bandwidth values are measured under different numbers of processes in turn, and then the number of processes L corresponding to the maximum bandwidth value is obtained, and L is taken as the optimal number of processes.
[0065] For example: determine that the number of threads is 5, the initial number of processes is 4, and increase it by a step of 1. The number of processes obtained are 4, 5, 6, 7, 8, 9..., then test according to: the number of threads is 5, the number of processes is 4; the number of threads is 5, the number of processes is 5; the number of threads is 5, the number of processes is 6; the number of threads is 5, the number of processes is 7; the number of threads is 5, the number of processes is 8; the number of threads is 5, the number of processes is 9... to obtain multiple maximum bandwidth values, select the maximum value from the multiple maximum bandwidth values, and take the number of processes corresponding to the maximum value as the optimal number of processes.
[0066] By increasing the number of processes in sequence while keeping the number of threads unchanged, multiple configuration combinations of the number of threads and the number of processes can be obtained, and the configuration combinations are tested separately to make the test more precise, obtain more bandwidth values, and thus obtain a more accurate optimal number of processes.
[0067] The process of determining the optimal number of threads is similar to the above steps for determining the optimal number of processes. Figure 3 , Figure 3 The schematic diagram of the optimal thread number determination structure provided by the embodiment of the present invention is as follows:
[0068] First, determine the commonly used value for the number of processes. The commonly used value for the number of processes is a commonly used value, which can be set by the tester according to the actual situation or according to the number of CPU cores, such as 3 times the number of CPU cores.
[0069] Then, the initial number of threads and the step value of the number of threads are obtained; the initial number of threads can be set by the tester, and in order to make the test more accurate, the initial number of threads can be set to 1. The step value of the number of threads refers to the number of threads that are incremented, and the value is a positive integer, which can be set by the tester according to the actual situation. The smaller the step value of the number of threads, the finer the value of the number of threads, making the test more refined, so that the optimal number of threads is more accurate.
[0070] Then, starting from the initial number of threads, the number of threads is increased in sequence according to the thread number step value, and the obtained new number of threads and the common value of the number of threads are input into the test system for testing, so as to obtain a plurality of second bandwidth values;
[0071] Since bandwidth often increases first and then decreases with the increase of the number of processes, the same is true for the number of threads. Therefore, in order to quickly find the maximum bandwidth value, the second bandwidth value can be recorded and the change trend of the second bandwidth value can be checked. When an inflection point appears, the test is stopped to obtain multiple second bandwidth values. The process of determining the inflection point is similar to the process of determining the number of processes, and will not be repeated here.
[0072] Finally, the number of threads corresponding to the maximum value among the multiple second bandwidth values is taken as the optimal number of threads. For example, the initial number of threads starts from 1, and increases according to the thread number step value to obtain multiple different numbers of threads, and the bandwidth values are measured under different numbers of threads in turn, and then the number of threads M corresponding to the maximum bandwidth value is obtained, and M is taken as the optimal number of processes.
[0073] For example: determine that the number of processes is 6, the initial number of threads is 1, and increase it by a step of 1. The obtained thread numbers are 1, 2, 3, 4, 5, 6, 7, ..., then test them according to: the number of threads is 1, the number of processes is 6; the number of threads is 2, the number of processes is 6; the number of threads is 3, the number of processes is 6; the number of threads is 4, the number of processes is 6; the number of threads is 5, the number of processes is 6; the number of threads is 6, the number of processes is 6..., and multiple maximum bandwidth values are obtained. The maximum value is selected from the multiple maximum bandwidth values, and the number of threads corresponding to the maximum value is used as the optimal number of threads.
[0074] By increasing the number of threads in sequence while keeping the number of processes unchanged, multiple configuration combinations of the number of threads and the number of processes can be obtained, and the configuration combinations are tested separately to make the test more precise, obtain more bandwidth values, and thus obtain a more accurate optimal number of threads.
[0075] Step S120: Determine test configuration information according to the optimal number of processes, the optimal number of threads and the preset error value; the above-mentioned optimal number of processes and the optimal number of threads represent the best parameter configuration of the network card, and the above-mentioned preset error value can be set by the tester according to the actual situation. The optimal number of processes and the optimal number of threads can be adjusted by the set error value, so as to obtain a new optimal number of processes and a new optimal number of threads, so as to obtain better test configuration information. The above-mentioned test configuration information includes the value of the number of threads and the value of the number of processes.
[0076] In order to obtain more detailed test configuration information, the process of determining the test configuration information includes the following steps:
[0077] Firstly, according to the optimal number of processes, the optimal number of threads and the preset error value, the range of the number of processes and the range of the number of threads are determined;
[0078] Then, according to the process number value range and the thread number value range, the process number and the thread number are combined to obtain multiple sets of configuration information, and the multiple sets of configuration information are used as test configuration information. The larger the above error value, the wider the obtained process number value range and thread number value range, the more configuration combinations are obtained, and the accuracy of the test is improved.
[0079] For example, if the error value is t, the optimal number of processes is L, and the optimal number of threads is M, then the range of the number of processes is [Lt:L+t], and the range of the number of threads is [Mt:M+t], and then (2t+1)*(2t+1) configurations can be generated. Taking t=1 as an example, the test configuration information can be obtained as [(L-1)*(M-1); (L-1)*(M); (L-1)*(M+1); (L)*(M-1); (L)*(M); (L)*(M+1); (L+1)*(M-1); (L+1)*(M); (L+1)*(M+1)], which is 9 configurations. Then, the network card rate can be tested in the above configurations and compared to get the maximum value.
[0080] By setting the error value, the number of processes and threads can be within a range of values, and then multiple configurations can be obtained through combination, making the test more precise and thus more accurate.
[0081] Step S130: Generate a test script for maximizing performance test of the network card according to the test configuration information. By inputting the test configuration information into the test system, a test script for maximizing performance test of the network card can be obtained, and by executing the test script, the maximum bandwidth of the network card can be obtained, thereby realizing the maximizing performance test of the network card.
[0082] In the above implementation process, by determining the optimal number of processes and the optimal number of threads, the optimal number of processes is the number of processes corresponding to the maximum bandwidth value when the number of threads remains unchanged, and the optimal number of threads is the number of threads corresponding to the maximum bandwidth value when the number of processes remains unchanged, so that the optimal configuration state of the network card can be determined; then according to the optimal number of processes, the optimal number of threads and the preset error value, the test configuration information is determined, and by adding the error value, the number of processes and the number of threads are within a certain range, and then a variety of configuration combinations can be obtained, and the maximum bandwidth of the network card is obtained by traversing the number of processes and the number of threads, so that the test is more refined; finally, a test script for the maximum performance test of the network card is generated according to the test configuration information, and the test script is obtained under the optimal configuration state of the network card and contains a refined configuration combination. By executing the test script, the maximum bandwidth of the network card can be accurately obtained, thereby realizing the maximum performance test. The generated test script automatically traverses the number of processes and threads without manual testing, thereby improving the work efficiency and accuracy of the staff in the network card performance test.
[0083] During the performance maximization test of the network card, network congestion may cause delays in the operation of automated instructions, resulting in distortion of test data. Therefore, in order to avoid distortion of test data caused by network congestion, you can also perform network congestion avoidance. Please refer to Figure 5, Figure 5 A flow chart of a test execution scheme for avoiding network congestion provided by an embodiment of the present invention. Specifically, the following steps are included:
[0084] First, add delay commands at both ends of the test script to obtain a new test script; the above-mentioned automatic generation of the number of processes in the test script based on the input number of threads and processes is implemented through a for loop, and the flag is incremented in the manner of 1, 2, 3, 4, 5... When the flag is less than M, write an iperf***& or netperf***& program to the test script once and specify the port number. The number of threads is specified using the -p parameter provided by the program. Since the control program will send the test script to both ends of the test in the form of a file during the execution of the test, it is possible to add a delay before and after the file, so that the test system will have a significant time interval between the test and the instruction issuance, thereby avoiding instruction delays or issuance failures caused by network congestion.
[0085] Then, the new test script is sent to the remote end for testing. When the test system is used for testing, it includes a control end and a remote end. The control end is used to generate and issue instructions, and the remote end is used to execute the test script for testing. The remote end may include multiple remote servers. The new test script is sent to the remote end in text form through the control end. The new test script can be copied to the remote end through the scp command; then the control end and the remote end simultaneously start the new test script for testing. After the test is completed, wait for the network to return to normal, and then collect the test logs and capture the results.
[0086] In the above implementation process, by adding delay commands at both ends of the test script and staggering control and testing, the test system will have an obvious time interval between testing and issuing instructions, thereby avoiding instruction delays or issuance failures caused by network congestion and further improving the accuracy of test data.
[0087] In the specific implementation process, if you want to measure the maximum performance of the network card, you mainly need to adjust two parameters, the number of processes and the number of threads of the test program. Among them, the number of processes plays a major role, and the bandwidth often increases first and then decreases with the increase of the number of processes. The same is true for the number of threads.
[0088] In order to obtain the network card automatic test script, when implementing the test, first take a common value for the number of threads, which can be set by the tester based on experience or actual test requirements. The number of processes can be incremented from N, with an increment of 1, where N is the network card nominal rate / 30 and rounded up. For example, if the network card nominal rate is 100, the value of N is 4. Then, the test is performed under different numbers of processes obtained by incrementing. Specifically, the number of threads and the number of processes are input into the test system for testing to obtain different bandwidth values. The bandwidth value obtained by the test is monitored in real time. When the bandwidth value increases first and then decreases, the test is stopped, and the previous bandwidth value when it decreases is taken as the maximum bandwidth value, so as to obtain the optimal number of processes L corresponding to the maximum bandwidth value. Among them, the regulation of the number of processes is realized through a for loop, and the flag is incremented in the manner of 1, 2, 3, 4, 5... When the flag is less than M, an iperf***& or netperf***& program is written to the test script once and the port number is specified. The number of threads is specified using the -p parameter provided by the program.
[0089] For example: determine that the number of threads is 6, the initial number of processes is 4, and increase it by a step of 1. The number of processes obtained is 4, 5, 6, 7, 8, 9..., then test according to: the number of threads is 6, the number of processes is 4; the number of threads is 6, the number of processes is 5; the number of threads is 6, the number of processes is 6; the number of threads is 6, the number of processes is 6; the number of threads is 6, the number of processes is 7; the number of threads is 6, the number of processes is 8; the number of threads is 6, the number of processes is 9... to obtain multiple maximum bandwidth values, select the maximum value from the multiple maximum bandwidth values, and take the number of processes corresponding to the maximum value as the optimal number of processes.
[0090] By increasing the number of processes in sequence while keeping the number of threads unchanged, multiple configuration combinations of the number of threads and the number of processes can be obtained, and the configuration combinations are tested separately to make the test more precise, obtain more bandwidth values, and thus obtain a more accurate optimal number of processes.
[0091] Then, determine the number of threads corresponding to the maximum bandwidth value, which is the same as the number of processes corresponding to the maximum bandwidth value mentioned above. First, take a common value for the number of processes, which can be set by the tester based on experience or actual test requirements. Then increase the number of threads from 1, and the increment step is 1, then the number of threads can be: 1, 2, 3... Then test under different numbers of threads in sequence, specifically input the number of threads and the number of processes into the test system for testing, obtain multiple bandwidth values, monitor the bandwidth values obtained by the test in real time, stop the test when the bandwidth value increases first and then decreases, and take the previous bandwidth value when it decreases as the maximum bandwidth value, and then obtain the optimal number of threads M corresponding to the maximum bandwidth value. By increasing the number of threads in sequence while keeping the number of processes unchanged, multiple configuration combinations of the number of threads and the number of processes can be obtained, and the configuration combinations are tested separately, so that the test is more refined, more bandwidth values are obtained, and the optimal number of threads is more accurate.
[0092] For example: determine that the number of processes is 5, the initial number of threads is 1, and increase it by a step of 1. The obtained thread numbers are 1, 2, 3, 4, 5, 6, 7, ..., then test according to: the number of threads is 1, the number of processes is 5; the number of threads is 2, the number of processes is 5; the number of threads is 3, the number of processes is 5; the number of threads is 4, the number of processes is 5; the number of threads is 5, the number of processes is 5; the number of threads is 6, the number of processes is 5... to obtain multiple maximum bandwidth values, select the maximum value from the multiple maximum bandwidth values, and take the number of threads corresponding to the maximum value as the optimal number of threads.
[0093] By determining the optimal number of processes and threads, the configuration is determined based on the actual network card, ensuring the accuracy of the test data.
[0094] Then, an error value t is taken, where the larger the value of t is, the more refined the test is and the more accurate the test results are. As the value of t increases, the accuracy of the test system will increase, but the time consumption will increase. Therefore, the error value can be set by the tester based on the actual situation and comprehensive consideration. By setting the error value, the number of processes and threads can be within a range of values, and then multiple configurations can be obtained through combination, making the test more refined and the test accuracy higher.
[0095] Then, after the error value is determined, the range of the number of threads and the number of processes is determined according to the optimal number of processes and the optimal number of threads obtained above. The values of the number of threads are respectively between the optimal number of threads ± the error value range, and the values of the number of processes are respectively between the optimal number of processes ± the error value range. That is, the number of processes is between [Lt:L+t], and the number of threads is between [Mt:M+t]. Combining the number of processes and the number of threads, (t+1)*(t+1) configurations can be generated. Taking t=1 as an example, the test configurations obtained are: [(L-1)*(M-1); (L-1)*(M); (L-1)*(M+1); (L)*(M-1); (L)*(M); (L)*(M+1); (L+1)*(M-1); (L+1)*(M); (L+1)*(M+1)].
[0096] For example: the optimal number of threads is 5, the optimal number of processes is 6, and the error value is 1. The value range of the number of threads is [4:6], and the value range of the number of processes is [5:7]. The test configurations obtained after permutations and combinations are: 4 threads, 5 processes; 4 threads, 6 processes; 4 threads, 7 processes; 5 threads, 5 processes; 5 threads, 6 processes; 5 threads, 7 processes; 6 threads, 5 processes; 6 threads, 6 processes; 6 threads, 7 processes.
[0097] Then, according to the various test configurations obtained above, corresponding test scripts can be generated, and the test scripts can be used to test the network card rate in the above configurations. By inputting the test configuration information into the test system, a test script for maximizing the performance test of the network card can be obtained, and by executing the test script, the maximum bandwidth of the network card can be obtained, thereby realizing the maximizing performance test of the network card.
[0098] During the test process, in order to avoid delays in the operation of automated instructions due to network congestion, which would lead to distortion of test data, delays were added to the front and back ends of the obtained test script to obtain a new test script. By adding delays before and after the file, the test system will have an obvious time interval between the test and the issuance of instructions, thereby avoiding delays or failures in issuing instructions caused by network congestion. By adding delay commands to the front and back ends of the test script and staggering control and testing, the test system will have an obvious time interval between the test and the issuance of instructions, thereby avoiding delays or failures in issuing instructions caused by network congestion, further improving the accuracy of test data.
[0099] When using the test system for testing, it includes a control end and a remote end. The control end is used to generate and issue instructions, and the remote end is used to execute test scripts for testing. The remote end may include multiple remote servers. The above-mentioned operation of generating test scripts can be completed on the control end. The control end is connected to multiple remote servers for testing. After obtaining a new test script, the new test script is copied from the control end to each remote server through the scp command. In this way, the control end and each remote server have a new test script.
[0100] Then, the test is started simultaneously on the control end and multiple remote servers. When executing a new test script, the first step is to enter the delay in the new test script. When the delay ends, the test script is executed. After the new test script is executed, it enters the delay at the end of the new test script again. After the delay waits for the network to return to normal, it starts to process the test data and compares the maximum value. By collecting the test logs and capturing the results, the test results are obtained.
[0101] For example, the test configuration in the new test script includes 4 threads and 5 processes; 4 threads and 6 processes; 4 threads and 7 processes; 5 threads and 5 processes; 5 threads and 6 processes; 5 threads and 7 processes; 6 threads and 5 processes; 6 threads and 6 processes; 6 threads and 7 processes. When executing the new test script, first enter the delay, and then start to execute the test script, that is, test the bandwidth under different test configurations respectively, and then enter the delay to get the network back to normal, compare the obtained bandwidth size, and get the maximum bandwidth value. For example, the bandwidths obtained by the above test configuration are 40G / s, 45G / s, 48G / s, 41G / s, 50G / s, 45G / s, 43G / s, 47G / s, and 48G / s respectively. By comparison, the maximum bandwidth is 50G / s.
[0102] In the above implementation process, by determining the optimal number of processes and the optimal number of threads, the optimal number of processes is the number of processes corresponding to the maximum bandwidth value when the number of threads remains unchanged, and the optimal number of threads is the number of threads corresponding to the maximum bandwidth value when the number of processes remains unchanged, so that the optimal configuration state of the network card can be determined; then according to the optimal number of processes, the optimal number of threads and the preset error value, the test configuration information is determined, and by adding the error value, the number of processes and the number of threads are within a certain range, and then a variety of configuration combinations can be obtained, and the maximum bandwidth of the network card is obtained by traversing the number of processes and the number of threads, so that the test is more refined; then according to the test configuration information, a test script for the maximum performance test of the network card is generated, and the test script is obtained under the optimal configuration state of the network card, and contains a refined configuration combination. By executing the test script, the maximum bandwidth of the network card can be accurately obtained, thereby realizing the maximum performance test. The generated test script automatically traverses the number of processes and threads without manual testing, thereby improving the work efficiency and accuracy of the staff in the network card performance test. In order to avoid command delays or failures in issuing commands due to network congestion during the test process, after obtaining the test script, delays are added to the front and back ends of the test script, so that the test system will have an obvious time interval between the test and the issuance of commands. This can avoid command delays or failures in issuing commands due to network congestion, thereby avoiding the risk of data distortion caused by network congestion and making the final test data more accurate.
[0103] Based on the same inventive concept, the present invention also proposes a network card automatic test script generation device, please refer to Figure 6 , Figure 6 A structural block diagram of a network card automatic test script generation device provided by an embodiment of the present invention. The network card automatic test script generation device includes:
[0104] The parameter determination module 110 is used to determine the optimal number of processes and the optimal number of threads. The optimal number of processes is the number of processes corresponding to the maximum bandwidth value measured by inputting different numbers of processes into the test system when the number of threads remains unchanged. The optimal number of threads is the number of threads corresponding to the maximum bandwidth value measured by inputting different numbers of threads into the test system when the number of processes remains unchanged.
[0105] A test configuration information determination module 120, configured to determine the test configuration information according to the optimal number of processes, the optimal number of threads and a preset error value;
[0106] The script generation module 130 is used to generate a test script for the network card maximum performance test according to the test configuration information.
[0107] In the above implementation process, the optimal number of processes and the optimal number of threads are determined by the parameter determination module 110. The optimal number of processes is the number of processes corresponding to the maximum bandwidth value measured by inputting different numbers of processes into the test system when the number of threads remains unchanged. The optimal number of threads is the number of threads corresponding to the maximum bandwidth value measured by inputting different numbers of threads into the test system when the number of processes remains unchanged, so that the optimal configuration state of the network card can be determined; the test configuration information determination module 120 determines the test configuration information according to the optimal number of processes, the optimal number of threads and the preset error value, and by adding the error value, the number of processes and the number of threads are within a certain range, and then a variety of configuration combinations can be obtained, and the maximum bandwidth of the network card is obtained by traversing the number of processes and the number of threads, so that the test is more refined; the script generation module 130 generates a test script for the network card maximum performance test according to the test configuration information, and the test script is obtained under the optimal configuration state of the network card, and contains a refined configuration combination. By executing the test script, the maximum bandwidth of the network card can be accurately obtained, thereby realizing the maximum performance test. The generated test script automatically traverses the number of processes and the number of threads without manual testing, thereby improving the work efficiency and accuracy of the staff in the network card performance test.
[0108] The parameter determination module 110 includes:
[0109] A thread number common value determination unit, used to determine a thread number common value;
[0110] An initial process number acquisition unit is used to acquire the initial process number and the process number step value;
[0111] A first bandwidth testing unit is used to increase the number of processes from an initial number of processes in sequence according to a step value of the number of processes, and input the obtained new common values of the number of processes and the number of threads into a test system for testing, so as to obtain a plurality of first bandwidth values;
[0112] The optimal process number unit is used to take the process number corresponding to the maximum value among the multiple first bandwidth values as the optimal process number.
[0113] By increasing the number of processes in sequence while keeping the number of threads unchanged, multiple configuration combinations of the number of threads and the number of processes can be obtained, and the configuration combinations are tested separately to make the test more precise, obtain more bandwidth values, and thus obtain a more accurate optimal number of processes.
[0114] Since the bandwidth often increases first and then decreases with the increase of the number of processes, the same is true for the number of threads. Therefore, in order to quickly find the maximum bandwidth value, the parameter determination module 110 also includes:
[0115] A first bandwidth value recording unit, used to record the first bandwidth value in real time, and obtain a real-time change trend of the first bandwidth value according to the first bandwidth value;
[0116] The test stopping unit is used to stop the test when the real-time change trend of the first bandwidth value has an inflection point, so as to obtain multiple first bandwidth values.
[0117] The parameter determination module 110 further includes:
[0118] A process number common value determination unit, used for determining a process number common value;
[0119] An initial thread number acquisition unit, used to acquire an initial thread number and a thread number step value;
[0120] A second bandwidth testing unit is used to increase the number of threads from the initial number of threads in accordance with the thread number step value, and input the obtained new number of threads and the common value of the number of threads into the test system for testing, so as to obtain a plurality of second bandwidth values;
[0121] The optimal thread number unit is used to take the thread number corresponding to the maximum value of the multiple second bandwidth values as the optimal thread number.
[0122] By increasing the number of threads in sequence while keeping the number of processes unchanged, multiple configuration combinations of the number of threads and the number of processes can be obtained, and the configuration combinations are tested separately to make the test more precise, obtain more bandwidth values, and thus obtain a more accurate optimal number of threads.
[0123] The test configuration information determination module 120 includes:
[0124] A value range determination unit, used to determine a value range of the number of processes and a value range of the number of threads according to an optimal number of processes, an optimal number of threads and a preset error value;
[0125] The configuration information generating unit is used to combine the process number and the thread number according to the process number value range and the thread number value range to obtain multiple groups of configuration information, and use the multiple groups of configuration information as test configuration information.
[0126] By setting the error value, the number of processes and threads can be within a range of values, and then multiple configurations can be obtained through combination, making the test more precise and thus more accurate.
[0127] In the process of maximizing the performance of the network card, network congestion may cause delays in the operation of automated instructions, resulting in distortion of test data. Therefore, in order to avoid distortion of test data caused by network congestion, network congestion avoidance can also be performed, including:
[0128] A test script adjustment module is used to add delay commands at both ends of the test script to obtain a new test script;
[0129] The test script sending module is used to send a new test script to a remote end for testing.
[0130] By adding delay commands at both ends of the test script and staggering control and testing, the test system will have an obvious time interval between testing and issuing instructions, thereby avoiding instruction delays or issuance failures caused by network congestion and further improving the accuracy of test data.
[0131] Among them, the test script sending module includes:
[0132] The script copy unit is used to copy the new test script to the remote end through the scp command;
[0133] Start the test unit to start a new test script on both the control end and the remote end for testing.
[0134] See also Figure 7 , Figure 7 A schematic block diagram of an electronic device provided in an embodiment of the present application. The electronic device includes a memory 101, a processor 102 and a communication interface 103, and the memory 101, the processor 102 and the communication interface 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The memory 101 can be used to store software programs and modules, such as program instructions / modules corresponding to a network card automatic test script generation device provided in an embodiment of the present application, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 101. The communication interface 103 can be used to communicate signaling or data with other node devices.
[0135] Among them, the memory 101 can be but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0136] The processor 102 may be an integrated circuit chip with signal processing capability. The processor 102 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0137] Understandably, Figure 7 The structure shown is for illustration only. The electronic device may also include Figure 7 More or fewer components as shown, or with Figure 7 Different configurations are shown. Figure 7 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0138] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0139] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0140] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0141] The above description is only the preferred 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 modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0142] It will be apparent to those skilled in the art that the present application is not limited to the details of the exemplary embodiments described above, and that the present application can be implemented in other specific forms without departing from the spirit or essential features of the present application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims be included in the present application. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
Claims
1. A method for generating a network card automatic test script, characterized in that: The following steps are involved: Determine an optimal number of processes and an optimal number of threads, wherein the optimal number of processes is the number of processes corresponding to the maximum bandwidth value measured by inputting different numbers of processes into the test system when the number of threads remains unchanged, and the optimal number of threads is the number of threads corresponding to the maximum bandwidth value measured by inputting different numbers of threads into the test system when the number of processes remains unchanged; Determining test configuration information according to the optimal number of processes, the optimal number of threads and a preset error value; Generate a test script for maximizing network card performance testing based on test configuration information; Execute the test script to traverse the number of processes and threads to obtain the maximum bandwidth of the network card; Determining the test configuration information according to the optimal number of processes, the optimal number of threads and a preset error value comprises the following steps: Determine a process number value range and a thread number value range according to the optimal process number, the optimal thread number and a preset error value; According to the process number value range and the thread number value range, the process number and the thread number are combined to obtain multiple groups of configuration information, and the multiple groups of configuration information are used as test configuration information; the test configuration information includes the value of the thread number and the value of the process number; Combining the number of processes and the number of threads according to the process number value range and the thread number value range to obtain multiple groups of configuration information includes the following steps: Take the error value as t, the optimal number of processes as L, the optimal number of threads as M, the range of the number of processes is between [Lt:L+t], the range of the number of threads is between [Mt:M+t], combine the number of processes and the number of threads, and get (2t+1)*(2t+1) configurations.
2. The method for generating a network card automatic test script according to claim 1, characterized in that: Determining the optimal number of processes comprises the following steps: Determine the common value of the number of threads; Get the initial number of processes and the step value of the number of processes; Starting from the initial process number, the process number is increased in sequence according to the process number step value, and the obtained new process number and the common value of the thread number are input into the test system for testing, so as to obtain a plurality of first bandwidth values; The number of processes corresponding to the maximum value among the multiple first bandwidth values is used as the optimal number of processes.
3. The method for generating a network card automatic test script according to claim 2, characterized in that: Before the step of taking the number of processes corresponding to the maximum value among the multiple first bandwidth values as the optimal number of processes, the following steps are also included: Recording the first bandwidth value in real time, and obtaining a real-time change trend of the first bandwidth value according to the first bandwidth value; When the real-time change trend of the first bandwidth value reaches an inflection point, the test is stopped to obtain multiple first bandwidth values.
4. The method for generating a network card automatic test script according to claim 1, characterized in that: Determining the optimal number of threads comprises the following steps: Determine the common value of the number of processes; Get the initial number of threads and the thread number step value; Starting from the initial number of threads, the number of threads is increased in sequence according to the step value of the number of threads, and the obtained new number of threads and the common value of the number of processes are input into the test system for testing, so as to obtain a plurality of second bandwidth values; The number of threads corresponding to the maximum value among the multiple second bandwidth values is used as the optimal number of threads.
5. The method for generating a network card automatic test script according to claim 1, characterized in that: The following steps are also included: Add delay commands at both ends of the test script to obtain a new test script; Send the new test script to the remote end for testing.
6. The method for generating a network card automatic test script according to claim 5, characterized in that: The sending of the new test script to the remote end for testing includes the following steps: Use the scp command to copy the new test script to the remote end; The control end and the remote end simultaneously start the new test script to perform the test.
7. A network card automatic test script generation device, characterized in that: include: A parameter determination module, used to determine an optimal number of processes and an optimal number of threads, wherein the optimal number of processes is the number of processes corresponding to the maximum bandwidth value measured by inputting different numbers of processes into the test system when the number of threads remains unchanged, and the optimal number of threads is the number of threads corresponding to the maximum bandwidth value measured by inputting different numbers of threads into the test system when the number of processes remains unchanged; A test configuration information determination module, used to determine the test configuration information according to the optimal number of processes, the optimal number of threads and a preset error value; A script generation module, used to generate a test script for maximizing performance test of a network card according to test configuration information; A module for executing the test script to traverse the number of processes and threads to obtain the maximum bandwidth of the network card; The test configuration information determination module includes: A value range determination unit, used to determine a value range of the number of processes and a value range of the number of threads according to an optimal number of processes, an optimal number of threads and a preset error value; A configuration information generating unit, configured to combine the number of processes and the number of threads according to a range of values of the number of processes and a range of values of the number of threads, to obtain multiple sets of configuration information, and to use the multiple sets of configuration information as test configuration information; the test configuration information includes the value of the number of threads and the value of the number of processes; The error value is taken as t, the optimal number of processes is L, the optimal number of threads is M, the number of processes is in the range of [Lt:L+t], the number of threads is in the range of [Mt:M+t], the number of processes and the number of threads are combined to obtain a module with (2t+1)*(2t+1) configurations.
8. An electronic device, characterized in that: include: A memory for storing one or more programs; processor; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Network card bandwidth test method and device based on multi-process, terminal and storage medium
CN109660422A
STREAM-based pressure test method and system, terminal and storage medium
CN114116339A