diff --git a/core/src/main/python/wlsdeploy/util/exit_code.py b/core/src/main/python/wlsdeploy/util/exit_code.py index 8f82e04b9..579e4ec19 100644 --- a/core/src/main/python/wlsdeploy/util/exit_code.py +++ b/core/src/main/python/wlsdeploy/util/exit_code.py @@ -5,6 +5,7 @@ Standard exit codes for command-line utilities. """ + class ExitCode(object): """ Standard exit codes for command-line utilities. diff --git a/core/src/main/python/wlsdeploy/util/tool_main.py b/core/src/main/python/wlsdeploy/util/tool_main.py index 11c6e1d62..70ee7ce70 100644 --- a/core/src/main/python/wlsdeploy/util/tool_main.py +++ b/core/src/main/python/wlsdeploy/util/tool_main.py @@ -7,8 +7,10 @@ import traceback from java.lang import Exception as JException +from java.util.logging import Level as JLevel from oracle.weblogic.deploy.logging import WLSDeployLoggingConfig +from oracle.weblogic.deploy.logging import WLSDeployLogEndHandler from oracle.weblogic.deploy.util import CLAException from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion from oracle.weblogic.deploy.util import WLSDeployExit @@ -21,6 +23,7 @@ import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.exit_code import ExitCode + def run_tool(main, process_args, args, program_name, class_name, logger): """ The standardized entry point into each tool. @@ -78,6 +81,9 @@ def __exit_tool(model_context, exit_code): version = model_context.get_target_wls_version() if model_context.get_target_wlst_mode() == WlstModes.ONLINE: tool_mode = JWLSTMode.ONLINE + + exit_code = __get_summary_handler_exit_code(exit_code) + WLSDeployExit.exit(WLSDeployContext(program, version, tool_mode), exit_code) @@ -107,3 +113,25 @@ def __handle_unexpected_exception(ex, model_context, class_name, method_name, lo # and of course only while in the except block handling code logger.fine('WLSDPLY-20036', program_name, traceback.format_exception(type(ex), ex, sys.exc_info()[2]), class_name=class_name, method_name=method_name, error=ex) + + +def __get_summary_handler_exit_code(program_exit_code): + """ + Private method for use only within this module. + + Helper method to get the proper tool exit code based on the exit code from the tool and the number + of errors and warnings from the summary log handler. + :param program_exit_code: the exit code from the tool + :return: the exit code to use + """ + if program_exit_code != ExitCode.OK: + return program_exit_code + + exit_code = ExitCode.OK + summary_handler = WLSDeployLogEndHandler.getSummaryHandler() + if summary_handler is not None: + if summary_handler.getMessageCount(JLevel.SEVERE) > 0: + exit_code = ExitCode.ERROR + elif summary_handler.getMessageCount(JLevel.WARNING) > 0: + exit_code = ExitCode.WARNING + return exit_code diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index 5d73301db..2fbe866a0 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -517,8 +517,8 @@ void test17DiscoverDomainWithRequiredArgument(TestInfo testInfo) throws Exceptio + " -archive_file " + discoveredArchive + " -domain_type RestrictedJRF"; CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - verifyResult(result, "discoverDomain.sh completed successfully"); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); // unzip discoveredArchive.zip cmd = "unzip -o " + discoveredArchive + " -d " + getTestOutputPath(testInfo); @@ -561,8 +561,8 @@ void test18DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { " -model_file " + discoveredModelFile; try (PrintWriter out = getTestMethodWriter(testInfo)) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - verifyResult(result, "discoverDomain.sh completed successfully"); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); // verify model file verifyModelFile(discoveredModelFile.toString()); @@ -593,7 +593,8 @@ void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { try (PrintWriter out = getTestMethodWriter(testInfo)) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyResult(result, "discoverDomain.sh completed successfully"); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); // verify model file and variable file verifyModelFile(discoveredModelFile.toString()); @@ -643,8 +644,8 @@ void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { + " -domain_type JRF"; CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - verifyResult(result, "discoverDomain.sh completed successfully"); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); // verify model file verifyModelFile(discoveredModelFile.toString()); @@ -1034,8 +1035,8 @@ void test32PrepareModel(TestInfo testInfo) throws Exception { + " -target " + "wko"; CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - verifyResult(result, "prepareModel.sh completed successfully"); + // ListenPort differences warning + assertEquals(1, result.exitValue(), "Unexpected return code"); // verify model file String tempWkoModel = outputFiles + FS + "simple-topology-targetwko.yaml";