Test methods, equipment, media and products
By employing asynchronous communication and concurrent testing in a cluster network, and utilizing the coroutines and channel mechanisms of the Go language, efficient concurrent testing of multiple computer devices was achieved. This solves the problem of the inability to perform concurrent testing in existing technologies and improves testing efficiency and automation.
Patent Information
- Application Number
- CN202411246893.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2044-09-06
AI Technical Summary
Current technology does not allow for concurrent testing of multiple computer devices within a cluster.
The test commands for test cases are sent to each device under test in the cluster network using an asynchronous communication method combined with a concurrent method, so that each device under test can execute the same test commands or test cases in parallel. Asynchronous communication and concurrent testing are achieved through the coroutine and channel mechanism of the Go language.
It improves communication efficiency and automation, solves the problem of concurrent testing of multiple devices under test, and enhances testing efficiency.
Smart Images

Figure CN119127701B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a testing method, device, medium, and product. Background Technology
[0002] In the field of computer science, the concept of a cluster refers to a parallel computer system in which multiple independent computers, whether homogeneous or heterogeneous, are interconnected through a high-performance network or local area network to collaboratively complete specific parallel computing tasks.
[0003] In existing technologies, concurrent testing can be performed on software products and service server interfaces, but not on the concurrent testing of computer devices within a cluster. Therefore, how to perform concurrent testing on the computer devices within a cluster is a problem that urgently needs to be solved. Summary of the Invention
[0004] This invention provides a testing method, equipment, medium, and product to solve the technical problem that existing technologies cannot perform concurrent testing on multiple computer devices in a cluster.
[0005] According to one aspect of the present invention, a testing method is provided, comprising:
[0006] In response to a test trigger command, the test command for the test case is sent to each device under test in the cluster network using an asynchronous communication method combined with a concurrent method, so that each device under test executes each test item in the test case and obtains the execution result corresponding to each test item;
[0007] The test result of the corresponding test case is determined based on the execution result of each test item.
[0008] According to another aspect of the present invention, a testing apparatus is provided, comprising:
[0009] The testing module is used to respond to test trigger commands by sending test commands for test cases to each device under test in the cluster network using asynchronous communication combined with concurrency, so that each device under test executes each test item in the test case and obtains the execution result corresponding to each test item.
[0010] The determination module is used to determine the test result of the corresponding test case based on the execution result of each test item.
[0011] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0012] At least one processor; and,
[0013] A memory communicatively connected to the at least one processor; wherein,
[0014] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the test method described in any embodiment of the present invention.
[0015] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the test method described in any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the testing method described in any embodiment of the present invention.
[0017] The technical solution of this invention improves communication efficiency and automation by enabling asynchronous communication between each test case and test item when testing a device under test in a cluster network. Simultaneously, it sends the same test command or test case to each device under test in the cluster network concurrently, allowing each device under test to execute the same test command or test case in parallel. This solves the technical problem in the prior art that multiple devices under test in a cluster cannot be tested concurrently, thus improving testing efficiency.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of a testing method provided in an embodiment of the present invention;
[0021] Figure 2 This is a flowchart of another testing method provided in an embodiment of the present invention;
[0022] Figure 3 This is a schematic diagram of the configuration of a testing framework provided in an embodiment of the present invention;
[0023] Figure 4This is a test flowchart of an integrated testing framework provided in an embodiment of the present invention;
[0024] Figure 5 This is a schematic diagram of the structure of a testing device provided in an embodiment of the present invention;
[0025] Figure 6 This is a structural block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] To facilitate understanding of the solution, the parameters involved in this embodiment are explained below.
[0029] In the field of computer science, the concept of a cluster refers to a parallel computer system in which multiple independent computers, whether homogeneous or heterogeneous, are interconnected through a high-performance network or local area network to collaboratively complete specific parallel computing tasks.
[0030] A cluster is a parallel computer system characterized by consisting of multiple independent computers, which can be single-machine or multi-processor systems (such as PCs, workstations, or SMPs), and each computing node (i.e., each independent computer) has its own corresponding memory, I / O devices, and operating system.
[0031] Cluster characteristics include: First, low cost: Compared to traditional parallel computer systems, cluster systems are less expensive because they typically use commercially available PCs, workstations, and network equipment; Second, ease of construction: Because cluster systems use standard computer and network hardware, their construction process is relatively simple; Third, strong scalability: The computing power of a cluster can increase with the number of nodes, making it very suitable for handling large-scale computing tasks; Fourth, high reliability: The computing power of a cluster can increase with the number of nodes, making it very suitable for handling large-scale computing tasks.
[0032] Cluster architecture: A cluster system can be viewed as a single, centralized computing resource. From the user's perspective, the entire cluster can be used as a single computing system. This is thanks to the implementation of a Cluster Operating System, which can build an additional layer of operating system on top of the operating systems of each node to manage the entire cluster, achieving a Single System Image (SSI).
[0033] Cluster classification: Cluster systems can be classified according to different criteria. For example, based on application objectives, they can be classified into high-performance clusters, high-availability clusters, and load-balanced clusters; based on processor operating systems, they can be classified into Linux clusters, Solaris clusters, and NT clusters; based on processor configuration, they can be classified into homogeneous clusters and heterogeneous clusters.
[0034] Cluster systems have wide applications in various fields such as scientific computing, transaction processing, parallel databases, and network servers. For example, in scientific computing, cluster systems can support PVM and MPI, using optimized BLAS libraries; in transaction processing, they can support online transaction processing (OLTP) and online analytical processing (OLAP).
[0035] With advancements in microprocessor, network, and parallel programming technologies, cluster systems are experiencing strong growth. In the future, cluster systems are expected to find applications and development in more fields, while their performance, reliability, and scalability will be further improved.
[0036] Go, also known as Golang, is a statically typed, compiled, concurrent programming language developed by Google with garbage collection. Its design goal is to provide an efficient, concise, safe, and concurrent programming language suitable for building reliable and high-performance software systems. The following are the main features of the Go language:
[0037] First, it's open source and cross-platform: Go is an open-source language, with its source code hosted on GitHub by Google's Go project. Go supports cross-platform development and can be compiled into executables suitable for different operating systems and hardware architectures, such as Windows, Linux, and Mac.
[0038] Secondly, static typing and compilation: Go is a statically typed programming language, which means that some type-related errors can be caught during compilation, helping to discover potential bugs in advance. Programs written in Go need to be compiled into archive files or executable files before they can be used or executed.
[0039] Thirdly, automatic garbage collection: Go has an automatic garbage collection mechanism, so developers do not need to manually manage memory allocation and reclamation, which greatly reduces the burden of programming and also helps prevent memory leaks.
[0040] Fourth, native support for concurrent programming: Go natively supports concurrent programming, making it incredibly simple through Goroutines and Channels. Goroutines are lightweight threads that can efficiently create thousands of concurrent tasks. Channels provide communication and synchronization mechanisms between different Goroutines, making writing concurrent code intuitive and safe.
[0041] Fifth, concise and efficient syntax: Go's syntax is concise and clear, eliminating some cumbersome features and syntactic elements, making the code easier to read and maintain. Go is a compiled language, ensuring both the security and performance of statically compiled languages and the high efficiency of dynamic languages for development and maintenance.
[0042] Sixth, build tools and dependency management: Go programs can be obtained, compiled, tested, and installed using command-line statements, and a comprehensive build tool is provided. Go offers a rich package management system, allowing developers to easily import and use various third-party libraries.
[0043] Seventh, multiple programming paradigms: In addition to supporting functional programming, Go also supports object-oriented programming, and has the concepts of interface types and implementation types, but uses embedding instead of inheritance.
[0044] Eighth, a rich standard library: The language standard library contains many useful APIs, which to some extent reduces the dependence on third-party libraries.
[0045] Ninth, version iteration and optimization: Since its release, Go has undergone several milestones, with each version bringing many important improvements and optimizations. For example, Go version 1.17 introduced faster compilation speeds, enhanced Embed functionality, and module enhancements.
[0046] Tenth, wide application: Go is widely used in backend development, cloud computing, network programming, embedded systems, and many other fields. Many web applications, RESTful API services, microservice architectures, cloud service providers, and distributed systems are developed using Go.
[0047] In conclusion, Go, with its numerous advantages such as simplicity, efficiency, powerful concurrency performance, and cross-platform support, has become a popular choice in modern programming.
[0048] It should be noted that a cluster network can include multiple computer devices (also referred to as multiple computing nodes). When testing a cluster network, it is necessary to simultaneously send the same command to a large number of computer devices in the cluster network for testing. Then, after each computer device returns its test result, the next function test is performed. This requires a testing framework that can execute test cases asynchronously and sequentially with high concurrency. In view of this, this embodiment of the invention proposes a testing method that can use asynchronous communication combined with concurrent methods to execute test cases.
[0049] In one embodiment, Figure 1 This is a flowchart of a testing method provided by an embodiment of the present invention. This embodiment is applicable to concurrent testing of multiple devices under test in a cluster. The method can be executed by a testing device, which can be implemented in hardware and / or software and can be configured in an electronic device. The electronic device can include, but is not limited to, terminal devices with data processing capabilities such as personal computers or laptops. It should be noted that the electronic device can be a cluster network composed of multiple computing nodes, that is, a cluster network composed of multiple computing nodes can be used as a single computing system. Figure 1 As shown, the method includes:
[0050] S110. In response to the test trigger command, the test command of the test case is sent to each device under test in the cluster network using asynchronous communication and concurrent methods, so that each device under test executes each test item in the test case and obtains the execution result corresponding to each test item.
[0051] In this context, a test trigger command refers to a specific command or signal that can be used to initiate the testing process. For example, test trigger commands can be issued manually or automatically by automated build tools. The device under test (DUT) refers to the terminal device that needs to be tested. The cluster network can include one or more computing nodes, each of which can be considered a DUT. For instance, a computing node can be a computer. A high-concurrency, asynchronously sequential test framework runs on each DUT. After integrating this test framework, each DUT can run each test case or test item asynchronously, and can concurrently send test commands for the test cases to each DUT in the cluster network.
[0052] Each test case may include one or more test items. For example, assuming a test case is a computation task, the computation task may include multiple test items such as preprocessing, computation, transmission, and postprocessing.
[0053] During the testing of each computing node in a cluster network, each test case or test item can be performed asynchronously. Furthermore, a concurrent approach can be used to send test commands for one test item from the test case to each device under test (DUT) in the cluster network, causing each DUT to execute that test command. After completing the test command for that test item, the next test item is then concurrently sent to each DUT in the cluster network, until all test commands for all test items in a test case have been executed.
[0054] S120. Determine the test result of the corresponding test case based on the execution result of each test item.
[0055] In this context, the execution result for each test item refers to the execution result of the test command for that test item. The test result of a test case can be determined by the execution results of all test items contained within that test case. For example, assuming a test case contains N test items, where N is an integer greater than 1, the test result of that test case is determined by the execution results of the N test items. For instance, if the execution results of all N test items are successful, then the test result of that test case is considered successful.
[0056] The technical solution of this embodiment improves communication efficiency and automation by allowing each test case and test item to communicate asynchronously when testing the device under test in a cluster network. At the same time, it uses a concurrent approach to send the same test command or test case to each device under test in the cluster network, so that each device under test can execute the same test command or test case in parallel. This solves the technical problem in the prior art that it is impossible to perform concurrent testing on multiple devices under test in a cluster, and improves testing efficiency.
[0057] In one embodiment, Figure 2 This is a flowchart of another testing method provided by an embodiment of the present invention. This embodiment further elaborates on the process of sending test commands for test cases and the process of determining test results, based on the above embodiments. Figure 2 As shown, the method includes:
[0058] S210: In response to the test trigger command, a test command for one test item in the test case is sent concurrently to each device under test in the cluster network using a Go language coroutine.
[0059] A coroutine is a lightweight user-space thread that can execute concurrently within a single process. A Go coroutine can be used to send a test command for a test item from a test case to a device under test (DUT) in a cluster network. This can be understood as determining the number of coroutines required for a test item based on the total number of DUTs in a cluster network. Generally, the total number of DUTs in a cluster network is equivalent to the number of coroutines required for a test case.
[0060] Suppose a cluster network contains M devices under test. Each test item uses M goroutines in the Go language to send test commands to the M devices under test in the cluster network concurrently.
[0061] In one embodiment, S210 includes S2101-S2103:
[0062] S2101. Obtain the total number of devices under test in the cluster network and the number of test items for each test case.
[0063] The total number of devices refers to the number of devices under test in a cluster network; the number of test items refers to the number of test items in a test case. Generally, the number of test items in each test case can be the same or different, depending on the actual situation of the test case.
[0064] In this embodiment, a dedicated cluster management tool can be used to query the total number of devices under test (DUTs) in a cluster network. Alternatively, a disk scan of the IP addresses of devices in a cluster network can be performed to obtain the total number of DUTs in that cluster network. Alternatively, hardware device information can be queried to obtain the total number of DUTs in a cluster network. Manual recording and counting can also be used to obtain the total number of DUTs in a cluster network. Querying hardware device information can be done using database query tools or scripts.
[0065] In this embodiment, the number of test items contained in a test case can be obtained by querying the document records of the test case; the number of test items contained in a test case can also be obtained by analyzing the test case code; or a manual query can be performed to obtain the number of test items contained in a test case.
[0066] S2102. Based on the total number of devices, the test tasks corresponding to each test item are split to obtain test sub-tasks equal to the total number of devices.
[0067] In this context, a test task refers to all the test commands corresponding to a test item; a test subtask refers to a subset of the test commands within a test item. Each test subtask corresponds to a different set of test commands; that is, the test commands for any two test subtasks do not overlap. For example, assuming a test case contains N test items and a cluster network contains M devices under test, the test task corresponding to one test item can be divided into M test subtasks.
[0068] S2103. Use Go language coroutines to concurrently send test commands corresponding to test subtasks to each device under test in the cluster network.
[0069] In this embodiment, a Go language goroutine can be used to send a test command corresponding to a test subtask to a device under test (DUT) in the cluster network. In actual operation, each goroutine sends a test command corresponding to a test subtask to each DUT in the cluster network, and the execution is concurrent.
[0070] S2104. In the case that the test command of a test subtask is not executed successfully, determine the comparison result between the actual number of times the test command corresponding to the test item is retried and the preset retried number threshold.
[0071] The actual retransmission count refers to the total number of times a test command corresponding to a test item is resent to the test devices in the cluster network, i.e., the total number of times excluding the first transmission. The preset retransmission threshold is a pre-configured threshold value for repeatedly sending test commands to each device under test. For example, the preset retransmission threshold can be 5 times. If the test command of a test subtask in a test item fails to execute successfully, the actual retransmission count of the test command corresponding to that test item is compared with the preset retransmission threshold to determine whether the actual retransmission count reaches the preset retransmission threshold. Based on the comparison result, it is determined whether the test command corresponding to that test item should be retransmitted.
[0072] S2105. When the actual number of retransmissions is less than the preset retransmission threshold, return to the step of using Go language goroutines to concurrently send the test commands corresponding to the test subtasks to each device under test in the cluster network, until the actual number of retransmissions reaches the preset retransmission threshold.
[0073] If the actual number of retransmissions of the test command corresponding to a test item is less than a preset retransmission threshold, it indicates that a Go goroutine can be used to concurrently send the test command for the corresponding test subtask to each device under test in the cluster network. In this case, a Go goroutine can be used to concurrently send the test command corresponding to the test subtask to one or more devices under test in the cluster network. In actual operation, if at least one test subtask in a test item fails to execute, at least one Go goroutine can be used to retransmit the test command only to each device under test corresponding to the failed test subtask until the actual number of retransmissions reaches the preset retransmission threshold, or the test subtask executes successfully. Alternatively, if at least one test subtask in a test item fails to execute, a Go goroutine can be used to concurrently send the test command for one test subtask to each device under test in the cluster network until the actual number of retransmissions reaches the preset retransmission threshold, or the test subtask executes successfully.
[0074] S220. After a test item is completed, the next test item is started using asynchronous communication. The process then returns to the step of using Go language goroutines to concurrently send the test command of one test item in the test case to each device under test in the cluster network, until the execution process of each test item in the test case is completed.
[0075] Asynchronous communication can be implemented using channels in the Go programming language. After one test item in a test case is completed, the next test item can be triggered using a Go channel signal. This involves sending the channel signal to the next test item, which then automatically starts running upon receiving it. Go coroutines are then used to concurrently send the test command for the next test item in the test case to each device under test in the cluster network, until all test items in the test case have been executed.
[0076] It's important to note that each test item within a test case is executed sequentially, while each test subtask within a test item is executed in parallel. This can be understood as follows: only after each device under test (DUT) completes the execution of the first test item in a test case can the second test item be sent concurrently to each DUT in the cluster network to initiate the testing process for the second test item. Of course, if the first test item fails, and its execution result does not affect the execution of subsequent test items, the execution of the next test item can be triggered using a channel signal in Go. However, if the actual number of retransmissions for the first test item reaches a preset retransmission threshold and still fails, and the execution result of the first test item affects the execution of subsequent test items, the execution of the next test item cannot be triggered using a channel signal in Go. In this case, the execution of the test case is stopped, and a test failure message is sent to the tester for manual intervention.
[0077] S230. Call the common assertion function to judge the execution result of each test item corresponding to a test case, and obtain the test result of the corresponding test item.
[0078] Each test item in the test cases is executed in a loop on the device under test of each integration test framework, and a common assertion function is called to judge the execution result of each test item to determine whether the test result of each test item is a successful test or a failed test.
[0079] S240. Determine the test results of the corresponding test cases based on the test results of each test item.
[0080] In this embodiment, if the test result of each test item in a test case is a successful test, the test result of the test case is determined to be a successful execution; if the test result of one of the test items is a failed test, the test result of the test case is determined to be a failed execution.
[0081] The technical solution of this embodiment, based on the above embodiment, uses the channel signal of the Go language to trigger the start and run of the next test item, thereby realizing asynchronous communication between multiple test items, thus improving communication efficiency and automation.
[0082] In one embodiment, after determining the test result of the corresponding test case based on the execution result of each test item, the method further includes: storing the attribute information of each test item and the corresponding test result in a pre-configured log file; configuring a corresponding timestamp on the log file to obtain a log file with configured timestamps. The attribute information of the test item is used to characterize the configuration information of each test item itself. In one embodiment, the attribute information of the test item includes at least one of the following: the test case to which it belongs, the test item identification information, the test result, and the test item description information. The test case to which it belongs refers to which test case a test item belongs to; the test item identification information is used to characterize the unique identifier of the test item, for example, the test item ID; the test result is used to characterize whether the test item passes the test, and the test result includes: successful test and unsuccessful test; the test item description information is used to characterize the specific function or feature of the test item.
[0083] In this embodiment, the attribute information and test results of each test item can be statistically analyzed and input into a pre-configured log file. To facilitate the retrieval of each log file and ensure its secure storage, a timestamp can be added to the suffix of each log file to prevent historical log files from being overwritten.
[0084] In one embodiment, Figure 3 This is a schematic diagram illustrating the configuration of a testing framework provided in an embodiment of the present invention. For example... Figure 3 As shown, the test framework includes: METHOD module, DATA module, CASE module, and REPORT module.
[0085] The METHOD module is used to define some public variables and methods in the Go-based testing framework, such as initialization functions and assertion functions required by the testing framework.
[0086] The DATA module stores configuration files required by test cases during the testing process, such as files that test cases need to parse or executable files that test cases need to call. These configuration files can be XML or JSON files.
[0087] The CASE module stores executable files for test cases. Generally, test cases are implemented using the Go programming language. The executable file can be either an .exe or a .bin file.
[0088] The REPORT module: After completing a round of testing within the test framework, the test report for that round can be placed in this module. For example, the log files for this round can be stored in the REPORT module. Of course, historical log files are also stored in the REPORT module.
[0089] In one embodiment, Figure 4 This is a test flowchart of an integrated testing framework provided in an embodiment of the present invention. Figure 4 As shown, the testing process in this embodiment includes the following steps:
[0090] S410. Import the Go source code file from the METHOD module into the device of the integration test framework.
[0091] After running the test framework, you can first import the Go source code files in the METHOD module to load the common methods and variables required by the test framework, so that the CASE module can be called subsequently.
[0092] S420. The test cases in the CASE module are sent concurrently to each device under test in a cluster network so that the device under test can test each test item in the test cases.
[0093] The system checks the test cases in the CASE module and imports them. It then counts the number of test items in each test case, which is used by the framework to iterate through each test item. Each test item uses Go's goroutines to concurrently send test commands to every computer in the cluster. Within a set number of retries, the system polls the status of each computer running the test command until all computers have completed the current test command. When a test item finishes, it uses a Go channel to send a signal to the next test item, which then begins execution.
[0094] S430. Use assertion functions to determine the execution result of each test item, and determine the test result of the corresponding test case based on the execution result of the test item.
[0095] In this embodiment, each test item in the test case is executed in a loop. Each test item calls a common assertion function to judge the execution result and return the test result pass or fail to determine whether the test item has passed.
[0096] S440. Statistically analyze the attribute information and execution results of each test item and input them into the log file in the REPORT module.
[0097] The attribute information and execution results of each test item are statistically analyzed and output to the log file in the REPORT module. The information for each test item includes: the test case it belongs to, the test item identifier, the test result, and the test item description. The output log files are all stored in the REPORT module, and a timestamp is added to the end of each log file to prevent overwriting of historical log files.
[0098] In this embodiment, when testing computer devices in a cluster, each test case or test item can be performed asynchronously, improving communication efficiency and automation. Furthermore, by concurrently sending test commands or test cases to each computer device in the cluster network, testing efficiency is further enhanced.
[0099] In one embodiment, Figure 5 This is a schematic diagram of the structure of a testing device provided in an embodiment of the present invention. Figure 5 As shown, the device includes a test module 510 and a determination module 520.
[0100] Test module 510 is used to respond to test trigger commands by sending test commands for test cases to each device under test in the cluster network in an asynchronous communication manner combined with a concurrent manner, so that each device under test executes each test item in the test case and obtains the execution result corresponding to each test item;
[0101] The determination module 520 is used to determine the test result of the corresponding test case based on the execution result of each test item.
[0102] In one embodiment, each test case includes at least one test item; the test command for the test case is sent to each device under test in the cluster network using an asynchronous communication method combined with a concurrent method, specifically for:
[0103] The test command for one test item in the test case is sent concurrently to each device under test in the cluster network using Go language coroutines.
[0104] After one test item is completed, the next test item is started using asynchronous communication. Then, the process of sending test commands for one test item in the test case to each device under test in the cluster network using Go language goroutines is repeated until the execution of each test item in the test case is completed.
[0105] In one embodiment, a Go language coroutine is used to concurrently send a test command for one test item from a test case to each device under test in the cluster network, specifically for:
[0106] Obtain the total number of devices under test in the cluster network and the number of test items for each test case;
[0107] The test tasks for each test item are broken down based on the total number of devices, resulting in test sub-tasks equal to the total number of devices.
[0108] The test commands corresponding to the test subtasks are sent concurrently to each device under test in the cluster network using Go language coroutines.
[0109] In one embodiment, if the test command of a test subtask is successfully executed, Go language coroutines are used to concurrently send a test command for one test item in the test case to each device under test in the cluster network. Specifically, this is further used for:
[0110] Determine the comparison result between the actual number of resentments of the test command corresponding to the test item and the preset resentment threshold;
[0111] When the actual number of retransmissions is less than the preset retransmission threshold, return to the step of using Go language goroutines to concurrently send the test commands corresponding to the test subtasks to each device under test in the cluster network, until the actual number of retransmissions reaches the preset retransmission threshold.
[0112] In one embodiment, the determining module 520 includes:
[0113] The judgment unit is used to call the common assertion function to judge the execution result of each test item corresponding to a test case and obtain the test result of the corresponding test item;
[0114] The determination unit is used to determine the test results of the corresponding test cases based on the test results of each test item.
[0115] In one embodiment, after determining the test result of the corresponding test case based on the execution result of each test item, the testing apparatus further includes:
[0116] The storage module is used to store the attribute information of each test item and the corresponding test results into a pre-configured log file;
[0117] The configuration module is used to configure the corresponding timestamps for log files, so as to obtain log files with configured timestamps.
[0118] In one embodiment, the attribute information of a test item includes at least one of the following: the test case to which it belongs, the test item identification information, the test result, and the test item description information.
[0119] The testing apparatus provided in the embodiments of the present invention can execute the testing methods provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0120] In one embodiment, Figure 6This is a structural block diagram of an electronic device provided in an embodiment of the present invention, such as... Figure 6 The diagram illustrates a schematic representation of an electronic device 10 that can be used to implement embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0121] like Figure 6 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0122] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0123] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as test methods.
[0124] In some embodiments, the test method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the test method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the test method by any other suitable means (e.g., by means of firmware).
[0125] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0126] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0127] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0128] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0129] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0130] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0131] This invention also provides a computer program product, including a computer program that, when executed by a processor, can implement the testing methods provided in any embodiment of this application.
[0132] In the implementation of the computer program product, computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0133] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0134] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A test method characterized by, The method comprises the following steps: In response to a test triggering instruction, test commands of a test case are sent to each device under test in a cluster network in an asynchronous communication mode combined with a concurrent mode, so that each device under test executes each test item in the test case to obtain an execution result corresponding to each test item; A test result of the corresponding test case is determined based on the execution result corresponding to each test item; Each test case comprises at least one test item; the test commands of the test case are sent to each device under test in the cluster network in the asynchronous communication mode combined with the concurrent mode, which comprises the following steps: The test commands of one test item in the test case are sent to each device under test in the cluster network in a coroutine concurrent mode of Go language, which comprises the following steps: The total number of devices under test in the cluster network and the number of test items of each test case are obtained; Based on the total number of devices, each test task corresponding to each test item is split to obtain test subtasks equivalent to the total number of devices; The test commands corresponding to the test subtasks are sent to each device under test in the cluster network in the coroutine concurrent mode of Go language; After the execution of one test item is completed, the next test item is started in the asynchronous communication mode, and the step of sending the test commands of one test item in the test case to each device under test in the cluster network in the coroutine concurrent mode of Go language is returned until the execution process of each test item in the test case is completed.
2. The method of claim 1, wherein, In the case that the test command of one test subtask is not successfully executed, the step of sending the test commands of one test item in the test case to each device under test in the cluster network in the coroutine concurrent mode of Go language further comprises the following steps: The comparison result between the actual retransmission number of the test command corresponding to the test item and a preset retransmission number threshold is determined; When the actual retransmission number is less than the preset retransmission number threshold, the step of sending the test commands corresponding to the test subtasks to each device under test in the cluster network in the coroutine concurrent mode of Go language is returned until the actual retransmission number reaches the preset retransmission number threshold.
3. The method of claim 1, wherein, The test result of the corresponding test case is determined based on the execution result corresponding to each test item, which comprises the following steps: The execution result of each test item corresponding to one test case is judged by calling a public assertion function to obtain the test result of the corresponding test item; The test result of the corresponding test case is determined based on the test result of each test item.
4. The method according to any one of claims 1 to 3, characterized in that, After the test result of the corresponding test case is determined based on the execution result corresponding to each test item, the following steps are further included: The attribute information of each test item and the corresponding test result are stored in a pre-configured log file; The log file is configured with a corresponding time stamp to obtain a log file configured with a time stamp.
5. The method of claim 4, wherein, The attribute information of the test item at least comprises one of the following: the corresponding test case, test item identification information, test result and test item description information.
6. An electronic device, comprising: The electronic device comprises: At least one processor; and The memory is in communication connection with the at least one processor; wherein The memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the test method of any one of claims 1-5.
7. A computer readable storage medium characterized in that, The computer readable storage medium stores computer instructions for causing a processor to implement the test method of any one of claims 1-5 when executed by the processor.
8. A computer program product, characterised in that, The computer program product comprises a computer program which, when executed by a processor, implements the test method according to any one of claims 1-5.
Citation Information
Patent Citations
Automatic testing method and device, computer equipment and storage medium
CN108572919A
Equipment testing method and device, electronic equipment, readable medium and product
CN112631843A