Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
systemsmanagement:saltstack:products:testing
py27-compat-salt
include-stdout-in-error-message-for-zypperpkg-5...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File include-stdout-in-error-message-for-zypperpkg-565.patch of Package py27-compat-salt
From 8952167790cba52fccb809241c7ccde5e97dcf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yeray=20Guti=C3=A9rrez=20Cedr=C3=A9s?= <yeray.gutierrez@suse.com> Date: Fri, 14 Oct 2022 08:45:42 +0100 Subject: [PATCH] Include stdout in error message for zypperpkg (#565) --- salt/modules/zypperpkg.py | 11 ++++++++++- tests/unit/modules/test_zypperpkg.py | 28 ++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py index 4b1176644e..851e617e02 100644 --- a/salt/modules/zypperpkg.py +++ b/salt/modules/zypperpkg.py @@ -325,7 +325,16 @@ class _Zypper(object): if self._is_error(): _error_msg = list() if not self._is_xml_mode(): - msg = self.__call_result['stderr'] and self.__call_result['stderr'].strip() or "" + msg = ( + self.__call_result["stderr"] + and self.__call_result["stderr"].strip() + or "" + ) + msg += ( + self.__call_result["stdout"] + and self.__call_result["stdout"].strip() + or "" + ) if msg: _error_msg.append(msg) else: diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py index 9cdbeff64a..3a015d300b 100644 --- a/tests/unit/modules/test_zypperpkg.py +++ b/tests/unit/modules/test_zypperpkg.py @@ -170,7 +170,10 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin): self.assertEqual(sniffer.calls[5].get('kwargs', {}).get('env', {}).get('SALT_RUNNING'), "1") # Test exceptions - stdout_xml_snippet = '<?xml version="1.0"?><stream><message type="error">Booya!</message></stream>' + stdout_xml_snippet = ( + '<?xml version="1.0"?><stream><message' + ' type="error">Booya!</message></stream>' + ) sniffer = RunSniffer(stdout=stdout_xml_snippet, retcode=1) with patch.dict( "salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer} @@ -180,10 +183,27 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin): ): zypper.__zypper__.xml.call("crashme") - with self.assertRaisesRegex(CommandExecutionError, "^Zypper command failure: Check Zypper's logs.$"): - zypper.__zypper__.call('crashme again') + output_to_user_stdout = "Output to user to stdout" + output_to_user_stderr = "Output to user to stderr" + sniffer = RunSniffer( + stdout=output_to_user_stdout, stderr=output_to_user_stderr, retcode=1 + ) + with patch.dict( + "salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer} + ), patch.object(zypper.__zypper__, "_is_rpm_lock", return_value=False): + with self.assertRaisesRegex( + CommandExecutionError, + "^Zypper command failure: {}$".format( + output_to_user_stderr + output_to_user_stdout + ), + ): + zypper.__zypper__.call("crashme again") - zypper.__zypper__.noraise.call('stay quiet') + sniffer = RunSniffer(retcode=1) + with patch.dict( + "salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer} + ), patch.object(zypper.__zypper__, "_is_rpm_lock", return_value=False): + zypper.__zypper__.noraise.call("stay quiet") self.assertEqual(zypper.__zypper__.error_msg, "Check Zypper's logs.") def test_list_upgrades_error_handling(self): -- 2.36.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor