CN111737145A - Automatic testing method and device - Google Patents

Automatic testing method and device Download PDF

Info

Publication number
CN111737145A
CN111737145A CN202010702065.6A CN202010702065A CN111737145A CN 111737145 A CN111737145 A CN 111737145A CN 202010702065 A CN202010702065 A CN 202010702065A CN 111737145 A CN111737145 A CN 111737145A
Authority
CN
China
Prior art keywords
channel
shell
target
target machine
command
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010702065.6A
Other languages
Chinese (zh)
Other versions
CN111737145B (en
Inventor
杨湘渝
孔庆鸥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zhixiang Technology Co Ltd
Original Assignee
Beijing Zhixiang Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zhixiang Technology Co Ltd filed Critical Beijing Zhixiang Technology Co Ltd
Priority to CN202010702065.6A priority Critical patent/CN111737145B/en
Publication of CN111737145A publication Critical patent/CN111737145A/en
Application granted granted Critical
Publication of CN111737145B publication Critical patent/CN111737145B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)

Abstract

The invention discloses an automatic testing method and a device, wherein after a shell command channel is established with a target machine, a channel identifier of the shell command channel is obtained, and then a testing instruction is sent to the corresponding target machine for testing through the shell command channel based on the channel identifier.

Description

Automatic testing method and device
Technical Field
The invention relates to the technical field of computers, in particular to an automatic testing method and device.
Background
With the continuous development of software testing technology, automated testing is more and more advocated and valued by software organizations and individuals. However, in the actual test work, the efficiency of the software test is low due to various reasons, and the progress of the software test is affected. Therefore, how to improve the script writing efficiency and the running test efficiency from the automated test architecture becomes a problem that automated testers continuously think.
Disclosure of Invention
The invention provides an automatic testing method and device, and aims to solve the problem of low testing efficiency caused by repeated establishment of a connection channel in the prior art.
In a first aspect, the present invention provides an automated testing method, including: establishing a shell command channel with a target machine, and acquiring a channel identifier of the shell command channel; and sending a test instruction to the corresponding target machine for testing through the shell command channel based on the channel identification.
Optionally, the target machines are target machines of different shell command channel types, and the target machine under each shell command channel type is a single target machine or a target machine group consisting of a plurality of target machines;
the establishing of the shell command channel with the target machine and the obtaining of the channel identification of the shell command channel comprise the following steps: and establishing a shell command channel of a single target machine or a target unit under different shell command channel types through a preset HOSTS command, and acquiring a channel identifier of the shell command channel.
Optionally, when the number of the target machines in the shell command channel type is single, the establishing a shell command channel with the target machine, and obtaining a channel identifier of the shell command channel further includes:
and establishing a shell command channel of the target machine under the shell command channel type through a preset HOST command, and acquiring a channel identifier of the shell command channel.
Optionally, the obtaining the channel identifier of the shell command channel includes: after the shell command channel is successfully established, acquiring a first device identifier of a target machine under each shell command channel type;
based on the channel identification, sending a test instruction to a corresponding target machine for testing through the shell command channel, wherein the test instruction comprises the following steps: and sending a test instruction to a target machine corresponding to the first equipment identification for testing through the shell command channel based on the first equipment identification.
Optionally, the preset HOST command includes one or more of the following: the IP address, the user name, the password and the channel type of the target machine; the preset HOSTS command comprises: a list of target machine IP or a list of host names of the target machines.
Optionally, when the target machine in the shell command channel type is the target machine group, the establishing a shell command channel with the target machine and obtaining the channel identifier of the shell command channel include:
establishing a shell command channel of a target unit under different shell command channel types through a preset HOSTS command, and acquiring a group channel identifier of the target unit and second equipment identifiers of all target machines in the target unit after the shell command channel is successfully established;
the step of sending a test instruction to a corresponding target machine for testing through the shell command channel based on the channel identifier comprises the following steps: sending a test instruction to the target unit for testing through the shell command channel based on the group channel identifier, and/or sending a test instruction to the target unit corresponding to the second device identifier for testing through the shell command channel based on the second device identifier;
when the number of the target machines in the shell command channel type is single, the establishing a shell command channel with the target machines, and acquiring the channel identifier of the shell command channel further include:
establishing shell command channels of target machines under different shell command channel types through a preset HOSTS command; after the shell command channel is successfully established, acquiring a first device identifier of a target machine under each shell command channel type;
the step of sending a test instruction to a corresponding target machine for testing through the shell command channel based on the channel identifier comprises the following steps: and sending a test instruction to a target machine corresponding to the first equipment identification for testing through the shell command channel based on the first equipment identification.
Optionally, the group channel identifier is an IP list of the target machine or a machine name list of the target machine;
the first equipment identification is the machine name of the target machine;
the second device identification is the machine name of the target machine or the target machine number associated with the group channel identification.
Optionally, after sending the test data and the test instruction to the target machine, the method further includes:
acquiring all test results, acquiring the test results through regular matching, and acquiring the test results of specified rows or columns; and verifying the test result through character string matching, reverse matching or regular matching.
In a second aspect, the present invention provides an automated testing apparatus, comprising:
the connection unit is used for establishing a shell command channel with a target machine and acquiring a channel identifier of the shell command channel;
and the processing unit is used for sending a test instruction to the corresponding target machine for testing based on the channel identification passing through the shell command channel and the channel identification passing through the shell command channel.
In a third aspect, the present invention provides a computer-readable storage medium storing a signal-mapped computer program which, when executed by at least one processor, implements any of the above-described methods for automated testing of data.
The invention has the following beneficial effects:
the invention acquires the channel identification of the shell command channel after establishing the shell command channel with the target machine, and then sends the test data and the test instruction to the corresponding target machine through the shell command channel based on the channel identification, namely, the invention realizes the long connection between the test machine and the target machine through the channel identification, avoids the problem that the connection channel needs to be reestablished before the test machine sends the test instruction to the target machine each time, thereby improving the efficiency of data test.
Drawings
FIG. 1 is a schematic flow chart of an automated testing method according to a first embodiment of the present invention;
FIG. 2 is a schematic flow chart of another automated testing method provided by the first embodiment of the invention;
fig. 3 is a schematic structural diagram of an automated testing apparatus according to a second embodiment of the present invention.
Detailed Description
The embodiment of the invention aims at the problem of low testing efficiency caused by the fact that the existing testing machine needs to reestablish the connection channel with the target machine before testing the data such as scripts and the like each time, and the method and the device achieve long connection between the testing machine and the target machine through the channel identification after the shell command channel is established with the target machine, so that repeated connection channel reestablishment is avoided, and the efficiency of data testing is greatly improved. The present invention will be described in further detail below with reference to the drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention.
A first embodiment of the present invention provides an automated testing method, referring to fig. 1, on the tester side, the method including:
s101, establishing a shell command channel with a target machine, and acquiring a channel identifier of the shell command channel;
specifically, the embodiment of the invention associates the channel identifier with the target machine correspondingly, and establishes an independent connecting pipeline between the tester and the target machine through the channel identifier.
It should be noted that, in the embodiment of the present invention, one or more target machines may be provided, and multiple target machines may be set among the multiple target machines, and according to different types of shell command channels, multiple target machines in the same shell command channel type may be set as one group, that is, multiple target machines in the same shell command channel type constitute a target machine group, and long connection between the testing machine and the target machine group is achieved through the shell command channel and the channel identifier.
That is to say, in the embodiment of the present invention, each target machine has and only has one channel identifier, but one channel identifier may simultaneously correspond to multiple target machines, for example, one channel identifier may correspond to an entire target machine group. In other words, in the embodiment of the present invention, the test data may be sent to one target machine through one channel identifier, or the test data may be sent to a whole target machine group through one channel identifier at the same time.
In a specific implementation, a person skilled in the art may set a specific channel identifier according to actual needs, for example, set the channel identifier as a target machine name, a host IP address, or a list of machine names of the target machine, and so on.
And S102, sending a test instruction to the corresponding target machine for testing through the shell command channel based on the channel identification.
Specifically, in the embodiment of the present invention, the test driver may be sent to the target machine through the shell command channel based on the channel identifier, and then the test instruction may be sent to the corresponding target machine and the test driver on the target machine for testing.
It should be noted that the test data according to the embodiment of the present invention may be drive script data, and may also be other various test data.
That is to say, in the embodiment of the present invention, the target machine is identified by the channel identifier, so that the command channel connection between the tester and the target machine is realized, the connection channel is prevented from being reestablished in each test, the test efficiency of data is improved, the system resource is saved, and the user experience is greatly improved.
The core idea of the invention is to provide a centralized management architecture aiming at multi-type, multi-quantity and multi-interaction complex test scenes of target machines, establish a shell command channel to various target machines in a unified form, once the channel is established, the channel can repeatedly send test instructions, and can continuously receive and process test results. In addition, in the embodiment of the invention, each command channel can open an independent process for connection, and a multi-process concurrency mechanism is naturally formed. Therefore, the test operation efficiency and flexibility are improved, and the compatibility of the test platform is also improved.
Specifically, the embodiment of the invention adopts a centralized management shell command channel method to establish shell command channels for different target machines, returns a preset identifier (namely the channel identifier) after the connection is successful, and can dynamically send a test instruction by using the identifier. The environment configuration of each connection in the embodiment of the invention is the same, so that the continuity of a plurality of sent test instructions is ensured, namely, the long connection between the tester and the target machine is realized.
In specific implementation, the target machines in the embodiment of the present invention may be target machines of different shell command channel types, and a target machine in each shell command channel type is a target machine or a target unit composed of multiple target machines, and may also be one or more target machines in the same shell command channel type;
the embodiment of the invention takes the shell (various shell command channel types) as a command execution environment, mainly because the shell adopts one-to-one command/response pairs, the processing is convenient, and the determined prompt provides a convenient command ending mark. The shell is provided with a natural full-function script running environment, various platforms, various script languages and character string input and output, and is easy to develop and debug, the shell is provided with a processing mode facing command/response pairs (a processing mode facing a text line by vs Expect), SEND identification is sent, received and command judgment is finished, response data returned by EXPECT identification processing can be shielded, asynchronous receiving of command channel processing details can be shielded, real-time display is returned, prompt matching is carried out, overtime processing is carried out, command layer logic is concerned, programming is simplified, and a natural multi-process concurrent processing mechanism is adopted.
Further, step S101 in the embodiment of the present invention specifically includes: and establishing a shell command channel of a single target machine or a target unit under different shell command channel types through a preset HOSTS command, and acquiring a channel identifier of the shell command channel.
When only one target machine of the shell command channel type exists, a shell command channel with the target machine or the target unit can be established through a preset HOSTS command, and a channel identifier of the shell command channel is obtained.
That is, the embodiment of the present invention opens a separate process for each command channel (i.e., shell command channel) through the channel identifier to perform connection. The shell command channels can be established for a plurality of target machines at the same time, and the returned channel identification is used for dynamically executing the test instruction. Therefore, the test operation efficiency and flexibility are improved, and the compatibility of the test platform is also improved.
Specifically, the embodiment of the invention can establish the shell command channel between the tester and the target machine through the preset HOSTS command, acquire the channel identifier of the successfully established shell command channel, and identify the target machine through the channel identifier, thereby establishing the long connection between the tester and the target machine.
Of course, when the number of the target machines in a certain shell command channel type is single, the embodiment of the present invention may also establish the shell command channel with the target machine in the shell command channel type through the preset HOST command, and obtain the channel identifier of the shell command channel.
Generally speaking, the embodiment of the invention establishes the shell command channel between the tester and one or more target units of different types through the preset HOSTS command, and establishes the shell command channel between the tester and one target unit of different types through the preset HOST command.
In the embodiment of the present invention, the preset HOST command includes one or more of the following: the IP address, the user name, the password and the channel type of the target machine; the preset HOSTS command comprises: the IP list of the target machine or the machine name list of the target machine.
Certainly, in a specific implementation, a preset identifier (a first device identifier) that should be returned after the target machine is successfully connected may be set in the preset HOST command, that is, the identifier is allocated to the target machine by the tester through the command, so that a shell command channel is established between the tester and the target machine through the identifier.
Similarly, a group channel identifier and a second device identifier may also be set in the preset HOSTS command, so that the tester establishes a shell command channel with the target machine through the specific identifier.
In summary, the embodiment of the present invention adopts a centralized management shell connection method, which can establish shell command channels for different target machines, return a predetermined identifier after successful connection, dynamically upload a test driver using the identifier, and send test instructions.
The preset HOSTS command and the preset HOST command in the embodiment of the present invention will be explained and explained in detail by a specific example:
the specific setting of the preset HOST command in the embodiment of the present invention may be as follows: the HOST is a HOST name of a tester corresponding to the received command, and the preset HOST command further comprises: the IP is the IP address of the target machine, the password is the password of the target machine, and certainly, the user name of the target machine can be further set in the preset HOST command, and the like. The command may establish a number of different shell command channel types, such as: bash, expect, and python, specified by shell _ list (default bash expect). The shell command channels are independent of each other and each receive and execute a response type command. And returning to the host name hostname of the test machine after the shell connection is successfully established, automatically generating by the system if the user does not specify, and sending a test command to the target machine by using the hostname instead of a SEND command. The command may connect multiple target machines simultaneously.
The specific setting of the preset HOSTS command in the embodiment of the present invention may be: HOSTS [ user% passed @ ] ip [: hostname ] shell _ list. This command calls for the HOST command to complete, with the same parameters as HOST. If IP is cluster IP, the command will automatically connect a set of target machines and will be named hostnameN, where N is the ID of each target machine. hostnameN may SEND a test instruction to the target machine instead of a SEND command. That is, the command may establish multiple shell command channels for an entire target machine group at the same time, where the first parameter may be an IP list (IP _ list) of the target machine or a host name list (hostnames) of the target machine, alias of the group of hosts is used, after the target machine is successfully connected, alias of the target machine group (i.e., group channel identifier, it should be noted that, in the embodiment of the present invention, the group channel identifier is an IP list of the target machine or a host name list of the target machine, and so on, each identifier capable of uniquely identifying the target machine in the group is returned), and the command may be sent to different target machines by using alias (i.e., the second device identifier) instead of the SEND command.
In addition, the method according to the embodiment of the present invention may support various system types and shell types, for example, a remote linux: SSH, remote Windows: remote Shell, local Process: process pipes, and so on.
In specific implementation, in the embodiment of the present invention, the establishing, by using a preset HOST command, a shell command channel of a target machine in a shell command channel type, and acquiring a channel identifier of the shell command channel include: establishing a shell command channel of a target machine under a shell command channel type through a preset HOST command, and acquiring a first equipment identifier of the target machine under each shell command channel type after the shell command channel is successfully established;
based on the channel identification, sending a test instruction to a corresponding target machine for testing through the shell command channel, wherein the test instruction comprises the following steps: and sending a test instruction to a target machine corresponding to the first equipment identification for testing through the shell command channel based on the first equipment identification.
It should be noted that, in the embodiment of the present invention, the first device identifier may be various identifiers that can uniquely correspond to the target machine, for example, a machine name of the target machine, and the like.
In specific implementation, in the embodiment of the present invention, a shell command channel may be established for a target unit through a preset HOSTS command, a test instruction may be sent to the target unit corresponding to a group channel identifier through a group channel identifier for testing, and a test instruction may be sent to a target unit corresponding to a second device identifier through the shell command channel based on the second device identifier for testing.
In addition, the embodiment of the invention can also establish a shell command channel of a target unit under different shell command channel types through a preset HOSTS command, and after the shell command channel is successfully established, the group channel identifier of the target unit and the second equipment identifiers of all target machines in the target unit are obtained; and sending a test instruction to the target unit for testing based on the group channel identifier passing through the shell command channel, and/or sending a test instruction to the target unit corresponding to the second device identifier for testing based on the second device identifier passing through the shell command channel.
It should be noted that, in the embodiment of the present invention, the second device identification bit is a machine name of the target machine or a preset target machine number associated with the group channel identifier, for example, on the basis of the group channel identifier alias, a target machine number X associated with the group channel identifier is set, where X is a natural number or a number conforming to another rule, and the alias X is used as a channel identifier of the reorganized target machine, and the test data and the test instruction are transmitted to the corresponding target machine through the alias X.
In addition, in specific implementation, in the embodiment of the present invention, establishing a shell command channel with a target machine in different shell command channel types by presetting an HOSTS command, and acquiring a channel identifier of the shell command channel includes: establishing shell command channels of target machines under different shell command channel types through a preset HOSTS command; after the shell command channel is successfully established, acquiring a first device identifier of a target machine under each shell command channel type;
sending a test instruction to a corresponding target machine for testing through the shell command channel based on the channel identification, wherein the test instruction comprises the following steps: and sending a test instruction to a target machine corresponding to the first equipment identification for testing through the shell command channel based on the first equipment identification.
That is, in the embodiment of the present invention, the preset HOSTS command may implement connection between the tester and the target machine in all cases, and the preset HOST command is only used in a case where there is only one target machine in each hell connection type among a plurality of different shell command channel types.
In specific implementation, in this embodiment of the present invention, after the sending the test data and the test instruction to the target machine, the method further includes: acquiring all test results, acquiring the test results through regular matching, and acquiring the test results of specified rows or columns; and verifying the test result through character string matching, reverse matching or regular matching.
That is to say, after the connection channel is established, the test script is dynamically uploaded, and the test instruction is dynamically executed, the embodiment of the present invention further verifies the test result and counts the test result, that is, the embodiment of the present invention can make the test instruction compiling and the test result verifying more flexible.
The dynamic uploading of the test script in the embodiment of the invention specifically comprises the following steps: after the shell command channel is established, the test driving script (such as a lib library and a driver tool) can be dynamically copied or synchronized to a plurality of target machines.
Abstract SCP commands: source-file target-file of SCPoptions hostname
The test script is copied to the target scp by the command.
Abstract RSYNC command: source-file target-file
This command is used to synchronize the test script with the target machine rsync.
The dynamic execution of the test instruction in the embodiment of the invention specifically comprises: after the shell command channel is established, the test instructions can be dynamically executed to a plurality of target machines, the execution of the test instructions can be controlled in a programmed mode, and the test result is returned.
Abstract SEND command: SEND-hostname-shell _ type command
The command is sent to the target machine through the command, a command output result is returned, the hostname is used for designating the target machine for sending the command, if the command is not designated, the command is sent to the current HOST (the HOST which is successfully called by the latest HOST), the shell _ type is used for designating different session types, can be one of bash, expect and python, and the command is the command of the shell _ type which is sent to the target machine to run.
In specific implementation, the verification test result in the embodiment of the present invention specifically includes: a plurality of test result verification and acquisition methods are provided, including character string matching, reverse matching and regular matching verification methods, including all-result, regular matching result and designated row or column result acquisition methods. The tester can flexibly adopt different verification and acquisition methods according to the difference of each test result, and verify the test result for multiple times.
Abstract EXPECT command: EXPECT options exp varName …
And acquiring and verifying an output result of the test instruction through the command. And outputting a result by using the exp matching test command, and returning a success or failure result. The same test instruction returns results that may perform multiple EXPECT command validations. The varName is a plurality of variable names and is used for storing matching results into corresponding variables when regular matching is used (-r), and variable contents group needing to be accessed are obtained by () in a regular expression.
The following instructions may be set to complete the corresponding result matching in the embodiment of the present invention:
-i: neglecting the case of the letter; -n: the reverse result is: returning failure when matching, and returning success when not matching; -q: the matching information is not output, and only the result of whether the matching information is successful is returned; -o: outputting the matching information but not performing error processing; -r: and performing regular matching, wherein exp is a regular expression. If not, exp is matched as a general character string (refer to string match, supporting wildcards and suggestive characters such as _ [ char ] \ x, etc.); -n: and (5) specifying the matching number, and stopping matching when the matching waiting number reaches n. If not specified, the default is 1. -0 match all rows to be output until the end; -Ln: match the output content of the nth row, n being a non-0 integer, the negative number representing the penultimate row, e.g., -L1 match the first row of the output, -L-1 match the last row of the output; -Ln,: matching the output content starting from the nth row, n being a non-0 integer, the negative number representing the last few rows; -Ln, Ln: matching Ln row output contents starting from the nth row, wherein n is a non-0 integer and a negative number represents the last few rows; -Cn: matching the output content of the nth column, n being a non-0 integer, the negative number representing the penultimate column, e.g. the first column of the matching output as-C1, -the last column of the matching output as-C-1; -Cn,: matching the output content starting from the nth column, n being a non-0 integer, the negative number representing the penultimate column; -Cn, Cn: matching Ln column output contents starting from the nth column, wherein n is a non-0 integer and a negative number represents the last few columns; and when the EXPECT judgment result is negative, the program exits and returns a non-0 value. This behavior (defaulted to { exit 1 }) can be modified by setting the global variable __ error _ action. And if the matching is successful, storing the matched content in the global variable match.
Abstract ASSERT command: an ASSERT expression by which the result of the execution of the test instruction is verified. The expression (TCL expression) is evaluated and a success or failure result is returned. When the result of the ASSERT judgment is negative, the program exits and returns to a non-0 value. This behavior (defaulted to { exit 1 }) can be modified by setting the global variable __ error _ action.
The statistical test result in the embodiment of the invention specifically comprises the following steps: and recording a test log in the test script execution process, and counting to form a test report after the test is finished.
Abstract LOG command: LOG _ message, which LOGs out the LOG file through the command. And outputting LOG _ message to the LOG FILE specified by stdout and LOG _ FILE, and adding the current date-time.
Abstract REPORT command: and the REPORT statistically outputs the test result through the command.
That is to say, the embodiment of the invention realizes the verification and acquisition methods of various test results through the above mode, thereby greatly improving the flexibility of writing test instructions and verifying test results.
As shown in fig. 2, the method of the present invention is verified based on a single machine, cluster and distributed test environment to the android intelligent security platform, a shell command channel with a target machine is established, a channel identifier of the shell command channel is obtained, then test data and test instructions are dynamically sent to the target machine through the shell command channel based on the channel identifier, and a test result returned by the target machine is received. Experiments show that the method provided by the embodiment of the invention can identify the target machine through the channel identifier, and realizes long connection between the tester and the target machine, so that the data testing efficiency is improved, the system resources are saved, and the user experience is greatly improved.
Generally, the core idea of the embodiment of the invention is to provide an automatic testing method for receiving and sending data based on a shell command channel aiming at multi-type, multi-quantity and multi-interaction complex testing scenes. The independent processes are opened for each command channel through the process pipeline for connection, shell command channels can be established for a plurality of target machines at the same time, the test instructions are dynamically executed by using the return identifiers, and the execution of the test instructions can be controlled in a programmable mode. Different types of shell command channels can be established for target machines of different platforms. Therefore, the test operation efficiency and flexibility are improved, and the compatibility of the test platform is also improved. Meanwhile, the invention also provides a plurality of test result verification and acquisition methods, thereby improving the flexibility of test verification.
A second embodiment of the present invention provides an automated testing apparatus, referring to fig. 3, comprising: the connection unit is used for establishing a shell command channel with a target machine and acquiring a channel identifier of the shell command channel; and the processing unit number is used for sending a test instruction to the corresponding target machine for testing through the shell command channel based on the channel identifier.
It should be noted that, in the embodiment of the present invention, one or more target machines may be provided, and multiple target machines may be set as a group according to different types of shell command channels, that is, multiple target machines in the same shell command channel type form a target machine group, and long connection between the testing machine and the entire target machine group is achieved through the same shell command channel and the same channel identifier.
That is to say, in the embodiment of the present invention, the channel identifier and the target machine are set correspondingly, that is, the target machine is identified by the channel identifier. Each target machine has one and only one channel identifier, but one channel identifier may correspond to multiple target machines at the same time, for example, one channel identifier may correspond to an entire target group. In other words, in the embodiment of the present invention, the test data may be sent to one target machine through one channel identifier, or the test data may be sent to the whole target machine group through one channel identifier at the same time.
In a specific implementation, a person skilled in the art may set a specific channel identifier according to actual needs, such as setting the channel identifier as a machine name or an IP address of the target machine.
In addition, the test data according to the embodiment of the present invention may be drive script data, and may also be other various test data.
That is to say, in the embodiment of the present invention, the target machine is identified by the channel identifier, so that long connection between the tester and the target machine is achieved, a connection channel is prevented from being reestablished in each test, the test efficiency of data is improved, system resources are saved, and the user experience is greatly improved.
Specifically, the embodiment of the invention adopts a centralized management shell command channel method to establish shell command channels for different target machines, returns a preset identifier (namely the channel identifier) after the connection is successful, and can dynamically send a test instruction by using the identifier. The environment configuration of each connection in the embodiment of the invention is the same, so that the continuity of a plurality of sent test instructions is ensured, namely, the long connection between the tester and the target machine is realized.
In specific implementation, the target machines in the embodiment of the present invention may be target machines of different shell command channel types, and a target machine in each shell command channel type is a target machine or a target unit formed by multiple target machines;
the embodiment of the invention takes the shell (various shell command channel types) as a command execution environment, mainly because the shell adopts one-to-one command/response pairs, the processing is convenient, and the determined prompt provides a convenient command ending mark. The shell is provided with a natural full-function script running environment, various platforms, various script languages and character string input and output, and is easy to develop and debug, the shell is provided with a processing mode facing command/response pairs (a processing mode facing a text line for vs Expect), SEND identification is used for sending, receiving and judging command ending, EXPECT identification is used for processing returned response data, asynchronous receiving of command channel processing details can be shielded, real-time display is carried out, prompt matching is carried out, overtime processing is carried out, command layer logic is concerned, programming is simplified, and a natural multi-process concurrent processing mechanism is provided.
Further, the connection unit in the embodiment of the present invention is further configured to establish a shell command channel with a target machine or a target unit in different shell command channel types through a preset HOSTS command, and obtain a channel identifier of the shell command channel.
That is, in the embodiment of the present invention, a shell command channel between the tester and the target machine may be established by presetting the HOSTS command, and a channel identifier of the shell command channel that is successfully established is obtained, so as to identify the target machine through the channel identifier, thereby establishing a long connection between the tester and the target machine.
Of course, when there is one target machine in a certain shell command channel type, the embodiment of the present invention may also establish the shell command channel with the target machine in the shell command channel type through the preset HOST command, and obtain the channel identifier of the shell command channel.
Generally speaking, the embodiment of the invention establishes the shell command channel between the tester and one or more target units of different types through the preset HOSTS command, and establishes the shell command channel between the tester and one target unit of different types through the preset HOST command.
In the embodiment of the present invention, the preset HOST command includes one or more of the following: the IP address, the user name and the password of the target machine; the preset HOSTS command comprises: the IP list of the target machine or the machine name list of the target machine.
The preset HOSTS command and the preset HOST command in the embodiment of the present invention will be explained and explained in detail by a specific example:
the specific setting of the preset HOST command in the embodiment of the present invention may be as follows: HOST [ user% passed ] ip [: hostname ] shell _ list, wherein hostname is the HOST name of the tester corresponding to the received command, and in addition, the preset HOST command also comprises: the IP is the IP address of the target machine, the password is the password of the target machine, and certainly, the user name of the target machine can be further set in the preset HOST command, and the like. The command may establish a number of different shell command channel types, such as: bash, expect, and python, specified by shell _ list (default bash expect). The shell command channels are independent of each other and each receive and execute a response type command. And returning to the host name hostname of the test machine after the shell connection is successfully established, automatically generating by the system if the user does not specify, and sending a test command to the target machine by using the hostname instead of a SEND command. The command may connect multiple target machines simultaneously.
The specific setting of the preset HOSTS command in the embodiment of the present invention may be: the HOSTS IP _ list | hostnamesaias may establish multiple shell command channels for a target unit at the same time, where a first parameter may be a target machine IP list (IP _ list) or a target machine name list (hostnames) of the target machine, alias of the group of HOSTS is used, after the target machine is successfully connected, alias of the target unit (i.e., group channel identifier) is returned (it should be noted that, in the embodiment of the present invention, the group channel identifier is the target machine IP list or the target machine name list, and other various identifiers capable of uniquely identifying the group of target machines), and a command may be sent to different target machines by using alias (i.e., a second device identifier) instead of a SEND command.
In addition, the method according to the embodiment of the present invention may support various system types and shell types, for example, a remote linux: SSH, remote Windows: remote Shell, local Process: process pipes, and so on.
In a specific implementation, in the embodiment of the present invention, the connection unit is further configured to establish a shell command channel with a target machine in a shell command channel type through a preset HOST command, and after the shell command channel is established successfully, obtain a first device identifier of the target machine in each shell command channel type;
and the processing unit is also used for sending a test instruction to the target machine corresponding to the first equipment identifier for testing through the shell command channel based on the first equipment identifier.
It should be noted that, in the embodiment of the present invention, the first device identifier may be various identifiers that can uniquely correspond to the target machine, for example, a machine name of the target machine, and the like.
In a specific implementation, in the embodiment of the present invention, the connection unit is further configured to establish a shell command channel for the target unit through a preset HOSTS command, and send a test instruction to the target unit corresponding to the group channel identifier through the group channel identifier for testing, and the processing unit is further configured to send the test instruction to the target unit corresponding to the second device identifier through the shell command channel based on the second device identifier for testing.
In addition, the embodiment of the invention can also establish a shell command channel of a target unit under different shell command channel types through a preset HOSTS command, and after the shell command channel is successfully established, the group channel identifier of the target unit and the second equipment identifiers of all target machines in the target unit are obtained; and sending a test instruction to the target unit for testing based on the group channel identifier passing through the shell command channel, and/or sending a test instruction to the target unit corresponding to the second device identifier for testing based on the second device identifier passing through the shell command channel.
It should be noted that, in the embodiment of the present invention, the second device identification bit is a machine name of the target machine or a preset target machine number associated with the group channel identifier, for example, on the basis of the group channel identifier alias, a target machine number X associated with the group channel identifier is set, where X is a natural number or a number conforming to another rule, and the alias X is used as a channel identifier of the reorganized target machine, and the test data and the test instruction are transmitted to the corresponding target machine through the alias X.
In addition, in a specific implementation, in the embodiment of the present invention, the connection unit is further configured to establish a shell command channel with a target machine in a different shell command channel type through a preset HOSTS command; after the shell command channel is successfully established, acquiring a first device identifier of a target machine under each shell command channel type;
and sending a test instruction to a target machine corresponding to the first equipment identifier for testing through the shell command channel based on the first equipment identifier by a processing unit.
That is, in the embodiment of the present invention, the preset HOSTS command may implement connection between the tester and the target machine in all cases, and the preset HOST command is only used in a case where there is only one target machine in each hell connection type among a plurality of different shell command channel types.
In a specific implementation, in the embodiment of the present invention, the processing unit is further configured to obtain all test results, obtain the test results through regular matching, and obtain the test results of the designated row or column; and verifying the test result through character string matching, reverse matching or regular matching.
Generally, the core idea of the embodiment of the invention is to provide an automatic testing method for receiving and sending data based on a shell command channel aiming at multi-type, multi-quantity and multi-interaction complex testing scenes. The independent processes are opened for each command channel through the process pipeline for connection, shell command channels can be established for a plurality of target machines at the same time, the test instructions are dynamically executed by using the return identifiers, and the execution of the test instructions can be controlled in a programmable mode. Different types of shell command channels can be established for target machines of different platforms. Therefore, the test operation efficiency and flexibility are improved, and the compatibility of the test platform is also improved. Meanwhile, the invention also provides a plurality of test result verification and acquisition methods, thereby improving the flexibility of test verification.
The relevant content of the embodiments of the present invention can be understood by referring to the first embodiment of the present invention, and will not be discussed in detail herein.
A third embodiment of the invention provides a computer-readable storage medium storing a signal-mapped computer program which, when executed by at least one processor, implements the method for automated testing of data as set forth in any of the first embodiments of the invention.
The contents of the embodiments of the present invention can be understood by referring to the first and second embodiments of the present invention, and will not be discussed in detail herein.
Although the preferred embodiments of the present invention have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, and the scope of the invention should not be limited to the embodiments described above.

