Test method, equipment, medium and product
Through asynchronous communication and concurrent testing methods, multiple devices in the machine group are tested in parallel, solving the problem that concurrent testing cannot be performed in the prior art, and improving the testing efficiency and automation level.
Patent Information
- Application Number
- CN202411246893.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-09-06
AI Technical Summary
The prior art cannot conduct concurrent testing of multiple computer equipment in the machine group, resulting in inefficient testing.
Asynchronous communication method combined with concurrent method, the test command of the test case is sent to each device under test in the machine network, so that each device can execute the same test command or use case in parallel, and the test result is determined based on the execution results.
It improves communication efficiency and automation, solves the problem of being unable to conduct concurrent testing of multiple devices under test, and significantly improves testing efficiency.
Smart Images

Figure CN119127701A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a testing method, equipment, medium and product. Background Art
[0002] In the computer field, the concept of cluster refers to a parallel computer system composed of multiple homogeneous or heterogeneous independent computers interconnected through a high-performance network or local area network to collaboratively complete specific parallel computing tasks.
[0003] In the prior art, software products and server interfaces can be tested concurrently, but computer devices in a cluster are not tested concurrently. Therefore, how to perform concurrent testing on computer devices in a cluster is a problem that needs to be solved urgently. Summary of the invention
[0004] The present invention provides a testing method, equipment, medium and product to solve the technical problem in the prior art that multiple computer devices in a cluster cannot be tested concurrently.
[0005] According to one aspect of the present invention, there is provided a testing method, comprising:
[0006] In response to the test trigger instruction, the test command of the test case is sent to each device under test in the cluster network in an asynchronous communication mode and in a concurrent mode, 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 corresponding to each of the test items.
[0008] According to another aspect of the present invention, there is provided a testing device, comprising:
[0009] The test module is used to respond to the test trigger instruction, send the test command of the test case to each device under test in the cluster network in an asynchronous communication mode and in a concurrent mode, 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 corresponding to each of the test items.
[0011] According to another aspect of the present invention, there is provided an electronic device, 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 executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the testing 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, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the test method described in any embodiment of the present invention when executed.
[0016] According to another aspect of the present invention, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the test method according to any embodiment of the present invention is implemented.
[0017] The technical solution of the embodiment of the present invention improves communication efficiency and automation by allowing each test case and test item to communicate through asynchronous communication when testing the device under test in a cluster network; at the same time, a concurrent method is used to send the same test command or test case to each device under test in the cluster network, so that each device under test executes the same test command or test case in parallel, thereby solving the technical problem in the prior art that multiple devices under test in a cluster cannot be tested concurrently, thereby improving test efficiency.
[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0020] Figure 1 is a flow chart of a testing method provided by an embodiment of the present invention;
[0021] Figure 2 is a flow chart of another testing method provided by an embodiment of the present invention;
[0022] Figure 3 is a configuration diagram of a test framework provided by an embodiment of the present invention;
[0023] Figure 4It is a test flow chart of an integrated test framework provided by an embodiment of the present invention;
[0024] Figure 5 is a structural schematic diagram of a testing device provided by an embodiment of the present invention;
[0025] Figure 6 It is a structural block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work 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 and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] In order to facilitate the understanding of the solution, the parameters involved in this embodiment are explained as follows.
[0029] In the computer field, the concept of cluster refers to a parallel computer system composed of multiple homogeneous or heterogeneous independent computers 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, which is characterized by being composed of multiple independent computers, which can be stand-alone or multi-processor systems (such as PCs, workstations or SMPs), and each computing node (that is, each independent computer) has its own corresponding memory, I / O devices and operating system.
[0031] The characteristics of a cluster include: First, low price: compared with traditional parallel computer systems, cluster systems are less expensive because they typically use commercially available PCs, workstations, and network equipment; second, easy to build: since 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 increase in the number of nodes, which makes it very suitable for processing large-scale computing tasks; fourth, high reliability: the computing power of a cluster can increase with the increase in the number of nodes, which makes it very suitable for processing large-scale computing tasks.
[0032] Cluster structure: The cluster system can be viewed as a single, centralized computing resource. From the user's perspective, they can use the entire cluster as a single computing system. This is due to the implementation of the Cluster Operating System, which can build another operating system on top of the operating system of each node to manage the entire cluster and achieve a single system image (SSI).
[0033] Classification of clusters: Cluster systems can be classified according to different standards. For example, according to application goals, they can be divided into high-performance clusters, high-availability clusters, and load-balancing clusters; according to processor operating systems, they can be divided into Linux clusters, Solaris clusters, and NT clusters; according to processor configurations, they can be divided into homogeneous clusters and non-homogeneous clusters.
[0034] Cluster systems are widely used in many fields such as scientific computing, transaction processing, parallel databases and network servers. For example, in the field of scientific computing, cluster systems can support PVM and MPI, using optimized BLAS libraries; in the field of transaction processing, they can support online transaction processing (OLTP) and online analytical processing (OLAP).
[0035] With the advancement of microprocessor technology, network technology and parallel programming technology, cluster systems are developing rapidly. In the future, cluster systems are expected to be applied and developed in more fields, and their performance, reliability and scalability will be further improved.
[0036] Go language, also known as Golang, is a statically strongly typed, compiled, concurrent, and garbage collected programming language developed by Google. Its design goal is to provide an efficient, concise, secure, and concurrent programming language suitable for building reliable and high-performance software systems. The following are the main features of Go language:
[0037] First, open source and cross-platform: Go language is open source, and its source code is hosted on GitHub by Google's Go project. Go language supports cross-platform development and can be compiled into executable files suitable for different operating systems and hardware architectures, such as Windows, Linux, Mac, etc.
[0038] Second, static typing and compilation: Go is a statically typed programming language, which means that some type-related errors can be caught during compilation, which helps to find potential bugs in advance. Programs written in Go need to be compiled to generate archive files or executable files before they can be used or executed.
[0039] Third: Automatic garbage collection: The Go language has an automatic garbage collection mechanism. Developers do not need to manually manage memory allocation and recovery, which greatly reduces the burden of programming and also helps prevent memory leaks.
[0040] Fourth, native support for concurrent programming: Go language inherently supports concurrent programming, and through the Goroutines and Channel mechanisms, concurrent programming becomes very simple. Goroutines are lightweight threads that can efficiently create thousands of concurrent tasks. Channels provide a communication and synchronization mechanism between different Goroutines, making writing concurrent code intuitive and safe.
[0041] Fifth, the syntax is concise and efficient: The syntax design of Go language is concise and clear, and some cumbersome features and syntax elements are abandoned, making the code easier to read and maintain. Go language is a compiled language, which ensures that it can achieve the security and performance of static compiled languages and the high efficiency of dynamic language development and maintenance.
[0042] Sixth, build tools and dependency management: Go program acquisition, compilation, testing, and installation can all be done using command line statements, providing a complete build tool. The Go language provides a rich package management system that allows developers to easily import and use various third-party libraries.
[0043] Seventh, multiple programming paradigms: In addition to supporting functional programming, the Go language also supports object-oriented programming. It has the concepts of interface types and implementation types, but uses embedding instead of inheritance.
[0044] Eighth, rich standard library: There are many useful APIs in the language standard library, which reduces the dependence on third-party libraries to a certain extent.
[0045] Ninth, version iteration and optimization: Since the release of the Go language, its versions have gone through multiple milestones, and each version has brought many important improvements and optimizations. For example, Go 1.17 introduced faster compilation speed, enhanced Embed functions, module enhancements, etc.
[0046] Tenth, wide application: Go language is widely used in many fields such as back-end development, cloud computing, network programming, embedded systems, etc. Many web applications, RESTful API services, microservice architectures, cloud service providers and distributed systems are developed using Go language.
[0047] To sum up, Go language has become a popular choice in modern programming with its many advantages such as simplicity, efficiency, strong concurrency performance, and cross-platform support.
[0048] It should be noted that a cluster network may include multiple computer devices (also referred to as multiple computing nodes). When testing a cluster network, it is necessary to send the same command to a large number of computer devices in the cluster network for testing at the same time, and then each computer device returns the test result before testing the next function. At this time, a test framework that can execute test cases in high concurrency and asynchronous sequence is required. In view of this, an embodiment of the present invention proposes a test method that can use an asynchronous communication method and a concurrent method to execute test cases.
[0049] In one embodiment, Figure 1 This is a flow chart of a test method provided by an embodiment of the present invention. This embodiment is applicable to the case of concurrent testing of multiple devices under test in a cluster. The method can be executed by a test device, which can be implemented in the form of hardware and / or software, and the test device can be configured in an electronic device. The electronic device may include, but is not limited to: terminal devices with data processing functions 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 is used as a single computing system. Figure 1 As shown, the method includes:
[0050] S110. In response to the test trigger instruction, an asynchronous communication method is used in combination with a concurrent method to send a test command of the test case to each device under test in the cluster network, so that each device under test executes each test item in the test case and obtains an execution result corresponding to each test item.
[0051] Among them, the test trigger instruction refers to a specific command or signal that can be used to start the test process. Exemplarily, the test trigger instruction can be issued by manual input or automatic triggering of an automated construction tool. The device under test refers to the terminal device that needs to be tested. Among them, the cluster network can include one or more computing nodes, and each computing node can be used as a device under test. For example, the computing node can be a computer device. A test framework that executes test cases with high concurrency and asynchronous sequence is run in each device under test. After integrating the test framework, each device under test can run each test case or test item in an asynchronous communication mode, and the test command of the test case can be sent concurrently to each device under test in the cluster network.
[0052] Each test case may include one or more test items. For example, assuming that a test case is a computing task, the computing task may include multiple test items such as preprocessing, preprocessing, computing, transmission, and postprocessing.
[0053] In the process of testing each computing node in a cluster network, each test case or test item can be performed in an asynchronous communication manner. In addition, a test command of a test item in the test case can be sent to each device under test in the cluster network in a concurrent manner, so that each device under test executes the test command of the test item, and after completing the test command of the test item, the next test item is sent to each device under test in the cluster network in a concurrent manner until the test commands of all test items in a test case are completed.
[0054] S120: Determine the test result of the corresponding test case based on the execution result corresponding to each test item.
[0055] The execution result corresponding to each test item refers to the execution result of the test command of each test item; the test result of a test case can be determined by the execution results of all test items contained in the test case. Exemplarily, assuming that a test case includes N test items, N is an integer greater than 1, then the test result of the test case is determined by the execution results of the N test items. For example, if the execution results of the N test items are all successfully executed, the test result of the test case is a successful test.
[0056] The technical solution of this embodiment improves communication efficiency and automation by allowing each test case and test item to communicate through asynchronous communication when testing the device under test in a cluster network. At the same time, a concurrent method is used to send the same test command or test case to each device under test in the cluster network, so that each device under test executes the same test command or test case in parallel, thereby solving the technical problem in the prior art that multiple devices under test in a cluster cannot be tested concurrently, thereby improving test efficiency.
[0057] In one embodiment, Figure 2 1 is a flow chart of another test method provided by an embodiment of the present invention. This embodiment further details the process of sending the test command of the test case and the process of determining the test result based on the above embodiment. Figure 2 As shown, the method includes:
[0058] S210 , in response to the test trigger instruction, using the Go language coroutine to concurrently send a test command of a test item in the test case to each device under test in the cluster network.
[0059] Among them, a coroutine is a lightweight thread in user mode that can be executed concurrently in a single process. A coroutine in the Go language can be used to send a test command for a test item in a test case to a device under test in a cluster network. It can be understood that the number of coroutines required for a test item can be determined based on the total number of devices under test in a cluster network. Generally speaking, the total number of devices under test in a cluster network is equal to the number of coroutines required for a test case.
[0060] Assume that a cluster network contains M devices under test, and each test item uses M coroutines in the Go language to concurrently send test commands to the M devices under test in the cluster network.
[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 in 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 speaking, the number of test items in each test case can be the same or different, and can be configured according to the actual situation of the test case.
[0064] In the embodiment, a special cluster management tool can be used to query the total number of devices under test contained in a cluster network, or the IP address of the devices in the cluster network can be scanned to obtain the total number of devices under test contained in the cluster network, or the total number of devices under test contained in a cluster network can be obtained by querying hardware device information, or the total number of devices under test contained in a cluster network can be obtained by manual recording and statistics. Among them, the method of querying hardware device information can be queried using a database query tool or script.
[0065] In an embodiment, the document record of the test case can be queried to obtain the number of test items included in the test case; the case code of the test case can also be analyzed to obtain the number of test items included in the test case; or a manual query can be used to obtain the number of test items included in the test case.
[0066] S2102. Split the test task corresponding to each test item based on the total number of devices to obtain test subtasks equal to the total number of devices.
[0067] Among them, a test task refers to all test commands corresponding to a test item; a test subtask refers to a part of the test commands in a test item. The test commands corresponding to each test subtask are different, that is, the test commands corresponding to any two test subtasks are non-overlapping. For example, assuming that a test case contains N test items, and a cluster network contains M devices under test, the test task corresponding to a test item can be split into M test subtasks.
[0068] S2103. Use the Go language coroutine to concurrently send a test command corresponding to the test subtask to each device under test in the cluster network.
[0069] In an embodiment, a coroutine in Go language may be used to send a test command corresponding to a test subtask to a device under test in a cluster network. In actual operation, each coroutine sends a test command corresponding to a test subtask to each device under test in the cluster network, which is executed concurrently.
[0070] S2104: When a test command of a test subtask is not successfully executed, determine a comparison result between an actual number of retransmissions of the test command corresponding to the test item and a preset retransmission number threshold.
[0071] The actual number of retransmissions refers to the total number of times a test command corresponding to a test item is resent to the test device in the cluster network, that is, the total number of times except for the first transmission; the preset retransmission threshold refers to the pre-configured threshold value for repeatedly sending the test command to each device under test. Exemplarily, the preset retransmission threshold can be 5 times. In the case that a test command of a test subtask in a test item is not successfully executed, the actual number of retransmissions of the test command corresponding to the test item is compared with the preset retransmission threshold to determine whether the actual number of retransmissions reaches the preset retransmission threshold, and based on the comparison result between the two, it is determined whether to retransmit the test command corresponding to the test item again.
[0072] S2105. When the actual number of retransmissions is less than the preset retransmission threshold, return to the step of using the Go language coroutine to concurrently send the test command corresponding to the test subtask to each device under test in the cluster network until the actual number of retransmissions reaches the preset retransmission threshold.
[0073] When the actual number of retransmissions of the test command corresponding to a test item is less than the preset retransmission threshold, it is characterized that the Go language coroutine can be used to send the test command of the corresponding test subtask to each device under test in the cluster network again. At this time, the Go language coroutine can be used to send the test command corresponding to the test subtask to one or more devices under test in the cluster network. In the actual operation process, when at least one of the test subtasks in a test item is not successfully executed, at least one coroutine of the Go language can be used to retransmit the test command to each device under test corresponding to the unsuccessful test subtask until the actual number of retransmissions reaches the preset retransmission threshold, or the test subtask is successfully executed. Of course, when at least one of the test subtasks in a test item is not successfully executed, the Go language coroutine can also be used to send a test command of a 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 is successfully executed.
[0074] S220. After one test item is executed, the next test item is started by asynchronous communication, and the process returns to the step of using the Go language coroutine to concurrently send a test command for a 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] Among them, the asynchronous communication mode can be implemented by using the channel signal in the Go language. After a test item in the test case is executed, the channel signal in the Go language can be used to trigger the start of the next test item, that is, the channel signal in the Go language is sent to the next test item, and after the next test item receives the channel signal, the next test item is automatically started to run; then the Go language coroutine is used to send the test command of the next test item in the test case to each device under test in the cluster network until the execution process of all test items in the test case is completed.
[0076] It should be noted that each test item in a test case is executed sequentially, while each test subtask in each test item is executed in parallel. It can be understood that only after each device under test completes the execution of the first test item in the test case can the second test item in the test case be sent concurrently to each device under test in the cluster network to start the test process of the second test item. Of course, if the first test item fails to execute, and the execution result of the first test item does not affect the execution process of subsequent test items, the channel signal in the Go language can be used to trigger the execution of the next test item; if the actual retransmission number of the first test item reaches the preset retransmission number threshold, and it still fails to execute, and the execution result of the first test item affects the execution process of subsequent test items, the channel signal in the Go language cannot be used to trigger the execution of the next test item. At this time, the execution process of the test case is stopped, and a test failure prompt message is sent to the tester to facilitate manual intervention by the tester.
[0077] S230 , calling a common assertion function to judge the execution result of each test item corresponding to a test case, and obtaining the test result of the corresponding test item.
[0078] Each test item in the test case is executed cyclically on the device under test of each integrated 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 an unsuccessful test.
[0079] S240: Determine the test result of the corresponding test case based on the test result of each test item.
[0080] In an embodiment, when 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 successfully executed; if the test result of one of the test items is an unsuccessful test, the test result of the test case is determined to be unsuccessful 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-up of the next test item, thereby realizing asynchronous communication between multiple test items, thereby improving communication efficiency and automation.
[0082] In one embodiment, after determining the test result of the corresponding test case based on the execution result corresponding to each test item, it also includes: storing the attribute information of each test item and the corresponding test result in a pre-configured log file; configuring the corresponding timestamp for the log file to obtain a log file with a configured timestamp. Among them, 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. Among them, the test case to which it belongs refers to which test case a test item belongs; the test item identification information is used to characterize the unique identification of the test item, for example, the test item identification information can be the ID of the test item; the test result is used to characterize whether the test item passes the test, and the test results include: successful test and unsuccessful test; the test item description information is used to characterize the specific function or characteristic of the test item.
[0083] In an embodiment, the attribute information and test results of each test item can be counted and input into a pre-configured log file. In order to facilitate the search of each log file and ensure the safe storage of the log file, a timestamp can be added to the suffix of each log file to prevent the historical log file from being overwritten.
[0084] In one embodiment, Figure 3 FIG. 1 is a configuration diagram of a test framework provided by an embodiment of the present invention. Figure 3 As shown, the test framework includes: METHOD module, DATA module, CASE module and REPORT module.
[0085] Among them, the METHOD module is used to define some common variables and methods in the test framework based on the Go language, such as some initialization functions and assertion functions required in the test framework;
[0086] DATA module: used to store configuration files required by test cases during the test process, such as files that need to be parsed by test cases or some executable files that need to be called by test cases, etc. The configuration files can be XML files or JSON files.
[0087] CASE module: an executable file used to store test cases. Generally speaking, test cases are implemented in Go language. The executable file can be an exe file or a bin file.
[0088] REPORT module: After completing a round of testing in the test framework, you can put the test report of this round in this module. For example, the log file of this round is stored in the REPORT module. Of course, the historical log files are also stored in the REPORT module.
[0089] In one embodiment, Figure 4 : is a test flow chart of an integrated test framework provided by an embodiment of the present invention. Figure 4 As shown, the test process of this embodiment includes the following steps:
[0090] S410. Import the Go source code file in the METHOD module into the device of the integrated test framework.
[0091] After running the test framework, you can first import the Go source code files in the METHOD method module to load the common methods and variables required by the test framework for subsequent calls to the CASE module.
[0092] S420, sending the test cases in the CASE module to each device under test in a cluster network in parallel, so that the device under test tests each test item in the test cases.
[0093] Determine the test cases in the CASE module, import the CASE module, count the number of test items contained in each test case, and use it for the subsequent framework to loop and execute each test item. Each test item uses the coroutine in Go to send test commands to each computer device in the cluster, and polls the status of each computer device running the test command within the number of retries until all computer devices have finished running the current test command. When a test item is finished, use the channel in Go to send the model to the next test item, and the next test item starts running.
[0094] S430: using the assertion function to judge the execution result of each test item, and determining the test result of the corresponding test case based on the execution result of the test item.
[0095] In an embodiment, each test item in a test case is executed in a loop, and a common assertion function is called in the test item to judge the execution result and return a test result of pass or fail to judge whether the test item has passed the test.
[0096] S440. Count 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 counted and output to the log file in the REPORT module, where the information of the test item includes: the test case to which it belongs, the test item identification information, the test result and the test item description information, etc. The output log files are stored in the REPORT module, and a timestamp is added to the suffix of each log file to prevent the historical log files from being overwritten.
[0098] In this embodiment, when testing a computer device in a cluster, each test case or test item can be performed in an asynchronous communication mode, thereby improving communication efficiency and automation. In addition, a test command or test case is sent to each computer device in a cluster network in a concurrent manner, thereby improving test efficiency.
[0099] In one embodiment, Figure 5 Schematic diagram of a test device provided by an embodiment of the present invention. Figure 5 As shown, the device includes: a testing module 510 and a determining module 520.
[0100] The test module 510 is used to respond to the test trigger instruction, send the test command of the test case to each device under test in the cluster network in an asynchronous communication mode and in a concurrent mode, 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 corresponding to each test item.
[0102] In one embodiment, each test case includes at least one test item; an asynchronous communication method is used in combination with a concurrent method to send a test command of the test case to each device under test in the cluster network, specifically for:
[0103] Use the Go language coroutine to concurrently send a test command for a test item in the test case to each device under test in the cluster network;
[0104] After one test item is executed, the next test item is started using asynchronous communication, and the step of using the Go language coroutine to concurrently send a test command for a test item in the test case to each device under test in the cluster network is returned until the execution process of each test item in the test case is completed.
[0105] In one embodiment, a test command of a test item in a test case is sent to each device under test in a cluster network using a coroutine in the Go language, specifically for:
[0106] Get the total number of devices under test in the cluster network and the number of test items in each test case;
[0107] Split the test tasks corresponding to each test item based on the total number of devices to obtain test subtasks equal to the total number of devices;
[0108] The Go language coroutine is used to concurrently send the test commands corresponding to the test subtasks to each device under test in the cluster network.
[0109] In one embodiment, when a test command of a test subtask is successfully executed, a test command of a test item in a test case is sent to each device under test in a cluster network using a Go language coroutine concurrently, and is also specifically used for:
[0110] Determine a comparison result between an actual number of retransmissions of a test command corresponding to a test item and a preset number of retransmissions threshold;
[0111] When the actual number of retransmissions is less than the preset retransmission threshold, return to the step of using the Go language coroutine to concurrently send the test command corresponding to the test subtask 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 determination module 520 includes:
[0113] A judgment unit, used to call a 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 result of the corresponding test case based on the test result of each test item.
[0115] In one embodiment, after determining the test result of the corresponding test case based on the execution result corresponding to each test item, the testing device further includes:
[0116] A storage module, used to store the attribute information of each test item and the corresponding test result in a pre-configured log file;
[0117] The configuration module is used to configure the corresponding timestamp for the log file to obtain the log file with the configured timestamp.
[0118] 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.
[0119] The testing device provided in the embodiment of the present invention can execute the testing method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0120] In one embodiment, Figure 6is a structural block diagram of an electronic device provided by an embodiment of the present invention, such as Figure 6 As shown, a schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0121] like Figure 6 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0122] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0123] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the test method.
[0124] In some embodiments, the test method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the test method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the test method in any other appropriate manner (e.g., by means of firmware).
[0125] Various implementations 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 chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0126] Computer programs for implementing 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0127] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0128] To provide interaction with a user, the systems and techniques described herein may 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0129] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0130] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0131] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, can implement the testing method provided in any embodiment of the present application.
[0132] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present application, and the programming language includes an object-oriented programming language, such as Java, Smalltalk, C++, and also includes a conventional procedural programming language, such as "C" language or similar programming language. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0133] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0134] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A testing method, characterized in that: include: In response to the test trigger instruction, the test command of the test case is sent to each device under test in the cluster network in an asynchronous communication mode and in a concurrent mode, so that each device under test executes each test item in the test case and obtains the execution result corresponding to each test item; The test result of the corresponding test case is determined based on the execution result corresponding to each of the test items.
2. The method according to claim 1, characterized in that: Each of the test cases includes at least one test item; The method of sending a test command of a test case to each device under test in the cluster network by using an asynchronous communication method and in a concurrent manner includes: Using the Go language coroutine to concurrently send a test command of a test item in the test case to each device under test in the cluster network; After one of the test items is executed, the next test item is started using asynchronous communication, and the step of using the Go language coroutine to concurrently send a test command for a test item in the test case to each device under test in the cluster network is returned until the execution process of each test item in the test case is completed.
3. The method according to claim 2, characterized in that The coroutine using the Go language concurrently sends a test command of a test item in the test case to each device under test in the cluster network, including: Get the total number of devices under test in the cluster network and the number of test items in each test case; Splitting the test task corresponding to each test item based on the total number of devices to obtain test subtasks equal to the total number of devices; The Go language coroutine is used to concurrently send the test command corresponding to the test subtask to each device under test in the cluster network.
4. The method according to claim 3, characterized in that: In the case where a test command of a test subtask is not successfully executed, the coroutine using the Go language concurrently sends a test command of a test item in the test case to each device under test in the cluster network, and further includes: Determine a comparison result between an actual number of retransmissions of the test command corresponding to the test item and a preset retransmission number threshold; When the actual number of retransmissions is less than the preset retransmission threshold, return to the step of using the Go language coroutine to concurrently send the test command corresponding to the test subtask to each device under test in the cluster network until the actual number of retransmissions reaches the preset retransmission threshold.
5. The method according to claim 1, characterized in that: The determining the test result of the corresponding test case based on the execution result corresponding to each of the test items includes: 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; The test result of the corresponding test case is determined based on the test result of each of the test items.
6. The method according to any one of claims 1 to 5, characterized in that After determining the test result of the corresponding test case based on the execution result corresponding to each of the test items, the method further includes: Storing the attribute information of each test item and the corresponding test result in a pre-configured log file; A corresponding timestamp is configured for the log file to obtain a log file with a configured timestamp.
7. The method according to claim 6, characterized in that 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.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the testing method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the testing method according to any one of claims 1 to 7 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the testing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Automatic test device and method for Web page
CN104123397A
Automatic testing method and device, computer equipment and storage medium
CN108572919A
Testing method and device, medium and electronic equipment
CN111459798A
Equipment testing method and device, electronic equipment, readable medium and product
CN112631843A
Test method and device, equipment and storage medium
CN114519006A
