ianmiell / shutit

Automation framework for programmers
http://ianmiell.github.io/shutit/
MIT License
2.15k stars 110 forks source link

send_and_return_status bug #323

Open ianmiell opened 6 years ago

ianmiell commented 6 years ago

HI Ian, your method send_and_return_status has a bug. for example,

the command: gi_session = shutit.create_session('bash',loglevel='DEBUG') gi_session.login('ssh {user}@{host}'.format(host=self.nodes[0], user=self.gi_user), user=self.gi_user, password=self.gi_pwd)
result=gi_session.send_and_return_status(self.GI_HOME+'/bin/crsctl check crs') print 'The result is '+result

==>from the description, send_and_return_status: """Returns true if a good exit code was received (usually 0)

when exit_code=1, the result is shown as follows:

the log: 2018-08-01 11:50:38,601 DEBUG: Expecting: rws3010158:3iR91CPn:O6IvN3zi# 2018-08-01 11:50:38,602 DEBUG: _check_blocked: background is ignored 2018-08-01 11:50:38,603 DEBUG: sendline: actually sending:

WARNING: command: /u01/app/grid/bin/crsctl check crs

returned unaccepted exit code: 1 If this is expected, pass in check_exit=False or an exit_values array into the send function call.

Interactive, so not retrying. Pause point on exit_code != 0 (1). CTRL-C to quit 2018-08-01 11:50:38,653 DEBUG: _check_blocked: background is ignored 2018-08-01 11:50:38,654 DEBUG: sendline: actually sending: bash

rws3010158:3iR91CPn:O6IvN3zi# rws3010158:3iR91CPn:O6IvN3zi# bash

When exit_code=0,

2018-08-01 12:06:33,149 DEBUG: sendline: actually sending: /u01/app/grid/bin/crsctl check has

/u01/app/grid/bin/crsctl check has /u01/app/grid/bin/crsctl check has CRS-4638: Oracle High Availability Services is online rws3010158:m6LK6ees:Mrlx7zQl# 2018-08-01 12:06:33,290 DEBUG: shutit_pexpect_child.buffer(hex)>>>

<<< 2018-08-01 12:06:33,290 DEBUG: shutit_pexpect_child.before (hex)>>> 2f7530312f6170702f677269642f62696e2f63727363746c20636865636b206861730d0a4352532d343633383a204f7261636c65204869676820417661696c6162696c697479205365727669636573206973206f6e6c696e650d0a <<< 2018-08-01 12:06:33,290 DEBUG: shutit_pexpect_child.after (hex)>>> 727773333031303135383a6d364c4b366565733a4d726c78377a516c2320 <<< 2018-08-01 12:06:33,290 DEBUG: shutit_pexpect_child.buffer>>>

<<< 2018-08-01 12:06:33,290 DEBUG: shutit_pexpect_child.before>>> /u01/app/grid/bin/crsctl check has CRS-4638: Oracle High Availability Services is online

<<< 2018-08-01 12:06:33,290 DEBUG: shutit_pexpect_child.after>>> rws3010158:m6LK6ees:Mrlx7zQl# <<< 2018-08-01 12:06:33,290 DEBUG: _check_blocked: background is ignored 2018-08-01 12:06:33,290 DEBUG: sendline: actually sending: echo EXIT_CODE:$?

2018-08-01 12:06:33,341 DEBUG: Expecting: rws3010158:m6LK6ees:Mrlx7zQl# 2018-08-01 12:06:33,343 DEBUG: _check_blocked: background is ignored 2018-08-01 12:06:33,343 DEBUG: sendline: actually sending: echo EXIT_CODE:$?

2018-08-01 12:06:33,394 DEBUG: Expecting: rws3010158:m6LK6ees:Mrlx7zQl# GI Deinstallation fail FAIL! please try to fix it

===>it doesnot retrun any value, it got exception.

it 's really a bug.

ianmiell commented 6 years ago

Looks ok to me:

import shutit                                                                                                      
s=shutit.create_session('bash',loglevel='info')                                                                    
r=s.send_and_return_status('false')                                                                                
print(r)                                                                                                           
s.send('ls')
ianmiell commented 6 years ago

Which version do you have?