Claims (10)

1. An automated testing method, comprising:
establishing a shell command channel with a target machine, and acquiring a channel identifier of the shell command channel;
and sending a test instruction to the corresponding target machine for testing through the shell command channel based on the channel identification.
2. The method of claim 1,
the target machines are target machines of different shell connection types, and the target machine under each shell connection type is a single target machine or a target unit consisting of a plurality of target machines;
the establishing of the shell command channel with the target machine and the obtaining of the channel identification of the shell command channel comprise the following steps: and establishing a shell command channel of a single target machine or a target unit under different shell connection types through a preset HOSTS command, and acquiring a channel identifier of the shell command channel.
3. The method of claim 2,
when the number of the target machines in the shell connection type is single, the establishing a shell command channel with the target machines, and obtaining the channel identifier of the shell command channel further include:
and establishing a shell command channel of a target machine in the shell connection type through a preset HOST command, and acquiring a channel identifier of the shell command channel.
4. The method of claim 3,
the obtaining of the channel identifier of the shell command channel includes: after the shell command channel is successfully established, acquiring a first device identifier of a target machine under each shell connection type;
based on the channel identification, sending a test instruction to a corresponding target machine for testing through the shell command channel, wherein the test instruction comprises the following steps: and sending a test instruction to a target machine corresponding to the first equipment identification for testing through the shell command channel based on the first equipment identification.
5. The method of claim 3,
the preset HOST command comprises one or more of the following commands: the IP address, the user name, the password and the channel type of the target machine;
the preset HOSTS command comprises: the IP list of the target machine or the machine name list of the target machine.
6. The method of claim 2,
when the target machine in the shell connection type is the target machine group, establishing a shell command channel with the target machine, and acquiring a channel identifier of the shell command channel, wherein the method comprises the following steps:
establishing a shell command channel of a target unit under different shell connection types through a preset HOSTS command, and acquiring a group channel identifier of the target unit and second equipment identifiers of all target machines in the target unit after the shell command channel is successfully established;
the step of sending a test instruction to a corresponding target machine for testing through the shell command channel based on the channel identifier comprises the following steps: sending a test instruction to the target unit for testing through the shell command channel based on the group channel identifier, and/or sending a test instruction to the target unit corresponding to the second device identifier for testing through the shell command channel based on the second device identifier;
when the number of the target machines in the shell connection type is single, the establishing a shell command channel with the target machines, and obtaining the channel identifier of the shell command channel further include:
establishing shell command channels of target machines under different shell connection types through a preset HOSTS command; after the shell command channel is successfully established, acquiring a first device identifier of a target machine under each shell connection type;
the step of sending a test instruction to a corresponding target machine for testing through the shell command channel based on the channel identifier comprises the following steps: and sending a test instruction to a target machine corresponding to the first equipment identification for testing through the shell command channel based on the first equipment identification.
7. The method of claim 6,
the group channel identification is an IP list of the target machine or a machine name list of the target machine;
the first equipment identification is the machine name of the target machine;
the second device identification is the machine name of the target machine or the target machine number associated with the group channel identification.
8. The method of any one of claims 1-6, wherein after sending the test data and test instructions to the target machine, the method further comprises:
acquiring all test results, acquiring the test results through regular matching, and acquiring the test results of specified rows or columns; and verifying the test result through character string matching, reverse matching or regular matching.
9. An automated testing apparatus, comprising:
the connection unit is used for establishing a shell command channel with a target machine and acquiring a channel identifier of the shell command channel;
and the processing unit is used for sending a test instruction to the corresponding target machine for testing based on the channel identification passing through the shell command channel and the channel identification passing through the shell command channel.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a signal-mapped computer program which, when executed by at least one processor, implements the automated testing method of any one of claims 1-8.
CN202010702065.6A 2020-07-21 2020-07-21 Automatic testing method and device Active CN111737145B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010702065.6A CN111737145B (en) 2020-07-21 2020-07-21 Automatic testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010702065.6A CN111737145B (en) 2020-07-21 2020-07-21 Automatic testing method and device

