Hello community,

here is the log from the commit of package salt for openSUSE:Factory checked in 
at 2019-07-08 15:01:56
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/salt (Old)
 and      /work/SRC/openSUSE:Factory/.salt.new.4615 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "salt"

Mon Jul  8 15:01:56 2019 rev:89 rq:713188 version:2019.2.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/salt/salt.changes        2019-06-25 
22:17:15.416702351 +0200
+++ /work/SRC/openSUSE:Factory/.salt.new.4615/salt.changes      2019-07-08 
15:01:57.966619933 +0200
@@ -1,0 +2,16 @@
+Wed Jul  3 08:53:13 UTC 2019 - Pablo Suárez Hernández 
<[email protected]>
+
+- Allow passing kwargs to pkg.list_downloaded for Zypper (bsc#1140193)
+
+- Added:
+  * allow-passing-kwargs-to-pkg.list_downloaded-bsc-1140.patch
+
+-------------------------------------------------------------------
+Fri Jun 28 15:26:59 UTC 2019 - Pablo Suárez Hernández 
<[email protected]>
+
+- Do not make "ansiblegate" module to crash on Python3 minions (bsc#1139761)
+
+- Added:
+  * do-not-make-ansiblegate-to-crash-on-python3-minions.patch
+
+-------------------------------------------------------------------

New:
----
  allow-passing-kwargs-to-pkg.list_downloaded-bsc-1140.patch
  do-not-make-ansiblegate-to-crash-on-python3-minions.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ salt.spec ++++++
--- /var/tmp/diff_new_pack.WwRjfD/_old  2019-07-08 15:02:00.246623380 +0200
+++ /var/tmp/diff_new_pack.WwRjfD/_new  2019-07-08 15:02:00.250623386 +0200
@@ -198,6 +198,10 @@
 Patch65:       virt.volume_infos-fix-for-single-vm.patch
 # PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/161
 Patch66:       provide-the-missing-features-required-for-yomi-yet-o.patch
+# PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/53661
+Patch67:       do-not-make-ansiblegate-to-crash-on-python3-minions.patch
+# PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/53693
+Patch68:       allow-passing-kwargs-to-pkg.list_downloaded-bsc-1140.patch
 
 # BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
@@ -734,6 +738,8 @@
 %patch64 -p1
 %patch65 -p1
 %patch66 -p1
+%patch67 -p1
+%patch68 -p1
 
 %build
 %if 0%{?build_py2}

++++++ _lastrevision ++++++
--- /var/tmp/diff_new_pack.WwRjfD/_old  2019-07-08 15:02:00.326623501 +0200
+++ /var/tmp/diff_new_pack.WwRjfD/_new  2019-07-08 15:02:00.330623508 +0200
@@ -1 +1 @@
-9254ebb1efeefa8f3a97e0c301de5f7376f14669
\ No newline at end of file
+0ae10b837a49c10246690aabc972d2cb02bb75de
\ No newline at end of file

++++++ allow-passing-kwargs-to-pkg.list_downloaded-bsc-1140.patch ++++++
>From 9e2139213bc2eeb8afbf10fdff663ebe7ed23887 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
 <[email protected]>
Date: Wed, 3 Jul 2019 09:34:50 +0100
Subject: [PATCH] Allow passing kwargs to pkg.list_downloaded
 (bsc#1140193)

Add unit test for pkg.list_downloaded with kwargs
---
 salt/modules/zypperpkg.py            |  2 +-
 tests/unit/modules/test_zypperpkg.py | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py
index 9d0407e674..6bc7211f59 100644
--- a/salt/modules/zypperpkg.py
+++ b/salt/modules/zypperpkg.py
@@ -2553,7 +2553,7 @@ def download(*packages, **kwargs):
     )
 
 
-def list_downloaded(root=None):
+def list_downloaded(root=None, **kwargs):
     '''
     .. versionadded:: 2017.7.0
 
diff --git a/tests/unit/modules/test_zypperpkg.py 
b/tests/unit/modules/test_zypperpkg.py
index d2ae06a98e..0a3053680f 100644
--- a/tests/unit/modules/test_zypperpkg.py
+++ b/tests/unit/modules/test_zypperpkg.py
@@ -766,6 +766,33 @@ Repository 'DUMMY' not found by its alias, number, or URI.
             self.assertEqual(len(list_patches), 3)
             self.assertDictEqual(list_patches, PATCHES_RET)
 
+    @patch('salt.utils.path.os_walk', MagicMock(return_value=[('test', 'test', 
'test')]))
+    @patch('os.path.getsize', MagicMock(return_value=123456))
+    @patch('os.path.getctime', MagicMock(return_value=1234567890.123456))
+    @patch('fnmatch.filter', 
MagicMock(return_value=['/var/cache/zypper/packages/foo/bar/test_package.rpm']))
+    def test_list_downloaded_with_kwargs(self):
+        '''
+        Test downloaded packages listing.
+
+        :return:
+        '''
+        DOWNLOADED_RET = {
+            'test-package': {
+                '1.0': {
+                    'path': 
'/var/cache/zypper/packages/foo/bar/test_package.rpm',
+                    'size': 123456,
+                    'creation_date_time_t': 1234567890,
+                    'creation_date_time': '2009-02-13T23:31:30',
+                }
+            }
+        }
+
+        with patch.dict(zypper.__salt__, {'lowpkg.bin_pkg_info': 
MagicMock(return_value={'name': 'test-package',
+                                                                               
          'version': '1.0'})}):
+            list_downloaded = zypper.list_downloaded(kw1=True, kw2=False)
+            self.assertEqual(len(list_downloaded), 1)
+            self.assertDictEqual(list_downloaded, DOWNLOADED_RET)
+
     @patch('salt.utils.path.os_walk', MagicMock(return_value=[('test', 'test', 
'test')]))
     @patch('os.path.getsize', MagicMock(return_value=123456))
     @patch('os.path.getctime', MagicMock(return_value=1234567890.123456))
-- 
2.21.0


++++++ do-not-make-ansiblegate-to-crash-on-python3-minions.patch ++++++
>From 189a19b6e8d28cc49e5ad5f2a683e1dfdce66a86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
 <[email protected]>
Date: Fri, 28 Jun 2019 15:17:56 +0100
Subject: [PATCH] Do not make ansiblegate to crash on Python3 minions

Fix pylint issues

Move MockTimedProc implementation to tests.support.mock

Add unit test for ansible caller
---
 salt/modules/ansiblegate.py            | 14 +++++++--
 tests/support/mock.py                  | 31 +++++++++++++++++++
 tests/unit/modules/test_ansiblegate.py | 41 ++++++++++++++++++++++++++
 tests/unit/modules/test_cmdmod.py      | 34 +--------------------
 4 files changed, 84 insertions(+), 36 deletions(-)

diff --git a/salt/modules/ansiblegate.py b/salt/modules/ansiblegate.py
index 771db6d6aa..88e8147573 100644
--- a/salt/modules/ansiblegate.py
+++ b/salt/modules/ansiblegate.py
@@ -147,6 +147,10 @@ class AnsibleModuleCaller(object):
         :param kwargs: keywords to the module
         :return:
         '''
+        if six.PY3:
+            python_exec = 'python3'
+        else:
+            python_exec = 'python'
 
         module = self._resolver.load_module(module)
         if not hasattr(module, 'main'):
@@ -162,9 +166,13 @@ class AnsibleModuleCaller(object):
             ["echo", "{0}".format(js_args)],
             stdout=subprocess.PIPE, timeout=self.timeout)
         proc_out.run()
+        if six.PY3:
+            proc_out_stdout = proc_out.stdout.decode()
+        else:
+            proc_out_stdout = proc_out.stdout
         proc_exc = salt.utils.timed_subprocess.TimedProc(
-            ['python', module.__file__],
-            stdin=proc_out.stdout, stdout=subprocess.PIPE, 
timeout=self.timeout)
+            [python_exec, module.__file__],
+            stdin=proc_out_stdout, stdout=subprocess.PIPE, 
timeout=self.timeout)
         proc_exc.run()
 
         try:
@@ -263,7 +271,7 @@ def help(module=None, *args):
             description = doc.get('description') or ''
             del doc['description']
             ret['Description'] = description
-        ret['Available sections on module 
"{}"'.format(module.__name__.replace('ansible.modules.', ''))] = doc.keys()
+        ret['Available sections on module 
"{}"'.format(module.__name__.replace('ansible.modules.', ''))] = [i for i in 
doc.keys()]
     else:
         for arg in args:
             info = doc.get(arg)
diff --git a/tests/support/mock.py b/tests/support/mock.py
index 38b68bd5c4..4b44c112ee 100644
--- a/tests/support/mock.py
+++ b/tests/support/mock.py
@@ -510,6 +510,37 @@ class MockOpen(object):
                     ret.extend(fh_.writelines_calls)
         return ret
 
+class MockTimedProc(object):
+    '''
+    Class used as a stand-in for salt.utils.timed_subprocess.TimedProc
+    '''
+    class _Process(object):
+        '''
+        Used to provide a dummy "process" attribute
+        '''
+        def __init__(self, returncode=0, pid=12345):
+            self.returncode = returncode
+            self.pid = pid
+
+    def __init__(self, stdout=None, stderr=None, returncode=0, pid=12345):
+        if stdout is not None and not isinstance(stdout, bytes):
+            raise TypeError('Must pass stdout to MockTimedProc as bytes')
+        if stderr is not None and not isinstance(stderr, bytes):
+            raise TypeError('Must pass stderr to MockTimedProc as bytes')
+        self._stdout = stdout
+        self._stderr = stderr
+        self.process = self._Process(returncode=returncode, pid=pid)
+
+    def run(self):
+        pass
+
+    @property
+    def stdout(self):
+        return self._stdout
+
+    @property
+    def stderr(self):
+        return self._stderr
 
 # reimplement mock_open to support multiple filehandles
 mock_open = MockOpen
diff --git a/tests/unit/modules/test_ansiblegate.py 
b/tests/unit/modules/test_ansiblegate.py
index 1fbb083eb7..70b47f8bc2 100644
--- a/tests/unit/modules/test_ansiblegate.py
+++ b/tests/unit/modules/test_ansiblegate.py
@@ -29,6 +29,7 @@ from tests.support.unit import TestCase, skipIf
 from tests.support.mock import (
     patch,
     MagicMock,
+    MockTimedProc,
     NO_MOCK,
     NO_MOCK_REASON
 )
@@ -36,6 +37,7 @@ from tests.support.mock import (
 import salt.modules.ansiblegate as ansible
 import salt.utils.platform
 from salt.exceptions import LoaderError
+from salt.ext import six
 
 
 @skipIf(NO_MOCK, NO_MOCK_REASON)
@@ -137,3 +139,42 @@ description:
         '''
         with patch('salt.modules.ansiblegate.ansible', None):
             assert ansible.__virtual__() == 'ansible'
+
+    def test_ansible_module_call(self):
+        '''
+        Test Ansible module call from ansible gate module
+
+        :return:
+        '''
+
+        class Module(object):
+            '''
+            An ansible module mock.
+            '''
+            __name__ = 'one.two.three'
+            __file__ = 'foofile'
+
+            def main():
+                pass
+
+        ANSIBLE_MODULE_ARGS = '{"ANSIBLE_MODULE_ARGS": ["arg_1", {"kwarg1": 
"foobar"}]}'
+
+        proc = MagicMock(side_effect=[
+            MockTimedProc(
+                stdout=ANSIBLE_MODULE_ARGS.encode(),
+                stderr=None),
+            MockTimedProc(stdout='{"completed": true}'.encode(), stderr=None)
+        ])
+
+        with patch.object(ansible, '_resolver', self.resolver), \
+            patch.object(ansible._resolver, 'load_module', 
MagicMock(return_value=Module())):
+            _ansible_module_caller = 
ansible.AnsibleModuleCaller(ansible._resolver)
+            with patch('salt.utils.timed_subprocess.TimedProc', proc):
+                ret = _ansible_module_caller.call("one.two.three", "arg_1", 
kwarg1="foobar")
+                if six.PY3:
+                    proc.assert_any_call(['echo', '{"ANSIBLE_MODULE_ARGS": 
{"kwarg1": "foobar", "_raw_params": "arg_1"}}'], stdout=-1, timeout=1200)
+                    proc.assert_any_call(['python3', 'foofile'], 
stdin=ANSIBLE_MODULE_ARGS, stdout=-1, timeout=1200)
+                else:
+                    proc.assert_any_call(['echo', '{"ANSIBLE_MODULE_ARGS": 
{"_raw_params": "arg_1", "kwarg1": "foobar"}}'], stdout=-1, timeout=1200)
+                    proc.assert_any_call(['python', 'foofile'], 
stdin=ANSIBLE_MODULE_ARGS, stdout=-1, timeout=1200)
+                assert ret == {"completed": True, "timeout": 1200}
diff --git a/tests/unit/modules/test_cmdmod.py 
b/tests/unit/modules/test_cmdmod.py
index 8da672dd22..a20afaca0f 100644
--- a/tests/unit/modules/test_cmdmod.py
+++ b/tests/unit/modules/test_cmdmod.py
@@ -24,6 +24,7 @@ from tests.support.paths import FILES
 from tests.support.mock import (
     mock_open,
     Mock,
+    MockTimedProc,
     MagicMock,
     NO_MOCK,
     NO_MOCK_REASON,
@@ -36,39 +37,6 @@ MOCK_SHELL_FILE = '# List of acceptable shells\n' \
                   '/bin/bash\n'
 
 
-class MockTimedProc(object):
-    '''
-    Class used as a stand-in for salt.utils.timed_subprocess.TimedProc
-    '''
-    class _Process(object):
-        '''
-        Used to provide a dummy "process" attribute
-        '''
-        def __init__(self, returncode=0, pid=12345):
-            self.returncode = returncode
-            self.pid = pid
-
-    def __init__(self, stdout=None, stderr=None, returncode=0, pid=12345):
-        if stdout is not None and not isinstance(stdout, bytes):
-            raise TypeError('Must pass stdout to MockTimedProc as bytes')
-        if stderr is not None and not isinstance(stderr, bytes):
-            raise TypeError('Must pass stderr to MockTimedProc as bytes')
-        self._stdout = stdout
-        self._stderr = stderr
-        self.process = self._Process(returncode=returncode, pid=pid)
-
-    def run(self):
-        pass
-
-    @property
-    def stdout(self):
-        return self._stdout
-
-    @property
-    def stderr(self):
-        return self._stderr
-
-
 @skipIf(NO_MOCK, NO_MOCK_REASON)
 class CMDMODTestCase(TestCase, LoaderModuleMockMixin):
     '''
-- 
2.21.0



Reply via email to