Bug 1139684

Summary: eap cli script does not get correct result code for eap domain server on windows
Product: [JBoss] JBoss Operations Network Reporter: Armine Hovsepyan <ahovsepy>
Component: Plugin -- JBoss EAP 6Assignee: Thomas Segismont <tsegismo>
Status: CLOSED CURRENTRELEASE QA Contact: Armine Hovsepyan <ahovsepy>
Severity: high Docs Contact:
Priority: unspecified    
Version: JON 3.3.0CC: jshaughn, lkrejci, mfoley, pkremens, rhatlapa, tsegismo
Target Milestone: ER04   
Target Release: JON 3.3.0   
Hardware: x86_64   
OS: Windows   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-11 14:03:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1050014    
Attachments:
Description Flags
eap_script_error_code_windows
none
eap_script_error_code_linux
none
cli_error_code_windows none

Description Armine Hovsepyan 2014-09-09 12:40:26 UTC
Created attachment 935657 [details]
eap_script_error_code_windows

Description of problem:
eap cli script does not get correct result code for eap domain server on windows

Version-Release number of selected component (if applicable):
JON 3.3 ER02

How reproducible:
always

Steps to Reproduce:
1. run eap script on domain server on windows that should fail 
2. run (the same) eap script on domain server on linux that should fail 

Actual results:
after step1. no error code in result
after step2. error code 1 in reulst


Expected results:


Additional info:
screen-shots attached

feedback from Radmin H. rhatlapa> I think it is caused by JON that it doesn't provde NOPAUSE env variable resulting in the script not really ending

Comment 1 Armine Hovsepyan 2014-09-09 12:40:50 UTC
Created attachment 935658 [details]
eap_script_error_code_linux

Comment 3 Thomas Segismont 2014-09-11 15:04:25 UTC
Fixed in master

commit 24713c78326a2f1b0d6df7199151266745bcf7f9
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Thu Sep 11 17:02:43 2014 +0200

    Bug 1139684 - eap cli script does not get correct result code for eap domain server on windows
    
    When running the CLI on Windows, make sure no "pause" message is shown after script execution
    Otherwise the CLI process will just keep running so we'll never get the exit code

Comment 4 Thomas Segismont 2014-09-12 13:18:32 UTC
Cherry-picked over to release/jon3.3.x

commit 9c88c59b63b465c117fdb717e64e0c7e666aadb9
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Thu Sep 11 17:02:43 2014 +0200

    Bug 1139684 - eap cli script does not get correct result code for eap domain server on windows
    
    When running the CLI on Windows, make sure no "pause" message is shown after script execution
    Otherwise the CLI process will just keep running so we'll never get the exit code
    
    (cherry picked from commit 24713c78326a2f1b0d6df7199151266745bcf7f9)
    Signed-off-by: Thomas Segismont <tsegismo@redhat.com>

Comment 5 Simeon Pinder 2014-09-17 02:49:28 UTC
Moving to ON_QA as available for test with the following brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=385149

Comment 6 Armine Hovsepyan 2014-09-18 15:13:43 UTC
the issue is still visible

cli command to use:
/subsystem=logging:read-operation-names
/subsystem=datasources:read-operation-names

returns exit code 1 for eap domain in linux and passes for eap domain in windows

re-assigning

Comment 8 Thomas Segismont 2014-09-18 16:44:24 UTC
C:\Users\Administrator\Downloads\jboss-eap-6.2\bin>jboss-cli.bat --connect --file=test.cli
JBAS014808: Child resource '"subsystem" => "datasources"' not found

C:\Users\Administrator\Downloads\jboss-eap-6.2\bin>echo Exit Code is %errorlevel%
Exit Code is 1

C:\Users\Administrator\Downloads\jboss-eap-6.2\bin>cmd /C jboss-cli.bat --connect --file=test.cli
JBAS014808: Child resource '"subsystem" => "datasources"' not found

C:\Users\Administrator\Downloads\jboss-eap-6.2\bin>echo Exit Code is %errorlevel%
Exit Code is 0



Great... the errorlevel is 0 when you call the CLI with "CMD /C", which is mandatatory for JON as you can't call a batch file directly, you need to invoke the "CMD" executable.

Comment 10 Thomas Segismont 2014-09-18 19:16:05 UTC
So the issue seems to be that the jboss-cli.bat script should end with something like:

=======
if ERRORLEVEL 1 exit /B 1
=======

With a modified EAP script on my Windows 2008 machine, I get:

=======
C:\Tools\jboss-eap-6.2\bin>cmd /C jboss-cli.bat --connect --commands=dsq
Unexpected command 'dsq'. Type 'help --commands' for the list of supported commands.

C:\Tools\jboss-eap-6.2\bin>echo %errorlevel%
1
=======


We should open a BZ against EAP6 but I must find a workaround because, with this bug, EAP CLI script execution from JON (as operation or bundle handover) is not reliable on Windows.

Comment 11 Thomas Segismont 2014-09-19 12:08:23 UTC
Fixed in master

commit 62b5a80761270d3b8a16e2899383d890feeca272
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Fri Sep 19 14:07:18 2014 +0200
    
    This is due to "WFLY-3578 jboss-cli.bat always exits with return code 0 even after a cli failure"
    https://issues.jboss.org/browse/WFLY-3578
    
    Added jboss-cli-wrapper.bat
    Calling "cmd /c jboss-cli.bat" will always return 0 even if an error occurs in the CLI
    Calling it through the wrapper solves the issue
    
    Side work:
    * fix standalone and domain startup: start script prefix, if set, was not added
    * when an error occurs, execute command and execute script operations now copy process output into the operation result instead of the error message
    * some code cleanup (avoid possible NPE)

Comment 12 Jay Shaughnessy 2014-09-24 19:56:25 UTC
release/jon3.3.x commit 96481d79219356f4083656d0c496fc42081533ae
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Fri Sep 19 14:07:18 2014 +0200

    (cherry picked from commit 62b5a80761270d3b8a16e2899383d890feeca272)
    Signed-off-by: Jay Shaughnessy <jshaughn@redhat.com>

Comment 13 Simeon Pinder 2014-10-01 21:33:37 UTC
Moving to ON_QA as available for test with build:
https://brewweb.devel.redhat.com/buildinfo?buildID=388959

Comment 14 Armine Hovsepyan 2014-10-06 14:29:04 UTC
Created attachment 944273 [details]
cli_error_code_windows

Comment 15 Armine Hovsepyan 2014-10-06 14:31:30 UTC
verified in JON 3.3 ER04