Publications (2)

Publication Number Publication Date
CN111737145A true CN111737145A (en) 2020-10-02
CN111737145B CN111737145B (en) 2020-12-22

Family

ID=72655242

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010702065.6A Active CN111737145B (en) 2020-07-21 2020-07-21 Automatic testing method and device

Country Status (1)

Country Link
CN (1) CN111737145B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090307763A1 (en) * 2008-06-05 2009-12-10 Fiberlink Communications Corporation Automated Test Management System and Method
CN104834602A (en) * 2015-05-20 2015-08-12 广州华多网络科技有限公司 Program issuing method, device and system
CN105893252A (en) * 2016-03-28 2016-08-24 杭州华三通信技术有限公司 Automatic testing method and device
CN106059853A (en) * 2016-05-26 2016-10-26 中国建设银行股份有限公司 Network connectivity test method and device
CN107870836A (en) * 2017-10-31 2018-04-03 郑州云海信息技术有限公司 A kind of automated testing method of Intel Omni Path performances
CN107943636A (en) * 2017-12-07 2018-04-20 郑州云海信息技术有限公司 It is a kind of that the method tested is performed based on more machine batches under Linux

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090307763A1 (en) * 2008-06-05 2009-12-10 Fiberlink Communications Corporation Automated Test Management System and Method
CN104834602A (en) * 2015-05-20 2015-08-12 广州华多网络科技有限公司 Program issuing method, device and system
CN105893252A (en) * 2016-03-28 2016-08-24 杭州华三通信技术有限公司 Automatic testing method and device
CN106059853A (en) * 2016-05-26 2016-10-26 中国建设银行股份有限公司 Network connectivity test method and device
CN107870836A (en) * 2017-10-31 2018-04-03 郑州云海信息技术有限公司 A kind of automated testing method of Intel Omni Path performances
CN107943636A (en) * 2017-12-07 2018-04-20 郑州云海信息技术有限公司 It is a kind of that the method tested is performed based on more machine batches under Linux

