CN107168877A - A kind of method for carrying out remote testing to server based on Python - Google Patents
A kind of method for carrying out remote testing to server based on Python Download PDFInfo
- Publication number
- CN107168877A CN107168877A CN201710359601.5A CN201710359601A CN107168877A CN 107168877 A CN107168877 A CN 107168877A CN 201710359601 A CN201710359601 A CN 201710359601A CN 107168877 A CN107168877 A CN 107168877A
- Authority
- CN
- China
- Prior art keywords
- machine
- measured
- test
- python
- remote testing
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3664—Environments for testing or debugging software
Abstract
The invention discloses a kind of method for carrying out remote testing to server based on Python, comprise the following steps:S1, control machine carries out long-range connecting test simultaneously to multiple machines to be measured;S2, to remotely being connected by the machine to be measured of connecting test;S3, control machine carries out state-detection to the machine to be measured of connection, and machine state to be measured normally enters S4, machine interrupt test to be measured abnormal to state;S4, carries out remote testing, and return test result to control machine to the normal machine to be measured of state.Compared with prior art, method of the present invention can use multiple versions of server system, and detection efficiency is high, and test result is objective and accurate.
Description
Technical field
It is specifically a kind of that server is carried out remotely based on Python the present invention relates to server test technical field
The method of test.
Background technology
With continuing to develop for current internet and big data technology, the quantity demand of server with model demand increasingly
It is abundant.In order to meet all products all by the requirement completely tested, single tester certainly will will carry out the survey of multiple projects
Examination, testing efficiency straight line declines.Therefore, the necessity of automatic test just further reinforcement.Automatic test one is critically important
The characteristics of be exactly remote testing.
Conventional remote testing, is roughly divided into two kinds:
The first, the manual ssh of tester is logged in
The advantage of this method is that test result is intuitively effective, and tester can carry out abundant operation.The disadvantage is that,
Once can not smoothly connect, tester needs to carry out all kinds of investigations, and this part is according to the richness of tester's experience, difficulty or ease
Degree is in polarization state, is unfavorable for industrialization test.
Second, logged in automatically using expect:
The advantage of this method is to log in automatically, carries out automatic test.The disadvantage is that, versatility is not good enough.
Expect is tested suitable for interactivity, but in the scene of remote testing, after automatic log in, if control is returned, it is current whole
End will be remote machine, terminate there is problem in terms of exiting in subsequent test.If not returning control, directly terminate connection.
Substantial amounts of connection will be set up so when testing tens of order easily for one, not only existence and stability is asked
Topic, also loses time.
The content of the invention
To overcome the shortcomings of that above-mentioned prior art is present, efficiently, objectively it is based on it is an object of the invention to provide a kind of
The method that Python carries out remote testing to server.
The technical solution adopted for the present invention to solve the technical problems is:One kind is carried out long-range based on Python to server
The method of test, it is characterized in that:Comprise the following steps,
S1, control machine carries out long-range connecting test simultaneously to multiple machines to be measured;
S2, to remotely being connected by the machine to be measured of connecting test;
S3, control machine carries out state-detection to the machine to be measured of connection, and machine state to be measured normally enters S4, to state not just
Normal machine interrupt test to be measured;
S4, carries out remote testing, and return test result to control machine to the normal machine to be measured of state.
Further, long-range connecting test described in step S1 includes the logical tests of ping and ssh connecting tests.
Further, the ping lead to test be specially:Ping sends some request bags to each machine to be measured, and detection is obtained
Response bag number, if at least obtaining 1 response bag, the machine to be measured is by the logical tests of ping, otherwise every special time
Repeat to send request bag, until reaching maximum number of times of transmission, if control machine does not receive response bag all the time, judge the machine to be measured not
Pass through the logical detections of ping.
Further, control machine record returns to the time that response bag expends by the machine to be measured of the logical tests of ping.
Further, the special time is 30 seconds, and the maximum number of times of transmission is 20 times.
Further, control machine is remotely connected by Python paramiko modules in step S2, described
Paramiko modules carry out code entry trial to machine to be measured respectively and rsa logs in trial.
Further, long-range connection includes described in step S3:Machine to be measured records the available machine time of itself, and control machine is by institute
State the available machine time and the time of the machine to be measured return response bag consuming by the logical tests of ping is compared, according to what is compared
Difference, judges whether the starting state of machine to be measured is normal.
Further, remote testing is carried out to the normal machine to be measured of the state in step S4 and is included in foundation in control machine
Paramiko objects, according to the information of machine to be measured, set up the ssh connections of machine to be measured and control machine, control machine by ssh passages to
Machine to be measured sends test command, and machine to be measured performs the test command, obtains test result, and the test result is back to
Control machine.
Further, the IP of the information of the machine to be measured including machine to be measured, user name and key is logged in.
The beneficial effects of the invention are as follows:The present invention carries out long-range connection to many machines to be measured simultaneously using 1 control machine and surveyed
Examination and remote detection, form the test observation more than 1 pair, improve testing efficiency, be that follow-up automatic test is laid a good foundation;
When to machine status monitoring to be measured, when comparing ping logical times and the start that control machine and machine to be measured are recorded respectively
Between, objectively embody the state outcome of machine to be measured, it is to avoid the test experience artificially monitored makes for the subjective impact of monitoring nut
Monitoring to machine state to be measured is more accurate;
When control machine is remotely connected to machine to be measured, two kinds of login modes are carried out using Python paramiko modules
Trial, the problem of avoiding compatibility between linux system different editions make the application model of remote test method of the present invention
Enclose more extensive.
Brief description of the drawings
Fig. 1 is the flow chart of the method for the invention.
Fig. 2 is the flow chart of long-range connecting detection of the present invention.
Embodiment
For the technical characterstic for illustrating this programme can be understood, below by embodiment, and its accompanying drawing is combined, to this hair
It is bright to be described in detail.Present invention omits the description to common knowledge to avoid being unnecessarily limiting the present invention.
As shown in figure 1, a kind of method for carrying out remote testing to server based on Python of the present invention, is in control machine
The Python tests of upper execution, including control machine carry out long-range connecting test to multiple machines to be measured simultaneously, and Python detections are to be measured
Whether machine is effectively connected, and to sending bind command by the machine to be measured of connecting test, is attached, control machine testing is to be measured
Machine /available machine times of proc/uptime records, the judgement of machine starting state to be measured is carried out, is normally treated for starting state
Survey machine sets up effective connection, starts remote testing.
Specifically, the method for the invention includes following S1-S4,4 steps:
S1, control machine performs Python tests, and long-range connecting test is carried out simultaneously to multiple machines to be measured;
As shown in Fig. 2 long-range connecting detection predominantly detects two aspects:Can ping lead to, ssh connections can be carried out.
Detection can ping lead to, so-called ping is logical refer to two equipment between network be logical.In view of opening for machinery compartment
Dynamic time difference, is tested using wheel dynamic formula method here.Often wheel interval 30 seconds, 20 takes turns test altogether.So do, one can
To save the Connection Time, two ensure that in the case where that can connect, and can connect certainly.
Specifically, each ping of control machine sends out three request bags, if can obtain minimum of one response bag every time, depending on
The machine to be measured is can lead to ping, and it is pass that mark ping, which leads to testing result, carries out the detection of next machine to be measured.If three
Request bag can not all receive response, then the logical requests of second of ping are carried out after being spaced 30 seconds, response bag are received, number of repetition is most
For 20 times (being within 10 minutes that system starts the time to greatest extent).
Can ssh connections for the machine testing to be measured by the logical detections of ping:
Remote file transferring is by ssh passages, and one to carry out speed fast, and two being encrypted transmission.
Can ping it is logical on the basis of detection can carry out ssh connections, direct remote cipher key is logged in here, according to logging in
As a result the action of next step is carried out, if the log on error, then error message is pointed out, and this is to be measured for interrupt routine and Safe withdrawing
Machine.
Further, control machine record returns to the time that response bag expends by the machine to be measured of the logical tests of ping.
S2, to remotely being connected by the machine to be measured of connecting test;
Long-range connection using python paramiko modules (paramiko is the module write with python language,
Follow SSH2 agreements, support by encrypt and certification in the way of, carry out the connection of remote server).Paramiko modules are supported close
Code is logged in logs in two ways with rsa.Why need to do both trials, be due to that ssh is set on different machines
Authority is different, and particularly under root accounts, code entry is not supported substantially.Therefore for the connected mode specific to machine to be measured
Need exist for doing two kinds and log in trial, respectively code entry is attempted to log in trial with rsa, it is therefore necessary to do compatible processing
The compatibility processing refers to:Widely different between different release versions under linux system, many manufacturers are also all
The customization system of oneself has been done, has been caused under different system, the setting of SSH agreements is different, and part system does not support RSA to log in.
Here normal way is to set up connection for the first time by the way of password, and just (RSA is faster by the way of RSA is logged in afterwards
It is more stable).When it is secondary log in RSA and can not set up connection when, it should enable code entry again, and can not be as connection error at
Reason.
S3, control machine carries out state-detection to the machine to be measured of connection, and machine state to be measured normally enters S4, to state not just
Normal machine interrupt test to be measured;
Connect after machine to be measured, control machine testing/proc/uptime files, the run time of this document record system, including
System starts to the now time and the free time of system.According to time length is started, judge whether to start exception.
Specifically, machine startup duration is have recorded in the machine to be measured under linux system ,/proc/uptime, it is carried out
Detection, is to return to the time progress that response bag expends to pass through the machine to be measured of the logical tests of ping with control machine record in step S1
Compare, when the two difference is excessive, it is meant that unexpected thing is necessarily encountered in system starting process, system pole has
It improper may start, in this case, the test of machine to be measured should just be interrupted, retain test environment, it is determined that category
In, being further continued for being tested under normal circumstances.
Compared to manual test, this mode contrasted based on the time can more objectively embody test result
S4, when previous step S1-S3 result is all pass, control machine start to machine to be measured carry out remote testing and
Test returns result after terminating.
Specifically, due to can set up ssh connections, paramiko objects are now directly set up, then according to be measured
The information such as IP, the username and password of machine, the ssh connections set up between control machine and machine to be measured, and transmit test command and
Performed on machine to be measured, control machine can send multiple test commands to machine to be measured, corresponding, the multiple test results of acquisition (no matter
Correctness), and control machine is back to, shown and preserved.
Test result is shown by the shell frames of control machine, each machine to be measured there are independent shell display boxes,
It is shown separately to multiple test results.
Simply the preferred embodiment of the present invention described above, for those skilled in the art,
Without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications are also regarded as this hair
Bright protection domain.
Claims (9)
1. a kind of method for carrying out remote testing to server based on Python, it is characterized in that:Comprise the following steps,
S1, control machine carries out long-range connecting test simultaneously to multiple machines to be measured;
S2, to remotely being connected by the machine to be measured of connecting test;
S3, control machine carries out state-detection to the machine to be measured of connection, and the normal machine to be measured of state enters step S4, to state not just
Normal machine interrupt test to be measured;
S4, carries out remote testing, and return test result to control machine to the normal machine to be measured of state.
2. a kind of method for carrying out remote testing to server based on Python according to claim 1, it is characterized in that:Step
Long-range connecting test described in rapid S1 includes the logical tests of ping and ssh connecting tests.
3. a kind of method for carrying out remote testing to server based on Python according to claim 2, it is characterized in that:Institute
Stating the logical tests of ping is specially:Ping sends some request bags to each machine to be measured, the number of the response bag obtained is detected, if extremely
1 response bag is obtained less, then otherwise the machine to be measured repeats to send request bag by the logical tests of ping every special time, until
Maximum number of times of transmission is reached, if control machine does not receive response bag all the time, judges the machine to be measured not by the logical detections of ping.
4. a kind of method for carrying out remote testing to server based on Python according to claim 3, it is characterized in that:Control
Machine record processed returns to the time that response bag expends by the machine to be measured of the logical tests of ping.
5. a kind of described method for carrying out remote testing to server based on Python is required according to right 3, it is characterized in that:Institute
It is 30 seconds to state special time, and the maximum number of times of transmission is 20 times.
6. a kind of described method for carrying out remote testing to server based on Python is required according to right 1, it is characterized in that:Step
Control machine is remotely connected by Python paramiko modules in rapid S2, and the paramiko modules are respectively to test machine
Code entry is carried out to attempt to log in trial with rsa.
7. a kind of method for carrying out remote testing to server based on Python according to claim 4, it is characterized in that:Step
State-detection includes described in rapid S3:Machine to be measured records the available machine time of itself, and control machine is sent to by ssh passages, control
The time that the available machine time and the machine to be measured by the logical tests of ping return to response bag consuming is compared by machine, according to
The difference compared, judges whether the starting state of machine to be measured is normal.
8. a kind of method for carrying out remote testing to server based on Python according to claim 1, it is characterized in that:Step
Remote testing is carried out in rapid S4 to the normal test machine of the state and is included in control machine to set up paramiko objects, according to treating
The information of survey machine, sets up the ssh connections of machine to be measured and control machine, and control machine sends test command by ssh passages to machine to be measured,
Test machine performs the test command, obtains test result, and the test result is back into control machine.
9. a kind of method for carrying out remote testing to server based on Python according to claim 8, it is characterized in that:Institute
State the IP of the information including machine to be measured of machine to be measured, user name and log in key.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710359601.5A CN107168877A (en) | 2017-05-19 | 2017-05-19 | A kind of method for carrying out remote testing to server based on Python |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710359601.5A CN107168877A (en) | 2017-05-19 | 2017-05-19 | A kind of method for carrying out remote testing to server based on Python |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107168877A true CN107168877A (en) | 2017-09-15 |
Family
ID=59816278
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710359601.5A Pending CN107168877A (en) | 2017-05-19 | 2017-05-19 | A kind of method for carrying out remote testing to server based on Python |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107168877A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107729242A (en) * | 2017-10-12 | 2018-02-23 | 郑州云海信息技术有限公司 | A kind of automated testing method, system, device and computer-readable storage medium |
CN108763042A (en) * | 2018-05-24 | 2018-11-06 | 广东睿江云计算股份有限公司 | A kind of Cloud Server performance data acquisition method and device based on python |
CN108897682A (en) * | 2018-06-25 | 2018-11-27 | 郑州云海信息技术有限公司 | A kind of iteration tests outcome evaluation method based on Python |
CN108923997A (en) * | 2018-05-24 | 2018-11-30 | 广东睿江云计算股份有限公司 | A kind of cloud service node automatic test approach and device based on python |
CN109361562A (en) * | 2018-10-31 | 2019-02-19 | 广东电网有限责任公司信息中心 | A kind of automated testing method based on the access of related network equipment |
CN110928733A (en) * | 2019-11-13 | 2020-03-27 | 深圳忆联信息系统有限公司 | Encryption and decryption test method and device based on solid state disk and computer equipment |
CN111736935A (en) * | 2020-05-29 | 2020-10-02 | 苏州浪潮智能科技有限公司 | Method and system for realizing in-band and out-band concurrent detection and in-band operation imaging |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105117311A (en) * | 2015-08-07 | 2015-12-02 | 北京思特奇信息技术股份有限公司 | System deployment environment inspection method and system |
CN105404569A (en) * | 2015-12-09 | 2016-03-16 | 浪潮电子信息产业股份有限公司 | Method for testing remote Power Reset of server |
CN105471675A (en) * | 2015-11-20 | 2016-04-06 | 浪潮电子信息产业股份有限公司 | Method and system of testing nodes in batches |
CN105553763A (en) * | 2015-12-10 | 2016-05-04 | 山东中创软件商用中间件股份有限公司 | Network-based detection method and detection system |
US9525598B1 (en) * | 2014-11-13 | 2016-12-20 | Amazon Technologies, Inc. | Network testing device for automated topology validation |
-
2017
- 2017-05-19 CN CN201710359601.5A patent/CN107168877A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9525598B1 (en) * | 2014-11-13 | 2016-12-20 | Amazon Technologies, Inc. | Network testing device for automated topology validation |
CN105117311A (en) * | 2015-08-07 | 2015-12-02 | 北京思特奇信息技术股份有限公司 | System deployment environment inspection method and system |
CN105471675A (en) * | 2015-11-20 | 2016-04-06 | 浪潮电子信息产业股份有限公司 | Method and system of testing nodes in batches |
CN105404569A (en) * | 2015-12-09 | 2016-03-16 | 浪潮电子信息产业股份有限公司 | Method for testing remote Power Reset of server |
CN105553763A (en) * | 2015-12-10 | 2016-05-04 | 山东中创软件商用中间件股份有限公司 | Network-based detection method and detection system |
Non-Patent Citations (1)
Title |
---|
ROOTMELON: "python 如何判断和对端Linux主机是否网络通", 《HTTP://WWW.CNBLOGS.COM/ROOTMELON/P/5011458.HTML》 * |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107729242A (en) * | 2017-10-12 | 2018-02-23 | 郑州云海信息技术有限公司 | A kind of automated testing method, system, device and computer-readable storage medium |
CN108763042A (en) * | 2018-05-24 | 2018-11-06 | 广东睿江云计算股份有限公司 | A kind of Cloud Server performance data acquisition method and device based on python |
CN108923997A (en) * | 2018-05-24 | 2018-11-30 | 广东睿江云计算股份有限公司 | A kind of cloud service node automatic test approach and device based on python |
CN108923997B (en) * | 2018-05-24 | 2021-07-20 | 广东睿江云计算股份有限公司 | Cloud service node automatic testing method and device based on python |
CN108897682A (en) * | 2018-06-25 | 2018-11-27 | 郑州云海信息技术有限公司 | A kind of iteration tests outcome evaluation method based on Python |
CN109361562A (en) * | 2018-10-31 | 2019-02-19 | 广东电网有限责任公司信息中心 | A kind of automated testing method based on the access of related network equipment |
CN110928733A (en) * | 2019-11-13 | 2020-03-27 | 深圳忆联信息系统有限公司 | Encryption and decryption test method and device based on solid state disk and computer equipment |
CN110928733B (en) * | 2019-11-13 | 2023-08-08 | 深圳忆联信息系统有限公司 | Encryption and decryption test method and device based on solid state disk and computer equipment |
CN111736935A (en) * | 2020-05-29 | 2020-10-02 | 苏州浪潮智能科技有限公司 | Method and system for realizing in-band and out-band concurrent detection and in-band operation imaging |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107168877A (en) | A kind of method for carrying out remote testing to server based on Python | |
CN109510742B (en) | Server network card remote test method, device, terminal and storage medium | |
EP3140960B1 (en) | Methods, systems, and computer readable media for providing fuzz testing functionality | |
CN106933709A (en) | A kind of method of testing and device | |
CN109254922B (en) | Automatic testing method and device for BMC Redfish function of server | |
CN104572422A (en) | Memory monitoring achievement method based on startup and shutdown of Linux system | |
WO2016082543A1 (en) | Device testing method and testing device | |
CN111211934B (en) | Cluster remote communication test method and system | |
CN106445755A (en) | Method for automatically testing integral cabinet servers | |
CN105207832B (en) | A kind of server stress test method and device | |
CN106790463A (en) | The access method and system of Web configuration file heavy loads | |
EP2627057A1 (en) | Time-out control method, device and system | |
CN106603343A (en) | A method for testing stability of servers in batch | |
CN102223268B (en) | Network equipment as well as method and device for starting hardware testing of same | |
KR20130030037A (en) | Test analysis system of network and analysis method thereof | |
CN112311627B (en) | Universal power protocol testing method and system based on protocol description file in XML format | |
CN106598793B (en) | Test system and test method based on BIOS serial port log data | |
CN111181808B (en) | Method and system for testing BMC IP access control | |
CN107896345A (en) | The method of test network Connection Time in Android intelligent television | |
US20230089918A1 (en) | Method and apparatus for controlling charging, based on monitored communication signals associated with a charging session | |
CN103064789B (en) | A kind of automated testing method of software control | |
CN106982148B (en) | Server downtime monitoring method, device and system | |
CN114338347A (en) | Ampere platform-based fault information out-of-band acquisition method and device | |
CN111064794B (en) | Fault detection method, device, equipment and storage medium of terminal equipment | |
CN110851309B (en) | Integrated verification system and method |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170915 |