Also Published As

Publication number Publication date
CN111737145B (en) 2020-12-22

Similar Documents

Publication Publication Date Title
US10657032B2 (en) Systems and methods for monitoring performance of applications
KR101881804B1 (en) Method and apparatus for automating game test
CN107368503B (en) Data synchronization method and system based on button
US20090199096A1 (en) Automated gui test recording/playback
KR102243379B1 (en) Method and apparatus for automating game test
CN112597014B (en) Automatic test method and device based on data driving, medium and electronic equipment
CN111104139A (en) Firmware upgrading method, device, equipment and storage medium
CN114281680B (en) Web automatic testing method and system
CN115658529A (en) Automatic testing method for user page and related equipment
CN103593293A (en) Parallel automated testing method
CN111399861A (en) Software automation deployment method and system
CN112954257A (en) Automatic verification method and system for video conference
CN111737145B (en) Automatic testing method and device
CN106789205A (en) Group of planes order operation method and system
CN111949537A (en) Interface test method, device, equipment and medium
CN105302731A (en) Testing system and method for upgrading website configuration
CN113986263A (en) Code automation test method, device, electronic equipment and storage medium
CN115878448A (en) Database test method, distributed database and storage medium
CN109144524B (en) Version release method of subject game on education platform and electronic equipment
CN111858194A (en) Method and device for generating and processing robot error, robot and background server
CN112214407A (en) Data verification control and execution method and corresponding device, equipment and medium
US20100115328A1 (en) Methods and Systems for Handling Device Failovers during Test Executions
CN116257458B (en) Automatic testing method and system for mobile API (application program interface) in hybrid development mode
CN117407320B (en) Automatic testing method and device compatible with multiparty voice control equipment
CN110213127B (en) Automated testing system and method fusing virtualization multitasks

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant