From 55965ce505d9439459cfef188ab969a902a3a537 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Thu, 9 Feb 2017 11:33:21 -0800 Subject: [PATCH 001/370] Autodetect IPv6 connectivity from minion to master --- doc/ref/configuration/minion.rst | 5 +++-- salt/config/__init__.py | 2 +- salt/transport/zeromq.py | 2 +- salt/utils/__init__.py | 15 ++++++++++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst index cca12d2271..b3e562a0fc 100644 --- a/doc/ref/configuration/minion.rst +++ b/doc/ref/configuration/minion.rst @@ -81,9 +81,10 @@ The option can can also be set to a list of masters, enabling ``ipv6`` -------- -Default: ``False`` +Default: ``None`` -Whether the master should be connected over IPv6. +Whether the master should be connected over IPv6. By default salt minion +will try to automatically detect IPv6 connectivity to master. .. code-block:: yaml diff --git a/salt/config/__init__.py b/salt/config/__init__.py index aa5d7c7f07..9bf79b63db 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -990,7 +990,7 @@ DEFAULT_MINION_OPTS = { 'mine_interval': 60, 'ipc_mode': _DFLT_IPC_MODE, 'ipc_write_buffer': _DFLT_IPC_WBUFFER, - 'ipv6': False, + 'ipv6': None, 'file_buffer_size': 262144, 'tcp_pub_port': 4510, 'tcp_pull_port': 4511, diff --git a/salt/transport/zeromq.py b/salt/transport/zeromq.py index 86ef1f96c3..20c7ba88cc 100644 --- a/salt/transport/zeromq.py +++ b/salt/transport/zeromq.py @@ -346,7 +346,7 @@ class AsyncZeroMQPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.t zmq.RECONNECT_IVL_MAX, self.opts['recon_max'] ) - if self.opts['ipv6'] is True and hasattr(zmq, 'IPV4ONLY'): + if (self.opts['ipv6'] is True or ':' in self.opts['master_ip']) and hasattr(zmq, 'IPV4ONLY'): # IPv6 sockets work for both IPv6 and IPv4 addresses self._socket.setsockopt(zmq.IPV4ONLY, 0) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 77100041a8..b88728aa36 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -716,12 +716,25 @@ def ip_bracket(addr): return addr -def dns_check(addr, safe=False, ipv6=False): +def dns_check(addr, safe=False, ipv6=None): ''' Return the ip resolved by dns, but do not exit on failure, only raise an exception. Obeys system preference for IPv4/6 address resolution. ''' error = False + + # Detect IPv6 support if it is not forced by trying to connect + # to the give address over IPv6. + if ipv6 is None: + s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) + try: + s.connect((addr, 0)) + s.close() + + ipv6 = True + except: + ipv6 = False + try: # issue #21397: force glibc to re-read resolv.conf if HAS_RESINIT: From 29f376676dce911e4f8bddd43cd4650ed5790d5b Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Thu, 9 Feb 2017 11:58:08 -0800 Subject: [PATCH 002/370] Rewrite dns_check to try to connect to address --- salt/minion.py | 4 ++-- salt/utils/__init__.py | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 7faa4f9fce..174783ad22 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -149,7 +149,7 @@ def resolve_dns(opts, fallback=True): if opts['master'] == '': raise SaltSystemExit ret['master_ip'] = \ - salt.utils.dns_check(opts['master'], True, opts['ipv6']) + salt.utils.dns_check(opts['master'], opts['master_port'], True, opts['ipv6']) except SaltClientError: if opts['retry_dns']: while True: @@ -163,7 +163,7 @@ def resolve_dns(opts, fallback=True): time.sleep(opts['retry_dns']) try: ret['master_ip'] = salt.utils.dns_check( - opts['master'], True, opts['ipv6'] + opts['master'], opts['master_port'], True, opts['ipv6'] ) break except SaltClientError: diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index b88728aa36..32dfe11f77 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -716,25 +716,13 @@ def ip_bracket(addr): return addr -def dns_check(addr, safe=False, ipv6=None): +def dns_check(addr, port, safe=False, ipv6=None): ''' Return the ip resolved by dns, but do not exit on failure, only raise an exception. Obeys system preference for IPv4/6 address resolution. + Tries to connect to the address before considering it useful. ''' error = False - - # Detect IPv6 support if it is not forced by trying to connect - # to the give address over IPv6. - if ipv6 is None: - s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) - try: - s.connect((addr, 0)) - s.close() - - ipv6 = True - except: - ipv6 = False - try: # issue #21397: force glibc to re-read resolv.conf if HAS_RESINIT: @@ -747,9 +735,22 @@ def dns_check(addr, safe=False, ipv6=None): else: addr = False for h in hostnames: - if h[0] == socket.AF_INET or (h[0] == socket.AF_INET6 and ipv6): - addr = ip_bracket(h[4][0]) + if h[0] == socket.AF_INET and ipv6 is True: + continue + if h[0] == socket.AF_INET6 and ipv6 is False: + continue + + candidate_addr = ip_bracket(h[4][0]) + + s = socket.socket(h[0], socket.SOCK_DGRAM) + try: + s.connect((candidate_addr.strip('[]'), port)) + s.close() + + addr = candidate_addr break + except: + pass if not addr: error = True except TypeError: From c494839c658c64701a751379f425705d65a440ce Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Thu, 9 Feb 2017 13:26:26 -0800 Subject: [PATCH 003/370] Avoid bare exceptions in dns_check --- salt/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 32dfe11f77..82ef7a2354 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -749,7 +749,7 @@ def dns_check(addr, port, safe=False, ipv6=None): addr = candidate_addr break - except: + except Exception: pass if not addr: error = True From 9a34fbeba9aa526079a80a14eda29aa790d0dd6a Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Thu, 9 Feb 2017 17:09:40 -0800 Subject: [PATCH 004/370] Actually connect to master instead of checking route availability --- salt/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 82ef7a2354..4ab8c131a2 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -742,7 +742,7 @@ def dns_check(addr, port, safe=False, ipv6=None): candidate_addr = ip_bracket(h[4][0]) - s = socket.socket(h[0], socket.SOCK_DGRAM) + s = socket.socket(h[0], socket.SOCK_STREAM) try: s.connect((candidate_addr.strip('[]'), port)) s.close() From af9578631ed16cb8ff1a7b15ce2a3cd6f2f52a90 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Thu, 9 Feb 2017 17:12:04 -0800 Subject: [PATCH 005/370] Properly log address that failed to resolve or pass connection check --- salt/minion.py | 4 ++-- salt/utils/__init__.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 174783ad22..e8b489427d 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -154,8 +154,8 @@ def resolve_dns(opts, fallback=True): if opts['retry_dns']: while True: import salt.log - msg = ('Master hostname: \'{0}\' not found. Retrying in {1} ' - 'seconds').format(opts['master'], opts['retry_dns']) + msg = ('Master hostname: \'{0}\' not found or not responsive. ' + 'Retrying in {1} seconds').format(opts['master'], opts['retry_dns']) if salt.log.setup.is_console_configured(): log.error(msg) else: diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 4ab8c131a2..5d713eca24 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -733,7 +733,7 @@ def dns_check(addr, port, safe=False, ipv6=None): if not hostnames: error = True else: - addr = False + resolved = False for h in hostnames: if h[0] == socket.AF_INET and ipv6 is True: continue @@ -747,11 +747,11 @@ def dns_check(addr, port, safe=False, ipv6=None): s.connect((candidate_addr.strip('[]'), port)) s.close() - addr = candidate_addr + resolved = candidate_addr break except Exception: pass - if not addr: + if not resolved: error = True except TypeError: err = ('Attempt to resolve address \'{0}\' failed. Invalid or unresolveable address').format(addr) @@ -760,7 +760,7 @@ def dns_check(addr, port, safe=False, ipv6=None): error = True if error: - err = ('DNS lookup of \'{0}\' failed.').format(addr) + err = ('DNS lookup or connection check of \'{0}\' failed.').format(addr) if safe: if salt.log.is_console_configured(): # If logging is not configured it also means that either @@ -769,7 +769,7 @@ def dns_check(addr, port, safe=False, ipv6=None): log.error(err) raise SaltClientError() raise SaltSystemExit(code=42, msg=err) - return addr + return resolved def required_module_list(docstring=None): From e8a2cc0488fcb174778343c96e35eea51bfa9e97 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Tue, 14 Feb 2017 10:57:53 -0800 Subject: [PATCH 006/370] Do no try to connect to salt master in syndic config test --- salt/minion.py | 6 +++--- salt/utils/__init__.py | 7 ++++++- tests/unit/config/config_test.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index e8b489427d..7dba19c881 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -132,7 +132,7 @@ log = logging.getLogger(__name__) # 6. Handle publications -def resolve_dns(opts, fallback=True): +def resolve_dns(opts, connect=True, fallback=True): ''' Resolves the master_ip and master_uri options ''' @@ -149,7 +149,7 @@ def resolve_dns(opts, fallback=True): if opts['master'] == '': raise SaltSystemExit ret['master_ip'] = \ - salt.utils.dns_check(opts['master'], opts['master_port'], True, opts['ipv6']) + salt.utils.dns_check(opts['master'], opts['master_port'], connect, True, opts['ipv6']) except SaltClientError: if opts['retry_dns']: while True: @@ -163,7 +163,7 @@ def resolve_dns(opts, fallback=True): time.sleep(opts['retry_dns']) try: ret['master_ip'] = salt.utils.dns_check( - opts['master'], opts['master_port'], True, opts['ipv6'] + opts['master'], opts['master_port'], connect, True, opts['ipv6'] ) break except SaltClientError: diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 5d713eca24..da7694f4f0 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -716,7 +716,7 @@ def ip_bracket(addr): return addr -def dns_check(addr, port, safe=False, ipv6=None): +def dns_check(addr, port, connect=True, safe=False, ipv6=None): ''' Return the ip resolved by dns, but do not exit on failure, only raise an exception. Obeys system preference for IPv4/6 address resolution. @@ -739,9 +739,14 @@ def dns_check(addr, port, safe=False, ipv6=None): continue if h[0] == socket.AF_INET6 and ipv6 is False: continue + if h[0] == socket.AF_INET6 and connect is False and ipv6 is None: + continue candidate_addr = ip_bracket(h[4][0]) + if not connect: + resolved = candidate_addr + s = socket.socket(h[0], socket.SOCK_STREAM) try: s.connect((candidate_addr.strip('[]'), port)) diff --git a/tests/unit/config/config_test.py b/tests/unit/config/config_test.py index 89290b5ec0..58d3516094 100644 --- a/tests/unit/config/config_test.py +++ b/tests/unit/config/config_test.py @@ -364,7 +364,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): syndic_opts = sconfig.syndic_config( syndic_conf_path, minion_conf_path ) - syndic_opts.update(salt.minion.resolve_dns(syndic_opts)) + syndic_opts.update(salt.minion.resolve_dns(syndic_opts, connect=False)) root_dir = syndic_opts['root_dir'] # id & pki dir are shared & so configured on the minion side self.assertEqual(syndic_opts['id'], 'minion') From bd1fe03ce72213e7a36a61d2ba5d433c6d488339 Mon Sep 17 00:00:00 2001 From: rallytime Date: Tue, 14 Feb 2017 13:33:04 -0700 Subject: [PATCH 007/370] Update :depends: docs for boto states and modules Some boto states and modules declare that they depend on the boto3 lib. That's all good. But some of these states and modules _also_ depend on the regular boto lib. This updates the docs to reflect this. Fixes #39304 --- salt/modules/boto_cloudtrail.py | 8 ++++++-- salt/modules/boto_iot.py | 8 ++++++-- salt/modules/boto_lambda.py | 8 ++++++-- salt/modules/boto_s3_bucket.py | 8 ++++++-- salt/states/boto_cloudtrail.py | 6 +++++- salt/states/boto_iot.py | 6 +++++- salt/states/boto_lambda.py | 6 +++++- salt/states/boto_s3_bucket.py | 6 +++++- 8 files changed, 44 insertions(+), 12 deletions(-) diff --git a/salt/modules/boto_cloudtrail.py b/salt/modules/boto_cloudtrail.py index ea76a0fcbc..25a251f8ac 100644 --- a/salt/modules/boto_cloudtrail.py +++ b/salt/modules/boto_cloudtrail.py @@ -4,6 +4,12 @@ Connection module for Amazon CloudTrail .. versionadded:: 2016.3.0 +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. + :configuration: This module accepts explicit Lambda credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no @@ -39,8 +45,6 @@ Connection module for Amazon CloudTrail key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 -:depends: boto3 - ''' # keep lint from choking on _get_conn and _cache_id #pylint: disable=E0602 diff --git a/salt/modules/boto_iot.py b/salt/modules/boto_iot.py index a72eb9ca3b..faa3a87c63 100644 --- a/salt/modules/boto_iot.py +++ b/salt/modules/boto_iot.py @@ -4,6 +4,12 @@ Connection module for Amazon IoT .. versionadded:: 2016.3.0 +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. + :configuration: This module accepts explicit Lambda credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no @@ -39,8 +45,6 @@ Connection module for Amazon IoT key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 -:depends: boto3 - ''' # keep lint from choking on _get_conn and _cache_id #pylint: disable=E0602 diff --git a/salt/modules/boto_lambda.py b/salt/modules/boto_lambda.py index 47832ede28..549b972854 100644 --- a/salt/modules/boto_lambda.py +++ b/salt/modules/boto_lambda.py @@ -4,6 +4,12 @@ Connection module for Amazon Lambda .. versionadded:: 2016.3.0 +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. + :configuration: This module accepts explicit Lambda credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no @@ -69,8 +75,6 @@ Connection module for Amazon Lambda error: message: error message -:depends: boto3 - ''' # keep lint from choking on _get_conn and _cache_id #pylint: disable=E0602 diff --git a/salt/modules/boto_s3_bucket.py b/salt/modules/boto_s3_bucket.py index 3226256fab..1777d02e8c 100644 --- a/salt/modules/boto_s3_bucket.py +++ b/salt/modules/boto_s3_bucket.py @@ -4,6 +4,12 @@ Connection module for Amazon S3 Buckets .. versionadded:: 2016.3.0 +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. + :configuration: This module accepts explicit Lambda credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no @@ -39,8 +45,6 @@ Connection module for Amazon S3 Buckets key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 -:depends: boto3 - ''' # keep lint from choking on _get_conn and _cache_id #pylint: disable=E0602 diff --git a/salt/states/boto_cloudtrail.py b/salt/states/boto_cloudtrail.py index 52b79654f4..1da56b4838 100644 --- a/salt/states/boto_cloudtrail.py +++ b/salt/states/boto_cloudtrail.py @@ -8,7 +8,11 @@ Manage CloudTrail Objects Create and destroy CloudTrail objects. Be aware that this interacts with Amazon's services, and so may incur charges. -This module uses ``boto3``, which can be installed via package, or pip. +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. This module accepts explicit vpc credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic diff --git a/salt/states/boto_iot.py b/salt/states/boto_iot.py index ca5f8dcf09..adbf629ebc 100644 --- a/salt/states/boto_iot.py +++ b/salt/states/boto_iot.py @@ -8,7 +8,11 @@ Manage IoT Objects Create and destroy IoT objects. Be aware that this interacts with Amazon's services, and so may incur charges. -This module uses ``boto3``, which can be installed via package, or pip. +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. This module accepts explicit vpc credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic diff --git a/salt/states/boto_lambda.py b/salt/states/boto_lambda.py index 26f369122f..ca79f50099 100644 --- a/salt/states/boto_lambda.py +++ b/salt/states/boto_lambda.py @@ -8,7 +8,11 @@ Manage Lambda Functions Create and destroy Lambda Functions. Be aware that this interacts with Amazon's services, and so may incur charges. -This module uses ``boto3``, which can be installed via package, or pip. +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. This module accepts explicit vpc credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic diff --git a/salt/states/boto_s3_bucket.py b/salt/states/boto_s3_bucket.py index 21e8d68d2f..b6e52b241d 100644 --- a/salt/states/boto_s3_bucket.py +++ b/salt/states/boto_s3_bucket.py @@ -8,7 +8,11 @@ Manage S3 Buckets Create and destroy S3 buckets. Be aware that this interacts with Amazon's services, and so may incur charges. -This module uses ``boto3``, which can be installed via package, or pip. +:depends: + - boto + - boto3 + +The dependencies listed above can be installed via package or pip. This module accepts explicit vpc credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic From e13febe58d1f14473d2893f20d43a1707bf94851 Mon Sep 17 00:00:00 2001 From: rallytime Date: Tue, 14 Feb 2017 17:18:35 -0700 Subject: [PATCH 008/370] Update external_cache docs with other configuration options There are more places than just the minion config file to define external job cache configuration settings for minions. This change updates the docs to include some of those other places and the order in which they're evaluated if the settings are defined in more than one place. Fixes #38762 --- doc/topics/jobs/external_cache.rst | 31 +++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/doc/topics/jobs/external_cache.rst b/doc/topics/jobs/external_cache.rst index ff5c6fe750..ef83e94df0 100644 --- a/doc/topics/jobs/external_cache.rst +++ b/doc/topics/jobs/external_cache.rst @@ -89,12 +89,33 @@ A simpler returner, such as Slack or HipChat, requires: Step 2: Configure the Returner ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -After you understand the configuration and have the external system ready, add -the returner configuration settings to the Salt Minion configuration file for -the External Job Cache, or to the Salt Master configuration file for the Master -Job Cache. +After you understand the configuration and have the external system ready, the +configuration requirements must be declared. -For example, MySQL requires: +External Job Cache +"""""""""""""""""" + +The returner configuration settings can be declared in the Salt Minion +configuration file, the Minion's pillar data, or the Minion's grains. + +If ``external_job_cache`` configuration settings are specified in more than +one place, the options are retrieved in the following order. The first +configuration location that is found is the one that will be used. + +- Minion configuration file +- Minion's grains +- Minion's pillar data + +Master Job Cache +"""""""""""""""" + +The returner configuration settings for the Master Job Cache should be +declared in the Salt Master's configuration file. + +Configuration File Examples +""""""""""""""""""""""""""" + +MySQL requires: .. code-block:: yaml From 7e1803b617cd9d594a0df3f07ae55fac14b91693 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 15 Feb 2017 11:10:39 -0600 Subject: [PATCH 009/370] Update docs on upstream EPEL7 pygit2/libgit2 issues (#39421) pygit2 was rebuilt, but libgit2 still needs a rebuild. I opened an upstream bug report this morning, this updates the docs to reflect the current status of this upstream issue. --- doc/topics/tutorials/gitfs.rst | 55 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/doc/topics/tutorials/gitfs.rst b/doc/topics/tutorials/gitfs.rst index 6d74ab3040..2e411956bb 100644 --- a/doc/topics/tutorials/gitfs.rst +++ b/doc/topics/tutorials/gitfs.rst @@ -100,11 +100,13 @@ releases pygit2_ 0.20.3 and libgit2_ 0.20.0 is the recommended combination. RedHat Pygit2 Issues ~~~~~~~~~~~~~~~~~~~~ -Around the time of the release of RedHat 7.3, RedHat effectively broke pygit2_ -by upgrading python-cffi_ to a release incompatible with the version of pygit2_ -available in their repositories. This prevents Python from importing the -pygit2_ module at all, leading to a master that refuses to start, and leaving -the following errors in the master log file: +The release of RedHat/CentOS 7.3 upgraded both ``python-cffi`` and +``http-parser``, both of which are dependencies for pygit2_/libgit2_. Both +pygit2_ and libgit2_ (which are from the EPEL repository and not managed +directly by RedHat) need to be rebuilt against these updated dependencies. + +The below errors will show up in the master log if an incompatible +``python-pygit2`` package is installed: .. code-block:: text @@ -113,34 +115,37 @@ the following errors in the master log file: 2017-02-10 09:07:34,907 [salt.utils.gitfs ][CRITICAL][11211] No suitable gitfs provider module is installed. 2017-02-10 09:07:34,912 [salt.master ][CRITICAL][11211] Master failed pre flight checks, exiting -This issue has been reported on the `RedHat Bugzilla`_. In the meantime, you -can work around it by downgrading python-cffi_. To do this, go to `this page`_ -and download the appropriate python-cffi_ 0.8.6 RPM. Then copy that RPM to the -master and downgrade using the ``rpm`` command. For example: +The below errors will show up in the master log if an incompatible ``libgit2`` +package is installed: + +.. code-block:: text + + 2017-02-15 18:04:45,211 [salt.utils.gitfs ][ERROR ][6211] Error occurred fetching gitfs remote 'https://foo.com/bar.git': No Content-Type header in response + +As of 15 February 2017, ``python-pygit2`` has been rebuilt and is in the stable +EPEL repository. However, ``libgit2`` remains broken (a `bug report`_ has been +filed to get it rebuilt). + +In the meantime, you can work around this by downgrading ``http-parser``. To do +this, go to `this page`_ and download the appropriate ``http-parser`` RPM for +the OS architecture you are using (x86_64, etc.). Then downgrade using the +``rpm`` command. For example: .. code-block:: bash - # rpm -Uvh --oldpackage python-cffi-0.8.6-1.el7.x86_64.rpm + [root@784e8a8c5028 /]# curl --silent -O https://kojipkgs.fedoraproject.org//packages/http-parser/2.0/5.20121128gitcd01361.el7/x86_64/http-parser-2.0-5.20121128gitcd01361.el7.x86_64.rpm + [root@784e8a8c5028 /]# rpm -Uvh --oldpackage http-parser-2.0-5.20121128gitcd01361.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... - 1:python-cffi-0.8.6-1.el7 ################################# [ 50%] + 1:http-parser-2.0-5.20121128gitcd01################################# [ 50%] Cleaning up / removing... - 2:python-cffi-1.6.0-5.el7 ################################# [100%] - # rpm -q python-cffi - python-cffi-0.8.6-1.el7.x86_64 + 2:http-parser-2.7.1-3.el7 ################################# [100%] -To confirm that pygit2_ is now "fixed", you can test trying to import it like so: +A restart of the salt-master daemon may be required to allow http(s) +repositories to continue to be fetched. -.. code-block:: bash - - # python -c 'import pygit2' - # - -If the command produces no output, then your master should work when you start -it again. - -.. _`this page`: https://koji.fedoraproject.org/koji/buildinfo?buildID=569520 -.. _`RedHat Bugzilla`: https://bugzilla.redhat.com/show_bug.cgi?id=1400668 +.. _`this page`: https://koji.fedoraproject.org/koji/buildinfo?buildID=703753 +.. _`bug report`: https://bugzilla.redhat.com/show_bug.cgi?id=1422583 GitPython From a7d5118262716daae886d80d6a364557aab10cc4 Mon Sep 17 00:00:00 2001 From: Morgan Willcock Date: Wed, 15 Feb 2017 17:58:59 +0000 Subject: [PATCH 010/370] Return failure when package path does not exist --- salt/states/win_dism.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/salt/states/win_dism.py b/salt/states/win_dism.py index fa3ea59134..4b73d4e711 100644 --- a/salt/states/win_dism.py +++ b/salt/states/win_dism.py @@ -17,6 +17,7 @@ from __future__ import absolute_import # Import python libs import logging +import os # Import salt libs import salt.utils @@ -319,6 +320,15 @@ def package_installed(name, 'comment': '', 'changes': {}} + # Fail if using a non-existent package path + if '~' not in name and not os.path.exists(name): + if __opts__['test']: + ret['result'] = None + else: + ret['result'] = False + ret['comment'] = 'Package path {0} does not exist'.format(name) + return ret + old = __salt__['dism.installed_packages']() # Get package info so we can see if it's already installed @@ -387,6 +397,15 @@ def package_removed(name, image=None, restart=False): 'comment': '', 'changes': {}} + # Fail if using a non-existent package path + if '~' not in name and not os.path.exists(name): + if __opts__['test']: + ret['result'] = None + else: + ret['result'] = False + ret['comment'] = 'Package path {0} does not exist'.format(name) + return ret + old = __salt__['dism.installed_packages']() # Get package info so we can see if it's already removed From 0df6b922e740eca3b205edcc430bad12bd0e4dfc Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Wed, 15 Feb 2017 12:34:04 -0800 Subject: [PATCH 011/370] Narrow down connection exception to socket.error --- salt/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index da7694f4f0..cc1af2893e 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -754,7 +754,7 @@ def dns_check(addr, port, connect=True, safe=False, ipv6=None): resolved = candidate_addr break - except Exception: + except socket.error: pass if not resolved: error = True From 709c197f84dc722ad6d17c15a87b33a61de7acb8 Mon Sep 17 00:00:00 2001 From: David Boucha Date: Wed, 15 Feb 2017 13:42:18 -0700 Subject: [PATCH 012/370] allow sync_grains to be disabled on grains.setval --- salt/modules/grains.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/modules/grains.py b/salt/modules/grains.py index e87f818ed6..bd9069e396 100644 --- a/salt/modules/grains.py +++ b/salt/modules/grains.py @@ -192,7 +192,7 @@ def item(*args, **kwargs): return ret -def setvals(grains, destructive=False): +def setvals(grains, destructive=False, refresh=True): ''' Set new grains values in the grains config file @@ -275,12 +275,12 @@ def setvals(grains, destructive=False): log.error(msg.format(fn_)) if not __opts__.get('local', False): # Sync the grains - __salt__['saltutil.sync_grains']() + __salt__['saltutil.sync_grains'](refresh=refresh) # Return the grains we just set to confirm everything was OK return new_grains -def setval(key, val, destructive=False): +def setval(key, val, destructive=False, refresh=True): ''' Set a grains value in the grains config file @@ -301,7 +301,7 @@ def setval(key, val, destructive=False): salt '*' grains.setval key val salt '*' grains.setval key "{'sub-key': 'val', 'sub-key2': 'val2'}" ''' - return setvals({key: val}, destructive) + return setvals({key: val}, destructive, refresh) def append(key, val, convert=False, delimiter=DEFAULT_TARGET_DELIM): From 391bbecd9056bad267d1490dc772c8b011e3e159 Mon Sep 17 00:00:00 2001 From: David Boucha Date: Wed, 15 Feb 2017 13:49:24 -0700 Subject: [PATCH 013/370] add docs --- salt/modules/grains.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/salt/modules/grains.py b/salt/modules/grains.py index bd9069e396..2082dc03d0 100644 --- a/salt/modules/grains.py +++ b/salt/modules/grains.py @@ -200,6 +200,10 @@ def setvals(grains, destructive=False, refresh=True): If an operation results in a key being removed, delete the key, too. Defaults to False. + refresh + Refresh minion grains using saltutil.sync_grains. + Defaults to True. + CLI Example: .. code-block:: bash @@ -294,6 +298,10 @@ def setval(key, val, destructive=False, refresh=True): If an operation results in a key being removed, delete the key, too. Defaults to False. + refresh + Refresh minion grains using saltutil.sync_grains. + Defaults to True. + CLI Example: .. code-block:: bash From 2761a1b244034b61cceff3b8015d15df2eb2a024 Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Wed, 15 Feb 2017 12:35:27 -0800 Subject: [PATCH 014/370] Move new kwargs to the end of argument list --- salt/minion.py | 6 +++--- salt/utils/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 7dba19c881..9fd080956e 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -132,7 +132,7 @@ log = logging.getLogger(__name__) # 6. Handle publications -def resolve_dns(opts, connect=True, fallback=True): +def resolve_dns(opts, fallback=True, connect=True): ''' Resolves the master_ip and master_uri options ''' @@ -149,7 +149,7 @@ def resolve_dns(opts, connect=True, fallback=True): if opts['master'] == '': raise SaltSystemExit ret['master_ip'] = \ - salt.utils.dns_check(opts['master'], opts['master_port'], connect, True, opts['ipv6']) + salt.utils.dns_check(opts['master'], opts['master_port'], True, opts['ipv6'], connect) except SaltClientError: if opts['retry_dns']: while True: @@ -163,7 +163,7 @@ def resolve_dns(opts, connect=True, fallback=True): time.sleep(opts['retry_dns']) try: ret['master_ip'] = salt.utils.dns_check( - opts['master'], opts['master_port'], connect, True, opts['ipv6'] + opts['master'], opts['master_port'], True, opts['ipv6'], connect ) break except SaltClientError: diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index cc1af2893e..8f9d8ccf73 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -716,7 +716,7 @@ def ip_bracket(addr): return addr -def dns_check(addr, port, connect=True, safe=False, ipv6=None): +def dns_check(addr, port, safe=False, ipv6=None, connect=True): ''' Return the ip resolved by dns, but do not exit on failure, only raise an exception. Obeys system preference for IPv4/6 address resolution. From e652a455923caf9a1b786e3151bebf1d1437a220 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Thu, 16 Feb 2017 12:26:49 -0700 Subject: [PATCH 015/370] Fix mocks in win_disim tests --- tests/unit/states/win_dism_test.py | 73 +++++++++++++++++------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/tests/unit/states/win_dism_test.py b/tests/unit/states/win_dism_test.py index 9d2811ff10..367627630b 100644 --- a/tests/unit/states/win_dism_test.py +++ b/tests/unit/states/win_dism_test.py @@ -95,11 +95,12 @@ class WinDismTestCase(TestCase): dism.__salt__, {'dism.installed_capabilities': mock_installed, 'dism.add_capability': mock_add}): - out = dism.capability_installed('Capa2', 'somewhere', True) + with patch.dict(dism.__opts__, {'test': False}): + out = dism.capability_installed('Capa2', 'somewhere', True) - mock_installed.assert_called_once_with() - assert not mock_add.called - self.assertEqual(out, expected) + mock_installed.assert_called_once_with() + assert not mock_add.called + self.assertEqual(out, expected) def test_capability_removed(self): ''' @@ -360,13 +361,14 @@ class WinDismTestCase(TestCase): 'dism.add_package': mock_add, 'dism.package_info': mock_info}): with patch.dict(dism.__opts__, {'test': False}): + with patch('os.path.exists'): - out = dism.package_installed('Pack2') + out = dism.package_installed('Pack2') - mock_installed.assert_called_with() - mock_add.assert_called_once_with( - 'Pack2', False, False, None, False) - self.assertEqual(out, expected) + mock_installed.assert_called_with() + mock_add.assert_called_once_with( + 'Pack2', False, False, None, False) + self.assertEqual(out, expected) def test_package_installed_failure(self): ''' @@ -390,13 +392,14 @@ class WinDismTestCase(TestCase): 'dism.add_package': mock_add, 'dism.package_info': mock_info}): with patch.dict(dism.__opts__, {'test': False}): + with patch('os.path.exists'): - out = dism.package_installed('Pack2') + out = dism.package_installed('Pack2') - mock_installed.assert_called_with() - mock_add.assert_called_once_with( - 'Pack2', False, False, None, False) - self.assertEqual(out, expected) + mock_installed.assert_called_with() + mock_add.assert_called_once_with( + 'Pack2', False, False, None, False) + self.assertEqual(out, expected) def test_package_installed_installed(self): ''' @@ -418,12 +421,14 @@ class WinDismTestCase(TestCase): dism.__salt__, {'dism.installed_packages': mock_installed, 'dism.add_package': mock_add, 'dism.package_info': mock_info}): + with patch.dict(dism.__opts__, {'test': False}): + with patch('os.path.exists'): - out = dism.package_installed('Pack2') + out = dism.package_installed('Pack2') - mock_installed.assert_called_once_with() - assert not mock_add.called - self.assertEqual(out, expected) + mock_installed.assert_called_once_with() + assert not mock_add.called + self.assertEqual(out, expected) def test_package_removed(self): ''' @@ -448,13 +453,14 @@ class WinDismTestCase(TestCase): 'dism.remove_package': mock_remove, 'dism.package_info': mock_info}): with patch.dict(dism.__opts__, {'test': False}): + with patch('os.path.exists'): - out = dism.package_removed('Pack2') + out = dism.package_removed('Pack2') - mock_removed.assert_called_with() - mock_remove.assert_called_once_with( - 'Pack2', None, False) - self.assertEqual(out, expected) + mock_removed.assert_called_with() + mock_remove.assert_called_once_with( + 'Pack2', None, False) + self.assertEqual(out, expected) def test_package_removed_failure(self): ''' @@ -478,13 +484,14 @@ class WinDismTestCase(TestCase): 'dism.remove_package': mock_remove, 'dism.package_info': mock_info}): with patch.dict(dism.__opts__, {'test': False}): + with patch('os.path.exists'): - out = dism.package_removed('Pack2') + out = dism.package_removed('Pack2') - mock_removed.assert_called_with() - mock_remove.assert_called_once_with( - 'Pack2', None, False) - self.assertEqual(out, expected) + mock_removed.assert_called_with() + mock_remove.assert_called_once_with( + 'Pack2', None, False) + self.assertEqual(out, expected) def test_package_removed_removed(self): ''' @@ -507,11 +514,13 @@ class WinDismTestCase(TestCase): 'dism.remove_package': mock_remove, 'dism.package_info': mock_info}): - out = dism.package_removed('Pack2') + with patch.dict(dism.__opts__, {'test': False}): + with patch('os.path.exists'): + out = dism.package_removed('Pack2') - mock_removed.assert_called_once_with() - assert not mock_remove.called - self.assertEqual(out, expected) + mock_removed.assert_called_once_with() + assert not mock_remove.called + self.assertEqual(out, expected) if __name__ == '__main__': From f829d6f9fc4ffa97b2c175a4e915a174631eba72 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 16 Feb 2017 15:10:43 -0600 Subject: [PATCH 016/370] skip false values from preferred_ip --- salt/cloud/clouds/dimensiondata.py | 2 ++ salt/cloud/clouds/nova.py | 2 ++ salt/cloud/clouds/openstack.py | 2 ++ salt/cloud/clouds/rackspace.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/salt/cloud/clouds/dimensiondata.py b/salt/cloud/clouds/dimensiondata.py index 9b43815e8c..48924c136e 100644 --- a/salt/cloud/clouds/dimensiondata.py +++ b/salt/cloud/clouds/dimensiondata.py @@ -228,6 +228,8 @@ def create(vm_): ) for private_ip in private: private_ip = preferred_ip(vm_, [private_ip]) + if private_ip is False: + continue if salt.utils.cloud.is_public_ip(private_ip): log.warning('%s is a public IP', private_ip) data.public_ips.append(private_ip) diff --git a/salt/cloud/clouds/nova.py b/salt/cloud/clouds/nova.py index 2af1713a26..fda1ba6b81 100644 --- a/salt/cloud/clouds/nova.py +++ b/salt/cloud/clouds/nova.py @@ -833,6 +833,8 @@ def create(vm_): ) for private_ip in private: private_ip = preferred_ip(vm_, [private_ip]) + if private_ip is False: + continue if salt.utils.cloud.is_public_ip(private_ip): log.warn('{0} is a public IP'.format(private_ip)) data.public_ips.append(private_ip) diff --git a/salt/cloud/clouds/openstack.py b/salt/cloud/clouds/openstack.py index f3da373360..6e3b9b7a5c 100644 --- a/salt/cloud/clouds/openstack.py +++ b/salt/cloud/clouds/openstack.py @@ -718,6 +718,8 @@ def create(vm_): ) for private_ip in private: private_ip = preferred_ip(vm_, [private_ip]) + if private_ip is False: + continue if salt.utils.cloud.is_public_ip(private_ip): log.warn('{0} is a public IP'.format(private_ip)) data.public_ips.append(private_ip) diff --git a/salt/cloud/clouds/rackspace.py b/salt/cloud/clouds/rackspace.py index abdeaeee2e..300151faee 100644 --- a/salt/cloud/clouds/rackspace.py +++ b/salt/cloud/clouds/rackspace.py @@ -286,6 +286,8 @@ def create(vm_): ) for private_ip in private: private_ip = preferred_ip(vm_, [private_ip]) + if private_ip is False: + continue if salt.utils.cloud.is_public_ip(private_ip): log.warn('{0} is a public IP'.format(private_ip)) data.public_ips.append(private_ip) From 9d13422ac14f7e81769a60ec7179b6edc2064d7c Mon Sep 17 00:00:00 2001 From: Mihai Dinca Date: Fri, 10 Feb 2017 09:22:17 +0100 Subject: [PATCH 017/370] OpenSCAP module --- salt/modules/openscap.py | 105 ++++++++++++++ tests/unit/modules/openscap_test.py | 207 ++++++++++++++++++++++++++++ 2 files changed, 312 insertions(+) create mode 100644 salt/modules/openscap.py create mode 100644 tests/unit/modules/openscap_test.py diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py new file mode 100644 index 0000000000..b50ede7c28 --- /dev/null +++ b/salt/modules/openscap.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import +import tempfile +import shlex +import shutil +from subprocess import Popen, PIPE + +from salt.client import Caller + + +ArgumentParser = object + +try: + import argparse # pylint: disable=minimum-python-version + ArgumentParser = argparse.ArgumentParser + HAS_ARGPARSE = True +except ImportError: # python 2.6 + HAS_ARGPARSE = False + + +_XCCDF_MAP = { + 'eval': { + 'parser_arguments': [ + (('--profile',), {'required': True}), + ], + 'cmd_pattern': ( + "oscap xccdf eval " + "--oval-results --results results.xml --report report.html " + "--profile {0} {1}" + ) + } +} + + +def __virtual__(): + return HAS_ARGPARSE, 'argparse module is required.' + + +class _ArgumentParser(ArgumentParser): + + def __init__(self, action=None, *args, **kwargs): + super(_ArgumentParser, self).__init__(*args, prog='oscap', **kwargs) + self.add_argument('action', choices=['eval']) + add_arg = None + for params, kwparams in _XCCDF_MAP['eval']['parser_arguments']: + self.add_argument(*params, **kwparams) + + def error(self, message, *args, **kwargs): + raise Exception(message) + + +_OSCAP_EXIT_CODES_MAP = { + 0: True, # all rules pass + 1: False, # there is an error during evaluation + 2: True # there is at least one rule with either fail or unknown result +} + + +def xccdf(params): + ''' + Run ``oscap xccdf`` commands on minions. + It uses cp.push_dir to upload the generated files to the salt master + in the master's minion files cachedir + (defaults to ``/var/cache/salt/master/minions/minion-id/files``) + + It needs ``file_recv`` set to ``True`` in the master configuration file. + + CLI Example: + + .. code-block:: bash + + salt '*' openscap.xccdf "eval --profile Default /usr/share/openscap/scap-yast2sec-xccdf.xml" + ''' + params = shlex.split(params) + policy = params[-1] + + success = True + error = None + upload_dir = None + action = None + + try: + parser = _ArgumentParser() + action = parser.parse_known_args(params)[0].action + args, argv = _ArgumentParser(action=action).parse_known_args(args=params) + except Exception as err: + success = False + error = str(err) + + if success: + cmd = _XCCDF_MAP[action]['cmd_pattern'].format(args.profile, policy) + tempdir = tempfile.mkdtemp() + proc = Popen( + shlex.split(cmd), stdout=PIPE, stderr=PIPE, cwd=tempdir) + (stdoutdata, stderrdata) = proc.communicate() + success = _OSCAP_EXIT_CODES_MAP[proc.returncode] + if success: + caller = Caller() + caller.cmd('cp.push_dir', tempdir) + shutil.rmtree(tempdir, ignore_errors=True) + upload_dir = tempdir + else: + error = stderrdata + + return dict(success=success, upload_dir=upload_dir, error=error) diff --git a/tests/unit/modules/openscap_test.py b/tests/unit/modules/openscap_test.py new file mode 100644 index 0000000000..c883975690 --- /dev/null +++ b/tests/unit/modules/openscap_test.py @@ -0,0 +1,207 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import + +from subprocess import PIPE + +from salt.modules import openscap + +from salttesting import skipIf, TestCase +from salttesting.mock import ( + Mock, + MagicMock, + patch, + NO_MOCK, + NO_MOCK_REASON +) + + +@skipIf(NO_MOCK, NO_MOCK_REASON) +class OpenscapTestCase(TestCase): + + random_temp_dir = '/tmp/unique-name' + policy_file = '/usr/share/openscap/policy-file-xccdf.xml' + + def setUp(self): + patchers = [ + patch('salt.modules.openscap.Caller', MagicMock()), + patch('salt.modules.openscap.shutil.rmtree', Mock()), + patch( + 'salt.modules.openscap.tempfile.mkdtemp', + Mock(return_value=self.random_temp_dir) + ), + ] + for patcher in patchers: + self.apply_patch(patcher) + + def apply_patch(self, patcher): + patcher.start() + self.addCleanup(patcher.stop) + + @patch( + 'salt.modules.openscap.Popen', + MagicMock( + return_value=Mock( + **{'returncode': 0, 'communicate.return_value': ('', '')} + ) + ) + ) + def test_openscap_xccdf_eval_success(self): + response = openscap.xccdf( + 'eval --profile Default {0}'.format(self.policy_file)) + + self.assertEqual(openscap.tempfile.mkdtemp.call_count, 1) + expected_cmd = [ + 'oscap', + 'xccdf', + 'eval', + '--oval-results', + '--results', 'results.xml', + '--report', 'report.html', + '--profile', 'Default', + self.policy_file + ] + openscap.Popen.assert_called_once_with( + expected_cmd, + cwd=openscap.tempfile.mkdtemp.return_value, + stderr=PIPE, + stdout=PIPE) + openscap.Caller().cmd.assert_called_once_with( + 'cp.push_dir', self.random_temp_dir) + self.assertEqual(openscap.shutil.rmtree.call_count, 1) + self.assertEqual( + response, + { + 'upload_dir': self.random_temp_dir, + 'error': None, 'success': True + } + ) + + @patch( + 'salt.modules.openscap.Popen', + MagicMock( + return_value=Mock( + **{'returncode': 2, 'communicate.return_value': ('', '')} + ) + ) + ) + def test_openscap_xccdf_eval_success_with_failing_rules(self): + response = openscap.xccdf( + 'eval --profile Default {0}'.format(self.policy_file)) + + self.assertEqual(openscap.tempfile.mkdtemp.call_count, 1) + expected_cmd = [ + 'oscap', + 'xccdf', + 'eval', + '--oval-results', + '--results', 'results.xml', + '--report', 'report.html', + '--profile', 'Default', + self.policy_file + ] + openscap.Popen.assert_called_once_with( + expected_cmd, + cwd=openscap.tempfile.mkdtemp.return_value, + stderr=PIPE, + stdout=PIPE) + openscap.Caller().cmd.assert_called_once_with( + 'cp.push_dir', self.random_temp_dir) + self.assertEqual(openscap.shutil.rmtree.call_count, 1) + self.assertEqual( + response, + { + 'upload_dir': self.random_temp_dir, + 'error': None, + 'success': True + } + ) + + def test_openscap_xccdf_eval_fail_no_profile(self): + response = openscap.xccdf( + 'eval --param Default /unknown/param') + self.assertEqual( + response, + { + 'error': 'argument --profile is required', + 'upload_dir': None, + 'success': False + } + ) + + @patch( + 'salt.modules.openscap.Popen', + MagicMock( + return_value=Mock( + **{'returncode': 2, 'communicate.return_value': ('', '')} + ) + ) + ) + def test_openscap_xccdf_eval_success_ignore_unknown_params(self): + response = openscap.xccdf( + 'eval --profile Default --param Default /policy/file') + self.assertEqual( + response, + { + 'upload_dir': self.random_temp_dir, + 'error': None, + 'success': True + } + ) + expected_cmd = [ + 'oscap', + 'xccdf', + 'eval', + '--oval-results', + '--results', 'results.xml', + '--report', 'report.html', + '--profile', 'Default', + '/policy/file' + ] + openscap.Popen.assert_called_once_with( + expected_cmd, + cwd=openscap.tempfile.mkdtemp.return_value, + stderr=PIPE, + stdout=PIPE) + + @patch( + 'salt.modules.openscap.Popen', + MagicMock( + return_value=Mock(**{ + 'returncode': 1, + 'communicate.return_value': ('', 'evaluation error') + }) + ) + ) + def test_openscap_xccdf_eval_evaluation_error(self): + response = openscap.xccdf( + 'eval --profile Default {0}'.format(self.policy_file)) + + self.assertEqual( + response, + { + 'upload_dir': None, + 'error': 'evaluation error', + 'success': False + } + ) + + @patch( + 'salt.modules.openscap.Popen', + MagicMock( + return_value=Mock(**{ + 'returncode': 1, + 'communicate.return_value': ('', 'evaluation error') + }) + ) + ) + def test_openscap_xccdf_eval_fail_not_implemented_action(self): + response = openscap.xccdf('info {0}'.format(self.policy_file)) + + self.assertEqual( + response, + { + 'upload_dir': None, + 'error': "argument action: invalid choice: 'info' (choose from 'eval')", + 'success': False + } + ) From 17cf33df3bc8ed1fb943eb373bee289b0e6e545c Mon Sep 17 00:00:00 2001 From: Christian McHugh Date: Sat, 18 Feb 2017 07:49:57 +0000 Subject: [PATCH 018/370] Define ret before use --- salt/modules/zabbix.py | 64 +++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/salt/modules/zabbix.py b/salt/modules/zabbix.py index a8bb63e8e6..c4a968e67f 100644 --- a/salt/modules/zabbix.py +++ b/salt/modules/zabbix.py @@ -224,7 +224,7 @@ def apiinfo_version(**connection_args): salt '*' zabbix.apiinfo_version ''' conn_args = _login(**connection_args) - + ret = False try: if conn_args: method = 'apiinfo.version' @@ -264,6 +264,7 @@ def user_create(alias, passwd, usrgrps, **connection_args): salt '*' zabbix.user_create james password007 '[7, 12]' firstname='James Bond' ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.create' @@ -302,6 +303,7 @@ def user_delete(users, **connection_args): salt '*' zabbix.user_delete 15 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.delete' @@ -337,6 +339,7 @@ def user_exists(alias, **connection_args): salt '*' zabbix.user_exists james ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.get' @@ -346,7 +349,7 @@ def user_exists(alias, **connection_args): else: raise KeyError except KeyError: - return False + return ret def user_get(alias=None, userids=None, **connection_args): @@ -369,6 +372,7 @@ def user_get(alias=None, userids=None, **connection_args): salt '*' zabbix.user_get james ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.get' @@ -385,7 +389,7 @@ def user_get(alias=None, userids=None, **connection_args): else: raise KeyError except KeyError: - return False + return ret def user_update(userid, **connection_args): @@ -409,6 +413,7 @@ def user_update(userid, **connection_args): salt '*' zabbix.user_update 16 visible_name='James Brown' ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.update' @@ -444,6 +449,7 @@ def user_getmedia(userids=None, **connection_args): salt '*' zabbix.user_getmedia ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'usermedia.get' @@ -457,7 +463,7 @@ def user_getmedia(userids=None, **connection_args): else: raise KeyError except KeyError: - return False + return ret def user_addmedia(userids, active, mediatypeid, period, sendto, severity, **connection_args): @@ -486,6 +492,7 @@ def user_addmedia(userids, active, mediatypeid, period, sendto, severity, **conn ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.addmedia' @@ -526,6 +533,7 @@ def user_deletemedia(mediaids, **connection_args): salt '*' zabbix.user_deletemedia 27 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.deletemedia' @@ -559,6 +567,7 @@ def user_list(**connection_args): salt '*' zabbix.user_list ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'user.get' @@ -592,6 +601,7 @@ def usergroup_create(name, **connection_args): salt '*' zabbix.usergroup_create GroupName ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'usergroup.create' @@ -623,6 +633,7 @@ def usergroup_delete(usergroupids, **connection_args): salt '*' zabbix.usergroup_delete 28 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'usergroup.delete' @@ -660,6 +671,7 @@ def usergroup_exists(name=None, node=None, nodeids=None, **connection_args): ''' conn_args = _login(**connection_args) zabbix_version = apiinfo_version(**connection_args) + ret = False try: if conn_args: # usergroup.exists deprecated @@ -688,7 +700,7 @@ def usergroup_exists(name=None, node=None, nodeids=None, **connection_args): else: raise KeyError except KeyError: - return False + return ret def usergroup_get(name=None, usrgrpids=None, userids=None, **connection_args): @@ -714,6 +726,7 @@ def usergroup_get(name=None, usrgrpids=None, userids=None, **connection_args): salt '*' zabbix.usergroup_get Guests ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'usergroup.get' @@ -733,7 +746,7 @@ def usergroup_get(name=None, usrgrpids=None, userids=None, **connection_args): else: raise KeyError except KeyError: - return False + return ret def usergroup_update(usrgrpid, **connection_args): @@ -757,6 +770,7 @@ def usergroup_update(usrgrpid, **connection_args): salt '*' zabbix.usergroup_update 8 name=guestsRenamed ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'usergroup.update' @@ -788,6 +802,7 @@ def usergroup_list(**connection_args): salt '*' zabbix.usergroup_list ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'usergroup.get' @@ -797,7 +812,7 @@ def usergroup_list(**connection_args): else: raise KeyError except KeyError: - return False + return ret def host_create(host, groups, interfaces, **connection_args): @@ -828,6 +843,7 @@ def host_create(host, groups, interfaces, **connection_args): visible_name='Host Visible Name' ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'host.create' @@ -871,6 +887,7 @@ def host_delete(hostids, **connection_args): salt '*' zabbix.host_delete 10106 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'host.delete' @@ -910,7 +927,7 @@ def host_exists(host=None, hostid=None, name=None, node=None, nodeids=None, **co ''' conn_args = _login(**connection_args) zabbix_version = apiinfo_version(**connection_args) - + ret = False try: if conn_args: # hostgroup.exists deprecated @@ -948,7 +965,7 @@ def host_exists(host=None, hostid=None, name=None, node=None, nodeids=None, **co else: raise KeyError except KeyError: - return False + return ret def host_get(host=None, name=None, hostids=None, **connection_args): @@ -975,6 +992,7 @@ def host_get(host=None, name=None, hostids=None, **connection_args): salt '*' zabbix.host_get 'Zabbix server' ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'host.get' @@ -993,7 +1011,7 @@ def host_get(host=None, name=None, hostids=None, **connection_args): else: raise KeyError except KeyError: - return False + return ret def host_update(hostid, **connection_args): @@ -1020,6 +1038,7 @@ def host_update(hostid, **connection_args): salt '*' zabbix.host_update 10084 name='Zabbix server2' ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'host.update' @@ -1051,6 +1070,7 @@ def host_list(**connection_args): salt '*' zabbix.host_list ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'host.get' @@ -1060,7 +1080,7 @@ def host_list(**connection_args): else: raise KeyError except KeyError: - return False + return ret def hostgroup_create(name, **connection_args): @@ -1084,6 +1104,7 @@ def hostgroup_create(name, **connection_args): salt '*' zabbix.hostgroup_create MyNewGroup ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostgroup.create' @@ -1116,6 +1137,7 @@ def hostgroup_delete(hostgroupids, **connection_args): salt '*' zabbix.hostgroup_delete 23 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostgroup.delete' @@ -1154,6 +1176,7 @@ def hostgroup_exists(name=None, groupid=None, node=None, nodeids=None, **connect ''' conn_args = _login(**connection_args) zabbix_version = apiinfo_version(**connection_args) + ret = False try: if conn_args: # hostgroup.exists deprecated @@ -1187,7 +1210,7 @@ def hostgroup_exists(name=None, groupid=None, node=None, nodeids=None, **connect else: raise KeyError except KeyError: - return False + return ret def hostgroup_get(name=None, groupids=None, hostids=None, **connection_args): @@ -1216,6 +1239,7 @@ def hostgroup_get(name=None, groupids=None, hostids=None, **connection_args): salt '*' zabbix.hostgroup_get MyNewGroup ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostgroup.get' @@ -1235,7 +1259,7 @@ def hostgroup_get(name=None, groupids=None, hostids=None, **connection_args): else: raise KeyError except KeyError: - return False + return ret def hostgroup_update(groupid, name=None, **connection_args): @@ -1260,6 +1284,7 @@ def hostgroup_update(groupid, name=None, **connection_args): salt '*' zabbix.hostgroup_update 24 name='Renamed Name' ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostgroup.update' @@ -1293,6 +1318,7 @@ def hostgroup_list(**connection_args): salt '*' zabbix.hostgroup_list ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostgroup.get' @@ -1302,7 +1328,7 @@ def hostgroup_list(**connection_args): else: raise KeyError except KeyError: - return False + return ret def hostinterface_get(hostids, **connection_args): @@ -1326,6 +1352,7 @@ def hostinterface_get(hostids, **connection_args): salt '*' zabbix.hostinterface_get 101054 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostinterface.get' @@ -1338,7 +1365,7 @@ def hostinterface_get(hostids, **connection_args): else: raise KeyError except KeyError: - return False + return ret def hostinterface_create(hostid, ip, dns='', main=1, type=1, useip=1, port=None, **connection_args): @@ -1369,6 +1396,7 @@ def hostinterface_create(hostid, ip, dns='', main=1, type=1, useip=1, port=None, salt '*' zabbix.hostinterface_create 10105 192.193.194.197 ''' conn_args = _login(**connection_args) + ret = False if not port: port = INTERFACE_DEFAULT_PORTS[type] @@ -1405,6 +1433,7 @@ def hostinterface_delete(interfaceids, **connection_args): salt '*' zabbix.hostinterface_delete 50 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostinterface.delete' @@ -1441,6 +1470,7 @@ def hostinterface_update(interfaceid, **connection_args): salt '*' zabbix.hostinterface_update 6 ip=0.0.0.2 ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'hostinterface.update' @@ -1482,6 +1512,7 @@ def template_get(name=None, host=None, templateids=None, **connection_args): salt '*' zabbix.template_get templateids="['10050', '10001']" ''' conn_args = _login(**connection_args) + ret = False try: if conn_args: method = 'template.get' @@ -1498,8 +1529,7 @@ def template_get(name=None, host=None, templateids=None, **connection_args): else: raise KeyError except KeyError: - return False - + return ret def run_query(method, params, **connection_args): ''' From f08052803558d452441603cc8b6939618889ad3e Mon Sep 17 00:00:00 2001 From: Christian McHugh Date: Sat, 18 Feb 2017 08:30:14 +0000 Subject: [PATCH 019/370] Allow states to declare _connection_ keys as documented --- salt/states/zabbix_host.py | 69 +++++++++++++++++++++++---------- salt/states/zabbix_hostgroup.py | 29 ++++++++++---- salt/states/zabbix_user.py | 41 ++++++++++++++------ salt/states/zabbix_usergroup.py | 35 ++++++++++++----- 4 files changed, 124 insertions(+), 50 deletions(-) diff --git a/salt/states/zabbix_host.py b/salt/states/zabbix_host.py index 0ae038d750..de83e1d88e 100644 --- a/salt/states/zabbix_host.py +++ b/salt/states/zabbix_host.py @@ -62,6 +62,14 @@ def present(host, groups, interfaces, **kwargs): ''' + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] + ret = {'name': host, 'changes': {}, 'result': False, 'comment': ''} # Comment and change messages @@ -130,7 +138,7 @@ def present(host, groups, interfaces, **kwargs): groupids = [] for group in groups: if isinstance(group, six.string_types): - groupid = __salt__['zabbix.hostgroup_get'](name=group) + groupid = __salt__['zabbix.hostgroup_get'](name=group, **connection_args) try: groupids.append(int(groupid[0]['groupid'])) except TypeError: @@ -140,16 +148,16 @@ def present(host, groups, interfaces, **kwargs): groupids.append(group) groups = groupids - host_exists = __salt__['zabbix.host_exists'](host) + host_exists = __salt__['zabbix.host_exists'](host, **connection_args) if host_exists: - host = __salt__['zabbix.host_get'](name=host)[0] + host = __salt__['zabbix.host_get'](name=host, **connection_args)[0] hostid = host['hostid'] update_hostgroups = False update_interfaces = False - hostgroups = __salt__['zabbix.hostgroup_get'](hostids=hostid) + hostgroups = __salt__['zabbix.hostgroup_get'](hostids=hostid, **connection_args) cur_hostgroups = list() for hostgroup in hostgroups: @@ -158,7 +166,7 @@ def present(host, groups, interfaces, **kwargs): if set(groups) != set(cur_hostgroups): update_hostgroups = True - hostinterfaces = __salt__['zabbix.hostinterface_get'](hostids=hostid) + hostinterfaces = __salt__['zabbix.hostinterface_get'](hostids=hostid, **connection_args) if hostinterfaces: hostinterfaces = sorted(hostinterfaces, key=lambda k: k['main']) @@ -197,16 +205,16 @@ def present(host, groups, interfaces, **kwargs): if update_hostgroups or update_interfaces: if update_hostgroups: - hostupdate = __salt__['zabbix.host_update'](hostid, groups=groups) + hostupdate = __salt__['zabbix.host_update'](hostid, groups=groups, **connection_args) ret['changes']['groups'] = str(groups) if 'error' in hostupdate: error.append(hostupdate['error']) if update_interfaces: if hostinterfaces: for interface in hostinterfaces: - __salt__['zabbix.hostinterface_delete'](interfaceids=interface['interfaceid']) + __salt__['zabbix.hostinterface_delete'](interfaceids=interface['interfaceid'], **connection_args) - hostid = __salt__['zabbix.host_get'](name=host)[0]['hostid'] + hostid = __salt__['zabbix.host_get'](name=host, **connection_args)[0]['hostid'] for interface in interfaces_formated: updatedint = __salt__['zabbix.hostinterface_create'](hostid=hostid, @@ -215,7 +223,8 @@ def present(host, groups, interfaces, **kwargs): main=interface['main'], type=interface['type'], useip=interface['useip'], - port=interface['port']) + port=interface['port'], + **connection_args) if 'error' in updatedint: error.append(updatedint['error']) @@ -227,7 +236,7 @@ def present(host, groups, interfaces, **kwargs): else: ret['comment'] = comment_host_exists else: - host_create = __salt__['zabbix.host_create'](host, groups, interfaces_formated, **kwargs) + host_create = __salt__['zabbix.host_create'](host, groups, interfaces_formated, **connection_args) if 'error' not in host_create: ret['result'] = True @@ -273,8 +282,15 @@ def absent(name): 'new': 'Host {0} deleted.'.format(name), } } + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] - host_exists = __salt__['zabbix.host_exists'](name) + host_exists = __salt__['zabbix.host_exists'](name, **connection_args) # Dry run, test=true mode if __opts__['test']: @@ -286,7 +302,7 @@ def absent(name): ret['comment'] = comment_host_deleted return ret - host_get = __salt__['zabbix.host_get'](name) + host_get = __salt__['zabbix.host_get'](name, **connection_args) if not host_get: ret['result'] = True @@ -294,7 +310,7 @@ def absent(name): else: try: hostid = host_get[0]['hostid'] - host_delete = __salt__['zabbix.host_delete'](hostid) + host_delete = __salt__['zabbix.host_delete'](hostid, **connection_args) except KeyError: host_delete = False @@ -325,11 +341,19 @@ def assign_templates(host, templates, **kwargs): add_zabbix_templates_to_host: zabbix_host.assign_templates: - host: TestHost - - templates: - - "Template OS Linux" - - "Template App MySQL" + - templates: + - "Template OS Linux" + - "Template App MySQL" ''' + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] + ret = {'name': host, 'changes': {}, 'result': False, 'comment': ''} # Set comments @@ -342,7 +366,7 @@ def assign_templates(host, templates, **kwargs): requested_template_ids = list() hostid = '' - host_exists = __salt__['zabbix.host_exists'](host) + host_exists = __salt__['zabbix.host_exists'](host, **connection_args) # Fail out if host does not exist if not host_exists: @@ -350,7 +374,7 @@ def assign_templates(host, templates, **kwargs): ret['comment'] = comment_host_templates_notupdated return ret - host_info = __salt__['zabbix.host_get'](name=host)[0] + host_info = __salt__['zabbix.host_get'](name=host, **connection_args)[0] hostid = host_info['hostid'] if not templates: @@ -358,14 +382,16 @@ def assign_templates(host, templates, **kwargs): # Get current templateids for host host_templates = __salt__['zabbix.host_get'](hostids=hostid, - output='[{"hostid"}]', selectParentTemplates='["templateid"]') + output='[{"hostid"}]', + selectParentTemplates='["templateid"]', + **connection_args) for template_id in host_templates[0]['parentTemplates']: curr_template_ids.append(template_id['templateid']) # Get requested templateids for template in templates: try: - template_id = __salt__['zabbix.template_get'](host=template)[0]['templateid'] + template_id = __salt__['zabbix.template_get'](host=template, **connection_args)[0]['templateid'] requested_template_ids.append(template_id) except TypeError: ret['result'] = False @@ -395,8 +421,9 @@ def assign_templates(host, templates, **kwargs): # Attempt to perform update ret['result'] = True if update_host_templates: - update_output = __salt__['zabbix.host_update'](hostid, templates=(requested_template_ids)) + update_output = __salt__['zabbix.host_update'](hostid, templates=(requested_template_ids), **connection_args) if update_output is False: + print("Failing out: update_output fale") ret['result'] = False ret['comment'] = comment_host_templates_notupdated return ret diff --git a/salt/states/zabbix_hostgroup.py b/salt/states/zabbix_hostgroup.py index 5f694e9743..21f78bfbe4 100644 --- a/salt/states/zabbix_hostgroup.py +++ b/salt/states/zabbix_hostgroup.py @@ -15,7 +15,7 @@ def __virtual__(): return 'zabbix.hostgroup_create' in __salt__ -def present(name): +def present(name, **kwargs): ''' Ensures that the host group exists, eventually creates new host group. @@ -34,6 +34,13 @@ def present(name): ''' + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} # Comment and change messages @@ -45,7 +52,7 @@ def present(name): } } - hostgroup_exists = __salt__['zabbix.hostgroup_exists'](name) + hostgroup_exists = __salt__['zabbix.hostgroup_exists'](name, **connection_args) # Dry run, test=true mode if __opts__['test']: @@ -62,7 +69,7 @@ def present(name): ret['result'] = True ret['comment'] = comment_hostgroup_exists else: - hostgroup_create = __salt__['zabbix.hostgroup_create'](name) + hostgroup_create = __salt__['zabbix.hostgroup_create'](name, **connection_args) if 'error' not in hostgroup_create: ret['result'] = True @@ -75,7 +82,7 @@ def present(name): return ret -def absent(name): +def absent(name, **kwargs): ''' Ensures that the host group does not exist, eventually delete host group. @@ -105,7 +112,15 @@ def absent(name): } } - hostgroup_exists = __salt__['zabbix.hostgroup_exists'](name) + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] + + hostgroup_exists = __salt__['zabbix.hostgroup_exists'](name, **connection_args) # Dry run, test=true mode if __opts__['test']: @@ -118,7 +133,7 @@ def absent(name): ret['changes'] = changes_hostgroup_deleted return ret - hostgroup_get = __salt__['zabbix.hostgroup_get'](name) + hostgroup_get = __salt__['zabbix.hostgroup_get'](name, **connection_args) if not hostgroup_get: ret['result'] = True @@ -126,7 +141,7 @@ def absent(name): else: try: groupid = hostgroup_get[0]['groupid'] - hostgroup_delete = __salt__['zabbix.hostgroup_delete'](groupid) + hostgroup_delete = __salt__['zabbix.hostgroup_delete'](groupid, **connection_args) except KeyError: hostgroup_delete = False diff --git a/salt/states/zabbix_user.py b/salt/states/zabbix_user.py index 16d009f76a..d60cf2cffa 100644 --- a/salt/states/zabbix_user.py +++ b/salt/states/zabbix_user.py @@ -64,6 +64,14 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): - sendto: '+42032132588568' ''' + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] + ret = {'name': alias, 'changes': {}, 'result': False, 'comment': ''} # Comment and change messages @@ -125,16 +133,16 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): 'severity': severity}) return medias_list - user_exists = __salt__['zabbix.user_exists'](alias) + user_exists = __salt__['zabbix.user_exists'](alias, **connection_args) if user_exists: - user = __salt__['zabbix.user_get'](alias)[0] + user = __salt__['zabbix.user_get'](alias, **connection_args)[0] userid = user['userid'] update_usrgrps = False update_medias = False - usergroups = __salt__['zabbix.usergroup_get'](userids=userid) + usergroups = __salt__['zabbix.usergroup_get'](userids=userid, **connection_args) cur_usrgrps = list() for usergroup in usergroups: @@ -143,7 +151,7 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): if set(cur_usrgrps) != set(usrgrps): update_usrgrps = True - user_medias = __salt__['zabbix.user_getmedia'](userid) + user_medias = __salt__['zabbix.user_getmedia'](userid, **connection_args) medias_formated = _media_format(medias) if user_medias: @@ -179,8 +187,8 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): ret['comment'] = comment_user_updated if update_usrgrps: - __salt__['zabbix.user_update'](userid, usrgrps=usrgrps) - updated_groups = __salt__['zabbix.usergroup_get'](userids=userid) + __salt__['zabbix.user_update'](userid, usrgrps=usrgrps, **connection_args) + updated_groups = __salt__['zabbix.usergroup_get'](userids=userid, **connection_args) cur_usrgrps = list() for usergroup in updated_groups: @@ -194,7 +202,7 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): ret['changes']['usrgrps'] = str(updated_groups) if password_reset: - updated_password = __salt__['zabbix.user_update'](userid, passwd=passwd) + updated_password = __salt__['zabbix.user_update'](userid, passwd=passwd, **connection_args) if 'error' in updated_password: error.append(updated_groups['error']) else: @@ -202,7 +210,7 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): if update_medias: for user_med in user_medias: - deletedmed = __salt__['zabbix.user_deletemedia'](user_med['mediaid']) + deletedmed = __salt__['zabbix.user_deletemedia'](user_med['mediaid'], **connection_args) if 'error' in deletedmed: error.append(deletedmed['error']) @@ -212,7 +220,8 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): mediatypeid=media['mediatypeid'], period=media['period'], sendto=media['sendto'], - severity=media['severity']) + severity=media['severity'], + **connection_args) if 'error' in updatemed: error.append(updatemed['error']) @@ -241,7 +250,7 @@ def present(alias, passwd, usrgrps, medias, password_reset=False, **kwargs): return ret -def absent(name): +def absent(name, **kwargs): ''' Ensures that the user does not exist, eventually delete user. @@ -258,6 +267,14 @@ def absent(name): zabbix_user.absent ''' + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] + ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} # Comment and change messages @@ -269,7 +286,7 @@ def absent(name): } } - user_get = __salt__['zabbix.user_get'](name) + user_get = __salt__['zabbix.user_get'](name, **connection_args) # Dry run, test=true mode if __opts__['test']: @@ -287,7 +304,7 @@ def absent(name): else: try: userid = user_get[0]['userid'] - user_delete = __salt__['zabbix.user_delete'](userid) + user_delete = __salt__['zabbix.user_delete'](userid, **connection_args) except KeyError: user_delete = False diff --git a/salt/states/zabbix_usergroup.py b/salt/states/zabbix_usergroup.py index ecc60ecb92..cbbaa684a9 100644 --- a/salt/states/zabbix_usergroup.py +++ b/salt/states/zabbix_usergroup.py @@ -38,6 +38,14 @@ def present(name, **kwargs): - users_status: 0 ''' + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] + ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} # Comment and change messages @@ -50,10 +58,10 @@ def present(name, **kwargs): } } - usergroup_exists = __salt__['zabbix.usergroup_exists'](name) + usergroup_exists = __salt__['zabbix.usergroup_exists'](name, **connection_args) if usergroup_exists: - usergroup = __salt__['zabbix.usergroup_get'](name)[0] + usergroup = __salt__['zabbix.usergroup_get'](name, **connection_args)[0] usrgrpid = int(usergroup['usrgrpid']) update_debug_mode = False update_gui_access = False @@ -93,21 +101,21 @@ def present(name, **kwargs): ret['comment'] = comment_usergroup_updated if update_debug_mode: - updated_debug = __salt__['zabbix.usergroup_update'](usrgrpid, debug_mode=kwargs['debug_mode']) + updated_debug = __salt__['zabbix.usergroup_update'](usrgrpid, debug_mode=kwargs['debug_mode'], **connection_args) if 'error' in updated_debug: error.append(updated_debug['error']) else: ret['changes']['debug_mode'] = kwargs['debug_mode'] if update_gui_access: - updated_gui = __salt__['zabbix.usergroup_update'](usrgrpid, gui_access=kwargs['gui_access']) + updated_gui = __salt__['zabbix.usergroup_update'](usrgrpid, gui_access=kwargs['gui_access'], **connection_args) if 'error' in updated_gui: error.append(updated_gui['error']) else: ret['changes']['gui_access'] = kwargs['gui_access'] if update_users_status: - updated_status = __salt__['zabbix.usergroup_update'](usrgrpid, users_status=kwargs['users_status']) + updated_status = __salt__['zabbix.usergroup_update'](usrgrpid, users_status=kwargs['users_status'], **connection_args) if 'error' in updated_status: error.append(updated_status['error']) else: @@ -136,7 +144,7 @@ def present(name, **kwargs): return ret -def absent(name): +def absent(name, **kwargs): ''' Ensures that the user group does not exist, eventually delete user group. @@ -152,8 +160,15 @@ def absent(name): delete_thai_monks_usrgrp: zabbix_usergroup.absent: - name: 'Thai monks' - ''' + connection_args = {} + if '_connection_user' in kwargs: + connection_args['_connection_user'] = kwargs['_connection_user'] + if '_connection_password' in kwargs: + connection_args['_connection_password'] = kwargs['_connection_password'] + if '_connection_url' in kwargs: + connection_args['_connection_url'] = kwargs['_connection_url'] + ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} # Comment and change messages @@ -165,7 +180,7 @@ def absent(name): } } - usergroup_exists = __salt__['zabbix.usergroup_exists'](name) + usergroup_exists = __salt__['zabbix.usergroup_exists'](name, **connection_args) # Dry run, test=true mode if __opts__['test']: @@ -177,7 +192,7 @@ def absent(name): ret['comment'] = comment_usergroup_deleted return ret - usergroup_get = __salt__['zabbix.usergroup_get'](name) + usergroup_get = __salt__['zabbix.usergroup_get'](name, **connection_args) if not usergroup_get: ret['result'] = True @@ -185,7 +200,7 @@ def absent(name): else: try: usrgrpid = usergroup_get[0]['usrgrpid'] - usergroup_delete = __salt__['zabbix.usergroup_delete'](usrgrpid) + usergroup_delete = __salt__['zabbix.usergroup_delete'](usrgrpid, **connection_args) except KeyError: usergroup_delete = False From 20b097a74538584da995c8e94e47aa48907debf5 Mon Sep 17 00:00:00 2001 From: Tomas Zvala Date: Fri, 17 Feb 2017 17:22:14 +0100 Subject: [PATCH 020/370] dockerng: compare sets instead of lists of security_opt Apparently some versions of docker add label=disabled to security_opt when the container is launched as privileged. This causes Salt to relaunch the container to remove it on next run. Container started as privileged and with the security_opt set, causes it to have the option set twice and makes salt want to remove one instance. With this fix, dockerng will compare just (non-)existence of the flag. So containers started with privileged flag and security_opt set to label=disabled will not get relaunched on every salt run. Fixes #39447 --- salt/states/dockerng.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/salt/states/dockerng.py b/salt/states/dockerng.py index 9e4f04f315..358a5091e5 100644 --- a/salt/states/dockerng.py +++ b/salt/states/dockerng.py @@ -426,6 +426,21 @@ def _compare(actual, create_kwargs, defaults_from_image): if actual_data != data: ret.update({item: {'old': actual_data, 'new': data}}) continue + elif item == 'security_opt': + if actual_data is None: + actual_data = [] + if data is None: + data = [] + actual_data = sorted(set(actual_data)) + desired_data = sorted(set(data)) + log.trace('dockerng.running ({0}): munged actual value: {1}' + .format(item, actual_data)) + log.trace('dockerng.running ({0}): munged desired value: {1}' + .format(item, desired_data)) + if actual_data != desired_data: + ret.update({item: {'old': actual_data, + 'new': desired_data}}) + continue elif item in ('cmd', 'command', 'entrypoint'): if (actual_data is None and item not in create_kwargs and _image_get(config['image_path'])): From a6a17d58aaa5b478d25870037561d4a7e4fc233e Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 18 Feb 2017 19:37:46 -0600 Subject: [PATCH 021/370] Handle docker-py 2.0's new host_config path docker-py 2.0 made some changes to the location of the function which creates the host config. This adds a function to get the proper argspec for host config, networking config, and container config, irrespective of the installed version of docker-py. --- salt/modules/dockerng.py | 93 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index f91b4e3af2..fe077228db 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -264,7 +264,6 @@ import distutils.version # pylint: disable=import-error,no-name-in-module,unuse import fnmatch import functools import gzip -import inspect as inspect_module import json import logging import os @@ -278,6 +277,7 @@ import time # Import Salt libs from salt.exceptions import CommandExecutionError, SaltInvocationError from salt.ext.six.moves import map # pylint: disable=import-error,redefined-builtin +from salt.utils.args import get_function_argspec as _argspec from salt.utils.decorators \ import identical_signature_wrapper as _mimic_signature import salt.utils @@ -288,11 +288,22 @@ import salt.ext.six as six # pylint: disable=import-error try: import docker - import docker.utils HAS_DOCKER_PY = True except ImportError: HAS_DOCKER_PY = False +# These next two imports are only necessary to have access to the needed +# functions so that we can get argspecs for the container config, host config, +# and networking config (see the get_client_args() function). +try: + import docker.types +except ImportError: + pass +try: + import docker.utils +except ImportError: + pass + try: PY_VERSION = sys.version_info[0] if PY_VERSION == 2: @@ -2994,7 +3005,7 @@ def create(image, # https://docs.docker.com/engine/reference/api/docker_remote_api_v1.15/#create-a-container if salt.utils.version_cmp(version()['ApiVersion'], '1.15') > 0: client = __context__['docker.client'] - host_config_args = inspect_module.getargspec(docker.utils.create_host_config).args + host_config_args = get_client_args()['host_config'] create_kwargs['host_config'] = client.create_host_config( **dict((arg, create_kwargs.pop(arg, None)) for arg in host_config_args if arg != 'version') ) @@ -5492,3 +5503,79 @@ def script_retcode(name, ignore_retcode=ignore_retcode, use_vt=use_vt, keep_env=keep_env)['retcode'] + + +def get_client_args(): + ''' + .. versionadded:: 2016.3.6,2016.11.4,Nitrogen + + Returns the args for docker-py's `low-level API`_, organized by container + config, host config, and networking config. This is designed for use by the + :mod:`docker states ` to more gracefully handle API + changes. + + .. _`low-level API`: http://docker-py.readthedocs.io/en/stable/api.html + + CLI Example: + + .. code-block:: bash + + salt myminion docker.get_client_args + ''' + try: + config_args = _argspec(docker.types.ContainerConfig.__init__).args + except AttributeError: + try: + config_args = _argspec(docker.utils.create_container_config).args + except AttributeError: + raise CommandExecutionError( + 'Failed to get create_container_config argspec' + ) + + try: + host_config_args = \ + _argspec(docker.types.HostConfig.__init__).args + except AttributeError: + try: + host_config_args = _argspec(docker.utils.create_host_config).args + except AttributeError: + raise CommandExecutionError( + 'Failed to get create_host_config argspec' + ) + + try: + endpoint_config_args = \ + _argspec(docker.types.EndpointConfig.__init__).args + except AttributeError: + try: + endpoint_config_args = \ + _argspec(docker.utils.create_endpoint_config).args + except AttributeError: + raise CommandExecutionError( + 'Failed to get create_host_config argspec' + ) + + for arglist in (config_args, host_config_args, endpoint_config_args): + try: + # The API version is passed automagically by the API code that + # imports these classes/functions and is not an arg that we will be + # passing, so remove it if present. + arglist.remove('version') + except ValueError: + pass + + # Remove any args in host or networking config from the main config dict. + # This keeps us from accidentally allowing args that have been moved from + # the container config to the host config (but are still accepted by + # create_container_config so warnings can be issued). + for arglist in (host_config_args, endpoint_config_args): + for item in arglist: + try: + config_args.remove(item) + except ValueError: + # Arg is not in config_args + pass + + return {'config': config_args, + 'host_config': host_config_args, + 'networking_config': endpoint_config_args} From cbd0270bac6d03bd037102cc3aa8afb556df2108 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 18 Feb 2017 19:47:36 -0600 Subject: [PATCH 022/370] docker: make docker-exec the default execution driver Docker 1.13.1 removed the ExecutionDriver from the ``docker info`` return data. This causes all attempts to run commands in containers to fall back to the old lxc-attach driver, which is incompatible with newer docker releases. --- salt/modules/dockerng.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index fe077228db..bbcecfe90e 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -203,6 +203,14 @@ Functions Executing Commands Within a Running Container --------------------------------------------- +.. note:: + With the release of Docker 1.13.1, the Execution Driver has been removed. + Starting in versions 2016.3.6, 2016.11.4, and Nitrogen, Salt defaults to + using ``docker exec`` to run commands in containers, however for older Salt + releases it will be necessary to set the ``docker.exec_driver`` config + option to either ``docker-exec`` or ``nsenter`` for Docker versions 1.13.1 + and newer. + Multiple methods exist for executing commands within Docker containers: - lxc-attach_: Default for older versions of docker @@ -843,10 +851,12 @@ def _get_exec_driver(): __context__[contextkey] = from_config return from_config - # For old versions of docker, lxc was the only supported driver. - # This is a sane default. - driver = info().get('ExecutionDriver', 'lxc-') - if driver.startswith('lxc-'): + # The execution driver was removed in Docker 1.13.1, docker-exec is now + # the default. + driver = info().get('ExecutionDriver', 'docker-exec') + if driver == 'docker-exec': + __context__[contextkey] = driver + elif driver.startswith('lxc-'): __context__[contextkey] = 'lxc-attach' elif driver.startswith('native-') and HAS_NSENTER: __context__[contextkey] = 'nsenter' @@ -5510,9 +5520,7 @@ def get_client_args(): .. versionadded:: 2016.3.6,2016.11.4,Nitrogen Returns the args for docker-py's `low-level API`_, organized by container - config, host config, and networking config. This is designed for use by the - :mod:`docker states ` to more gracefully handle API - changes. + config, host config, and networking config. .. _`low-level API`: http://docker-py.readthedocs.io/en/stable/api.html From 65cbef318e740abadadcfe85d9b5e2c35d349a9a Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Sat, 18 Feb 2017 21:18:54 -0800 Subject: [PATCH 023/370] Adding in the ability to include access groups for the Slack engine, then specify what commands those groups have access to run. --- salt/engines/slack.py | 55 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/salt/engines/slack.py b/salt/engines/slack.py index b3e212c590..5f08d6e553 100644 --- a/salt/engines/slack.py +++ b/salt/engines/slack.py @@ -28,6 +28,29 @@ prefaced with a ``!``. list_commands: cmd: pillar.get salt:engines:slack:valid_commands target=saltmaster tgt_type=list + :configuration: Example configuration using groups + .. versionadded: Nitrogen + + engines: + slack: + token: 'xoxb-xxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx' + control: True + groups: + gods: + users: + - garethgreenaway + commands: + - test.ping + - cmd.run + - list_jobs + - list_commands + aliases: + list_jobs: + cmd: jobs.list_jobs + list_commands: + cmd: pillar.get salt:engines:slack:valid_commands target=saltmaster tgt_type=list + + :depends: slackclient ''' @@ -82,10 +105,11 @@ def _get_users(token): def start(token, aliases=None, - valid_users=None, - valid_commands=None, + valid_users=[], + valid_commands=[], control=False, trigger="!", + groups=None, tag='salt/engines/slack'): ''' Listen to Slack events and forward them to Salt @@ -136,6 +160,21 @@ def start(token, if _text: if _text.startswith(trigger) and control: + # Get groups + if groups: + for group in groups: + if 'users' in groups[group]: + # Add users to valid_users + valid_users.extend(groups[group]['users']) + + # Add commands to valid_commands + if 'commands' in groups[group]: + valid_commands.extend(groups[group]['commands']) + + # Add group aliases to aliases + if 'aliases' in groups[group]: + aliases.update(groups[group]['aliases']) + # Ensure the user is allowed to run commands if valid_users: log.debug('{0} {1}'.format(all_users, _m['user'])) @@ -165,18 +204,18 @@ def start(token, args = [] kwargs = {} - # Ensure the command is allowed - if valid_commands: - if cmd not in valid_commands: - channel.send_message('Using {0} is not allowed.'.format(cmd)) - return - # Evaluate aliases if aliases and isinstance(aliases, dict) and cmd in aliases.keys(): cmdline = aliases[cmd].get('cmd') cmdline = salt.utils.shlex_split(cmdline) cmd = cmdline[0] + # Ensure the command is allowed + if valid_commands: + if cmd not in valid_commands: + channel.send_message('{0} is not allowed to use command {1}.'.format(all_users[_m['user']], cmd)) + return + # Parse args and kwargs if len(cmdline) > 1: for item in cmdline[1:]: From 51f4e52d435ba3f1d247f0c5bde21839e8b20bc8 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Sun, 19 Feb 2017 10:51:27 -0700 Subject: [PATCH 024/370] Newline for correct lint --- salt/modules/zabbix.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/modules/zabbix.py b/salt/modules/zabbix.py index c4a968e67f..2b516bce95 100644 --- a/salt/modules/zabbix.py +++ b/salt/modules/zabbix.py @@ -1531,6 +1531,7 @@ def template_get(name=None, host=None, templateids=None, **connection_args): except KeyError: return ret + def run_query(method, params, **connection_args): ''' Send Zabbix API call From c67d9135e5ffa102d3df1460d05965b650c743a1 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 15 Feb 2017 10:54:27 +0100 Subject: [PATCH 025/370] Restore support to generate thin tarballs with local packages (when absonly=False) See: https://github.com/saltstack/salt/pull/35997#discussion_r100556792 --- salt/runners/thin.py | 5 +++-- salt/utils/thin.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/salt/runners/thin.py b/salt/runners/thin.py index 4174003a77..42cbd03f09 100644 --- a/salt/runners/thin.py +++ b/salt/runners/thin.py @@ -16,7 +16,7 @@ import salt.utils.thin def generate(extra_mods='', overwrite=False, so_mods='', - python2_bin='python2', python3_bin='python3'): + python2_bin='python2', python3_bin='python3', absonly=True): ''' Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma @@ -40,7 +40,8 @@ def generate(extra_mods='', overwrite=False, so_mods='', overwrite, so_mods, python2_bin, - python3_bin) + python3_bin, + absonly) def generate_min(extra_mods='', overwrite=False, so_mods='', diff --git a/salt/utils/thin.py b/salt/utils/thin.py index ea00bf1637..17b9237c0a 100644 --- a/salt/utils/thin.py +++ b/salt/utils/thin.py @@ -154,7 +154,7 @@ def get_tops(extra_mods='', so_mods=''): def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='', - python2_bin='python2', python3_bin='python3'): + python2_bin='python2', python3_bin='python3', absonly=True): ''' Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma @@ -269,7 +269,7 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='', tempdir = None for py_ver, tops in _six.iteritems(tops_py_version_mapping): for top in tops: - if not os.path.isabs(top): + if absonly and not os.path.isabs(top): continue base = os.path.basename(top) top_dirname = os.path.dirname(top) From 46e26e5260b0a74f0f2262ce955aac8379c3163d Mon Sep 17 00:00:00 2001 From: Luke Hollins Date: Sun, 19 Feb 2017 14:47:05 -0500 Subject: [PATCH 026/370] Added sysctls to dockerng configuration --- salt/modules/dockerng.py | 42 +++++++++++++++++++++++++++++ salt/states/dockerng.py | 58 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index ecee6d65be..12e5d153a9 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -569,6 +569,11 @@ VALID_CREATE_OPTS = { 'devices': { 'path': 'HostConfig:Devices', }, + 'sysctls': { + 'path': 'HostConfig:Sysctls', + 'min_docker': (1, 12, 0), + 'default': {}, + }, } @@ -1917,6 +1922,43 @@ def _validate_input(kwargs, else: kwargs['labels'] = salt.utils.repack_dictlist(kwargs['labels']) + def _valid_sysctls(): # pylint: disable=unused-variable + ''' + Can be a a dictionary + ''' + if kwargs.get('sysctls') is None: + return + if isinstance(kwargs['sysctls'], list): + repacked_sysctl = {} + for sysctl_var in kwargs['sysctls']: + try: + key, val = sysctl_var.split('=') + except AttributeError: + raise SaltInvocationError( + 'Invalid sysctl variable definition \'{0}\'' + .format(sysctl_var) + ) + else: + if key in sysctl_env: + raise SaltInvocationError( + 'Duplicate sysctl variable \'{0}\'' + .format(key) + ) + if not isinstance(val, six.string_types): + raise SaltInvocationError( + 'sysctl values must be strings {key}=\'{val}\'' + .format(key=key, val=val)) + repacked_sysctl[key] = val + kwargs['sysctls'] = repacked_sysctl + elif isinstance(kwargs['sysctls'], dict): + for key, val in six.iteritems(kwargs['sysctls']): + if not isinstance(val, six.string_types): + raise SaltInvocationError('sysctl values must be dicts') + elif not isinstance(kwargs['sysctls'], dict): + raise SaltInvocationError( + 'Invalid sysctls configuration.' + ) + # And now, the actual logic to perform the validation if 'docker.docker_version' not in __context__: # Have to call this func using the __salt__ dunder (instead of just diff --git a/salt/states/dockerng.py b/salt/states/dockerng.py index e38f418b71..6a12eb3456 100644 --- a/salt/states/dockerng.py +++ b/salt/states/dockerng.py @@ -117,7 +117,7 @@ def _prep_input(kwargs): configure in an SLS file as a dictlist. If the data type is a string, then skip repacking and let _validate_input() try to sort it out. ''' - for kwarg in ('environment', 'lxc_conf'): + for kwarg in ('environment', 'lxc_conf', 'sysctls'): kwarg_value = kwargs.get(kwarg) if kwarg_value is not None \ and not isinstance(kwarg_value, six.string_types): @@ -450,6 +450,35 @@ def _compare(actual, create_kwargs, defaults_from_image): if data != actual_data: ret.update({item: {'old': actual_data, 'new': data}}) continue + + elif item == 'sysctls': + if actual_data is None: + actual_data = [] + actual_sysctls = {} + for sysctl_var in actual_data: + try: + key, val = sysctl_var.split('=', 1) + except (AttributeError, ValueError): + log.warning( + 'Unexpected sysctl variable in inspect ' + 'output {0}'.format(sysctl_var) + ) + continue + else: + actual_sysctls[key] = val + log.trace('dockerng.running ({0}): munged actual value: {1}' + .format(item, actual_sysctls)) + sysctls_diff = {} + for key in data: + actual_val = actual_sysctls.get(key) + if data[key] != actual_val: + sysctls_ptr = sysctls_diff.setdefault(item, {}) + sysctls_ptr.setdefault('old', {})[key] = actual_val + sysctls_ptr.setdefault('new', {})[key] = data[key] + if sysctls_diff: + ret.update(sysctls_diff) + continue + elif item in ('cmd', 'command', 'entrypoint'): if (actual_data is None and item not in create_kwargs and _image_get(config['image_path'])): @@ -1602,6 +1631,33 @@ def running(name, `Configure logging drivers`_ documentation for more information. .. _`Configure logging drivers`: https://docs.docker.com/engine/admin/logging/overview/ + + sysctls + Either a list of variable/value mappings, or a list of strings in the + format ``VARNAME=value``. The below two examples are equivalent: + + .. code-block:: yaml + + foo: + dockerng.running: + - image: bar/baz:latest + - sysctls: + - VAR1.name.x: value + - VAR2.name.y: value + + .. code-block:: yaml + + foo: + dockerng.running: + - image: bar/baz:latest + - sysctls: + - VAR1.name.x=value + - VAR2.name.y=value + + .. note:: + + Values must be strings. Otherwise it will be considered + an error. ''' ret = {'name': name, 'changes': {}, From 994cb7e0221df45b45b76a5aeb5079359eab0641 Mon Sep 17 00:00:00 2001 From: Felix Dreissig Date: Sun, 19 Feb 2017 21:22:28 +0100 Subject: [PATCH 027/370] Improve error handling in Grains virtual hardware identification Some logical flaws appear to have creeped in over time and the log message didn't really make sense anymore. --- salt/grains/core.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/salt/grains/core.py b/salt/grains/core.py index 6606ffa2f5..2bf48c80d8 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -685,14 +685,14 @@ def _virtual(osdata): grains['virtual'] = 'kvm' elif 'joyent smartdc hvm' in model: grains['virtual'] = 'kvm' + break else: - if osdata['kernel'] in skip_cmds: + if osdata['kernel'] not in skip_cmds: log.warning( - "The tools 'dmidecode' and 'lspci' failed to " - 'execute because they do not exist on the system of the user ' - 'running this instance or the user does not have the ' - 'necessary permissions to execute them. Grains output might ' - 'not be accurate.' + 'All tools for virtual hardware identification failed to ' + 'execute because they do not exist on the system running this ' + 'instance or the user does not have the necessary permissions ' + 'to execute them. Grains output might not be accurate.' ) choices = ('Linux', 'OpenBSD', 'HP-UX') From 46efe430efc4959f06428580c5300da848a34d88 Mon Sep 17 00:00:00 2001 From: Felix Dreissig Date: Sun, 19 Feb 2017 21:25:09 +0100 Subject: [PATCH 028/370] Change log severity for failed Grains virtual hardware commands "Although 'dmidecode' was found in path, the current user cannot execute it" is a frequent annoyance when running Salt as non-root user. [1] [2] [3] [4] This is more of an ugly hack, but fixing the underlying problem would probably require major refactoring of the whole function. [1] https://github.com/saltstack/salt/issues/2494#issuecomment-10237835 [2] https://groups.google.com/d/topic/salt-users/aM11D1mIV4c/discussion [3] https://github.com/saltstack/salt/issues/5249#issuecomment-18429165 [4] https://github.com/saltstack/salt/issues/39184 --- salt/grains/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/grains/core.py b/salt/grains/core.py index 2bf48c80d8..5a1948391e 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -851,7 +851,7 @@ def _virtual(osdata): grains['virtual_subtype'] = 'Xen Dom0' for command in failed_commands: - log.warning( + log.info( "Although '{0}' was found in path, the current user " 'cannot execute it. Grains output might not be ' 'accurate.'.format(command) From 9cf654b72cf0680a2b5d0a227862746999864465 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Sun, 19 Feb 2017 14:20:19 -0700 Subject: [PATCH 029/370] Threadsafety option for context dictionaries --- salt/loader.py | 3 ++- salt/utils/context.py | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index 3558aadd20..93f87be613 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -1037,7 +1037,8 @@ class LazyLoader(salt.utils.lazy.LazyDict): self.pack = {} if pack is None else pack if opts is None: opts = {} - self.context_dict = salt.utils.context.ContextDict() + threadsafety = not opts.get('multiprocessing') + self.context_dict = salt.utils.context.ContextDict(threadsafe=threadsafety) self.opts = self.__prep_mod_opts(opts) self.module_dirs = module_dirs diff --git a/salt/utils/context.py b/salt/utils/context.py index b1c8c381bd..62934cd07a 100644 --- a/salt/utils/context.py +++ b/salt/utils/context.py @@ -66,12 +66,15 @@ class ContextDict(collections.MutableMapping): then allow any children to override the values of the parent. ''' - def __init__(self, **data): + def __init__(self, threadsafe=False, **data): # state should be thread local, so this object can be threadsafe self._state = threading.local() # variable for the overridden data self._state.data = None self.global_data = {} + # Threadsafety indicates whether or not we should protect data stored + # in child context dicts from being leaked + self._threadsafe = threadsafe @property def active(self): @@ -89,7 +92,7 @@ class ContextDict(collections.MutableMapping): ''' Clone this context, and return the ChildContextDict ''' - child = ChildContextDict(parent=self, overrides=kwargs) + child = ChildContextDict(parent=self, threadsafe=self._threadsafe, overrides=kwargs) return child def __setitem__(self, key, val): @@ -127,19 +130,24 @@ class ChildContextDict(collections.MutableMapping): '''An overrideable child of ContextDict ''' - def __init__(self, parent, overrides=None): + def __init__(self, parent, overrides=None, threadsafe=False): self.parent = parent self._data = {} if overrides is None else overrides self._old_data = None # merge self.global_data into self._data - for k, v in six.iteritems(self.parent.global_data): - if k not in self._data: - # A deepcopy is necessary to avoid using the same - # objects in globals as we do in thread local storage. - # Otherwise, changing one would automatically affect - # the other. - self._data[k] = copy.deepcopy(v) + if threadsafe: + for k, v in six.iteritems(self.parent.global_data): + if k not in self._data: + # A deepcopy is necessary to avoid using the same + # objects in globals as we do in thread local storage. + # Otherwise, changing one would automatically affect + # the other. + self._data[k] = copy.deepcopy(v) + else: + for k, v in six.iteritems(self.parent.global_data): + if k not in self._data: + self._data[k] = v def __setitem__(self, key, val): self._data[key] = val From 0ecde2cd023735c4af3f03a38c5f46109d3ec50e Mon Sep 17 00:00:00 2001 From: Mihai Dinca Date: Mon, 20 Feb 2017 10:23:13 +0100 Subject: [PATCH 030/370] Include oscap returncode in response --- salt/modules/openscap.py | 8 +++++++- tests/unit/modules/openscap_test.py | 19 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py index b50ede7c28..d7e72ca538 100644 --- a/salt/modules/openscap.py +++ b/salt/modules/openscap.py @@ -78,6 +78,7 @@ def xccdf(params): error = None upload_dir = None action = None + returncode = None try: parser = _ArgumentParser() @@ -94,6 +95,7 @@ def xccdf(params): shlex.split(cmd), stdout=PIPE, stderr=PIPE, cwd=tempdir) (stdoutdata, stderrdata) = proc.communicate() success = _OSCAP_EXIT_CODES_MAP[proc.returncode] + returncode = proc.returncode if success: caller = Caller() caller.cmd('cp.push_dir', tempdir) @@ -102,4 +104,8 @@ def xccdf(params): else: error = stderrdata - return dict(success=success, upload_dir=upload_dir, error=error) + return dict( + success=success, + upload_dir=upload_dir, + error=error, + returncode=returncode) diff --git a/tests/unit/modules/openscap_test.py b/tests/unit/modules/openscap_test.py index c883975690..c704d9d728 100644 --- a/tests/unit/modules/openscap_test.py +++ b/tests/unit/modules/openscap_test.py @@ -72,7 +72,8 @@ class OpenscapTestCase(TestCase): response, { 'upload_dir': self.random_temp_dir, - 'error': None, 'success': True + 'error': None, 'success': True, + 'returncode': 0 } ) @@ -112,7 +113,8 @@ class OpenscapTestCase(TestCase): { 'upload_dir': self.random_temp_dir, 'error': None, - 'success': True + 'success': True, + 'returncode': 2 } ) @@ -124,7 +126,8 @@ class OpenscapTestCase(TestCase): { 'error': 'argument --profile is required', 'upload_dir': None, - 'success': False + 'success': False, + 'returncode': None } ) @@ -144,7 +147,8 @@ class OpenscapTestCase(TestCase): { 'upload_dir': self.random_temp_dir, 'error': None, - 'success': True + 'success': True, + 'returncode': 2 } ) expected_cmd = [ @@ -181,7 +185,8 @@ class OpenscapTestCase(TestCase): { 'upload_dir': None, 'error': 'evaluation error', - 'success': False + 'success': False, + 'returncode': 1 } ) @@ -189,7 +194,6 @@ class OpenscapTestCase(TestCase): 'salt.modules.openscap.Popen', MagicMock( return_value=Mock(**{ - 'returncode': 1, 'communicate.return_value': ('', 'evaluation error') }) ) @@ -202,6 +206,7 @@ class OpenscapTestCase(TestCase): { 'upload_dir': None, 'error': "argument action: invalid choice: 'info' (choose from 'eval')", - 'success': False + 'success': False, + 'returncode': None } ) From 9fedb84607c9a1fad36f0f77a4c4f42962168f7c Mon Sep 17 00:00:00 2001 From: Mihai Dinca Date: Mon, 20 Feb 2017 10:33:31 +0100 Subject: [PATCH 031/370] Always return oscap's stderr --- salt/modules/openscap.py | 4 +--- tests/unit/modules/openscap_test.py | 19 ++++++------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py index d7e72ca538..2061550012 100644 --- a/salt/modules/openscap.py +++ b/salt/modules/openscap.py @@ -93,7 +93,7 @@ def xccdf(params): tempdir = tempfile.mkdtemp() proc = Popen( shlex.split(cmd), stdout=PIPE, stderr=PIPE, cwd=tempdir) - (stdoutdata, stderrdata) = proc.communicate() + (stdoutdata, error) = proc.communicate() success = _OSCAP_EXIT_CODES_MAP[proc.returncode] returncode = proc.returncode if success: @@ -101,8 +101,6 @@ def xccdf(params): caller.cmd('cp.push_dir', tempdir) shutil.rmtree(tempdir, ignore_errors=True) upload_dir = tempdir - else: - error = stderrdata return dict( success=success, diff --git a/tests/unit/modules/openscap_test.py b/tests/unit/modules/openscap_test.py index c704d9d728..327af75238 100644 --- a/tests/unit/modules/openscap_test.py +++ b/tests/unit/modules/openscap_test.py @@ -72,7 +72,8 @@ class OpenscapTestCase(TestCase): response, { 'upload_dir': self.random_temp_dir, - 'error': None, 'success': True, + 'error': '', + 'success': True, 'returncode': 0 } ) @@ -81,7 +82,7 @@ class OpenscapTestCase(TestCase): 'salt.modules.openscap.Popen', MagicMock( return_value=Mock( - **{'returncode': 2, 'communicate.return_value': ('', '')} + **{'returncode': 2, 'communicate.return_value': ('', 'some error')} ) ) ) @@ -112,7 +113,7 @@ class OpenscapTestCase(TestCase): response, { 'upload_dir': self.random_temp_dir, - 'error': None, + 'error': 'some error', 'success': True, 'returncode': 2 } @@ -135,7 +136,7 @@ class OpenscapTestCase(TestCase): 'salt.modules.openscap.Popen', MagicMock( return_value=Mock( - **{'returncode': 2, 'communicate.return_value': ('', '')} + **{'returncode': 2, 'communicate.return_value': ('', 'some error')} ) ) ) @@ -146,7 +147,7 @@ class OpenscapTestCase(TestCase): response, { 'upload_dir': self.random_temp_dir, - 'error': None, + 'error': 'some error', 'success': True, 'returncode': 2 } @@ -190,14 +191,6 @@ class OpenscapTestCase(TestCase): } ) - @patch( - 'salt.modules.openscap.Popen', - MagicMock( - return_value=Mock(**{ - 'communicate.return_value': ('', 'evaluation error') - }) - ) - ) def test_openscap_xccdf_eval_fail_not_implemented_action(self): response = openscap.xccdf('info {0}'.format(self.policy_file)) From 8fe48fa5c453f4b8064b4d5062271210a84e2e40 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Mon, 20 Feb 2017 18:11:30 -0500 Subject: [PATCH 032/370] prevent billions of inexplicable lines of this: > 17:32 salt.template DEBUG compile template: > 17:32 salt.template ERROR Template does not exist: --- salt/pillar/__init__.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/salt/pillar/__init__.py b/salt/pillar/__init__.py index 18d9089344..ba6e793546 100644 --- a/salt/pillar/__init__.py +++ b/salt/pillar/__init__.py @@ -390,20 +390,21 @@ class Pillar(object): # Gather initial top files try: if self.opts['pillarenv']: - tops[self.opts['pillarenv']] = [ - compile_template( - self.client.cache_file( - self.opts['state_top'], - self.opts['pillarenv'] - ), - self.rend, - self.opts['renderer'], - self.opts['renderer_blacklist'], - self.opts['renderer_whitelist'], - self.opts['pillarenv'], - _pillar_rend=True, - ) - ] + top = self.client.cache_file( + self.opts['state_top'], self.opts['pillarenv']) + + if top: + tops[self.opts['pillarenv']] = [ + compile_template( + top, + self.rend, + self.opts['renderer'], + self.opts['renderer_blacklist'], + self.opts['renderer_whitelist'], + self.opts['pillarenv'], + _pillar_rend=True, + ) + ] else: for saltenv in self._get_envs(): if self.opts.get('pillar_source_merging_strategy', None) == "none": From 2d068462a97b2f352fe7d6c553fceae50d47580b Mon Sep 17 00:00:00 2001 From: zer0def Date: Tue, 21 Feb 2017 15:02:34 +0100 Subject: [PATCH 033/370] Added arbitrary query execution and additional parameters to continuous query creation for InfluxDB --- salt/modules/influx.py | 60 ++++++++++++++++++++++-- salt/states/influxdb_continuous_query.py | 10 +++- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/salt/modules/influx.py b/salt/modules/influx.py index 5b9c075b8a..73298b663d 100644 --- a/salt/modules/influx.py +++ b/salt/modules/influx.py @@ -35,6 +35,8 @@ try: except ImportError: HAS_INFLUXDB = False +import collections +import json import logging log = logging.getLogger(__name__) @@ -593,7 +595,7 @@ def get_continuous_query(database, name, **client_args): return {} -def create_continuous_query(database, name, query, **client_args): +def create_continuous_query(database, name, query, resample_time=None, coverage_period=None, **client_args): ''' Create a continuous query. @@ -604,17 +606,34 @@ def create_continuous_query(database, name, query, **client_args): name Name of the continuous query to create. - query: + query The continuous query string. + resample_time : None + Duration between continuous query resampling. + + coverage_period : None + Duration specifying time period per sample. + CLI Example: .. code-block:: bash salt '*' influxdb.create_continuous_query mydb cq_month 'SELECT mean(*) INTO mydb.a_month.:MEASUREMENT FROM mydb.a_week./.*/ GROUP BY time(5m), *' ''' client = _client(**client_args) - full_query = 'CREATE CONTINUOUS QUERY {0} ON {1} BEGIN {2} END' - query = full_query.format(name, database, query) + full_query = 'CREATE CONTINUOUS QUERY {name} ON {database}' + if resample_time: + full_query += ' RESAMPLE EVERY {resample_time}' + if coverage_period: + full_query += ' FOR {coverage_period}' + full_query += ' BEGIN {query} END' + query = full_query.format( + name=name, + database=database, + query=query, + resample_time=resample_time, + coverage_period=coverage_period + ) client.query(query) return True @@ -641,3 +660,36 @@ def drop_continuous_query(database, name, **client_args): query = 'DROP CONTINUOUS QUERY {0} ON {1}'.format(name, database) client.query(query) return True + + +def _pull_query_results(resultset): + ''' + Parses a ResultSet returned from InfluxDB into a dictionary of results, + grouped by series names and optional JSON-encoded grouping tags. + ''' + _results = collections.defaultdict(lambda: collections.OrderedDict()) + for _header, _values in resultset.items(): + _header, _group_tags = _header + if _group_tags: + _results[_header][json.dumps(_group_tags)] = [_value for _value in _values] + else: + _results[_header] = [_value for _value in _values] + return _results + + +def query(database, query, **client_args): + ''' + Execute a query. + + database + Name of the database to query on. + + query + InfluxQL query string. + ''' + client = _client(**client_args) + _result = client.query(query, database=database) + + if isinstance(_result, collections.Sequence): + return [_pull_query_results(_query_result) for _query_result in _result if _query_result] + return [_pull_query_results(_result) if _result else {}] diff --git a/salt/states/influxdb_continuous_query.py b/salt/states/influxdb_continuous_query.py index 3248693557..6750144def 100644 --- a/salt/states/influxdb_continuous_query.py +++ b/salt/states/influxdb_continuous_query.py @@ -18,7 +18,7 @@ def __virtual__(): return False -def present(name, database, query, **client_args): +def present(name, database, query, resample_time=None, coverage_period=None, **client_args): ''' Ensure that given continuous query is present. @@ -30,6 +30,12 @@ def present(name, database, query, **client_args): query The query content + + resample_time : None + Duration between continuous query resampling. + + coverage_period : None + Duration specifying time period per sample. ''' ret = {'name': name, 'changes': {}, @@ -45,7 +51,7 @@ def present(name, database, query, **client_args): .format(name) return ret if __salt__['influxdb.create_continuous_query']( - database, name, query + database, name, query, resample_time, coverage_period ): ret['comment'] = 'continuous query {0} has been created'\ .format(name) From face5c5c8fa51bfe59cedf8a749b4d19f0b589cf Mon Sep 17 00:00:00 2001 From: Nathan DELHAYE Date: Tue, 21 Feb 2017 15:48:36 +0100 Subject: [PATCH 034/370] Fix error when collection doesn't have an alias in solrcloud --- salt/modules/solrcloud.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/salt/modules/solrcloud.py b/salt/modules/solrcloud.py index 0e1ac295e6..305cb7dadf 100644 --- a/salt/modules/solrcloud.py +++ b/salt/modules/solrcloud.py @@ -229,7 +229,10 @@ def alias_get_collections(alias_name, **kwargs): if not isinstance(alias_name, six.string_types): raise ValueError('Alias name must be a string') - collection_aliases = [(k_v[0], k_v[1]["aliases"]) for k_v in six.iteritems(cluster_status(**kwargs)["collections"])] + collection_aliases = [ + (k_v[0], k_v[1]["aliases"]) + for k_v in six.iteritems(cluster_status(**kwargs)["collections"]) + if "aliases" in k_v[1]] aliases = [k_v1[0] for k_v1 in [k_v for k_v in collection_aliases if alias_name in k_v[1]]] return aliases From a9e15c233babc4d6fe8799b358d5b91fefa4597f Mon Sep 17 00:00:00 2001 From: Nathan DELHAYE Date: Tue, 21 Feb 2017 15:50:46 +0100 Subject: [PATCH 035/370] Fix arbitrary core property url format --- salt/modules/solrcloud.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/salt/modules/solrcloud.py b/salt/modules/solrcloud.py index 305cb7dadf..a90d617b76 100644 --- a/salt/modules/solrcloud.py +++ b/salt/modules/solrcloud.py @@ -98,17 +98,19 @@ def _validate_core_properties(properties): props_string = "" for prop_name, prop_value in six.iteritems(properties): - if prop_name in STRING_PROPS_LIST: - if not isinstance(prop_value, six.string_types): - raise ValueError('In option "properties", core property "'+prop_name+'" value must be a string') - - props_string = props_string+"&"+prop_name+"="+prop_value - - elif prop_name in BOOL_PROPS_LIST: + if prop_name in BOOL_PROPS_LIST: if not isinstance(prop_value, bool): raise ValueError('Option "'+prop_name+'" value must be an boolean') props_string = props_string+"&property."+prop_name+"="+("true" if prop_value else "false") + elif prop_name in STRING_PROPS_LIST: + if not isinstance(prop_value, six.string_types): + raise ValueError('In option "properties", core property "'+prop_name+'" value must be a string') + + props_string = props_string+"&property."+prop_name+"="+prop_value + + else: + props_string = props_string+"&property."+str(prop_name)+"="+str(prop_value) return props_string From 391424c4e1859e293b134eada7c3253ecd69ea5c Mon Sep 17 00:00:00 2001 From: Yuri Grigorov Date: Tue, 21 Feb 2017 17:07:47 +0200 Subject: [PATCH 036/370] Add splay support for all scheduling criteria Feature #39322 --- salt/utils/schedule.py | 219 ++++++++++++++++------------------------- 1 file changed, 85 insertions(+), 134 deletions(-) diff --git a/salt/utils/schedule.py b/salt/utils/schedule.py index dd84979595..876dc704dc 100644 --- a/salt/utils/schedule.py +++ b/salt/utils/schedule.py @@ -916,6 +916,26 @@ class Schedule(object): ''' Evaluate and execute the schedule ''' + + def _splay(splaytime): + ''' + Calculate splaytime + ''' + splay_ = None + if isinstance(splaytime, dict): + if splaytime['end'] >= splaytime['start']: + splay_ = random.randint(splaytime['start'], + splaytime['end']) + else: + log.error('schedule.handle_func: Invalid Splay, ' + 'end must be larger than start. Ignoring splay.') + else: + splay_ = random.randint(1, splaytime) + if splay_: + log.debug('schedule.handle_func: Adding splay of ' + '{0} seconds to next run.'.format(splay_)) + return splay_ + schedule = self.option('schedule') if not isinstance(schedule, dict): raise ValueError('Schedule must be of type dict.') @@ -946,10 +966,18 @@ class Schedule(object): ) if 'name' not in data: data['name'] = job - # Add up how many seconds between now and then - when = 0 - seconds = 0 - cron = 0 + + if '_next_fire_time' not in data: + data['_next_fire_time'] = None + + if '_splay' not in data: + data['_splay'] = None + + if 'run_on_start' in data and \ + data['run_on_start'] and \ + '_run_on_start' not in data: + data['_run_on_start'] = True + now = int(time.time()) if 'until' in data: @@ -1005,11 +1033,20 @@ class Schedule(object): continue if True in [True for item in time_elements if item in data]: - # Add up how many seconds between now and then - seconds += int(data.get('seconds', 0)) - seconds += int(data.get('minutes', 0)) * 60 - seconds += int(data.get('hours', 0)) * 3600 - seconds += int(data.get('days', 0)) * 86400 + if '_seconds' not in data: + interval = int(data.get('seconds', 0)) + interval += int(data.get('minutes', 0)) * 60 + interval += int(data.get('hours', 0)) * 3600 + interval += int(data.get('days', 0)) * 86400 + + data['_seconds'] = interval + + if not data['_next_fire_time']: + data['_next_fire_time'] = now + data['_seconds'] + + if interval < self.loop_interval: + self.loop_interval = interval + elif 'once' in data: once_fmt = data.get('once_fmt', '%Y-%m-%dT%H:%M:%S') @@ -1021,10 +1058,8 @@ class Schedule(object): data['once'], once_fmt) continue - if now != once: - continue - else: - seconds = 1 + if not data['_next_fire_time']: + data['_next_fire_time'] = once elif 'when' in data: if not _WHEN_SUPPORTED: @@ -1071,35 +1106,18 @@ class Schedule(object): when = int(time.mktime(when__.timetuple())) if when >= now: _when.append(when) + + if data['_splay']: + _when.append(data['_splay']) + _when.sort() if _when: # Grab the first element # which is the next run time when = _when[0] - - # If we're switching to the next run in a list - # ensure the job can run - if '_when' in data and data['_when'] != when: - data['_when_run'] = True - data['_when'] = when - seconds = when - now - - # scheduled time is in the past and the run was not triggered before - if seconds < 0 and not data.get('_when_run', False): - continue - - if '_when_run' not in data: - data['_when_run'] = True - - # Backup the run time - if '_when' not in data: - data['_when'] = when - - # A new 'when' ensure _when_run is True - if when > data['_when']: - data['_when'] = when - data['_when_run'] = True - + if not data['_next_fire_time'] or \ + now > data['_next_fire_time']: + data['_next_fire_time'] = when else: continue @@ -1134,91 +1152,44 @@ class Schedule(object): log.error('Invalid date string. Ignoring') continue when = int(time.mktime(when__.timetuple())) - now = int(time.time()) - seconds = when - now - # scheduled time is in the past and the run was not triggered before - if seconds < 0 and not data.get('_when_run', False): - continue - - if '_when_run' not in data: - data['_when_run'] = True - - # Backup the run time - if '_when' not in data: - data['_when'] = when - - # A new 'when' ensure _when_run is True - if when > data['_when']: - data['_when'] = when - data['_when_run'] = True + if not data['_next_fire_time'] or \ + now > data['_next_fire_time']: + data['_next_fire_time'] = when elif 'cron' in data: if not _CRON_SUPPORTED: log.error('Missing python-croniter. Ignoring job {0}'.format(job)) continue - now = int(time.mktime(datetime.datetime.now().timetuple())) - try: - cron = int(croniter.croniter(data['cron'], now).get_next()) - except (ValueError, KeyError): - log.error('Invalid cron string. Ignoring') - continue - seconds = cron - now + if not data['_next_fire_time'] or \ + now > data['_next_fire_time']: + try: + data['_next_fire_time'] = int( + croniter.croniter(data['cron'], now).get_next()) + except (ValueError, KeyError): + log.error('Invalid cron string. Ignoring') + continue + else: continue - # Check if the seconds variable is lower than current lowest - # loop interval needed. If it is lower than overwrite variable - # external loops using can then check this variable for how often - # they need to reschedule themselves - # Not used with 'when' parameter, causes run away jobs and CPU - # spikes. - if 'when' not in data: - if seconds < self.loop_interval: - self.loop_interval = seconds run = False + seconds = data['_next_fire_time'] - now + if data['_splay']: + seconds = data['_splay'] - now + if -1 < seconds <= 0: + run = True - if 'splay' in data: - if 'when' in data: - log.error('Unable to use "splay" with "when" option at this time. Ignoring.') - elif 'cron' in data: - log.error('Unable to use "splay" with "cron" option at this time. Ignoring.') - else: - if '_seconds' not in data: - log.debug('The _seconds parameter is missing, ' - 'most likely the first run or the schedule ' - 'has been refreshed refresh.') - if 'seconds' in data: - data['_seconds'] = data['seconds'] - else: - data['_seconds'] = 0 + if '_run_on_start' in data and data['_run_on_start']: + run = True + data['_run_on_start'] = False + elif run: + if 'splay' in data and not data['_splay']: + run = False + splay = _splay(data['splay']) + data['_splay'] = data['_next_fire_time'] + splay - if 'when' in data: - # scheduled time is now or in the past, and the run was triggered before - if seconds <= 0 and data['_when_run']: - data['_when_run'] = False - run = True - elif 'cron' in data: - if seconds == 1: - run = True - else: - if job in self.intervals: - if now - self.intervals[job] >= seconds: - run = True - else: - # If run_on_start is True, the job will run when the Salt - # minion start. If the value is False will run at the next - # scheduled run. Default is True. - if 'run_on_start' in data: - if data['run_on_start']: - run = True - else: - self.intervals[job] = int(time.time()) - else: - run = True - - if run: if 'range' in data: if not _RANGE_SUPPORTED: log.error('Missing python-dateutil. Ignoring job {0}'.format(job)) @@ -1242,7 +1213,7 @@ class Schedule(object): else: run = False else: - if now >= start and now <= end: + if start <= now <= end: run = True else: run = False @@ -1257,30 +1228,8 @@ class Schedule(object): if not run: continue - else: - if 'splay' in data: - if 'when' in data: - log.error('Unable to use "splay" with "when" option at this time. Ignoring.') - else: - if isinstance(data['splay'], dict): - if data['splay']['end'] >= data['splay']['start']: - splay = random.randint(data['splay']['start'], data['splay']['end']) - else: - log.error('schedule.handle_func: Invalid Splay, end must be larger than start. \ - Ignoring splay.') - splay = None - else: - splay = random.randint(0, data['splay']) - if splay: - log.debug('schedule.handle_func: Adding splay of ' - '{0} seconds to next run.'.format(splay)) - if 'seconds' in data: - data['seconds'] = data['_seconds'] + splay - else: - data['seconds'] = 0 + splay - - log.info('Running scheduled job: {0}'.format(job)) + log.info('Running scheduled job: {0}'.format(job)) if 'jid_include' not in data or data['jid_include']: data['jid_include'] = True @@ -1322,7 +1271,9 @@ class Schedule(object): if multiprocessing_enabled: proc.join() finally: - self.intervals[job] = now + if '_seconds' in data: + data['_next_fire_time'] = now + data['_seconds'] + data['_splay'] = None if salt.utils.is_windows(): # Restore our function references. self.functions = functions From c3b3838f10c4105cdf98bc0d69f514e16b91570b Mon Sep 17 00:00:00 2001 From: zer0def Date: Tue, 21 Feb 2017 16:13:14 +0100 Subject: [PATCH 037/370] Removed OrderedDict usage in InfluxDB execution module, so that it doesn't cause unnecessary template rendering errors. --- salt/modules/influx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/influx.py b/salt/modules/influx.py index 73298b663d..98c2096ea1 100644 --- a/salt/modules/influx.py +++ b/salt/modules/influx.py @@ -667,14 +667,14 @@ def _pull_query_results(resultset): Parses a ResultSet returned from InfluxDB into a dictionary of results, grouped by series names and optional JSON-encoded grouping tags. ''' - _results = collections.defaultdict(lambda: collections.OrderedDict()) + _results = collections.defaultdict(lambda: {}) for _header, _values in resultset.items(): _header, _group_tags = _header if _group_tags: _results[_header][json.dumps(_group_tags)] = [_value for _value in _values] else: _results[_header] = [_value for _value in _values] - return _results + return dict(sorted(_results.items())) def query(database, query, **client_args): From 539bb2aa80a2598ff43991a8a6dcac0f78a1f2b7 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 21 Feb 2017 08:48:42 -0700 Subject: [PATCH 038/370] Add better ssl option docs --- doc/topics/transports/tcp.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/doc/topics/transports/tcp.rst b/doc/topics/transports/tcp.rst index 06da078854..a6a510ff8d 100644 --- a/doc/topics/transports/tcp.rst +++ b/doc/topics/transports/tcp.rst @@ -31,6 +31,38 @@ actual message that we are sending. With this flexible wire protocol we can implement any message semantics that we'd like-- including multiplexed message passing on a single socket. +TLS Support +=========== + +.. version_added:: 2016.11.1 + +The TCP transport allows for the master/minion communication to be optionally +wrapped in a TLS connection. Enabling this is simple, the master and minion need +to be using the tcp connection, then the `ssl` option is enabled. The `ssl` +option is passed as a dict and corresponds to the options passed to the +Python `ssl.wrap_socket ` +function. + +A simple setup looks like this, on the Salt Master add the `ssl` option to the +master configuration file: + +.. code-block:: yaml + + ssl: + keyfile: + certfile: + ssl_version: PROTOCOL_TLSv1_2 + +The `ssl` option in the minion configuration file looks like this: + + +.. note:: + + While setting the ssl_version is not required, we recomend it. Some older + versions of python do not support the latest TLS protocol and if this is + the case for your version of python we strongly recommend upgrading your + version of Python. + Crypto ====== From f0d3c1654794d62914961e61cbaf12d30dba0978 Mon Sep 17 00:00:00 2001 From: Andres Montalban Date: Tue, 21 Feb 2017 14:37:30 -0300 Subject: [PATCH 039/370] Fix case when /etc/localtime is a file and it is not updated --- salt/modules/timezone.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/salt/modules/timezone.py b/salt/modules/timezone.py index dc87989f8b..a2d5c82aaf 100644 --- a/salt/modules/timezone.py +++ b/salt/modules/timezone.py @@ -89,6 +89,8 @@ def _get_zone_etc_localtime(): return get_zonecode() raise CommandExecutionError(tzfile + ' does not exist') elif exc.errno == errno.EINVAL: + if 'FreeBSD' in __grains__['os_family']: + return get_zonecode() log.warning( tzfile + ' is not a symbolic link, attempting to match ' + tzfile + ' to zoneinfo files' From d946d105978c0e98d86537e4337170b967e8c871 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 21 Feb 2017 10:53:04 -0700 Subject: [PATCH 040/370] Namespace 'status' functions in 'win_status' --- salt/modules/status.py | 21 +++++++-------- salt/modules/win_status.py | 54 ++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/salt/modules/status.py b/salt/modules/status.py index 7ed3ee95e5..74e1d2a9bd 100644 --- a/salt/modules/status.py +++ b/salt/modules/status.py @@ -4,7 +4,6 @@ Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' - # Import python libs from __future__ import absolute_import import datetime @@ -38,6 +37,16 @@ __func_alias__ = { } +def __virtual__(): + ''' + Not all functions supported by Windows + ''' + if salt.utils.is_windows(): + return False, 'Windows platform is not supported by this module' + + return __virtualname__ + + def _number(text): ''' Convert a string to a number. @@ -64,8 +73,6 @@ def procs(): salt '*' status.procs ''' # Get the user, pid and cmd - if salt.utils.is_windows(): - raise CommandExecutionError('This platform is not supported') ret = {} uind = 0 pind = 0 @@ -114,8 +121,6 @@ def custom(): salt '*' status.custom ''' - if salt.utils.is_windows(): - raise CommandExecutionError('This platform is not supported') ret = {} conf = __salt__['config.dot_vals']('status') for key, val in six.iteritems(conf): @@ -584,10 +589,6 @@ def diskusage(*args): salt '*' status.diskusage ext? # usage for ext[234] filesystems salt '*' status.diskusage / ext? # usage for / and all ext filesystems ''' - - if salt.utils.is_windows(): - raise CommandExecutionError('This platform is not supported') - selected = set() fstypes = set() if not args: @@ -926,8 +927,6 @@ def w(): # pylint: disable=C0103 salt '*' status.w ''' - if salt.utils.is_windows(): - raise CommandExecutionError('This platform is not supported') user_list = [] users = __salt__['cmd.run']('w -h').splitlines() for row in users: diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 69866eed14..122ce4b648 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -12,47 +12,57 @@ or for problem solving if your minion is having problems. # Import Python Libs from __future__ import absolute_import +import os +import ctypes +import sys +import time +import datetime +from subprocess import list2cmdline import logging +log = logging.getLogger(__name__) + # Import Salt Libs import salt.utils import salt.ext.six as six import salt.utils.event from salt._compat import subprocess from salt.utils.network import host_to_ips as _host_to_ips +from salt.modules.status import master, ping_master, time_ +from salt.utils import namespaced_function as _namespaced_function -import os -import ctypes -import sys -import time -import datetime -from subprocess import list2cmdline - -log = logging.getLogger(__name__) - -try: +# Import 3rd Party Libs +if salt.utils.is_windows(): import wmi import salt.utils.winapi - has_required_packages = True -except ImportError: - if salt.utils.is_windows(): - log.exception('pywin32 and wmi python packages are required ' - 'in order to use the status module.') - has_required_packages = False + HAS_WMI = True +else: + HAS_WMI = False __opts__ = {} - -# Define the module's virtual name __virtualname__ = 'status' def __virtual__(): ''' - Only works on Windows systems + Only works on Windows systems with WMI and WinAPI ''' - if salt.utils.is_windows() and has_required_packages: - return __virtualname__ - return (False, 'Cannot load win_status module on non-windows') + if not salt.utils.is_windows(): + return False, 'win_status.py: Requires Windows' + + if not HAS_WMI: + return False, 'win_status.py: Requires WMI and WinAPI' + + # Namespace modules from `status.py` + global ping_master, time_ + ping_master = _namespaced_function(ping_master, globals()) + time_ = _namespaced_function(time_, globals()) + + return __virtualname__ + +__func_alias__ = { + 'time_': 'time' +} def cpuload(): From c357e37831fd757da7aa804c5e5e62c12041a575 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 21 Feb 2017 11:09:46 -0700 Subject: [PATCH 041/370] Add minion config --- doc/topics/transports/tcp.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/topics/transports/tcp.rst b/doc/topics/transports/tcp.rst index a6a510ff8d..1707ec3f32 100644 --- a/doc/topics/transports/tcp.rst +++ b/doc/topics/transports/tcp.rst @@ -53,8 +53,11 @@ master configuration file: certfile: ssl_version: PROTOCOL_TLSv1_2 -The `ssl` option in the minion configuration file looks like this: +The minimal `ssl` option in the minion configuration file looks like this: +.. code-block:: yaml + + ssl: {} .. note:: From 6d2cf8171e3928cc87954227ee8a264a7e9ed79f Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 21 Feb 2017 11:12:06 -0700 Subject: [PATCH 042/370] Fix 'ping_master' function --- salt/modules/win_status.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 122ce4b648..773e80c080 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -28,7 +28,10 @@ import salt.ext.six as six import salt.utils.event from salt._compat import subprocess from salt.utils.network import host_to_ips as _host_to_ips -from salt.modules.status import master, ping_master, time_ +# pylint: disable=W0611 +from salt.modules.status import ping_master, time_ +import copy +# pylint: enable=W0611 from salt.utils import namespaced_function as _namespaced_function # Import 3rd Party Libs From 1356dd6cc0a9ad33f3b7ad60d22a87d9b400bfc9 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 21 Feb 2017 11:37:12 -0700 Subject: [PATCH 043/370] Explain where the functions available as mine_functions come from. --- doc/topics/mine/index.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/topics/mine/index.rst b/doc/topics/mine/index.rst index bad3f9bd9e..fef3d8c818 100644 --- a/doc/topics/mine/index.rst +++ b/doc/topics/mine/index.rst @@ -31,8 +31,10 @@ Mine Functions To enable the Salt Mine the ``mine_functions`` option needs to be applied to a Minion. This option can be applied via the Minion's configuration file, or the Minion's Pillar. The ``mine_functions`` option dictates what functions are -being executed and allows for arguments to be passed in. If no arguments are -passed, an empty list must be added: +being executed and allows for arguments to be passed in. The list of +functions are available in the :py:mod:`salt.module`. If no arguments +are passed, an empty list must be added like in the ``test.ping`` function in +the example below: .. code-block:: yaml From bb622a68b29f8fc3df4bb5d6645fd7c029799157 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 21 Feb 2017 11:39:03 -0700 Subject: [PATCH 044/370] Further explain the additional function arguments and where to find them --- doc/topics/mine/index.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/topics/mine/index.rst b/doc/topics/mine/index.rst index fef3d8c818..3148f3255c 100644 --- a/doc/topics/mine/index.rst +++ b/doc/topics/mine/index.rst @@ -44,6 +44,11 @@ the example below: interface: eth0 cidr: '10.0.0.0/8' +In the example above :py:mod:`salt.modules.network.ip_addrs` has additional +filters to help narrow down the results. In the above example IP addresses +are only returned if they are on a eth0 interface and in the 10.0.0.0/8 IP +range. + Mine Functions Aliases ---------------------- From 4142b4bcd36f849dc8073c505f4804bd005e8741 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 21 Feb 2017 11:40:12 -0700 Subject: [PATCH 045/370] Show how to force the pillar refresh and verify the pillar contains what we expect --- doc/topics/mine/index.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/topics/mine/index.rst b/doc/topics/mine/index.rst index 3148f3255c..256a4b23ab 100644 --- a/doc/topics/mine/index.rst +++ b/doc/topics/mine/index.rst @@ -159,6 +159,19 @@ to add them to the pool of load balanced servers. mine_functions: network.ip_addrs: [eth0] +Then trigger the minions to refresh their pillar data by running: + +.. code-block:: bash + + salt '*' saltutil.refresh_pillar + +Verify that the results are showing up in the pillar on the minions by +executing the following and checking for ``network.ip_addrs`` in the output: + +.. code-block:: bash + + salt '*' pillar.items + :file:`/etc/salt/minion.d/mine.conf`: .. code-block:: yaml From da42040c1a418dd78948e8fbe53afd2f49d1482a Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Tue, 21 Feb 2017 12:47:14 -0600 Subject: [PATCH 046/370] Try the docker-py 2.0 client name first This should give us a modest perfomance improvement as more people begin to use docker-py>=2.0. --- salt/modules/dockerng.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index bbcecfe90e..817dc4f0ab 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -787,10 +787,10 @@ def _get_client(timeout=None): client_kwargs['version'] = 'auto' try: - __context__['docker.client'] = docker.Client(**client_kwargs) - except AttributeError: # docker-py 2.0 renamed this client attribute __context__['docker.client'] = docker.APIClient(**client_kwargs) + except AttributeError: + __context__['docker.client'] = docker.Client(**client_kwargs) # Set a new timeout if one was passed if timeout is not None and __context__['docker.client'].timeout != timeout: From b8b9c633a1c1546018528d20d0a6ecd0b9a43995 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 21 Feb 2017 11:57:23 -0700 Subject: [PATCH 047/370] Add example output for the pillar.items command --- doc/topics/mine/index.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/topics/mine/index.rst b/doc/topics/mine/index.rst index 256a4b23ab..fd40539fff 100644 --- a/doc/topics/mine/index.rst +++ b/doc/topics/mine/index.rst @@ -172,6 +172,18 @@ executing the following and checking for ``network.ip_addrs`` in the output: salt '*' pillar.items +Which should show that the function is present on the minion, but not include +the output: + +.. code-block:: shell + + minion1.example.com: + ---------- + mine_functions: + ---------- + network.ip_addrs: + - eth0 + :file:`/etc/salt/minion.d/mine.conf`: .. code-block:: yaml From c258cb3f73fc34f201fe0397dcd67829a445ddc2 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 21 Feb 2017 12:06:56 -0700 Subject: [PATCH 048/370] Streamline wmic command returns for easier parsing --- salt/modules/win_status.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 773e80c080..0c9e137c4e 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -82,17 +82,11 @@ def cpuload(): ''' # Pull in the information from WMIC - cmd = list2cmdline(['wmic', 'cpu']) - info = __salt__['cmd.run'](cmd).split('\r\n') - - # Find the location of LoadPercentage - column = info[0].index('LoadPercentage') - - # Get the end of the number. - end = info[1].index(' ', column+1) + cmd = list2cmdline(['wmic', 'cpu', 'get', 'loadpercentage', '/value']) + info = __salt__['cmd.run'](cmd).split('=') # Return pull it out of the informatin and cast it to an int - return int(info[1][column:end]) + return int(info[1]) def diskusage(human_readable=False, path=None): @@ -216,18 +210,9 @@ def uptime(human_readable=False): ''' # Open up a subprocess to get information from WMIC - cmd = list2cmdline(['wmic', 'os', 'get', 'lastbootuptime']) - outs = __salt__['cmd.run'](cmd) + cmd = list2cmdline(['wmic', 'os', 'get', 'lastbootuptime', '/value']) + startup_time = __salt__['cmd.run'](cmd).split('=')[1][:14] - # Get the line that has when the computer started in it: - stats_line = '' - # use second line from output - stats_line = outs.split('\r\n')[1] - - # Extract the time string from the line and parse - # - # Get string, just use the leading 14 characters - startup_time = stats_line[:14] # Convert to time struct startup_time = time.strptime(startup_time, '%Y%m%d%H%M%S') # Convert to datetime object From f08cbd67b469de8373040a326b7c556feb22df88 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 21 Feb 2017 12:06:42 -0700 Subject: [PATCH 049/370] Explain what changing the mine_interval on the minion does and how to have all the minions update at will --- doc/topics/mine/index.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/topics/mine/index.rst b/doc/topics/mine/index.rst index fd40539fff..3c313714f2 100644 --- a/doc/topics/mine/index.rst +++ b/doc/topics/mine/index.rst @@ -184,12 +184,22 @@ the output: network.ip_addrs: - eth0 +Mine data is typically only updated on the master every 60 minutes, this can +be modified by setting: + :file:`/etc/salt/minion.d/mine.conf`: .. code-block:: yaml mine_interval: 5 +To force the mine data to update immediately run: + +.. code-block:: bash + + salt '*' mine.update + + :file:`/srv/salt/haproxy.sls`: .. code-block:: yaml From 837c32e67321e309867554487b960dcf048b0df2 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 21 Feb 2017 12:11:56 -0700 Subject: [PATCH 050/370] Remove list2cmdline --- salt/modules/win_status.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 0c9e137c4e..54e31902c6 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -82,11 +82,8 @@ def cpuload(): ''' # Pull in the information from WMIC - cmd = list2cmdline(['wmic', 'cpu', 'get', 'loadpercentage', '/value']) - info = __salt__['cmd.run'](cmd).split('=') - - # Return pull it out of the informatin and cast it to an int - return int(info[1]) + cmd = ['wmic', 'cpu', 'get', 'loadpercentage', '/value'] + return int(__salt__['cmd.run'](cmd).split('=')[1]) def diskusage(human_readable=False, path=None): @@ -210,7 +207,7 @@ def uptime(human_readable=False): ''' # Open up a subprocess to get information from WMIC - cmd = list2cmdline(['wmic', 'os', 'get', 'lastbootuptime', '/value']) + cmd = ['wmic', 'os', 'get', 'lastbootuptime', '/value'] startup_time = __salt__['cmd.run'](cmd).split('=')[1][:14] # Convert to time struct From 99fd63586f607d6305dc5d68e37c610a42a6f6ec Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 21 Feb 2017 12:34:18 -0700 Subject: [PATCH 051/370] Better explain what we are setting in these files for new users. Also note where the variable server comes from. --- doc/topics/mine/index.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/topics/mine/index.rst b/doc/topics/mine/index.rst index 3c313714f2..9d9c2a511b 100644 --- a/doc/topics/mine/index.rst +++ b/doc/topics/mine/index.rst @@ -199,7 +199,7 @@ To force the mine data to update immediately run: salt '*' mine.update - +Setup the :py:mod:`salt.states.file.managed` state in :file:`/srv/salt/haproxy.sls`: .. code-block:: yaml @@ -210,7 +210,7 @@ To force the mine data to update immediately run: - source: salt://haproxy_config - template: jinja -:file:`/srv/salt/haproxy_config`: +Create the Jinja template in :file:`/srv/salt/haproxy_config`: .. code-block:: yaml @@ -222,6 +222,8 @@ To force the mine data to update immediately run: <...file contents snipped...> +In the above example, ``server`` will be expanded to the ``minion_id``. + .. note:: The expr_form argument will be renamed to ``tgt_type`` in the Nitrogen release of Salt. From d5453e2f9e6a00d9b22bb64435c3222743da6fd6 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 21 Feb 2017 13:34:31 -0700 Subject: [PATCH 052/370] Remove unused import (lint) --- salt/modules/win_status.py | 1 - 1 file changed, 1 deletion(-) diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 54e31902c6..4ba74cbc02 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -17,7 +17,6 @@ import ctypes import sys import time import datetime -from subprocess import list2cmdline import logging log = logging.getLogger(__name__) From 6d645cae0ed4e807809e9dd0bf88559f6a484914 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 21 Feb 2017 14:54:21 -0700 Subject: [PATCH 053/370] Add __virtual__ function --- salt/states/ssh_known_hosts.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/salt/states/ssh_known_hosts.py b/salt/states/ssh_known_hosts.py index fce1043839..d8ebee3122 100644 --- a/salt/states/ssh_known_hosts.py +++ b/salt/states/ssh_known_hosts.py @@ -27,6 +27,25 @@ import os import salt.utils from salt.exceptions import CommandNotFoundError +# Define the state's virtual name +__virtualname__ = 'ssh_known_hosts' + + +def __virtual__(): + ''' + Does not work on Windows, requires ssh module functions + ''' + if salt.utils.is_windows(): + return False, 'ssh_known_hosts: Does not support Windows' + + if 'ssh.set_known_host' not in __salt__ \ + or 'ssh.check_known_host' not in __salt__ \ + or 'ssh.get_known_host' not in __salt__ \ + or 'ssh.rm_known_host' not in __salt__: + return False, 'ssh_known_hosts: Missing required module "ssh"' + + return __virtualname__ + def present( name, From 984f3def298bf631e419ab7ad19011a6807678e8 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 21 Feb 2017 15:50:31 -0700 Subject: [PATCH 054/370] Allow SPM to install all module types --- salt/config/__init__.py | 3 +++ salt/spm/pkgfiles/local.py | 34 ++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 3abbe29ca9..869258c542 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -1615,6 +1615,9 @@ DEFAULT_SPM_OPTS = { 'spm_db': os.path.join(salt.syspaths.CACHE_DIR, 'spm', 'packages.db'), 'cache': 'localfs', 'spm_repo_dups': 'ignore', + # If set, spm_node_type will be either master or minion, but they should + # NOT be a default + 'spm_node_type': '', # <---- Salt master settings overridden by SPM ---------------------- } diff --git a/salt/spm/pkgfiles/local.py b/salt/spm/pkgfiles/local.py index 5f35d96870..7f266f3fe3 100644 --- a/salt/spm/pkgfiles/local.py +++ b/salt/spm/pkgfiles/local.py @@ -39,6 +39,8 @@ def check_existing(package, pkg_files, formula_def, conn=None): if conn is None: conn = init() + node_type = str(__opts__.get('spm_node_type')) + existing_files = [] for member in pkg_files: if member.isdir(): @@ -50,8 +52,17 @@ def check_existing(package, pkg_files, formula_def, conn=None): continue if member.name.startswith('{0}/_'.format(package)): - # Module files are distributed via _modules, _states, etc - out_file = os.path.join(conn['formula_path'], new_name) + if node_type in ('master', 'minion'): + # Module files are distributed via extmods directory + out_file = os.path.join( + salt.syspaths.CACHE_DIR, + node_type, + 'extmods', + new_name.replace('_', ''), + ) + else: + # Module files are distributed via _modules, _states, etc + out_file = os.path.join(conn['formula_path'], new_name) elif member.name == '{0}/pillar.example'.format(package): # Pillars are automatically put in the pillar_path new_name = '{0}.sls.orig'.format(package) @@ -83,6 +94,8 @@ def install_file(package, formula_tar, member, formula_def, conn=None): if conn is None: conn = init() + node_type = str(__opts__.get('spm_node_type')) + out_path = conn['formula_path'] tld = formula_def.get('top_level_dir', package) @@ -91,10 +104,19 @@ def install_file(package, formula_tar, member, formula_def, conn=None): log.debug('{0} not in top level directory, not installing'.format(new_name)) return False - if member.name.startswith('{0}/_'.format(package)): - # Module files are distributed via _modules, _states, etc - member.name = member.name.replace('{0}/'.format(package), '') - elif member.name == '{0}/pillar.example'.format(package): + if new_name.startswith('{0}/_'.format(package)): + if node_type in ('master', 'minion'): + # Module files are distributed via extmods directory + member.name = member.name.replace('{0}/_'.format(package), '') + out_path = os.path.join( + salt.syspaths.CACHE_DIR, + node_type, + 'extmods', + ) + else: + # Module files are distributed via _modules, _states, etc + member.name = member.name.replace('{0}/'.format(package), '') + elif new_name == '{0}/pillar.example'.format(package): # Pillars are automatically put in the pillar_path member.name = '{0}.sls.orig'.format(package) out_path = conn['pillar_path'] From e354247efd7b727097cf63224c88c9574c51414f Mon Sep 17 00:00:00 2001 From: Zack Hsi Date: Tue, 21 Feb 2017 17:03:48 -0800 Subject: [PATCH 055/370] Support Alpine Linux iptables --- salt/modules/iptables.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/salt/modules/iptables.py b/salt/modules/iptables.py index e565f50194..9940dd275a 100644 --- a/salt/modules/iptables.py +++ b/salt/modules/iptables.py @@ -107,6 +107,11 @@ def _conf(family='ipv4'): elif __grains__['os_family'] == 'SUSE': # SuSE does not seem to use separate files for IPv4 and IPv6 return '/etc/sysconfig/scripts/SuSEfirewall2-custom' + elif __grains__['os'] == 'Alpine': + if family == 'ipv6': + return '/etc/iptables/rules6-save' + else: + return '/etc/iptables/rules-save' else: raise SaltException('Saving iptables to file is not' + ' supported on {0}.'.format(__grains__['os']) + From 22b78aa984134ced8b11b502a45792870e72b76b Mon Sep 17 00:00:00 2001 From: coutotyler Date: Tue, 21 Feb 2017 18:19:16 -0800 Subject: [PATCH 056/370] Adding loop state --- tests/unit/states/loop.py | 107 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 tests/unit/states/loop.py diff --git a/tests/unit/states/loop.py b/tests/unit/states/loop.py new file mode 100644 index 0000000000..a62734c461 --- /dev/null +++ b/tests/unit/states/loop.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +''' +Loop state + +Allows for looping over execution modules. + +.. code-block:: yaml + + wait_for_service_to_be_healthy: + loop.until: + - name: boto_elb.get_instance_health + - condition: m_ret[0]['state'] == 'InService' + - period: 5 + - timeout: 20 + - m_args: + - {{ elb }} + - m_kwargs: + keyid: {{ access_key }} + key: {{ secret_key }} + instances: "{{ instance }}" +''' +from __future__ import absolute_import + +# Import python libs +import logging +import time + +# Import salt libs +import salt.utils + +# Initialize logging +log = logging.getLogger(__name__) + +# Define the module's virtual name +__virtualname__ = 'loop' + +def __virtual__(): + return True + +def until(name, + m_args=None, + m_kwargs=None, + condition=None, + period=None, + timeout=None): + ''' + Loop over an execution module until a condition is met. + + name + The name of the execution module + + m_args + The execution module's positional arguments + + m_kwargs + The execution module's keyword arguments + + condition + The condition which must be met for the loop to break. This + should contain ``m_ret`` which is the return from the execution + module. + + period + The number of seconds to wait between executions + + timeout + The timeout in seconds + ''' + ret = {'name': name, + 'changes': {}, + 'result': False, + 'comment': ''} + + if name not in __salt__: + ret['comment'] = "Can't find module {0}".format(name) + return ret + if condition is None: + ret['comment'] = 'An exit condition must be specified' + return ret + try: + period = int(period) + except ValueError: + ret['comment'] = 'Period must be specified in seconds' + try: + timeout = int(timeout) + except ValueError: + ret['comment'] = 'Timeout must be specified in seconds' + + def timed_out(): + if timeout is None: + return False + if time.time() >= timeout: + return True + return False + + timeout = time.time() + timeout + + while not timed_out(): + m_ret = __salt__[name](*m_args, **m_kwargs) + if eval(condition): + ret['result'] = True + ret['comment'] = 'Condition {0} was met'.format(condition) + return ret + time.sleep(period) + + ret['comment'] = 'Timed out while waiting for condition {0}'.format(condition) + return ret From 26c1280aa420cb303dd37bacd2ca93973ecb051f Mon Sep 17 00:00:00 2001 From: Sergei Zviagintsev Date: Mon, 20 Feb 2017 11:29:47 +0100 Subject: [PATCH 057/370] Fix condition in if-statement The latter part of the condition would never succeed. Remove it. Update the comment. --- salt/cloud/clouds/ec2.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py index 1b6c665ba5..af4a3d7fd7 100644 --- a/salt/cloud/clouds/ec2.py +++ b/salt/cloud/clouds/ec2.py @@ -2511,10 +2511,9 @@ def create(vm_=None, call=None): key_filename = config.get_cloud_config_value( 'private_key', vm_, __opts__, search_global=False, default=None ) - if deploy or (deploy and win_password == 'auto'): + if deploy: # The private_key and keyname settings are only needed for bootstrapping - # new instances when deploy is True, or when win_password is set to 'auto' - # and deploy is also True. + # new instances when deploy is True if key_filename is None: raise SaltCloudSystemExit( 'The required \'private_key\' configuration setting is missing from the ' From 4f1bb33018f6117e38d914370cb52a4c4621d55f Mon Sep 17 00:00:00 2001 From: Sergei Zviagintsev Date: Mon, 20 Feb 2017 22:18:56 +0100 Subject: [PATCH 058/370] ec2: Move key file path and mode validation into separate function Move the key file existence and mode validation from create() into a separate function, so we can write unit tests for it and make create() simpler. --- salt/cloud/clouds/ec2.py | 48 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py index af4a3d7fd7..b78add70af 100644 --- a/salt/cloud/clouds/ec2.py +++ b/salt/cloud/clouds/ec2.py @@ -2481,6 +2481,31 @@ def wait_for_instance( return vm_ +def _validate_key_path_and_mode(key_filename): + if key_filename is None: + raise SaltCloudSystemExit( + 'The required \'private_key\' configuration setting is missing from the ' + '\'ec2\' driver.' + ) + + if not os.path.exists(key_filename): + raise SaltCloudSystemExit( + 'The EC2 key file \'{0}\' does not exist.\n'.format( + key_filename + ) + ) + + key_mode = str( + oct(stat.S_IMODE(os.stat(key_filename).st_mode)) + ) + if key_mode not in ('0400', '0600'): + raise SaltCloudSystemExit( + 'The EC2 key file \'{0}\' needs to be set to mode 0400 or 0600.\n'.format( + key_filename + ) + ) + + return True def create(vm_=None, call=None): ''' @@ -2514,28 +2539,7 @@ def create(vm_=None, call=None): if deploy: # The private_key and keyname settings are only needed for bootstrapping # new instances when deploy is True - if key_filename is None: - raise SaltCloudSystemExit( - 'The required \'private_key\' configuration setting is missing from the ' - '\'ec2\' driver.' - ) - - if not os.path.exists(key_filename): - raise SaltCloudSystemExit( - 'The EC2 key file \'{0}\' does not exist.\n'.format( - key_filename - ) - ) - - key_mode = str( - oct(stat.S_IMODE(os.stat(key_filename).st_mode)) - ) - if key_mode not in ('0400', '0600'): - raise SaltCloudSystemExit( - 'The EC2 key file \'{0}\' needs to be set to mode 0400 or 0600.\n'.format( - key_filename - ) - ) + _validate_key_path_and_mode(key_filename) __utils__['cloud.fire_event']( 'event', From 313e9cae068192fe11ad10ea0b5c05061b0e5c60 Mon Sep 17 00:00:00 2001 From: Sergei Zviagintsev Date: Mon, 20 Feb 2017 22:21:05 +0100 Subject: [PATCH 059/370] Add unit test for _validate_key_file_permissions in ec2 module --- tests/unit/cloud/clouds/ec2_test.py | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/unit/cloud/clouds/ec2_test.py diff --git a/tests/unit/cloud/clouds/ec2_test.py b/tests/unit/cloud/clouds/ec2_test.py new file mode 100644 index 0000000000..5f5125560b --- /dev/null +++ b/tests/unit/cloud/clouds/ec2_test.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +# Import Python libs +from __future__ import absolute_import +import os +import tempfile + +# Import Salt Libs +from salt.cloud.clouds import ec2 +from salt.exceptions import SaltCloudSystemExit + +# Import Salt Testing Libs +from salttesting import TestCase, skipIf +from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch +from salttesting.helpers import ensure_in_syspath + +ensure_in_syspath('../../../') + +@skipIf(NO_MOCK, NO_MOCK_REASON) +class EC2TestCase(TestCase): + ''' + Unit TestCase for salt.cloud.clouds.ec2 module. + ''' + def test__validate_key_path_and_mode(self): + with tempfile.NamedTemporaryFile() as f: + key_file = f.name + + os.chmod(key_file, 0o644) + self.assertRaises(SaltCloudSystemExit, + ec2._validate_key_path_and_mode, + key_file) + os.chmod(key_file, 0o600) + self.assertTrue(ec2._validate_key_path_and_mode(key_file)) + os.chmod(key_file, 0o400) + self.assertTrue(ec2._validate_key_path_and_mode(key_file)) + + # tmp file removed + self.assertRaises(SaltCloudSystemExit, + ec2._validate_key_path_and_mode, + key_file) + +if __name__ == '__main__': + from unit import run_tests + run_tests(EC2TestCase, needs_daemon=False) From ad5b52ce3c78d12f262159d18327c91a1316951b Mon Sep 17 00:00:00 2001 From: Sergei Zviagintsev Date: Mon, 20 Feb 2017 12:15:43 +0100 Subject: [PATCH 060/370] Add unit test for salt.utils.cloud.check_key_path_and_mode --- tests/unit/utils/cloud_test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit/utils/cloud_test.py b/tests/unit/utils/cloud_test.py index d26585e2c7..311e009dac 100644 --- a/tests/unit/utils/cloud_test.py +++ b/tests/unit/utils/cloud_test.py @@ -12,6 +12,7 @@ # Import Python libs from __future__ import absolute_import import os +import tempfile # Import Salt Testing libs from salttesting import TestCase, skipIf @@ -124,6 +125,20 @@ class CloudUtilsTestCase(TestCase): # we successful pass the place with os.write(tmpfd, ... self.assertNotEqual("a bytes-like object is required, not 'str'", str(context.exception)) + def test_check_key_path_and_mode(self): + with tempfile.NamedTemporaryFile() as f: + key_file = f.name + + os.chmod(key_file, 0o644) + self.assertFalse(cloud.check_key_path_and_mode('foo', key_file)) + os.chmod(key_file, 0o600) + self.assertTrue(cloud.check_key_path_and_mode('foo', key_file)) + os.chmod(key_file, 0o400) + self.assertTrue(cloud.check_key_path_and_mode('foo', key_file)) + + # tmp file removed + self.assertFalse(cloud.check_key_path_and_mode('foo', key_file)) + if __name__ == '__main__': from integration import run_tests run_tests(CloudUtilsTestCase, needs_daemon=False) From 8c515fcade925d81f960e02e6803a029ab8affc5 Mon Sep 17 00:00:00 2001 From: Sergei Zviagintsev Date: Thu, 15 Dec 2016 02:03:20 +0100 Subject: [PATCH 061/370] Make file perms check Python 3 compatible Compare file mode with Python 2-3 compatible octal constants. --- salt/cloud/clouds/ec2.py | 6 ++---- salt/utils/cloud.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py index b78add70af..df02736e7f 100644 --- a/salt/cloud/clouds/ec2.py +++ b/salt/cloud/clouds/ec2.py @@ -2495,10 +2495,8 @@ def _validate_key_path_and_mode(key_filename): ) ) - key_mode = str( - oct(stat.S_IMODE(os.stat(key_filename).st_mode)) - ) - if key_mode not in ('0400', '0600'): + key_mode = stat.S_IMODE(os.stat(key_filename).st_mode) + if key_mode not in (0o400, 0o600): raise SaltCloudSystemExit( 'The EC2 key file \'{0}\' needs to be set to mode 0400 or 0600.\n'.format( key_filename diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py index fc5643f747..ed41f79f40 100644 --- a/salt/utils/cloud.py +++ b/salt/utils/cloud.py @@ -3207,8 +3207,8 @@ def check_key_path_and_mode(provider, key_path): ) return False - key_mode = str(oct(stat.S_IMODE(os.stat(key_path).st_mode))) - if key_mode not in ('0400', '0600'): + key_mode = stat.S_IMODE(os.stat(key_path).st_mode) + if key_mode not in (0o400, 0o600): log.error( 'The key file \'{0}\' used in the \'{1}\' provider configuration ' 'needs to be set to mode 0400 or 0600.\n'.format( From 7a6fc11291bdc6980baf88df03726c0d6f8ad9aa Mon Sep 17 00:00:00 2001 From: Dmitry Kuzmenko Date: Wed, 22 Feb 2017 14:06:26 +0300 Subject: [PATCH 062/370] Cosmetic: support bool value for 'ssl' config option. This is useful for minion config which doesn't need anything to be set in ssl opts, but needs to enable it. In this case `ssl: True` looks better than `ssl: {}` in yaml config. --- salt/config/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 4ad9f04bd3..f7f8723ce3 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -932,7 +932,7 @@ VALID_OPTS = { # http://docs.python.org/2/library/ssl.html#ssl.wrap_socket # Note: to set enum arguments values like `cert_reqs` and `ssl_version` use constant names # without ssl module prefix: `CERT_REQUIRED` or `PROTOCOL_SSLv23`. - 'ssl': (dict, type(None)), + 'ssl': (dict, bool, type(None)), # django auth 'django_auth_path': str, @@ -3106,7 +3106,11 @@ def _update_ssl_config(opts): ''' Resolves string names to integer constant in ssl configuration. ''' - if opts['ssl'] is None: + if opts['ssl'] in (None, False): + opts['ssl'] = None + return + if opts['ssl'] is True: + opts['ssl'] = {} return import ssl for key, prefix in (('cert_reqs', 'CERT_'), From d405e1c81ecb5634aa0493a4ecc34c792f608120 Mon Sep 17 00:00:00 2001 From: Sergei Zviagintsev Date: Sun, 19 Feb 2017 22:28:23 +0100 Subject: [PATCH 063/370] Fix UnboundLocalError in salt.scripts.salt_cloud Importing salt.cloud inside the function causes the 'salt' name to be treated as local. If the event of ImportError, the function will fail with UnboundLocalError trying to get salt.defaults.exitcodes.EX_UNAVAILABLE: (py2-env) salt-test@tommynaut:~> python Python 2.7.13 (default, Jan 03 2017, 17:41:54) [GCC] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import salt.scripts >>> from mock import MagicMock, patch >>> >>> def die(*args): ... raise ImportError ... >>> mock = MagicMock(side_effect=die) >>> >>> with patch('__builtin__.__import__', mock): ... salt.scripts.salt_cloud() ... No handlers could be found for logger "salt.scripts" salt-cloud is not available in this system Traceback (most recent call last): File "", line 2, in File "/home/salt-test/salt/salt/scripts.py", line 447, in salt_cloud sys.exit(salt.defaults.exitcodes.EX_UNAVAILABLE) UnboundLocalError: local variable 'salt' referenced before assignment Declare the 'salt' name global to fix this. --- salt/scripts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/salt/scripts.py b/salt/scripts.py index bbe83c38cb..78b82b664b 100644 --- a/salt/scripts.py +++ b/salt/scripts.py @@ -430,6 +430,10 @@ def salt_cloud(): ''' The main function for salt-cloud ''' + # Define 'salt' global so we may use it after ImportError. Otherwise, + # UnboundLocalError will be raised. + global salt + try: # Late-imports for CLI performance import salt.cloud From 663cca762e1deb7e15ef6253ef6f064ed7f22ef1 Mon Sep 17 00:00:00 2001 From: Sergei Zviagintsev Date: Mon, 20 Feb 2017 09:33:45 +0100 Subject: [PATCH 064/370] Remove redundant variable Instead of using the intermediate 'has_saltcloud' variable report error in the except clause. --- salt/scripts.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/salt/scripts.py b/salt/scripts.py index 78b82b664b..84a7b47ce3 100644 --- a/salt/scripts.py +++ b/salt/scripts.py @@ -438,17 +438,13 @@ def salt_cloud(): # Late-imports for CLI performance import salt.cloud import salt.cloud.cli - has_saltcloud = True except ImportError as e: - log.error("Error importing salt cloud {0}".format(e)) # No salt cloud on Windows - has_saltcloud = False - if '' in sys.path: - sys.path.remove('') - - if not has_saltcloud: + log.error("Error importing salt cloud {0}".format(e)) print('salt-cloud is not available in this system') sys.exit(salt.defaults.exitcodes.EX_UNAVAILABLE) + if '' in sys.path: + sys.path.remove('') client = salt.cloud.cli.SaltCloud() _install_signal_handlers(client) From f5cb8749efe9ab3a8b6719ae90ded8bddc8ed6e9 Mon Sep 17 00:00:00 2001 From: "marco.messerschmidt" Date: Wed, 22 Feb 2017 13:26:02 +0100 Subject: [PATCH 065/370] initial fix --- salt/modules/mount.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/salt/modules/mount.py b/salt/modules/mount.py index 6b2ad6e900..b99c03dd12 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -82,7 +82,7 @@ def _active_mountinfo(ret): 'root': comps[3], 'opts': _resolve_user_group_names(comps[5].split(',')), 'fstype': comps[_sep + 1], - 'device': device_name, + 'device': device_name.replace('\\040','\\ '), 'alt_device': _list.get(comps[4], None), 'superopts': _resolve_user_group_names(comps[_sep + 3].split(',')), 'device_uuid': device_uuid, @@ -102,6 +102,7 @@ def _active_mounts(ret): with salt.utils.fopen(filename) as ifile: for line in ifile: + log.info('in _active_mounts line: {}'.format(line)) comps = line.split() ret[comps[1]] = {'device': comps[0], 'alt_device': _list.get(comps[1], None), @@ -539,7 +540,7 @@ def set_fstab( # preserve arguments for updating entry_args = { 'name': name, - 'device': device, + 'device': device.replace('\\ ','\\040'), 'fstype': fstype, 'opts': opts, 'dump': dump, From d89194597a07c97775a2fbb3761229d1e313659a Mon Sep 17 00:00:00 2001 From: "marco.messerschmidt" Date: Wed, 22 Feb 2017 13:37:11 +0100 Subject: [PATCH 066/370] adjust escaping --- salt/modules/mount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/mount.py b/salt/modules/mount.py index b99c03dd12..ba6019be39 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -82,7 +82,7 @@ def _active_mountinfo(ret): 'root': comps[3], 'opts': _resolve_user_group_names(comps[5].split(',')), 'fstype': comps[_sep + 1], - 'device': device_name.replace('\\040','\\ '), + 'device': device_name.replace('\\040','\ '), 'alt_device': _list.get(comps[4], None), 'superopts': _resolve_user_group_names(comps[_sep + 3].split(',')), 'device_uuid': device_uuid, @@ -540,7 +540,7 @@ def set_fstab( # preserve arguments for updating entry_args = { 'name': name, - 'device': device.replace('\\ ','\\040'), + 'device': device.replace('\ ','\\040'), 'fstype': fstype, 'opts': opts, 'dump': dump, From 1a01c110452fc4ede472a5f7b3b1230e2c7f925e Mon Sep 17 00:00:00 2001 From: Heghedus Razvan Date: Tue, 21 Feb 2017 14:25:50 +0200 Subject: [PATCH 067/370] system: multi line support in computer description Special characters like \n \t are not escaped, so it's impossible to set a multi line computer description. To fix this I escaped all special characters. Signed-off-by: Heghedus Razvan --- salt/modules/system.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/salt/modules/system.py b/salt/modules/system.py index 1632d290c8..c2d1841991 100644 --- a/salt/modules/system.py +++ b/salt/modules/system.py @@ -11,6 +11,7 @@ import os.path # Import salt libs import salt.utils +import salt.ext.six as six from salt.exceptions import CommandExecutionError, SaltInvocationError @@ -504,10 +505,14 @@ def get_computer_desc(): match = pattern.match(line) if match: # get rid of whitespace then strip off quotes - desc = _strip_quotes(match.group(1).strip()).replace('\\"', '"') + desc = _strip_quotes(match.group(1).strip()) # no break so we get the last occurance except IOError: return False + if six.PY3: + desc = desc.replace('\\"', '"').decode('unicode_escape') + else: + desc = desc.replace('\\"', '"').decode('string_escape') return desc @@ -526,9 +531,13 @@ def set_computer_desc(desc): salt '*' system.set_computer_desc "Michael's laptop" ''' + if six.PY3: + desc = desc.encode('unicode_escape').replace('"', '\\"') + else: + desc = desc.encode('string_escape').replace('"', '\\"') hostname_cmd = salt.utils.which('hostnamectl') if hostname_cmd: - result = __salt__['cmd.retcode']('{0} set-hostname --pretty {1}'.format(hostname_cmd, desc)) + result = __salt__['cmd.retcode']('{0} set-hostname --pretty "{1}"'.format(hostname_cmd, desc)) return True if result == 0 else False if not os.path.isfile('/etc/machine-info'): @@ -537,7 +546,7 @@ def set_computer_desc(desc): is_pretty_hostname_found = False pattern = re.compile(r'^\s*PRETTY_HOSTNAME=(.*)$') - new_line = 'PRETTY_HOSTNAME="{0}"'.format(desc.replace('"', '\\"')) + new_line = 'PRETTY_HOSTNAME="{0}"'.format(desc) try: with salt.utils.fopen('/etc/machine-info', 'r+') as mach_info: lines = mach_info.readlines() From 567bb50884a193346471673a52741f9b1d407a43 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 22 Feb 2017 16:52:04 +0200 Subject: [PATCH 068/370] [CLOUD] Log error when private/public IP was not detected --- salt/cloud/clouds/ec2.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py index c99f6b0c79..33a4105a3e 100644 --- a/salt/cloud/clouds/ec2.py +++ b/salt/cloud/clouds/ec2.py @@ -2122,14 +2122,21 @@ def query_instance(vm_=None, call=None): log.debug('Returned query data: {0}'.format(data)) - if ssh_interface(vm_) == 'public_ips' and 'ipAddress' in data[0]['instancesSet']['item']: - log.error( - 'Public IP not detected.' - ) - return data - if ssh_interface(vm_) == 'private_ips' and \ - 'privateIpAddress' in data[0]['instancesSet']['item']: - return data + if ssh_interface(vm_) == 'public_ips': + if 'ipAddress' in data[0]['instancesSet']['item']: + return data + else: + log.error( + 'Public IP not detected.' + ) + + if ssh_interface(vm_) == 'private_ips': + if 'privateIpAddress' in data[0]['instancesSet']['item']: + return data + else: + log.error( + 'Private IP not detected.' + ) try: data = salt.utils.cloud.wait_for_ip( From c50374041d87b3611b2d133fc342bd55c0d95983 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 22 Feb 2017 09:20:49 -0600 Subject: [PATCH 069/370] Add ulimits to dockerng state/exec module --- salt/modules/dockerng.py | 56 +++++++++++++++++++++++++++++++++++++--- salt/states/dockerng.py | 30 ++++++++++++++++++++- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index 817dc4f0ab..14aaf434e0 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -554,6 +554,12 @@ VALID_CREATE_OPTS = { 'min_docker': (1, 5, 0), 'default': '', }, + 'ulimits': { + 'path': 'HostConfig:Ulimits', + 'min_docker': (1, 6, 0), + 'min_docker_py': (1, 2, 0), + 'default': [], + }, } @@ -1792,6 +1798,44 @@ def _validate_input(kwargs, else: kwargs['labels'] = salt.utils.repack_dictlist(kwargs['labels']) + def _valid_ulimits(): # pylint: disable=unused-variable + ''' + Must be a string or list of strings with bind mount information + ''' + if kwargs.get('ulimits') is None: + # No need to validate + return + err = ( + 'Invalid ulimits configuration. See the documentation for proper ' + 'usage.' + ) + try: + _valid_dictlist('ulimits') + # If this was successful then assume the correct API value was + # passed on on the CLI and do not proceed with validation. + return + except SaltInvocationError: + pass + try: + _valid_stringlist('ulimits') + except SaltInvocationError: + raise SaltInvocationError(err) + + new_ulimits = [] + for ulimit in kwargs['ulimits']: + ulimit_name, comps = ulimit.strip().split('=', 1) + try: + comps = [int(x) for x in comps.split(':', 1)] + except ValueError: + raise SaltInvocationError(err) + if len(comps) == 1: + comps *= 2 + soft_limit, hard_limit = comps + new_ulimits.append({'Name': ulimit_name, + 'Soft': soft_limit, + 'Hard': hard_limit}) + kwargs['ulimits'] = new_ulimits + # And now, the actual logic to perform the validation if 'docker.docker_version' not in __context__: # Have to call this func using the __salt__ dunder (instead of just @@ -5557,11 +5601,15 @@ def get_client_args(): except AttributeError: try: endpoint_config_args = \ - _argspec(docker.utils.create_endpoint_config).args + _argspec(docker.utils.utils.create_endpoint_config).args except AttributeError: - raise CommandExecutionError( - 'Failed to get create_host_config argspec' - ) + try: + endpoint_config_args = \ + _argspec(docker.utils.create_endpoint_config).args + except AttributeError: + raise CommandExecutionError( + 'Failed to get create_endpoint_config argspec' + ) for arglist in (config_args, host_config_args, endpoint_config_args): try: diff --git a/salt/states/dockerng.py b/salt/states/dockerng.py index 358a5091e5..30f3df5c76 100644 --- a/salt/states/dockerng.py +++ b/salt/states/dockerng.py @@ -50,7 +50,8 @@ from salt.modules.dockerng import ( STOP_TIMEOUT, VALID_CREATE_OPTS, _validate_input, - _get_repo_tag + _get_repo_tag, + _get_docker_py_versioninfo, ) # pylint: enable=no-name-in-module,import-error import salt.utils @@ -240,6 +241,7 @@ def _compare(actual, create_kwargs, defaults_from_image): ret.update({item: {'old': actual_ports, 'new': desired_ports}}) continue + elif item == 'volumes': if actual_data is None: actual_data = [] @@ -411,6 +413,7 @@ def _compare(actual, create_kwargs, defaults_from_image): # sometimes `[]`. We have to deal with it. if bool(actual_data) != bool(data): ret.update({item: {'old': actual_data, 'new': data}}) + elif item == 'labels': if actual_data is None: actual_data = {} @@ -426,6 +429,7 @@ def _compare(actual, create_kwargs, defaults_from_image): if actual_data != data: ret.update({item: {'old': actual_data, 'new': data}}) continue + elif item == 'security_opt': if actual_data is None: actual_data = [] @@ -441,6 +445,7 @@ def _compare(actual, create_kwargs, defaults_from_image): ret.update({item: {'old': actual_data, 'new': desired_data}}) continue + elif item in ('cmd', 'command', 'entrypoint'): if (actual_data is None and item not in create_kwargs and _image_get(config['image_path'])): @@ -1481,6 +1486,29 @@ def running(name, This option requires Docker 1.5.0 or newer. + ulimits + List of ulimits. These limits should be passed in + the format ``::``, with the hard + limit being optional. + + .. code-block:: yaml + + foo: + dockerng.running: + - image: bar/baz:latest + - ulimits: nofile=1024:1024,nproc=60 + + Ulimits can be passed as a YAML list instead of a comma-separated list: + + .. code-block:: yaml + + foo: + dockerng.running: + - image: bar/baz:latest + - ulimits: + - nofile=1024:1024 + - nproc=60 + labels Add Metadata to the container. Can be a list of strings/dictionaries or a dictionary of strings (keys and values). From 01d4a84a2fd3c2c8d040c692cd4d8bffd6bd98b7 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 22 Feb 2017 09:51:22 -0600 Subject: [PATCH 070/370] dockerng.get_client_args: Fix path for endpoint config for some versions of docker-py (#39544) --- salt/modules/dockerng.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index bbcecfe90e..a3e00a70a4 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -5557,11 +5557,15 @@ def get_client_args(): except AttributeError: try: endpoint_config_args = \ - _argspec(docker.utils.create_endpoint_config).args + _argspec(docker.utils.utils.create_endpoint_config).args except AttributeError: - raise CommandExecutionError( - 'Failed to get create_host_config argspec' - ) + try: + endpoint_config_args = \ + _argspec(docker.utils.create_endpoint_config).args + except AttributeError: + raise CommandExecutionError( + 'Failed to get create_endpoint_config argspec' + ) for arglist in (config_args, host_config_args, endpoint_config_args): try: From b3b98a66dfae069c3a4960545dcd1ed5ed46f505 Mon Sep 17 00:00:00 2001 From: Sumit Jamgade Date: Wed, 22 Feb 2017 17:53:24 +0100 Subject: [PATCH 071/370] [msgpack] look for `datetime.datetime` in keys also while packing and `del` the old if the encoded key is different form the original one. --- salt/payload.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/salt/payload.py b/salt/payload.py index 04c1588b62..e132003066 100644 --- a/salt/payload.py +++ b/salt/payload.py @@ -224,6 +224,10 @@ class Serial(object): def datetime_encoder(obj): if isinstance(obj, dict): for key, value in six.iteritems(obj.copy()): + encodedkey = datetime_encoder(key) + if key != encodedkey: + del obj[key] + key = encodedkey obj[key] = datetime_encoder(value) return dict(obj) elif isinstance(obj, (list, tuple)): From 49da135abd341f00a619b547686cb561e43a8ac0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 22 Feb 2017 17:18:55 +0000 Subject: [PATCH 072/370] Don't use our own six dictionary fixes in this branch --- .pylintrc | 3 ++- .testing.pylintrc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 22462fed98..828166f71a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -52,7 +52,8 @@ fileperms-default=0644 fileperms-ignore-paths=tests/runtests.py,tests/jenkins*.py,tests/saltsh.py,tests/buildpackage.py # Py3 Modernize PyLint Plugin Settings -modernize-nofix = libmodernize.fixes.fix_dict_six +modernize-nofix = libmodernize.fixes.fix_dict_six, + saltpylint.py3modernize.fixes.fix_dict_salt_six # Minimum Python Version To Enforce minimum-python-version = 2.6 diff --git a/.testing.pylintrc b/.testing.pylintrc index 870a0ddfac..a826a0b3e0 100644 --- a/.testing.pylintrc +++ b/.testing.pylintrc @@ -52,7 +52,8 @@ fileperms-default=0644 fileperms-ignore-paths=tests/runtests.py,tests/jenkins*.py,tests/saltsh.py,tests/buildpackage.py # Py3 Modernize PyLint Plugin Settings -modernize-nofix = libmodernize.fixes.fix_dict_six +modernize-nofix = libmodernize.fixes.fix_dict_six, + saltpylint.py3modernize.fixes.fix_dict_salt_six # Minimum Python Version To Enforce minimum-python-version = 2.6 From 4ccb695fc2d7a3aef6e5ceb349729cb76f0750b6 Mon Sep 17 00:00:00 2001 From: coutotyler Date: Wed, 22 Feb 2017 09:29:38 -0800 Subject: [PATCH 073/370] Moving loop.py from unit tests dir to states dir where it should be --- {tests/unit => salt}/states/loop.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {tests/unit => salt}/states/loop.py (100%) diff --git a/tests/unit/states/loop.py b/salt/states/loop.py similarity index 100% rename from tests/unit/states/loop.py rename to salt/states/loop.py From 1dba2f9cb053b031866fdd7a8eb74df408cb82c9 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 22 Feb 2017 11:44:38 -0700 Subject: [PATCH 074/370] Add warning in docs --- conf/minion | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/minion b/conf/minion index 419bcc8fad..a39c1a1c2d 100644 --- a/conf/minion +++ b/conf/minion @@ -647,6 +647,10 @@ ########################################### # Disable multiprocessing support, by default when a minion receives a # publication a new process is spawned and the command is executed therein. +# +# WARNING: Disabling multiprocessing may result in substantial slowdowns +# when processing large pillars. See https://github.com/saltstack/salt/issues/38758 +# for a full explanation. #multiprocessing: True From 650dbaca4ecb0c1956e66e524995dfb16e440a71 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 22 Feb 2017 10:54:35 -0600 Subject: [PATCH 075/370] states.file.patch/modules.file.check_hash: use hash length to determine type This brings the file.patch state and file.check_hash function to parity with the source_hash handling changes made in the 2016.11 branch, by using the hash length to determine the type. It also fixes a shadowed builtin in the file.patch state. --- salt/modules/file.py | 51 ++++++++++++++++++++++++++++----------- salt/states/file.py | 57 ++++++++++++++++++++++++++------------------ 2 files changed, 71 insertions(+), 37 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 8f0c6914b6..ce792f904c 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -687,31 +687,54 @@ def check_hash(path, file_hash): ''' Check if a file matches the given hash string - Returns true if the hash matched, otherwise false. Raises ValueError if - the hash was not formatted correctly. + Returns ``True`` if the hash matches, otherwise ``False``. path - A file path + Path to a file local to the minion. + hash - A string in the form :. For example: - ``md5:e138491e9d5b97023cea823fe17bac22`` + The hash to check against the file specified in the ``path`` argument. + For versions 2016.11.4 and newer, the hash can be specified without an + accompanying hash type (e.g. ``e138491e9d5b97023cea823fe17bac22``), + but for earlier releases it is necessary to also specify the hash type + in the format ``:`` (e.g. + ``md5:e138491e9d5b97023cea823fe17bac22``). CLI Example: .. code-block:: bash - salt '*' file.check_hash /etc/fstab md5: + salt '*' file.check_hash /etc/fstab e138491e9d5b97023cea823fe17bac22 + salt '*' file.check_hash /etc/fstab md5:e138491e9d5b97023cea823fe17bac22 ''' path = os.path.expanduser(path) - hash_parts = file_hash.split(':', 1) - if len(hash_parts) != 2: - # Support "=" for backward compatibility. - hash_parts = file_hash.split('=', 1) - if len(hash_parts) != 2: - raise ValueError('Bad hash format: \'{0}\''.format(file_hash)) - hash_form, hash_value = hash_parts - return get_hash(path, hash_form) == hash_value + if not isinstance(file_hash, six.string_types): + raise SaltInvocationError('hash must be a string') + + for sep in (':', '='): + if sep in file_hash: + hash_type, hash_value = file_hash.split(sep, 1) + break + else: + hash_value = file_hash + hash_len = len(file_hash) + hash_type = HASHES_REVMAP.get(hash_len) + if hash_type is None: + raise SaltInvocationError( + 'Hash {0} (length: {1}) could not be matched to a supported ' + 'hash type. The supported hash types and lengths are: ' + '{2}'.format( + file_hash, + hash_len, + ', '.join( + ['{0} ({1})'.format(HASHES_REVMAP[x], x) + for x in sorted(HASHES_REVMAP)] + ), + ) + ) + + return get_hash(path, hash_type) == hash_value def find(path, *args, **kwargs): diff --git a/salt/states/file.py b/salt/states/file.py index 7d90055fc3..a74322da0d 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -281,7 +281,7 @@ import salt.utils.dictupdate import salt.utils.templates import salt.utils.url from salt.utils.locales import sdecode -from salt.exceptions import CommandExecutionError +from salt.exceptions import CommandExecutionError, SaltInvocationError # Import 3rd-party libs import salt.ext.six as six @@ -4372,7 +4372,6 @@ def prepend(name, def patch(name, source=None, - hash=None, options='', dry_run_first=True, **kwargs): @@ -4394,10 +4393,13 @@ def patch(name, salt://spam/eggs. A source is required. hash - Hash of the patched file. If the hash of the target file matches this - value then the patch is assumed to have been applied. The hash string - is the hash algorithm followed by the hash of the file: - md5=e138491e9d5b97023cea823fe17bac22 + The hash of the patched file. If the hash of the target file matches + this value then the patch is assumed to have been applied. For versions + 2016.11.4 and newer, the hash can be specified without an accompanying + hash type (e.g. ``e138491e9d5b97023cea823fe17bac22``), but for earlier + releases it is necessary to also specify the hash type in the format + ``:`` (e.g. + ``md5:e138491e9d5b97023cea823fe17bac22``). options Extra options to pass to patch. @@ -4410,7 +4412,7 @@ def patch(name, by the ``source`` parameter. If not provided, this defaults to the environment from which the state is being executed. - Usage: + **Usage:** .. code-block:: yaml @@ -4418,8 +4420,15 @@ def patch(name, /opt/file.txt: file.patch: - source: salt://file.patch - - hash: md5=e138491e9d5b97023cea823fe17bac22 + - hash: e138491e9d5b97023cea823fe17bac22 + + .. note:: + For minions running version 2016.11.3 or older, the hash in the example + above would need to be specified with the hash type (i.e. + ``md5:e138491e9d5b97023cea823fe17bac22``). ''' + hash_ = kwargs.pop('hash', None) + if 'env' in kwargs: salt.utils.warn_until( 'Oxygen', @@ -4439,11 +4448,16 @@ def patch(name, return _error(ret, check_msg) if not source: return _error(ret, 'Source is required') - if hash is None: + if hash_ is None: return _error(ret, 'Hash is required') - if hash and __salt__['file.check_hash'](name, hash): - ret.update(result=True, comment='Patch is already applied') + try: + if hash_ and __salt__['file.check_hash'](name, hash_): + ret['result'] = True + ret['comment'] = 'Patch is already applied' + return ret + except (SaltInvocationError, ValueError) as exc: + ret['comment'] = exc.__str__() return ret # get cached file or copy it to cache @@ -4454,9 +4468,8 @@ def patch(name, return ret log.debug( - 'State patch.applied cached source {0} -> {1}'.format( - source, cached_source_path - ) + 'State patch.applied cached source %s -> %s', + source, cached_source_path ) if dry_run_first or __opts__['test']: @@ -4467,20 +4480,18 @@ def patch(name, ret['comment'] = 'File {0} will be patched'.format(name) ret['result'] = None return ret - if ret['changes']['retcode']: + if ret['changes']['retcode'] != 0: return ret ret['changes'] = __salt__['file.patch']( name, cached_source_path, options=options ) - ret['result'] = not ret['changes']['retcode'] - if ret['result'] and hash and not __salt__['file.check_hash'](name, hash): - ret.update( - result=False, - comment='File {0} hash mismatch after patch was applied'.format( - name - ) - ) + ret['result'] = ret['changes']['retcode'] == 0 + # No need to check for SaltInvocationError or ValueError this time, since + # these exceptions would have been caught above. + if ret['result'] and hash_ and not __salt__['file.check_hash'](name, hash_): + ret['result'] = False + ret['comment'] = 'Hash mismatch after patch was applied' return ret From 79c1a915c4535342c9fc799fa8dc05f991388edd Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 22 Feb 2017 11:49:44 -0700 Subject: [PATCH 076/370] Remove trailing whitespace Needed for lint check --- salt/modules/zabbix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/zabbix.py b/salt/modules/zabbix.py index 2b516bce95..2ef8280a23 100644 --- a/salt/modules/zabbix.py +++ b/salt/modules/zabbix.py @@ -1531,7 +1531,7 @@ def template_get(name=None, host=None, templateids=None, **connection_args): except KeyError: return ret - + def run_query(method, params, **connection_args): ''' Send Zabbix API call From c90a52ef27f8b04c362637a0806c0d9111f77e3a Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 22 Feb 2017 12:27:14 -0700 Subject: [PATCH 077/370] Remove expensive check --- salt/states/ssh_known_hosts.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/salt/states/ssh_known_hosts.py b/salt/states/ssh_known_hosts.py index d8ebee3122..e704e7e43d 100644 --- a/salt/states/ssh_known_hosts.py +++ b/salt/states/ssh_known_hosts.py @@ -38,12 +38,6 @@ def __virtual__(): if salt.utils.is_windows(): return False, 'ssh_known_hosts: Does not support Windows' - if 'ssh.set_known_host' not in __salt__ \ - or 'ssh.check_known_host' not in __salt__ \ - or 'ssh.get_known_host' not in __salt__ \ - or 'ssh.rm_known_host' not in __salt__: - return False, 'ssh_known_hosts: Missing required module "ssh"' - return __virtualname__ From b230c35eac5b77e86b833c072eabf6f44761264c Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 22 Feb 2017 14:29:24 -0700 Subject: [PATCH 078/370] This should be good to go now --- doc/topics/transports/tcp.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/topics/transports/tcp.rst b/doc/topics/transports/tcp.rst index 1707ec3f32..d12bde129e 100644 --- a/doc/topics/transports/tcp.rst +++ b/doc/topics/transports/tcp.rst @@ -57,8 +57,13 @@ The minimal `ssl` option in the minion configuration file looks like this: .. code-block:: yaml + ssl: True + # Versions below 2016.11.4: ssl: {} +Specific options can be sent to the minion also, as defined in the Python +`ssl.wrap_socket` function. + .. note:: While setting the ssl_version is not required, we recomend it. Some older From 663f6f159d53eeafb32562c7597e24b79a96250f Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Wed, 22 Feb 2017 16:04:05 -0700 Subject: [PATCH 079/370] add additional PRs to 2016.11.3 release notes --- doc/topics/releases/2016.11.3.rst | 165 +++++++++++++++++++++++++++++- 1 file changed, 160 insertions(+), 5 deletions(-) diff --git a/doc/topics/releases/2016.11.3.rst b/doc/topics/releases/2016.11.3.rst index 2b285a8883..a2062836a8 100644 --- a/doc/topics/releases/2016.11.3.rst +++ b/doc/topics/releases/2016.11.3.rst @@ -10,17 +10,152 @@ Changes for v2016.11.2..v2016.11.3 Extended changelog courtesy of Todd Stansell (https://github.com/tjstansell/salt-changelogs): -*Generated at: 2017-02-16T16:48:51Z* +*Generated at: 2017-02-22T23:01:16Z* Statistics: -- Total Merges: **126** -- Total Issue references: **75** -- Total PR references: **199** +- Total Merges: **139** +- Total Issue references: **78** +- Total PR references: **217** Changes: +- **PR** `#39536`_: (*twangboy*) Namespace 'status' functions in 'win_status' + @ *2017-02-21T23:45:31Z* + + - **PR** `#39005`_: (*cro*) Ungate the status.py module and raise unsupported errors in functions not executable on Windows. + | refs: `#39536`_ + * 40f72db Merge pull request `#39536`_ from twangboy/fix_win_status + * d5453e2 Remove unused import (lint) + + * 837c32e Remove list2cmdline + + * c258cb3 Streamline wmic command returns for easier parsing + + * 6d2cf81 Fix 'ping_master' function + + * d946d10 Namespace 'status' functions in 'win_status' + +- **PR** `#39534`_: (*rallytime*) Fix breakage in aptpkg and dpkg execution modules + @ *2017-02-21T20:31:15Z* + + - **PR** `#39418`_: (*anlutro*) Allow aptpkg.info_installed on package names that aren't installed + | refs: `#39534`_ + * dc8f578 Merge pull request `#39534`_ from rallytime/fix-pkg-function-specs + * d34a8fe Fix breakage in aptpkg and dpkg execution modules + +* 1d0d7b2 Upgrade SaltTesting to run test suite for 2016.11 and add SaltPyLint (`#39521`_) + + - **ISSUE** `#34712`_: (*richardscollin*) Salt Test Suite Error - develop + | refs: `#37366`_ + - **PR** `#39521`_: (*vutny*) Upgrade SaltTesting to run test suite for 2016.11 and add SaltPyLint + - **PR** `#37366`_: (*eradman*) dev_python*.txt: use current SaltTesting and SaltPyLint modules + | refs: `#39521`_ + +- **PR** `#39370`_: (*twangboy*) Gate win_osinfo and winservice + @ *2017-02-17T23:53:58Z* + + * e4c7168 Merge pull request `#39370`_ from twangboy/gate_win_utils + * 167cdb3 Gate windows specific imports, add __virtual__ + + * e67387d Add option to return a Non instantiated class + + * 315b0cc Clarify return value for win_osinfo + + * 994314e Fix more docs + + * 2bbe3cb Fix some docs + + * 4103563 Merge branch 'gate_win_utils' of https://github.com/twangboy/salt into gate_win_utils + + * 24c1bd0 Remove extra newlines + + * 82a86ce Add helper function for winservice + + * 0051b5a Put the win_osinfo classes in a helper function + + * 4e08534 Gate win_osinfo and winservice better + +- **PR** `#39486`_: (*twangboy*) Remove orphaned function list_configurable_policies + @ *2017-02-17T22:21:50Z* + + * a3e71b6 Merge pull request `#39486`_ from twangboy/win_remove_orphaned + * 1328055 Remove orphaned function list_configurable_policies + +- **PR** `#39418`_: (*anlutro*) Allow aptpkg.info_installed on package names that aren't installed + | refs: `#39534`_ + @ *2017-02-17T18:34:19Z* + + * 87b269f Merge pull request `#39418`_ from alprs/fix-aptpkg_info_nonexistent_pkg + * 246bf1e add failhard argument to various apt pkg functions + +- **PR** `#39438`_: (*mirceaulinic*) file.get_managed: refetch source when file hashsum is changed + @ *2017-02-17T17:58:29Z* + + * e816d6c Merge pull request `#39438`_ from cloudflare/fix_39422 + * 8453800 file.get_managed: refetch cached file when hashsum chnaged + +- **PR** `#39432`_: (*dmaziuk*) Quick and dirty fix for GECOS fields with more than 3 commas + @ *2017-02-17T17:57:30Z* + + - **ISSUE** `#39203`_: (*dmaziuk*) salt.users gecos field + | refs: `#39432`_ `#39432`_ + * a5fe8f0 Merge pull request `#39432`_ from dmaziuk/issue39203 + * 41c0463 Remove # + + * 4f877c6 Quick and dirty fix for GECOS fields with more than 3 commas + +- **PR** `#39484`_: (*corywright*) The Reactor docs should use pillar='{}' instead of 'pillar={}' + @ *2017-02-17T17:50:57Z* + + * 3665229 Merge pull request `#39484`_ from corywright/fix-reactor-docs-pillar-keyword-args + * cc90d0d The Reactor docs should use pillar='{}' instead of 'pillar={}' + +- **PR** `#39456`_: (*twangboy*) Add salt icon to buildenv directory + @ *2017-02-16T22:47:58Z* + + * 2e3a9c5 Merge pull request `#39456`_ from twangboy/win_fix_icon + * 8dd915d Add salt icon to buildenv directory + +- **PR** `#39462`_: (*twangboy*) Use url_path instead of url_data.path + @ *2017-02-16T22:44:18Z* + + * 63adc03 Merge pull request `#39462`_ from twangboy/win_fix_fileclient + * a96bc13 Use url_path instead of url_data.path + +- **PR** `#39458`_: (*rallytime*) Fix more warnings in doc build + @ *2017-02-16T21:45:52Z* + + * e9b034f Merge pull request `#39458`_ from rallytime/fixup-more-doc-build-warnings + * e698bc3 Fix more warnings in doc build + +- **PR** `#39437`_: (*sakateka*) Fixes about saltfile + @ *2017-02-16T20:32:15Z* + + * e4f8c2b Merge pull request `#39437`_ from sakateka/fixes_about_saltfile + * ab68524 less pylint: salt/utils/parsers.py + + * 9e7d9dc Revert "pylint: salt/utils/parsers.py" + + * f3f129c document ~/.salt/Saltfile + + * 33f3614 pylint: salt/utils/parsers.py + + * 0f36e10 expand config_dir and '~/.salt/Saltfile' as last resort + +* 1acf00d add 2016.11.3 changelog to release notes (`#39451`_) + + - **PR** `#39451`_: (*Ch3LL*) add 2016.11.3 changelog to release notes + +- **PR** `#39448`_: (*gtmanfred*) Add release notes for cisco proxy minions added in Carbon + @ *2017-02-16T17:29:48Z* + + - **ISSUE** `#38032`_: (*meggiebot*) Add missing Carbon docs + | refs: `#39448`_ + * 8e2cbd2 Merge pull request `#39448`_ from gtmanfred/2016.11 + * 3172e88 Add release notes for cisco proxy minions added in Carbon + - **PR** `#39428`_: (*rallytime*) [2016.11] Merge forward from 2016.3 to 2016.11 @ *2017-02-16T00:01:15Z* @@ -691,7 +826,7 @@ Changes: * f8a6863 Merge pull request `#39087`_ from lomeroe/`bp-37375`_ * c3aaa53 _in_range_inclusive class method incorrectly called isinstance - * ce263f9 set_computer_policy and set_user_policy call "set" by the original function name (set) instead of the aliased function name ``set_`` + * ce263f9 set_computer_policy and set_user_policy call "set" by the original function name (set) instead of the aliased function name set_ * ff7d74b correct tool extension guid for user registry policies @@ -846,6 +981,7 @@ Changes: * a7fc02e Ungate the status.py module and raise unsupported errors in functions not executeable on Windows. (`#39005`_) - **PR** `#39005`_: (*cro*) Ungate the status.py module and raise unsupported errors in functions not executable on Windows. + | refs: `#39536`_ - **PR** `#39012`_: (*terminalmage*) Fix "invalid lexer" errors in docs build @ *2017-01-28T06:47:45Z* @@ -1252,6 +1388,7 @@ Changes: .. _`#33890`: https://github.com/saltstack/salt/issues/33890 .. _`#34280`: https://github.com/saltstack/salt/pull/34280 .. _`#34551`: https://github.com/saltstack/salt/issues/34551 +.. _`#34712`: https://github.com/saltstack/salt/issues/34712 .. _`#34780`: https://github.com/saltstack/salt/issues/34780 .. _`#35055`: https://github.com/saltstack/salt/pull/35055 .. _`#35777`: https://github.com/saltstack/salt/issues/35777 @@ -1264,12 +1401,14 @@ Changes: .. _`#37174`: https://github.com/saltstack/salt/issues/37174 .. _`#37262`: https://github.com/saltstack/salt/pull/37262 .. _`#37338`: https://github.com/saltstack/salt/pull/37338 +.. _`#37366`: https://github.com/saltstack/salt/pull/37366 .. _`#37375`: https://github.com/saltstack/salt/pull/37375 .. _`#37413`: https://github.com/saltstack/salt/issues/37413 .. _`#37632`: https://github.com/saltstack/salt/pull/37632 .. _`#37864`: https://github.com/saltstack/salt/pull/37864 .. _`#37938`: https://github.com/saltstack/salt/issues/37938 .. _`#38003`: https://github.com/saltstack/salt/issues/38003 +.. _`#38032`: https://github.com/saltstack/salt/issues/38032 .. _`#38081`: https://github.com/saltstack/salt/issues/38081 .. _`#38100`: https://github.com/saltstack/salt/issues/38100 .. _`#38165`: https://github.com/saltstack/salt/pull/38165 @@ -1435,6 +1574,7 @@ Changes: .. _`#39198`: https://github.com/saltstack/salt/pull/39198 .. _`#39199`: https://github.com/saltstack/salt/pull/39199 .. _`#39202`: https://github.com/saltstack/salt/pull/39202 +.. _`#39203`: https://github.com/saltstack/salt/issues/39203 .. _`#39206`: https://github.com/saltstack/salt/pull/39206 .. _`#39209`: https://github.com/saltstack/salt/pull/39209 .. _`#39210`: https://github.com/saltstack/salt/pull/39210 @@ -1484,16 +1624,31 @@ Changes: .. _`#39362`: https://github.com/saltstack/salt/pull/39362 .. _`#39364`: https://github.com/saltstack/salt/pull/39364 .. _`#39369`: https://github.com/saltstack/salt/pull/39369 +.. _`#39370`: https://github.com/saltstack/salt/pull/39370 .. _`#39378`: https://github.com/saltstack/salt/pull/39378 .. _`#39379`: https://github.com/saltstack/salt/pull/39379 .. _`#39380`: https://github.com/saltstack/salt/pull/39380 .. _`#39392`: https://github.com/saltstack/salt/pull/39392 .. _`#39400`: https://github.com/saltstack/salt/pull/39400 .. _`#39409`: https://github.com/saltstack/salt/pull/39409 +.. _`#39418`: https://github.com/saltstack/salt/pull/39418 .. _`#39419`: https://github.com/saltstack/salt/pull/39419 .. _`#39424`: https://github.com/saltstack/salt/pull/39424 .. _`#39428`: https://github.com/saltstack/salt/pull/39428 .. _`#39429`: https://github.com/saltstack/salt/pull/39429 +.. _`#39432`: https://github.com/saltstack/salt/pull/39432 +.. _`#39437`: https://github.com/saltstack/salt/pull/39437 +.. _`#39438`: https://github.com/saltstack/salt/pull/39438 +.. _`#39448`: https://github.com/saltstack/salt/pull/39448 +.. _`#39451`: https://github.com/saltstack/salt/pull/39451 +.. _`#39456`: https://github.com/saltstack/salt/pull/39456 +.. _`#39458`: https://github.com/saltstack/salt/pull/39458 +.. _`#39462`: https://github.com/saltstack/salt/pull/39462 +.. _`#39484`: https://github.com/saltstack/salt/pull/39484 +.. _`#39486`: https://github.com/saltstack/salt/pull/39486 +.. _`#39521`: https://github.com/saltstack/salt/pull/39521 +.. _`#39534`: https://github.com/saltstack/salt/pull/39534 +.. _`#39536`: https://github.com/saltstack/salt/pull/39536 .. _`bp-36336`: https://github.com/saltstack/salt/pull/36336 .. _`bp-37338`: https://github.com/saltstack/salt/pull/37338 .. _`bp-37375`: https://github.com/saltstack/salt/pull/37375 From c0f8c35df739782445f558f5df58e5eeb4713718 Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Wed, 22 Feb 2017 16:09:16 -0700 Subject: [PATCH 080/370] fix reference to set in docs --- doc/topics/releases/2016.11.3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/topics/releases/2016.11.3.rst b/doc/topics/releases/2016.11.3.rst index a2062836a8..2adeda6ac9 100644 --- a/doc/topics/releases/2016.11.3.rst +++ b/doc/topics/releases/2016.11.3.rst @@ -826,7 +826,7 @@ Changes: * f8a6863 Merge pull request `#39087`_ from lomeroe/`bp-37375`_ * c3aaa53 _in_range_inclusive class method incorrectly called isinstance - * ce263f9 set_computer_policy and set_user_policy call "set" by the original function name (set) instead of the aliased function name set_ + * ce263f9 set_computer_policy and set_user_policy call "set" by the original function name (set) instead of the aliased function name ``set_`` * ff7d74b correct tool extension guid for user registry policies From 344499eef717e4d4aee3bd219756dd9bf22ac0c2 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 22 Feb 2017 16:37:54 -0700 Subject: [PATCH 081/370] Add mention-bot configuration --- .mention-bot | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .mention-bot diff --git a/.mention-bot b/.mention-bot new file mode 100644 index 0000000000..12a2c4c97a --- /dev/null +++ b/.mention-bot @@ -0,0 +1,6 @@ +{ + "skipTitle": "Merge forward", + "delayed": true, + "delayedUntil": "2h" +} + From 65889e1f30861e51a88ae699a4d19347c1ce89e0 Mon Sep 17 00:00:00 2001 From: rallytime Date: Wed, 22 Feb 2017 16:45:37 -0700 Subject: [PATCH 082/370] [2016.3] Pylint: Remove unused import --- salt/states/dockerng.py | 1 - 1 file changed, 1 deletion(-) diff --git a/salt/states/dockerng.py b/salt/states/dockerng.py index 30f3df5c76..1430c35814 100644 --- a/salt/states/dockerng.py +++ b/salt/states/dockerng.py @@ -51,7 +51,6 @@ from salt.modules.dockerng import ( VALID_CREATE_OPTS, _validate_input, _get_repo_tag, - _get_docker_py_versioninfo, ) # pylint: enable=no-name-in-module,import-error import salt.utils From c52cecd8564e2360ee006b843cef060d1ff815d5 Mon Sep 17 00:00:00 2001 From: rallytime Date: Wed, 22 Feb 2017 16:51:01 -0700 Subject: [PATCH 083/370] Fix syntax error leftover from incomplete merge-conflict resolution --- salt/modules/dockerng.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index 88127ee3a8..f094d1f592 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -583,6 +583,7 @@ VALID_CREATE_OPTS = { 'Type': None, 'Config': {}, } + }, 'ulimits': { 'path': 'HostConfig:Ulimits', 'min_docker': (1, 6, 0), From db645da0bfc50e5652670edcc9f8a7cc37d45914 Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 22 Feb 2017 16:53:27 -0700 Subject: [PATCH 084/370] Fix fileserver roots tests for Windows --- salt/fileclient.py | 3 +- tests/integration/fileserver/roots_test.py | 58 ++++++++++++++++------ 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index 6b8843d6c6..f8e48f952b 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -356,9 +356,10 @@ class Client(object): del dirs[:] else: for found_file in files: - stripped_root = os.path.relpath(root, path).replace('/', '.') + stripped_root = os.path.relpath(root, path) if salt.utils.is_windows(): stripped_root = stripped_root.replace('\\', '/') + stripped_root = stripped_root.replace('/', '.') if found_file.endswith(('.sls')): if found_file.endswith('init.sls'): if stripped_root.endswith('.'): diff --git a/tests/integration/fileserver/roots_test.py b/tests/integration/fileserver/roots_test.py index 9bf3a5550a..2c0aa4d55e 100644 --- a/tests/integration/fileserver/roots_test.py +++ b/tests/integration/fileserver/roots_test.py @@ -17,6 +17,7 @@ ensure_in_syspath('../..') import integration from salt.fileserver import roots from salt import fileclient +import salt.utils roots.__opts__ = {} @@ -66,21 +67,39 @@ class RootsTest(integration.ModuleCase): fnd = {'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile'} ret = roots.serve_file(load, fnd) + + data = 'Scene 24\n\n \n OLD MAN: Ah, hee he he ha!\n ' \ + 'ARTHUR: And this enchanter of whom you speak, he ' \ + 'has seen the grail?\n OLD MAN: Ha ha he he he ' \ + 'he!\n ARTHUR: Where does he live? Old man, where ' \ + 'does he live?\n OLD MAN: He knows of a cave, a ' \ + 'cave which no man has entered.\n ARTHUR: And the ' \ + 'Grail... The Grail is there?\n OLD MAN: Very much ' \ + 'danger, for beyond the cave lies the Gorge\n ' \ + 'of Eternal Peril, which no man has ever crossed.\n ' \ + 'ARTHUR: But the Grail! Where is the Grail!?\n ' \ + 'OLD MAN: Seek you the Bridge of Death.\n ARTHUR: ' \ + 'The Bridge of Death, which leads to the Grail?\n ' \ + 'OLD MAN: Hee hee ha ha!\n\n' + if salt.utils.is_windows(): + data = 'Scene 24\r\n\r\n \r\n OLD MAN: Ah, hee he he ' \ + 'ha!\r\n ARTHUR: And this enchanter of whom you ' \ + 'speak, he has seen the grail?\r\n OLD MAN: Ha ha ' \ + 'he he he he!\r\n ARTHUR: Where does he live? Old ' \ + 'man, where does he live?\r\n OLD MAN: He knows of ' \ + 'a cave, a cave which no man has entered.\r\n ' \ + 'ARTHUR: And the Grail... The Grail is there?\r\n ' \ + 'OLD MAN: Very much danger, for beyond the cave lies ' \ + 'the Gorge\r\n of Eternal Peril, which no man ' \ + 'has ever crossed.\r\n ARTHUR: But the Grail! ' \ + 'Where is the Grail!?\r\n OLD MAN: Seek you the ' \ + 'Bridge of Death.\r\n ARTHUR: The Bridge of Death, ' \ + 'which leads to the Grail?\r\n OLD MAN: Hee hee ha ' \ + 'ha!\r\n\r\n' + self.assertDictEqual( ret, - {'data': 'Scene 24\n\n \n OLD MAN: Ah, hee he he ha!\n ' - 'ARTHUR: And this enchanter of whom you speak, he ' - 'has seen the grail?\n OLD MAN: Ha ha he he he ' - 'he!\n ARTHUR: Where does he live? Old man, where ' - 'does he live?\n OLD MAN: He knows of a cave, a ' - 'cave which no man has entered.\n ARTHUR: And the ' - 'Grail... The Grail is there?\n OLD MAN: Very much ' - 'danger, for beyond the cave lies the Gorge\n ' - 'of Eternal Peril, which no man has ever crossed.\n ' - 'ARTHUR: But the Grail! Where is the Grail!?\n ' - 'OLD MAN: Seek you the Bridge of Death.\n ARTHUR: ' - 'The Bridge of Death, which leads to the Grail?\n ' - 'OLD MAN: Hee hee ha ha!\n\n', + {'data': data, 'dest': 'testfile'}) @skipIf(True, "Update test not yet implemented") @@ -104,10 +123,17 @@ class RootsTest(integration.ModuleCase): 'rel': 'testfile' } ret = roots.file_hash(load, fnd) + + # Hashes are different in Windows. May be how git translates line + # endings + hsum = 'baba5791276eb99a7cc498fb1acfbc3b4bd96d24cfe984b4ed6b5be2418731df' + if salt.utils.is_windows(): + hsum = '754aa260e1f3e70f43aaf92149c7d1bad37f708c53304c37660e628d7553f687' + self.assertDictEqual( ret, { - 'hsum': 'baba5791276eb99a7cc498fb1acfbc3b4bd96d24cfe984b4ed6b5be2418731df', + 'hsum': hsum, 'hash_type': 'sha256' } ) @@ -153,6 +179,10 @@ class RootsTest(integration.ModuleCase): ret = roots.dir_list({'saltenv': 'base'}) self.assertIn('empty_dir', ret) + # Git doesn't handle symlinks in Windows. See the thread below: + # http://stackoverflow.com/questions/5917249/git-symlinks-in-windows + @skipIf(salt.utils.is_windows(), + 'Git doesn\'t handle symlinks properly on Windows') def test_symlink_list(self): with patch.dict(roots.__opts__, {'cachedir': self.master_opts['cachedir'], 'file_roots': self.master_opts['file_roots'], From 5db986860c5c6bcb6a507744dfbc72c5cf5c76ec Mon Sep 17 00:00:00 2001 From: rallytime Date: Wed, 22 Feb 2017 17:02:21 -0700 Subject: [PATCH 085/370] [develop] Fix some pylint errors that snuck into develop --- salt/cloud/clouds/ec2.py | 2 ++ salt/payload.py | 4 ++-- salt/states/boto_iam.py | 4 ++-- tests/unit/cloud/clouds/ec2_test.py | 6 ++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py index df02736e7f..89f5780c3f 100644 --- a/salt/cloud/clouds/ec2.py +++ b/salt/cloud/clouds/ec2.py @@ -2481,6 +2481,7 @@ def wait_for_instance( return vm_ + def _validate_key_path_and_mode(key_filename): if key_filename is None: raise SaltCloudSystemExit( @@ -2505,6 +2506,7 @@ def _validate_key_path_and_mode(key_filename): return True + def create(vm_=None, call=None): ''' Create a single VM from a data dict diff --git a/salt/payload.py b/salt/payload.py index e132003066..1235a2e8b5 100644 --- a/salt/payload.py +++ b/salt/payload.py @@ -226,8 +226,8 @@ class Serial(object): for key, value in six.iteritems(obj.copy()): encodedkey = datetime_encoder(key) if key != encodedkey: - del obj[key] - key = encodedkey + del obj[key] + key = encodedkey obj[key] = datetime_encoder(value) return dict(obj) elif isinstance(obj, (list, tuple)): diff --git a/salt/states/boto_iam.py b/salt/states/boto_iam.py index b7990b5c9e..6095ce9fa3 100644 --- a/salt/states/boto_iam.py +++ b/salt/states/boto_iam.py @@ -141,10 +141,10 @@ import os import salt.utils import salt.utils.odict as odict import salt.utils.dictupdate as dictupdate - -# Import 3rd party libs import salt.ext.six as six from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin + +# Import 3rd party libs try: from salt._compat import ElementTree as ET HAS_ELEMENT_TREE = True diff --git a/tests/unit/cloud/clouds/ec2_test.py b/tests/unit/cloud/clouds/ec2_test.py index 5f5125560b..1c7afc690c 100644 --- a/tests/unit/cloud/clouds/ec2_test.py +++ b/tests/unit/cloud/clouds/ec2_test.py @@ -11,11 +11,12 @@ from salt.exceptions import SaltCloudSystemExit # Import Salt Testing Libs from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch +from salttesting.mock import NO_MOCK, NO_MOCK_REASON from salttesting.helpers import ensure_in_syspath ensure_in_syspath('../../../') + @skipIf(NO_MOCK, NO_MOCK_REASON) class EC2TestCase(TestCase): ''' @@ -39,6 +40,7 @@ class EC2TestCase(TestCase): ec2._validate_key_path_and_mode, key_file) + if __name__ == '__main__': - from unit import run_tests + from integration import run_tests run_tests(EC2TestCase, needs_daemon=False) From 62491c900dd9ceca390c1a25fce744e955224658 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 22 Feb 2017 19:20:43 -0700 Subject: [PATCH 086/370] Add empty blacklist to mention bot --- .mention-bot | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mention-bot b/.mention-bot index 12a2c4c97a..c3181cdc9f 100644 --- a/.mention-bot +++ b/.mention-bot @@ -1,6 +1,7 @@ { "skipTitle": "Merge forward", "delayed": true, - "delayedUntil": "2h" + "delayedUntil": "2h", + "userBlacklist": [] } From 652044b18fa72b4f4dfcc09ca8c860b5957d32f1 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 22 Feb 2017 19:34:02 -0700 Subject: [PATCH 087/370] A note in the docs about mentionbot --- doc/topics/development/contributing.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/topics/development/contributing.rst b/doc/topics/development/contributing.rst index 920d02611b..f1df02ee33 100644 --- a/doc/topics/development/contributing.rst +++ b/doc/topics/development/contributing.rst @@ -418,3 +418,14 @@ and bug resolution. See the :ref:`Labels and Milestones .. _'Git resources`: https://help.github.com/articles/good-resources-for-learning-git-and-github/ .. _`Closing issues via commit message`: https://help.github.com/articles/closing-issues-via-commit-messages .. _`git format-patch`: https://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html + +Mentionbot +========== + +SaltStack runs a mention-bot which notifies contributors who might be able +to help review incoming pull-requests based on their past contribution to +files which are being changed. + +If you do not wish to receive these notifications, please add your GitHub +handle to the blacklist line in the `.mention-bot` file located in the +root of the Salt repository. From 8b2c55d92a6d45f7d228799207fe64b25fe48b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B0=8F=E9=9B=AA?= Date: Thu, 23 Feb 2017 10:48:39 +0800 Subject: [PATCH 088/370] fix custom MySQldb converter bug --- salt/modules/mysql.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index 9f74554ef9..a7fdee0ec1 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -119,7 +119,7 @@ __ssl_options__ = __ssl_options_parameterized__ + [ 'X509' ] -r''' +''' # TODO DEVELOPER NOTE: ABOUT arguments management, escapes, formats, arguments and security of SQL. @@ -621,19 +621,6 @@ def query(database, query, **connection_args): orig_conv = MySQLdb.converters.conversions conv_iter = iter(orig_conv) conv = dict(zip(conv_iter, [str] * len(orig_conv))) - # some converters are lists, do not break theses - conv[FIELD_TYPE.BLOB] = [ - (FLAG.BINARY, str), - ] - conv[FIELD_TYPE.STRING] = [ - (FLAG.BINARY, str), - ] - conv[FIELD_TYPE.VAR_STRING] = [ - (FLAG.BINARY, str), - ] - conv[FIELD_TYPE.VARCHAR] = [ - (FLAG.BINARY, str), - ] connection_args.update({'connection_db': database, 'connection_conv': conv}) dbc = _connect(**connection_args) From 8482e93d0c8d2d3e8e221eefbf446b447a0f8311 Mon Sep 17 00:00:00 2001 From: shellchen Date: Thu, 23 Feb 2017 10:52:53 +0800 Subject: [PATCH 089/370] fix --- salt/modules/mysql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index a7fdee0ec1..2355e9a821 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -119,7 +119,7 @@ __ssl_options__ = __ssl_options_parameterized__ + [ 'X509' ] -''' # TODO +r''' DEVELOPER NOTE: ABOUT arguments management, escapes, formats, arguments and security of SQL. From 8e4d76225f669ec62940f72ea20bc37dd9d52f6f Mon Sep 17 00:00:00 2001 From: coutotyler Date: Wed, 22 Feb 2017 19:20:20 -0800 Subject: [PATCH 090/370] Adding defaults for timeout and period. Replacing try/except clauses with isinstance() calls. Adding check for test=true. Replacing double quotes with singles --- salt/states/loop.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/salt/states/loop.py b/salt/states/loop.py index a62734c461..a2fec3c306 100644 --- a/salt/states/loop.py +++ b/salt/states/loop.py @@ -41,8 +41,8 @@ def until(name, m_args=None, m_kwargs=None, condition=None, - period=None, - timeout=None): + period=0, + timeout=604800): ''' Loop over an execution module until a condition is met. @@ -72,23 +72,23 @@ def until(name, 'comment': ''} if name not in __salt__: - ret['comment'] = "Can't find module {0}".format(name) + ret['comment'] = 'Cannot find module {0}'.format(name) return ret if condition is None: ret['comment'] = 'An exit condition must be specified' return ret - try: - period = int(period) - except ValueError: - ret['comment'] = 'Period must be specified in seconds' - try: - timeout = int(timeout) - except ValueError: - ret['comment'] = 'Timeout must be specified in seconds' + if not isinstance(period, int): + ret['comment'] = 'Period must be specified as an integer in seconds' + return ret + if not isinstance(timeout, int): + ret['comment'] = 'Timeout must be specified as an integer in seconds' + return ret + if __opts__['test']: + ret['comment'] = 'The execution module {0} will be run'.format(name) + ret['result'] = None + return ret def timed_out(): - if timeout is None: - return False if time.time() >= timeout: return True return False From d07cf594e089ca67d1cc135e270b4d95964bc6db Mon Sep 17 00:00:00 2001 From: stein Date: Thu, 23 Feb 2017 16:07:38 +0800 Subject: [PATCH 091/370] add stop instance before destroy --- salt/cloud/clouds/aliyun.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/salt/cloud/clouds/aliyun.py b/salt/cloud/clouds/aliyun.py index 8df138b6bb..3bb808102e 100644 --- a/salt/cloud/clouds/aliyun.py +++ b/salt/cloud/clouds/aliyun.py @@ -1026,6 +1026,13 @@ def destroy(name, call=None): instanceId = _get_node(name)['InstanceId'] + # have to stop instance before del it + stop_params = { + 'Action': 'StopInstance', + 'InstanceId': instanceId + } + stop_status = query(stop_params) + params = { 'Action': 'DeleteInstance', 'InstanceId': instanceId From ba986ce99ef165193b15197077d3aa2d4e940d03 Mon Sep 17 00:00:00 2001 From: stein Date: Thu, 23 Feb 2017 16:09:45 +0800 Subject: [PATCH 092/370] add stop instance before destroy --- salt/cloud/clouds/aliyun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/cloud/clouds/aliyun.py b/salt/cloud/clouds/aliyun.py index 3bb808102e..e2b5471bdf 100644 --- a/salt/cloud/clouds/aliyun.py +++ b/salt/cloud/clouds/aliyun.py @@ -1031,7 +1031,7 @@ def destroy(name, call=None): 'Action': 'StopInstance', 'InstanceId': instanceId } - stop_status = query(stop_params) + query(stop_params) params = { 'Action': 'DeleteInstance', From fad2a064ab915c9a7794ecc041dc96c1f71e9ec3 Mon Sep 17 00:00:00 2001 From: Jarrod Moore Date: Thu, 23 Feb 2017 21:19:53 +1100 Subject: [PATCH 093/370] Allow masterless minions to pull files from S3 --- salt/fileclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index f8e48f952b..9be6acc5dd 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -1340,7 +1340,7 @@ class FSClient(RemoteClient): the FSChan object ''' def __init__(self, opts): # pylint: disable=W0231 - self.opts = opts + RemoteClient.__init__(self, opts) self.channel = salt.fileserver.FSChan(opts) self.auth = DumbAuth() From 58faedacad04058385121823edc59ce4dd31bba8 Mon Sep 17 00:00:00 2001 From: "marco.messerschmidt" Date: Thu, 23 Feb 2017 11:34:13 +0100 Subject: [PATCH 094/370] remove log.info --- salt/modules/mount.py | 1 - 1 file changed, 1 deletion(-) diff --git a/salt/modules/mount.py b/salt/modules/mount.py index ba6019be39..5c9e9ca55f 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -102,7 +102,6 @@ def _active_mounts(ret): with salt.utils.fopen(filename) as ifile: for line in ifile: - log.info('in _active_mounts line: {}'.format(line)) comps = line.split() ret[comps[1]] = {'device': comps[0], 'alt_device': _list.get(comps[1], None), From e16dc832b2350a4708c521fe508f3b9a376a88f2 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 22 Feb 2017 13:51:22 +0000 Subject: [PATCH 095/370] Code cleanup. Tests are not destructive. Py3 compat. --- tests/unit/cache/localfs_test.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/unit/cache/localfs_test.py b/tests/unit/cache/localfs_test.py index 2e636089b0..f6d2b97047 100644 --- a/tests/unit/cache/localfs_test.py +++ b/tests/unit/cache/localfs_test.py @@ -5,12 +5,12 @@ unit tests for the localfs cache # Import Python libs from __future__ import absolute_import +import shutil import tempfile # Import Salt Testing libs import integration from salttesting import skipIf, TestCase -from salttesting.helpers import destructiveTest, ensure_in_syspath from salttesting.mock import ( MagicMock, NO_MOCK, @@ -18,7 +18,6 @@ from salttesting.mock import ( patch ) -ensure_in_syspath('../../') # Import Salt libs import salt.payload @@ -26,6 +25,9 @@ import salt.utils from salt.cache import localfs from salt.exceptions import SaltCacheError +# Import 3rd-party libs +import salt.ext.six as six + localfs.__context__ = {} localfs.__opts__ = {'cachedir': ''} @@ -41,6 +43,7 @@ class LocalFSTest(TestCase): Helper function that creates a temporary cache file using localfs.store. This is to used to create DRY unit tests for the localfs cache. ''' + self.addCleanup(shutil.rmtree, tmp_dir) with patch.dict(localfs.__opts__, {'cachedir': tmp_dir}): with patch.dict(localfs.__context__, {'serial': serializer}): localfs.store(bank='bank', key='key', data='payload data', cachedir=tmp_dir) @@ -79,7 +82,6 @@ class LocalFSTest(TestCase): ''' self.assertRaises(SaltCacheError, localfs.store, bank='', key='', data='', cachedir='') - @destructiveTest def test_store_success(self): ''' Tests that the store function writes the data to the serializer for storage. @@ -91,9 +93,9 @@ class LocalFSTest(TestCase): self._create_tmp_cache_file(tmp_dir, salt.payload.Serial(self)) # Read in the contents of the key.p file and assert "payload data" was written - with salt.utils.fopen(tmp_dir + '/bank/key.p') as fh_: + with salt.utils.fopen(tmp_dir + '/bank/key.p', 'rb') as fh_: for line in fh_: - self.assertIn('payload data', line) + self.assertIn(six.b('payload data'), line) # 'fetch' function tests: 3 @@ -114,7 +116,6 @@ class LocalFSTest(TestCase): ''' self.assertRaises(SaltCacheError, localfs.fetch, bank='', key='', cachedir='') - @destructiveTest def test_fetch_success(self): ''' Tests that the fetch function is able to read the cache file and return its data. @@ -152,7 +153,6 @@ class LocalFSTest(TestCase): ''' self.assertRaises(SaltCacheError, localfs.updated, bank='', key='', cachedir='') - @destructiveTest def test_updated_success(self): ''' Test that the updated function returns the modification time of the cache file @@ -228,7 +228,6 @@ class LocalFSTest(TestCase): ''' self.assertRaises(SaltCacheError, localfs.list_, bank='', cachedir='') - @destructiveTest def test_list_success(self): ''' Tests the return of the list function containing bank entries. @@ -245,7 +244,6 @@ class LocalFSTest(TestCase): # 'contains' function tests: 1 - @destructiveTest def test_contains(self): ''' Test the return of the contains function when key=None and when a key @@ -264,8 +262,3 @@ class LocalFSTest(TestCase): # Now test the return of the contains function when key='key' with patch.dict(localfs.__opts__, {'cachedir': tmp_dir}): self.assertTrue(localfs.contains(bank='bank', key='key', cachedir=tmp_dir)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LocalFSTest, needs_daemon=False) From e48ea8fa1b2e689a098f4aef2c1265d8abcc3401 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 22 Feb 2017 18:37:59 +0000 Subject: [PATCH 096/370] Don't use `assert_called_once()` or `assert_not_called()`. These worked in Py2 but not in Py3. A read of http://engineroom.trackmaven.com/blog/mocking-mistakes/ specially the section "Mocking the unexpected" will enlighten one. --- tests/unit/cloud/clouds/dimensiondata_test.py | 2 +- tests/unit/modules/boto_apigateway_test.py | 22 +++++++++---------- .../unit/modules/boto_cognitoidentity_test.py | 2 +- tests/unit/modules/gentoo_service_test.py | 6 ++--- tests/unit/modules/linux_lvm_test.py | 2 +- tests/unit/modules/pacman_test.py | 2 +- tests/unit/modules/systemd_test.py | 2 +- tests/unit/modules/zypper_test.py | 16 +++++++------- tests/unit/states/boto_apigateway_test.py | 4 ++-- .../unit/states/boto_cognitoidentity_test.py | 12 +++++----- tests/unit/states/boto_iot_test.py | 8 +++---- tests/unit/states/grafana_datasource_test.py | 2 +- tests/unit/states/ipset_test.py | 12 +++++----- tests/unit/utils/verify_test.py | 2 +- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/tests/unit/cloud/clouds/dimensiondata_test.py b/tests/unit/cloud/clouds/dimensiondata_test.py index c492c946f8..646fb2513c 100644 --- a/tests/unit/cloud/clouds/dimensiondata_test.py +++ b/tests/unit/cloud/clouds/dimensiondata_test.py @@ -153,7 +153,7 @@ class DimensionDataTestCase(ExtendedTestCase): get_deps = dimensiondata.get_dependencies() self.assertEqual(get_deps, True) if LooseVersion(mock.__version__) >= LooseVersion('2.0.0'): - p.assert_called_once() + self.assertTrue(p.call_count >= 1) def test_provider_matches(self): """ diff --git a/tests/unit/modules/boto_apigateway_test.py b/tests/unit/modules/boto_apigateway_test.py index ebcfad31c8..0ed863dde2 100644 --- a/tests/unit/modules/boto_apigateway_test.py +++ b/tests/unit/modules/boto_apigateway_test.py @@ -1503,9 +1503,9 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM res = boto_apigateway.update_usage_plan('plan1_id', quota=quota, **conn_parameters) self.assertNotEqual(None, res.get('error')) - self.conn.get_usage_plans.assert_not_called() - self.conn.create_usage_plan.assert_not_called() - self.conn.update_usage_plan.assert_not_called() + self.assertTrue(self.conn.get_usage_plans.call_count == 0) + self.assertTrue(self.conn.create_usage_plan.call_count == 0) + self.assertTrue(self.conn.update_usage_plan.call_count == 0) def test_that_when_creating_a_usage_plan_and_create_usage_plan_throws_an_exception_that_an_error_is_returned(self): ''' @@ -1542,7 +1542,7 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM result = boto_apigateway.update_usage_plan(plan_id='plan1_id', throttle=None, quota=None, **conn_parameters) self.assertEqual(result.get('updated'), True) self.assertEqual(result.get('result'), ret) - self.conn.update_usage_plan.assert_called_once() + self.assertTrue(self.conn.update_usage_plan.call_count >= 1) def test_that_when_deleting_usage_plan_and_describe_usage_plans_had_error_that_the_same_error_is_returned(self): ''' @@ -1552,7 +1552,7 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM self.conn.get_usage_plans.side_effect = ClientError(error_content, ret) result = boto_apigateway.delete_usage_plan(plan_id='some plan id', **conn_parameters) self.assertEqual(result.get('error').get('message'), error_message.format(ret)) - self.conn.delete_usage_plan.assert_not_called() + self.assertTrue(self.conn.delete_usage_plan.call_count == 0) def test_that_when_deleting_usage_plan_and_plan_exists_that_the_functions_returns_deleted_true(self): self.conn.get_usage_plans.return_value = usage_plans_ret @@ -1561,7 +1561,7 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM result = boto_apigateway.delete_usage_plan(plan_id='plan1_id', **conn_parameters) self.assertEqual(result.get('deleted'), True) self.assertEqual(result.get('usagePlanId'), 'plan1_id') - self.conn.delete_usage_plan.assert_called_once() + self.assertTrue(self.conn.delete_usage_plan.call_count >= 1) def test_that_when_deleting_usage_plan_and_plan_does_not_exist_that_the_functions_returns_deleted_true(self): ''' @@ -1575,7 +1575,7 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM result = boto_apigateway.delete_usage_plan(plan_id='plan1_id', **conn_parameters) self.assertEqual(result.get('deleted'), True) self.assertEqual(result.get('usagePlanId'), 'plan1_id') - self.conn.delete_usage_plan.assert_not_called() + self.assertTrue(self.conn.delete_usage_plan.call_count == 0) def test_that_when_deleting_usage_plan_and_delete_usage_plan_throws_exception_that_an_error_is_returned(self): ''' @@ -1586,7 +1586,7 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM self.conn.delete_usage_plan.side_effect = ClientError(error_content, error_msg) result = boto_apigateway.delete_usage_plan(plan_id='plan1_id', **conn_parameters) self.assertEqual(result.get('error').get('message'), error_message.format(error_msg)) - self.conn.delete_usage_plan.assert_called_once() + self.assertTrue(self.conn.delete_usage_plan.call_count >= 1) def test_that_attach_or_detach_usage_plan_when_apis_is_empty_that_success_is_returned(self): ''' @@ -1595,12 +1595,12 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM result = boto_apigateway.attach_usage_plan_to_apis(plan_id='plan1_id', apis=[], **conn_parameters) self.assertEqual(result.get('success'), True) self.assertEqual(result.get('result', 'no result?'), None) - self.conn.update_usage_plan.assert_not_called() + self.assertTrue(self.conn.update_usage_plan.call_count == 0) result = boto_apigateway.detach_usage_plan_from_apis(plan_id='plan1_id', apis=[], **conn_parameters) self.assertEqual(result.get('success'), True) self.assertEqual(result.get('result', 'no result?'), None) - self.conn.update_usage_plan.assert_not_called() + self.assertTrue(self.conn.update_usage_plan.call_count == 0) def test_that_attach_or_detach_usage_plan_when_api_does_not_contain_apiId_or_stage_that_an_error_is_returned(self): ''' @@ -1613,7 +1613,7 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM result = boto_apigateway.detach_usage_plan_from_apis(plan_id='plan1_id', apis=[api], **conn_parameters) self.assertNotEqual(result.get('error'), None) - self.conn.update_usage_plan.assert_not_called() + self.assertTrue(self.conn.update_usage_plan.call_count == 0) def test_that_attach_or_detach_usage_plan_and_update_usage_plan_throws_exception_that_an_error_is_returned(self): ''' diff --git a/tests/unit/modules/boto_cognitoidentity_test.py b/tests/unit/modules/boto_cognitoidentity_test.py index 1ac4d181ef..5e97d2230a 100644 --- a/tests/unit/modules/boto_cognitoidentity_test.py +++ b/tests/unit/modules/boto_cognitoidentity_test.py @@ -185,7 +185,7 @@ class BotoCognitoIdentityTestCase(BotoCognitoIdentityTestCaseBase, BotoCognitoId self.conn.describe_identity_pool.return_value = third_pool_ret result = boto_cognitoidentity.describe_identity_pools(IdentityPoolName='', IdentityPoolId=third_pool_id, **conn_parameters) self.assertEqual(result.get('identity_pools'), [third_pool_ret]) - self.conn.list_identity_pools.assert_not_called() + self.assertTrue(self.conn.list_identity_pools.call_count == 0) def test_that_when_describing_a_named_identity_pool_and_pool_does_not_exist_the_describe_identity_pool_method_returns_none(self): ''' diff --git a/tests/unit/modules/gentoo_service_test.py b/tests/unit/modules/gentoo_service_test.py index 21768d0cfd..26c823495e 100644 --- a/tests/unit/modules/gentoo_service_test.py +++ b/tests/unit/modules/gentoo_service_test.py @@ -250,14 +250,14 @@ class GentooServicesTestCase(TestCase): with patch.dict(gentoo_service.__salt__, {'cmd.run': level_list_mock}): with patch.dict(gentoo_service.__salt__, {'cmd.retcode': rc_update_mock}): self.assertTrue(gentoo_service.enable('name', runlevels='l1')) - rc_update_mock.assert_not_called() + self.assertTrue(rc_update_mock.call_count == 0) rc_update_mock.reset_mock() # same as above with the list instead of the string with patch.dict(gentoo_service.__salt__, {'cmd.run': level_list_mock}): with patch.dict(gentoo_service.__salt__, {'cmd.retcode': rc_update_mock}): self.assertTrue(gentoo_service.enable('name', runlevels=['l1'])) - rc_update_mock.assert_not_called() + self.assertTrue(rc_update_mock.call_count == 0) rc_update_mock.reset_mock() # add service to 'l2' runlevel @@ -367,7 +367,7 @@ class GentooServicesTestCase(TestCase): with patch.dict(gentoo_service.__salt__, {'cmd.run': level_list_mock}): with patch.dict(gentoo_service.__salt__, {'cmd.retcode': rc_update_mock}): self.assertTrue(gentoo_service.disable('name', runlevels=['l1'])) - rc_update_mock.assert_not_called() + self.assertTrue(rc_update_mock.call_count == 0) rc_update_mock.reset_mock() # remove from 'l1' and 'l3', leave at 'l2' diff --git a/tests/unit/modules/linux_lvm_test.py b/tests/unit/modules/linux_lvm_test.py index 747dd61917..10b3b1b7cd 100644 --- a/tests/unit/modules/linux_lvm_test.py +++ b/tests/unit/modules/linux_lvm_test.py @@ -186,7 +186,7 @@ class LinuxLVMTestCase(TestCase): with patch.dict(linux_lvm.__salt__, {'cmd.run_all': cmd_mock}): self.assertEqual(linux_lvm.pvcreate('A', metadatasize=1000), True) - cmd_mock.assert_not_called() + self.assertTrue(cmd_mock.call_count == 0) def test_pvremove(self): ''' diff --git a/tests/unit/modules/pacman_test.py b/tests/unit/modules/pacman_test.py index ee4005b730..0404ab1c9f 100644 --- a/tests/unit/modules/pacman_test.py +++ b/tests/unit/modules/pacman_test.py @@ -69,7 +69,7 @@ class PacmanTestCase(TestCase): self.assertDictEqual(pacman.list_pkgs(True), mock_ret) sortmock.assert_called_with(mock_ret) - stringifymock.assert_not_called() + self.assertTrue(stringifymock.call_count == 0) def test_group_list(self): ''' diff --git a/tests/unit/modules/systemd_test.py b/tests/unit/modules/systemd_test.py index b37a2a2f15..73a5930a61 100644 --- a/tests/unit/modules/systemd_test.py +++ b/tests/unit/modules/systemd_test.py @@ -412,7 +412,7 @@ class SystemdScopeTestCase(TestCase): # Test not masked (should take no action and return True) self.assertTrue(systemd.unmask(self.unit_name)) # Also should not have called cmd.run_all - mock_not_run.assert_not_called() + self.assertTrue(mock_not_run.call_count == 0) with patch.object(systemd, 'masked', masked_mock): diff --git a/tests/unit/modules/zypper_test.py b/tests/unit/modules/zypper_test.py index cb80daebe3..5f1ff8ea0c 100644 --- a/tests/unit/modules/zypper_test.py +++ b/tests/unit/modules/zypper_test.py @@ -582,7 +582,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. zypper.__zypper__.xml.call.call_args_list, [call('ar', url, name)] ) - zypper.__zypper__.refreshable.xml.call.assert_not_called() + self.assertTrue(zypper.__zypper__.refreshable.xml.call.call_count == 0) def test_repo_noadd_nomod_noref(self): ''' @@ -604,8 +604,8 @@ Repository 'DUMMY' not found by its alias, number, or URI. self.assertEqual( out['comment'], 'Specified arguments did not result in modification of repo') - zypper.__zypper__.xml.call.assert_not_called() - zypper.__zypper__.refreshable.xml.call.assert_not_called() + self.assertTrue(zypper.__zypper__.xml.call.call_count == 0) + self.assertTrue(zypper.__zypper__.refreshable.xml.call.call_count == 0) def test_repo_noadd_modbaseurl_ref(self): ''' @@ -634,8 +634,8 @@ Repository 'DUMMY' not found by its alias, number, or URI. 'cache': False, 'keeppackages': False, 'type': 'rpm-md'} - assert zypper.mod_repo.call_count == 2 - assert zypper.mod_repo.mock_calls[1] == call(name, **expected_params) + self.assertTrue(zypper.mod_repo.call_count == 2) + self.assertTrue(zypper.mod_repo.mock_calls[1] == call(name, **expected_params)) def test_repo_add_mod_noref(self): ''' @@ -673,7 +673,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. 'salt.modules.zypper', **self.zypper_patcher_config) with zypper_patcher: zypper.mod_repo(name, **{'url': url, 'refresh': True}) - zypper.__zypper__.xml.call.assert_not_called() + self.assertTrue(zypper.__zypper__.xml.call.call_count == 0) zypper.__zypper__.refreshable.xml.call.assert_called_once_with( 'mr', '--refresh', name ) @@ -699,7 +699,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. call('--gpg-auto-import-keys', 'refresh', name) ] ) - zypper.__zypper__.refreshable.xml.call.assert_not_called() + self.assertTrue(zypper.__zypper__.refreshable.xml.call.call_count == 0) def test_repo_noadd_nomod_ref(self): ''' @@ -723,7 +723,7 @@ Repository 'DUMMY' not found by its alias, number, or URI. zypper.__zypper__.xml.call.call_args_list, [call('--gpg-auto-import-keys', 'refresh', name)] ) - zypper.__zypper__.refreshable.xml.call.assert_not_called() + self.assertTrue(zypper.__zypper__.refreshable.xml.call.call_count == 0) def test_repo_add_mod_ref(self): ''' diff --git a/tests/unit/states/boto_apigateway_test.py b/tests/unit/states/boto_apigateway_test.py index 9bbcefdc3b..81b35ef608 100644 --- a/tests/unit/states/boto_apigateway_test.py +++ b/tests/unit/states/boto_apigateway_test.py @@ -1085,7 +1085,7 @@ class BotoApiGatewayUsagePlanTestCase(BotoApiGatewayStateTestCaseBase, BotoApiGa self.assertIn('changes', result) self.assertEqual(result['changes'], {}) - boto_apigateway.__salt__['boto_apigateway.update_usage_plan'].assert_not_called() + self.assertTrue(boto_apigateway.__salt__['boto_apigateway.update_usage_plan'].call_count == 0) @patch.dict(boto_apigateway.__salt__, {'boto_apigateway.describe_usage_plans': MagicMock(return_value={'plans': [{ 'id': 'planid', @@ -1106,7 +1106,7 @@ class BotoApiGatewayUsagePlanTestCase(BotoApiGatewayStateTestCaseBase, BotoApiGa self.assertEqual(result['comment'], 'a new usage plan plan_name would be updated') self.assertIn('result', result) self.assertEqual(result['result'], None) - boto_apigateway.__salt__['boto_apigateway.update_usage_plan'].assert_not_called() + self.assertTrue(boto_apigateway.__salt__['boto_apigateway.update_usage_plan'].call_count == 0) @patch.dict(boto_apigateway.__salt__, {'boto_apigateway.describe_usage_plans': MagicMock(return_value={'plans': [{ 'id': 'planid', diff --git a/tests/unit/states/boto_cognitoidentity_test.py b/tests/unit/states/boto_cognitoidentity_test.py index 47c5e3a1fc..6854cf0d87 100644 --- a/tests/unit/states/boto_cognitoidentity_test.py +++ b/tests/unit/states/boto_cognitoidentity_test.py @@ -220,7 +220,7 @@ class BotoCognitoIdentityTestCase(BotoCognitoIdentityStateTestCaseBase, BotoCogn **conn_parameters) self.assertEqual(result.get('result'), False) self.assertTrue('error on create_identity_pool' in result.get('comment', '')) - self.conn.update_identity_pool.assert_not_called() + self.assertTrue(self.conn.update_identity_pool.call_count == 0) def test_present_when_failing_to_update_an_existing_identity_pool(self): ''' @@ -238,7 +238,7 @@ class BotoCognitoIdentityTestCase(BotoCognitoIdentityStateTestCaseBase, BotoCogn **conn_parameters) self.assertEqual(result.get('result'), False) self.assertTrue('error on update_identity_pool' in result.get('comment', '')) - self.conn.create_identity_pool.assert_not_called() + self.assertTrue(self.conn.create_identity_pool.call_count == 0) def _get_identity_pool_roles_side_effect(self, *args, **kwargs): if kwargs.get('IdentityPoolId') == first_pool_id: @@ -268,8 +268,8 @@ class BotoCognitoIdentityTestCase(BotoCognitoIdentityStateTestCaseBase, BotoCogn **conn_parameters) self.assertEqual(result.get('result'), False) self.assertTrue('error on get_identity_pool_roles' in result.get('comment', '')) - self.conn.create_identity_pool.assert_not_called() - self.conn.set_identity_pool_roles.assert_not_called() + self.assertTrue(self.conn.create_identity_pool.call_count == 0) + self.assertTrue(self.conn.set_identity_pool_roles.call_count == 0) def test_present_when_failing_to_set_identity_pool_roles(self): ''' @@ -322,7 +322,7 @@ class BotoCognitoIdentityTestCase(BotoCognitoIdentityStateTestCaseBase, BotoCogn expected_call_args = (dict(IdentityPoolId=default_pool_id, Roles={'authenticated': 'my_auth_role_arn'}),) self.assertTrue(self.conn.set_identity_pool_roles.call_args == expected_call_args) - self.conn.update_identity_pool.assert_not_called() + self.assertTrue(self.conn.update_identity_pool.call_count == 0) def test_present_when_pool_name_exists(self): ''' @@ -349,7 +349,7 @@ class BotoCognitoIdentityTestCase(BotoCognitoIdentityStateTestCaseBase, BotoCogn expected_call_args = (dict(IdentityPoolId=second_pool_id, Roles={'authenticated': 'my_auth_role_arn'}),) self.assertTrue(self.conn.set_identity_pool_roles.call_args == expected_call_args) - self.conn.create_identity_pool.assert_not_called() + self.assertTrue(self.conn.create_identity_pool.call_count == 0) def test_absent_when_pool_does_not_exist(self): ''' diff --git a/tests/unit/states/boto_iot_test.py b/tests/unit/states/boto_iot_test.py index 92b3997156..d57051cf79 100644 --- a/tests/unit/states/boto_iot_test.py +++ b/tests/unit/states/boto_iot_test.py @@ -197,7 +197,7 @@ class BotoIoTThingTypeTestCase(BotoIoTStateTestCaseBase, BotoIoTTestCaseMixin): ) self.assertTrue(result['result']) self.assertEqual(result['changes'], {}) - self.conn.create_thing_type.assert_not_called() + self.assertTrue(self.conn.create_thing_type.call_count == 0) def test_present_with_failure(self): self.conn.describe_thing_type.side_effect = [not_found_error, thing_type_ret] @@ -229,7 +229,7 @@ class BotoIoTThingTypeTestCase(BotoIoTStateTestCaseBase, BotoIoTTestCaseMixin): result = salt_states['boto_iot.thing_type_absent']('test', thing_type_name, **conn_parameters) self.assertTrue(result['result']) self.assertEqual(result['changes']['new']['thing_type'], None) - self.conn.deprecate_thing_type.assert_not_called() + self.assertTrue(self.conn.deprecate_thing_type.call_count == 0) def test_absent_with_deprecate_failure(self): self.conn.describe_thing_type.return_value = thing_type_ret @@ -238,7 +238,7 @@ class BotoIoTThingTypeTestCase(BotoIoTStateTestCaseBase, BotoIoTTestCaseMixin): self.assertFalse(result['result']) self.assertTrue('An error occurred' in result['comment']) self.assertTrue('deprecate_thing_type' in result['comment']) - self.conn.delete_thing_type.assert_not_called() + self.assertTrue(self.conn.delete_thing_type.call_count == 0) def test_absent_with_delete_failure(self): self.conn.describe_thing_type.return_value = deprecated_thing_type_ret @@ -247,7 +247,7 @@ class BotoIoTThingTypeTestCase(BotoIoTStateTestCaseBase, BotoIoTTestCaseMixin): self.assertFalse(result['result']) self.assertTrue('An error occurred' in result['comment']) self.assertTrue('delete_thing_type' in result['comment']) - self.conn.deprecate_thing_type.assert_not_called() + self.assertTrue(self.conn.deprecate_thing_type.call_count == 0) class BotoIoTPolicyTestCase(BotoIoTStateTestCaseBase, BotoIoTTestCaseMixin): diff --git a/tests/unit/states/grafana_datasource_test.py b/tests/unit/states/grafana_datasource_test.py index 7949c82dd1..5c6cf2866b 100644 --- a/tests/unit/states/grafana_datasource_test.py +++ b/tests/unit/states/grafana_datasource_test.py @@ -80,7 +80,7 @@ class GrafanaDatasourceTestCase(TestCase): with patch('requests.get', mock_json_response([])): with patch('requests.delete') as rdelete: ret = grafana_datasource.absent('test', profile=profile) - rdelete.assert_not_called() + self.assertTrue(rdelete.call_count == 0) self.assertTrue(ret['result']) self.assertEqual(ret['comment'], 'Data source test already absent') diff --git a/tests/unit/states/ipset_test.py b/tests/unit/states/ipset_test.py index b98554cb58..fe5a243399 100644 --- a/tests/unit/states/ipset_test.py +++ b/tests/unit/states/ipset_test.py @@ -46,7 +46,7 @@ class IpsetSetPresentTestCase(TestCase): if new_set_assertion: mock_new_set.assert_called_once_with(self.fake_name, self.fake_set_type, 'ipv4') else: - mock_new_set.assert_not_called() + self.assertTrue(mock_new_set.call_count == 0) self.assertDictEqual(actual_ret, expected_ret) def test_already_exists(self): @@ -108,11 +108,11 @@ class IpsetSetAbsentTestCase(TestCase): if flush_assertion: mock_flush.assert_called_once_with(self.fake_name, 'ipv4') else: - mock_flush.assert_not_called() + self.assertTrue(mock_flush.call_count == 0) if delete_set_assertion: mock_delete_set.assert_called_once_with(self.fake_name, 'ipv4') else: - mock_delete_set.assert_not_called() + self.assertTrue(mock_delete_set.call_count == 0) self.assertDictEqual(actual_ret, expected_ret) def test_already_absent(self): @@ -170,7 +170,7 @@ class IpsetPresentTestCase(TestCase): expected_calls = expected_calls[:1] mock_add.assert_has_calls(expected_calls, any_order=True) else: - mock_add.assert_not_called() + self.assertTrue(mock_add.call_count == 0) self.assertDictEqual(actual_ret, expected_ret) def test_entries_already_present(self): @@ -242,7 +242,7 @@ class IpsetAbsentTestCase(TestCase): expected_calls = expected_calls[:1] mock_delete.assert_has_calls(expected_calls, any_order=True) else: - mock_delete.assert_not_called() + self.assertTrue(mock_delete.call_count == 0) self.assertDictEqual(actual_ret, expected_ret) def test_already_absent(self): @@ -310,7 +310,7 @@ class IpsetFlushTestCase(TestCase): if flush_assertion: mock_flush.assert_called_once_with(self.fake_name, 'ipv4') else: - mock_flush.assert_not_called() + self.assertTrue(mock_flush.call_count == 0) self.assertDictEqual(actual_ret, expected_ret) def test_no_set(self): diff --git a/tests/unit/utils/verify_test.py b/tests/unit/utils/verify_test.py index a4af8823ab..7aff44d935 100644 --- a/tests/unit/utils/verify_test.py +++ b/tests/unit/utils/verify_test.py @@ -247,7 +247,7 @@ class TestVerify(TestCase): mock_info = MagicMock() with patch.object(log, 'warning', mock_info): verify_log({'log_level': 'info'}) - mock_info.assert_not_called() + self.assertTrue(mock_info.call_count == 0) if __name__ == '__main__': From 8dc1c780b7f92bd7f4fbdb41736a9db615d13612 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 22 Feb 2017 19:13:37 +0000 Subject: [PATCH 097/370] Add missing mock patch --- tests/unit/map_conf_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/map_conf_test.py b/tests/unit/map_conf_test.py index 6945758a8f..aa10afcc01 100644 --- a/tests/unit/map_conf_test.py +++ b/tests/unit/map_conf_test.py @@ -80,6 +80,7 @@ class MapConfTest(TestCase): Validate evaluation of salt-cloud map configuration ''' + @patch('salt.config.check_driver_dependencies', MagicMock(return_value=True)) @patch('salt.cloud.Map.read', MagicMock(return_value=EXAMPLE_MAP)) def test_cloud_map_merge_conf(self): ''' From 1416dd2e9ac1cb4d940896027f4d0f79b504cecc Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 13:17:04 +0000 Subject: [PATCH 098/370] We must compare tuples --- tests/unit/modules/docker_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/modules/docker_test.py b/tests/unit/modules/docker_test.py index dcd5c64817..5d15eec276 100644 --- a/tests/unit/modules/docker_test.py +++ b/tests/unit/modules/docker_test.py @@ -65,7 +65,7 @@ class DockerTestCase(TestCase): all=True, filters={'label': 'KEY'}) - @skipIf(_docker_py_version() > 0, 'docker-py needs to be installed for this test to run') + @skipIf(_docker_py_version() > (0,), 'docker-py needs to be installed for this test to run') @patch.object(docker_mod, '_get_exec_driver') def test_check_mine_cache_is_refreshed_on_container_change_event(self, _): ''' From a3d514476f866b13100267b15cfb09c4c02da50e Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 22 Feb 2017 19:20:15 +0000 Subject: [PATCH 099/370] Only convert bytes --- salt/modules/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 4647dd7c94..518d7bbbf4 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3657,7 +3657,7 @@ def apply_template_on_contents( opts=__opts__)['data'] if six.PY2: contents = contents.encode('utf-8') - elif six.PY3: + elif six.PY3 and isinstance(contents, bytes): # bytes -> str contents = contents.decode('utf-8') else: From 80ded62a1a757c17e9238b066012e07677fb7c78 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 22 Feb 2017 19:27:42 +0000 Subject: [PATCH 100/370] The dictionary changes while iterating. Under Python 3, we don't get a list copy of the keys. --- salt/renderers/stateconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/renderers/stateconf.py b/salt/renderers/stateconf.py index c306950e21..fe41692e3a 100644 --- a/salt/renderers/stateconf.py +++ b/salt/renderers/stateconf.py @@ -382,7 +382,7 @@ def rename_state_ids(data, sls, is_extend=False): if sid.startswith('.'): req[sname] = _local_to_abs_sid(sid, sls) - for sid in data: + for sid in list(data): if sid.startswith('.'): newsid = _local_to_abs_sid(sid, sls) if newsid in data: From 54cdacb6806a80f799c8ff320fc4c64253ec8d06 Mon Sep 17 00:00:00 2001 From: Nicolas Delaby Date: Thu, 23 Feb 2017 11:48:21 +0100 Subject: [PATCH 101/370] Reduce scope of try except StopIteration wrapping Aimed to reduce amount of code where in one hand a 3 tuple were returned and in the other hand a 2 tuple value. --- salt/cli/batch.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/salt/cli/batch.py b/salt/cli/batch.py index 4f6f8c76c7..021e536680 100644 --- a/salt/cli/batch.py +++ b/salt/cli/batch.py @@ -58,21 +58,21 @@ class Batch(object): # Broadcast to targets fret = set() nret = set() - try: - for ret in ping_gen: - if ('minions' and 'jid') in ret: - for minion in ret['minions']: - nret.add(minion) - continue - else: + for ret in ping_gen: + if ('minions' and 'jid') in ret: + for minion in ret['minions']: + nret.add(minion) + continue + else: + try: m = next(six.iterkeys(ret)) - if m is not None: - fret.add(m) - return (list(fret), ping_gen, nret.difference(fret)) - except StopIteration: - if not self.quiet: - print_cli('No minions matched the target.') - return list(fret), ping_gen + except StopIteration: + if not self.quiet: + print_cli('No minions matched the target.') + break + if m is not None: + fret.add(m) + return (list(fret), ping_gen, nret.difference(fret)) def get_bnum(self): ''' From 81bd96e32d7da294528f549471c29a9aa3b05788 Mon Sep 17 00:00:00 2001 From: Michael Calmer Date: Thu, 23 Feb 2017 12:01:05 +0100 Subject: [PATCH 102/370] fix case in os_family for Suse --- salt/modules/service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/service.py b/salt/modules/service.py index bb7133ee99..49186e4c9d 100644 --- a/salt/modules/service.py +++ b/salt/modules/service.py @@ -53,7 +53,7 @@ def __virtual__(): if __grains__['kernel'] != 'Linux': return (False, 'Non Linux OSes are not supported') # SUSE >=12.0 uses systemd - if __grains__.get('os_family', '') == 'SUSE': + if __grains__.get('os_family', '') == 'Suse': try: # osrelease might be in decimal format (e.g. "12.1"), or for # SLES might include service pack (e.g. "11 SP3"), so split on From baf84b44303ccd56cc3521ff66d71feb8930a851 Mon Sep 17 00:00:00 2001 From: Jacek Tomasiak Date: Thu, 23 Feb 2017 12:06:46 +0100 Subject: [PATCH 103/370] Ensure user/group/file_mode after line edit Ownership parameters are used in `line` only when the file doesn't exist and `create` is enabled. After editing the file is saved with default ownership. `managed` already handles file existence and `create` internally so it can be called directly and will take care of the ownership and mode in all cases. --- salt/states/file.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 7d90055fc3..8d4fc58a44 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -3178,8 +3178,7 @@ def line(name, content, match=None, mode=None, location=None, if not name: return _error(ret, 'Must provide name to file.line') - if create and not os.path.isfile(name): - managed(name, create=create, user=user, group=group, mode=file_mode) + managed(name, create=create, user=user, group=group, mode=file_mode) check_res, check_msg = _check_file(name) if not check_res: From 18effe0103d36bf70cc74bdd2bb093e03fe72793 Mon Sep 17 00:00:00 2001 From: Joe Niland Date: Mon, 20 Feb 2017 16:02:17 +1100 Subject: [PATCH 104/370] Detect IIS version and vary certificate association command depending on version --- salt/modules/win_iis.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/salt/modules/win_iis.py b/salt/modules/win_iis.py index fe6db490bf..86248500e3 100644 --- a/salt/modules/win_iis.py +++ b/salt/modules/win_iis.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import json import logging import os +import decimal # Import salt libs from salt.ext.six.moves import range @@ -77,6 +78,22 @@ def _list_certs(certificatestore='My'): return ret +def _iisVersion(): + pscmd = [] + pscmd.append(r"Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\InetStp\\") + pscmd.append(' | Select-Object MajorVersion, MinorVersion') + + cmd_ret = _srvmgr(func=str().join(pscmd), as_json=True) + + try: + items = json.loads(cmd_ret['stdout'], strict=False) + except ValueError: + _LOG.error('Unable to parse return data as Json.') + return -1 + + return decimal.Decimal("{0}.{1}".format(items[0]['MajorVersion'], items[0]['MinorVersion'])) + + def _srvmgr(func, as_json=False): ''' Execute a function from the WebAdministration PS module. @@ -492,8 +509,17 @@ def create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslf _LOG.error('Certificate not present: %s', name) return False - pscmd.append("New-Item -Path '{0}' -Thumbprint '{1}'".format(binding_path, name)) - pscmd.append(" -SSLFlags {0}".format(sslflags)) + if _iisVersion() < 8: + # IIS 7.5 and earlier have different syntax for associating a certificate with a site + iis7path = binding_path.rpartition("!")[0] + + # Modify IP spec to IIS 7.5 format + iis7path = iis7path.replace(r"\*!", "\\0.0.0.0!") + + pscmd.append("New-Item -Path '{0}' -Thumbprint '{1}'".format(iis7path, name)) + else: + pscmd.append("New-Item -Path '{0}' -Thumbprint '{1}'".format(binding_path, name)) + pscmd.append(" -SSLFlags {0}".format(sslflags)) cmd_ret = _srvmgr(str().join(pscmd)) @@ -507,6 +533,7 @@ def create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslf if name == new_cert_bindings[binding_info]['certificatehash']: _LOG.debug('Certificate binding created successfully: %s', name) return True + _LOG.error('Unable to create certificate binding: %s', name) return False From c94f0b8c623d52a55e28fea917b20e8029030658 Mon Sep 17 00:00:00 2001 From: Joe Niland Date: Tue, 21 Feb 2017 12:17:16 +1100 Subject: [PATCH 105/370] Fix additional issue whereby existing certificate bindings were not found in IIS 7.5, due to the fact that IIS earlier than 8 doesn't support SNI --- salt/modules/win_iis.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/salt/modules/win_iis.py b/salt/modules/win_iis.py index 86248500e3..9bdc8cfdfa 100644 --- a/salt/modules/win_iis.py +++ b/salt/modules/win_iis.py @@ -474,6 +474,11 @@ def create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslf pscmd = list() name = str(name).upper() binding_info = _get_binding_info(hostheader, ipaddress, port) + + if _iisVersion() < 8: + # IIS 7.5 and earlier don't support SNI for HTTPS, therefore cert bindings don't contain the host header + binding_info = binding_info.rpartition(':')[0] + ':' + binding_path = r"IIS:\SslBindings\{0}".format(binding_info.replace(':', '!')) if sslflags not in _VALID_SSL_FLAGS: @@ -511,10 +516,8 @@ def create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslf if _iisVersion() < 8: # IIS 7.5 and earlier have different syntax for associating a certificate with a site - iis7path = binding_path.rpartition("!")[0] - # Modify IP spec to IIS 7.5 format - iis7path = iis7path.replace(r"\*!", "\\0.0.0.0!") + iis7path = binding_path.replace(r"\*!", "\\0.0.0.0!") pscmd.append("New-Item -Path '{0}' -Thumbprint '{1}'".format(iis7path, name)) else: From 3a74da3fb2d34d5b1590aeda41859df4efa01a7a Mon Sep 17 00:00:00 2001 From: Jarrod Moore Date: Thu, 23 Feb 2017 22:49:00 +1100 Subject: [PATCH 106/370] Set utils property explicitly for FSClient --- salt/fileclient.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index 9be6acc5dd..6ed8723f4f 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -1340,7 +1340,8 @@ class FSClient(RemoteClient): the FSChan object ''' def __init__(self, opts): # pylint: disable=W0231 - RemoteClient.__init__(self, opts) + self.opts = opts + self.utils = salt.loader.utils(opts) self.channel = salt.fileserver.FSChan(opts) self.auth = DumbAuth() From 9bb56da61389ac827ee429eeeade9fbb0ba45afa Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 01:20:12 +0000 Subject: [PATCH 107/370] Fix skipIf call and _docker_py_version --- tests/unit/modules/docker_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/modules/docker_test.py b/tests/unit/modules/docker_test.py index 5d15eec276..64e0f6073d 100644 --- a/tests/unit/modules/docker_test.py +++ b/tests/unit/modules/docker_test.py @@ -30,7 +30,9 @@ docker_mod.__opts__ = {} def _docker_py_version(): - return docker_mod.docker.version_info if docker_mod.HAS_DOCKER_PY else (0,) + if docker_mod.HAS_DOCKER_PY: + return docker_mod.docker.version_info + return (0,) @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -65,7 +67,7 @@ class DockerTestCase(TestCase): all=True, filters={'label': 'KEY'}) - @skipIf(_docker_py_version() > (0,), 'docker-py needs to be installed for this test to run') + @skipIf(docker_mod.HAS_DOCKER_PY is False, 'docker-py needs to be installed for this test to run') @patch.object(docker_mod, '_get_exec_driver') def test_check_mine_cache_is_refreshed_on_container_change_event(self, _): ''' From 872d173769fd16f566cd059c61d67dec9d823cba Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 01:29:53 +0000 Subject: [PATCH 108/370] The `unicode` type does not exist on Py3 --- salt/states/boto_iam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/boto_iam.py b/salt/states/boto_iam.py index 6095ce9fa3..4474a1f7fa 100644 --- a/salt/states/boto_iam.py +++ b/salt/states/boto_iam.py @@ -164,7 +164,7 @@ if six.PY2: return dict([(_byteify(k), _byteify(v)) for k, v in six.iteritems(thing)]) elif isinstance(thing, list): return [_byteify(m) for m in thing] - elif isinstance(thing, unicode): # pylint: disable=W1699 + elif isinstance(thing, six.text_type): # pylint: disable=W1699 return thing.encode('utf-8') else: return thing From ce71f6d45f964eabf072300f17dc042d867be536 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 01:43:15 +0000 Subject: [PATCH 109/370] Code cleanup --- tests/unit/cloud/clouds/ec2_test.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/unit/cloud/clouds/ec2_test.py b/tests/unit/cloud/clouds/ec2_test.py index 1c7afc690c..0b2059e1ef 100644 --- a/tests/unit/cloud/clouds/ec2_test.py +++ b/tests/unit/cloud/clouds/ec2_test.py @@ -12,9 +12,6 @@ from salt.exceptions import SaltCloudSystemExit # Import Salt Testing Libs from salttesting import TestCase, skipIf from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath - -ensure_in_syspath('../../../') @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -39,8 +36,3 @@ class EC2TestCase(TestCase): self.assertRaises(SaltCloudSystemExit, ec2._validate_key_path_and_mode, key_file) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EC2TestCase, needs_daemon=False) From eb1258e18b07247eb30ad523da899630d5188921 Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Thu, 23 Feb 2017 14:21:55 +0100 Subject: [PATCH 110/370] Rework MongoDB execution module due to eval deprecation Also adds new mongodb.version method, modifies output of mongodb.user_list and doesn't grant any roles to newly created user --- salt/modules/mongodb.py | 60 ++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py index c9486933da..8c4906aba6 100644 --- a/salt/modules/mongodb.py +++ b/salt/modules/mongodb.py @@ -155,6 +155,33 @@ def db_remove(name, user=None, password=None, host=None, port=None, authdb=None) return True +def _version(mdb): + return mdb.command('buildInfo')['version'] + +def version(user=None, password=None, host=None, port=None, database='admin', authdb=None): + ''' + Get MongoDB instance version + + CLI Example: + + .. code-block:: bash + + salt '*' mongodb.version + ''' + conn = _connect(user, password, host, port, authdb=authdb) + if not conn: + return 'Failed to connect to mongo database' + + try: + mdb = pymongo.database.Database(conn, database) + return _version(mdb) + except pymongo.errors.PyMongoError as err: + log.error( + 'Listing users failed with error: {0}'.format( + str(err) + ) + ) + return str(err) def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' @@ -175,20 +202,20 @@ def user_list(user=None, password=None, host=None, port=None, database='admin', mdb = pymongo.database.Database(conn, database) output = [] - mongodb_version = mdb.eval('db.version()') + mongodb_version = _version(mdb) if LooseVersion(mongodb_version) >= LooseVersion('2.6'): - for user in mdb.eval('db.getUsers()'): - output.append([ - ('user', user['user']), - ('roles', user['roles']) - ]) + for user in mdb.command('usersInfo')['users']: + output.append( + {'user': user['user'], + 'roles': user['roles']} + ) else: for user in mdb.system.users.find(): - output.append([ - ('user', user['user']), - ('readOnly', user.get('readOnly', 'None')) - ]) + output.append( + {'user': user['user'], + 'readOnly': user.get('readOnly', 'None')} + ) return output except pymongo.errors.PyMongoError as err: @@ -223,7 +250,7 @@ def user_exists(name, user=None, password=None, host=None, port=None, return False -def user_create(name, passwd, user=None, password=None, host=None, port=None, +def user_create(name, passwd, roles=None, user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Create a Mongodb user @@ -232,16 +259,19 @@ def user_create(name, passwd, user=None, password=None, host=None, port=None, .. code-block:: bash - salt '*' mongodb.user_create + salt '*' mongodb.user_create ''' conn = _connect(user, password, host, port, authdb=authdb) if not conn: return 'Failed to connect to mongo database' + if not roles: + roles = [] + try: log.info('Creating user {0}'.format(name)) mdb = pymongo.database.Database(conn, database) - mdb.add_user(name, passwd) + mdb.add_user(name, passwd, roles=roles) except pymongo.errors.PyMongoError as err: log.error( 'Creating database {0} failed with error: {1}'.format( @@ -347,7 +377,7 @@ def user_grant_roles(name, roles, database, user=None, password=None, host=None, try: log.info('Granting roles {0} to user {1}'.format(roles, name)) mdb = pymongo.database.Database(conn, database) - mdb.eval("db.grantRolesToUser('{0}', {1})".format(name, roles)) + mdb.command("grantRolesToUser", name, roles=roles) except pymongo.errors.PyMongoError as err: log.error( 'Granting roles {0} to user {1} failed with error: {2}'.format( @@ -386,7 +416,7 @@ def user_revoke_roles(name, roles, database, user=None, password=None, host=None try: log.info('Revoking roles {0} from user {1}'.format(roles, name)) mdb = pymongo.database.Database(conn, database) - mdb.eval("db.revokeRolesFromUser('{0}', {1})".format(name, roles)) + mdb.command("revokeRolesFromUser", name, roles=roles) except pymongo.errors.PyMongoError as err: log.error( 'Revoking roles {0} from user {1} failed with error: {2}'.format( From a31d88981c21f3df81f96b9acaff67b9414ffc7e Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Thu, 23 Feb 2017 15:13:54 +0100 Subject: [PATCH 111/370] Fix lint for MongoDB module --- salt/modules/mongodb.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py index 8c4906aba6..874d76ad59 100644 --- a/salt/modules/mongodb.py +++ b/salt/modules/mongodb.py @@ -155,9 +155,11 @@ def db_remove(name, user=None, password=None, host=None, port=None, authdb=None) return True + def _version(mdb): return mdb.command('buildInfo')['version'] + def version(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Get MongoDB instance version @@ -183,6 +185,7 @@ def version(user=None, password=None, host=None, port=None, database='admin', au ) return str(err) + def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' List users of a Mongodb database From b8a558e379302e58bf66b879fa7f38bd2641f670 Mon Sep 17 00:00:00 2001 From: Nicolas Delaby Date: Thu, 23 Feb 2017 15:25:47 +0100 Subject: [PATCH 112/370] docker.APIClient constructor already accept timeout argument --- salt/modules/docker.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/salt/modules/docker.py b/salt/modules/docker.py index c00add93c3..15da476ed5 100644 --- a/salt/modules/docker.py +++ b/salt/modules/docker.py @@ -792,7 +792,10 @@ def _get_client(timeout=None): - docker.version: API version to use (default: "auto") ''' if 'docker.client' not in __context__: - client_kwargs = {} + if timeout is None: + client_kwargs = {} + else: + client_kwargs['timeout'] = timeout for key, val in (('base_url', 'docker.url'), ('version', 'docker.version')): param = __salt__['config.get'](val, NOTSET) @@ -833,10 +836,6 @@ def _get_client(timeout=None): # docker-py 2.0 renamed this client attribute __context__['docker.client'] = docker.APIClient(**client_kwargs) - # Set a new timeout if one was passed - if timeout is not None and __context__['docker.client'].timeout != timeout: - __context__['docker.client'].timeout = timeout - def _get_md5(name, path): ''' From 6761021be9dbc0c634a13826130aaedbf4be56fe Mon Sep 17 00:00:00 2001 From: Mircea Ulinic Date: Thu, 23 Feb 2017 14:28:45 +0000 Subject: [PATCH 113/370] Specify versionadded for hash functions Added in https://github.com/saltstack/salt/pull/37421 but not included in Carbon. --- salt/modules/redismod.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/salt/modules/redismod.py b/salt/modules/redismod.py index 3d3f571538..644e094c37 100644 --- a/salt/modules/redismod.py +++ b/salt/modules/redismod.py @@ -248,6 +248,8 @@ def hdel(key, *fields, **options): ''' Delete one of more hash fields. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -266,6 +268,8 @@ def hexists(key, field, host=None, port=None, db=None, password=None): ''' Determine if a hash fields exists. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -308,6 +312,8 @@ def hincrby(key, field, increment=1, host=None, port=None, db=None, password=Non ''' Increment the integer value of a hash field by the given number. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -322,6 +328,8 @@ def hincrbyfloat(key, field, increment=1.0, host=None, port=None, db=None, passw ''' Increment the float value of a hash field by the given number. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -336,6 +344,8 @@ def hlen(key, host=None, port=None, db=None, password=None): ''' Returns number of fields of a hash. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -350,6 +360,8 @@ def hmget(key, *fields, **options): ''' Returns the values of all the given hash fields. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -368,6 +380,8 @@ def hmset(key, **fieldsvals): ''' Sets multiple hash fields to multiple values. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -386,6 +400,8 @@ def hset(key, field, value, host=None, port=None, db=None, password=None): ''' Set the value of a hash field. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -400,6 +416,8 @@ def hsetnx(key, field, value, host=None, port=None, db=None, password=None): ''' Set the value of a hash field only if the field does not exist. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -414,6 +432,8 @@ def hvals(key, host=None, port=None, db=None, password=None): ''' Return all the values in a hash. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -428,6 +448,8 @@ def hscan(key, cursor=0, match=None, count=None, host=None, port=None, db=None, ''' Incrementally iterate hash fields and associated values. + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash From 6f6d278532755163b6a79125862ec7bd5af9477c Mon Sep 17 00:00:00 2001 From: "marco.messerschmidt" Date: Thu, 23 Feb 2017 15:41:08 +0100 Subject: [PATCH 114/370] fix pylint warning --- salt/modules/mount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/mount.py b/salt/modules/mount.py index 5c9e9ca55f..85ba55494f 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -82,7 +82,7 @@ def _active_mountinfo(ret): 'root': comps[3], 'opts': _resolve_user_group_names(comps[5].split(',')), 'fstype': comps[_sep + 1], - 'device': device_name.replace('\\040','\ '), + 'device': device_name.replace('\\040', '\ '), 'alt_device': _list.get(comps[4], None), 'superopts': _resolve_user_group_names(comps[_sep + 3].split(',')), 'device_uuid': device_uuid, @@ -539,7 +539,7 @@ def set_fstab( # preserve arguments for updating entry_args = { 'name': name, - 'device': device.replace('\ ','\\040'), + 'device': device.replace('\ ', '\\040'), 'fstype': fstype, 'opts': opts, 'dump': dump, From 9b0427c27a0cfb6dcd82c6051dcdf3e91beab73e Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Thu, 23 Feb 2017 17:02:09 +0200 Subject: [PATCH 115/370] state.file: drop non-relevant examples for `source_hash` parameter --- salt/states/file.py | 78 +++++---------------------------------------- 1 file changed, 8 insertions(+), 70 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index c8266ab1df..3f0ca30849 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -1144,7 +1144,7 @@ def managed(name, will not be changed or managed. If the file is hosted on a HTTP or FTP server then the source_hash - argument is also required + argument is also required. A list of sources can also be passed in to provide a default source and a set of fallbacks. The first source in the list that is found to exist @@ -3055,7 +3055,7 @@ def blockreplace( will not be changed or managed. If the file is hosted on a HTTP or FTP server then the source_hash - argument is also required + argument is also required. A list of sources can also be passed in to provide a default source and a set of fallbacks. The first source in the list that is found to exist @@ -3064,7 +3064,8 @@ def blockreplace( .. code-block:: yaml file_override_example: - file.managed: + file.blockreplace: + - name: /etc/example.conf - source: - salt://file_that_does_not_exist - salt://file_that_exists @@ -3089,45 +3090,8 @@ def blockreplace( sha1 40 md5 32 - **Using a Source Hash File** - The file can contain several checksums for several files. Each line - must contain both the file name and the hash. If no file name is - matched, the first hash encountered will be used, otherwise the most - secure hash with the correct source file name will be used. - - When using a source hash file the source_hash argument needs to be a - url, the standard download urls are supported, ftp, http, salt etc: - - Example: - - .. code-block:: yaml - - tomdroid-src-0.7.3.tar.gz: - file.managed: - - name: /tmp/tomdroid-src-0.7.3.tar.gz - - source: https://launchpad.net/tomdroid/beta/0.7.3/+download/tomdroid-src-0.7.3.tar.gz - - source_hash: https://launchpad.net/tomdroid/beta/0.7.3/+download/tomdroid-src-0.7.3.hash - - The following is an example of the supported source_hash format: - - .. code-block:: text - - /etc/rc.conf ef6e82e4006dee563d98ada2a2a80a27 - sha254c8525aee419eb649f0233be91c151178b30f0dff8ebbdcc8de71b1d5c8bcc06a /etc/resolv.conf - ead48423703509d37c4a90e6a0d53e143b6fc268 - - Debian file type ``*.dsc`` files are also supported. - - **Inserting the Source Hash in the sls Data** - Examples: - - .. code-block:: yaml - - tomdroid-src-0.7.3.tar.gz: - file.managed: - - name: /tmp/tomdroid-src-0.7.3.tar.gz - - source: https://launchpad.net/tomdroid/beta/0.7.3/+download/tomdroid-src-0.7.3.tar.gz - - source_hash: md5=79eef25f9b0b2c642c62b7f737d4f53f + See the ``source_hash`` parameter description for :mod:`file.managed + ` function for more details and examples. template The named templating engine will be used to render the downloaded file. @@ -3568,34 +3532,8 @@ def append(name, sha1 40 md5 32 - The file can contain several checksums for several files. Each line - must contain both the file name and the hash. If no file name is - matched, the first hash encountered will be used, otherwise the most - secure hash with the correct source file name will be used. - - Debian file type ``*.dsc`` is supported. - - Examples: - - .. code-block:: text - - /etc/rc.conf ef6e82e4006dee563d98ada2a2a80a27 - sha254c8525aee419eb649f0233be91c151178b30f0dff8ebbdcc8de71b1d5c8bcc06a /etc/resolv.conf - ead48423703509d37c4a90e6a0d53e143b6fc268 - - Known issues: - If the remote server URL has the hash file as an apparent - sub-directory of the source file, the module will discover that it - has already cached a directory where a file should be cached. For - example: - - .. code-block:: yaml - - tomdroid-src-0.7.3.tar.gz: - file.managed: - - name: /tmp/tomdroid-src-0.7.3.tar.gz - - source: https://launchpad.net/tomdroid/beta/0.7.3/+download/tomdroid-src-0.7.3.tar.gz - - source_hash: https://launchpad.net/tomdroid/beta/0.7.3/+download/tomdroid-src-0.7.3.tar.gz/+md5 + See the ``source_hash`` parameter description for :mod:`file.managed + ` function for more details and examples. template The named templating engine will be used to render the appended-to file. From 71164348e706a458bbc962dae8213520515c6abd Mon Sep 17 00:00:00 2001 From: rallytime Date: Thu, 23 Feb 2017 09:36:14 -0700 Subject: [PATCH 116/370] [2016.11] Pylint: add missing import --- salt/states/ssh_known_hosts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/states/ssh_known_hosts.py b/salt/states/ssh_known_hosts.py index 64120c7f98..0de1414912 100644 --- a/salt/states/ssh_known_hosts.py +++ b/salt/states/ssh_known_hosts.py @@ -25,6 +25,7 @@ import os # Import salt libs from salt.exceptions import CommandNotFoundError +import salt.utils # Define the state's virtual name __virtualname__ = 'ssh_known_hosts' From 3889006149c4d6117549cdb4f3915644a376a6c5 Mon Sep 17 00:00:00 2001 From: Jarrod Moore Date: Thu, 23 Feb 2017 21:19:53 +1100 Subject: [PATCH 117/370] Allow masterless minions to pull files from S3 --- salt/fileclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index abd9742693..88a49b2864 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -1356,7 +1356,7 @@ class FSClient(RemoteClient): the FSChan object ''' def __init__(self, opts): # pylint: disable=W0231 - self.opts = opts + RemoteClient.__init__(self, opts) self.channel = salt.fileserver.FSChan(opts) self.auth = DumbAuth() From 83ec174d4482e481ef972689411d0476e7705980 Mon Sep 17 00:00:00 2001 From: Jarrod Moore Date: Thu, 23 Feb 2017 22:49:00 +1100 Subject: [PATCH 118/370] Set utils property explicitly for FSClient --- salt/fileclient.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index 88a49b2864..6689e0bfea 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -1356,7 +1356,8 @@ class FSClient(RemoteClient): the FSChan object ''' def __init__(self, opts): # pylint: disable=W0231 - RemoteClient.__init__(self, opts) + self.opts = opts + self.utils = salt.loader.utils(opts) self.channel = salt.fileserver.FSChan(opts) self.auth = DumbAuth() From cbdf905b9f16923c6609d979fcfc1ebae7663182 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 11:21:33 -0600 Subject: [PATCH 119/370] Update test to reflect new state comment --- tests/integration/states/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/states/file.py b/tests/integration/states/file.py index d63f318064..9360fbe135 100644 --- a/tests/integration/states/file.py +++ b/tests/integration/states/file.py @@ -1775,7 +1775,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): src_file, ret = self.do_patch('hello_dolly') self.assertSaltFalseReturn(ret) self.assertInSaltComment( - 'File {0} hash mismatch after patch was applied'.format(src_file), + 'Hash mismatch after patch was applied', ret ) From a7b282fdc83763140cbc9de3a762fc4c7ec112aa Mon Sep 17 00:00:00 2001 From: "marco.messerschmidt" Date: Thu, 23 Feb 2017 19:08:52 +0100 Subject: [PATCH 120/370] fix another pylint warning --- salt/modules/mount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/mount.py b/salt/modules/mount.py index 85ba55494f..1418bc7673 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -82,7 +82,7 @@ def _active_mountinfo(ret): 'root': comps[3], 'opts': _resolve_user_group_names(comps[5].split(',')), 'fstype': comps[_sep + 1], - 'device': device_name.replace('\\040', '\ '), + 'device': device_name.replace('\\040', '\\ '), 'alt_device': _list.get(comps[4], None), 'superopts': _resolve_user_group_names(comps[_sep + 3].split(',')), 'device_uuid': device_uuid, @@ -539,7 +539,7 @@ def set_fstab( # preserve arguments for updating entry_args = { 'name': name, - 'device': device.replace('\ ', '\\040'), + 'device': device.replace('\\ ', '\\040'), 'fstype': fstype, 'opts': opts, 'dump': dump, From 9342eda377ae10e30c56a812a736f8d9b567028c Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 13:42:19 -0600 Subject: [PATCH 121/370] Fix inaccurate documentation The refresh argument does not do what was documented here. This fixes that inaccuracy. --- salt/modules/grains.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/grains.py b/salt/modules/grains.py index 2082dc03d0..be0b65ba5a 100644 --- a/salt/modules/grains.py +++ b/salt/modules/grains.py @@ -201,7 +201,7 @@ def setvals(grains, destructive=False, refresh=True): Defaults to False. refresh - Refresh minion grains using saltutil.sync_grains. + Refresh modules and pillar after adding the new grains. Defaults to True. CLI Example: @@ -299,7 +299,7 @@ def setval(key, val, destructive=False, refresh=True): Defaults to False. refresh - Refresh minion grains using saltutil.sync_grains. + Refresh modules and pillar after adding the new grain. Defaults to True. CLI Example: From e0deccb3b51ec0de2c89eab67ad1059ce96ebb37 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Thu, 23 Feb 2017 12:22:44 -0800 Subject: [PATCH 122/370] Setting valid_users and valid_commands to default to None per @cachedout 's request, then updating them to empty lists if they are still set to None. --- salt/engines/slack.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/salt/engines/slack.py b/salt/engines/slack.py index 5f08d6e553..378dc37c21 100644 --- a/salt/engines/slack.py +++ b/salt/engines/slack.py @@ -105,8 +105,8 @@ def _get_users(token): def start(token, aliases=None, - valid_users=[], - valid_commands=[], + valid_users=None, + valid_commands=None, control=False, trigger="!", groups=None, @@ -114,6 +114,13 @@ def start(token, ''' Listen to Slack events and forward them to Salt ''' + + if valid_users is None: + valid_users = [] + + if valid_commands is None: + valid_commands = [] + if __opts__.get('__role') == 'master': fire_master = salt.utils.event.get_master_event( __opts__, From b1c7e9b505074afe9e3abc682338fbb55c2883e7 Mon Sep 17 00:00:00 2001 From: Sergey Kizunov Date: Thu, 23 Feb 2017 13:57:45 -0600 Subject: [PATCH 123/370] Bonjour/Avahi beacons: Make sure TXT record length is valid TXT records are limited in length to 255 characters. Enforce this requirement. Signed-off-by: Sergey Kizunov --- salt/beacons/avahi_announce.py | 24 ++++++++++++++++++++++-- salt/beacons/bonjour_announce.py | 24 ++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/salt/beacons/avahi_announce.py b/salt/beacons/avahi_announce.py index dab81c1953..117e1ddd23 100644 --- a/salt/beacons/avahi_announce.py +++ b/salt/beacons/avahi_announce.py @@ -67,6 +67,26 @@ def __validate__(config): return True, 'Valid beacon configuration' +def _enforce_txt_record_maxlen(key, value): + ''' + Enforces the TXT record maximum length of 255 characters. + TXT record length includes key, value, and '='. + + :param str key: Key of the TXT record + :param str value: Value of the TXT record + + :rtype: str + :return: The value of the TXT record. It may be truncated if it exceeds + the maximum permitted length. In case of truncation, '...' is + appended to indicate that the entire value is not present. + ''' + # Add 1 for '=' seperator between key and value + if len(key) + len(value) + 1 > 255: + # 255 - 3 ('...') - 1 ('=') = 251 + return value[:251 - len(key)] + '...' + return value + + def beacon(config): ''' Broadcast values via zeroconf @@ -158,11 +178,11 @@ def beacon(config): grain_value = grain_value[grain_index] else: grain_value = ','.join(grain_value) - txt[item] = grain_value + txt[item] = _enforce_txt_record_maxlen(item, grain_value) if LAST_GRAINS and (LAST_GRAINS.get(grain, '') != __grains__.get(grain, '')): changes[str('txt.' + item)] = txt[item] else: - txt[item] = config['txt'][item] + txt[item] = _enforce_txt_record_maxlen(item, config['txt'][item]) if not LAST_GRAINS: changes[str('txt.' + item)] = txt[item] diff --git a/salt/beacons/bonjour_announce.py b/salt/beacons/bonjour_announce.py index 5cff20cc14..0af2928928 100644 --- a/salt/beacons/bonjour_announce.py +++ b/salt/beacons/bonjour_announce.py @@ -60,6 +60,26 @@ def __validate__(config): return True, 'Valid beacon configuration' +def _enforce_txt_record_maxlen(key, value): + ''' + Enforces the TXT record maximum length of 255 characters. + TXT record length includes key, value, and '='. + + :param str key: Key of the TXT record + :param str value: Value of the TXT record + + :rtype: str + :return: The value of the TXT record. It may be truncated if it exceeds + the maximum permitted length. In case of truncation, '...' is + appended to indicate that the entire value is not present. + ''' + # Add 1 for '=' seperator between key and value + if len(key) + len(value) + 1 > 255: + # 255 - 3 ('...') - 1 ('=') = 251 + return value[:251 - len(key)] + '...' + return value + + def beacon(config): ''' Broadcast values via zeroconf @@ -152,11 +172,11 @@ def beacon(config): grain_value = grain_value[grain_index] else: grain_value = ','.join(grain_value) - txt[item] = grain_value + txt[item] = _enforce_txt_record_maxlen(item, grain_value) if LAST_GRAINS and (LAST_GRAINS.get(grain, '') != __grains__.get(grain, '')): changes[str('txt.' + item)] = txt[item] else: - txt[item] = config['txt'][item] + txt[item] = _enforce_txt_record_maxlen(item, config['txt'][item]) if not LAST_GRAINS: changes[str('txt.' + item)] = txt[item] From 0820620ef8f203b43ccdc82d1f0f53c44fd9ee3f Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 23 Feb 2017 10:51:25 -0600 Subject: [PATCH 124/370] intialize the Client stuff in FSClient We need __utils__ in FSClient for s3:// uris. --- salt/fileclient.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index 6689e0bfea..263a0a1fdd 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -1356,8 +1356,7 @@ class FSClient(RemoteClient): the FSChan object ''' def __init__(self, opts): # pylint: disable=W0231 - self.opts = opts - self.utils = salt.loader.utils(opts) + Client.__init__(self, opts) # pylint: disable=W0233 self.channel = salt.fileserver.FSChan(opts) self.auth = DumbAuth() From bec1583bfdb24288425b6436177fbb8d48404988 Mon Sep 17 00:00:00 2001 From: coutotyler Date: Thu, 23 Feb 2017 14:18:45 -0800 Subject: [PATCH 125/370] Adding warning about arbitrary code execution --- salt/states/loop.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/salt/states/loop.py b/salt/states/loop.py index a2fec3c306..db2506722c 100644 --- a/salt/states/loop.py +++ b/salt/states/loop.py @@ -18,6 +18,12 @@ Allows for looping over execution modules. keyid: {{ access_key }} key: {{ secret_key }} instances: "{{ instance }}" + +.. warning:: + + This state allows arbitrary python code to be executed through the condition + parameter which is literally evaluated within the state. Please use caution. + ''' from __future__ import absolute_import From 15af4c97283f6276fe9ad42fd518ca399388feb3 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 01:52:00 +0000 Subject: [PATCH 126/370] Test filenames conformity. Adjust for pytest. --- .../cli/{batch.py => test_batch.py} | 0 ...custom_module.py => test_custom_module.py} | 0 .../cli/{grains.py => test_grains.py} | 0 .../client/{kwarg.py => test_kwarg.py} | 0 .../client/{runner.py => test_runner.py} | 0 .../client/{standard.py => test_standard.py} | 0 .../client/{syndic.py => test_syndic.py} | 0 ...digital_ocean.py => test_digital_ocean.py} | 0 .../cloud/providers/{ec2.py => test_ec2.py} | 0 .../cloud/providers/{gce.py => test_gce.py} | 0 .../providers/{gogrid.py => test_gogrid.py} | 0 .../providers/{joyent.py => test_joyent.py} | 0 .../providers/{linode.py => test_linode.py} | 0 .../providers/{msazure.py => test_msazure.py} | 0 .../{openstack.py => test_openstack.py} | 0 .../{profitbricks.py => test_profitbricks.py} | 0 .../{rackspace.py => test_rackspace.py} | 0 .../{virtualbox.py => test_virtualbox.py} | 0 .../providers/{vultr.py => test_vultr.py} | 0 ...{fileclient_test.py => test_fileclient.py} | 0 .../{gitfs_test.py => test_gitfs.py} | 0 .../{roots_test.py => test_roots.py} | 0 .../grains/{core.py => test_core.py} | 0 .../{ext_grains.py => test_ext_grains.py} | 0 .../{ext_modules.py => test_ext_modules.py} | 0 .../loader/{globals.py => test_globals.py} | 0 .../{interfaces.py => test_interfaces.py} | 0 .../loader/{loader.py => test_loader.py} | 0 .../minion/{blackout.py => test_blackout.py} | 0 .../minion/{pillar.py => test_pillar.py} | 0 .../minion/{timeout.py => test_timeout.py} | 0 .../modules/{aliases.py => test_aliases.py} | 0 .../modules/{archive.py => test_archive.py} | 0 .../modules/{beacons.py => test_beacons.py} | 0 .../modules/{boto_iam.py => test_boto_iam.py} | 0 .../modules/{boto_sns.py => test_boto_sns.py} | 0 .../modules/{cmdmod.py => test_cmdmod.py} | 0 .../modules/{config.py => test_config.py} | 0 .../integration/modules/{cp.py => test_cp.py} | 0 ...darwin_sysctl.py => test_darwin_sysctl.py} | 0 .../modules/{data.py => test_data.py} | 0 .../{decorators.py => test_decorators.py} | 0 .../modules/{disk.py => test_disk.py} | 0 .../modules/{django.py => test_django.py} | 0 .../modules/{event.py => test_event.py} | 0 .../modules/{file.py => test_file.py} | 0 .../modules/{gem.py => test_gem.py} | 0 ...gentoolkitmod.py => test_gentoolkitmod.py} | 0 .../modules/{git.py => test_git.py} | 0 .../modules/{grains.py => test_grains.py} | 0 .../modules/{groupadd.py => test_groupadd.py} | 0 .../modules/{hosts.py => test_hosts.py} | 0 .../modules/{key.py => test_key.py} | 0 .../{linux_acl.py => test_linux_acl.py} | 0 .../modules/{locale.py => test_locale.py} | 0 .../modules/{lxc.py => test_lxc.py} | 0 ...mac_assistive.py => test_mac_assistive.py} | 0 .../modules/{mac_brew.py => test_mac_brew.py} | 0 .../{mac_defaults.py => test_mac_defaults.py} | 0 .../{mac_desktop.py => test_mac_desktop.py} | 0 .../{mac_group.py => test_mac_group.py} | 0 .../{mac_keychain.py => test_mac_keychain.py} | 0 .../{mac_pkgutil.py => test_mac_pkgutil.py} | 0 .../{mac_ports.py => test_mac_ports.py} | 0 .../{mac_power.py => test_mac_power.py} | 0 .../{mac_service.py => test_mac_service.py} | 0 .../{mac_shadow.py => test_mac_shadow.py} | 0 ...reupdate.py => test_mac_softwareupdate.py} | 0 .../{mac_system.py => test_mac_system.py} | 0 .../{mac_timezone.py => test_mac_timezone.py} | 0 .../modules/{mac_user.py => test_mac_user.py} | 0 .../{mac_xattr.py => test_mac_xattr.py} | 0 .../modules/{mine.py => test_mine.py} | 0 .../modules/{mysql.py => test_mysql.py} | 0 .../modules/{nilrt_ip.py => test_nilrt_ip.py} | 0 .../modules/{pillar.py => test_pillar.py} | 0 .../modules/{pip.py => test_pip.py} | 0 .../modules/{pkg.py => test_pkg.py} | 0 .../modules/{publish.py => test_publish.py} | 0 .../modules/{pw_user.py => test_pw_user.py} | 0 .../modules/{rabbitmq.py => test_rabbitmq.py} | 0 ...{random_org_test.py => test_random_org.py} | 0 .../modules/{saltutil.py => test_saltutil.py} | 0 .../modules/{shadow.py => test_shadow.py} | 0 .../modules/{ssh.py => test_ssh.py} | 0 .../modules/{state.py => test_state.py} | 0 .../{supervisord.py => test_supervisord.py} | 0 .../modules/{sysctl.py => test_sysctl.py} | 0 .../modules/{sysmod.py => test_sysmod.py} | 0 .../modules/{system.py => test_system.py} | 0 .../modules/{test.py => test_test.py} | 0 .../modules/{timezone.py => test_timezone.py} | 0 .../modules/{useradd.py => test_useradd.py} | 0 .../modules/{virt.py => test_virt.py} | 0 .../{virtualenv.py => test_virtualenv.py} | 0 .../{app_test.py => test_app.py} | 0 .../{app_pam_test.py => test_app_pam.py} | 0 .../output/{output.py => test_output.py} | 0 .../reactor/{reactor.py => test_reactor.py} | 0 .../{pydsl_test.py => test_pydsl.py} | 0 ...brato_return.py => test_librato_return.py} | 0 .../{local_cache.py => test_local_cache.py} | 0 .../{fileserver.py => test_fileserver.py} | 0 .../runners/{jobs.py => test_jobs.py} | 0 .../runners/{manage.py => test_manage.py} | 0 ...nner_returns.py => test_runner_returns.py} | 0 .../runners/{salt.py => test_salt.py} | 0 .../runners/{state.py => test_state.py} | 0 .../runners/{winrepo.py => test_winrepo.py} | 0 tests/integration/sdb/{env.py => test_env.py} | 0 .../shell/{arguments.py => test_arguments.py} | 0 .../shell/{auth.py => test_auth.py} | 0 .../shell/{call.py => test_call.py} | 0 .../shell/{cloud.py => test_cloud.py} | 0 tests/integration/shell/{cp.py => test_cp.py} | 0 .../shell/{enabled.py => test_enabled.py} | 0 .../integration/shell/{key.py => test_key.py} | 0 .../shell/{master.py => test_master.py} | 0 .../{master_tops.py => test_master_tops.py} | 0 .../shell/{matcher.py => test_matcher.py} | 0 .../shell/{minion.py => test_minion.py} | 0 .../shell/{proxy.py => test_proxy.py} | 0 .../shell/{runner.py => test_runner.py} | 0 .../shell/{saltcli.py => test_saltcli.py} | 0 .../shell/{syndic.py => test_syndic.py} | 0 .../ssh/{deploy.py => test_deploy.py} | 0 .../{alternatives.py => test_alternatives.py} | 0 .../states/{archive.py => test_archive.py} | 0 .../states/{boto_sns.py => test_boto_sns.py} | 0 .../states/{bower.py => test_bower.py} | 0 .../states/{cmd.py => test_cmd.py} | 0 .../states/{compiler.py => test_compiler.py} | 0 .../states/{file.py => test_file.py} | 0 .../states/{git.py => test_git.py} | 0 .../{handle_error.py => test_handle_error.py} | 0 ...handle_iorder.py => test_handle_iorder.py} | 0 .../states/{host.py => test_host.py} | 0 .../states/{keystone.py => test_keystone.py} | 0 .../states/{match.py => test_match.py} | 0 .../states/{mysql.py => test_mysql.py} | 0 .../states/{network.py => test_network.py} | 0 .../states/{npm.py => test_npm.py} | 0 .../states/{pip.py => test_pip.py} | 0 .../states/{pkg.py => test_pkg.py} | 0 .../states/{pkgrepo.py => test_pkgrepo.py} | 0 ...rabbitmq_user.py => test_rabbitmq_user.py} | 0 ...bbitmq_vhost.py => test_rabbitmq_vhost.py} | 0 .../{renderers.py => test_renderers.py} | 0 .../states/{service.py => test_service.py} | 0 .../states/{ssh.py => test_ssh.py} | 0 .../{supervisord.py => test_supervisord.py} | 0 .../states/{svn.py => test_svn.py} | 0 .../states/{user.py => test_user.py} | 0 .../{virtualenv.py => test_virtualenv.py} | 0 .../wheel/{client.py => test_client.py} | 0 .../integration/wheel/{key.py => test_key.py} | 0 .../acl/{client_test.py => test_client.py} | 0 ...{adb_beacon_test.py => test_adb_beacon.py} | 0 .../beacons/{glxinfo.py => test_glxinfo.py} | 0 ..._beacon_test.py => test_inotify_beacon.py} | 0 .../{localfs_test.py => test_localfs.py} | 0 .../unit/cli/{batch_test.py => test_batch.py} | 0 ...siondata_test.py => test_dimensiondata.py} | 0 .../cloud/clouds/{ec2_test.py => test_ec2.py} | 0 .../cloud/clouds/{gce_test.py => test_gce.py} | 0 .../clouds/{joyent_test.py => test_joyent.py} | 0 .../clouds/{linode_test.py => test_linode.py} | 0 ...{opennebula_test.py => test_opennebula.py} | 0 .../{saltify_test.py => test_saltify.py} | 0 .../clouds/{vmware_test.py => test_vmware.py} | 0 .../{libcloud_test.py => test_libcloud.py} | 0 .../schemas/{ssh_test.py => test_ssh.py} | 0 .../unit/config/{api_test.py => test_api.py} | 0 .../config/{config_test.py => test_config.py} | 0 ...{sqs_events_test.py => test_sqs_events.py} | 0 .../{gitfs_test.py => test_gitfs.py} | 0 .../fileserver/{map_test.py => test_map.py} | 0 .../grains/{core_test.py => test_core.py} | 0 tests/unit/modules/network_test.py | 365 ----------------- .../{aliases_test.py => test_aliases.py} | 0 ...ernatives_test.py => test_alternatives.py} | 0 .../{apache_test.py => test_apache.py} | 0 .../{aptpkg_test.py => test_aptpkg.py} | 0 .../{archive_test.py => test_archive.py} | 0 ...rtifactory_test.py => test_artifactory.py} | 0 tests/unit/modules/{at_test.py => test_at.py} | 0 ...{augeas_cfg_test.py => test_augeas_cfg.py} | 0 .../modules/{bluez_test.py => test_bluez.py} | 0 ...ateway_test.py => test_boto_apigateway.py} | 0 ...dtrail_test.py => test_boto_cloudtrail.py} | 0 ..._test.py => test_boto_cloudwatch_event.py} | 0 ...y_test.py => test_boto_cognitoidentity.py} | 0 ...t.py => test_boto_elasticsearch_domain.py} | 0 .../{boto_elb_test.py => test_boto_elb.py} | 0 .../{boto_iot_test.py => test_boto_iot.py} | 0 ...oto_lambda_test.py => test_boto_lambda.py} | 0 ..._bucket_test.py => test_boto_s3_bucket.py} | 0 ...secgroup_test.py => test_boto_secgroup.py} | 0 .../{boto_vpc_test.py => test_boto_vpc.py} | 0 .../modules/{bower_test.py => test_bower.py} | 0 .../{bridge_test.py => test_bridge.py} | 0 .../modules/{btrfs_test.py => test_btrfs.py} | 0 .../{cassandra_test.py => test_cassandra.py} | 0 ...ndra_cql_test.py => test_cassandra_cql.py} | 0 .../modules/{chef_test.py => test_chef.py} | 0 .../{cmdmod_test.py => test_cmdmod.py} | 0 .../{composer_test.py => test_composer.py} | 0 .../{config_test.py => test_config.py} | 0 tests/unit/modules/{cp_test.py => test_cp.py} | 0 .../modules/{cpan_test.py => test_cpan.py} | 0 .../modules/{cron_test.py => test_cron.py} | 0 .../unit/modules/{cyg_test.py => test_cyg.py} | 0 ...aemontools_test.py => test_daemontools.py} | 0 .../modules/{data_test.py => test_data.py} | 0 .../modules/{ddns_test.py => test_ddns.py} | 0 ...{deb_apache_test.py => test_deb_apache.py} | 0 ..._postgres_test.py => test_deb_postgres.py} | 0 ...{debconfmod_test.py => test_debconfmod.py} | 0 .../{debian_ip_test.py => test_debian_ip.py} | 0 ...service_test.py => test_debian_service.py} | 0 .../{defaults_test.py => test_defaults.py} | 0 .../{devmap_test.py => test_devmap.py} | 0 .../unit/modules/{dig_test.py => test_dig.py} | 0 .../modules/{disk_test.py => test_disk.py} | 0 .../{djangomod_test.py => test_djangomod.py} | 0 .../{dnsmasq_test.py => test_dnsmasq.py} | 0 .../{dnsutil_test.py => test_dnsutil.py} | 0 .../{docker_test.py => test_docker.py} | 0 .../modules/{dpkg_test.py => test_dpkg.py} | 0 .../modules/{drac_test.py => test_drac.py} | 0 .../modules/{drbd_test.py => test_drbd.py} | 0 .../{environ_test.py => test_environ.py} | 0 .../{etcd_mod_test.py => test_etcd_mod.py} | 0 .../modules/{event_test.py => test_event.py} | 0 .../modules/{extfs_test.py => test_extfs.py} | 0 .../modules/{file_test.py => test_file.py} | 0 .../{firewalld_test.py => test_firewalld.py} | 0 .../unit/modules/{gem_test.py => test_gem.py} | 0 .../{genesis_test.py => test_genesis.py} | 0 ...service_test.py => test_gentoo_service.py} | 0 .../unit/modules/{git_test.py => test_git.py} | 0 .../{glusterfs_test.py => test_glusterfs.py} | 0 ...medesktop_test.py => test_gnomedesktop.py} | 0 .../{grains_test.py => test_grains.py} | 0 .../{groupadd_test.py => test_groupadd.py} | 0 ...rub_legacy_test.py => test_grub_legacy.py} | 0 .../{guestfs_test.py => test_guestfs.py} | 0 .../{hadoop_test.py => test_hadoop.py} | 0 ...aproxyconn_test.py => test_haproxyconn.py} | 0 .../{hashutil_test.py => test_hashutil.py} | 0 tests/unit/modules/{hg_test.py => test_hg.py} | 0 .../{hipchat_test.py => test_hipchat.py} | 0 .../modules/{hosts_test.py => test_hosts.py} | 0 .../{htpasswd_test.py => test_htpasswd.py} | 0 .../modules/{http_test.py => test_http.py} | 0 .../unit/modules/{ilo_test.py => test_ilo.py} | 0 .../{incron_test.py => test_incron.py} | 0 .../{influx08_test.py => test_influx08.py} | 0 ...{ini_manage_test.py => test_ini_manage.py} | 0 ...ctor_test.py => test_inspect_collector.py} | 0 ...pect_fsdb_test.py => test_inspect_fsdb.py} | 0 ...{introspect_test.py => test_introspect.py} | 0 .../modules/{ipset_test.py => test_ipset.py} | 0 .../{iptables_test.py => test_iptables.py} | 0 .../{jboss7_test.py => test_jboss7.py} | 0 ...{jboss7_cli_test.py => test_jboss7_cli.py} | 0 .../unit/modules/{k8s_test.py => test_k8s.py} | 0 .../{kapacitor_test.py => test_kapacitor.py} | 0 .../unit/modules/{key_test.py => test_key.py} | 0 .../{keyboard_test.py => test_keyboard.py} | 0 .../{keystone_test.py => test_keystone.py} | 0 .../modules/{kmod_test.py => test_kmod.py} | 0 .../{launchctl_test.py => test_launchctl.py} | 0 .../{ldapmod_test.py => test_ldapmod.py} | 0 ...cloud_dns_test.py => test_libcloud_dns.py} | 0 .../{linux_acl_test.py => test_linux_acl.py} | 0 .../{linux_lvm_test.py => test_linux_lvm.py} | 0 ...ux_sysctl_test.py => test_linux_sysctl.py} | 0 .../{localemod_test.py => test_localemod.py} | 0 .../{locate_test.py => test_locate.py} | 0 .../{logadm_test.py => test_logadm.py} | 0 .../{logrotate_test.py => test_logrotate.py} | 0 .../unit/modules/{lvs_test.py => test_lvs.py} | 0 ...ssistive_test.py => test_mac_assistive.py} | 0 .../{mac_brew_test.py => test_mac_brew.py} | 0 ..._defaults_test.py => test_mac_defaults.py} | 0 ...ac_desktop_test.py => test_mac_desktop.py} | 0 .../{mac_group_test.py => test_mac_group.py} | 0 ..._keychain_test.py => test_mac_keychain.py} | 0 ...ac_package_test.py => test_mac_package.py} | 0 ...ac_pkgutil_test.py => test_mac_pkgutil.py} | 0 .../{mac_power_test.py => test_mac_power.py} | 0 ...{mac_sysctl_test.py => test_mac_sysctl.py} | 0 .../{mac_user_test.py => test_mac_user.py} | 0 .../{mac_xattr_test.py => test_mac_xattr.py} | 0 .../modules/{mdadm_test.py => test_mdadm.py} | 0 .../{memcached_test.py => test_memcached.py} | 0 .../modules/{mine_test.py => test_mine.py} | 0 ...{mod_random_test.py => test_mod_random.py} | 0 .../modules/{modjk_test.py => test_modjk.py} | 0 .../modules/{monit_test.py => test_monit.py} | 0 .../{moosefs_test.py => test_moosefs.py} | 0 .../modules/{mount_test.py => test_mount.py} | 0 .../modules/{munin_test.py => test_munin.py} | 0 .../modules/{mysql_test.py => test_mysql.py} | 0 .../{nagios_test.py => test_nagios.py} | 0 .../{netscaler_test.py => test_netscaler.py} | 0 tests/unit/modules/test_network.py | 366 +++++++++++++++++- tests/unit/modules/test_network_utils.py | 25 ++ .../{neutron_test.py => test_neutron.py} | 0 .../modules/{nfs3_test.py => test_nfs3.py} | 0 .../{nftables_test.py => test_nftables.py} | 0 .../modules/{nginx_test.py => test_nginx.py} | 0 .../modules/{nova_test.py => test_nova.py} | 0 .../unit/modules/{npm_test.py => test_npm.py} | 0 ...{openbsdpkg_test.py => test_openbsdpkg.py} | 0 .../{openscap_test.py => test_openscap.py} | 0 ...onfig_test.py => test_openstack_config.py} | 0 .../{oracle_test.py => test_oracle.py} | 0 .../{pacman_test.py => test_pacman.py} | 0 .../{pagerduty_test.py => test_pagerduty.py} | 0 .../unit/modules/{pam_test.py => test_pam.py} | 0 .../{parallels_test.py => test_parallels.py} | 0 .../{parted_test.py => test_parted.py} | 0 .../modules/{pecl_test.py => test_pecl.py} | 0 .../{pillar_test.py => test_pillar.py} | 0 .../unit/modules/{pip_test.py => test_pip.py} | 0 ..._resource_test.py => test_pkg_resource.py} | 0 .../{pkgutil_test.py => test_pkgutil.py} | 0 ...rtage_config.py => test_portage_config.py} | 0 .../{postfix_test.py => test_postfix.py} | 0 .../{postgres_test.py => test_postgres.py} | 0 .../{poudriere_test.py => test_poudriere.py} | 0 .../{powerpath_test.py => test_powerpath.py} | 0 .../modules/{proxy_test.py => test_proxy.py} | 0 tests/unit/modules/{ps_test.py => test_ps.py} | 0 .../{publish_test.py => test_publish.py} | 0 .../{puppet_test.py => test_puppet.py} | 0 .../{pw_group_test.py => test_pw_group.py} | 0 .../{pw_user_test.py => test_pw_user.py} | 0 .../modules/{pyenv_test.py => test_pyenv.py} | 0 .../{qemu_img_test.py => test_qemu_img.py} | 0 .../{qemu_nbd_test.py => test_qemu_nbd.py} | 0 .../{rabbitmq_test.py => test_rabbitmq.py} | 0 ...t_publish_test.py => test_raet_publish.py} | 0 .../modules/{rbenv_test.py => test_rbenv.py} | 0 .../unit/modules/{rdp_test.py => test_rdp.py} | 0 .../{redismod_test.py => test_redismod.py} | 0 .../{reg_win_test.py => test_reg_win.py} | 0 .../unit/modules/{ret_test.py => test_ret.py} | 0 .../modules/{rh_ip_test.py => test_rh_ip.py} | 0 ...{rh_service_test.py => test_rh_service.py} | 0 .../modules/{riak_test.py => test_riak.py} | 0 .../unit/modules/{rpm_test.py => test_rpm.py} | 0 .../modules/{rsync_test.py => test_rsync.py} | 0 .../unit/modules/{rvm_test.py => test_rvm.py} | 0 tests/unit/modules/{s3_test.py => test_s3.py} | 0 tests/unit/modules/{s6_test.py => test_s6.py} | 0 ...tcloudmod_test.py => test_saltcloudmod.py} | 0 .../{schedule_test.py => test_schedule.py} | 0 .../modules/{scsi_test.py => test_scsi.py} | 0 .../unit/modules/{sdb_test.py => test_sdb.py} | 0 .../modules/{seed_test.py => test_seed.py} | 0 .../{sensors_test.py => test_sensors.py} | 0 ...e_test.py => test_serverdensity_device.py} | 0 .../{service_test.py => test_service.py} | 0 ...{servicenow_test.py => test_servicenow.py} | 0 .../{shadow_test.py => test_shadow.py} | 0 .../unit/modules/{smf_test.py => test_smf.py} | 0 .../modules/{smtp_test.py => test_smtp.py} | 0 .../{snapper_test.py => test_snapper.py} | 0 .../modules/{solr_test.py => test_solr.py} | 0 .../{sqlite3_test.py => test_sqlite3.py} | 0 .../unit/modules/{ssh_test.py => test_ssh.py} | 0 .../modules/{state_test.py => test_state.py} | 0 .../{status_test.py => test_status.py} | 0 ...upervisord_test.py => test_supervisord.py} | 0 .../unit/modules/{svn_test.py => test_svn.py} | 0 .../modules/{swift_test.py => test_swift.py} | 0 .../{sysbench_test.py => test_sysbench.py} | 0 .../{syslog_ng_test.py => test_syslog_ng.py} | 0 .../{sysmod_test.py => test_sysmod.py} | 0 .../{system_test.py => test_system.py} | 0 .../{systemd_test.py => test_systemd.py} | 0 .../{timezone_test.py => test_timezone.py} | 0 .../unit/modules/{tls_test.py => test_tls.py} | 0 ...o_notify_test.py => test_twilio_notify.py} | 0 .../modules/{udev_test.py => test_udev.py} | 0 .../{uptime_test.py => test_uptime.py} | 0 .../{useradd_test.py => test_useradd.py} | 0 .../modules/{uwsgi_test.py => test_uwsgi.py} | 0 .../{varnish_test.py => test_varnish.py} | 0 .../modules/{virt_test.py => test_virt.py} | 0 ...{virtualenv_test.py => test_virtualenv.py} | 0 .../{vsphere_test.py => test_vsphere.py} | 0 ..._autoruns_test.py => test_win_autoruns.py} | 0 ..._certutil_test.py => test_win_certutil.py} | 0 .../{win_disk_test.py => test_win_disk.py} | 0 .../{win_dism_test.py => test_win_dism.py} | 0 ..._client_test.py => test_win_dns_client.py} | 0 ..._firewall_test.py => test_win_firewall.py} | 0 ..._groupadd_test.py => test_win_groupadd.py} | 0 .../{win_iis_test.py => test_win_iis.py} | 0 .../{win_ip_test.py => test_win_ip.py} | 0 ...in_license_test.py => test_win_license.py} | 0 ...in_network_test.py => test_win_network.py} | 0 .../{win_ntp_test.py => test_win_ntp.py} | 0 .../{win_path_test.py => test_win_path.py} | 0 .../{win_pki_test.py => test_win_pki.py} | 0 ..._powercfg_test.py => test_win_powercfg.py} | 0 ...in_service_test.py => test_win_service.py} | 0 ...{win_shadow_test.py => test_win_shadow.py} | 0 .../{win_snmp_test.py => test_win_snmp.py} | 0 ...{win_status_test.py => test_win_status.py} | 0 ...{win_system_test.py => test_win_system.py} | 0 ..._timezone_test.py => test_win_timezone.py} | 0 .../modules/{xapi_test.py => test_xapi.py} | 0 ...{zcbuildout_test.py => test_zcbuildout.py} | 0 .../unit/modules/{zfs_test.py => test_zfs.py} | 0 .../unit/modules/{znc_test.py => test_znc.py} | 0 .../modules/{zpool_test.py => test_zpool.py} | 0 .../{zypper_test.py => test_zypper.py} | 0 .../{tools_test.py => test_tools.py} | 0 .../{json_out_test.py => test_json_out.py} | 0 .../{yaml_out_test.py => test_yaml_out.py} | 0 .../pillar/{consul_test.py => test_consul.py} | 0 .../unit/pillar/{git_test.py => test_git.py} | 0 tests/unit/pillar/{hg_test.py => test_hg.py} | 0 .../pillar/{mysql_test.py => test_mysql.py} | 0 ...{nodegroups_test.py => test_nodegroups.py} | 0 .../{sqlcipher_test.py => test_sqlcipher.py} | 0 .../{sqlite3_test.py => test_sqlite3.py} | 0 .../renderers/{gpg_test.py => test_gpg.py} | 0 .../renderers/{yaml_test.py => test_yaml.py} | 0 .../{yamlex_test.py => test_yamlex.py} | 0 ...ocal_cache_test.py => test_local_cache.py} | 0 ...mtp_return_test.py => test_smtp_return.py} | 0 .../runners/{cache_test.py => test_cache.py} | 0 .../runners/{jobs_test.py => test_jobs.py} | 0 ...erializers_test.py => test_serializers.py} | 0 ...{ssh_single_test.py => test_ssh_single.py} | 0 .../states/{alias_test.py => test_alias.py} | 0 ...ernatives_test.py => test_alternatives.py} | 0 .../states/{apache_test.py => test_apache.py} | 0 ...pache_conf_test.py => test_apache_conf.py} | 0 ...e_module_test.py => test_apache_module.py} | 0 ...pache_site_test.py => test_apache_site.py} | 0 .../unit/states/{apt_test.py => test_apt.py} | 0 .../{archive_test.py => test_archive.py} | 0 ...rtifactory_test.py => test_artifactory.py} | 0 tests/unit/states/{at_test.py => test_at.py} | 0 .../states/{augeas_test.py => test_augeas.py} | 0 .../{aws_sqs_test.py => test_aws_sqs.py} | 0 .../{blockdev_test.py => test_blockdev.py} | 0 ...ateway_test.py => test_boto_apigateway.py} | 0 .../{boto_asg_test.py => test_boto_asg.py} | 0 ...dtrail_test.py => test_boto_cloudtrail.py} | 0 ..._test.py => test_boto_cloudwatch_alarm.py} | 0 ..._test.py => test_boto_cloudwatch_event.py} | 0 ...y_test.py => test_boto_cognitoidentity.py} | 0 ...dynamodb_test.py => test_boto_dynamodb.py} | 0 .../{boto_ec2_test.py => test_boto_ec2.py} | 0 ...cache_test.py => test_boto_elasticache.py} | 0 ...t.py => test_boto_elasticsearch_domain.py} | 0 .../{boto_elb_test.py => test_boto_elb.py} | 0 ...iam_role_test.py => test_boto_iam_role.py} | 0 .../{boto_iot_test.py => test_boto_iot.py} | 0 ...o_kinesis_test.py => test_boto_kinesis.py} | 0 ...oto_lambda_test.py => test_boto_lambda.py} | 0 .../{boto_lc_test.py => test_boto_lc.py} | 0 ...o_route53_test.py => test_boto_route53.py} | 0 ..._bucket_test.py => test_boto_s3_bucket.py} | 0 ...secgroup_test.py => test_boto_secgroup.py} | 0 .../{boto_sns_test.py => test_boto_sns.py} | 0 .../{boto_sqs_test.py => test_boto_sqs.py} | 0 .../{boto_vpc_test.py => test_boto_vpc.py} | 0 .../states/{bower_test.py => test_bower.py} | 0 .../states/{chef_test.py => test_chef.py} | 0 .../states/{cloud_test.py => test_cloud.py} | 0 .../unit/states/{cmd_test.py => test_cmd.py} | 0 .../{composer_test.py => test_composer.py} | 0 .../states/{cron_test.py => test_cron.py} | 0 .../unit/states/{cyg_test.py => test_cyg.py} | 0 .../states/{ddns_test.py => test_ddns.py} | 0 ...{debconfmod_test.py => test_debconfmod.py} | 0 .../states/{disk_test.py => test_disk.py} | 0 .../states/{docker_test.py => test_docker.py} | 0 .../states/{drac_test.py => test_drac.py} | 0 .../{environ_test.py => test_environ.py} | 0 .../{eselect_test.py => test_eselect.py} | 0 .../states/{event_test.py => test_event.py} | 0 .../states/{file_test.py => test_file.py} | 0 .../unit/states/{gem_test.py => test_gem.py} | 0 .../{glusterfs_test.py => test_glusterfs.py} | 0 ...medesktop_test.py => test_gnomedesktop.py} | 0 .../{grafana_test.py => test_grafana.py} | 0 ...rce_test.py => test_grafana_datasource.py} | 0 .../states/{grains_test.py => test_grains.py} | 0 .../states/{group_test.py => test_group.py} | 0 tests/unit/states/{hg_test.py => test_hg.py} | 0 .../{hipchat_test.py => test_hipchat.py} | 0 .../states/{host_test.py => test_host.py} | 0 .../{htpasswd_test.py => test_htpasswd.py} | 0 .../states/{http_test.py => test_http.py} | 0 .../states/{incron_test.py => test_incron.py} | 0 ...se_test.py => test_influxdb08_database.py} | 0 ...8_user_test.py => test_influxdb08_user.py} | 0 ...{ini_manage_test.py => test_ini_manage.py} | 0 .../states/{ipmi_test.py => test_ipmi.py} | 0 .../states/{ipset_test.py => test_ipset.py} | 0 .../{iptables_test.py => test_iptables.py} | 0 .../states/{jboss7_test.py => test_jboss7.py} | 0 .../{kapacitor_test.py => test_kapacitor.py} | 0 .../{keyboard_test.py => test_keyboard.py} | 0 .../{keystone_test.py => test_keystone.py} | 0 .../states/{kmod_test.py => test_kmod.py} | 0 .../states/{layman_test.py => test_layman.py} | 0 .../states/{ldap_test.py => test_ldap.py} | 0 ...cloud_dns_test.py => test_libcloud_dns.py} | 0 .../{libvirt_test.py => test_libvirt.py} | 0 .../{linux_acl_test.py => test_linux_acl.py} | 0 .../states/{locale_test.py => test_locale.py} | 0 .../unit/states/{lvm_test.py => test_lvm.py} | 0 ...{lvs_server_test.py => test_lvs_server.py} | 0 ...vs_service_test.py => test_lvs_service.py} | 0 .../unit/states/{lxc_test.py => test_lxc.py} | 0 ...ssistive_test.py => test_mac_assistive.py} | 0 ..._defaults_test.py => test_mac_defaults.py} | 0 ..._keychain_test.py => test_mac_keychain.py} | 0 ...ac_package_test.py => test_mac_package.py} | 0 .../{mac_xattr_test.py => test_mac_xattr.py} | 0 .../{makeconf_test.py => test_makeconf.py} | 0 .../states/{mdadm_test.py => test_mdadm.py} | 0 .../{memcached_test.py => test_memcached.py} | 0 .../states/{modjk_test.py => test_modjk.py} | 0 ...jk_worker_test.py => test_modjk_worker.py} | 0 .../states/{module_test.py => test_module.py} | 0 ...abase_test.py => test_mongodb_database.py} | 0 ...godb_user_test.py => test_mongodb_user.py} | 0 .../states/{mount_test.py => test_mount.py} | 0 ...ql_grants_test.py => test_mysql_grants.py} | 0 ...ysql_query_test.py => test_mysql_query.py} | 0 ...{mysql_user_test.py => test_mysql_user.py} | 0 .../{network_test.py => test_network.py} | 0 .../{nftables_test.py => test_nftables.py} | 0 .../unit/states/{npm_test.py => test_npm.py} | 0 .../unit/states/{ntp_test.py => test_ntp.py} | 0 ...onfig_test.py => test_openstack_config.py} | 0 ..._port_test.py => test_openvswitch_port.py} | 0 .../{pagerduty_test.py => test_pagerduty.py} | 0 .../states/{pecl_test.py => test_pecl.py} | 0 .../unit/states/{pip_test.py => test_pip.py} | 0 .../states/{pkgng_test.py => test_pkgng.py} | 0 ..._config_test.py => test_portage_config.py} | 0 .../states/{ports_test.py => test_ports.py} | 0 .../{postgres_test.py => test_postgres.py} | 0 ...uster_test.py => test_postgres_cluster.py} | 0 ...base_test.py => test_postgres_database.py} | 0 ...ion_test.py => test_postgres_extension.py} | 0 ...s_group_test.py => test_postgres_group.py} | 0 ...initdb_test.py => test_postgres_initdb.py} | 0 ...uage_test.py => test_postgres_language.py} | 0 ...es_test.py => test_postgres_privileges.py} | 0 ...schema_test.py => test_postgres_schema.py} | 0 ...res_user_test.py => test_postgres_user.py} | 0 .../{powerpath_test.py => test_powerpath.py} | 0 .../{process_test.py => test_process.py} | 0 .../states/{proxy_test.py => test_proxy.py} | 0 .../states/{pyenv_test.py => test_pyenv.py} | 0 ...ax_queues_test.py => test_pyrax_queues.py} | 0 .../states/{quota_test.py => test_quota.py} | 0 ...uster_test.py => test_rabbitmq_cluster.py} | 0 ...plugin_test.py => test_rabbitmq_plugin.py} | 0 ...policy_test.py => test_rabbitmq_policy.py} | 0 ...q_vhost_test.py => test_rabbitmq_vhost.py} | 0 .../states/{rbenv_test.py => test_rbenv.py} | 0 .../unit/states/{rdp_test.py => test_rdp.py} | 0 .../{redismod_test.py => test_redismod.py} | 0 .../unit/states/{reg_test.py => test_reg.py} | 0 .../unit/states/{rvm_test.py => test_rvm.py} | 0 .../{saltmod_test.py => test_saltmod.py} | 0 .../{schedule_test.py => test_schedule.py} | 0 .../{selinux_test.py => test_selinux.py} | 0 ...e_test.py => test_serverdensity_device.py} | 0 .../{service_test.py => test_service.py} | 0 .../states/{slack_test.py => test_slack.py} | 0 .../states/{smtp_test.py => test_smtp.py} | 0 ...k_search_test.py => test_splunk_search.py} | 0 .../{ssh_auth_test.py => test_ssh_auth.py} | 0 ..._hosts_test.py => test_ssh_known_hosts.py} | 0 .../states/{status_test.py => test_status.py} | 0 ...upervisord_test.py => test_supervisord.py} | 0 .../unit/states/{svn_test.py => test_svn.py} | 0 .../states/{sysctl_test.py => test_sysctl.py} | 0 .../{syslog_ng_test.py => test_syslog_ng.py} | 0 .../states/{sysrc_test.py => test_sysrc.py} | 0 .../{timezone_test.py => test_timezone.py} | 0 .../states/{tomcat_test.py => test_tomcat.py} | 0 .../states/{user_test.py => test_user.py} | 0 ...{vbox_guest_test.py => test_vbox_guest.py} | 0 ...env_mod_test.py => test_virtualenv_mod.py} | 0 ..._certutil_test.py => test_win_certutil.py} | 0 .../{win_dism_test.py => test_win_dism.py} | 0 ..._client_test.py => test_win_dns_client.py} | 0 ..._firewall_test.py => test_win_firewall.py} | 0 ...in_license_test.py => test_win_license.py} | 0 ...in_network_test.py => test_win_network.py} | 0 .../{win_path_test.py => test_win_path.py} | 0 .../{win_pki_test.py => test_win_pki.py} | 0 ..._powercfg_test.py => test_win_powercfg.py} | 0 ...ager_test.py => test_win_servermanager.py} | 0 .../{win_snmp_test.py => test_win_snmp.py} | 0 ...{win_system_test.py => test_win_system.py} | 0 ...{win_update_test.py => test_win_update.py} | 0 .../{winrepo_test.py => test_winrepo.py} | 0 .../states/{xmpp_test.py => test_xmpp.py} | 0 ...{zcbuildout_test.py => test_zcbuildout.py} | 0 ...urrency_test.py => test_zk_concurrency.py} | 0 .../{jinja_test.py => test_jinja.py} | 0 tests/unit/{auth_test.py => test_auth.py} | 0 tests/unit/{client_test.py => test_client.py} | 0 tests/unit/{conf_test.py => test_conf.py} | 0 .../unit/{context_test.py => test_context.py} | 0 tests/unit/{crypt_test.py => test_crypt.py} | 0 .../unit/{daemons_test.py => test_daemons.py} | 0 tests/unit/{doc_test.py => test_doc.py} | 0 tests/unit/{files_test.py => test_files.py} | 0 tests/unit/{log_test.py => test_log.py} | 0 .../{map_conf_test.py => test_map_conf.py} | 0 tests/unit/{minion_test.py => test_minion.py} | 0 .../unit/{payload_test.py => test_payload.py} | 0 tests/unit/{pillar_test.py => test_pillar.py} | 0 tests/unit/{pydsl_test.py => test_pydsl.py} | 0 .../{pyobjects_test.py => test_pyobjects.py} | 0 tests/unit/{simple_test.py => test_simple.py} | 0 tests/unit/{spm_test.py => test_spm.py} | 0 tests/unit/{state_test.py => test_state.py} | 0 .../{stateconf_test.py => test_stateconf.py} | 0 .../{statemod_test.py => test_statemod.py} | 0 tests/unit/{target_test.py => test_target.py} | 0 .../{template_test.py => test_template.py} | 0 .../unit/{version_test.py => test_version.py} | 0 .../transport/{ipc_test.py => test_ipc.py} | 0 .../transport/{pub_test.py => test_pub.py} | 0 .../transport/{req_test.py => test_req.py} | 0 .../transport/{tcp_test.py => test_tcp.py} | 0 .../{zeromq_test.py => test_zeromq.py} | 0 ...ggregation_test.py => test_aggregation.py} | 0 .../unit/utils/{args_test.py => test_args.py} | 0 .../utils/{async_test.py => test_async.py} | 0 .../unit/utils/{boto_test.py => test_boto.py} | 0 .../utils/{cache_test.py => test_cache.py} | 0 .../utils/{cloud_test.py => test_cloud.py} | 0 ...omparer_test.py => test_configcomparer.py} | 0 .../{context_test.py => test_context.py} | 0 ...{decorators_test.py => test_decorators.py} | 0 ...{dictupdate_test.py => test_dictupdate.py} | 0 ...{disk_cache_test.py => test_disk_cache.py} | 0 .../{etcd_util_test.py => test_etcd_util.py} | 0 .../utils/{event_test.py => test_event.py} | 0 .../utils/{extend_test.py => test_extend.py} | 0 ...{filebuffer_test.py => test_filebuffer.py} | 0 .../unit/utils/{find_test.py => test_find.py} | 0 ...ormat_call_test.py => test_format_call.py} | 0 .../utils/{gitfs_test.py => test_gitfs.py} | 0 .../unit/utils/{http_test.py => test_http.py} | 0 ...letypes_test.py => test_immutabletypes.py} | 0 ...warg_regex_test.py => test_kwarg_regex.py} | 0 .../{locales_test.py => test_locales.py} | 0 .../{mac_utils_test.py => test_mac_utils.py} | 0 .../{minions_test.py => test_minions.py} | 0 .../{network_test.py => test_network.py} | 0 .../{parsers_test.py => test_parsers.py} | 0 .../{path_join_test.py => test_path_join.py} | 0 .../{process_test.py => test_process.py} | 0 .../{rsax931_test.py => test_rsax931.py} | 0 ...st.py => test_runtime_whitespace_regex.py} | 0 .../{safe_walk_test.py => test_safe_walk.py} | 0 ...{sanitizers_test.py => test_sanitizers.py} | 0 .../{schedule_test.py => test_schedule.py} | 0 .../utils/{schema_test.py => test_schema.py} | 0 .../{systemd_test.py => test_systemd.py} | 0 tests/unit/utils/{url_test.py => test_url.py} | 0 .../utils/{utils_test.py => test_utils.py} | 0 ...idate_net_test.py => test_validate_net.py} | 0 .../utils/{verify_test.py => test_verify.py} | 0 tests/unit/utils/{vt_test.py => test_vt.py} | 0 .../{warnings_test.py => test_warnings.py} | 0 .../utils/{which_test.py => test_which.py} | 0 ...{yamlloader_test.py => test_yamlloader.py} | 0 .../{cluster_test.py => test_cluster.py} | 0 .../{common_test.py => test_common.py} | 0 ...{connection_test.py => test_connection.py} | 0 ...{datacenter_test.py => test_datacenter.py} | 0 .../{host_test.py => test_host.py} | 0 695 files changed, 378 insertions(+), 378 deletions(-) rename tests/integration/cli/{batch.py => test_batch.py} (100%) rename tests/integration/cli/{custom_module.py => test_custom_module.py} (100%) rename tests/integration/cli/{grains.py => test_grains.py} (100%) rename tests/integration/client/{kwarg.py => test_kwarg.py} (100%) rename tests/integration/client/{runner.py => test_runner.py} (100%) rename tests/integration/client/{standard.py => test_standard.py} (100%) rename tests/integration/client/{syndic.py => test_syndic.py} (100%) rename tests/integration/cloud/providers/{digital_ocean.py => test_digital_ocean.py} (100%) rename tests/integration/cloud/providers/{ec2.py => test_ec2.py} (100%) rename tests/integration/cloud/providers/{gce.py => test_gce.py} (100%) rename tests/integration/cloud/providers/{gogrid.py => test_gogrid.py} (100%) rename tests/integration/cloud/providers/{joyent.py => test_joyent.py} (100%) rename tests/integration/cloud/providers/{linode.py => test_linode.py} (100%) rename tests/integration/cloud/providers/{msazure.py => test_msazure.py} (100%) rename tests/integration/cloud/providers/{openstack.py => test_openstack.py} (100%) rename tests/integration/cloud/providers/{profitbricks.py => test_profitbricks.py} (100%) rename tests/integration/cloud/providers/{rackspace.py => test_rackspace.py} (100%) rename tests/integration/cloud/providers/{virtualbox.py => test_virtualbox.py} (100%) rename tests/integration/cloud/providers/{vultr.py => test_vultr.py} (100%) rename tests/integration/fileserver/{fileclient_test.py => test_fileclient.py} (100%) rename tests/integration/fileserver/{gitfs_test.py => test_gitfs.py} (100%) rename tests/integration/fileserver/{roots_test.py => test_roots.py} (100%) rename tests/integration/grains/{core.py => test_core.py} (100%) rename tests/integration/loader/{ext_grains.py => test_ext_grains.py} (100%) rename tests/integration/loader/{ext_modules.py => test_ext_modules.py} (100%) rename tests/integration/loader/{globals.py => test_globals.py} (100%) rename tests/integration/loader/{interfaces.py => test_interfaces.py} (100%) rename tests/integration/loader/{loader.py => test_loader.py} (100%) rename tests/integration/minion/{blackout.py => test_blackout.py} (100%) rename tests/integration/minion/{pillar.py => test_pillar.py} (100%) rename tests/integration/minion/{timeout.py => test_timeout.py} (100%) rename tests/integration/modules/{aliases.py => test_aliases.py} (100%) rename tests/integration/modules/{archive.py => test_archive.py} (100%) rename tests/integration/modules/{beacons.py => test_beacons.py} (100%) rename tests/integration/modules/{boto_iam.py => test_boto_iam.py} (100%) rename tests/integration/modules/{boto_sns.py => test_boto_sns.py} (100%) rename tests/integration/modules/{cmdmod.py => test_cmdmod.py} (100%) rename tests/integration/modules/{config.py => test_config.py} (100%) rename tests/integration/modules/{cp.py => test_cp.py} (100%) rename tests/integration/modules/{darwin_sysctl.py => test_darwin_sysctl.py} (100%) rename tests/integration/modules/{data.py => test_data.py} (100%) rename tests/integration/modules/{decorators.py => test_decorators.py} (100%) rename tests/integration/modules/{disk.py => test_disk.py} (100%) rename tests/integration/modules/{django.py => test_django.py} (100%) rename tests/integration/modules/{event.py => test_event.py} (100%) rename tests/integration/modules/{file.py => test_file.py} (100%) rename tests/integration/modules/{gem.py => test_gem.py} (100%) rename tests/integration/modules/{gentoolkitmod.py => test_gentoolkitmod.py} (100%) rename tests/integration/modules/{git.py => test_git.py} (100%) rename tests/integration/modules/{grains.py => test_grains.py} (100%) rename tests/integration/modules/{groupadd.py => test_groupadd.py} (100%) rename tests/integration/modules/{hosts.py => test_hosts.py} (100%) rename tests/integration/modules/{key.py => test_key.py} (100%) rename tests/integration/modules/{linux_acl.py => test_linux_acl.py} (100%) rename tests/integration/modules/{locale.py => test_locale.py} (100%) rename tests/integration/modules/{lxc.py => test_lxc.py} (100%) rename tests/integration/modules/{mac_assistive.py => test_mac_assistive.py} (100%) rename tests/integration/modules/{mac_brew.py => test_mac_brew.py} (100%) rename tests/integration/modules/{mac_defaults.py => test_mac_defaults.py} (100%) rename tests/integration/modules/{mac_desktop.py => test_mac_desktop.py} (100%) rename tests/integration/modules/{mac_group.py => test_mac_group.py} (100%) rename tests/integration/modules/{mac_keychain.py => test_mac_keychain.py} (100%) rename tests/integration/modules/{mac_pkgutil.py => test_mac_pkgutil.py} (100%) rename tests/integration/modules/{mac_ports.py => test_mac_ports.py} (100%) rename tests/integration/modules/{mac_power.py => test_mac_power.py} (100%) rename tests/integration/modules/{mac_service.py => test_mac_service.py} (100%) rename tests/integration/modules/{mac_shadow.py => test_mac_shadow.py} (100%) rename tests/integration/modules/{mac_softwareupdate.py => test_mac_softwareupdate.py} (100%) rename tests/integration/modules/{mac_system.py => test_mac_system.py} (100%) rename tests/integration/modules/{mac_timezone.py => test_mac_timezone.py} (100%) rename tests/integration/modules/{mac_user.py => test_mac_user.py} (100%) rename tests/integration/modules/{mac_xattr.py => test_mac_xattr.py} (100%) rename tests/integration/modules/{mine.py => test_mine.py} (100%) rename tests/integration/modules/{mysql.py => test_mysql.py} (100%) rename tests/integration/modules/{nilrt_ip.py => test_nilrt_ip.py} (100%) rename tests/integration/modules/{pillar.py => test_pillar.py} (100%) rename tests/integration/modules/{pip.py => test_pip.py} (100%) rename tests/integration/modules/{pkg.py => test_pkg.py} (100%) rename tests/integration/modules/{publish.py => test_publish.py} (100%) rename tests/integration/modules/{pw_user.py => test_pw_user.py} (100%) rename tests/integration/modules/{rabbitmq.py => test_rabbitmq.py} (100%) rename tests/integration/modules/{random_org_test.py => test_random_org.py} (100%) rename tests/integration/modules/{saltutil.py => test_saltutil.py} (100%) rename tests/integration/modules/{shadow.py => test_shadow.py} (100%) rename tests/integration/modules/{ssh.py => test_ssh.py} (100%) rename tests/integration/modules/{state.py => test_state.py} (100%) rename tests/integration/modules/{supervisord.py => test_supervisord.py} (100%) rename tests/integration/modules/{sysctl.py => test_sysctl.py} (100%) rename tests/integration/modules/{sysmod.py => test_sysmod.py} (100%) rename tests/integration/modules/{system.py => test_system.py} (100%) rename tests/integration/modules/{test.py => test_test.py} (100%) rename tests/integration/modules/{timezone.py => test_timezone.py} (100%) rename tests/integration/modules/{useradd.py => test_useradd.py} (100%) rename tests/integration/modules/{virt.py => test_virt.py} (100%) rename tests/integration/modules/{virtualenv.py => test_virtualenv.py} (100%) rename tests/integration/netapi/rest_cherrypy/{app_test.py => test_app.py} (100%) rename tests/integration/netapi/rest_cherrypy/{app_pam_test.py => test_app_pam.py} (100%) rename tests/integration/output/{output.py => test_output.py} (100%) rename tests/integration/reactor/{reactor.py => test_reactor.py} (100%) rename tests/integration/renderers/{pydsl_test.py => test_pydsl.py} (100%) rename tests/integration/returners/{librato_return.py => test_librato_return.py} (100%) rename tests/integration/returners/{local_cache.py => test_local_cache.py} (100%) rename tests/integration/runners/{fileserver.py => test_fileserver.py} (100%) rename tests/integration/runners/{jobs.py => test_jobs.py} (100%) rename tests/integration/runners/{manage.py => test_manage.py} (100%) rename tests/integration/runners/{runner_returns.py => test_runner_returns.py} (100%) rename tests/integration/runners/{salt.py => test_salt.py} (100%) rename tests/integration/runners/{state.py => test_state.py} (100%) rename tests/integration/runners/{winrepo.py => test_winrepo.py} (100%) rename tests/integration/sdb/{env.py => test_env.py} (100%) rename tests/integration/shell/{arguments.py => test_arguments.py} (100%) rename tests/integration/shell/{auth.py => test_auth.py} (100%) rename tests/integration/shell/{call.py => test_call.py} (100%) rename tests/integration/shell/{cloud.py => test_cloud.py} (100%) rename tests/integration/shell/{cp.py => test_cp.py} (100%) rename tests/integration/shell/{enabled.py => test_enabled.py} (100%) rename tests/integration/shell/{key.py => test_key.py} (100%) rename tests/integration/shell/{master.py => test_master.py} (100%) rename tests/integration/shell/{master_tops.py => test_master_tops.py} (100%) rename tests/integration/shell/{matcher.py => test_matcher.py} (100%) rename tests/integration/shell/{minion.py => test_minion.py} (100%) rename tests/integration/shell/{proxy.py => test_proxy.py} (100%) rename tests/integration/shell/{runner.py => test_runner.py} (100%) rename tests/integration/shell/{saltcli.py => test_saltcli.py} (100%) rename tests/integration/shell/{syndic.py => test_syndic.py} (100%) rename tests/integration/ssh/{deploy.py => test_deploy.py} (100%) rename tests/integration/states/{alternatives.py => test_alternatives.py} (100%) rename tests/integration/states/{archive.py => test_archive.py} (100%) rename tests/integration/states/{boto_sns.py => test_boto_sns.py} (100%) rename tests/integration/states/{bower.py => test_bower.py} (100%) rename tests/integration/states/{cmd.py => test_cmd.py} (100%) rename tests/integration/states/{compiler.py => test_compiler.py} (100%) rename tests/integration/states/{file.py => test_file.py} (100%) rename tests/integration/states/{git.py => test_git.py} (100%) rename tests/integration/states/{handle_error.py => test_handle_error.py} (100%) rename tests/integration/states/{handle_iorder.py => test_handle_iorder.py} (100%) rename tests/integration/states/{host.py => test_host.py} (100%) rename tests/integration/states/{keystone.py => test_keystone.py} (100%) rename tests/integration/states/{match.py => test_match.py} (100%) rename tests/integration/states/{mysql.py => test_mysql.py} (100%) rename tests/integration/states/{network.py => test_network.py} (100%) rename tests/integration/states/{npm.py => test_npm.py} (100%) rename tests/integration/states/{pip.py => test_pip.py} (100%) rename tests/integration/states/{pkg.py => test_pkg.py} (100%) rename tests/integration/states/{pkgrepo.py => test_pkgrepo.py} (100%) rename tests/integration/states/{rabbitmq_user.py => test_rabbitmq_user.py} (100%) rename tests/integration/states/{rabbitmq_vhost.py => test_rabbitmq_vhost.py} (100%) rename tests/integration/states/{renderers.py => test_renderers.py} (100%) rename tests/integration/states/{service.py => test_service.py} (100%) rename tests/integration/states/{ssh.py => test_ssh.py} (100%) rename tests/integration/states/{supervisord.py => test_supervisord.py} (100%) rename tests/integration/states/{svn.py => test_svn.py} (100%) rename tests/integration/states/{user.py => test_user.py} (100%) rename tests/integration/states/{virtualenv.py => test_virtualenv.py} (100%) rename tests/integration/wheel/{client.py => test_client.py} (100%) rename tests/integration/wheel/{key.py => test_key.py} (100%) rename tests/unit/acl/{client_test.py => test_client.py} (100%) rename tests/unit/beacons/{adb_beacon_test.py => test_adb_beacon.py} (100%) rename tests/unit/beacons/{glxinfo.py => test_glxinfo.py} (100%) rename tests/unit/beacons/{inotify_beacon_test.py => test_inotify_beacon.py} (100%) rename tests/unit/cache/{localfs_test.py => test_localfs.py} (100%) rename tests/unit/cli/{batch_test.py => test_batch.py} (100%) rename tests/unit/cloud/clouds/{dimensiondata_test.py => test_dimensiondata.py} (100%) rename tests/unit/cloud/clouds/{ec2_test.py => test_ec2.py} (100%) rename tests/unit/cloud/clouds/{gce_test.py => test_gce.py} (100%) rename tests/unit/cloud/clouds/{joyent_test.py => test_joyent.py} (100%) rename tests/unit/cloud/clouds/{linode_test.py => test_linode.py} (100%) rename tests/unit/cloud/clouds/{opennebula_test.py => test_opennebula.py} (100%) rename tests/unit/cloud/clouds/{saltify_test.py => test_saltify.py} (100%) rename tests/unit/cloud/clouds/{vmware_test.py => test_vmware.py} (100%) rename tests/unit/cloud/{libcloud_test.py => test_libcloud.py} (100%) rename tests/unit/config/schemas/{ssh_test.py => test_ssh.py} (100%) rename tests/unit/config/{api_test.py => test_api.py} (100%) rename tests/unit/config/{config_test.py => test_config.py} (100%) rename tests/unit/engines/{sqs_events_test.py => test_sqs_events.py} (100%) rename tests/unit/fileserver/{gitfs_test.py => test_gitfs.py} (100%) rename tests/unit/fileserver/{map_test.py => test_map.py} (100%) rename tests/unit/grains/{core_test.py => test_core.py} (100%) delete mode 100644 tests/unit/modules/network_test.py rename tests/unit/modules/{aliases_test.py => test_aliases.py} (100%) rename tests/unit/modules/{alternatives_test.py => test_alternatives.py} (100%) rename tests/unit/modules/{apache_test.py => test_apache.py} (100%) rename tests/unit/modules/{aptpkg_test.py => test_aptpkg.py} (100%) rename tests/unit/modules/{archive_test.py => test_archive.py} (100%) rename tests/unit/modules/{artifactory_test.py => test_artifactory.py} (100%) rename tests/unit/modules/{at_test.py => test_at.py} (100%) rename tests/unit/modules/{augeas_cfg_test.py => test_augeas_cfg.py} (100%) rename tests/unit/modules/{bluez_test.py => test_bluez.py} (100%) rename tests/unit/modules/{boto_apigateway_test.py => test_boto_apigateway.py} (100%) rename tests/unit/modules/{boto_cloudtrail_test.py => test_boto_cloudtrail.py} (100%) rename tests/unit/modules/{boto_cloudwatch_event_test.py => test_boto_cloudwatch_event.py} (100%) rename tests/unit/modules/{boto_cognitoidentity_test.py => test_boto_cognitoidentity.py} (100%) rename tests/unit/modules/{boto_elasticsearch_domain_test.py => test_boto_elasticsearch_domain.py} (100%) rename tests/unit/modules/{boto_elb_test.py => test_boto_elb.py} (100%) rename tests/unit/modules/{boto_iot_test.py => test_boto_iot.py} (100%) rename tests/unit/modules/{boto_lambda_test.py => test_boto_lambda.py} (100%) rename tests/unit/modules/{boto_s3_bucket_test.py => test_boto_s3_bucket.py} (100%) rename tests/unit/modules/{boto_secgroup_test.py => test_boto_secgroup.py} (100%) rename tests/unit/modules/{boto_vpc_test.py => test_boto_vpc.py} (100%) rename tests/unit/modules/{bower_test.py => test_bower.py} (100%) rename tests/unit/modules/{bridge_test.py => test_bridge.py} (100%) rename tests/unit/modules/{btrfs_test.py => test_btrfs.py} (100%) rename tests/unit/modules/{cassandra_test.py => test_cassandra.py} (100%) rename tests/unit/modules/{cassandra_cql_test.py => test_cassandra_cql.py} (100%) rename tests/unit/modules/{chef_test.py => test_chef.py} (100%) rename tests/unit/modules/{cmdmod_test.py => test_cmdmod.py} (100%) rename tests/unit/modules/{composer_test.py => test_composer.py} (100%) rename tests/unit/modules/{config_test.py => test_config.py} (100%) rename tests/unit/modules/{cp_test.py => test_cp.py} (100%) rename tests/unit/modules/{cpan_test.py => test_cpan.py} (100%) rename tests/unit/modules/{cron_test.py => test_cron.py} (100%) rename tests/unit/modules/{cyg_test.py => test_cyg.py} (100%) rename tests/unit/modules/{daemontools_test.py => test_daemontools.py} (100%) rename tests/unit/modules/{data_test.py => test_data.py} (100%) rename tests/unit/modules/{ddns_test.py => test_ddns.py} (100%) rename tests/unit/modules/{deb_apache_test.py => test_deb_apache.py} (100%) rename tests/unit/modules/{deb_postgres_test.py => test_deb_postgres.py} (100%) rename tests/unit/modules/{debconfmod_test.py => test_debconfmod.py} (100%) rename tests/unit/modules/{debian_ip_test.py => test_debian_ip.py} (100%) rename tests/unit/modules/{debian_service_test.py => test_debian_service.py} (100%) rename tests/unit/modules/{defaults_test.py => test_defaults.py} (100%) rename tests/unit/modules/{devmap_test.py => test_devmap.py} (100%) rename tests/unit/modules/{dig_test.py => test_dig.py} (100%) rename tests/unit/modules/{disk_test.py => test_disk.py} (100%) rename tests/unit/modules/{djangomod_test.py => test_djangomod.py} (100%) rename tests/unit/modules/{dnsmasq_test.py => test_dnsmasq.py} (100%) rename tests/unit/modules/{dnsutil_test.py => test_dnsutil.py} (100%) rename tests/unit/modules/{docker_test.py => test_docker.py} (100%) rename tests/unit/modules/{dpkg_test.py => test_dpkg.py} (100%) rename tests/unit/modules/{drac_test.py => test_drac.py} (100%) rename tests/unit/modules/{drbd_test.py => test_drbd.py} (100%) rename tests/unit/modules/{environ_test.py => test_environ.py} (100%) rename tests/unit/modules/{etcd_mod_test.py => test_etcd_mod.py} (100%) rename tests/unit/modules/{event_test.py => test_event.py} (100%) rename tests/unit/modules/{extfs_test.py => test_extfs.py} (100%) rename tests/unit/modules/{file_test.py => test_file.py} (100%) rename tests/unit/modules/{firewalld_test.py => test_firewalld.py} (100%) rename tests/unit/modules/{gem_test.py => test_gem.py} (100%) rename tests/unit/modules/{genesis_test.py => test_genesis.py} (100%) rename tests/unit/modules/{gentoo_service_test.py => test_gentoo_service.py} (100%) rename tests/unit/modules/{git_test.py => test_git.py} (100%) rename tests/unit/modules/{glusterfs_test.py => test_glusterfs.py} (100%) rename tests/unit/modules/{gnomedesktop_test.py => test_gnomedesktop.py} (100%) rename tests/unit/modules/{grains_test.py => test_grains.py} (100%) rename tests/unit/modules/{groupadd_test.py => test_groupadd.py} (100%) rename tests/unit/modules/{grub_legacy_test.py => test_grub_legacy.py} (100%) rename tests/unit/modules/{guestfs_test.py => test_guestfs.py} (100%) rename tests/unit/modules/{hadoop_test.py => test_hadoop.py} (100%) rename tests/unit/modules/{haproxyconn_test.py => test_haproxyconn.py} (100%) rename tests/unit/modules/{hashutil_test.py => test_hashutil.py} (100%) rename tests/unit/modules/{hg_test.py => test_hg.py} (100%) rename tests/unit/modules/{hipchat_test.py => test_hipchat.py} (100%) rename tests/unit/modules/{hosts_test.py => test_hosts.py} (100%) rename tests/unit/modules/{htpasswd_test.py => test_htpasswd.py} (100%) rename tests/unit/modules/{http_test.py => test_http.py} (100%) rename tests/unit/modules/{ilo_test.py => test_ilo.py} (100%) rename tests/unit/modules/{incron_test.py => test_incron.py} (100%) rename tests/unit/modules/{influx08_test.py => test_influx08.py} (100%) rename tests/unit/modules/{ini_manage_test.py => test_ini_manage.py} (100%) rename tests/unit/modules/{inspect_collector_test.py => test_inspect_collector.py} (100%) rename tests/unit/modules/{inspect_fsdb_test.py => test_inspect_fsdb.py} (100%) rename tests/unit/modules/{introspect_test.py => test_introspect.py} (100%) rename tests/unit/modules/{ipset_test.py => test_ipset.py} (100%) rename tests/unit/modules/{iptables_test.py => test_iptables.py} (100%) rename tests/unit/modules/{jboss7_test.py => test_jboss7.py} (100%) rename tests/unit/modules/{jboss7_cli_test.py => test_jboss7_cli.py} (100%) rename tests/unit/modules/{k8s_test.py => test_k8s.py} (100%) rename tests/unit/modules/{kapacitor_test.py => test_kapacitor.py} (100%) rename tests/unit/modules/{key_test.py => test_key.py} (100%) rename tests/unit/modules/{keyboard_test.py => test_keyboard.py} (100%) rename tests/unit/modules/{keystone_test.py => test_keystone.py} (100%) rename tests/unit/modules/{kmod_test.py => test_kmod.py} (100%) rename tests/unit/modules/{launchctl_test.py => test_launchctl.py} (100%) rename tests/unit/modules/{ldapmod_test.py => test_ldapmod.py} (100%) rename tests/unit/modules/{libcloud_dns_test.py => test_libcloud_dns.py} (100%) rename tests/unit/modules/{linux_acl_test.py => test_linux_acl.py} (100%) rename tests/unit/modules/{linux_lvm_test.py => test_linux_lvm.py} (100%) rename tests/unit/modules/{linux_sysctl_test.py => test_linux_sysctl.py} (100%) rename tests/unit/modules/{localemod_test.py => test_localemod.py} (100%) rename tests/unit/modules/{locate_test.py => test_locate.py} (100%) rename tests/unit/modules/{logadm_test.py => test_logadm.py} (100%) rename tests/unit/modules/{logrotate_test.py => test_logrotate.py} (100%) rename tests/unit/modules/{lvs_test.py => test_lvs.py} (100%) rename tests/unit/modules/{mac_assistive_test.py => test_mac_assistive.py} (100%) rename tests/unit/modules/{mac_brew_test.py => test_mac_brew.py} (100%) rename tests/unit/modules/{mac_defaults_test.py => test_mac_defaults.py} (100%) rename tests/unit/modules/{mac_desktop_test.py => test_mac_desktop.py} (100%) rename tests/unit/modules/{mac_group_test.py => test_mac_group.py} (100%) rename tests/unit/modules/{mac_keychain_test.py => test_mac_keychain.py} (100%) rename tests/unit/modules/{mac_package_test.py => test_mac_package.py} (100%) rename tests/unit/modules/{mac_pkgutil_test.py => test_mac_pkgutil.py} (100%) rename tests/unit/modules/{mac_power_test.py => test_mac_power.py} (100%) rename tests/unit/modules/{mac_sysctl_test.py => test_mac_sysctl.py} (100%) rename tests/unit/modules/{mac_user_test.py => test_mac_user.py} (100%) rename tests/unit/modules/{mac_xattr_test.py => test_mac_xattr.py} (100%) rename tests/unit/modules/{mdadm_test.py => test_mdadm.py} (100%) rename tests/unit/modules/{memcached_test.py => test_memcached.py} (100%) rename tests/unit/modules/{mine_test.py => test_mine.py} (100%) rename tests/unit/modules/{mod_random_test.py => test_mod_random.py} (100%) rename tests/unit/modules/{modjk_test.py => test_modjk.py} (100%) rename tests/unit/modules/{monit_test.py => test_monit.py} (100%) rename tests/unit/modules/{moosefs_test.py => test_moosefs.py} (100%) rename tests/unit/modules/{mount_test.py => test_mount.py} (100%) rename tests/unit/modules/{munin_test.py => test_munin.py} (100%) rename tests/unit/modules/{mysql_test.py => test_mysql.py} (100%) rename tests/unit/modules/{nagios_test.py => test_nagios.py} (100%) rename tests/unit/modules/{netscaler_test.py => test_netscaler.py} (100%) create mode 100644 tests/unit/modules/test_network_utils.py rename tests/unit/modules/{neutron_test.py => test_neutron.py} (100%) rename tests/unit/modules/{nfs3_test.py => test_nfs3.py} (100%) rename tests/unit/modules/{nftables_test.py => test_nftables.py} (100%) rename tests/unit/modules/{nginx_test.py => test_nginx.py} (100%) rename tests/unit/modules/{nova_test.py => test_nova.py} (100%) rename tests/unit/modules/{npm_test.py => test_npm.py} (100%) rename tests/unit/modules/{openbsdpkg_test.py => test_openbsdpkg.py} (100%) rename tests/unit/modules/{openscap_test.py => test_openscap.py} (100%) rename tests/unit/modules/{openstack_config_test.py => test_openstack_config.py} (100%) rename tests/unit/modules/{oracle_test.py => test_oracle.py} (100%) rename tests/unit/modules/{pacman_test.py => test_pacman.py} (100%) rename tests/unit/modules/{pagerduty_test.py => test_pagerduty.py} (100%) rename tests/unit/modules/{pam_test.py => test_pam.py} (100%) rename tests/unit/modules/{parallels_test.py => test_parallels.py} (100%) rename tests/unit/modules/{parted_test.py => test_parted.py} (100%) rename tests/unit/modules/{pecl_test.py => test_pecl.py} (100%) rename tests/unit/modules/{pillar_test.py => test_pillar.py} (100%) rename tests/unit/modules/{pip_test.py => test_pip.py} (100%) rename tests/unit/modules/{pkg_resource_test.py => test_pkg_resource.py} (100%) rename tests/unit/modules/{pkgutil_test.py => test_pkgutil.py} (100%) rename tests/unit/modules/{portage_config.py => test_portage_config.py} (100%) rename tests/unit/modules/{postfix_test.py => test_postfix.py} (100%) rename tests/unit/modules/{postgres_test.py => test_postgres.py} (100%) rename tests/unit/modules/{poudriere_test.py => test_poudriere.py} (100%) rename tests/unit/modules/{powerpath_test.py => test_powerpath.py} (100%) rename tests/unit/modules/{proxy_test.py => test_proxy.py} (100%) rename tests/unit/modules/{ps_test.py => test_ps.py} (100%) rename tests/unit/modules/{publish_test.py => test_publish.py} (100%) rename tests/unit/modules/{puppet_test.py => test_puppet.py} (100%) rename tests/unit/modules/{pw_group_test.py => test_pw_group.py} (100%) rename tests/unit/modules/{pw_user_test.py => test_pw_user.py} (100%) rename tests/unit/modules/{pyenv_test.py => test_pyenv.py} (100%) rename tests/unit/modules/{qemu_img_test.py => test_qemu_img.py} (100%) rename tests/unit/modules/{qemu_nbd_test.py => test_qemu_nbd.py} (100%) rename tests/unit/modules/{rabbitmq_test.py => test_rabbitmq.py} (100%) rename tests/unit/modules/{raet_publish_test.py => test_raet_publish.py} (100%) rename tests/unit/modules/{rbenv_test.py => test_rbenv.py} (100%) rename tests/unit/modules/{rdp_test.py => test_rdp.py} (100%) rename tests/unit/modules/{redismod_test.py => test_redismod.py} (100%) rename tests/unit/modules/{reg_win_test.py => test_reg_win.py} (100%) rename tests/unit/modules/{ret_test.py => test_ret.py} (100%) rename tests/unit/modules/{rh_ip_test.py => test_rh_ip.py} (100%) rename tests/unit/modules/{rh_service_test.py => test_rh_service.py} (100%) rename tests/unit/modules/{riak_test.py => test_riak.py} (100%) rename tests/unit/modules/{rpm_test.py => test_rpm.py} (100%) rename tests/unit/modules/{rsync_test.py => test_rsync.py} (100%) rename tests/unit/modules/{rvm_test.py => test_rvm.py} (100%) rename tests/unit/modules/{s3_test.py => test_s3.py} (100%) rename tests/unit/modules/{s6_test.py => test_s6.py} (100%) rename tests/unit/modules/{saltcloudmod_test.py => test_saltcloudmod.py} (100%) rename tests/unit/modules/{schedule_test.py => test_schedule.py} (100%) rename tests/unit/modules/{scsi_test.py => test_scsi.py} (100%) rename tests/unit/modules/{sdb_test.py => test_sdb.py} (100%) rename tests/unit/modules/{seed_test.py => test_seed.py} (100%) rename tests/unit/modules/{sensors_test.py => test_sensors.py} (100%) rename tests/unit/modules/{serverdensity_device_test.py => test_serverdensity_device.py} (100%) rename tests/unit/modules/{service_test.py => test_service.py} (100%) rename tests/unit/modules/{servicenow_test.py => test_servicenow.py} (100%) rename tests/unit/modules/{shadow_test.py => test_shadow.py} (100%) rename tests/unit/modules/{smf_test.py => test_smf.py} (100%) rename tests/unit/modules/{smtp_test.py => test_smtp.py} (100%) rename tests/unit/modules/{snapper_test.py => test_snapper.py} (100%) rename tests/unit/modules/{solr_test.py => test_solr.py} (100%) rename tests/unit/modules/{sqlite3_test.py => test_sqlite3.py} (100%) rename tests/unit/modules/{ssh_test.py => test_ssh.py} (100%) rename tests/unit/modules/{state_test.py => test_state.py} (100%) rename tests/unit/modules/{status_test.py => test_status.py} (100%) rename tests/unit/modules/{supervisord_test.py => test_supervisord.py} (100%) rename tests/unit/modules/{svn_test.py => test_svn.py} (100%) rename tests/unit/modules/{swift_test.py => test_swift.py} (100%) rename tests/unit/modules/{sysbench_test.py => test_sysbench.py} (100%) rename tests/unit/modules/{syslog_ng_test.py => test_syslog_ng.py} (100%) rename tests/unit/modules/{sysmod_test.py => test_sysmod.py} (100%) rename tests/unit/modules/{system_test.py => test_system.py} (100%) rename tests/unit/modules/{systemd_test.py => test_systemd.py} (100%) rename tests/unit/modules/{timezone_test.py => test_timezone.py} (100%) rename tests/unit/modules/{tls_test.py => test_tls.py} (100%) rename tests/unit/modules/{twilio_notify_test.py => test_twilio_notify.py} (100%) rename tests/unit/modules/{udev_test.py => test_udev.py} (100%) rename tests/unit/modules/{uptime_test.py => test_uptime.py} (100%) rename tests/unit/modules/{useradd_test.py => test_useradd.py} (100%) rename tests/unit/modules/{uwsgi_test.py => test_uwsgi.py} (100%) rename tests/unit/modules/{varnish_test.py => test_varnish.py} (100%) rename tests/unit/modules/{virt_test.py => test_virt.py} (100%) rename tests/unit/modules/{virtualenv_test.py => test_virtualenv.py} (100%) rename tests/unit/modules/{vsphere_test.py => test_vsphere.py} (100%) rename tests/unit/modules/{win_autoruns_test.py => test_win_autoruns.py} (100%) rename tests/unit/modules/{win_certutil_test.py => test_win_certutil.py} (100%) rename tests/unit/modules/{win_disk_test.py => test_win_disk.py} (100%) rename tests/unit/modules/{win_dism_test.py => test_win_dism.py} (100%) rename tests/unit/modules/{win_dns_client_test.py => test_win_dns_client.py} (100%) rename tests/unit/modules/{win_firewall_test.py => test_win_firewall.py} (100%) rename tests/unit/modules/{win_groupadd_test.py => test_win_groupadd.py} (100%) rename tests/unit/modules/{win_iis_test.py => test_win_iis.py} (100%) rename tests/unit/modules/{win_ip_test.py => test_win_ip.py} (100%) rename tests/unit/modules/{win_license_test.py => test_win_license.py} (100%) rename tests/unit/modules/{win_network_test.py => test_win_network.py} (100%) rename tests/unit/modules/{win_ntp_test.py => test_win_ntp.py} (100%) rename tests/unit/modules/{win_path_test.py => test_win_path.py} (100%) rename tests/unit/modules/{win_pki_test.py => test_win_pki.py} (100%) rename tests/unit/modules/{win_powercfg_test.py => test_win_powercfg.py} (100%) rename tests/unit/modules/{win_service_test.py => test_win_service.py} (100%) rename tests/unit/modules/{win_shadow_test.py => test_win_shadow.py} (100%) rename tests/unit/modules/{win_snmp_test.py => test_win_snmp.py} (100%) rename tests/unit/modules/{win_status_test.py => test_win_status.py} (100%) rename tests/unit/modules/{win_system_test.py => test_win_system.py} (100%) rename tests/unit/modules/{win_timezone_test.py => test_win_timezone.py} (100%) rename tests/unit/modules/{xapi_test.py => test_xapi.py} (100%) rename tests/unit/modules/{zcbuildout_test.py => test_zcbuildout.py} (100%) rename tests/unit/modules/{zfs_test.py => test_zfs.py} (100%) rename tests/unit/modules/{znc_test.py => test_znc.py} (100%) rename tests/unit/modules/{zpool_test.py => test_zpool.py} (100%) rename tests/unit/modules/{zypper_test.py => test_zypper.py} (100%) rename tests/unit/netapi/rest_cherrypy/{tools_test.py => test_tools.py} (100%) rename tests/unit/output/{json_out_test.py => test_json_out.py} (100%) rename tests/unit/output/{yaml_out_test.py => test_yaml_out.py} (100%) rename tests/unit/pillar/{consul_test.py => test_consul.py} (100%) rename tests/unit/pillar/{git_test.py => test_git.py} (100%) rename tests/unit/pillar/{hg_test.py => test_hg.py} (100%) rename tests/unit/pillar/{mysql_test.py => test_mysql.py} (100%) rename tests/unit/pillar/{nodegroups_test.py => test_nodegroups.py} (100%) rename tests/unit/pillar/{sqlcipher_test.py => test_sqlcipher.py} (100%) rename tests/unit/pillar/{sqlite3_test.py => test_sqlite3.py} (100%) rename tests/unit/renderers/{gpg_test.py => test_gpg.py} (100%) rename tests/unit/renderers/{yaml_test.py => test_yaml.py} (100%) rename tests/unit/renderers/{yamlex_test.py => test_yamlex.py} (100%) rename tests/unit/returners/{local_cache_test.py => test_local_cache.py} (100%) rename tests/unit/returners/{smtp_return_test.py => test_smtp_return.py} (100%) rename tests/unit/runners/{cache_test.py => test_cache.py} (100%) rename tests/unit/runners/{jobs_test.py => test_jobs.py} (100%) rename tests/unit/serializers/{serializers_test.py => test_serializers.py} (100%) rename tests/unit/ssh/{ssh_single_test.py => test_ssh_single.py} (100%) rename tests/unit/states/{alias_test.py => test_alias.py} (100%) rename tests/unit/states/{alternatives_test.py => test_alternatives.py} (100%) rename tests/unit/states/{apache_test.py => test_apache.py} (100%) rename tests/unit/states/{apache_conf_test.py => test_apache_conf.py} (100%) rename tests/unit/states/{apache_module_test.py => test_apache_module.py} (100%) rename tests/unit/states/{apache_site_test.py => test_apache_site.py} (100%) rename tests/unit/states/{apt_test.py => test_apt.py} (100%) rename tests/unit/states/{archive_test.py => test_archive.py} (100%) rename tests/unit/states/{artifactory_test.py => test_artifactory.py} (100%) rename tests/unit/states/{at_test.py => test_at.py} (100%) rename tests/unit/states/{augeas_test.py => test_augeas.py} (100%) rename tests/unit/states/{aws_sqs_test.py => test_aws_sqs.py} (100%) rename tests/unit/states/{blockdev_test.py => test_blockdev.py} (100%) rename tests/unit/states/{boto_apigateway_test.py => test_boto_apigateway.py} (100%) rename tests/unit/states/{boto_asg_test.py => test_boto_asg.py} (100%) rename tests/unit/states/{boto_cloudtrail_test.py => test_boto_cloudtrail.py} (100%) rename tests/unit/states/{boto_cloudwatch_alarm_test.py => test_boto_cloudwatch_alarm.py} (100%) rename tests/unit/states/{boto_cloudwatch_event_test.py => test_boto_cloudwatch_event.py} (100%) rename tests/unit/states/{boto_cognitoidentity_test.py => test_boto_cognitoidentity.py} (100%) rename tests/unit/states/{boto_dynamodb_test.py => test_boto_dynamodb.py} (100%) rename tests/unit/states/{boto_ec2_test.py => test_boto_ec2.py} (100%) rename tests/unit/states/{boto_elasticache_test.py => test_boto_elasticache.py} (100%) rename tests/unit/states/{boto_elasticsearch_domain_test.py => test_boto_elasticsearch_domain.py} (100%) rename tests/unit/states/{boto_elb_test.py => test_boto_elb.py} (100%) rename tests/unit/states/{boto_iam_role_test.py => test_boto_iam_role.py} (100%) rename tests/unit/states/{boto_iot_test.py => test_boto_iot.py} (100%) rename tests/unit/states/{boto_kinesis_test.py => test_boto_kinesis.py} (100%) rename tests/unit/states/{boto_lambda_test.py => test_boto_lambda.py} (100%) rename tests/unit/states/{boto_lc_test.py => test_boto_lc.py} (100%) rename tests/unit/states/{boto_route53_test.py => test_boto_route53.py} (100%) rename tests/unit/states/{boto_s3_bucket_test.py => test_boto_s3_bucket.py} (100%) rename tests/unit/states/{boto_secgroup_test.py => test_boto_secgroup.py} (100%) rename tests/unit/states/{boto_sns_test.py => test_boto_sns.py} (100%) rename tests/unit/states/{boto_sqs_test.py => test_boto_sqs.py} (100%) rename tests/unit/states/{boto_vpc_test.py => test_boto_vpc.py} (100%) rename tests/unit/states/{bower_test.py => test_bower.py} (100%) rename tests/unit/states/{chef_test.py => test_chef.py} (100%) rename tests/unit/states/{cloud_test.py => test_cloud.py} (100%) rename tests/unit/states/{cmd_test.py => test_cmd.py} (100%) rename tests/unit/states/{composer_test.py => test_composer.py} (100%) rename tests/unit/states/{cron_test.py => test_cron.py} (100%) rename tests/unit/states/{cyg_test.py => test_cyg.py} (100%) rename tests/unit/states/{ddns_test.py => test_ddns.py} (100%) rename tests/unit/states/{debconfmod_test.py => test_debconfmod.py} (100%) rename tests/unit/states/{disk_test.py => test_disk.py} (100%) rename tests/unit/states/{docker_test.py => test_docker.py} (100%) rename tests/unit/states/{drac_test.py => test_drac.py} (100%) rename tests/unit/states/{environ_test.py => test_environ.py} (100%) rename tests/unit/states/{eselect_test.py => test_eselect.py} (100%) rename tests/unit/states/{event_test.py => test_event.py} (100%) rename tests/unit/states/{file_test.py => test_file.py} (100%) rename tests/unit/states/{gem_test.py => test_gem.py} (100%) rename tests/unit/states/{glusterfs_test.py => test_glusterfs.py} (100%) rename tests/unit/states/{gnomedesktop_test.py => test_gnomedesktop.py} (100%) rename tests/unit/states/{grafana_test.py => test_grafana.py} (100%) rename tests/unit/states/{grafana_datasource_test.py => test_grafana_datasource.py} (100%) rename tests/unit/states/{grains_test.py => test_grains.py} (100%) rename tests/unit/states/{group_test.py => test_group.py} (100%) rename tests/unit/states/{hg_test.py => test_hg.py} (100%) rename tests/unit/states/{hipchat_test.py => test_hipchat.py} (100%) rename tests/unit/states/{host_test.py => test_host.py} (100%) rename tests/unit/states/{htpasswd_test.py => test_htpasswd.py} (100%) rename tests/unit/states/{http_test.py => test_http.py} (100%) rename tests/unit/states/{incron_test.py => test_incron.py} (100%) rename tests/unit/states/{influxdb08_database_test.py => test_influxdb08_database.py} (100%) rename tests/unit/states/{influxdb08_user_test.py => test_influxdb08_user.py} (100%) rename tests/unit/states/{ini_manage_test.py => test_ini_manage.py} (100%) rename tests/unit/states/{ipmi_test.py => test_ipmi.py} (100%) rename tests/unit/states/{ipset_test.py => test_ipset.py} (100%) rename tests/unit/states/{iptables_test.py => test_iptables.py} (100%) rename tests/unit/states/{jboss7_test.py => test_jboss7.py} (100%) rename tests/unit/states/{kapacitor_test.py => test_kapacitor.py} (100%) rename tests/unit/states/{keyboard_test.py => test_keyboard.py} (100%) rename tests/unit/states/{keystone_test.py => test_keystone.py} (100%) rename tests/unit/states/{kmod_test.py => test_kmod.py} (100%) rename tests/unit/states/{layman_test.py => test_layman.py} (100%) rename tests/unit/states/{ldap_test.py => test_ldap.py} (100%) rename tests/unit/states/{libcloud_dns_test.py => test_libcloud_dns.py} (100%) rename tests/unit/states/{libvirt_test.py => test_libvirt.py} (100%) rename tests/unit/states/{linux_acl_test.py => test_linux_acl.py} (100%) rename tests/unit/states/{locale_test.py => test_locale.py} (100%) rename tests/unit/states/{lvm_test.py => test_lvm.py} (100%) rename tests/unit/states/{lvs_server_test.py => test_lvs_server.py} (100%) rename tests/unit/states/{lvs_service_test.py => test_lvs_service.py} (100%) rename tests/unit/states/{lxc_test.py => test_lxc.py} (100%) rename tests/unit/states/{mac_assistive_test.py => test_mac_assistive.py} (100%) rename tests/unit/states/{mac_defaults_test.py => test_mac_defaults.py} (100%) rename tests/unit/states/{mac_keychain_test.py => test_mac_keychain.py} (100%) rename tests/unit/states/{mac_package_test.py => test_mac_package.py} (100%) rename tests/unit/states/{mac_xattr_test.py => test_mac_xattr.py} (100%) rename tests/unit/states/{makeconf_test.py => test_makeconf.py} (100%) rename tests/unit/states/{mdadm_test.py => test_mdadm.py} (100%) rename tests/unit/states/{memcached_test.py => test_memcached.py} (100%) rename tests/unit/states/{modjk_test.py => test_modjk.py} (100%) rename tests/unit/states/{modjk_worker_test.py => test_modjk_worker.py} (100%) rename tests/unit/states/{module_test.py => test_module.py} (100%) rename tests/unit/states/{mongodb_database_test.py => test_mongodb_database.py} (100%) rename tests/unit/states/{mongodb_user_test.py => test_mongodb_user.py} (100%) rename tests/unit/states/{mount_test.py => test_mount.py} (100%) rename tests/unit/states/{mysql_grants_test.py => test_mysql_grants.py} (100%) rename tests/unit/states/{mysql_query_test.py => test_mysql_query.py} (100%) rename tests/unit/states/{mysql_user_test.py => test_mysql_user.py} (100%) rename tests/unit/states/{network_test.py => test_network.py} (100%) rename tests/unit/states/{nftables_test.py => test_nftables.py} (100%) rename tests/unit/states/{npm_test.py => test_npm.py} (100%) rename tests/unit/states/{ntp_test.py => test_ntp.py} (100%) rename tests/unit/states/{openstack_config_test.py => test_openstack_config.py} (100%) rename tests/unit/states/{openvswitch_port_test.py => test_openvswitch_port.py} (100%) rename tests/unit/states/{pagerduty_test.py => test_pagerduty.py} (100%) rename tests/unit/states/{pecl_test.py => test_pecl.py} (100%) rename tests/unit/states/{pip_test.py => test_pip.py} (100%) rename tests/unit/states/{pkgng_test.py => test_pkgng.py} (100%) rename tests/unit/states/{portage_config_test.py => test_portage_config.py} (100%) rename tests/unit/states/{ports_test.py => test_ports.py} (100%) rename tests/unit/states/{postgres_test.py => test_postgres.py} (100%) rename tests/unit/states/{postgres_cluster_test.py => test_postgres_cluster.py} (100%) rename tests/unit/states/{postgres_database_test.py => test_postgres_database.py} (100%) rename tests/unit/states/{postgres_extension_test.py => test_postgres_extension.py} (100%) rename tests/unit/states/{postgres_group_test.py => test_postgres_group.py} (100%) rename tests/unit/states/{postgres_initdb_test.py => test_postgres_initdb.py} (100%) rename tests/unit/states/{postgres_language_test.py => test_postgres_language.py} (100%) rename tests/unit/states/{postgres_privileges_test.py => test_postgres_privileges.py} (100%) rename tests/unit/states/{postgres_schema_test.py => test_postgres_schema.py} (100%) rename tests/unit/states/{postgres_user_test.py => test_postgres_user.py} (100%) rename tests/unit/states/{powerpath_test.py => test_powerpath.py} (100%) rename tests/unit/states/{process_test.py => test_process.py} (100%) rename tests/unit/states/{proxy_test.py => test_proxy.py} (100%) rename tests/unit/states/{pyenv_test.py => test_pyenv.py} (100%) rename tests/unit/states/{pyrax_queues_test.py => test_pyrax_queues.py} (100%) rename tests/unit/states/{quota_test.py => test_quota.py} (100%) rename tests/unit/states/{rabbitmq_cluster_test.py => test_rabbitmq_cluster.py} (100%) rename tests/unit/states/{rabbitmq_plugin_test.py => test_rabbitmq_plugin.py} (100%) rename tests/unit/states/{rabbitmq_policy_test.py => test_rabbitmq_policy.py} (100%) rename tests/unit/states/{rabbitmq_vhost_test.py => test_rabbitmq_vhost.py} (100%) rename tests/unit/states/{rbenv_test.py => test_rbenv.py} (100%) rename tests/unit/states/{rdp_test.py => test_rdp.py} (100%) rename tests/unit/states/{redismod_test.py => test_redismod.py} (100%) rename tests/unit/states/{reg_test.py => test_reg.py} (100%) rename tests/unit/states/{rvm_test.py => test_rvm.py} (100%) rename tests/unit/states/{saltmod_test.py => test_saltmod.py} (100%) rename tests/unit/states/{schedule_test.py => test_schedule.py} (100%) rename tests/unit/states/{selinux_test.py => test_selinux.py} (100%) rename tests/unit/states/{serverdensity_device_test.py => test_serverdensity_device.py} (100%) rename tests/unit/states/{service_test.py => test_service.py} (100%) rename tests/unit/states/{slack_test.py => test_slack.py} (100%) rename tests/unit/states/{smtp_test.py => test_smtp.py} (100%) rename tests/unit/states/{splunk_search_test.py => test_splunk_search.py} (100%) rename tests/unit/states/{ssh_auth_test.py => test_ssh_auth.py} (100%) rename tests/unit/states/{ssh_known_hosts_test.py => test_ssh_known_hosts.py} (100%) rename tests/unit/states/{status_test.py => test_status.py} (100%) rename tests/unit/states/{supervisord_test.py => test_supervisord.py} (100%) rename tests/unit/states/{svn_test.py => test_svn.py} (100%) rename tests/unit/states/{sysctl_test.py => test_sysctl.py} (100%) rename tests/unit/states/{syslog_ng_test.py => test_syslog_ng.py} (100%) rename tests/unit/states/{sysrc_test.py => test_sysrc.py} (100%) rename tests/unit/states/{timezone_test.py => test_timezone.py} (100%) rename tests/unit/states/{tomcat_test.py => test_tomcat.py} (100%) rename tests/unit/states/{user_test.py => test_user.py} (100%) rename tests/unit/states/{vbox_guest_test.py => test_vbox_guest.py} (100%) rename tests/unit/states/{virtualenv_mod_test.py => test_virtualenv_mod.py} (100%) rename tests/unit/states/{win_certutil_test.py => test_win_certutil.py} (100%) rename tests/unit/states/{win_dism_test.py => test_win_dism.py} (100%) rename tests/unit/states/{win_dns_client_test.py => test_win_dns_client.py} (100%) rename tests/unit/states/{win_firewall_test.py => test_win_firewall.py} (100%) rename tests/unit/states/{win_license_test.py => test_win_license.py} (100%) rename tests/unit/states/{win_network_test.py => test_win_network.py} (100%) rename tests/unit/states/{win_path_test.py => test_win_path.py} (100%) rename tests/unit/states/{win_pki_test.py => test_win_pki.py} (100%) rename tests/unit/states/{win_powercfg_test.py => test_win_powercfg.py} (100%) rename tests/unit/states/{win_servermanager_test.py => test_win_servermanager.py} (100%) rename tests/unit/states/{win_snmp_test.py => test_win_snmp.py} (100%) rename tests/unit/states/{win_system_test.py => test_win_system.py} (100%) rename tests/unit/states/{win_update_test.py => test_win_update.py} (100%) rename tests/unit/states/{winrepo_test.py => test_winrepo.py} (100%) rename tests/unit/states/{xmpp_test.py => test_xmpp.py} (100%) rename tests/unit/states/{zcbuildout_test.py => test_zcbuildout.py} (100%) rename tests/unit/states/{zk_concurrency_test.py => test_zk_concurrency.py} (100%) rename tests/unit/templates/{jinja_test.py => test_jinja.py} (100%) rename tests/unit/{auth_test.py => test_auth.py} (100%) rename tests/unit/{client_test.py => test_client.py} (100%) rename tests/unit/{conf_test.py => test_conf.py} (100%) rename tests/unit/{context_test.py => test_context.py} (100%) rename tests/unit/{crypt_test.py => test_crypt.py} (100%) rename tests/unit/{daemons_test.py => test_daemons.py} (100%) rename tests/unit/{doc_test.py => test_doc.py} (100%) rename tests/unit/{files_test.py => test_files.py} (100%) rename tests/unit/{log_test.py => test_log.py} (100%) rename tests/unit/{map_conf_test.py => test_map_conf.py} (100%) rename tests/unit/{minion_test.py => test_minion.py} (100%) rename tests/unit/{payload_test.py => test_payload.py} (100%) rename tests/unit/{pillar_test.py => test_pillar.py} (100%) rename tests/unit/{pydsl_test.py => test_pydsl.py} (100%) rename tests/unit/{pyobjects_test.py => test_pyobjects.py} (100%) rename tests/unit/{simple_test.py => test_simple.py} (100%) rename tests/unit/{spm_test.py => test_spm.py} (100%) rename tests/unit/{state_test.py => test_state.py} (100%) rename tests/unit/{stateconf_test.py => test_stateconf.py} (100%) rename tests/unit/{statemod_test.py => test_statemod.py} (100%) rename tests/unit/{target_test.py => test_target.py} (100%) rename tests/unit/{template_test.py => test_template.py} (100%) rename tests/unit/{version_test.py => test_version.py} (100%) rename tests/unit/transport/{ipc_test.py => test_ipc.py} (100%) rename tests/unit/transport/{pub_test.py => test_pub.py} (100%) rename tests/unit/transport/{req_test.py => test_req.py} (100%) rename tests/unit/transport/{tcp_test.py => test_tcp.py} (100%) rename tests/unit/transport/{zeromq_test.py => test_zeromq.py} (100%) rename tests/unit/utils/{aggregation_test.py => test_aggregation.py} (100%) rename tests/unit/utils/{args_test.py => test_args.py} (100%) rename tests/unit/utils/{async_test.py => test_async.py} (100%) rename tests/unit/utils/{boto_test.py => test_boto.py} (100%) rename tests/unit/utils/{cache_test.py => test_cache.py} (100%) rename tests/unit/utils/{cloud_test.py => test_cloud.py} (100%) rename tests/unit/utils/{configcomparer_test.py => test_configcomparer.py} (100%) rename tests/unit/utils/{context_test.py => test_context.py} (100%) rename tests/unit/utils/{decorators_test.py => test_decorators.py} (100%) rename tests/unit/utils/{dictupdate_test.py => test_dictupdate.py} (100%) rename tests/unit/utils/{disk_cache_test.py => test_disk_cache.py} (100%) rename tests/unit/utils/{etcd_util_test.py => test_etcd_util.py} (100%) rename tests/unit/utils/{event_test.py => test_event.py} (100%) rename tests/unit/utils/{extend_test.py => test_extend.py} (100%) rename tests/unit/utils/{filebuffer_test.py => test_filebuffer.py} (100%) rename tests/unit/utils/{find_test.py => test_find.py} (100%) rename tests/unit/utils/{format_call_test.py => test_format_call.py} (100%) rename tests/unit/utils/{gitfs_test.py => test_gitfs.py} (100%) rename tests/unit/utils/{http_test.py => test_http.py} (100%) rename tests/unit/utils/{immutabletypes_test.py => test_immutabletypes.py} (100%) rename tests/unit/utils/{kwarg_regex_test.py => test_kwarg_regex.py} (100%) rename tests/unit/utils/{locales_test.py => test_locales.py} (100%) rename tests/unit/utils/{mac_utils_test.py => test_mac_utils.py} (100%) rename tests/unit/utils/{minions_test.py => test_minions.py} (100%) rename tests/unit/utils/{network_test.py => test_network.py} (100%) rename tests/unit/utils/{parsers_test.py => test_parsers.py} (100%) rename tests/unit/utils/{path_join_test.py => test_path_join.py} (100%) rename tests/unit/utils/{process_test.py => test_process.py} (100%) rename tests/unit/utils/{rsax931_test.py => test_rsax931.py} (100%) rename tests/unit/utils/{runtime_whitespace_regex_test.py => test_runtime_whitespace_regex.py} (100%) rename tests/unit/utils/{safe_walk_test.py => test_safe_walk.py} (100%) rename tests/unit/utils/{sanitizers_test.py => test_sanitizers.py} (100%) rename tests/unit/utils/{schedule_test.py => test_schedule.py} (100%) rename tests/unit/utils/{schema_test.py => test_schema.py} (100%) rename tests/unit/utils/{systemd_test.py => test_systemd.py} (100%) rename tests/unit/utils/{url_test.py => test_url.py} (100%) rename tests/unit/utils/{utils_test.py => test_utils.py} (100%) rename tests/unit/utils/{validate_net_test.py => test_validate_net.py} (100%) rename tests/unit/utils/{verify_test.py => test_verify.py} (100%) rename tests/unit/utils/{vt_test.py => test_vt.py} (100%) rename tests/unit/utils/{warnings_test.py => test_warnings.py} (100%) rename tests/unit/utils/{which_test.py => test_which.py} (100%) rename tests/unit/utils/{yamlloader_test.py => test_yamlloader.py} (100%) rename tests/unit/utils/vmware_test/{cluster_test.py => test_cluster.py} (100%) rename tests/unit/utils/vmware_test/{common_test.py => test_common.py} (100%) rename tests/unit/utils/vmware_test/{connection_test.py => test_connection.py} (100%) rename tests/unit/utils/vmware_test/{datacenter_test.py => test_datacenter.py} (100%) rename tests/unit/utils/vmware_test/{host_test.py => test_host.py} (100%) diff --git a/tests/integration/cli/batch.py b/tests/integration/cli/test_batch.py similarity index 100% rename from tests/integration/cli/batch.py rename to tests/integration/cli/test_batch.py diff --git a/tests/integration/cli/custom_module.py b/tests/integration/cli/test_custom_module.py similarity index 100% rename from tests/integration/cli/custom_module.py rename to tests/integration/cli/test_custom_module.py diff --git a/tests/integration/cli/grains.py b/tests/integration/cli/test_grains.py similarity index 100% rename from tests/integration/cli/grains.py rename to tests/integration/cli/test_grains.py diff --git a/tests/integration/client/kwarg.py b/tests/integration/client/test_kwarg.py similarity index 100% rename from tests/integration/client/kwarg.py rename to tests/integration/client/test_kwarg.py diff --git a/tests/integration/client/runner.py b/tests/integration/client/test_runner.py similarity index 100% rename from tests/integration/client/runner.py rename to tests/integration/client/test_runner.py diff --git a/tests/integration/client/standard.py b/tests/integration/client/test_standard.py similarity index 100% rename from tests/integration/client/standard.py rename to tests/integration/client/test_standard.py diff --git a/tests/integration/client/syndic.py b/tests/integration/client/test_syndic.py similarity index 100% rename from tests/integration/client/syndic.py rename to tests/integration/client/test_syndic.py diff --git a/tests/integration/cloud/providers/digital_ocean.py b/tests/integration/cloud/providers/test_digital_ocean.py similarity index 100% rename from tests/integration/cloud/providers/digital_ocean.py rename to tests/integration/cloud/providers/test_digital_ocean.py diff --git a/tests/integration/cloud/providers/ec2.py b/tests/integration/cloud/providers/test_ec2.py similarity index 100% rename from tests/integration/cloud/providers/ec2.py rename to tests/integration/cloud/providers/test_ec2.py diff --git a/tests/integration/cloud/providers/gce.py b/tests/integration/cloud/providers/test_gce.py similarity index 100% rename from tests/integration/cloud/providers/gce.py rename to tests/integration/cloud/providers/test_gce.py diff --git a/tests/integration/cloud/providers/gogrid.py b/tests/integration/cloud/providers/test_gogrid.py similarity index 100% rename from tests/integration/cloud/providers/gogrid.py rename to tests/integration/cloud/providers/test_gogrid.py diff --git a/tests/integration/cloud/providers/joyent.py b/tests/integration/cloud/providers/test_joyent.py similarity index 100% rename from tests/integration/cloud/providers/joyent.py rename to tests/integration/cloud/providers/test_joyent.py diff --git a/tests/integration/cloud/providers/linode.py b/tests/integration/cloud/providers/test_linode.py similarity index 100% rename from tests/integration/cloud/providers/linode.py rename to tests/integration/cloud/providers/test_linode.py diff --git a/tests/integration/cloud/providers/msazure.py b/tests/integration/cloud/providers/test_msazure.py similarity index 100% rename from tests/integration/cloud/providers/msazure.py rename to tests/integration/cloud/providers/test_msazure.py diff --git a/tests/integration/cloud/providers/openstack.py b/tests/integration/cloud/providers/test_openstack.py similarity index 100% rename from tests/integration/cloud/providers/openstack.py rename to tests/integration/cloud/providers/test_openstack.py diff --git a/tests/integration/cloud/providers/profitbricks.py b/tests/integration/cloud/providers/test_profitbricks.py similarity index 100% rename from tests/integration/cloud/providers/profitbricks.py rename to tests/integration/cloud/providers/test_profitbricks.py diff --git a/tests/integration/cloud/providers/rackspace.py b/tests/integration/cloud/providers/test_rackspace.py similarity index 100% rename from tests/integration/cloud/providers/rackspace.py rename to tests/integration/cloud/providers/test_rackspace.py diff --git a/tests/integration/cloud/providers/virtualbox.py b/tests/integration/cloud/providers/test_virtualbox.py similarity index 100% rename from tests/integration/cloud/providers/virtualbox.py rename to tests/integration/cloud/providers/test_virtualbox.py diff --git a/tests/integration/cloud/providers/vultr.py b/tests/integration/cloud/providers/test_vultr.py similarity index 100% rename from tests/integration/cloud/providers/vultr.py rename to tests/integration/cloud/providers/test_vultr.py diff --git a/tests/integration/fileserver/fileclient_test.py b/tests/integration/fileserver/test_fileclient.py similarity index 100% rename from tests/integration/fileserver/fileclient_test.py rename to tests/integration/fileserver/test_fileclient.py diff --git a/tests/integration/fileserver/gitfs_test.py b/tests/integration/fileserver/test_gitfs.py similarity index 100% rename from tests/integration/fileserver/gitfs_test.py rename to tests/integration/fileserver/test_gitfs.py diff --git a/tests/integration/fileserver/roots_test.py b/tests/integration/fileserver/test_roots.py similarity index 100% rename from tests/integration/fileserver/roots_test.py rename to tests/integration/fileserver/test_roots.py diff --git a/tests/integration/grains/core.py b/tests/integration/grains/test_core.py similarity index 100% rename from tests/integration/grains/core.py rename to tests/integration/grains/test_core.py diff --git a/tests/integration/loader/ext_grains.py b/tests/integration/loader/test_ext_grains.py similarity index 100% rename from tests/integration/loader/ext_grains.py rename to tests/integration/loader/test_ext_grains.py diff --git a/tests/integration/loader/ext_modules.py b/tests/integration/loader/test_ext_modules.py similarity index 100% rename from tests/integration/loader/ext_modules.py rename to tests/integration/loader/test_ext_modules.py diff --git a/tests/integration/loader/globals.py b/tests/integration/loader/test_globals.py similarity index 100% rename from tests/integration/loader/globals.py rename to tests/integration/loader/test_globals.py diff --git a/tests/integration/loader/interfaces.py b/tests/integration/loader/test_interfaces.py similarity index 100% rename from tests/integration/loader/interfaces.py rename to tests/integration/loader/test_interfaces.py diff --git a/tests/integration/loader/loader.py b/tests/integration/loader/test_loader.py similarity index 100% rename from tests/integration/loader/loader.py rename to tests/integration/loader/test_loader.py diff --git a/tests/integration/minion/blackout.py b/tests/integration/minion/test_blackout.py similarity index 100% rename from tests/integration/minion/blackout.py rename to tests/integration/minion/test_blackout.py diff --git a/tests/integration/minion/pillar.py b/tests/integration/minion/test_pillar.py similarity index 100% rename from tests/integration/minion/pillar.py rename to tests/integration/minion/test_pillar.py diff --git a/tests/integration/minion/timeout.py b/tests/integration/minion/test_timeout.py similarity index 100% rename from tests/integration/minion/timeout.py rename to tests/integration/minion/test_timeout.py diff --git a/tests/integration/modules/aliases.py b/tests/integration/modules/test_aliases.py similarity index 100% rename from tests/integration/modules/aliases.py rename to tests/integration/modules/test_aliases.py diff --git a/tests/integration/modules/archive.py b/tests/integration/modules/test_archive.py similarity index 100% rename from tests/integration/modules/archive.py rename to tests/integration/modules/test_archive.py diff --git a/tests/integration/modules/beacons.py b/tests/integration/modules/test_beacons.py similarity index 100% rename from tests/integration/modules/beacons.py rename to tests/integration/modules/test_beacons.py diff --git a/tests/integration/modules/boto_iam.py b/tests/integration/modules/test_boto_iam.py similarity index 100% rename from tests/integration/modules/boto_iam.py rename to tests/integration/modules/test_boto_iam.py diff --git a/tests/integration/modules/boto_sns.py b/tests/integration/modules/test_boto_sns.py similarity index 100% rename from tests/integration/modules/boto_sns.py rename to tests/integration/modules/test_boto_sns.py diff --git a/tests/integration/modules/cmdmod.py b/tests/integration/modules/test_cmdmod.py similarity index 100% rename from tests/integration/modules/cmdmod.py rename to tests/integration/modules/test_cmdmod.py diff --git a/tests/integration/modules/config.py b/tests/integration/modules/test_config.py similarity index 100% rename from tests/integration/modules/config.py rename to tests/integration/modules/test_config.py diff --git a/tests/integration/modules/cp.py b/tests/integration/modules/test_cp.py similarity index 100% rename from tests/integration/modules/cp.py rename to tests/integration/modules/test_cp.py diff --git a/tests/integration/modules/darwin_sysctl.py b/tests/integration/modules/test_darwin_sysctl.py similarity index 100% rename from tests/integration/modules/darwin_sysctl.py rename to tests/integration/modules/test_darwin_sysctl.py diff --git a/tests/integration/modules/data.py b/tests/integration/modules/test_data.py similarity index 100% rename from tests/integration/modules/data.py rename to tests/integration/modules/test_data.py diff --git a/tests/integration/modules/decorators.py b/tests/integration/modules/test_decorators.py similarity index 100% rename from tests/integration/modules/decorators.py rename to tests/integration/modules/test_decorators.py diff --git a/tests/integration/modules/disk.py b/tests/integration/modules/test_disk.py similarity index 100% rename from tests/integration/modules/disk.py rename to tests/integration/modules/test_disk.py diff --git a/tests/integration/modules/django.py b/tests/integration/modules/test_django.py similarity index 100% rename from tests/integration/modules/django.py rename to tests/integration/modules/test_django.py diff --git a/tests/integration/modules/event.py b/tests/integration/modules/test_event.py similarity index 100% rename from tests/integration/modules/event.py rename to tests/integration/modules/test_event.py diff --git a/tests/integration/modules/file.py b/tests/integration/modules/test_file.py similarity index 100% rename from tests/integration/modules/file.py rename to tests/integration/modules/test_file.py diff --git a/tests/integration/modules/gem.py b/tests/integration/modules/test_gem.py similarity index 100% rename from tests/integration/modules/gem.py rename to tests/integration/modules/test_gem.py diff --git a/tests/integration/modules/gentoolkitmod.py b/tests/integration/modules/test_gentoolkitmod.py similarity index 100% rename from tests/integration/modules/gentoolkitmod.py rename to tests/integration/modules/test_gentoolkitmod.py diff --git a/tests/integration/modules/git.py b/tests/integration/modules/test_git.py similarity index 100% rename from tests/integration/modules/git.py rename to tests/integration/modules/test_git.py diff --git a/tests/integration/modules/grains.py b/tests/integration/modules/test_grains.py similarity index 100% rename from tests/integration/modules/grains.py rename to tests/integration/modules/test_grains.py diff --git a/tests/integration/modules/groupadd.py b/tests/integration/modules/test_groupadd.py similarity index 100% rename from tests/integration/modules/groupadd.py rename to tests/integration/modules/test_groupadd.py diff --git a/tests/integration/modules/hosts.py b/tests/integration/modules/test_hosts.py similarity index 100% rename from tests/integration/modules/hosts.py rename to tests/integration/modules/test_hosts.py diff --git a/tests/integration/modules/key.py b/tests/integration/modules/test_key.py similarity index 100% rename from tests/integration/modules/key.py rename to tests/integration/modules/test_key.py diff --git a/tests/integration/modules/linux_acl.py b/tests/integration/modules/test_linux_acl.py similarity index 100% rename from tests/integration/modules/linux_acl.py rename to tests/integration/modules/test_linux_acl.py diff --git a/tests/integration/modules/locale.py b/tests/integration/modules/test_locale.py similarity index 100% rename from tests/integration/modules/locale.py rename to tests/integration/modules/test_locale.py diff --git a/tests/integration/modules/lxc.py b/tests/integration/modules/test_lxc.py similarity index 100% rename from tests/integration/modules/lxc.py rename to tests/integration/modules/test_lxc.py diff --git a/tests/integration/modules/mac_assistive.py b/tests/integration/modules/test_mac_assistive.py similarity index 100% rename from tests/integration/modules/mac_assistive.py rename to tests/integration/modules/test_mac_assistive.py diff --git a/tests/integration/modules/mac_brew.py b/tests/integration/modules/test_mac_brew.py similarity index 100% rename from tests/integration/modules/mac_brew.py rename to tests/integration/modules/test_mac_brew.py diff --git a/tests/integration/modules/mac_defaults.py b/tests/integration/modules/test_mac_defaults.py similarity index 100% rename from tests/integration/modules/mac_defaults.py rename to tests/integration/modules/test_mac_defaults.py diff --git a/tests/integration/modules/mac_desktop.py b/tests/integration/modules/test_mac_desktop.py similarity index 100% rename from tests/integration/modules/mac_desktop.py rename to tests/integration/modules/test_mac_desktop.py diff --git a/tests/integration/modules/mac_group.py b/tests/integration/modules/test_mac_group.py similarity index 100% rename from tests/integration/modules/mac_group.py rename to tests/integration/modules/test_mac_group.py diff --git a/tests/integration/modules/mac_keychain.py b/tests/integration/modules/test_mac_keychain.py similarity index 100% rename from tests/integration/modules/mac_keychain.py rename to tests/integration/modules/test_mac_keychain.py diff --git a/tests/integration/modules/mac_pkgutil.py b/tests/integration/modules/test_mac_pkgutil.py similarity index 100% rename from tests/integration/modules/mac_pkgutil.py rename to tests/integration/modules/test_mac_pkgutil.py diff --git a/tests/integration/modules/mac_ports.py b/tests/integration/modules/test_mac_ports.py similarity index 100% rename from tests/integration/modules/mac_ports.py rename to tests/integration/modules/test_mac_ports.py diff --git a/tests/integration/modules/mac_power.py b/tests/integration/modules/test_mac_power.py similarity index 100% rename from tests/integration/modules/mac_power.py rename to tests/integration/modules/test_mac_power.py diff --git a/tests/integration/modules/mac_service.py b/tests/integration/modules/test_mac_service.py similarity index 100% rename from tests/integration/modules/mac_service.py rename to tests/integration/modules/test_mac_service.py diff --git a/tests/integration/modules/mac_shadow.py b/tests/integration/modules/test_mac_shadow.py similarity index 100% rename from tests/integration/modules/mac_shadow.py rename to tests/integration/modules/test_mac_shadow.py diff --git a/tests/integration/modules/mac_softwareupdate.py b/tests/integration/modules/test_mac_softwareupdate.py similarity index 100% rename from tests/integration/modules/mac_softwareupdate.py rename to tests/integration/modules/test_mac_softwareupdate.py diff --git a/tests/integration/modules/mac_system.py b/tests/integration/modules/test_mac_system.py similarity index 100% rename from tests/integration/modules/mac_system.py rename to tests/integration/modules/test_mac_system.py diff --git a/tests/integration/modules/mac_timezone.py b/tests/integration/modules/test_mac_timezone.py similarity index 100% rename from tests/integration/modules/mac_timezone.py rename to tests/integration/modules/test_mac_timezone.py diff --git a/tests/integration/modules/mac_user.py b/tests/integration/modules/test_mac_user.py similarity index 100% rename from tests/integration/modules/mac_user.py rename to tests/integration/modules/test_mac_user.py diff --git a/tests/integration/modules/mac_xattr.py b/tests/integration/modules/test_mac_xattr.py similarity index 100% rename from tests/integration/modules/mac_xattr.py rename to tests/integration/modules/test_mac_xattr.py diff --git a/tests/integration/modules/mine.py b/tests/integration/modules/test_mine.py similarity index 100% rename from tests/integration/modules/mine.py rename to tests/integration/modules/test_mine.py diff --git a/tests/integration/modules/mysql.py b/tests/integration/modules/test_mysql.py similarity index 100% rename from tests/integration/modules/mysql.py rename to tests/integration/modules/test_mysql.py diff --git a/tests/integration/modules/nilrt_ip.py b/tests/integration/modules/test_nilrt_ip.py similarity index 100% rename from tests/integration/modules/nilrt_ip.py rename to tests/integration/modules/test_nilrt_ip.py diff --git a/tests/integration/modules/pillar.py b/tests/integration/modules/test_pillar.py similarity index 100% rename from tests/integration/modules/pillar.py rename to tests/integration/modules/test_pillar.py diff --git a/tests/integration/modules/pip.py b/tests/integration/modules/test_pip.py similarity index 100% rename from tests/integration/modules/pip.py rename to tests/integration/modules/test_pip.py diff --git a/tests/integration/modules/pkg.py b/tests/integration/modules/test_pkg.py similarity index 100% rename from tests/integration/modules/pkg.py rename to tests/integration/modules/test_pkg.py diff --git a/tests/integration/modules/publish.py b/tests/integration/modules/test_publish.py similarity index 100% rename from tests/integration/modules/publish.py rename to tests/integration/modules/test_publish.py diff --git a/tests/integration/modules/pw_user.py b/tests/integration/modules/test_pw_user.py similarity index 100% rename from tests/integration/modules/pw_user.py rename to tests/integration/modules/test_pw_user.py diff --git a/tests/integration/modules/rabbitmq.py b/tests/integration/modules/test_rabbitmq.py similarity index 100% rename from tests/integration/modules/rabbitmq.py rename to tests/integration/modules/test_rabbitmq.py diff --git a/tests/integration/modules/random_org_test.py b/tests/integration/modules/test_random_org.py similarity index 100% rename from tests/integration/modules/random_org_test.py rename to tests/integration/modules/test_random_org.py diff --git a/tests/integration/modules/saltutil.py b/tests/integration/modules/test_saltutil.py similarity index 100% rename from tests/integration/modules/saltutil.py rename to tests/integration/modules/test_saltutil.py diff --git a/tests/integration/modules/shadow.py b/tests/integration/modules/test_shadow.py similarity index 100% rename from tests/integration/modules/shadow.py rename to tests/integration/modules/test_shadow.py diff --git a/tests/integration/modules/ssh.py b/tests/integration/modules/test_ssh.py similarity index 100% rename from tests/integration/modules/ssh.py rename to tests/integration/modules/test_ssh.py diff --git a/tests/integration/modules/state.py b/tests/integration/modules/test_state.py similarity index 100% rename from tests/integration/modules/state.py rename to tests/integration/modules/test_state.py diff --git a/tests/integration/modules/supervisord.py b/tests/integration/modules/test_supervisord.py similarity index 100% rename from tests/integration/modules/supervisord.py rename to tests/integration/modules/test_supervisord.py diff --git a/tests/integration/modules/sysctl.py b/tests/integration/modules/test_sysctl.py similarity index 100% rename from tests/integration/modules/sysctl.py rename to tests/integration/modules/test_sysctl.py diff --git a/tests/integration/modules/sysmod.py b/tests/integration/modules/test_sysmod.py similarity index 100% rename from tests/integration/modules/sysmod.py rename to tests/integration/modules/test_sysmod.py diff --git a/tests/integration/modules/system.py b/tests/integration/modules/test_system.py similarity index 100% rename from tests/integration/modules/system.py rename to tests/integration/modules/test_system.py diff --git a/tests/integration/modules/test.py b/tests/integration/modules/test_test.py similarity index 100% rename from tests/integration/modules/test.py rename to tests/integration/modules/test_test.py diff --git a/tests/integration/modules/timezone.py b/tests/integration/modules/test_timezone.py similarity index 100% rename from tests/integration/modules/timezone.py rename to tests/integration/modules/test_timezone.py diff --git a/tests/integration/modules/useradd.py b/tests/integration/modules/test_useradd.py similarity index 100% rename from tests/integration/modules/useradd.py rename to tests/integration/modules/test_useradd.py diff --git a/tests/integration/modules/virt.py b/tests/integration/modules/test_virt.py similarity index 100% rename from tests/integration/modules/virt.py rename to tests/integration/modules/test_virt.py diff --git a/tests/integration/modules/virtualenv.py b/tests/integration/modules/test_virtualenv.py similarity index 100% rename from tests/integration/modules/virtualenv.py rename to tests/integration/modules/test_virtualenv.py diff --git a/tests/integration/netapi/rest_cherrypy/app_test.py b/tests/integration/netapi/rest_cherrypy/test_app.py similarity index 100% rename from tests/integration/netapi/rest_cherrypy/app_test.py rename to tests/integration/netapi/rest_cherrypy/test_app.py diff --git a/tests/integration/netapi/rest_cherrypy/app_pam_test.py b/tests/integration/netapi/rest_cherrypy/test_app_pam.py similarity index 100% rename from tests/integration/netapi/rest_cherrypy/app_pam_test.py rename to tests/integration/netapi/rest_cherrypy/test_app_pam.py diff --git a/tests/integration/output/output.py b/tests/integration/output/test_output.py similarity index 100% rename from tests/integration/output/output.py rename to tests/integration/output/test_output.py diff --git a/tests/integration/reactor/reactor.py b/tests/integration/reactor/test_reactor.py similarity index 100% rename from tests/integration/reactor/reactor.py rename to tests/integration/reactor/test_reactor.py diff --git a/tests/integration/renderers/pydsl_test.py b/tests/integration/renderers/test_pydsl.py similarity index 100% rename from tests/integration/renderers/pydsl_test.py rename to tests/integration/renderers/test_pydsl.py diff --git a/tests/integration/returners/librato_return.py b/tests/integration/returners/test_librato_return.py similarity index 100% rename from tests/integration/returners/librato_return.py rename to tests/integration/returners/test_librato_return.py diff --git a/tests/integration/returners/local_cache.py b/tests/integration/returners/test_local_cache.py similarity index 100% rename from tests/integration/returners/local_cache.py rename to tests/integration/returners/test_local_cache.py diff --git a/tests/integration/runners/fileserver.py b/tests/integration/runners/test_fileserver.py similarity index 100% rename from tests/integration/runners/fileserver.py rename to tests/integration/runners/test_fileserver.py diff --git a/tests/integration/runners/jobs.py b/tests/integration/runners/test_jobs.py similarity index 100% rename from tests/integration/runners/jobs.py rename to tests/integration/runners/test_jobs.py diff --git a/tests/integration/runners/manage.py b/tests/integration/runners/test_manage.py similarity index 100% rename from tests/integration/runners/manage.py rename to tests/integration/runners/test_manage.py diff --git a/tests/integration/runners/runner_returns.py b/tests/integration/runners/test_runner_returns.py similarity index 100% rename from tests/integration/runners/runner_returns.py rename to tests/integration/runners/test_runner_returns.py diff --git a/tests/integration/runners/salt.py b/tests/integration/runners/test_salt.py similarity index 100% rename from tests/integration/runners/salt.py rename to tests/integration/runners/test_salt.py diff --git a/tests/integration/runners/state.py b/tests/integration/runners/test_state.py similarity index 100% rename from tests/integration/runners/state.py rename to tests/integration/runners/test_state.py diff --git a/tests/integration/runners/winrepo.py b/tests/integration/runners/test_winrepo.py similarity index 100% rename from tests/integration/runners/winrepo.py rename to tests/integration/runners/test_winrepo.py diff --git a/tests/integration/sdb/env.py b/tests/integration/sdb/test_env.py similarity index 100% rename from tests/integration/sdb/env.py rename to tests/integration/sdb/test_env.py diff --git a/tests/integration/shell/arguments.py b/tests/integration/shell/test_arguments.py similarity index 100% rename from tests/integration/shell/arguments.py rename to tests/integration/shell/test_arguments.py diff --git a/tests/integration/shell/auth.py b/tests/integration/shell/test_auth.py similarity index 100% rename from tests/integration/shell/auth.py rename to tests/integration/shell/test_auth.py diff --git a/tests/integration/shell/call.py b/tests/integration/shell/test_call.py similarity index 100% rename from tests/integration/shell/call.py rename to tests/integration/shell/test_call.py diff --git a/tests/integration/shell/cloud.py b/tests/integration/shell/test_cloud.py similarity index 100% rename from tests/integration/shell/cloud.py rename to tests/integration/shell/test_cloud.py diff --git a/tests/integration/shell/cp.py b/tests/integration/shell/test_cp.py similarity index 100% rename from tests/integration/shell/cp.py rename to tests/integration/shell/test_cp.py diff --git a/tests/integration/shell/enabled.py b/tests/integration/shell/test_enabled.py similarity index 100% rename from tests/integration/shell/enabled.py rename to tests/integration/shell/test_enabled.py diff --git a/tests/integration/shell/key.py b/tests/integration/shell/test_key.py similarity index 100% rename from tests/integration/shell/key.py rename to tests/integration/shell/test_key.py diff --git a/tests/integration/shell/master.py b/tests/integration/shell/test_master.py similarity index 100% rename from tests/integration/shell/master.py rename to tests/integration/shell/test_master.py diff --git a/tests/integration/shell/master_tops.py b/tests/integration/shell/test_master_tops.py similarity index 100% rename from tests/integration/shell/master_tops.py rename to tests/integration/shell/test_master_tops.py diff --git a/tests/integration/shell/matcher.py b/tests/integration/shell/test_matcher.py similarity index 100% rename from tests/integration/shell/matcher.py rename to tests/integration/shell/test_matcher.py diff --git a/tests/integration/shell/minion.py b/tests/integration/shell/test_minion.py similarity index 100% rename from tests/integration/shell/minion.py rename to tests/integration/shell/test_minion.py diff --git a/tests/integration/shell/proxy.py b/tests/integration/shell/test_proxy.py similarity index 100% rename from tests/integration/shell/proxy.py rename to tests/integration/shell/test_proxy.py diff --git a/tests/integration/shell/runner.py b/tests/integration/shell/test_runner.py similarity index 100% rename from tests/integration/shell/runner.py rename to tests/integration/shell/test_runner.py diff --git a/tests/integration/shell/saltcli.py b/tests/integration/shell/test_saltcli.py similarity index 100% rename from tests/integration/shell/saltcli.py rename to tests/integration/shell/test_saltcli.py diff --git a/tests/integration/shell/syndic.py b/tests/integration/shell/test_syndic.py similarity index 100% rename from tests/integration/shell/syndic.py rename to tests/integration/shell/test_syndic.py diff --git a/tests/integration/ssh/deploy.py b/tests/integration/ssh/test_deploy.py similarity index 100% rename from tests/integration/ssh/deploy.py rename to tests/integration/ssh/test_deploy.py diff --git a/tests/integration/states/alternatives.py b/tests/integration/states/test_alternatives.py similarity index 100% rename from tests/integration/states/alternatives.py rename to tests/integration/states/test_alternatives.py diff --git a/tests/integration/states/archive.py b/tests/integration/states/test_archive.py similarity index 100% rename from tests/integration/states/archive.py rename to tests/integration/states/test_archive.py diff --git a/tests/integration/states/boto_sns.py b/tests/integration/states/test_boto_sns.py similarity index 100% rename from tests/integration/states/boto_sns.py rename to tests/integration/states/test_boto_sns.py diff --git a/tests/integration/states/bower.py b/tests/integration/states/test_bower.py similarity index 100% rename from tests/integration/states/bower.py rename to tests/integration/states/test_bower.py diff --git a/tests/integration/states/cmd.py b/tests/integration/states/test_cmd.py similarity index 100% rename from tests/integration/states/cmd.py rename to tests/integration/states/test_cmd.py diff --git a/tests/integration/states/compiler.py b/tests/integration/states/test_compiler.py similarity index 100% rename from tests/integration/states/compiler.py rename to tests/integration/states/test_compiler.py diff --git a/tests/integration/states/file.py b/tests/integration/states/test_file.py similarity index 100% rename from tests/integration/states/file.py rename to tests/integration/states/test_file.py diff --git a/tests/integration/states/git.py b/tests/integration/states/test_git.py similarity index 100% rename from tests/integration/states/git.py rename to tests/integration/states/test_git.py diff --git a/tests/integration/states/handle_error.py b/tests/integration/states/test_handle_error.py similarity index 100% rename from tests/integration/states/handle_error.py rename to tests/integration/states/test_handle_error.py diff --git a/tests/integration/states/handle_iorder.py b/tests/integration/states/test_handle_iorder.py similarity index 100% rename from tests/integration/states/handle_iorder.py rename to tests/integration/states/test_handle_iorder.py diff --git a/tests/integration/states/host.py b/tests/integration/states/test_host.py similarity index 100% rename from tests/integration/states/host.py rename to tests/integration/states/test_host.py diff --git a/tests/integration/states/keystone.py b/tests/integration/states/test_keystone.py similarity index 100% rename from tests/integration/states/keystone.py rename to tests/integration/states/test_keystone.py diff --git a/tests/integration/states/match.py b/tests/integration/states/test_match.py similarity index 100% rename from tests/integration/states/match.py rename to tests/integration/states/test_match.py diff --git a/tests/integration/states/mysql.py b/tests/integration/states/test_mysql.py similarity index 100% rename from tests/integration/states/mysql.py rename to tests/integration/states/test_mysql.py diff --git a/tests/integration/states/network.py b/tests/integration/states/test_network.py similarity index 100% rename from tests/integration/states/network.py rename to tests/integration/states/test_network.py diff --git a/tests/integration/states/npm.py b/tests/integration/states/test_npm.py similarity index 100% rename from tests/integration/states/npm.py rename to tests/integration/states/test_npm.py diff --git a/tests/integration/states/pip.py b/tests/integration/states/test_pip.py similarity index 100% rename from tests/integration/states/pip.py rename to tests/integration/states/test_pip.py diff --git a/tests/integration/states/pkg.py b/tests/integration/states/test_pkg.py similarity index 100% rename from tests/integration/states/pkg.py rename to tests/integration/states/test_pkg.py diff --git a/tests/integration/states/pkgrepo.py b/tests/integration/states/test_pkgrepo.py similarity index 100% rename from tests/integration/states/pkgrepo.py rename to tests/integration/states/test_pkgrepo.py diff --git a/tests/integration/states/rabbitmq_user.py b/tests/integration/states/test_rabbitmq_user.py similarity index 100% rename from tests/integration/states/rabbitmq_user.py rename to tests/integration/states/test_rabbitmq_user.py diff --git a/tests/integration/states/rabbitmq_vhost.py b/tests/integration/states/test_rabbitmq_vhost.py similarity index 100% rename from tests/integration/states/rabbitmq_vhost.py rename to tests/integration/states/test_rabbitmq_vhost.py diff --git a/tests/integration/states/renderers.py b/tests/integration/states/test_renderers.py similarity index 100% rename from tests/integration/states/renderers.py rename to tests/integration/states/test_renderers.py diff --git a/tests/integration/states/service.py b/tests/integration/states/test_service.py similarity index 100% rename from tests/integration/states/service.py rename to tests/integration/states/test_service.py diff --git a/tests/integration/states/ssh.py b/tests/integration/states/test_ssh.py similarity index 100% rename from tests/integration/states/ssh.py rename to tests/integration/states/test_ssh.py diff --git a/tests/integration/states/supervisord.py b/tests/integration/states/test_supervisord.py similarity index 100% rename from tests/integration/states/supervisord.py rename to tests/integration/states/test_supervisord.py diff --git a/tests/integration/states/svn.py b/tests/integration/states/test_svn.py similarity index 100% rename from tests/integration/states/svn.py rename to tests/integration/states/test_svn.py diff --git a/tests/integration/states/user.py b/tests/integration/states/test_user.py similarity index 100% rename from tests/integration/states/user.py rename to tests/integration/states/test_user.py diff --git a/tests/integration/states/virtualenv.py b/tests/integration/states/test_virtualenv.py similarity index 100% rename from tests/integration/states/virtualenv.py rename to tests/integration/states/test_virtualenv.py diff --git a/tests/integration/wheel/client.py b/tests/integration/wheel/test_client.py similarity index 100% rename from tests/integration/wheel/client.py rename to tests/integration/wheel/test_client.py diff --git a/tests/integration/wheel/key.py b/tests/integration/wheel/test_key.py similarity index 100% rename from tests/integration/wheel/key.py rename to tests/integration/wheel/test_key.py diff --git a/tests/unit/acl/client_test.py b/tests/unit/acl/test_client.py similarity index 100% rename from tests/unit/acl/client_test.py rename to tests/unit/acl/test_client.py diff --git a/tests/unit/beacons/adb_beacon_test.py b/tests/unit/beacons/test_adb_beacon.py similarity index 100% rename from tests/unit/beacons/adb_beacon_test.py rename to tests/unit/beacons/test_adb_beacon.py diff --git a/tests/unit/beacons/glxinfo.py b/tests/unit/beacons/test_glxinfo.py similarity index 100% rename from tests/unit/beacons/glxinfo.py rename to tests/unit/beacons/test_glxinfo.py diff --git a/tests/unit/beacons/inotify_beacon_test.py b/tests/unit/beacons/test_inotify_beacon.py similarity index 100% rename from tests/unit/beacons/inotify_beacon_test.py rename to tests/unit/beacons/test_inotify_beacon.py diff --git a/tests/unit/cache/localfs_test.py b/tests/unit/cache/test_localfs.py similarity index 100% rename from tests/unit/cache/localfs_test.py rename to tests/unit/cache/test_localfs.py diff --git a/tests/unit/cli/batch_test.py b/tests/unit/cli/test_batch.py similarity index 100% rename from tests/unit/cli/batch_test.py rename to tests/unit/cli/test_batch.py diff --git a/tests/unit/cloud/clouds/dimensiondata_test.py b/tests/unit/cloud/clouds/test_dimensiondata.py similarity index 100% rename from tests/unit/cloud/clouds/dimensiondata_test.py rename to tests/unit/cloud/clouds/test_dimensiondata.py diff --git a/tests/unit/cloud/clouds/ec2_test.py b/tests/unit/cloud/clouds/test_ec2.py similarity index 100% rename from tests/unit/cloud/clouds/ec2_test.py rename to tests/unit/cloud/clouds/test_ec2.py diff --git a/tests/unit/cloud/clouds/gce_test.py b/tests/unit/cloud/clouds/test_gce.py similarity index 100% rename from tests/unit/cloud/clouds/gce_test.py rename to tests/unit/cloud/clouds/test_gce.py diff --git a/tests/unit/cloud/clouds/joyent_test.py b/tests/unit/cloud/clouds/test_joyent.py similarity index 100% rename from tests/unit/cloud/clouds/joyent_test.py rename to tests/unit/cloud/clouds/test_joyent.py diff --git a/tests/unit/cloud/clouds/linode_test.py b/tests/unit/cloud/clouds/test_linode.py similarity index 100% rename from tests/unit/cloud/clouds/linode_test.py rename to tests/unit/cloud/clouds/test_linode.py diff --git a/tests/unit/cloud/clouds/opennebula_test.py b/tests/unit/cloud/clouds/test_opennebula.py similarity index 100% rename from tests/unit/cloud/clouds/opennebula_test.py rename to tests/unit/cloud/clouds/test_opennebula.py diff --git a/tests/unit/cloud/clouds/saltify_test.py b/tests/unit/cloud/clouds/test_saltify.py similarity index 100% rename from tests/unit/cloud/clouds/saltify_test.py rename to tests/unit/cloud/clouds/test_saltify.py diff --git a/tests/unit/cloud/clouds/vmware_test.py b/tests/unit/cloud/clouds/test_vmware.py similarity index 100% rename from tests/unit/cloud/clouds/vmware_test.py rename to tests/unit/cloud/clouds/test_vmware.py diff --git a/tests/unit/cloud/libcloud_test.py b/tests/unit/cloud/test_libcloud.py similarity index 100% rename from tests/unit/cloud/libcloud_test.py rename to tests/unit/cloud/test_libcloud.py diff --git a/tests/unit/config/schemas/ssh_test.py b/tests/unit/config/schemas/test_ssh.py similarity index 100% rename from tests/unit/config/schemas/ssh_test.py rename to tests/unit/config/schemas/test_ssh.py diff --git a/tests/unit/config/api_test.py b/tests/unit/config/test_api.py similarity index 100% rename from tests/unit/config/api_test.py rename to tests/unit/config/test_api.py diff --git a/tests/unit/config/config_test.py b/tests/unit/config/test_config.py similarity index 100% rename from tests/unit/config/config_test.py rename to tests/unit/config/test_config.py diff --git a/tests/unit/engines/sqs_events_test.py b/tests/unit/engines/test_sqs_events.py similarity index 100% rename from tests/unit/engines/sqs_events_test.py rename to tests/unit/engines/test_sqs_events.py diff --git a/tests/unit/fileserver/gitfs_test.py b/tests/unit/fileserver/test_gitfs.py similarity index 100% rename from tests/unit/fileserver/gitfs_test.py rename to tests/unit/fileserver/test_gitfs.py diff --git a/tests/unit/fileserver/map_test.py b/tests/unit/fileserver/test_map.py similarity index 100% rename from tests/unit/fileserver/map_test.py rename to tests/unit/fileserver/test_map.py diff --git a/tests/unit/grains/core_test.py b/tests/unit/grains/test_core.py similarity index 100% rename from tests/unit/grains/core_test.py rename to tests/unit/grains/test_core.py diff --git a/tests/unit/modules/network_test.py b/tests/unit/modules/network_test.py deleted file mode 100644 index 276bbed5db..0000000000 --- a/tests/unit/modules/network_test.py +++ /dev/null @@ -1,365 +0,0 @@ -# -*- coding: utf-8 -*- -''' - :codeauthor: :email:`Jayesh Kariya ` -''' - -# Import Python Libs -from __future__ import absolute_import -import socket -import os.path - -# Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( - mock_open, - MagicMock, - patch, - NO_MOCK, - NO_MOCK_REASON -) - -from salttesting.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - -# Import Salt Libs -import salt.ext.six as six -import salt.utils -from salt.modules import network -from salt.exceptions import CommandExecutionError -if six.PY2: - import salt.ext.ipaddress - -# Globals -network.__grains__ = {} -network.__salt__ = {} - - -@skipIf(NO_MOCK, NO_MOCK_REASON) -class NetworkTestCase(TestCase): - ''' - Test cases for salt.modules.network - ''' - def test_wol_bad_mac(self): - ''' - tests network.wol with bad mac - ''' - bad_mac = '31337' - self.assertRaises(ValueError, network.wol, bad_mac) - - def test_wol_success(self): - ''' - tests network.wol success - ''' - mac = '080027136977' - bcast = '255.255.255.255 7' - - class MockSocket(object): - def __init__(self, *args, **kwargs): - pass - - def __call__(self, *args, **kwargs): - pass - - def setsockopt(self, *args, **kwargs): - pass - - def sendto(self, *args, **kwargs): - pass - - with patch('socket.socket', MockSocket): - self.assertTrue(network.wol(mac, bcast)) - - def test_ping(self): - ''' - Test for Performs a ping to a host - ''' - with patch.object(salt.utils.network, 'sanitize_host', - return_value='A'): - mock_all = MagicMock(side_effect=[{'retcode': 1}, {'retcode': 0}]) - with patch.dict(network.__salt__, {'cmd.run_all': mock_all}): - self.assertFalse(network.ping('host', return_boolean=True)) - - self.assertTrue(network.ping('host', return_boolean=True)) - - with patch.dict(network.__salt__, {'cmd.run': - MagicMock(return_value='A')}): - self.assertEqual(network.ping('host'), 'A') - - def test_netstat(self): - ''' - Test for return information on open ports and states - ''' - with patch.dict(network.__grains__, {'kernel': 'Linux'}): - with patch.object(network, '_netstat_linux', return_value='A'): - self.assertEqual(network.netstat(), 'A') - - with patch.dict(network.__grains__, {'kernel': 'OpenBSD'}): - with patch.object(network, '_netstat_bsd', return_value='A'): - self.assertEqual(network.netstat(), 'A') - - with patch.dict(network.__grains__, {'kernel': 'A'}): - self.assertRaises(CommandExecutionError, network.netstat) - - def test_active_tcp(self): - ''' - Test for return a dict containing information on all - of the running TCP connections - ''' - with patch.object(salt.utils.network, 'active_tcp', return_value='A'): - with patch.dict(network.__grains__, {'kernel': 'Linux'}): - self.assertEqual(network.active_tcp(), 'A') - - def test_traceroute(self): - ''' - Test for Performs a traceroute to a 3rd party host - ''' - with patch.object(salt.utils, 'which', side_effect=[False, True]): - self.assertListEqual(network.traceroute('host'), []) - - with patch.object(salt.utils.network, 'sanitize_host', - return_value='A'): - with patch.dict(network.__salt__, {'cmd.run': - MagicMock(return_value="")}): - self.assertListEqual(network.traceroute('host'), []) - - def test_dig(self): - ''' - Test for Performs a DNS lookup with dig - ''' - with patch.object(salt.utils.network, 'sanitize_host', - return_value='A'): - with patch.dict(network.__salt__, {'cmd.run': - MagicMock(return_value='A')}): - self.assertEqual(network.dig('host'), 'A') - - @patch('salt.utils.which', MagicMock(return_value='')) - def test_arp(self): - ''' - Test for return the arp table from the minion - ''' - with patch.dict(network.__salt__, - {'cmd.run': - MagicMock(return_value='A,B,C,D\nE,F,G,H\n')}): - self.assertDictEqual(network.arp(), {}) - - def test_interfaces(self): - ''' - Test for return a dictionary of information about - all the interfaces on the minion - ''' - with patch.object(salt.utils.network, 'interfaces', return_value={}): - self.assertDictEqual(network.interfaces(), {}) - - def test_hw_addr(self): - ''' - Test for return the hardware address (a.k.a. MAC address) - for a given interface - ''' - with patch.object(salt.utils.network, 'hw_addr', return_value={}): - self.assertDictEqual(network.hw_addr('iface'), {}) - - def test_interface(self): - ''' - Test for return the inet address for a given interface - ''' - with patch.object(salt.utils.network, 'interface', return_value={}): - self.assertDictEqual(network.interface('iface'), {}) - - def test_interface_ip(self): - ''' - Test for return the inet address for a given interface - ''' - with patch.object(salt.utils.network, 'interface_ip', return_value={}): - self.assertDictEqual(network.interface_ip('iface'), {}) - - def test_subnets(self): - ''' - Test for returns a list of subnets to which the host belongs - ''' - with patch.object(salt.utils.network, 'subnets', return_value={}): - self.assertDictEqual(network.subnets(), {}) - - def test_in_subnet(self): - ''' - Test for returns True if host is within specified - subnet, otherwise False. - ''' - with patch.object(salt.utils.network, 'in_subnet', return_value={}): - self.assertDictEqual(network.in_subnet('iface'), {}) - - def test_ip_addrs(self): - ''' - Test for returns a list of IPv4 addresses assigned to the host. - ''' - with patch.object(salt.utils.network, 'ip_addrs', - return_value=['0.0.0.0']): - with patch.object(salt.utils.network, 'in_subnet', - return_value=True): - self.assertListEqual(network.ip_addrs('interface', - 'include_loopback', - 'cidr'), ['0.0.0.0']) - - self.assertListEqual(network.ip_addrs('interface', - 'include_loopback'), - ['0.0.0.0']) - - def test_ip_addrs6(self): - ''' - Test for returns a list of IPv6 addresses assigned to the host. - ''' - with patch.object(salt.utils.network, 'ip_addrs6', - return_value=['A']): - self.assertListEqual(network.ip_addrs6('int', 'include'), ['A']) - - def test_get_hostname(self): - ''' - Test for Get hostname - ''' - with patch.object(network.socket, 'gethostname', return_value='A'): - self.assertEqual(network.get_hostname(), 'A') - - def test_mod_hostname(self): - ''' - Test for Modify hostname - ''' - self.assertFalse(network.mod_hostname(None)) - - with patch.object(salt.utils, 'which', return_value='hostname'): - with patch.dict(network.__salt__, - {'cmd.run': MagicMock(return_value=None)}): - file_d = '\n'.join(['#', 'A B C D,E,F G H']) - with patch('salt.utils.fopen', mock_open(read_data=file_d), - create=True) as mfi: - mfi.return_value.__iter__.return_value = file_d.splitlines() - with patch.dict(network.__grains__, {'os_family': 'A'}): - self.assertTrue(network.mod_hostname('hostname')) - - @patch('socket.socket') - def test_connect(self, mock_socket): - ''' - Test for Test connectivity to a host using a particular - port from the minion. - ''' - self.assertDictEqual(network.connect(False, 'port'), - {'comment': 'Required argument, host, is missing.', - 'result': False}) - - self.assertDictEqual(network.connect('host', False), - {'comment': 'Required argument, port, is missing.', - 'result': False}) - - ret = 'Unable to connect to host (0) on tcp port port' - mock_socket.side_effect = Exception('foo') - with patch.object(salt.utils.network, 'sanitize_host', - return_value='A'): - with patch.object(socket, 'getaddrinfo', - return_value=[['ipv4', 'A', 6, 'B', '0.0.0.0']]): - self.assertDictEqual(network.connect('host', 'port'), - {'comment': ret, 'result': False}) - - ret = 'Successfully connected to host (0) on tcp port port' - mock_socket.side_effect = MagicMock() - mock_socket.settimeout().return_value = None - mock_socket.connect().return_value = None - mock_socket.shutdown().return_value = None - with patch.object(salt.utils.network, 'sanitize_host', - return_value='A'): - with patch.object(socket, - 'getaddrinfo', - return_value=[['ipv4', - 'A', 6, 'B', '0.0.0.0']]): - self.assertDictEqual(network.connect('host', 'port'), - {'comment': ret, 'result': True}) - - @skipIf(not six.PY2, 'test applies only to python 2') - def test_is_private(self): - ''' - Test for Check if the given IP address is a private address - ''' - with patch.object(salt.ext.ipaddress.IPv4Address, 'is_private', - return_value=True): - self.assertTrue(network.is_private('0.0.0.0')) - with patch.object(salt.ext.ipaddress.IPv6Address, 'is_private', - return_value=True): - self.assertTrue(network.is_private('::1')) - - @skipIf(not six.PY2, 'test applies only to python 2') - def test_is_loopback(self): - ''' - Test for Check if the given IP address is a loopback address - ''' - with patch.object(salt.ext.ipaddress.IPv4Address, 'is_loopback', - return_value=True): - self.assertTrue(network.is_loopback('127.0.0.1')) - with patch.object(salt.ext.ipaddress.IPv6Address, 'is_loopback', - return_value=True): - self.assertTrue(network.is_loopback('::1')) - - def test_get_bufsize(self): - ''' - Test for return network buffer sizes as a dict - ''' - with patch.dict(network.__grains__, {'kernel': 'Linux'}): - with patch.object(os.path, 'exists', return_value=True): - with patch.object(network, '_get_bufsize_linux', - return_value={'size': 1}): - self.assertDictEqual(network.get_bufsize('iface'), - {'size': 1}) - - with patch.dict(network.__grains__, {'kernel': 'A'}): - self.assertDictEqual(network.get_bufsize('iface'), {}) - - def test_mod_bufsize(self): - ''' - Test for Modify network interface buffers (currently linux only) - ''' - with patch.dict(network.__grains__, {'kernel': 'Linux'}): - with patch.object(os.path, 'exists', return_value=True): - with patch.object(network, '_mod_bufsize_linux', - return_value={'size': 1}): - self.assertDictEqual(network.mod_bufsize('iface'), - {'size': 1}) - - with patch.dict(network.__grains__, {'kernel': 'A'}): - self.assertFalse(network.mod_bufsize('iface')) - - def test_routes(self): - ''' - Test for return currently configured routes from routing table - ''' - self.assertRaises(CommandExecutionError, network.routes, 'family') - - with patch.dict(network.__grains__, {'kernel': 'A', 'os': 'B'}): - self.assertRaises(CommandExecutionError, network.routes, 'inet') - - with patch.dict(network.__grains__, {'kernel': 'Linux'}): - with patch.object(network, '_netstat_route_linux', - side_effect=['A', [{'addr_family': 'inet'}]]): - self.assertEqual(network.routes(None), 'A') - - self.assertListEqual(network.routes('inet'), - [{'addr_family': 'inet'}]) - - def test_default_route(self): - ''' - Test for return default route(s) from routing table - ''' - self.assertRaises(CommandExecutionError, network.default_route, - 'family') - - with patch.object(network, 'routes', - side_effect=[[{'addr_family': 'inet'}, - {'destination': 'A'}], []]): - with patch.dict(network.__grains__, {'kernel': 'A', - 'os': 'B'}): - self.assertRaises(CommandExecutionError, - network.default_route, 'inet') - - with patch.dict(network.__grains__, {'kernel': 'Linux'}): - self.assertListEqual(network.default_route('inet'), []) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetworkTestCase, needs_daemon=False) diff --git a/tests/unit/modules/aliases_test.py b/tests/unit/modules/test_aliases.py similarity index 100% rename from tests/unit/modules/aliases_test.py rename to tests/unit/modules/test_aliases.py diff --git a/tests/unit/modules/alternatives_test.py b/tests/unit/modules/test_alternatives.py similarity index 100% rename from tests/unit/modules/alternatives_test.py rename to tests/unit/modules/test_alternatives.py diff --git a/tests/unit/modules/apache_test.py b/tests/unit/modules/test_apache.py similarity index 100% rename from tests/unit/modules/apache_test.py rename to tests/unit/modules/test_apache.py diff --git a/tests/unit/modules/aptpkg_test.py b/tests/unit/modules/test_aptpkg.py similarity index 100% rename from tests/unit/modules/aptpkg_test.py rename to tests/unit/modules/test_aptpkg.py diff --git a/tests/unit/modules/archive_test.py b/tests/unit/modules/test_archive.py similarity index 100% rename from tests/unit/modules/archive_test.py rename to tests/unit/modules/test_archive.py diff --git a/tests/unit/modules/artifactory_test.py b/tests/unit/modules/test_artifactory.py similarity index 100% rename from tests/unit/modules/artifactory_test.py rename to tests/unit/modules/test_artifactory.py diff --git a/tests/unit/modules/at_test.py b/tests/unit/modules/test_at.py similarity index 100% rename from tests/unit/modules/at_test.py rename to tests/unit/modules/test_at.py diff --git a/tests/unit/modules/augeas_cfg_test.py b/tests/unit/modules/test_augeas_cfg.py similarity index 100% rename from tests/unit/modules/augeas_cfg_test.py rename to tests/unit/modules/test_augeas_cfg.py diff --git a/tests/unit/modules/bluez_test.py b/tests/unit/modules/test_bluez.py similarity index 100% rename from tests/unit/modules/bluez_test.py rename to tests/unit/modules/test_bluez.py diff --git a/tests/unit/modules/boto_apigateway_test.py b/tests/unit/modules/test_boto_apigateway.py similarity index 100% rename from tests/unit/modules/boto_apigateway_test.py rename to tests/unit/modules/test_boto_apigateway.py diff --git a/tests/unit/modules/boto_cloudtrail_test.py b/tests/unit/modules/test_boto_cloudtrail.py similarity index 100% rename from tests/unit/modules/boto_cloudtrail_test.py rename to tests/unit/modules/test_boto_cloudtrail.py diff --git a/tests/unit/modules/boto_cloudwatch_event_test.py b/tests/unit/modules/test_boto_cloudwatch_event.py similarity index 100% rename from tests/unit/modules/boto_cloudwatch_event_test.py rename to tests/unit/modules/test_boto_cloudwatch_event.py diff --git a/tests/unit/modules/boto_cognitoidentity_test.py b/tests/unit/modules/test_boto_cognitoidentity.py similarity index 100% rename from tests/unit/modules/boto_cognitoidentity_test.py rename to tests/unit/modules/test_boto_cognitoidentity.py diff --git a/tests/unit/modules/boto_elasticsearch_domain_test.py b/tests/unit/modules/test_boto_elasticsearch_domain.py similarity index 100% rename from tests/unit/modules/boto_elasticsearch_domain_test.py rename to tests/unit/modules/test_boto_elasticsearch_domain.py diff --git a/tests/unit/modules/boto_elb_test.py b/tests/unit/modules/test_boto_elb.py similarity index 100% rename from tests/unit/modules/boto_elb_test.py rename to tests/unit/modules/test_boto_elb.py diff --git a/tests/unit/modules/boto_iot_test.py b/tests/unit/modules/test_boto_iot.py similarity index 100% rename from tests/unit/modules/boto_iot_test.py rename to tests/unit/modules/test_boto_iot.py diff --git a/tests/unit/modules/boto_lambda_test.py b/tests/unit/modules/test_boto_lambda.py similarity index 100% rename from tests/unit/modules/boto_lambda_test.py rename to tests/unit/modules/test_boto_lambda.py diff --git a/tests/unit/modules/boto_s3_bucket_test.py b/tests/unit/modules/test_boto_s3_bucket.py similarity index 100% rename from tests/unit/modules/boto_s3_bucket_test.py rename to tests/unit/modules/test_boto_s3_bucket.py diff --git a/tests/unit/modules/boto_secgroup_test.py b/tests/unit/modules/test_boto_secgroup.py similarity index 100% rename from tests/unit/modules/boto_secgroup_test.py rename to tests/unit/modules/test_boto_secgroup.py diff --git a/tests/unit/modules/boto_vpc_test.py b/tests/unit/modules/test_boto_vpc.py similarity index 100% rename from tests/unit/modules/boto_vpc_test.py rename to tests/unit/modules/test_boto_vpc.py diff --git a/tests/unit/modules/bower_test.py b/tests/unit/modules/test_bower.py similarity index 100% rename from tests/unit/modules/bower_test.py rename to tests/unit/modules/test_bower.py diff --git a/tests/unit/modules/bridge_test.py b/tests/unit/modules/test_bridge.py similarity index 100% rename from tests/unit/modules/bridge_test.py rename to tests/unit/modules/test_bridge.py diff --git a/tests/unit/modules/btrfs_test.py b/tests/unit/modules/test_btrfs.py similarity index 100% rename from tests/unit/modules/btrfs_test.py rename to tests/unit/modules/test_btrfs.py diff --git a/tests/unit/modules/cassandra_test.py b/tests/unit/modules/test_cassandra.py similarity index 100% rename from tests/unit/modules/cassandra_test.py rename to tests/unit/modules/test_cassandra.py diff --git a/tests/unit/modules/cassandra_cql_test.py b/tests/unit/modules/test_cassandra_cql.py similarity index 100% rename from tests/unit/modules/cassandra_cql_test.py rename to tests/unit/modules/test_cassandra_cql.py diff --git a/tests/unit/modules/chef_test.py b/tests/unit/modules/test_chef.py similarity index 100% rename from tests/unit/modules/chef_test.py rename to tests/unit/modules/test_chef.py diff --git a/tests/unit/modules/cmdmod_test.py b/tests/unit/modules/test_cmdmod.py similarity index 100% rename from tests/unit/modules/cmdmod_test.py rename to tests/unit/modules/test_cmdmod.py diff --git a/tests/unit/modules/composer_test.py b/tests/unit/modules/test_composer.py similarity index 100% rename from tests/unit/modules/composer_test.py rename to tests/unit/modules/test_composer.py diff --git a/tests/unit/modules/config_test.py b/tests/unit/modules/test_config.py similarity index 100% rename from tests/unit/modules/config_test.py rename to tests/unit/modules/test_config.py diff --git a/tests/unit/modules/cp_test.py b/tests/unit/modules/test_cp.py similarity index 100% rename from tests/unit/modules/cp_test.py rename to tests/unit/modules/test_cp.py diff --git a/tests/unit/modules/cpan_test.py b/tests/unit/modules/test_cpan.py similarity index 100% rename from tests/unit/modules/cpan_test.py rename to tests/unit/modules/test_cpan.py diff --git a/tests/unit/modules/cron_test.py b/tests/unit/modules/test_cron.py similarity index 100% rename from tests/unit/modules/cron_test.py rename to tests/unit/modules/test_cron.py diff --git a/tests/unit/modules/cyg_test.py b/tests/unit/modules/test_cyg.py similarity index 100% rename from tests/unit/modules/cyg_test.py rename to tests/unit/modules/test_cyg.py diff --git a/tests/unit/modules/daemontools_test.py b/tests/unit/modules/test_daemontools.py similarity index 100% rename from tests/unit/modules/daemontools_test.py rename to tests/unit/modules/test_daemontools.py diff --git a/tests/unit/modules/data_test.py b/tests/unit/modules/test_data.py similarity index 100% rename from tests/unit/modules/data_test.py rename to tests/unit/modules/test_data.py diff --git a/tests/unit/modules/ddns_test.py b/tests/unit/modules/test_ddns.py similarity index 100% rename from tests/unit/modules/ddns_test.py rename to tests/unit/modules/test_ddns.py diff --git a/tests/unit/modules/deb_apache_test.py b/tests/unit/modules/test_deb_apache.py similarity index 100% rename from tests/unit/modules/deb_apache_test.py rename to tests/unit/modules/test_deb_apache.py diff --git a/tests/unit/modules/deb_postgres_test.py b/tests/unit/modules/test_deb_postgres.py similarity index 100% rename from tests/unit/modules/deb_postgres_test.py rename to tests/unit/modules/test_deb_postgres.py diff --git a/tests/unit/modules/debconfmod_test.py b/tests/unit/modules/test_debconfmod.py similarity index 100% rename from tests/unit/modules/debconfmod_test.py rename to tests/unit/modules/test_debconfmod.py diff --git a/tests/unit/modules/debian_ip_test.py b/tests/unit/modules/test_debian_ip.py similarity index 100% rename from tests/unit/modules/debian_ip_test.py rename to tests/unit/modules/test_debian_ip.py diff --git a/tests/unit/modules/debian_service_test.py b/tests/unit/modules/test_debian_service.py similarity index 100% rename from tests/unit/modules/debian_service_test.py rename to tests/unit/modules/test_debian_service.py diff --git a/tests/unit/modules/defaults_test.py b/tests/unit/modules/test_defaults.py similarity index 100% rename from tests/unit/modules/defaults_test.py rename to tests/unit/modules/test_defaults.py diff --git a/tests/unit/modules/devmap_test.py b/tests/unit/modules/test_devmap.py similarity index 100% rename from tests/unit/modules/devmap_test.py rename to tests/unit/modules/test_devmap.py diff --git a/tests/unit/modules/dig_test.py b/tests/unit/modules/test_dig.py similarity index 100% rename from tests/unit/modules/dig_test.py rename to tests/unit/modules/test_dig.py diff --git a/tests/unit/modules/disk_test.py b/tests/unit/modules/test_disk.py similarity index 100% rename from tests/unit/modules/disk_test.py rename to tests/unit/modules/test_disk.py diff --git a/tests/unit/modules/djangomod_test.py b/tests/unit/modules/test_djangomod.py similarity index 100% rename from tests/unit/modules/djangomod_test.py rename to tests/unit/modules/test_djangomod.py diff --git a/tests/unit/modules/dnsmasq_test.py b/tests/unit/modules/test_dnsmasq.py similarity index 100% rename from tests/unit/modules/dnsmasq_test.py rename to tests/unit/modules/test_dnsmasq.py diff --git a/tests/unit/modules/dnsutil_test.py b/tests/unit/modules/test_dnsutil.py similarity index 100% rename from tests/unit/modules/dnsutil_test.py rename to tests/unit/modules/test_dnsutil.py diff --git a/tests/unit/modules/docker_test.py b/tests/unit/modules/test_docker.py similarity index 100% rename from tests/unit/modules/docker_test.py rename to tests/unit/modules/test_docker.py diff --git a/tests/unit/modules/dpkg_test.py b/tests/unit/modules/test_dpkg.py similarity index 100% rename from tests/unit/modules/dpkg_test.py rename to tests/unit/modules/test_dpkg.py diff --git a/tests/unit/modules/drac_test.py b/tests/unit/modules/test_drac.py similarity index 100% rename from tests/unit/modules/drac_test.py rename to tests/unit/modules/test_drac.py diff --git a/tests/unit/modules/drbd_test.py b/tests/unit/modules/test_drbd.py similarity index 100% rename from tests/unit/modules/drbd_test.py rename to tests/unit/modules/test_drbd.py diff --git a/tests/unit/modules/environ_test.py b/tests/unit/modules/test_environ.py similarity index 100% rename from tests/unit/modules/environ_test.py rename to tests/unit/modules/test_environ.py diff --git a/tests/unit/modules/etcd_mod_test.py b/tests/unit/modules/test_etcd_mod.py similarity index 100% rename from tests/unit/modules/etcd_mod_test.py rename to tests/unit/modules/test_etcd_mod.py diff --git a/tests/unit/modules/event_test.py b/tests/unit/modules/test_event.py similarity index 100% rename from tests/unit/modules/event_test.py rename to tests/unit/modules/test_event.py diff --git a/tests/unit/modules/extfs_test.py b/tests/unit/modules/test_extfs.py similarity index 100% rename from tests/unit/modules/extfs_test.py rename to tests/unit/modules/test_extfs.py diff --git a/tests/unit/modules/file_test.py b/tests/unit/modules/test_file.py similarity index 100% rename from tests/unit/modules/file_test.py rename to tests/unit/modules/test_file.py diff --git a/tests/unit/modules/firewalld_test.py b/tests/unit/modules/test_firewalld.py similarity index 100% rename from tests/unit/modules/firewalld_test.py rename to tests/unit/modules/test_firewalld.py diff --git a/tests/unit/modules/gem_test.py b/tests/unit/modules/test_gem.py similarity index 100% rename from tests/unit/modules/gem_test.py rename to tests/unit/modules/test_gem.py diff --git a/tests/unit/modules/genesis_test.py b/tests/unit/modules/test_genesis.py similarity index 100% rename from tests/unit/modules/genesis_test.py rename to tests/unit/modules/test_genesis.py diff --git a/tests/unit/modules/gentoo_service_test.py b/tests/unit/modules/test_gentoo_service.py similarity index 100% rename from tests/unit/modules/gentoo_service_test.py rename to tests/unit/modules/test_gentoo_service.py diff --git a/tests/unit/modules/git_test.py b/tests/unit/modules/test_git.py similarity index 100% rename from tests/unit/modules/git_test.py rename to tests/unit/modules/test_git.py diff --git a/tests/unit/modules/glusterfs_test.py b/tests/unit/modules/test_glusterfs.py similarity index 100% rename from tests/unit/modules/glusterfs_test.py rename to tests/unit/modules/test_glusterfs.py diff --git a/tests/unit/modules/gnomedesktop_test.py b/tests/unit/modules/test_gnomedesktop.py similarity index 100% rename from tests/unit/modules/gnomedesktop_test.py rename to tests/unit/modules/test_gnomedesktop.py diff --git a/tests/unit/modules/grains_test.py b/tests/unit/modules/test_grains.py similarity index 100% rename from tests/unit/modules/grains_test.py rename to tests/unit/modules/test_grains.py diff --git a/tests/unit/modules/groupadd_test.py b/tests/unit/modules/test_groupadd.py similarity index 100% rename from tests/unit/modules/groupadd_test.py rename to tests/unit/modules/test_groupadd.py diff --git a/tests/unit/modules/grub_legacy_test.py b/tests/unit/modules/test_grub_legacy.py similarity index 100% rename from tests/unit/modules/grub_legacy_test.py rename to tests/unit/modules/test_grub_legacy.py diff --git a/tests/unit/modules/guestfs_test.py b/tests/unit/modules/test_guestfs.py similarity index 100% rename from tests/unit/modules/guestfs_test.py rename to tests/unit/modules/test_guestfs.py diff --git a/tests/unit/modules/hadoop_test.py b/tests/unit/modules/test_hadoop.py similarity index 100% rename from tests/unit/modules/hadoop_test.py rename to tests/unit/modules/test_hadoop.py diff --git a/tests/unit/modules/haproxyconn_test.py b/tests/unit/modules/test_haproxyconn.py similarity index 100% rename from tests/unit/modules/haproxyconn_test.py rename to tests/unit/modules/test_haproxyconn.py diff --git a/tests/unit/modules/hashutil_test.py b/tests/unit/modules/test_hashutil.py similarity index 100% rename from tests/unit/modules/hashutil_test.py rename to tests/unit/modules/test_hashutil.py diff --git a/tests/unit/modules/hg_test.py b/tests/unit/modules/test_hg.py similarity index 100% rename from tests/unit/modules/hg_test.py rename to tests/unit/modules/test_hg.py diff --git a/tests/unit/modules/hipchat_test.py b/tests/unit/modules/test_hipchat.py similarity index 100% rename from tests/unit/modules/hipchat_test.py rename to tests/unit/modules/test_hipchat.py diff --git a/tests/unit/modules/hosts_test.py b/tests/unit/modules/test_hosts.py similarity index 100% rename from tests/unit/modules/hosts_test.py rename to tests/unit/modules/test_hosts.py diff --git a/tests/unit/modules/htpasswd_test.py b/tests/unit/modules/test_htpasswd.py similarity index 100% rename from tests/unit/modules/htpasswd_test.py rename to tests/unit/modules/test_htpasswd.py diff --git a/tests/unit/modules/http_test.py b/tests/unit/modules/test_http.py similarity index 100% rename from tests/unit/modules/http_test.py rename to tests/unit/modules/test_http.py diff --git a/tests/unit/modules/ilo_test.py b/tests/unit/modules/test_ilo.py similarity index 100% rename from tests/unit/modules/ilo_test.py rename to tests/unit/modules/test_ilo.py diff --git a/tests/unit/modules/incron_test.py b/tests/unit/modules/test_incron.py similarity index 100% rename from tests/unit/modules/incron_test.py rename to tests/unit/modules/test_incron.py diff --git a/tests/unit/modules/influx08_test.py b/tests/unit/modules/test_influx08.py similarity index 100% rename from tests/unit/modules/influx08_test.py rename to tests/unit/modules/test_influx08.py diff --git a/tests/unit/modules/ini_manage_test.py b/tests/unit/modules/test_ini_manage.py similarity index 100% rename from tests/unit/modules/ini_manage_test.py rename to tests/unit/modules/test_ini_manage.py diff --git a/tests/unit/modules/inspect_collector_test.py b/tests/unit/modules/test_inspect_collector.py similarity index 100% rename from tests/unit/modules/inspect_collector_test.py rename to tests/unit/modules/test_inspect_collector.py diff --git a/tests/unit/modules/inspect_fsdb_test.py b/tests/unit/modules/test_inspect_fsdb.py similarity index 100% rename from tests/unit/modules/inspect_fsdb_test.py rename to tests/unit/modules/test_inspect_fsdb.py diff --git a/tests/unit/modules/introspect_test.py b/tests/unit/modules/test_introspect.py similarity index 100% rename from tests/unit/modules/introspect_test.py rename to tests/unit/modules/test_introspect.py diff --git a/tests/unit/modules/ipset_test.py b/tests/unit/modules/test_ipset.py similarity index 100% rename from tests/unit/modules/ipset_test.py rename to tests/unit/modules/test_ipset.py diff --git a/tests/unit/modules/iptables_test.py b/tests/unit/modules/test_iptables.py similarity index 100% rename from tests/unit/modules/iptables_test.py rename to tests/unit/modules/test_iptables.py diff --git a/tests/unit/modules/jboss7_test.py b/tests/unit/modules/test_jboss7.py similarity index 100% rename from tests/unit/modules/jboss7_test.py rename to tests/unit/modules/test_jboss7.py diff --git a/tests/unit/modules/jboss7_cli_test.py b/tests/unit/modules/test_jboss7_cli.py similarity index 100% rename from tests/unit/modules/jboss7_cli_test.py rename to tests/unit/modules/test_jboss7_cli.py diff --git a/tests/unit/modules/k8s_test.py b/tests/unit/modules/test_k8s.py similarity index 100% rename from tests/unit/modules/k8s_test.py rename to tests/unit/modules/test_k8s.py diff --git a/tests/unit/modules/kapacitor_test.py b/tests/unit/modules/test_kapacitor.py similarity index 100% rename from tests/unit/modules/kapacitor_test.py rename to tests/unit/modules/test_kapacitor.py diff --git a/tests/unit/modules/key_test.py b/tests/unit/modules/test_key.py similarity index 100% rename from tests/unit/modules/key_test.py rename to tests/unit/modules/test_key.py diff --git a/tests/unit/modules/keyboard_test.py b/tests/unit/modules/test_keyboard.py similarity index 100% rename from tests/unit/modules/keyboard_test.py rename to tests/unit/modules/test_keyboard.py diff --git a/tests/unit/modules/keystone_test.py b/tests/unit/modules/test_keystone.py similarity index 100% rename from tests/unit/modules/keystone_test.py rename to tests/unit/modules/test_keystone.py diff --git a/tests/unit/modules/kmod_test.py b/tests/unit/modules/test_kmod.py similarity index 100% rename from tests/unit/modules/kmod_test.py rename to tests/unit/modules/test_kmod.py diff --git a/tests/unit/modules/launchctl_test.py b/tests/unit/modules/test_launchctl.py similarity index 100% rename from tests/unit/modules/launchctl_test.py rename to tests/unit/modules/test_launchctl.py diff --git a/tests/unit/modules/ldapmod_test.py b/tests/unit/modules/test_ldapmod.py similarity index 100% rename from tests/unit/modules/ldapmod_test.py rename to tests/unit/modules/test_ldapmod.py diff --git a/tests/unit/modules/libcloud_dns_test.py b/tests/unit/modules/test_libcloud_dns.py similarity index 100% rename from tests/unit/modules/libcloud_dns_test.py rename to tests/unit/modules/test_libcloud_dns.py diff --git a/tests/unit/modules/linux_acl_test.py b/tests/unit/modules/test_linux_acl.py similarity index 100% rename from tests/unit/modules/linux_acl_test.py rename to tests/unit/modules/test_linux_acl.py diff --git a/tests/unit/modules/linux_lvm_test.py b/tests/unit/modules/test_linux_lvm.py similarity index 100% rename from tests/unit/modules/linux_lvm_test.py rename to tests/unit/modules/test_linux_lvm.py diff --git a/tests/unit/modules/linux_sysctl_test.py b/tests/unit/modules/test_linux_sysctl.py similarity index 100% rename from tests/unit/modules/linux_sysctl_test.py rename to tests/unit/modules/test_linux_sysctl.py diff --git a/tests/unit/modules/localemod_test.py b/tests/unit/modules/test_localemod.py similarity index 100% rename from tests/unit/modules/localemod_test.py rename to tests/unit/modules/test_localemod.py diff --git a/tests/unit/modules/locate_test.py b/tests/unit/modules/test_locate.py similarity index 100% rename from tests/unit/modules/locate_test.py rename to tests/unit/modules/test_locate.py diff --git a/tests/unit/modules/logadm_test.py b/tests/unit/modules/test_logadm.py similarity index 100% rename from tests/unit/modules/logadm_test.py rename to tests/unit/modules/test_logadm.py diff --git a/tests/unit/modules/logrotate_test.py b/tests/unit/modules/test_logrotate.py similarity index 100% rename from tests/unit/modules/logrotate_test.py rename to tests/unit/modules/test_logrotate.py diff --git a/tests/unit/modules/lvs_test.py b/tests/unit/modules/test_lvs.py similarity index 100% rename from tests/unit/modules/lvs_test.py rename to tests/unit/modules/test_lvs.py diff --git a/tests/unit/modules/mac_assistive_test.py b/tests/unit/modules/test_mac_assistive.py similarity index 100% rename from tests/unit/modules/mac_assistive_test.py rename to tests/unit/modules/test_mac_assistive.py diff --git a/tests/unit/modules/mac_brew_test.py b/tests/unit/modules/test_mac_brew.py similarity index 100% rename from tests/unit/modules/mac_brew_test.py rename to tests/unit/modules/test_mac_brew.py diff --git a/tests/unit/modules/mac_defaults_test.py b/tests/unit/modules/test_mac_defaults.py similarity index 100% rename from tests/unit/modules/mac_defaults_test.py rename to tests/unit/modules/test_mac_defaults.py diff --git a/tests/unit/modules/mac_desktop_test.py b/tests/unit/modules/test_mac_desktop.py similarity index 100% rename from tests/unit/modules/mac_desktop_test.py rename to tests/unit/modules/test_mac_desktop.py diff --git a/tests/unit/modules/mac_group_test.py b/tests/unit/modules/test_mac_group.py similarity index 100% rename from tests/unit/modules/mac_group_test.py rename to tests/unit/modules/test_mac_group.py diff --git a/tests/unit/modules/mac_keychain_test.py b/tests/unit/modules/test_mac_keychain.py similarity index 100% rename from tests/unit/modules/mac_keychain_test.py rename to tests/unit/modules/test_mac_keychain.py diff --git a/tests/unit/modules/mac_package_test.py b/tests/unit/modules/test_mac_package.py similarity index 100% rename from tests/unit/modules/mac_package_test.py rename to tests/unit/modules/test_mac_package.py diff --git a/tests/unit/modules/mac_pkgutil_test.py b/tests/unit/modules/test_mac_pkgutil.py similarity index 100% rename from tests/unit/modules/mac_pkgutil_test.py rename to tests/unit/modules/test_mac_pkgutil.py diff --git a/tests/unit/modules/mac_power_test.py b/tests/unit/modules/test_mac_power.py similarity index 100% rename from tests/unit/modules/mac_power_test.py rename to tests/unit/modules/test_mac_power.py diff --git a/tests/unit/modules/mac_sysctl_test.py b/tests/unit/modules/test_mac_sysctl.py similarity index 100% rename from tests/unit/modules/mac_sysctl_test.py rename to tests/unit/modules/test_mac_sysctl.py diff --git a/tests/unit/modules/mac_user_test.py b/tests/unit/modules/test_mac_user.py similarity index 100% rename from tests/unit/modules/mac_user_test.py rename to tests/unit/modules/test_mac_user.py diff --git a/tests/unit/modules/mac_xattr_test.py b/tests/unit/modules/test_mac_xattr.py similarity index 100% rename from tests/unit/modules/mac_xattr_test.py rename to tests/unit/modules/test_mac_xattr.py diff --git a/tests/unit/modules/mdadm_test.py b/tests/unit/modules/test_mdadm.py similarity index 100% rename from tests/unit/modules/mdadm_test.py rename to tests/unit/modules/test_mdadm.py diff --git a/tests/unit/modules/memcached_test.py b/tests/unit/modules/test_memcached.py similarity index 100% rename from tests/unit/modules/memcached_test.py rename to tests/unit/modules/test_memcached.py diff --git a/tests/unit/modules/mine_test.py b/tests/unit/modules/test_mine.py similarity index 100% rename from tests/unit/modules/mine_test.py rename to tests/unit/modules/test_mine.py diff --git a/tests/unit/modules/mod_random_test.py b/tests/unit/modules/test_mod_random.py similarity index 100% rename from tests/unit/modules/mod_random_test.py rename to tests/unit/modules/test_mod_random.py diff --git a/tests/unit/modules/modjk_test.py b/tests/unit/modules/test_modjk.py similarity index 100% rename from tests/unit/modules/modjk_test.py rename to tests/unit/modules/test_modjk.py diff --git a/tests/unit/modules/monit_test.py b/tests/unit/modules/test_monit.py similarity index 100% rename from tests/unit/modules/monit_test.py rename to tests/unit/modules/test_monit.py diff --git a/tests/unit/modules/moosefs_test.py b/tests/unit/modules/test_moosefs.py similarity index 100% rename from tests/unit/modules/moosefs_test.py rename to tests/unit/modules/test_moosefs.py diff --git a/tests/unit/modules/mount_test.py b/tests/unit/modules/test_mount.py similarity index 100% rename from tests/unit/modules/mount_test.py rename to tests/unit/modules/test_mount.py diff --git a/tests/unit/modules/munin_test.py b/tests/unit/modules/test_munin.py similarity index 100% rename from tests/unit/modules/munin_test.py rename to tests/unit/modules/test_munin.py diff --git a/tests/unit/modules/mysql_test.py b/tests/unit/modules/test_mysql.py similarity index 100% rename from tests/unit/modules/mysql_test.py rename to tests/unit/modules/test_mysql.py diff --git a/tests/unit/modules/nagios_test.py b/tests/unit/modules/test_nagios.py similarity index 100% rename from tests/unit/modules/nagios_test.py rename to tests/unit/modules/test_nagios.py diff --git a/tests/unit/modules/netscaler_test.py b/tests/unit/modules/test_netscaler.py similarity index 100% rename from tests/unit/modules/netscaler_test.py rename to tests/unit/modules/test_netscaler.py diff --git a/tests/unit/modules/test_network.py b/tests/unit/modules/test_network.py index 7c0946b127..276bbed5db 100644 --- a/tests/unit/modules/test_network.py +++ b/tests/unit/modules/test_network.py @@ -1,25 +1,365 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Jayesh Kariya ` +''' -# Import Python libs +# Import Python Libs from __future__ import absolute_import +import socket +import os.path -# Import Salt Testing libs -from salttesting.case import ModuleCase +# Import Salt Testing Libs +from salttesting import TestCase, skipIf +from salttesting.mock import ( + mock_open, + MagicMock, + patch, + NO_MOCK, + NO_MOCK_REASON +) -# Import Salt libs -import salt.loader +from salttesting.helpers import ensure_in_syspath + +ensure_in_syspath('../../') + +# Import Salt Libs +import salt.ext.six as six +import salt.utils +from salt.modules import network +from salt.exceptions import CommandExecutionError +if six.PY2: + import salt.ext.ipaddress + +# Globals +network.__grains__ = {} +network.__salt__ = {} -class NetworkUtilsTestCase(ModuleCase): +@skipIf(NO_MOCK, NO_MOCK_REASON) +class NetworkTestCase(TestCase): + ''' + Test cases for salt.modules.network + ''' + def test_wol_bad_mac(self): + ''' + tests network.wol with bad mac + ''' + bad_mac = '31337' + self.assertRaises(ValueError, network.wol, bad_mac) + + def test_wol_success(self): + ''' + tests network.wol success + ''' + mac = '080027136977' + bcast = '255.255.255.255 7' + + class MockSocket(object): + def __init__(self, *args, **kwargs): + pass + + def __call__(self, *args, **kwargs): + pass + + def setsockopt(self, *args, **kwargs): + pass + + def sendto(self, *args, **kwargs): + pass + + with patch('socket.socket', MockSocket): + self.assertTrue(network.wol(mac, bcast)) + + def test_ping(self): + ''' + Test for Performs a ping to a host + ''' + with patch.object(salt.utils.network, 'sanitize_host', + return_value='A'): + mock_all = MagicMock(side_effect=[{'retcode': 1}, {'retcode': 0}]) + with patch.dict(network.__salt__, {'cmd.run_all': mock_all}): + self.assertFalse(network.ping('host', return_boolean=True)) + + self.assertTrue(network.ping('host', return_boolean=True)) + + with patch.dict(network.__salt__, {'cmd.run': + MagicMock(return_value='A')}): + self.assertEqual(network.ping('host'), 'A') + + def test_netstat(self): + ''' + Test for return information on open ports and states + ''' + with patch.dict(network.__grains__, {'kernel': 'Linux'}): + with patch.object(network, '_netstat_linux', return_value='A'): + self.assertEqual(network.netstat(), 'A') + + with patch.dict(network.__grains__, {'kernel': 'OpenBSD'}): + with patch.object(network, '_netstat_bsd', return_value='A'): + self.assertEqual(network.netstat(), 'A') + + with patch.dict(network.__grains__, {'kernel': 'A'}): + self.assertRaises(CommandExecutionError, network.netstat) + + def test_active_tcp(self): + ''' + Test for return a dict containing information on all + of the running TCP connections + ''' + with patch.object(salt.utils.network, 'active_tcp', return_value='A'): + with patch.dict(network.__grains__, {'kernel': 'Linux'}): + self.assertEqual(network.active_tcp(), 'A') + + def test_traceroute(self): + ''' + Test for Performs a traceroute to a 3rd party host + ''' + with patch.object(salt.utils, 'which', side_effect=[False, True]): + self.assertListEqual(network.traceroute('host'), []) + + with patch.object(salt.utils.network, 'sanitize_host', + return_value='A'): + with patch.dict(network.__salt__, {'cmd.run': + MagicMock(return_value="")}): + self.assertListEqual(network.traceroute('host'), []) + + def test_dig(self): + ''' + Test for Performs a DNS lookup with dig + ''' + with patch.object(salt.utils.network, 'sanitize_host', + return_value='A'): + with patch.dict(network.__salt__, {'cmd.run': + MagicMock(return_value='A')}): + self.assertEqual(network.dig('host'), 'A') + + @patch('salt.utils.which', MagicMock(return_value='')) + def test_arp(self): + ''' + Test for return the arp table from the minion + ''' + with patch.dict(network.__salt__, + {'cmd.run': + MagicMock(return_value='A,B,C,D\nE,F,G,H\n')}): + self.assertDictEqual(network.arp(), {}) + + def test_interfaces(self): + ''' + Test for return a dictionary of information about + all the interfaces on the minion + ''' + with patch.object(salt.utils.network, 'interfaces', return_value={}): + self.assertDictEqual(network.interfaces(), {}) + + def test_hw_addr(self): + ''' + Test for return the hardware address (a.k.a. MAC address) + for a given interface + ''' + with patch.object(salt.utils.network, 'hw_addr', return_value={}): + self.assertDictEqual(network.hw_addr('iface'), {}) + + def test_interface(self): + ''' + Test for return the inet address for a given interface + ''' + with patch.object(salt.utils.network, 'interface', return_value={}): + self.assertDictEqual(network.interface('iface'), {}) + + def test_interface_ip(self): + ''' + Test for return the inet address for a given interface + ''' + with patch.object(salt.utils.network, 'interface_ip', return_value={}): + self.assertDictEqual(network.interface_ip('iface'), {}) + + def test_subnets(self): + ''' + Test for returns a list of subnets to which the host belongs + ''' + with patch.object(salt.utils.network, 'subnets', return_value={}): + self.assertDictEqual(network.subnets(), {}) + + def test_in_subnet(self): + ''' + Test for returns True if host is within specified + subnet, otherwise False. + ''' + with patch.object(salt.utils.network, 'in_subnet', return_value={}): + self.assertDictEqual(network.in_subnet('iface'), {}) + + def test_ip_addrs(self): + ''' + Test for returns a list of IPv4 addresses assigned to the host. + ''' + with patch.object(salt.utils.network, 'ip_addrs', + return_value=['0.0.0.0']): + with patch.object(salt.utils.network, 'in_subnet', + return_value=True): + self.assertListEqual(network.ip_addrs('interface', + 'include_loopback', + 'cidr'), ['0.0.0.0']) + + self.assertListEqual(network.ip_addrs('interface', + 'include_loopback'), + ['0.0.0.0']) + + def test_ip_addrs6(self): + ''' + Test for returns a list of IPv6 addresses assigned to the host. + ''' + with patch.object(salt.utils.network, 'ip_addrs6', + return_value=['A']): + self.assertListEqual(network.ip_addrs6('int', 'include'), ['A']) + + def test_get_hostname(self): + ''' + Test for Get hostname + ''' + with patch.object(network.socket, 'gethostname', return_value='A'): + self.assertEqual(network.get_hostname(), 'A') + + def test_mod_hostname(self): + ''' + Test for Modify hostname + ''' + self.assertFalse(network.mod_hostname(None)) + + with patch.object(salt.utils, 'which', return_value='hostname'): + with patch.dict(network.__salt__, + {'cmd.run': MagicMock(return_value=None)}): + file_d = '\n'.join(['#', 'A B C D,E,F G H']) + with patch('salt.utils.fopen', mock_open(read_data=file_d), + create=True) as mfi: + mfi.return_value.__iter__.return_value = file_d.splitlines() + with patch.dict(network.__grains__, {'os_family': 'A'}): + self.assertTrue(network.mod_hostname('hostname')) + + @patch('socket.socket') + def test_connect(self, mock_socket): + ''' + Test for Test connectivity to a host using a particular + port from the minion. + ''' + self.assertDictEqual(network.connect(False, 'port'), + {'comment': 'Required argument, host, is missing.', + 'result': False}) + + self.assertDictEqual(network.connect('host', False), + {'comment': 'Required argument, port, is missing.', + 'result': False}) + + ret = 'Unable to connect to host (0) on tcp port port' + mock_socket.side_effect = Exception('foo') + with patch.object(salt.utils.network, 'sanitize_host', + return_value='A'): + with patch.object(socket, 'getaddrinfo', + return_value=[['ipv4', 'A', 6, 'B', '0.0.0.0']]): + self.assertDictEqual(network.connect('host', 'port'), + {'comment': ret, 'result': False}) + + ret = 'Successfully connected to host (0) on tcp port port' + mock_socket.side_effect = MagicMock() + mock_socket.settimeout().return_value = None + mock_socket.connect().return_value = None + mock_socket.shutdown().return_value = None + with patch.object(salt.utils.network, 'sanitize_host', + return_value='A'): + with patch.object(socket, + 'getaddrinfo', + return_value=[['ipv4', + 'A', 6, 'B', '0.0.0.0']]): + self.assertDictEqual(network.connect('host', 'port'), + {'comment': ret, 'result': True}) + + @skipIf(not six.PY2, 'test applies only to python 2') def test_is_private(self): - __salt__ = salt.loader.raw_mod(self.minion_opts, 'network', None) - self.assertTrue(__salt__['network.is_private']('10.0.0.1'), True) + ''' + Test for Check if the given IP address is a private address + ''' + with patch.object(salt.ext.ipaddress.IPv4Address, 'is_private', + return_value=True): + self.assertTrue(network.is_private('0.0.0.0')) + with patch.object(salt.ext.ipaddress.IPv6Address, 'is_private', + return_value=True): + self.assertTrue(network.is_private('::1')) + @skipIf(not six.PY2, 'test applies only to python 2') def test_is_loopback(self): - __salt__ = salt.loader.raw_mod(self.minion_opts, 'network', None) - self.assertTrue(__salt__['network.is_loopback']('127.0.0.1'), True) + ''' + Test for Check if the given IP address is a loopback address + ''' + with patch.object(salt.ext.ipaddress.IPv4Address, 'is_loopback', + return_value=True): + self.assertTrue(network.is_loopback('127.0.0.1')) + with patch.object(salt.ext.ipaddress.IPv6Address, 'is_loopback', + return_value=True): + self.assertTrue(network.is_loopback('::1')) + + def test_get_bufsize(self): + ''' + Test for return network buffer sizes as a dict + ''' + with patch.dict(network.__grains__, {'kernel': 'Linux'}): + with patch.object(os.path, 'exists', return_value=True): + with patch.object(network, '_get_bufsize_linux', + return_value={'size': 1}): + self.assertDictEqual(network.get_bufsize('iface'), + {'size': 1}) + + with patch.dict(network.__grains__, {'kernel': 'A'}): + self.assertDictEqual(network.get_bufsize('iface'), {}) + + def test_mod_bufsize(self): + ''' + Test for Modify network interface buffers (currently linux only) + ''' + with patch.dict(network.__grains__, {'kernel': 'Linux'}): + with patch.object(os.path, 'exists', return_value=True): + with patch.object(network, '_mod_bufsize_linux', + return_value={'size': 1}): + self.assertDictEqual(network.mod_bufsize('iface'), + {'size': 1}) + + with patch.dict(network.__grains__, {'kernel': 'A'}): + self.assertFalse(network.mod_bufsize('iface')) + + def test_routes(self): + ''' + Test for return currently configured routes from routing table + ''' + self.assertRaises(CommandExecutionError, network.routes, 'family') + + with patch.dict(network.__grains__, {'kernel': 'A', 'os': 'B'}): + self.assertRaises(CommandExecutionError, network.routes, 'inet') + + with patch.dict(network.__grains__, {'kernel': 'Linux'}): + with patch.object(network, '_netstat_route_linux', + side_effect=['A', [{'addr_family': 'inet'}]]): + self.assertEqual(network.routes(None), 'A') + + self.assertListEqual(network.routes('inet'), + [{'addr_family': 'inet'}]) + + def test_default_route(self): + ''' + Test for return default route(s) from routing table + ''' + self.assertRaises(CommandExecutionError, network.default_route, + 'family') + + with patch.object(network, 'routes', + side_effect=[[{'addr_family': 'inet'}, + {'destination': 'A'}], []]): + with patch.dict(network.__grains__, {'kernel': 'A', + 'os': 'B'}): + self.assertRaises(CommandExecutionError, + network.default_route, 'inet') + + with patch.dict(network.__grains__, {'kernel': 'Linux'}): + self.assertListEqual(network.default_route('inet'), []) + if __name__ == '__main__': from integration import run_tests - run_tests(NetworkUtilsTestCase, - needs_daemon=False) + run_tests(NetworkTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_network_utils.py b/tests/unit/modules/test_network_utils.py new file mode 100644 index 0000000000..7c0946b127 --- /dev/null +++ b/tests/unit/modules/test_network_utils.py @@ -0,0 +1,25 @@ +# coding: utf-8 + +# Import Python libs +from __future__ import absolute_import + +# Import Salt Testing libs +from salttesting.case import ModuleCase + +# Import Salt libs +import salt.loader + + +class NetworkUtilsTestCase(ModuleCase): + def test_is_private(self): + __salt__ = salt.loader.raw_mod(self.minion_opts, 'network', None) + self.assertTrue(__salt__['network.is_private']('10.0.0.1'), True) + + def test_is_loopback(self): + __salt__ = salt.loader.raw_mod(self.minion_opts, 'network', None) + self.assertTrue(__salt__['network.is_loopback']('127.0.0.1'), True) + +if __name__ == '__main__': + from integration import run_tests + run_tests(NetworkUtilsTestCase, + needs_daemon=False) diff --git a/tests/unit/modules/neutron_test.py b/tests/unit/modules/test_neutron.py similarity index 100% rename from tests/unit/modules/neutron_test.py rename to tests/unit/modules/test_neutron.py diff --git a/tests/unit/modules/nfs3_test.py b/tests/unit/modules/test_nfs3.py similarity index 100% rename from tests/unit/modules/nfs3_test.py rename to tests/unit/modules/test_nfs3.py diff --git a/tests/unit/modules/nftables_test.py b/tests/unit/modules/test_nftables.py similarity index 100% rename from tests/unit/modules/nftables_test.py rename to tests/unit/modules/test_nftables.py diff --git a/tests/unit/modules/nginx_test.py b/tests/unit/modules/test_nginx.py similarity index 100% rename from tests/unit/modules/nginx_test.py rename to tests/unit/modules/test_nginx.py diff --git a/tests/unit/modules/nova_test.py b/tests/unit/modules/test_nova.py similarity index 100% rename from tests/unit/modules/nova_test.py rename to tests/unit/modules/test_nova.py diff --git a/tests/unit/modules/npm_test.py b/tests/unit/modules/test_npm.py similarity index 100% rename from tests/unit/modules/npm_test.py rename to tests/unit/modules/test_npm.py diff --git a/tests/unit/modules/openbsdpkg_test.py b/tests/unit/modules/test_openbsdpkg.py similarity index 100% rename from tests/unit/modules/openbsdpkg_test.py rename to tests/unit/modules/test_openbsdpkg.py diff --git a/tests/unit/modules/openscap_test.py b/tests/unit/modules/test_openscap.py similarity index 100% rename from tests/unit/modules/openscap_test.py rename to tests/unit/modules/test_openscap.py diff --git a/tests/unit/modules/openstack_config_test.py b/tests/unit/modules/test_openstack_config.py similarity index 100% rename from tests/unit/modules/openstack_config_test.py rename to tests/unit/modules/test_openstack_config.py diff --git a/tests/unit/modules/oracle_test.py b/tests/unit/modules/test_oracle.py similarity index 100% rename from tests/unit/modules/oracle_test.py rename to tests/unit/modules/test_oracle.py diff --git a/tests/unit/modules/pacman_test.py b/tests/unit/modules/test_pacman.py similarity index 100% rename from tests/unit/modules/pacman_test.py rename to tests/unit/modules/test_pacman.py diff --git a/tests/unit/modules/pagerduty_test.py b/tests/unit/modules/test_pagerduty.py similarity index 100% rename from tests/unit/modules/pagerduty_test.py rename to tests/unit/modules/test_pagerduty.py diff --git a/tests/unit/modules/pam_test.py b/tests/unit/modules/test_pam.py similarity index 100% rename from tests/unit/modules/pam_test.py rename to tests/unit/modules/test_pam.py diff --git a/tests/unit/modules/parallels_test.py b/tests/unit/modules/test_parallels.py similarity index 100% rename from tests/unit/modules/parallels_test.py rename to tests/unit/modules/test_parallels.py diff --git a/tests/unit/modules/parted_test.py b/tests/unit/modules/test_parted.py similarity index 100% rename from tests/unit/modules/parted_test.py rename to tests/unit/modules/test_parted.py diff --git a/tests/unit/modules/pecl_test.py b/tests/unit/modules/test_pecl.py similarity index 100% rename from tests/unit/modules/pecl_test.py rename to tests/unit/modules/test_pecl.py diff --git a/tests/unit/modules/pillar_test.py b/tests/unit/modules/test_pillar.py similarity index 100% rename from tests/unit/modules/pillar_test.py rename to tests/unit/modules/test_pillar.py diff --git a/tests/unit/modules/pip_test.py b/tests/unit/modules/test_pip.py similarity index 100% rename from tests/unit/modules/pip_test.py rename to tests/unit/modules/test_pip.py diff --git a/tests/unit/modules/pkg_resource_test.py b/tests/unit/modules/test_pkg_resource.py similarity index 100% rename from tests/unit/modules/pkg_resource_test.py rename to tests/unit/modules/test_pkg_resource.py diff --git a/tests/unit/modules/pkgutil_test.py b/tests/unit/modules/test_pkgutil.py similarity index 100% rename from tests/unit/modules/pkgutil_test.py rename to tests/unit/modules/test_pkgutil.py diff --git a/tests/unit/modules/portage_config.py b/tests/unit/modules/test_portage_config.py similarity index 100% rename from tests/unit/modules/portage_config.py rename to tests/unit/modules/test_portage_config.py diff --git a/tests/unit/modules/postfix_test.py b/tests/unit/modules/test_postfix.py similarity index 100% rename from tests/unit/modules/postfix_test.py rename to tests/unit/modules/test_postfix.py diff --git a/tests/unit/modules/postgres_test.py b/tests/unit/modules/test_postgres.py similarity index 100% rename from tests/unit/modules/postgres_test.py rename to tests/unit/modules/test_postgres.py diff --git a/tests/unit/modules/poudriere_test.py b/tests/unit/modules/test_poudriere.py similarity index 100% rename from tests/unit/modules/poudriere_test.py rename to tests/unit/modules/test_poudriere.py diff --git a/tests/unit/modules/powerpath_test.py b/tests/unit/modules/test_powerpath.py similarity index 100% rename from tests/unit/modules/powerpath_test.py rename to tests/unit/modules/test_powerpath.py diff --git a/tests/unit/modules/proxy_test.py b/tests/unit/modules/test_proxy.py similarity index 100% rename from tests/unit/modules/proxy_test.py rename to tests/unit/modules/test_proxy.py diff --git a/tests/unit/modules/ps_test.py b/tests/unit/modules/test_ps.py similarity index 100% rename from tests/unit/modules/ps_test.py rename to tests/unit/modules/test_ps.py diff --git a/tests/unit/modules/publish_test.py b/tests/unit/modules/test_publish.py similarity index 100% rename from tests/unit/modules/publish_test.py rename to tests/unit/modules/test_publish.py diff --git a/tests/unit/modules/puppet_test.py b/tests/unit/modules/test_puppet.py similarity index 100% rename from tests/unit/modules/puppet_test.py rename to tests/unit/modules/test_puppet.py diff --git a/tests/unit/modules/pw_group_test.py b/tests/unit/modules/test_pw_group.py similarity index 100% rename from tests/unit/modules/pw_group_test.py rename to tests/unit/modules/test_pw_group.py diff --git a/tests/unit/modules/pw_user_test.py b/tests/unit/modules/test_pw_user.py similarity index 100% rename from tests/unit/modules/pw_user_test.py rename to tests/unit/modules/test_pw_user.py diff --git a/tests/unit/modules/pyenv_test.py b/tests/unit/modules/test_pyenv.py similarity index 100% rename from tests/unit/modules/pyenv_test.py rename to tests/unit/modules/test_pyenv.py diff --git a/tests/unit/modules/qemu_img_test.py b/tests/unit/modules/test_qemu_img.py similarity index 100% rename from tests/unit/modules/qemu_img_test.py rename to tests/unit/modules/test_qemu_img.py diff --git a/tests/unit/modules/qemu_nbd_test.py b/tests/unit/modules/test_qemu_nbd.py similarity index 100% rename from tests/unit/modules/qemu_nbd_test.py rename to tests/unit/modules/test_qemu_nbd.py diff --git a/tests/unit/modules/rabbitmq_test.py b/tests/unit/modules/test_rabbitmq.py similarity index 100% rename from tests/unit/modules/rabbitmq_test.py rename to tests/unit/modules/test_rabbitmq.py diff --git a/tests/unit/modules/raet_publish_test.py b/tests/unit/modules/test_raet_publish.py similarity index 100% rename from tests/unit/modules/raet_publish_test.py rename to tests/unit/modules/test_raet_publish.py diff --git a/tests/unit/modules/rbenv_test.py b/tests/unit/modules/test_rbenv.py similarity index 100% rename from tests/unit/modules/rbenv_test.py rename to tests/unit/modules/test_rbenv.py diff --git a/tests/unit/modules/rdp_test.py b/tests/unit/modules/test_rdp.py similarity index 100% rename from tests/unit/modules/rdp_test.py rename to tests/unit/modules/test_rdp.py diff --git a/tests/unit/modules/redismod_test.py b/tests/unit/modules/test_redismod.py similarity index 100% rename from tests/unit/modules/redismod_test.py rename to tests/unit/modules/test_redismod.py diff --git a/tests/unit/modules/reg_win_test.py b/tests/unit/modules/test_reg_win.py similarity index 100% rename from tests/unit/modules/reg_win_test.py rename to tests/unit/modules/test_reg_win.py diff --git a/tests/unit/modules/ret_test.py b/tests/unit/modules/test_ret.py similarity index 100% rename from tests/unit/modules/ret_test.py rename to tests/unit/modules/test_ret.py diff --git a/tests/unit/modules/rh_ip_test.py b/tests/unit/modules/test_rh_ip.py similarity index 100% rename from tests/unit/modules/rh_ip_test.py rename to tests/unit/modules/test_rh_ip.py diff --git a/tests/unit/modules/rh_service_test.py b/tests/unit/modules/test_rh_service.py similarity index 100% rename from tests/unit/modules/rh_service_test.py rename to tests/unit/modules/test_rh_service.py diff --git a/tests/unit/modules/riak_test.py b/tests/unit/modules/test_riak.py similarity index 100% rename from tests/unit/modules/riak_test.py rename to tests/unit/modules/test_riak.py diff --git a/tests/unit/modules/rpm_test.py b/tests/unit/modules/test_rpm.py similarity index 100% rename from tests/unit/modules/rpm_test.py rename to tests/unit/modules/test_rpm.py diff --git a/tests/unit/modules/rsync_test.py b/tests/unit/modules/test_rsync.py similarity index 100% rename from tests/unit/modules/rsync_test.py rename to tests/unit/modules/test_rsync.py diff --git a/tests/unit/modules/rvm_test.py b/tests/unit/modules/test_rvm.py similarity index 100% rename from tests/unit/modules/rvm_test.py rename to tests/unit/modules/test_rvm.py diff --git a/tests/unit/modules/s3_test.py b/tests/unit/modules/test_s3.py similarity index 100% rename from tests/unit/modules/s3_test.py rename to tests/unit/modules/test_s3.py diff --git a/tests/unit/modules/s6_test.py b/tests/unit/modules/test_s6.py similarity index 100% rename from tests/unit/modules/s6_test.py rename to tests/unit/modules/test_s6.py diff --git a/tests/unit/modules/saltcloudmod_test.py b/tests/unit/modules/test_saltcloudmod.py similarity index 100% rename from tests/unit/modules/saltcloudmod_test.py rename to tests/unit/modules/test_saltcloudmod.py diff --git a/tests/unit/modules/schedule_test.py b/tests/unit/modules/test_schedule.py similarity index 100% rename from tests/unit/modules/schedule_test.py rename to tests/unit/modules/test_schedule.py diff --git a/tests/unit/modules/scsi_test.py b/tests/unit/modules/test_scsi.py similarity index 100% rename from tests/unit/modules/scsi_test.py rename to tests/unit/modules/test_scsi.py diff --git a/tests/unit/modules/sdb_test.py b/tests/unit/modules/test_sdb.py similarity index 100% rename from tests/unit/modules/sdb_test.py rename to tests/unit/modules/test_sdb.py diff --git a/tests/unit/modules/seed_test.py b/tests/unit/modules/test_seed.py similarity index 100% rename from tests/unit/modules/seed_test.py rename to tests/unit/modules/test_seed.py diff --git a/tests/unit/modules/sensors_test.py b/tests/unit/modules/test_sensors.py similarity index 100% rename from tests/unit/modules/sensors_test.py rename to tests/unit/modules/test_sensors.py diff --git a/tests/unit/modules/serverdensity_device_test.py b/tests/unit/modules/test_serverdensity_device.py similarity index 100% rename from tests/unit/modules/serverdensity_device_test.py rename to tests/unit/modules/test_serverdensity_device.py diff --git a/tests/unit/modules/service_test.py b/tests/unit/modules/test_service.py similarity index 100% rename from tests/unit/modules/service_test.py rename to tests/unit/modules/test_service.py diff --git a/tests/unit/modules/servicenow_test.py b/tests/unit/modules/test_servicenow.py similarity index 100% rename from tests/unit/modules/servicenow_test.py rename to tests/unit/modules/test_servicenow.py diff --git a/tests/unit/modules/shadow_test.py b/tests/unit/modules/test_shadow.py similarity index 100% rename from tests/unit/modules/shadow_test.py rename to tests/unit/modules/test_shadow.py diff --git a/tests/unit/modules/smf_test.py b/tests/unit/modules/test_smf.py similarity index 100% rename from tests/unit/modules/smf_test.py rename to tests/unit/modules/test_smf.py diff --git a/tests/unit/modules/smtp_test.py b/tests/unit/modules/test_smtp.py similarity index 100% rename from tests/unit/modules/smtp_test.py rename to tests/unit/modules/test_smtp.py diff --git a/tests/unit/modules/snapper_test.py b/tests/unit/modules/test_snapper.py similarity index 100% rename from tests/unit/modules/snapper_test.py rename to tests/unit/modules/test_snapper.py diff --git a/tests/unit/modules/solr_test.py b/tests/unit/modules/test_solr.py similarity index 100% rename from tests/unit/modules/solr_test.py rename to tests/unit/modules/test_solr.py diff --git a/tests/unit/modules/sqlite3_test.py b/tests/unit/modules/test_sqlite3.py similarity index 100% rename from tests/unit/modules/sqlite3_test.py rename to tests/unit/modules/test_sqlite3.py diff --git a/tests/unit/modules/ssh_test.py b/tests/unit/modules/test_ssh.py similarity index 100% rename from tests/unit/modules/ssh_test.py rename to tests/unit/modules/test_ssh.py diff --git a/tests/unit/modules/state_test.py b/tests/unit/modules/test_state.py similarity index 100% rename from tests/unit/modules/state_test.py rename to tests/unit/modules/test_state.py diff --git a/tests/unit/modules/status_test.py b/tests/unit/modules/test_status.py similarity index 100% rename from tests/unit/modules/status_test.py rename to tests/unit/modules/test_status.py diff --git a/tests/unit/modules/supervisord_test.py b/tests/unit/modules/test_supervisord.py similarity index 100% rename from tests/unit/modules/supervisord_test.py rename to tests/unit/modules/test_supervisord.py diff --git a/tests/unit/modules/svn_test.py b/tests/unit/modules/test_svn.py similarity index 100% rename from tests/unit/modules/svn_test.py rename to tests/unit/modules/test_svn.py diff --git a/tests/unit/modules/swift_test.py b/tests/unit/modules/test_swift.py similarity index 100% rename from tests/unit/modules/swift_test.py rename to tests/unit/modules/test_swift.py diff --git a/tests/unit/modules/sysbench_test.py b/tests/unit/modules/test_sysbench.py similarity index 100% rename from tests/unit/modules/sysbench_test.py rename to tests/unit/modules/test_sysbench.py diff --git a/tests/unit/modules/syslog_ng_test.py b/tests/unit/modules/test_syslog_ng.py similarity index 100% rename from tests/unit/modules/syslog_ng_test.py rename to tests/unit/modules/test_syslog_ng.py diff --git a/tests/unit/modules/sysmod_test.py b/tests/unit/modules/test_sysmod.py similarity index 100% rename from tests/unit/modules/sysmod_test.py rename to tests/unit/modules/test_sysmod.py diff --git a/tests/unit/modules/system_test.py b/tests/unit/modules/test_system.py similarity index 100% rename from tests/unit/modules/system_test.py rename to tests/unit/modules/test_system.py diff --git a/tests/unit/modules/systemd_test.py b/tests/unit/modules/test_systemd.py similarity index 100% rename from tests/unit/modules/systemd_test.py rename to tests/unit/modules/test_systemd.py diff --git a/tests/unit/modules/timezone_test.py b/tests/unit/modules/test_timezone.py similarity index 100% rename from tests/unit/modules/timezone_test.py rename to tests/unit/modules/test_timezone.py diff --git a/tests/unit/modules/tls_test.py b/tests/unit/modules/test_tls.py similarity index 100% rename from tests/unit/modules/tls_test.py rename to tests/unit/modules/test_tls.py diff --git a/tests/unit/modules/twilio_notify_test.py b/tests/unit/modules/test_twilio_notify.py similarity index 100% rename from tests/unit/modules/twilio_notify_test.py rename to tests/unit/modules/test_twilio_notify.py diff --git a/tests/unit/modules/udev_test.py b/tests/unit/modules/test_udev.py similarity index 100% rename from tests/unit/modules/udev_test.py rename to tests/unit/modules/test_udev.py diff --git a/tests/unit/modules/uptime_test.py b/tests/unit/modules/test_uptime.py similarity index 100% rename from tests/unit/modules/uptime_test.py rename to tests/unit/modules/test_uptime.py diff --git a/tests/unit/modules/useradd_test.py b/tests/unit/modules/test_useradd.py similarity index 100% rename from tests/unit/modules/useradd_test.py rename to tests/unit/modules/test_useradd.py diff --git a/tests/unit/modules/uwsgi_test.py b/tests/unit/modules/test_uwsgi.py similarity index 100% rename from tests/unit/modules/uwsgi_test.py rename to tests/unit/modules/test_uwsgi.py diff --git a/tests/unit/modules/varnish_test.py b/tests/unit/modules/test_varnish.py similarity index 100% rename from tests/unit/modules/varnish_test.py rename to tests/unit/modules/test_varnish.py diff --git a/tests/unit/modules/virt_test.py b/tests/unit/modules/test_virt.py similarity index 100% rename from tests/unit/modules/virt_test.py rename to tests/unit/modules/test_virt.py diff --git a/tests/unit/modules/virtualenv_test.py b/tests/unit/modules/test_virtualenv.py similarity index 100% rename from tests/unit/modules/virtualenv_test.py rename to tests/unit/modules/test_virtualenv.py diff --git a/tests/unit/modules/vsphere_test.py b/tests/unit/modules/test_vsphere.py similarity index 100% rename from tests/unit/modules/vsphere_test.py rename to tests/unit/modules/test_vsphere.py diff --git a/tests/unit/modules/win_autoruns_test.py b/tests/unit/modules/test_win_autoruns.py similarity index 100% rename from tests/unit/modules/win_autoruns_test.py rename to tests/unit/modules/test_win_autoruns.py diff --git a/tests/unit/modules/win_certutil_test.py b/tests/unit/modules/test_win_certutil.py similarity index 100% rename from tests/unit/modules/win_certutil_test.py rename to tests/unit/modules/test_win_certutil.py diff --git a/tests/unit/modules/win_disk_test.py b/tests/unit/modules/test_win_disk.py similarity index 100% rename from tests/unit/modules/win_disk_test.py rename to tests/unit/modules/test_win_disk.py diff --git a/tests/unit/modules/win_dism_test.py b/tests/unit/modules/test_win_dism.py similarity index 100% rename from tests/unit/modules/win_dism_test.py rename to tests/unit/modules/test_win_dism.py diff --git a/tests/unit/modules/win_dns_client_test.py b/tests/unit/modules/test_win_dns_client.py similarity index 100% rename from tests/unit/modules/win_dns_client_test.py rename to tests/unit/modules/test_win_dns_client.py diff --git a/tests/unit/modules/win_firewall_test.py b/tests/unit/modules/test_win_firewall.py similarity index 100% rename from tests/unit/modules/win_firewall_test.py rename to tests/unit/modules/test_win_firewall.py diff --git a/tests/unit/modules/win_groupadd_test.py b/tests/unit/modules/test_win_groupadd.py similarity index 100% rename from tests/unit/modules/win_groupadd_test.py rename to tests/unit/modules/test_win_groupadd.py diff --git a/tests/unit/modules/win_iis_test.py b/tests/unit/modules/test_win_iis.py similarity index 100% rename from tests/unit/modules/win_iis_test.py rename to tests/unit/modules/test_win_iis.py diff --git a/tests/unit/modules/win_ip_test.py b/tests/unit/modules/test_win_ip.py similarity index 100% rename from tests/unit/modules/win_ip_test.py rename to tests/unit/modules/test_win_ip.py diff --git a/tests/unit/modules/win_license_test.py b/tests/unit/modules/test_win_license.py similarity index 100% rename from tests/unit/modules/win_license_test.py rename to tests/unit/modules/test_win_license.py diff --git a/tests/unit/modules/win_network_test.py b/tests/unit/modules/test_win_network.py similarity index 100% rename from tests/unit/modules/win_network_test.py rename to tests/unit/modules/test_win_network.py diff --git a/tests/unit/modules/win_ntp_test.py b/tests/unit/modules/test_win_ntp.py similarity index 100% rename from tests/unit/modules/win_ntp_test.py rename to tests/unit/modules/test_win_ntp.py diff --git a/tests/unit/modules/win_path_test.py b/tests/unit/modules/test_win_path.py similarity index 100% rename from tests/unit/modules/win_path_test.py rename to tests/unit/modules/test_win_path.py diff --git a/tests/unit/modules/win_pki_test.py b/tests/unit/modules/test_win_pki.py similarity index 100% rename from tests/unit/modules/win_pki_test.py rename to tests/unit/modules/test_win_pki.py diff --git a/tests/unit/modules/win_powercfg_test.py b/tests/unit/modules/test_win_powercfg.py similarity index 100% rename from tests/unit/modules/win_powercfg_test.py rename to tests/unit/modules/test_win_powercfg.py diff --git a/tests/unit/modules/win_service_test.py b/tests/unit/modules/test_win_service.py similarity index 100% rename from tests/unit/modules/win_service_test.py rename to tests/unit/modules/test_win_service.py diff --git a/tests/unit/modules/win_shadow_test.py b/tests/unit/modules/test_win_shadow.py similarity index 100% rename from tests/unit/modules/win_shadow_test.py rename to tests/unit/modules/test_win_shadow.py diff --git a/tests/unit/modules/win_snmp_test.py b/tests/unit/modules/test_win_snmp.py similarity index 100% rename from tests/unit/modules/win_snmp_test.py rename to tests/unit/modules/test_win_snmp.py diff --git a/tests/unit/modules/win_status_test.py b/tests/unit/modules/test_win_status.py similarity index 100% rename from tests/unit/modules/win_status_test.py rename to tests/unit/modules/test_win_status.py diff --git a/tests/unit/modules/win_system_test.py b/tests/unit/modules/test_win_system.py similarity index 100% rename from tests/unit/modules/win_system_test.py rename to tests/unit/modules/test_win_system.py diff --git a/tests/unit/modules/win_timezone_test.py b/tests/unit/modules/test_win_timezone.py similarity index 100% rename from tests/unit/modules/win_timezone_test.py rename to tests/unit/modules/test_win_timezone.py diff --git a/tests/unit/modules/xapi_test.py b/tests/unit/modules/test_xapi.py similarity index 100% rename from tests/unit/modules/xapi_test.py rename to tests/unit/modules/test_xapi.py diff --git a/tests/unit/modules/zcbuildout_test.py b/tests/unit/modules/test_zcbuildout.py similarity index 100% rename from tests/unit/modules/zcbuildout_test.py rename to tests/unit/modules/test_zcbuildout.py diff --git a/tests/unit/modules/zfs_test.py b/tests/unit/modules/test_zfs.py similarity index 100% rename from tests/unit/modules/zfs_test.py rename to tests/unit/modules/test_zfs.py diff --git a/tests/unit/modules/znc_test.py b/tests/unit/modules/test_znc.py similarity index 100% rename from tests/unit/modules/znc_test.py rename to tests/unit/modules/test_znc.py diff --git a/tests/unit/modules/zpool_test.py b/tests/unit/modules/test_zpool.py similarity index 100% rename from tests/unit/modules/zpool_test.py rename to tests/unit/modules/test_zpool.py diff --git a/tests/unit/modules/zypper_test.py b/tests/unit/modules/test_zypper.py similarity index 100% rename from tests/unit/modules/zypper_test.py rename to tests/unit/modules/test_zypper.py diff --git a/tests/unit/netapi/rest_cherrypy/tools_test.py b/tests/unit/netapi/rest_cherrypy/test_tools.py similarity index 100% rename from tests/unit/netapi/rest_cherrypy/tools_test.py rename to tests/unit/netapi/rest_cherrypy/test_tools.py diff --git a/tests/unit/output/json_out_test.py b/tests/unit/output/test_json_out.py similarity index 100% rename from tests/unit/output/json_out_test.py rename to tests/unit/output/test_json_out.py diff --git a/tests/unit/output/yaml_out_test.py b/tests/unit/output/test_yaml_out.py similarity index 100% rename from tests/unit/output/yaml_out_test.py rename to tests/unit/output/test_yaml_out.py diff --git a/tests/unit/pillar/consul_test.py b/tests/unit/pillar/test_consul.py similarity index 100% rename from tests/unit/pillar/consul_test.py rename to tests/unit/pillar/test_consul.py diff --git a/tests/unit/pillar/git_test.py b/tests/unit/pillar/test_git.py similarity index 100% rename from tests/unit/pillar/git_test.py rename to tests/unit/pillar/test_git.py diff --git a/tests/unit/pillar/hg_test.py b/tests/unit/pillar/test_hg.py similarity index 100% rename from tests/unit/pillar/hg_test.py rename to tests/unit/pillar/test_hg.py diff --git a/tests/unit/pillar/mysql_test.py b/tests/unit/pillar/test_mysql.py similarity index 100% rename from tests/unit/pillar/mysql_test.py rename to tests/unit/pillar/test_mysql.py diff --git a/tests/unit/pillar/nodegroups_test.py b/tests/unit/pillar/test_nodegroups.py similarity index 100% rename from tests/unit/pillar/nodegroups_test.py rename to tests/unit/pillar/test_nodegroups.py diff --git a/tests/unit/pillar/sqlcipher_test.py b/tests/unit/pillar/test_sqlcipher.py similarity index 100% rename from tests/unit/pillar/sqlcipher_test.py rename to tests/unit/pillar/test_sqlcipher.py diff --git a/tests/unit/pillar/sqlite3_test.py b/tests/unit/pillar/test_sqlite3.py similarity index 100% rename from tests/unit/pillar/sqlite3_test.py rename to tests/unit/pillar/test_sqlite3.py diff --git a/tests/unit/renderers/gpg_test.py b/tests/unit/renderers/test_gpg.py similarity index 100% rename from tests/unit/renderers/gpg_test.py rename to tests/unit/renderers/test_gpg.py diff --git a/tests/unit/renderers/yaml_test.py b/tests/unit/renderers/test_yaml.py similarity index 100% rename from tests/unit/renderers/yaml_test.py rename to tests/unit/renderers/test_yaml.py diff --git a/tests/unit/renderers/yamlex_test.py b/tests/unit/renderers/test_yamlex.py similarity index 100% rename from tests/unit/renderers/yamlex_test.py rename to tests/unit/renderers/test_yamlex.py diff --git a/tests/unit/returners/local_cache_test.py b/tests/unit/returners/test_local_cache.py similarity index 100% rename from tests/unit/returners/local_cache_test.py rename to tests/unit/returners/test_local_cache.py diff --git a/tests/unit/returners/smtp_return_test.py b/tests/unit/returners/test_smtp_return.py similarity index 100% rename from tests/unit/returners/smtp_return_test.py rename to tests/unit/returners/test_smtp_return.py diff --git a/tests/unit/runners/cache_test.py b/tests/unit/runners/test_cache.py similarity index 100% rename from tests/unit/runners/cache_test.py rename to tests/unit/runners/test_cache.py diff --git a/tests/unit/runners/jobs_test.py b/tests/unit/runners/test_jobs.py similarity index 100% rename from tests/unit/runners/jobs_test.py rename to tests/unit/runners/test_jobs.py diff --git a/tests/unit/serializers/serializers_test.py b/tests/unit/serializers/test_serializers.py similarity index 100% rename from tests/unit/serializers/serializers_test.py rename to tests/unit/serializers/test_serializers.py diff --git a/tests/unit/ssh/ssh_single_test.py b/tests/unit/ssh/test_ssh_single.py similarity index 100% rename from tests/unit/ssh/ssh_single_test.py rename to tests/unit/ssh/test_ssh_single.py diff --git a/tests/unit/states/alias_test.py b/tests/unit/states/test_alias.py similarity index 100% rename from tests/unit/states/alias_test.py rename to tests/unit/states/test_alias.py diff --git a/tests/unit/states/alternatives_test.py b/tests/unit/states/test_alternatives.py similarity index 100% rename from tests/unit/states/alternatives_test.py rename to tests/unit/states/test_alternatives.py diff --git a/tests/unit/states/apache_test.py b/tests/unit/states/test_apache.py similarity index 100% rename from tests/unit/states/apache_test.py rename to tests/unit/states/test_apache.py diff --git a/tests/unit/states/apache_conf_test.py b/tests/unit/states/test_apache_conf.py similarity index 100% rename from tests/unit/states/apache_conf_test.py rename to tests/unit/states/test_apache_conf.py diff --git a/tests/unit/states/apache_module_test.py b/tests/unit/states/test_apache_module.py similarity index 100% rename from tests/unit/states/apache_module_test.py rename to tests/unit/states/test_apache_module.py diff --git a/tests/unit/states/apache_site_test.py b/tests/unit/states/test_apache_site.py similarity index 100% rename from tests/unit/states/apache_site_test.py rename to tests/unit/states/test_apache_site.py diff --git a/tests/unit/states/apt_test.py b/tests/unit/states/test_apt.py similarity index 100% rename from tests/unit/states/apt_test.py rename to tests/unit/states/test_apt.py diff --git a/tests/unit/states/archive_test.py b/tests/unit/states/test_archive.py similarity index 100% rename from tests/unit/states/archive_test.py rename to tests/unit/states/test_archive.py diff --git a/tests/unit/states/artifactory_test.py b/tests/unit/states/test_artifactory.py similarity index 100% rename from tests/unit/states/artifactory_test.py rename to tests/unit/states/test_artifactory.py diff --git a/tests/unit/states/at_test.py b/tests/unit/states/test_at.py similarity index 100% rename from tests/unit/states/at_test.py rename to tests/unit/states/test_at.py diff --git a/tests/unit/states/augeas_test.py b/tests/unit/states/test_augeas.py similarity index 100% rename from tests/unit/states/augeas_test.py rename to tests/unit/states/test_augeas.py diff --git a/tests/unit/states/aws_sqs_test.py b/tests/unit/states/test_aws_sqs.py similarity index 100% rename from tests/unit/states/aws_sqs_test.py rename to tests/unit/states/test_aws_sqs.py diff --git a/tests/unit/states/blockdev_test.py b/tests/unit/states/test_blockdev.py similarity index 100% rename from tests/unit/states/blockdev_test.py rename to tests/unit/states/test_blockdev.py diff --git a/tests/unit/states/boto_apigateway_test.py b/tests/unit/states/test_boto_apigateway.py similarity index 100% rename from tests/unit/states/boto_apigateway_test.py rename to tests/unit/states/test_boto_apigateway.py diff --git a/tests/unit/states/boto_asg_test.py b/tests/unit/states/test_boto_asg.py similarity index 100% rename from tests/unit/states/boto_asg_test.py rename to tests/unit/states/test_boto_asg.py diff --git a/tests/unit/states/boto_cloudtrail_test.py b/tests/unit/states/test_boto_cloudtrail.py similarity index 100% rename from tests/unit/states/boto_cloudtrail_test.py rename to tests/unit/states/test_boto_cloudtrail.py diff --git a/tests/unit/states/boto_cloudwatch_alarm_test.py b/tests/unit/states/test_boto_cloudwatch_alarm.py similarity index 100% rename from tests/unit/states/boto_cloudwatch_alarm_test.py rename to tests/unit/states/test_boto_cloudwatch_alarm.py diff --git a/tests/unit/states/boto_cloudwatch_event_test.py b/tests/unit/states/test_boto_cloudwatch_event.py similarity index 100% rename from tests/unit/states/boto_cloudwatch_event_test.py rename to tests/unit/states/test_boto_cloudwatch_event.py diff --git a/tests/unit/states/boto_cognitoidentity_test.py b/tests/unit/states/test_boto_cognitoidentity.py similarity index 100% rename from tests/unit/states/boto_cognitoidentity_test.py rename to tests/unit/states/test_boto_cognitoidentity.py diff --git a/tests/unit/states/boto_dynamodb_test.py b/tests/unit/states/test_boto_dynamodb.py similarity index 100% rename from tests/unit/states/boto_dynamodb_test.py rename to tests/unit/states/test_boto_dynamodb.py diff --git a/tests/unit/states/boto_ec2_test.py b/tests/unit/states/test_boto_ec2.py similarity index 100% rename from tests/unit/states/boto_ec2_test.py rename to tests/unit/states/test_boto_ec2.py diff --git a/tests/unit/states/boto_elasticache_test.py b/tests/unit/states/test_boto_elasticache.py similarity index 100% rename from tests/unit/states/boto_elasticache_test.py rename to tests/unit/states/test_boto_elasticache.py diff --git a/tests/unit/states/boto_elasticsearch_domain_test.py b/tests/unit/states/test_boto_elasticsearch_domain.py similarity index 100% rename from tests/unit/states/boto_elasticsearch_domain_test.py rename to tests/unit/states/test_boto_elasticsearch_domain.py diff --git a/tests/unit/states/boto_elb_test.py b/tests/unit/states/test_boto_elb.py similarity index 100% rename from tests/unit/states/boto_elb_test.py rename to tests/unit/states/test_boto_elb.py diff --git a/tests/unit/states/boto_iam_role_test.py b/tests/unit/states/test_boto_iam_role.py similarity index 100% rename from tests/unit/states/boto_iam_role_test.py rename to tests/unit/states/test_boto_iam_role.py diff --git a/tests/unit/states/boto_iot_test.py b/tests/unit/states/test_boto_iot.py similarity index 100% rename from tests/unit/states/boto_iot_test.py rename to tests/unit/states/test_boto_iot.py diff --git a/tests/unit/states/boto_kinesis_test.py b/tests/unit/states/test_boto_kinesis.py similarity index 100% rename from tests/unit/states/boto_kinesis_test.py rename to tests/unit/states/test_boto_kinesis.py diff --git a/tests/unit/states/boto_lambda_test.py b/tests/unit/states/test_boto_lambda.py similarity index 100% rename from tests/unit/states/boto_lambda_test.py rename to tests/unit/states/test_boto_lambda.py diff --git a/tests/unit/states/boto_lc_test.py b/tests/unit/states/test_boto_lc.py similarity index 100% rename from tests/unit/states/boto_lc_test.py rename to tests/unit/states/test_boto_lc.py diff --git a/tests/unit/states/boto_route53_test.py b/tests/unit/states/test_boto_route53.py similarity index 100% rename from tests/unit/states/boto_route53_test.py rename to tests/unit/states/test_boto_route53.py diff --git a/tests/unit/states/boto_s3_bucket_test.py b/tests/unit/states/test_boto_s3_bucket.py similarity index 100% rename from tests/unit/states/boto_s3_bucket_test.py rename to tests/unit/states/test_boto_s3_bucket.py diff --git a/tests/unit/states/boto_secgroup_test.py b/tests/unit/states/test_boto_secgroup.py similarity index 100% rename from tests/unit/states/boto_secgroup_test.py rename to tests/unit/states/test_boto_secgroup.py diff --git a/tests/unit/states/boto_sns_test.py b/tests/unit/states/test_boto_sns.py similarity index 100% rename from tests/unit/states/boto_sns_test.py rename to tests/unit/states/test_boto_sns.py diff --git a/tests/unit/states/boto_sqs_test.py b/tests/unit/states/test_boto_sqs.py similarity index 100% rename from tests/unit/states/boto_sqs_test.py rename to tests/unit/states/test_boto_sqs.py diff --git a/tests/unit/states/boto_vpc_test.py b/tests/unit/states/test_boto_vpc.py similarity index 100% rename from tests/unit/states/boto_vpc_test.py rename to tests/unit/states/test_boto_vpc.py diff --git a/tests/unit/states/bower_test.py b/tests/unit/states/test_bower.py similarity index 100% rename from tests/unit/states/bower_test.py rename to tests/unit/states/test_bower.py diff --git a/tests/unit/states/chef_test.py b/tests/unit/states/test_chef.py similarity index 100% rename from tests/unit/states/chef_test.py rename to tests/unit/states/test_chef.py diff --git a/tests/unit/states/cloud_test.py b/tests/unit/states/test_cloud.py similarity index 100% rename from tests/unit/states/cloud_test.py rename to tests/unit/states/test_cloud.py diff --git a/tests/unit/states/cmd_test.py b/tests/unit/states/test_cmd.py similarity index 100% rename from tests/unit/states/cmd_test.py rename to tests/unit/states/test_cmd.py diff --git a/tests/unit/states/composer_test.py b/tests/unit/states/test_composer.py similarity index 100% rename from tests/unit/states/composer_test.py rename to tests/unit/states/test_composer.py diff --git a/tests/unit/states/cron_test.py b/tests/unit/states/test_cron.py similarity index 100% rename from tests/unit/states/cron_test.py rename to tests/unit/states/test_cron.py diff --git a/tests/unit/states/cyg_test.py b/tests/unit/states/test_cyg.py similarity index 100% rename from tests/unit/states/cyg_test.py rename to tests/unit/states/test_cyg.py diff --git a/tests/unit/states/ddns_test.py b/tests/unit/states/test_ddns.py similarity index 100% rename from tests/unit/states/ddns_test.py rename to tests/unit/states/test_ddns.py diff --git a/tests/unit/states/debconfmod_test.py b/tests/unit/states/test_debconfmod.py similarity index 100% rename from tests/unit/states/debconfmod_test.py rename to tests/unit/states/test_debconfmod.py diff --git a/tests/unit/states/disk_test.py b/tests/unit/states/test_disk.py similarity index 100% rename from tests/unit/states/disk_test.py rename to tests/unit/states/test_disk.py diff --git a/tests/unit/states/docker_test.py b/tests/unit/states/test_docker.py similarity index 100% rename from tests/unit/states/docker_test.py rename to tests/unit/states/test_docker.py diff --git a/tests/unit/states/drac_test.py b/tests/unit/states/test_drac.py similarity index 100% rename from tests/unit/states/drac_test.py rename to tests/unit/states/test_drac.py diff --git a/tests/unit/states/environ_test.py b/tests/unit/states/test_environ.py similarity index 100% rename from tests/unit/states/environ_test.py rename to tests/unit/states/test_environ.py diff --git a/tests/unit/states/eselect_test.py b/tests/unit/states/test_eselect.py similarity index 100% rename from tests/unit/states/eselect_test.py rename to tests/unit/states/test_eselect.py diff --git a/tests/unit/states/event_test.py b/tests/unit/states/test_event.py similarity index 100% rename from tests/unit/states/event_test.py rename to tests/unit/states/test_event.py diff --git a/tests/unit/states/file_test.py b/tests/unit/states/test_file.py similarity index 100% rename from tests/unit/states/file_test.py rename to tests/unit/states/test_file.py diff --git a/tests/unit/states/gem_test.py b/tests/unit/states/test_gem.py similarity index 100% rename from tests/unit/states/gem_test.py rename to tests/unit/states/test_gem.py diff --git a/tests/unit/states/glusterfs_test.py b/tests/unit/states/test_glusterfs.py similarity index 100% rename from tests/unit/states/glusterfs_test.py rename to tests/unit/states/test_glusterfs.py diff --git a/tests/unit/states/gnomedesktop_test.py b/tests/unit/states/test_gnomedesktop.py similarity index 100% rename from tests/unit/states/gnomedesktop_test.py rename to tests/unit/states/test_gnomedesktop.py diff --git a/tests/unit/states/grafana_test.py b/tests/unit/states/test_grafana.py similarity index 100% rename from tests/unit/states/grafana_test.py rename to tests/unit/states/test_grafana.py diff --git a/tests/unit/states/grafana_datasource_test.py b/tests/unit/states/test_grafana_datasource.py similarity index 100% rename from tests/unit/states/grafana_datasource_test.py rename to tests/unit/states/test_grafana_datasource.py diff --git a/tests/unit/states/grains_test.py b/tests/unit/states/test_grains.py similarity index 100% rename from tests/unit/states/grains_test.py rename to tests/unit/states/test_grains.py diff --git a/tests/unit/states/group_test.py b/tests/unit/states/test_group.py similarity index 100% rename from tests/unit/states/group_test.py rename to tests/unit/states/test_group.py diff --git a/tests/unit/states/hg_test.py b/tests/unit/states/test_hg.py similarity index 100% rename from tests/unit/states/hg_test.py rename to tests/unit/states/test_hg.py diff --git a/tests/unit/states/hipchat_test.py b/tests/unit/states/test_hipchat.py similarity index 100% rename from tests/unit/states/hipchat_test.py rename to tests/unit/states/test_hipchat.py diff --git a/tests/unit/states/host_test.py b/tests/unit/states/test_host.py similarity index 100% rename from tests/unit/states/host_test.py rename to tests/unit/states/test_host.py diff --git a/tests/unit/states/htpasswd_test.py b/tests/unit/states/test_htpasswd.py similarity index 100% rename from tests/unit/states/htpasswd_test.py rename to tests/unit/states/test_htpasswd.py diff --git a/tests/unit/states/http_test.py b/tests/unit/states/test_http.py similarity index 100% rename from tests/unit/states/http_test.py rename to tests/unit/states/test_http.py diff --git a/tests/unit/states/incron_test.py b/tests/unit/states/test_incron.py similarity index 100% rename from tests/unit/states/incron_test.py rename to tests/unit/states/test_incron.py diff --git a/tests/unit/states/influxdb08_database_test.py b/tests/unit/states/test_influxdb08_database.py similarity index 100% rename from tests/unit/states/influxdb08_database_test.py rename to tests/unit/states/test_influxdb08_database.py diff --git a/tests/unit/states/influxdb08_user_test.py b/tests/unit/states/test_influxdb08_user.py similarity index 100% rename from tests/unit/states/influxdb08_user_test.py rename to tests/unit/states/test_influxdb08_user.py diff --git a/tests/unit/states/ini_manage_test.py b/tests/unit/states/test_ini_manage.py similarity index 100% rename from tests/unit/states/ini_manage_test.py rename to tests/unit/states/test_ini_manage.py diff --git a/tests/unit/states/ipmi_test.py b/tests/unit/states/test_ipmi.py similarity index 100% rename from tests/unit/states/ipmi_test.py rename to tests/unit/states/test_ipmi.py diff --git a/tests/unit/states/ipset_test.py b/tests/unit/states/test_ipset.py similarity index 100% rename from tests/unit/states/ipset_test.py rename to tests/unit/states/test_ipset.py diff --git a/tests/unit/states/iptables_test.py b/tests/unit/states/test_iptables.py similarity index 100% rename from tests/unit/states/iptables_test.py rename to tests/unit/states/test_iptables.py diff --git a/tests/unit/states/jboss7_test.py b/tests/unit/states/test_jboss7.py similarity index 100% rename from tests/unit/states/jboss7_test.py rename to tests/unit/states/test_jboss7.py diff --git a/tests/unit/states/kapacitor_test.py b/tests/unit/states/test_kapacitor.py similarity index 100% rename from tests/unit/states/kapacitor_test.py rename to tests/unit/states/test_kapacitor.py diff --git a/tests/unit/states/keyboard_test.py b/tests/unit/states/test_keyboard.py similarity index 100% rename from tests/unit/states/keyboard_test.py rename to tests/unit/states/test_keyboard.py diff --git a/tests/unit/states/keystone_test.py b/tests/unit/states/test_keystone.py similarity index 100% rename from tests/unit/states/keystone_test.py rename to tests/unit/states/test_keystone.py diff --git a/tests/unit/states/kmod_test.py b/tests/unit/states/test_kmod.py similarity index 100% rename from tests/unit/states/kmod_test.py rename to tests/unit/states/test_kmod.py diff --git a/tests/unit/states/layman_test.py b/tests/unit/states/test_layman.py similarity index 100% rename from tests/unit/states/layman_test.py rename to tests/unit/states/test_layman.py diff --git a/tests/unit/states/ldap_test.py b/tests/unit/states/test_ldap.py similarity index 100% rename from tests/unit/states/ldap_test.py rename to tests/unit/states/test_ldap.py diff --git a/tests/unit/states/libcloud_dns_test.py b/tests/unit/states/test_libcloud_dns.py similarity index 100% rename from tests/unit/states/libcloud_dns_test.py rename to tests/unit/states/test_libcloud_dns.py diff --git a/tests/unit/states/libvirt_test.py b/tests/unit/states/test_libvirt.py similarity index 100% rename from tests/unit/states/libvirt_test.py rename to tests/unit/states/test_libvirt.py diff --git a/tests/unit/states/linux_acl_test.py b/tests/unit/states/test_linux_acl.py similarity index 100% rename from tests/unit/states/linux_acl_test.py rename to tests/unit/states/test_linux_acl.py diff --git a/tests/unit/states/locale_test.py b/tests/unit/states/test_locale.py similarity index 100% rename from tests/unit/states/locale_test.py rename to tests/unit/states/test_locale.py diff --git a/tests/unit/states/lvm_test.py b/tests/unit/states/test_lvm.py similarity index 100% rename from tests/unit/states/lvm_test.py rename to tests/unit/states/test_lvm.py diff --git a/tests/unit/states/lvs_server_test.py b/tests/unit/states/test_lvs_server.py similarity index 100% rename from tests/unit/states/lvs_server_test.py rename to tests/unit/states/test_lvs_server.py diff --git a/tests/unit/states/lvs_service_test.py b/tests/unit/states/test_lvs_service.py similarity index 100% rename from tests/unit/states/lvs_service_test.py rename to tests/unit/states/test_lvs_service.py diff --git a/tests/unit/states/lxc_test.py b/tests/unit/states/test_lxc.py similarity index 100% rename from tests/unit/states/lxc_test.py rename to tests/unit/states/test_lxc.py diff --git a/tests/unit/states/mac_assistive_test.py b/tests/unit/states/test_mac_assistive.py similarity index 100% rename from tests/unit/states/mac_assistive_test.py rename to tests/unit/states/test_mac_assistive.py diff --git a/tests/unit/states/mac_defaults_test.py b/tests/unit/states/test_mac_defaults.py similarity index 100% rename from tests/unit/states/mac_defaults_test.py rename to tests/unit/states/test_mac_defaults.py diff --git a/tests/unit/states/mac_keychain_test.py b/tests/unit/states/test_mac_keychain.py similarity index 100% rename from tests/unit/states/mac_keychain_test.py rename to tests/unit/states/test_mac_keychain.py diff --git a/tests/unit/states/mac_package_test.py b/tests/unit/states/test_mac_package.py similarity index 100% rename from tests/unit/states/mac_package_test.py rename to tests/unit/states/test_mac_package.py diff --git a/tests/unit/states/mac_xattr_test.py b/tests/unit/states/test_mac_xattr.py similarity index 100% rename from tests/unit/states/mac_xattr_test.py rename to tests/unit/states/test_mac_xattr.py diff --git a/tests/unit/states/makeconf_test.py b/tests/unit/states/test_makeconf.py similarity index 100% rename from tests/unit/states/makeconf_test.py rename to tests/unit/states/test_makeconf.py diff --git a/tests/unit/states/mdadm_test.py b/tests/unit/states/test_mdadm.py similarity index 100% rename from tests/unit/states/mdadm_test.py rename to tests/unit/states/test_mdadm.py diff --git a/tests/unit/states/memcached_test.py b/tests/unit/states/test_memcached.py similarity index 100% rename from tests/unit/states/memcached_test.py rename to tests/unit/states/test_memcached.py diff --git a/tests/unit/states/modjk_test.py b/tests/unit/states/test_modjk.py similarity index 100% rename from tests/unit/states/modjk_test.py rename to tests/unit/states/test_modjk.py diff --git a/tests/unit/states/modjk_worker_test.py b/tests/unit/states/test_modjk_worker.py similarity index 100% rename from tests/unit/states/modjk_worker_test.py rename to tests/unit/states/test_modjk_worker.py diff --git a/tests/unit/states/module_test.py b/tests/unit/states/test_module.py similarity index 100% rename from tests/unit/states/module_test.py rename to tests/unit/states/test_module.py diff --git a/tests/unit/states/mongodb_database_test.py b/tests/unit/states/test_mongodb_database.py similarity index 100% rename from tests/unit/states/mongodb_database_test.py rename to tests/unit/states/test_mongodb_database.py diff --git a/tests/unit/states/mongodb_user_test.py b/tests/unit/states/test_mongodb_user.py similarity index 100% rename from tests/unit/states/mongodb_user_test.py rename to tests/unit/states/test_mongodb_user.py diff --git a/tests/unit/states/mount_test.py b/tests/unit/states/test_mount.py similarity index 100% rename from tests/unit/states/mount_test.py rename to tests/unit/states/test_mount.py diff --git a/tests/unit/states/mysql_grants_test.py b/tests/unit/states/test_mysql_grants.py similarity index 100% rename from tests/unit/states/mysql_grants_test.py rename to tests/unit/states/test_mysql_grants.py diff --git a/tests/unit/states/mysql_query_test.py b/tests/unit/states/test_mysql_query.py similarity index 100% rename from tests/unit/states/mysql_query_test.py rename to tests/unit/states/test_mysql_query.py diff --git a/tests/unit/states/mysql_user_test.py b/tests/unit/states/test_mysql_user.py similarity index 100% rename from tests/unit/states/mysql_user_test.py rename to tests/unit/states/test_mysql_user.py diff --git a/tests/unit/states/network_test.py b/tests/unit/states/test_network.py similarity index 100% rename from tests/unit/states/network_test.py rename to tests/unit/states/test_network.py diff --git a/tests/unit/states/nftables_test.py b/tests/unit/states/test_nftables.py similarity index 100% rename from tests/unit/states/nftables_test.py rename to tests/unit/states/test_nftables.py diff --git a/tests/unit/states/npm_test.py b/tests/unit/states/test_npm.py similarity index 100% rename from tests/unit/states/npm_test.py rename to tests/unit/states/test_npm.py diff --git a/tests/unit/states/ntp_test.py b/tests/unit/states/test_ntp.py similarity index 100% rename from tests/unit/states/ntp_test.py rename to tests/unit/states/test_ntp.py diff --git a/tests/unit/states/openstack_config_test.py b/tests/unit/states/test_openstack_config.py similarity index 100% rename from tests/unit/states/openstack_config_test.py rename to tests/unit/states/test_openstack_config.py diff --git a/tests/unit/states/openvswitch_port_test.py b/tests/unit/states/test_openvswitch_port.py similarity index 100% rename from tests/unit/states/openvswitch_port_test.py rename to tests/unit/states/test_openvswitch_port.py diff --git a/tests/unit/states/pagerduty_test.py b/tests/unit/states/test_pagerduty.py similarity index 100% rename from tests/unit/states/pagerduty_test.py rename to tests/unit/states/test_pagerduty.py diff --git a/tests/unit/states/pecl_test.py b/tests/unit/states/test_pecl.py similarity index 100% rename from tests/unit/states/pecl_test.py rename to tests/unit/states/test_pecl.py diff --git a/tests/unit/states/pip_test.py b/tests/unit/states/test_pip.py similarity index 100% rename from tests/unit/states/pip_test.py rename to tests/unit/states/test_pip.py diff --git a/tests/unit/states/pkgng_test.py b/tests/unit/states/test_pkgng.py similarity index 100% rename from tests/unit/states/pkgng_test.py rename to tests/unit/states/test_pkgng.py diff --git a/tests/unit/states/portage_config_test.py b/tests/unit/states/test_portage_config.py similarity index 100% rename from tests/unit/states/portage_config_test.py rename to tests/unit/states/test_portage_config.py diff --git a/tests/unit/states/ports_test.py b/tests/unit/states/test_ports.py similarity index 100% rename from tests/unit/states/ports_test.py rename to tests/unit/states/test_ports.py diff --git a/tests/unit/states/postgres_test.py b/tests/unit/states/test_postgres.py similarity index 100% rename from tests/unit/states/postgres_test.py rename to tests/unit/states/test_postgres.py diff --git a/tests/unit/states/postgres_cluster_test.py b/tests/unit/states/test_postgres_cluster.py similarity index 100% rename from tests/unit/states/postgres_cluster_test.py rename to tests/unit/states/test_postgres_cluster.py diff --git a/tests/unit/states/postgres_database_test.py b/tests/unit/states/test_postgres_database.py similarity index 100% rename from tests/unit/states/postgres_database_test.py rename to tests/unit/states/test_postgres_database.py diff --git a/tests/unit/states/postgres_extension_test.py b/tests/unit/states/test_postgres_extension.py similarity index 100% rename from tests/unit/states/postgres_extension_test.py rename to tests/unit/states/test_postgres_extension.py diff --git a/tests/unit/states/postgres_group_test.py b/tests/unit/states/test_postgres_group.py similarity index 100% rename from tests/unit/states/postgres_group_test.py rename to tests/unit/states/test_postgres_group.py diff --git a/tests/unit/states/postgres_initdb_test.py b/tests/unit/states/test_postgres_initdb.py similarity index 100% rename from tests/unit/states/postgres_initdb_test.py rename to tests/unit/states/test_postgres_initdb.py diff --git a/tests/unit/states/postgres_language_test.py b/tests/unit/states/test_postgres_language.py similarity index 100% rename from tests/unit/states/postgres_language_test.py rename to tests/unit/states/test_postgres_language.py diff --git a/tests/unit/states/postgres_privileges_test.py b/tests/unit/states/test_postgres_privileges.py similarity index 100% rename from tests/unit/states/postgres_privileges_test.py rename to tests/unit/states/test_postgres_privileges.py diff --git a/tests/unit/states/postgres_schema_test.py b/tests/unit/states/test_postgres_schema.py similarity index 100% rename from tests/unit/states/postgres_schema_test.py rename to tests/unit/states/test_postgres_schema.py diff --git a/tests/unit/states/postgres_user_test.py b/tests/unit/states/test_postgres_user.py similarity index 100% rename from tests/unit/states/postgres_user_test.py rename to tests/unit/states/test_postgres_user.py diff --git a/tests/unit/states/powerpath_test.py b/tests/unit/states/test_powerpath.py similarity index 100% rename from tests/unit/states/powerpath_test.py rename to tests/unit/states/test_powerpath.py diff --git a/tests/unit/states/process_test.py b/tests/unit/states/test_process.py similarity index 100% rename from tests/unit/states/process_test.py rename to tests/unit/states/test_process.py diff --git a/tests/unit/states/proxy_test.py b/tests/unit/states/test_proxy.py similarity index 100% rename from tests/unit/states/proxy_test.py rename to tests/unit/states/test_proxy.py diff --git a/tests/unit/states/pyenv_test.py b/tests/unit/states/test_pyenv.py similarity index 100% rename from tests/unit/states/pyenv_test.py rename to tests/unit/states/test_pyenv.py diff --git a/tests/unit/states/pyrax_queues_test.py b/tests/unit/states/test_pyrax_queues.py similarity index 100% rename from tests/unit/states/pyrax_queues_test.py rename to tests/unit/states/test_pyrax_queues.py diff --git a/tests/unit/states/quota_test.py b/tests/unit/states/test_quota.py similarity index 100% rename from tests/unit/states/quota_test.py rename to tests/unit/states/test_quota.py diff --git a/tests/unit/states/rabbitmq_cluster_test.py b/tests/unit/states/test_rabbitmq_cluster.py similarity index 100% rename from tests/unit/states/rabbitmq_cluster_test.py rename to tests/unit/states/test_rabbitmq_cluster.py diff --git a/tests/unit/states/rabbitmq_plugin_test.py b/tests/unit/states/test_rabbitmq_plugin.py similarity index 100% rename from tests/unit/states/rabbitmq_plugin_test.py rename to tests/unit/states/test_rabbitmq_plugin.py diff --git a/tests/unit/states/rabbitmq_policy_test.py b/tests/unit/states/test_rabbitmq_policy.py similarity index 100% rename from tests/unit/states/rabbitmq_policy_test.py rename to tests/unit/states/test_rabbitmq_policy.py diff --git a/tests/unit/states/rabbitmq_vhost_test.py b/tests/unit/states/test_rabbitmq_vhost.py similarity index 100% rename from tests/unit/states/rabbitmq_vhost_test.py rename to tests/unit/states/test_rabbitmq_vhost.py diff --git a/tests/unit/states/rbenv_test.py b/tests/unit/states/test_rbenv.py similarity index 100% rename from tests/unit/states/rbenv_test.py rename to tests/unit/states/test_rbenv.py diff --git a/tests/unit/states/rdp_test.py b/tests/unit/states/test_rdp.py similarity index 100% rename from tests/unit/states/rdp_test.py rename to tests/unit/states/test_rdp.py diff --git a/tests/unit/states/redismod_test.py b/tests/unit/states/test_redismod.py similarity index 100% rename from tests/unit/states/redismod_test.py rename to tests/unit/states/test_redismod.py diff --git a/tests/unit/states/reg_test.py b/tests/unit/states/test_reg.py similarity index 100% rename from tests/unit/states/reg_test.py rename to tests/unit/states/test_reg.py diff --git a/tests/unit/states/rvm_test.py b/tests/unit/states/test_rvm.py similarity index 100% rename from tests/unit/states/rvm_test.py rename to tests/unit/states/test_rvm.py diff --git a/tests/unit/states/saltmod_test.py b/tests/unit/states/test_saltmod.py similarity index 100% rename from tests/unit/states/saltmod_test.py rename to tests/unit/states/test_saltmod.py diff --git a/tests/unit/states/schedule_test.py b/tests/unit/states/test_schedule.py similarity index 100% rename from tests/unit/states/schedule_test.py rename to tests/unit/states/test_schedule.py diff --git a/tests/unit/states/selinux_test.py b/tests/unit/states/test_selinux.py similarity index 100% rename from tests/unit/states/selinux_test.py rename to tests/unit/states/test_selinux.py diff --git a/tests/unit/states/serverdensity_device_test.py b/tests/unit/states/test_serverdensity_device.py similarity index 100% rename from tests/unit/states/serverdensity_device_test.py rename to tests/unit/states/test_serverdensity_device.py diff --git a/tests/unit/states/service_test.py b/tests/unit/states/test_service.py similarity index 100% rename from tests/unit/states/service_test.py rename to tests/unit/states/test_service.py diff --git a/tests/unit/states/slack_test.py b/tests/unit/states/test_slack.py similarity index 100% rename from tests/unit/states/slack_test.py rename to tests/unit/states/test_slack.py diff --git a/tests/unit/states/smtp_test.py b/tests/unit/states/test_smtp.py similarity index 100% rename from tests/unit/states/smtp_test.py rename to tests/unit/states/test_smtp.py diff --git a/tests/unit/states/splunk_search_test.py b/tests/unit/states/test_splunk_search.py similarity index 100% rename from tests/unit/states/splunk_search_test.py rename to tests/unit/states/test_splunk_search.py diff --git a/tests/unit/states/ssh_auth_test.py b/tests/unit/states/test_ssh_auth.py similarity index 100% rename from tests/unit/states/ssh_auth_test.py rename to tests/unit/states/test_ssh_auth.py diff --git a/tests/unit/states/ssh_known_hosts_test.py b/tests/unit/states/test_ssh_known_hosts.py similarity index 100% rename from tests/unit/states/ssh_known_hosts_test.py rename to tests/unit/states/test_ssh_known_hosts.py diff --git a/tests/unit/states/status_test.py b/tests/unit/states/test_status.py similarity index 100% rename from tests/unit/states/status_test.py rename to tests/unit/states/test_status.py diff --git a/tests/unit/states/supervisord_test.py b/tests/unit/states/test_supervisord.py similarity index 100% rename from tests/unit/states/supervisord_test.py rename to tests/unit/states/test_supervisord.py diff --git a/tests/unit/states/svn_test.py b/tests/unit/states/test_svn.py similarity index 100% rename from tests/unit/states/svn_test.py rename to tests/unit/states/test_svn.py diff --git a/tests/unit/states/sysctl_test.py b/tests/unit/states/test_sysctl.py similarity index 100% rename from tests/unit/states/sysctl_test.py rename to tests/unit/states/test_sysctl.py diff --git a/tests/unit/states/syslog_ng_test.py b/tests/unit/states/test_syslog_ng.py similarity index 100% rename from tests/unit/states/syslog_ng_test.py rename to tests/unit/states/test_syslog_ng.py diff --git a/tests/unit/states/sysrc_test.py b/tests/unit/states/test_sysrc.py similarity index 100% rename from tests/unit/states/sysrc_test.py rename to tests/unit/states/test_sysrc.py diff --git a/tests/unit/states/timezone_test.py b/tests/unit/states/test_timezone.py similarity index 100% rename from tests/unit/states/timezone_test.py rename to tests/unit/states/test_timezone.py diff --git a/tests/unit/states/tomcat_test.py b/tests/unit/states/test_tomcat.py similarity index 100% rename from tests/unit/states/tomcat_test.py rename to tests/unit/states/test_tomcat.py diff --git a/tests/unit/states/user_test.py b/tests/unit/states/test_user.py similarity index 100% rename from tests/unit/states/user_test.py rename to tests/unit/states/test_user.py diff --git a/tests/unit/states/vbox_guest_test.py b/tests/unit/states/test_vbox_guest.py similarity index 100% rename from tests/unit/states/vbox_guest_test.py rename to tests/unit/states/test_vbox_guest.py diff --git a/tests/unit/states/virtualenv_mod_test.py b/tests/unit/states/test_virtualenv_mod.py similarity index 100% rename from tests/unit/states/virtualenv_mod_test.py rename to tests/unit/states/test_virtualenv_mod.py diff --git a/tests/unit/states/win_certutil_test.py b/tests/unit/states/test_win_certutil.py similarity index 100% rename from tests/unit/states/win_certutil_test.py rename to tests/unit/states/test_win_certutil.py diff --git a/tests/unit/states/win_dism_test.py b/tests/unit/states/test_win_dism.py similarity index 100% rename from tests/unit/states/win_dism_test.py rename to tests/unit/states/test_win_dism.py diff --git a/tests/unit/states/win_dns_client_test.py b/tests/unit/states/test_win_dns_client.py similarity index 100% rename from tests/unit/states/win_dns_client_test.py rename to tests/unit/states/test_win_dns_client.py diff --git a/tests/unit/states/win_firewall_test.py b/tests/unit/states/test_win_firewall.py similarity index 100% rename from tests/unit/states/win_firewall_test.py rename to tests/unit/states/test_win_firewall.py diff --git a/tests/unit/states/win_license_test.py b/tests/unit/states/test_win_license.py similarity index 100% rename from tests/unit/states/win_license_test.py rename to tests/unit/states/test_win_license.py diff --git a/tests/unit/states/win_network_test.py b/tests/unit/states/test_win_network.py similarity index 100% rename from tests/unit/states/win_network_test.py rename to tests/unit/states/test_win_network.py diff --git a/tests/unit/states/win_path_test.py b/tests/unit/states/test_win_path.py similarity index 100% rename from tests/unit/states/win_path_test.py rename to tests/unit/states/test_win_path.py diff --git a/tests/unit/states/win_pki_test.py b/tests/unit/states/test_win_pki.py similarity index 100% rename from tests/unit/states/win_pki_test.py rename to tests/unit/states/test_win_pki.py diff --git a/tests/unit/states/win_powercfg_test.py b/tests/unit/states/test_win_powercfg.py similarity index 100% rename from tests/unit/states/win_powercfg_test.py rename to tests/unit/states/test_win_powercfg.py diff --git a/tests/unit/states/win_servermanager_test.py b/tests/unit/states/test_win_servermanager.py similarity index 100% rename from tests/unit/states/win_servermanager_test.py rename to tests/unit/states/test_win_servermanager.py diff --git a/tests/unit/states/win_snmp_test.py b/tests/unit/states/test_win_snmp.py similarity index 100% rename from tests/unit/states/win_snmp_test.py rename to tests/unit/states/test_win_snmp.py diff --git a/tests/unit/states/win_system_test.py b/tests/unit/states/test_win_system.py similarity index 100% rename from tests/unit/states/win_system_test.py rename to tests/unit/states/test_win_system.py diff --git a/tests/unit/states/win_update_test.py b/tests/unit/states/test_win_update.py similarity index 100% rename from tests/unit/states/win_update_test.py rename to tests/unit/states/test_win_update.py diff --git a/tests/unit/states/winrepo_test.py b/tests/unit/states/test_winrepo.py similarity index 100% rename from tests/unit/states/winrepo_test.py rename to tests/unit/states/test_winrepo.py diff --git a/tests/unit/states/xmpp_test.py b/tests/unit/states/test_xmpp.py similarity index 100% rename from tests/unit/states/xmpp_test.py rename to tests/unit/states/test_xmpp.py diff --git a/tests/unit/states/zcbuildout_test.py b/tests/unit/states/test_zcbuildout.py similarity index 100% rename from tests/unit/states/zcbuildout_test.py rename to tests/unit/states/test_zcbuildout.py diff --git a/tests/unit/states/zk_concurrency_test.py b/tests/unit/states/test_zk_concurrency.py similarity index 100% rename from tests/unit/states/zk_concurrency_test.py rename to tests/unit/states/test_zk_concurrency.py diff --git a/tests/unit/templates/jinja_test.py b/tests/unit/templates/test_jinja.py similarity index 100% rename from tests/unit/templates/jinja_test.py rename to tests/unit/templates/test_jinja.py diff --git a/tests/unit/auth_test.py b/tests/unit/test_auth.py similarity index 100% rename from tests/unit/auth_test.py rename to tests/unit/test_auth.py diff --git a/tests/unit/client_test.py b/tests/unit/test_client.py similarity index 100% rename from tests/unit/client_test.py rename to tests/unit/test_client.py diff --git a/tests/unit/conf_test.py b/tests/unit/test_conf.py similarity index 100% rename from tests/unit/conf_test.py rename to tests/unit/test_conf.py diff --git a/tests/unit/context_test.py b/tests/unit/test_context.py similarity index 100% rename from tests/unit/context_test.py rename to tests/unit/test_context.py diff --git a/tests/unit/crypt_test.py b/tests/unit/test_crypt.py similarity index 100% rename from tests/unit/crypt_test.py rename to tests/unit/test_crypt.py diff --git a/tests/unit/daemons_test.py b/tests/unit/test_daemons.py similarity index 100% rename from tests/unit/daemons_test.py rename to tests/unit/test_daemons.py diff --git a/tests/unit/doc_test.py b/tests/unit/test_doc.py similarity index 100% rename from tests/unit/doc_test.py rename to tests/unit/test_doc.py diff --git a/tests/unit/files_test.py b/tests/unit/test_files.py similarity index 100% rename from tests/unit/files_test.py rename to tests/unit/test_files.py diff --git a/tests/unit/log_test.py b/tests/unit/test_log.py similarity index 100% rename from tests/unit/log_test.py rename to tests/unit/test_log.py diff --git a/tests/unit/map_conf_test.py b/tests/unit/test_map_conf.py similarity index 100% rename from tests/unit/map_conf_test.py rename to tests/unit/test_map_conf.py diff --git a/tests/unit/minion_test.py b/tests/unit/test_minion.py similarity index 100% rename from tests/unit/minion_test.py rename to tests/unit/test_minion.py diff --git a/tests/unit/payload_test.py b/tests/unit/test_payload.py similarity index 100% rename from tests/unit/payload_test.py rename to tests/unit/test_payload.py diff --git a/tests/unit/pillar_test.py b/tests/unit/test_pillar.py similarity index 100% rename from tests/unit/pillar_test.py rename to tests/unit/test_pillar.py diff --git a/tests/unit/pydsl_test.py b/tests/unit/test_pydsl.py similarity index 100% rename from tests/unit/pydsl_test.py rename to tests/unit/test_pydsl.py diff --git a/tests/unit/pyobjects_test.py b/tests/unit/test_pyobjects.py similarity index 100% rename from tests/unit/pyobjects_test.py rename to tests/unit/test_pyobjects.py diff --git a/tests/unit/simple_test.py b/tests/unit/test_simple.py similarity index 100% rename from tests/unit/simple_test.py rename to tests/unit/test_simple.py diff --git a/tests/unit/spm_test.py b/tests/unit/test_spm.py similarity index 100% rename from tests/unit/spm_test.py rename to tests/unit/test_spm.py diff --git a/tests/unit/state_test.py b/tests/unit/test_state.py similarity index 100% rename from tests/unit/state_test.py rename to tests/unit/test_state.py diff --git a/tests/unit/stateconf_test.py b/tests/unit/test_stateconf.py similarity index 100% rename from tests/unit/stateconf_test.py rename to tests/unit/test_stateconf.py diff --git a/tests/unit/statemod_test.py b/tests/unit/test_statemod.py similarity index 100% rename from tests/unit/statemod_test.py rename to tests/unit/test_statemod.py diff --git a/tests/unit/target_test.py b/tests/unit/test_target.py similarity index 100% rename from tests/unit/target_test.py rename to tests/unit/test_target.py diff --git a/tests/unit/template_test.py b/tests/unit/test_template.py similarity index 100% rename from tests/unit/template_test.py rename to tests/unit/test_template.py diff --git a/tests/unit/version_test.py b/tests/unit/test_version.py similarity index 100% rename from tests/unit/version_test.py rename to tests/unit/test_version.py diff --git a/tests/unit/transport/ipc_test.py b/tests/unit/transport/test_ipc.py similarity index 100% rename from tests/unit/transport/ipc_test.py rename to tests/unit/transport/test_ipc.py diff --git a/tests/unit/transport/pub_test.py b/tests/unit/transport/test_pub.py similarity index 100% rename from tests/unit/transport/pub_test.py rename to tests/unit/transport/test_pub.py diff --git a/tests/unit/transport/req_test.py b/tests/unit/transport/test_req.py similarity index 100% rename from tests/unit/transport/req_test.py rename to tests/unit/transport/test_req.py diff --git a/tests/unit/transport/tcp_test.py b/tests/unit/transport/test_tcp.py similarity index 100% rename from tests/unit/transport/tcp_test.py rename to tests/unit/transport/test_tcp.py diff --git a/tests/unit/transport/zeromq_test.py b/tests/unit/transport/test_zeromq.py similarity index 100% rename from tests/unit/transport/zeromq_test.py rename to tests/unit/transport/test_zeromq.py diff --git a/tests/unit/utils/aggregation_test.py b/tests/unit/utils/test_aggregation.py similarity index 100% rename from tests/unit/utils/aggregation_test.py rename to tests/unit/utils/test_aggregation.py diff --git a/tests/unit/utils/args_test.py b/tests/unit/utils/test_args.py similarity index 100% rename from tests/unit/utils/args_test.py rename to tests/unit/utils/test_args.py diff --git a/tests/unit/utils/async_test.py b/tests/unit/utils/test_async.py similarity index 100% rename from tests/unit/utils/async_test.py rename to tests/unit/utils/test_async.py diff --git a/tests/unit/utils/boto_test.py b/tests/unit/utils/test_boto.py similarity index 100% rename from tests/unit/utils/boto_test.py rename to tests/unit/utils/test_boto.py diff --git a/tests/unit/utils/cache_test.py b/tests/unit/utils/test_cache.py similarity index 100% rename from tests/unit/utils/cache_test.py rename to tests/unit/utils/test_cache.py diff --git a/tests/unit/utils/cloud_test.py b/tests/unit/utils/test_cloud.py similarity index 100% rename from tests/unit/utils/cloud_test.py rename to tests/unit/utils/test_cloud.py diff --git a/tests/unit/utils/configcomparer_test.py b/tests/unit/utils/test_configcomparer.py similarity index 100% rename from tests/unit/utils/configcomparer_test.py rename to tests/unit/utils/test_configcomparer.py diff --git a/tests/unit/utils/context_test.py b/tests/unit/utils/test_context.py similarity index 100% rename from tests/unit/utils/context_test.py rename to tests/unit/utils/test_context.py diff --git a/tests/unit/utils/decorators_test.py b/tests/unit/utils/test_decorators.py similarity index 100% rename from tests/unit/utils/decorators_test.py rename to tests/unit/utils/test_decorators.py diff --git a/tests/unit/utils/dictupdate_test.py b/tests/unit/utils/test_dictupdate.py similarity index 100% rename from tests/unit/utils/dictupdate_test.py rename to tests/unit/utils/test_dictupdate.py diff --git a/tests/unit/utils/disk_cache_test.py b/tests/unit/utils/test_disk_cache.py similarity index 100% rename from tests/unit/utils/disk_cache_test.py rename to tests/unit/utils/test_disk_cache.py diff --git a/tests/unit/utils/etcd_util_test.py b/tests/unit/utils/test_etcd_util.py similarity index 100% rename from tests/unit/utils/etcd_util_test.py rename to tests/unit/utils/test_etcd_util.py diff --git a/tests/unit/utils/event_test.py b/tests/unit/utils/test_event.py similarity index 100% rename from tests/unit/utils/event_test.py rename to tests/unit/utils/test_event.py diff --git a/tests/unit/utils/extend_test.py b/tests/unit/utils/test_extend.py similarity index 100% rename from tests/unit/utils/extend_test.py rename to tests/unit/utils/test_extend.py diff --git a/tests/unit/utils/filebuffer_test.py b/tests/unit/utils/test_filebuffer.py similarity index 100% rename from tests/unit/utils/filebuffer_test.py rename to tests/unit/utils/test_filebuffer.py diff --git a/tests/unit/utils/find_test.py b/tests/unit/utils/test_find.py similarity index 100% rename from tests/unit/utils/find_test.py rename to tests/unit/utils/test_find.py diff --git a/tests/unit/utils/format_call_test.py b/tests/unit/utils/test_format_call.py similarity index 100% rename from tests/unit/utils/format_call_test.py rename to tests/unit/utils/test_format_call.py diff --git a/tests/unit/utils/gitfs_test.py b/tests/unit/utils/test_gitfs.py similarity index 100% rename from tests/unit/utils/gitfs_test.py rename to tests/unit/utils/test_gitfs.py diff --git a/tests/unit/utils/http_test.py b/tests/unit/utils/test_http.py similarity index 100% rename from tests/unit/utils/http_test.py rename to tests/unit/utils/test_http.py diff --git a/tests/unit/utils/immutabletypes_test.py b/tests/unit/utils/test_immutabletypes.py similarity index 100% rename from tests/unit/utils/immutabletypes_test.py rename to tests/unit/utils/test_immutabletypes.py diff --git a/tests/unit/utils/kwarg_regex_test.py b/tests/unit/utils/test_kwarg_regex.py similarity index 100% rename from tests/unit/utils/kwarg_regex_test.py rename to tests/unit/utils/test_kwarg_regex.py diff --git a/tests/unit/utils/locales_test.py b/tests/unit/utils/test_locales.py similarity index 100% rename from tests/unit/utils/locales_test.py rename to tests/unit/utils/test_locales.py diff --git a/tests/unit/utils/mac_utils_test.py b/tests/unit/utils/test_mac_utils.py similarity index 100% rename from tests/unit/utils/mac_utils_test.py rename to tests/unit/utils/test_mac_utils.py diff --git a/tests/unit/utils/minions_test.py b/tests/unit/utils/test_minions.py similarity index 100% rename from tests/unit/utils/minions_test.py rename to tests/unit/utils/test_minions.py diff --git a/tests/unit/utils/network_test.py b/tests/unit/utils/test_network.py similarity index 100% rename from tests/unit/utils/network_test.py rename to tests/unit/utils/test_network.py diff --git a/tests/unit/utils/parsers_test.py b/tests/unit/utils/test_parsers.py similarity index 100% rename from tests/unit/utils/parsers_test.py rename to tests/unit/utils/test_parsers.py diff --git a/tests/unit/utils/path_join_test.py b/tests/unit/utils/test_path_join.py similarity index 100% rename from tests/unit/utils/path_join_test.py rename to tests/unit/utils/test_path_join.py diff --git a/tests/unit/utils/process_test.py b/tests/unit/utils/test_process.py similarity index 100% rename from tests/unit/utils/process_test.py rename to tests/unit/utils/test_process.py diff --git a/tests/unit/utils/rsax931_test.py b/tests/unit/utils/test_rsax931.py similarity index 100% rename from tests/unit/utils/rsax931_test.py rename to tests/unit/utils/test_rsax931.py diff --git a/tests/unit/utils/runtime_whitespace_regex_test.py b/tests/unit/utils/test_runtime_whitespace_regex.py similarity index 100% rename from tests/unit/utils/runtime_whitespace_regex_test.py rename to tests/unit/utils/test_runtime_whitespace_regex.py diff --git a/tests/unit/utils/safe_walk_test.py b/tests/unit/utils/test_safe_walk.py similarity index 100% rename from tests/unit/utils/safe_walk_test.py rename to tests/unit/utils/test_safe_walk.py diff --git a/tests/unit/utils/sanitizers_test.py b/tests/unit/utils/test_sanitizers.py similarity index 100% rename from tests/unit/utils/sanitizers_test.py rename to tests/unit/utils/test_sanitizers.py diff --git a/tests/unit/utils/schedule_test.py b/tests/unit/utils/test_schedule.py similarity index 100% rename from tests/unit/utils/schedule_test.py rename to tests/unit/utils/test_schedule.py diff --git a/tests/unit/utils/schema_test.py b/tests/unit/utils/test_schema.py similarity index 100% rename from tests/unit/utils/schema_test.py rename to tests/unit/utils/test_schema.py diff --git a/tests/unit/utils/systemd_test.py b/tests/unit/utils/test_systemd.py similarity index 100% rename from tests/unit/utils/systemd_test.py rename to tests/unit/utils/test_systemd.py diff --git a/tests/unit/utils/url_test.py b/tests/unit/utils/test_url.py similarity index 100% rename from tests/unit/utils/url_test.py rename to tests/unit/utils/test_url.py diff --git a/tests/unit/utils/utils_test.py b/tests/unit/utils/test_utils.py similarity index 100% rename from tests/unit/utils/utils_test.py rename to tests/unit/utils/test_utils.py diff --git a/tests/unit/utils/validate_net_test.py b/tests/unit/utils/test_validate_net.py similarity index 100% rename from tests/unit/utils/validate_net_test.py rename to tests/unit/utils/test_validate_net.py diff --git a/tests/unit/utils/verify_test.py b/tests/unit/utils/test_verify.py similarity index 100% rename from tests/unit/utils/verify_test.py rename to tests/unit/utils/test_verify.py diff --git a/tests/unit/utils/vt_test.py b/tests/unit/utils/test_vt.py similarity index 100% rename from tests/unit/utils/vt_test.py rename to tests/unit/utils/test_vt.py diff --git a/tests/unit/utils/warnings_test.py b/tests/unit/utils/test_warnings.py similarity index 100% rename from tests/unit/utils/warnings_test.py rename to tests/unit/utils/test_warnings.py diff --git a/tests/unit/utils/which_test.py b/tests/unit/utils/test_which.py similarity index 100% rename from tests/unit/utils/which_test.py rename to tests/unit/utils/test_which.py diff --git a/tests/unit/utils/yamlloader_test.py b/tests/unit/utils/test_yamlloader.py similarity index 100% rename from tests/unit/utils/yamlloader_test.py rename to tests/unit/utils/test_yamlloader.py diff --git a/tests/unit/utils/vmware_test/cluster_test.py b/tests/unit/utils/vmware_test/test_cluster.py similarity index 100% rename from tests/unit/utils/vmware_test/cluster_test.py rename to tests/unit/utils/vmware_test/test_cluster.py diff --git a/tests/unit/utils/vmware_test/common_test.py b/tests/unit/utils/vmware_test/test_common.py similarity index 100% rename from tests/unit/utils/vmware_test/common_test.py rename to tests/unit/utils/vmware_test/test_common.py diff --git a/tests/unit/utils/vmware_test/connection_test.py b/tests/unit/utils/vmware_test/test_connection.py similarity index 100% rename from tests/unit/utils/vmware_test/connection_test.py rename to tests/unit/utils/vmware_test/test_connection.py diff --git a/tests/unit/utils/vmware_test/datacenter_test.py b/tests/unit/utils/vmware_test/test_datacenter.py similarity index 100% rename from tests/unit/utils/vmware_test/datacenter_test.py rename to tests/unit/utils/vmware_test/test_datacenter.py diff --git a/tests/unit/utils/vmware_test/host_test.py b/tests/unit/utils/vmware_test/test_host.py similarity index 100% rename from tests/unit/utils/vmware_test/host_test.py rename to tests/unit/utils/vmware_test/test_host.py From 5d5a3ee01e0055456da1652954839b836195f05b Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 02:35:42 +0000 Subject: [PATCH 127/370] All tests now follow the `test_*.py` pattern. --- tests/runtests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/runtests.py b/tests/runtests.py index b90e8e28f0..da8d51cd1d 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -403,7 +403,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): Run an integration test suite ''' full_path = os.path.join(TEST_DIR, path) - return self.run_suite(full_path, display_name) + return self.run_suite(full_path, display_name, suffix='test_*.py') def start_daemons_only(self): if not salt.utils.is_windows(): @@ -566,7 +566,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): for name in self.options.name: if name.startswith('unit.'): continue - results = self.run_suite('', name, load_from_name=True) + results = self.run_suite('', name, suffix='test_*.py', load_from_name=True) status.append(results) for suite in TEST_SUITES: if suite != 'unit' and getattr(self.options, suite): @@ -595,7 +595,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): self.set_filehandle_limits('unit') results = self.run_suite( - os.path.join(TEST_DIR, 'unit'), 'Unit', '*_test.py' + os.path.join(TEST_DIR, 'unit'), 'Unit', suffix='test_*.py' ) status.append(results) # We executed ALL unittests, we can skip running unittests by name @@ -604,7 +604,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): for name in named_unit_test: results = self.run_suite( - os.path.join(TEST_DIR, 'unit'), name, load_from_name=True + os.path.join(TEST_DIR, 'unit'), name, suffix='test_*.py', load_from_name=True ) status.append(results) return status From bc728001a780bb2579c358160534ecf6f3eeb394 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 30 Jun 2016 02:34:28 +0100 Subject: [PATCH 128/370] Start laying out `py.test` `conftest.py`. Add `destructive_test` marker support. --- tests/conftest.py | 492 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 492 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000000..82597bbefa --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,492 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + + tests.conftest + ~~~~~~~~~~~~~~ + + Prepare py.test for our test suite +''' + +# Import python libs +from __future__ import absolute_import +import os +import stat +import socket +import logging + +# Import 3rd-party libs +import pytest +import salt.ext.six as six + +# Import salt libs +import salt.utils + +# Define the pytest plugins we rely on +pytest_plugins = ['salt', 'pytest_catchlog', 'tempdir', 'helpers_namespace'] # pylint: disable=invalid-name + +# Import pytest-salt libs +#from pytestsalt.utils import get_unused_localhost_port + +log = logging.getLogger('salt.testsuite') + + +def pytest_tempdir_basename(): + ''' + Return the temporary directory basename for the salt test suite. + ''' + return 'salt-tests-tmp' + + +# ----- CLI Options Setup -------------------------------------------------------------------------------------------> +def pytest_addoption(parser): + ''' + register argparse-style options and ini-style config values. + ''' + test_selection_group = parser.getgroup('Tests Selection') + test_selection_group.addoption( + '--run-destructive', + action='store_true', + default=False, + help='Run destructive tests. These tests can include adding ' + 'or removing users from your system for example. ' + 'Default: False' + ) + test_selection_group.addoption( + '--run-expensive', + action='store_true', + default=False, + help='Run expensive tests. These tests usually involve costs ' + 'like for example bootstrapping a cloud VM. ' + 'Default: False' + ) +# <---- CLI Options Setup -------------------------------------------------------------------------------------------- + + +# ----- Register Markers --------------------------------------------------------------------------------------------> +def pytest_configure(config): + ''' + called after command line options have been parsed + and all plugins and initial conftest files been loaded. + ''' + config.addinivalue_line( + 'markers', + 'destructive_test: Run destructive tests. These tests can include adding ' + 'or removing users from your system for example.' + ) + config.addinivalue_line( + 'markers', + 'skip_if_not_root: Skip if the current user is not `root`.' + ) + config.addinivalue_line( + 'markers', + 'skip_if_binaries_missing(*binaries, check_all=False, message=None): Skip if ' + 'any of the passed binaries are not found in path. If \'check_all\' is ' + '\'True\', then all binaries must be found.' + ) + config.addinivalue_line( + 'markers', + 'requires_network(only_local_network=False): Skip if no networking is set up. ' + 'If \'only_local_network\' is \'True\', only the local network is checked.' + ) +# <---- Register Markers --------------------------------------------------------------------------------------------- + + +# ----- Test Setup --------------------------------------------------------------------------------------------------> +@pytest.hookimpl(tryfirst=True) +def pytest_runtest_setup(item): + ''' + Fixtures injection based on markers or test skips based on CLI arguments + ''' + destructive_tests_marker = item.get_marker('destructive_test') + if destructive_tests_marker is not None: + if item.config.getoption('--run-destructive') is False: + pytest.skip('Destructive tests are disabled') + + expensive_tests_marker = item.get_marker('expensive_test') + if expensive_tests_marker is not None: + if item.config.getoption('--run-expensive') is False: + pytest.skip('Expensive tests are disabled') + + skip_if_not_root_marker = item.get_marker('skip_if_not_root') + if skip_if_not_root_marker is not None: + if os.getuid() != 0: + pytest.skip('You must be logged in as root to run this test') + + skip_if_binaries_missing_marker = item.get_marker('skip_if_binaries_missing') + if skip_if_binaries_missing_marker is not None: + binaries = skip_if_binaries_missing_marker.args + if len(binaries) == 1: + if isinstance(binaries[0], (list, tuple, set, frozenset)): + binaries = binaries[0] + check_all = skip_if_binaries_missing_marker.kwargs.get('check_all', False) + message = skip_if_binaries_missing_marker.kwargs.get('message', None) + if check_all: + for binary in binaries: + if salt.utils.which(binary) is None: + pytest.skip( + '{0}The "{1}" binary was not found'.format( + message and '{0}. '.format(message) or '', + binary + ) + ) + elif salt.utils.which_bin(binaries) is None: + pytest.skip( + '{0}None of the following binaries was found: {1}'.format( + message and '{0}. '.format(message) or '', + ', '.join(binaries) + ) + ) + + requires_network_marker = item.get_marker('requires_network') + if requires_network_marker is not None: + only_local_network = requires_network_marker.kwargs.get('only_local_network', False) + has_local_network = False + # First lets try if we have a local network. Inspired in verify_socket + try: + pubsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + retsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + pubsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + pubsock.bind(('', 18000)) + pubsock.close() + retsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + retsock.bind(('', 18001)) + retsock.close() + has_local_network = True + except socket.error: + # I wonder if we just have IPV6 support? + try: + pubsock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + retsock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + pubsock.setsockopt( + socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 + ) + pubsock.bind(('', 18000)) + pubsock.close() + retsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + retsock.bind(('', 18001)) + retsock.close() + has_local_network = True + except socket.error: + # Let's continue + pass + + if only_local_network is True: + if has_local_network is False: + # Since we're only supposed to check local network, and no + # local network was detected, skip the test + pytest.skip('No local network was detected') + + # We are using the google.com DNS records as numerical IPs to avoid + # DNS lookups which could greatly slow down this check + for addr in ('173.194.41.198', '173.194.41.199', '173.194.41.200', + '173.194.41.201', '173.194.41.206', '173.194.41.192', + '173.194.41.193', '173.194.41.194', '173.194.41.195', + '173.194.41.196', '173.194.41.197'): + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(0.25) + sock.connect((addr, 80)) + sock.close() + # We connected? Stop the loop + break + except socket.error: + # Let's check the next IP + continue + else: + pytest.skip('No internet network connection was detected') +# <---- Test Setup --------------------------------------------------------------------------------------------------- + + +# ----- Automatic Markers Setup -------------------------------------------------------------------------------------> +def pytest_collection_modifyitems(items): + ''' + Automatically add markers to tests based on directory layout + ''' + for item in items: + fspath = str(item.fspath) + if '/integration/' in fspath: + item.add_marker(pytest.mark.integration) + for kind in ('cli', 'client', 'cloud', 'fileserver', 'loader', 'minion', 'modules', + 'netapi', 'output', 'reactor', 'renderers', 'runners', 'sdb', 'shell', + 'ssh', 'states', 'utils', 'wheel'): + if '/{0}/'.format(kind) in fspath: + item.add_marker(getattr(pytest.mark, kind)) + break + if '/unit/' in fspath: + item.add_marker(pytest.mark.unit) + for kind in ('acl', 'beacons', 'cli', 'cloud', 'config', 'grains', 'modules', 'netapi', + 'output', 'pillar', 'renderers', 'runners', 'serializers', 'states', + 'templates', 'transport', 'utils'): + if '/{0}/'.format(kind) in fspath: + item.add_marker(getattr(pytest.mark, kind)) + break +# <---- Automatic Markers Setup -------------------------------------------------------------------------------------- + + +# ----- Pytest Helpers ----------------------------------------------------------------------------------------------> +if six.PY2: + # backport mock_open from the python 3 unittest.mock library so that we can + # mock read, readline, readlines, and file iteration properly + + file_spec = None + + def _iterate_read_data(read_data): + # Helper for mock_open: + # Retrieve lines from read_data via a generator so that separate calls to + # readline, read, and readlines are properly interleaved + data_as_list = ['{0}\n'.format(l) for l in read_data.split('\n')] + + if data_as_list[-1] == '\n': + # If the last line ended in a newline, the list comprehension will have an + # extra entry that's just a newline. Remove this. + data_as_list = data_as_list[:-1] + else: + # If there wasn't an extra newline by itself, then the file being + # emulated doesn't have a newline to end the last line remove the + # newline that our naive format() added + data_as_list[-1] = data_as_list[-1][:-1] + + for line in data_as_list: + yield line + + @pytest.helpers.mock.register + def mock_open(mock=None, read_data=''): + """ + A helper function to create a mock to replace the use of `open`. It works + for `open` called directly or used as a context manager. + + The `mock` argument is the mock object to configure. If `None` (the + default) then a `MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + + `read_data` is a string for the `read` methoddline`, and `readlines` of the + file handle to return. This is an empty string by default. + """ + _mock = pytest.importorskip('mock', minversion='2.0.0') + + def _readlines_side_effect(*args, **kwargs): + if handle.readlines.return_value is not None: + return handle.readlines.return_value + return list(_data) + + def _read_side_effect(*args, **kwargs): + if handle.read.return_value is not None: + return handle.read.return_value + return ''.join(_data) + + def _readline_side_effect(): + if handle.readline.return_value is not None: + while True: + yield handle.readline.return_value + for line in _data: + yield line + + global file_spec + if file_spec is None: + file_spec = file + + if mock is None: + mock = _mock.MagicMock(name='open', spec=open) + + handle = _mock.MagicMock(spec=file_spec) + handle.__enter__.return_value = handle + + _data = _iterate_read_data(read_data) + + handle.write.return_value = None + handle.read.return_value = None + handle.readline.return_value = None + handle.readlines.return_value = None + + handle.read.side_effect = _read_side_effect + handle.readline.side_effect = _readline_side_effect() + handle.readlines.side_effect = _readlines_side_effect + + mock.return_value = handle + return mock +else: + @pytest.helpers.mock.register + def mock_open(mock=None, read_data=''): + _mock = pytest.importorskip('mock', minversion='2.0.0') + return _mock.mock_open(mock=mock, read_data=read_data) +# <---- Pytest Helpers ----------------------------------------------------------------------------------------------- + + +# ----- Fixtures Overrides ------------------------------------------------------------------------------------------> +# ----- Generate CLI Scripts ----------------------------------------------------------------------------------------> +@pytest.fixture(scope='session') +def cli_master_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt_master' + + +@pytest.fixture(scope='session') +def cli_minion_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt_minion' + + +@pytest.fixture(scope='session') +def cli_salt_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt' + + +@pytest.fixture(scope='session') +def cli_run_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt_run' + + +@pytest.fixture(scope='session') +def cli_key_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt_key' + + +@pytest.fixture(scope='session') +def cli_call_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt_call' + + +@pytest.fixture(scope='session') +def cli_syndic_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt_syndic' + + +@pytest.fixture(scope='session') +def cli_ssh_script_name(): + ''' + Return the CLI script basename + ''' + return 'cli_salt_ssh' + + +@pytest.fixture(scope='session') +def cli_bin_dir(tempdir, + request, + python_executable_path, + cli_master_script_name, + cli_minion_script_name, + cli_salt_script_name, + cli_call_script_name, + cli_key_script_name, + cli_run_script_name, + cli_ssh_script_name): + ''' + Return the path to the CLI script directory to use + ''' + tmp_cli_scripts_dir = tempdir.join('cli-scrips-bin') + tmp_cli_scripts_dir.ensure(dir=True) + cli_bin_dir_path = tmp_cli_scripts_dir.strpath + + # Now that we have the CLI directory created, lets generate the required CLI scripts to run salt's test suite + script_templates = { + 'salt': [ + 'from salt.scripts import salt_main\n', + 'if __name__ == \'__main__\':\n' + ' salt_main()' + ], + 'salt-api': [ + 'import salt.cli\n', + 'def main():\n', + ' sapi = salt.cli.SaltAPI()', + ' sapi.run()\n', + 'if __name__ == \'__main__\':', + ' main()' + ], + 'common': [ + 'from salt.scripts import salt_{0}\n', + 'if __name__ == \'__main__\':\n', + ' salt_{0}()' + ] + } + + for script_name in (cli_master_script_name, + cli_minion_script_name, + cli_call_script_name, + cli_key_script_name, + cli_run_script_name, + cli_salt_script_name, + cli_ssh_script_name): + original_script_name = script_name.split('cli_')[-1].replace('_', '-') + script_path = os.path.join(cli_bin_dir_path, script_name) + + if not os.path.isfile(script_path): + log.info('Generating {0}'.format(script_path)) + + with salt.utils.fopen(script_path, 'w') as sfh: + script_template = script_templates.get(original_script_name, None) + if script_template is None: + script_template = script_templates.get('common', None) + if script_template is None: + raise RuntimeError( + 'Salt\'s test suite does not know how to handle the "{0}" script'.format( + original_script_name + ) + ) + sfh.write( + '#!{0}\n\n'.format(python_executable_path) + + 'import sys\n' + + 'CODE_DIR="{0}"\n'.format(request.config.startdir.realpath().strpath) + + 'if CODE_DIR not in sys.path:\n' + + ' sys.path.insert(0, CODE_DIR)\n\n' + + '\n'.join(script_template).format(original_script_name.replace('salt-', '')) + ) + fst = os.stat(script_path) + os.chmod(script_path, fst.st_mode | stat.S_IEXEC) + + # Return the CLI bin dir value + return cli_bin_dir_path +# <---- Generate CLI Scripts ----------------------------------------------------------------------------------------- + + +# ----- Salt Configuration ------------------------------------------------------------------------------------------> +@pytest.fixture(scope='session') +def session_integration_files_dir(request): + ''' + Fixture which returns the salt integration files directory path. + Creates the directory if it does not yet exist. + ''' + return request.config.startdir.join('tests').join('integration').join('files') + + +@pytest.fixture(scope='session') +def session_state_tree_root_dir(session_integration_files_dir): + ''' + Fixture which returns the salt state tree root directory path. + Creates the directory if it does not yet exist. + ''' + return session_integration_files_dir.join('file') + + +@pytest.fixture(scope='session') +def session_pillar_tree_root_dir(session_integration_files_dir): + ''' + Fixture which returns the salt pillar tree root directory path. + Creates the directory if it does not yet exist. + ''' + return session_integration_files_dir.join('pillar') +# <---- Salt Configuration ------------------------------------------------------------------------------------------- + + +# <---- Fixtures Overrides ------------------------------------------------------------------------------------------- +# ----- Custom Fixtures Definitions ---------------------------------------------------------------------------------> +# <---- Custom Fixtures Definitions ---------------------------------------------------------------------------------- From 5576f6ed333b80aa35c1e6ee703fc05f80d68f9a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 13:17:33 +0000 Subject: [PATCH 129/370] Gate it! --- tests/unit/modules/test_boto_vpc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/modules/test_boto_vpc.py b/tests/unit/modules/test_boto_vpc.py index db9ac53720..093909cccd 100644 --- a/tests/unit/modules/test_boto_vpc.py +++ b/tests/unit/modules/test_boto_vpc.py @@ -24,11 +24,12 @@ import salt.loader from salt.modules import boto_vpc from salt.exceptions import SaltInvocationError, CommandExecutionError from salt.modules.boto_vpc import _maybe_set_name_tag, _maybe_set_tags -from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # Import 3rd-party libs import salt.ext.six as six -# pylint: disable=import-error,no-name-in-module,unused-import +# pylint: disable=import-error +from salt.ext.six.moves import range # pylint: disable=redefined-builtin +# pylint: disable=no-name-in-module,unused-import try: import boto import boto3 @@ -80,7 +81,8 @@ mods = salt.loader.minion_mods(opts) boto_vpc.__utils__ = utils boto_vpc.__salt__ = {} -boto_vpc.__init__(opts) +if HAS_BOTO: + boto_vpc.__init__(opts) def _has_required_boto(): From 1e2753c8755f3b19a23feb824b307efce6bcb8da Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 13:21:58 +0000 Subject: [PATCH 130/370] Fix imports after renames --- tests/unit/netapi/rest_tornado/test_utils.py | 2 +- tests/unit/states/test_boto_apigateway.py | 2 +- tests/unit/states/test_boto_cloudtrail.py | 2 +- tests/unit/states/test_boto_cloudwatch_event.py | 15 ++++++++------- tests/unit/states/test_boto_cognitoidentity.py | 2 +- .../unit/states/test_boto_elasticsearch_domain.py | 2 +- tests/unit/states/test_boto_iot.py | 2 +- tests/unit/states/test_boto_lambda.py | 2 +- tests/unit/states/test_boto_s3_bucket.py | 2 +- tests/unit/states/test_boto_vpc.py | 2 +- tests/unit/states/test_zcbuildout.py | 2 +- tests/unit/transport/test_tcp.py | 4 ++-- tests/unit/transport/test_zeromq.py | 4 ++-- 13 files changed, 22 insertions(+), 21 deletions(-) diff --git a/tests/unit/netapi/rest_tornado/test_utils.py b/tests/unit/netapi/rest_tornado/test_utils.py index e66ad89c05..b3d0f476e3 100644 --- a/tests/unit/netapi/rest_tornado/test_utils.py +++ b/tests/unit/netapi/rest_tornado/test_utils.py @@ -33,7 +33,7 @@ except ImportError: HAS_TORNADO = False # Import utility lib from tests -from unit.utils.event_test import eventpublisher_process, event, SOCK_DIR # pylint: disable=import-error +from unit.utils.test_event import eventpublisher_process, event, SOCK_DIR # pylint: disable=import-error @skipIf(HAS_TORNADO is False, 'The tornado package needs to be installed') diff --git a/tests/unit/states/test_boto_apigateway.py b/tests/unit/states/test_boto_apigateway.py index 81b35ef608..daae8a15de 100644 --- a/tests/unit/states/test_boto_apigateway.py +++ b/tests/unit/states/test_boto_apigateway.py @@ -24,7 +24,7 @@ import salt.loader import yaml # pylint: disable=import-error,no-name-in-module -from unit.modules.boto_apigateway_test import BotoApiGatewayTestCaseMixin +from unit.modules.test_boto_apigateway import BotoApiGatewayTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_cloudtrail.py b/tests/unit/states/test_boto_cloudtrail.py index 9e6dd95257..5067efcf5a 100644 --- a/tests/unit/states/test_boto_cloudtrail.py +++ b/tests/unit/states/test_boto_cloudtrail.py @@ -27,7 +27,7 @@ from salt.ext.six.moves import range # pylint: disable=import-error,redefined-b import logging # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.boto_cloudtrail_test import BotoCloudTrailTestCaseMixin +from unit.modules.test_boto_cloudtrail import BotoCloudTrailTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_cloudwatch_event.py b/tests/unit/states/test_boto_cloudwatch_event.py index 5367465b2d..028541619c 100644 --- a/tests/unit/states/test_boto_cloudwatch_event.py +++ b/tests/unit/states/test_boto_cloudwatch_event.py @@ -23,7 +23,7 @@ import logging from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # pylint: disable=import-error,no-name-in-module -from unit.modules.boto_cloudwatch_event_test import BotoCloudWatchEventTestCaseMixin +from unit.modules.test_boto_cloudwatch_event import BotoCloudWatchEventTestCaseMixin # pylint: disable=unused-import # Import 3rd-party libs @@ -50,12 +50,13 @@ error_content = { 'Message': "Test-defined error" } } -not_found_error = ClientError({ - 'Error': { - 'Code': 'ResourceNotFoundException', - 'Message': "Test-defined error" - } -}, 'msg') +if HAS_BOTO: + not_found_error = ClientError({ + 'Error': { + 'Code': 'ResourceNotFoundException', + 'Message': "Test-defined error" + } + }, 'msg') rule_name = 'test_thing_type' rule_desc = 'test_thing_type_desc' rule_sched = 'rate(20 min)' diff --git a/tests/unit/states/test_boto_cognitoidentity.py b/tests/unit/states/test_boto_cognitoidentity.py index 6854cf0d87..b464cce1cc 100644 --- a/tests/unit/states/test_boto_cognitoidentity.py +++ b/tests/unit/states/test_boto_cognitoidentity.py @@ -24,7 +24,7 @@ import logging from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # pylint: disable=import-error,no-name-in-module -from unit.modules.boto_cognitoidentity_test import BotoCognitoIdentityTestCaseMixin +from unit.modules.test_boto_cognitoidentity import BotoCognitoIdentityTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_elasticsearch_domain.py b/tests/unit/states/test_boto_elasticsearch_domain.py index bc73632135..ca5b45273a 100644 --- a/tests/unit/states/test_boto_elasticsearch_domain.py +++ b/tests/unit/states/test_boto_elasticsearch_domain.py @@ -25,7 +25,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.boto_elasticsearch_domain_test import BotoElasticsearchDomainTestCaseMixin +from unit.modules.test_boto_elasticsearch_domain import BotoElasticsearchDomainTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_iot.py b/tests/unit/states/test_boto_iot.py index d57051cf79..4d7149a206 100644 --- a/tests/unit/states/test_boto_iot.py +++ b/tests/unit/states/test_boto_iot.py @@ -25,7 +25,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.boto_iot_test import BotoIoTTestCaseMixin +from unit.modules.test_boto_iot import BotoIoTTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_lambda.py b/tests/unit/states/test_boto_lambda.py index f200ba2283..986a8ff4aa 100644 --- a/tests/unit/states/test_boto_lambda.py +++ b/tests/unit/states/test_boto_lambda.py @@ -26,7 +26,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module -from unit.modules.boto_lambda_test import BotoLambdaTestCaseMixin, TempZipFile +from unit.modules.test_boto_lambda import BotoLambdaTestCaseMixin, TempZipFile # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_s3_bucket.py b/tests/unit/states/test_boto_s3_bucket.py index 330f98ccf5..fe430cdf62 100644 --- a/tests/unit/states/test_boto_s3_bucket.py +++ b/tests/unit/states/test_boto_s3_bucket.py @@ -26,7 +26,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.boto_s3_bucket_test import BotoS3BucketTestCaseMixin +from unit.modules.test_boto_s3_bucket import BotoS3BucketTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_vpc.py b/tests/unit/states/test_boto_vpc.py index 31be861915..3c274bbb13 100644 --- a/tests/unit/states/test_boto_vpc.py +++ b/tests/unit/states/test_boto_vpc.py @@ -21,7 +21,7 @@ import salt.utils.boto from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,unused-import -from unit.modules.boto_vpc_test import BotoVpcTestCaseMixin +from unit.modules.test_boto_vpc import BotoVpcTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_zcbuildout.py b/tests/unit/states/test_zcbuildout.py index 1c41f54fbf..6fa2d8d419 100644 --- a/tests/unit/states/test_zcbuildout.py +++ b/tests/unit/states/test_zcbuildout.py @@ -16,7 +16,7 @@ import integration # Import Salt libs import salt.utils -from unit.modules.zcbuildout_test import Base, KNOWN_VIRTUALENV_BINARY_NAMES +from unit.modules.test_zcbuildout import Base, KNOWN_VIRTUALENV_BINARY_NAMES from salt.modules import zcbuildout as modbuildout from salt.states import zcbuildout as buildout from salt.modules import cmdmod as cmd diff --git a/tests/unit/transport/test_tcp.py b/tests/unit/transport/test_tcp.py index 918b1c9bbf..bece048655 100644 --- a/tests/unit/transport/test_tcp.py +++ b/tests/unit/transport/test_tcp.py @@ -26,8 +26,8 @@ ensure_in_syspath('../') import integration # Import Salt libs -from unit.transport.req_test import ReqChannelMixin -from unit.transport.pub_test import PubChannelMixin +from unit.transport.test_req import ReqChannelMixin +from unit.transport.test_pub import PubChannelMixin # TODO: move to a library? diff --git a/tests/unit/transport/test_zeromq.py b/tests/unit/transport/test_zeromq.py index 5f66e94c5d..061296de78 100644 --- a/tests/unit/transport/test_zeromq.py +++ b/tests/unit/transport/test_zeromq.py @@ -33,8 +33,8 @@ ensure_in_syspath('../') import integration # Import Salt libs -from unit.transport.req_test import ReqChannelMixin -from unit.transport.pub_test import PubChannelMixin +from unit.transport.test_req import ReqChannelMixin +from unit.transport.test_pub import PubChannelMixin ON_SUSE = False if 'SuSE' in platform.dist(): From cb7a25e4a2bb532c1ad99192f4b54101d0edf985 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 13:49:30 +0000 Subject: [PATCH 131/370] Somehow `salt.utils.boto3` is "landing" as `boto3` in `sys.modules` --- tests/unit/utils/test_boto.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/unit/utils/test_boto.py b/tests/unit/utils/test_boto.py index 07538036bd..467edabda8 100644 --- a/tests/unit/utils/test_boto.py +++ b/tests/unit/utils/test_boto.py @@ -104,12 +104,17 @@ def _has_required_boto3(): Returns True/False boolean depending on if Boto is installed and correct version. ''' - if not HAS_BOTO3: + try: + if not HAS_BOTO3: + return False + elif LooseVersion(boto3.__version__) < LooseVersion(required_boto3_version): + return False + else: + return True + except AttributeError as exc: + if "has no attribute '__version__'" not in str(exc): + raise return False - elif LooseVersion(boto3.__version__) < LooseVersion(required_boto3_version): - return False - else: - return True def _has_required_moto(): From bb5757c74fc7b0ba6ee275b974882c86b3c16bf7 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 17:11:58 +0000 Subject: [PATCH 132/370] A little hackish but enough to prove it runs --- tests/conftest.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 82597bbefa..25c2df8cf5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,10 +11,20 @@ # Import python libs from __future__ import absolute_import import os +import sys import stat import socket import logging +# Let's allow `integration` and `unit` to be importable +TESTS_DIR = os.path.dirname( + os.path.normpath(os.path.abspath(__file__)) +) +if TESTS_DIR not in sys.path: + sys.path.insert(0, TESTS_DIR) + +CODE_DIR = os.path.dirname(TESTS_DIR) + # Import 3rd-party libs import pytest import salt.ext.six as six @@ -23,10 +33,10 @@ import salt.ext.six as six import salt.utils # Define the pytest plugins we rely on -pytest_plugins = ['salt', 'pytest_catchlog', 'tempdir', 'helpers_namespace'] # pylint: disable=invalid-name +pytest_plugins = ['pytest_catchlog', 'tempdir', 'helpers_namespace'] # pylint: disable=invalid-name -# Import pytest-salt libs -#from pytestsalt.utils import get_unused_localhost_port +# Define where not to collect tests from +collect_ignore = ['setup.py'] log = logging.getLogger('salt.testsuite') @@ -69,6 +79,7 @@ def pytest_configure(config): called after command line options have been parsed and all plugins and initial conftest files been loaded. ''' + config.addinivalue_line('norecursedirs', os.path.join(CODE_DIR, 'templates')) config.addinivalue_line( 'markers', 'destructive_test: Run destructive tests. These tests can include adding ' @@ -489,4 +500,21 @@ def session_pillar_tree_root_dir(session_integration_files_dir): # <---- Fixtures Overrides ------------------------------------------------------------------------------------------- # ----- Custom Fixtures Definitions ---------------------------------------------------------------------------------> +@pytest.fixture(scope='session', autouse=True) +def test_daemon(): + from collections import namedtuple + from integration import TestDaemon, PNUM + values = ('transport', 'zeromq'), ('sysinfo', True), ('no_colors', False), ('output_columns', PNUM) + options_nt = namedtuple('options', [n for n, v in values]) + options = options_nt(*[v for n, v in values]) + fake_parser_nt = namedtuple('parser', 'options') + fake_parser = fake_parser_nt(options) + + # Transplant configuration + TestDaemon.transplant_configs(transport=fake_parser.options.transport) + + tg = TestDaemon(fake_parser) + with tg: + yield + TestDaemon.clean() # <---- Custom Fixtures Definitions ---------------------------------------------------------------------------------- From 9bd7f60b8af39393bde23e4e50174febeb5f9989 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 17:27:54 +0000 Subject: [PATCH 133/370] Add a pytest pip requirements file with what we currently need --- requirements/pytest.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 requirements/pytest.txt diff --git a/requirements/pytest.txt b/requirements/pytest.txt new file mode 100644 index 0000000000..196391fbea --- /dev/null +++ b/requirements/pytest.txt @@ -0,0 +1,4 @@ +pytest +git+https://github.com/eisensheng/pytest-catchlog.git@develop#egg=Pytest-catchlog +pytest-helpers-namespace +pytest-tempdir From 2ebb0a56cce5a2510138515bb65ca556534f6106 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 18:29:32 +0000 Subject: [PATCH 134/370] Port some more options of runtests.py --- tests/conftest.py | 51 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 25c2df8cf5..e904ea2e8c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -53,7 +53,30 @@ def pytest_addoption(parser): ''' register argparse-style options and ini-style config values. ''' + parser.addoption( + '--sysinfo', + default=False, + action='store_true', + help='Print some system information.' + ) + parser.addoption( + '--transport', + default='zeromq', + choices=('zeromq', 'raet', 'tcp'), + help=('Select which transport to run the integration tests with, ' + 'zeromq, raet, or tcp. Default: %default') + ) test_selection_group = parser.getgroup('Tests Selection') + test_selection_group.addoption( + '--ssh', + '--ssh-tests', + dest='ssh', + action='store_true', + default=False, + help='Run salt-ssh tests. These tests will spin up a temporary ' + 'SSH server on your machine. In certain environments, this ' + 'may be insecure! Default: False' + ) test_selection_group.addoption( '--run-destructive', action='store_true', @@ -70,6 +93,20 @@ def pytest_addoption(parser): 'like for example bootstrapping a cloud VM. ' 'Default: False' ) + output_options_group = parser.getgroup('Output Options') + output_options_group.addoption( + '--output-columns', + default=80, + type=int, + help='Number of maximum columns to use on the output' + ) + output_options_group.addoption( + '--no-colors', + '--no-colours', + default=False, + action='store_true', + help='Disable colour printing.' + ) # <---- CLI Options Setup -------------------------------------------------------------------------------------------- @@ -501,14 +538,16 @@ def session_pillar_tree_root_dir(session_integration_files_dir): # <---- Fixtures Overrides ------------------------------------------------------------------------------------------- # ----- Custom Fixtures Definitions ---------------------------------------------------------------------------------> @pytest.fixture(scope='session', autouse=True) -def test_daemon(): +def test_daemon(request): from collections import namedtuple from integration import TestDaemon, PNUM - values = ('transport', 'zeromq'), ('sysinfo', True), ('no_colors', False), ('output_columns', PNUM) - options_nt = namedtuple('options', [n for n, v in values]) - options = options_nt(*[v for n, v in values]) - fake_parser_nt = namedtuple('parser', 'options') - fake_parser = fake_parser_nt(options) + values = (('transport', request.config.getoption('--transport')), + ('sysinfo', request.config.getoption('--sysinfo')), + ('no_colors', request.config.getoption('--no-colors')), + ('output_columns', request.config.getoption('--output-columns')), + ('ssh', request.config.getoption('--ssh'))) + options = namedtuple('options', [n for n, v in values])(*[v for n, v in values]) + fake_parser = namedtuple('parser', 'options')(options) # Transplant configuration TestDaemon.transplant_configs(transport=fake_parser.options.transport) From fbc2af52fcaa52ab52de3f25bfadd316d7fa981a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 21:43:26 +0000 Subject: [PATCH 135/370] Full module path import --- tests/integration/cloud/helpers/virtualbox.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/cloud/helpers/virtualbox.py b/tests/integration/cloud/helpers/virtualbox.py index 0e835c1e13..37841a4f65 100644 --- a/tests/integration/cloud/helpers/virtualbox.py +++ b/tests/integration/cloud/helpers/virtualbox.py @@ -13,7 +13,7 @@ from salttesting import skipIf # Import Salt libs import salt.ext.six as six import integration -from salt.utils import virtualbox +import salt.utils.virtualbox # Create the cloud instance name to be used throughout the tests INSTANCE_NAME = integration.cloud.helpers.random_name() @@ -34,10 +34,10 @@ log.setLevel(logging.INFO) info = log.info -@skipIf(virtualbox.HAS_LIBS is False, 'virtualbox has to be installed') +@skipIf(salt.utils.virtualbox.HAS_LIBS is False, 'virtualbox has to be installed') class VirtualboxTestCase(unittest.TestCase): def setUp(self): - self.vbox = virtualbox.vb_get_box() + self.vbox = salt.utils.virtualbox.vb_get_box() def assertMachineExists(self, name, msg=None): try: @@ -52,7 +52,7 @@ class VirtualboxTestCase(unittest.TestCase): self.assertRaisesRegexp(Exception, "Could not find a registered machine", self.vbox.findMachine, name) -@skipIf(virtualbox.HAS_LIBS is False, 'salt-cloud requires virtualbox to be installed') +@skipIf(salt.utils.virtualbox.HAS_LIBS is False, 'salt-cloud requires virtualbox to be installed') class VirtualboxCloudTestCase(integration.ShellCase): def run_cloud(self, arg_str, catch_stderr=False, timeout=None): """ From ea2cb8470e05fb3bee5639f6208cd2c1881b7885 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 22:15:37 +0000 Subject: [PATCH 136/370] Py2 compat --- tests/utils/test_ipaddress.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/utils/test_ipaddress.py b/tests/utils/test_ipaddress.py index 66efafd8e8..8ab3d6d7ce 100644 --- a/tests/utils/test_ipaddress.py +++ b/tests/utils/test_ipaddress.py @@ -35,7 +35,10 @@ bytes = bytearray import re import contextlib import operator -import ipaddress +try: + import ipaddress +except ImportError: + import salt.ext.ipaddress as ipaddress import sys if sys.version_info < (2, 7): import unittest2 as unittest From 8337a164eefab3ce84326be79ae70e41dcc6e975 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 Feb 2017 23:48:38 +0000 Subject: [PATCH 137/370] Make sure we have the required library before even calling `vb_machine_exists` --- tests/integration/cloud/providers/test_virtualbox.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/cloud/providers/test_virtualbox.py b/tests/integration/cloud/providers/test_virtualbox.py index f53c829885..477514dbd5 100644 --- a/tests/integration/cloud/providers/test_virtualbox.py +++ b/tests/integration/cloud/providers/test_virtualbox.py @@ -26,7 +26,7 @@ import integration from salt.config import cloud_providers_config, vm_profiles_config from salt.utils.virtualbox import vb_xpcom_to_attribute_dict, vb_clone_vm, vb_destroy_machine, vb_create_machine, \ vb_get_box, vb_machine_exists, XPCOM_ATTRIBUTES, vb_start_vm, vb_stop_vm, \ - vb_get_network_addresses, vb_wait_for_network_address, machine_get_machinestate_str + vb_get_network_addresses, vb_wait_for_network_address, machine_get_machinestate_str, HAS_LIBS # Setup logging log = logging.getLogger() @@ -207,7 +207,7 @@ class VirtualboxProviderTest(VirtualboxCloudTestCase): vb_destroy_machine(INSTANCE_NAME) -@skipIf(vb_machine_exists(BOOTABLE_BASE_BOX_NAME) is False, +@skipIf(HAS_LIBS and vb_machine_exists(BOOTABLE_BASE_BOX_NAME) is False, "Bootable VM '{0}' not found. Cannot run tests.".format(BOOTABLE_BASE_BOX_NAME) ) class VirtualboxProviderHeavyTests(VirtualboxCloudTestCase): @@ -381,7 +381,7 @@ class CloneVirtualboxTests(VirtualboxTestCase): self.assertMachineDoesNotExist(vb_name) -@skipIf(vb_machine_exists(BOOTABLE_BASE_BOX_NAME) is False, +@skipIf(HAS_LIBS and vb_machine_exists(BOOTABLE_BASE_BOX_NAME) is False, "Bootable VM '{0}' not found. Cannot run tests.".format(BOOTABLE_BASE_BOX_NAME) ) class BootVirtualboxTests(VirtualboxTestCase): From 2a76618b17f788a377914cf455e52cc8317c6823 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 13:25:57 +0000 Subject: [PATCH 138/370] Fix templates for the new test module naming scheme --- doc/topics/development/extend/index.rst | 6 +++--- templates/{module_test => test_module}/template.yml | 0 .../tests/unit/modules/test_{{module_name}}.py} | 7 ------- templates/{state_test => test_state}/template.yml | 0 .../tests/unit/states/test_{{module_name}}.py} | 8 -------- 5 files changed, 3 insertions(+), 18 deletions(-) rename templates/{module_test => test_module}/template.yml (100%) rename templates/{module_test/tests/unit/modules/{{module_name}}_test.py => test_module/tests/unit/modules/test_{{module_name}}.py} (83%) rename templates/{state_test => test_state}/template.yml (100%) rename templates/{state_test/tests/unit/states/{{module_name}}_test.py => test_state/tests/unit/states/test_{{module_name}}.py} (83%) diff --git a/doc/topics/development/extend/index.rst b/doc/topics/development/extend/index.rst index b9f8a7977f..b76fd16ccb 100644 --- a/doc/topics/development/extend/index.rst +++ b/doc/topics/development/extend/index.rst @@ -29,7 +29,7 @@ Creates a new execution module within salt/modules/{{module_name}}.py module_unit ^^^^^^^^^^^ -Creates a new execution module unit test suite within tests/unit/modules/{{module_name}}_test.py +Creates a new execution module unit test suite within tests/unit/modules/test_{{module_name}}.py state ^^^^^ @@ -39,7 +39,7 @@ Creates a new state module within salt/states/{{module_name}}.py state_unit ^^^^^^^^^^ -Creates a new state module unit test suite within tests/unit/states/{{module_name}}_test.py +Creates a new state module unit test suite within tests/unit/states/test_{{module_name}}.py Adding templates @@ -103,4 +103,4 @@ salt.utils.extend module ======================== .. automodule:: salt.utils.extend - :members: \ No newline at end of file + :members: diff --git a/templates/module_test/template.yml b/templates/test_module/template.yml similarity index 100% rename from templates/module_test/template.yml rename to templates/test_module/template.yml diff --git a/templates/module_test/tests/unit/modules/{{module_name}}_test.py b/templates/test_module/tests/unit/modules/test_{{module_name}}.py similarity index 83% rename from templates/module_test/tests/unit/modules/{{module_name}}_test.py rename to templates/test_module/tests/unit/modules/test_{{module_name}}.py index 557d0958e1..7cc2f4f073 100644 --- a/templates/module_test/tests/unit/modules/{{module_name}}_test.py +++ b/templates/test_module/tests/unit/modules/test_{{module_name}}.py @@ -14,10 +14,8 @@ from salttesting.mock import ( NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath from salt.modules import {{module_name}} -ensure_in_syspath('../../') SERVICE_NAME = '{{module_name}}' {{module_name}}.__salt__ = {} @@ -39,8 +37,3 @@ class {{module_name|capitalize}}TestCase(ModuleTestCase): def test_behaviour(self): # Test inherent behaviours pass - -if __name__ == '__main__': - from unit import run_tests - run_tests({{module_name|capitalize}}TestCase) - diff --git a/templates/state_test/template.yml b/templates/test_state/template.yml similarity index 100% rename from templates/state_test/template.yml rename to templates/test_state/template.yml diff --git a/templates/state_test/tests/unit/states/{{module_name}}_test.py b/templates/test_state/tests/unit/states/test_{{module_name}}.py similarity index 83% rename from templates/state_test/tests/unit/states/{{module_name}}_test.py rename to templates/test_state/tests/unit/states/test_{{module_name}}.py index b7fc4ef4e1..8aba4e8440 100644 --- a/templates/state_test/tests/unit/states/{{module_name}}_test.py +++ b/templates/test_state/tests/unit/states/test_{{module_name}}.py @@ -14,11 +14,8 @@ from salttesting.mock import ( NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath from salt.states import {{module_name}} -ensure_in_syspath('../../') - SERVICE_NAME = '{{module_name}}' {{module_name}}.__salt__ = {} @@ -39,8 +36,3 @@ class {{module_name|capitalize}}TestCase(ModuleTestCase): def test_behaviour(self): # Test inherent behaviours pass - -if __name__ == '__main__': - from unit import run_tests - run_tests({{module_name|capitalize}}TestCase) - From 4ff190cac6bb21e6750a1a1f4296425af4db2eec Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 13:42:40 +0000 Subject: [PATCH 139/370] Fix, simplify, syntax the test_doc unit test --- tests/unit/test_doc.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_doc.py b/tests/unit/test_doc.py index 3b0e675bac..f4f6a217a8 100644 --- a/tests/unit/test_doc.py +++ b/tests/unit/test_doc.py @@ -6,17 +6,17 @@ # Import Python libs from __future__ import absolute_import -import os # Import Salt Testing libs from salttesting import TestCase from salttesting.helpers import ensure_in_syspath -# Import Salt libs -import salt.modules.cmdmod - ensure_in_syspath('../') +# Import Salt libs +import integration +import salt.modules.cmdmod + class DocTestCase(TestCase): ''' @@ -34,7 +34,7 @@ class DocTestCase(TestCase): https://github.com/saltstack/salt/issues/12788 ''' - salt_dir = os.path.dirname(os.path.realpath(__file__)).rsplit('/', 2)[0] + salt_dir = integration.CODE_DIR salt_dir += '/' cmd = 'grep -r :doc: ' + salt_dir @@ -52,12 +52,12 @@ class DocTestCase(TestCase): # the page that documents to not use ":doc:", or # the doc/conf.py file if 'man' in key \ - or key.endswith('doc_test.py') \ - or key.endswith('doc/conf.py') \ - or key.endswith('/conventions/documentation.rst') \ - or key.endswith('doc/topics/releases/2016.11.2.rst') \ - or key.endswith('doc/topics/releases/2016.11.3.rst') \ - or key.endswith('doc/topics/releases/2016.3.5.rst'): + or key.endswith('test_doc.py') \ + or key.endswith('doc/conf.py') \ + or key.endswith('/conventions/documentation.rst') \ + or key.endswith('doc/topics/releases/2016.11.2.rst') \ + or key.endswith('doc/topics/releases/2016.11.3.rst') \ + or key.endswith('doc/topics/releases/2016.3.5.rst'): continue # Set up test return dict From b0794617c5409be7c5dbfdaebe439bb6d2cb4121 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 13:44:11 +0000 Subject: [PATCH 140/370] Fix `unit.utils.test_warnings` after the rename changes --- tests/unit/utils/test_warnings.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/utils/test_warnings.py b/tests/unit/utils/test_warnings.py index c0ec760dc9..b6dd8dd658 100644 --- a/tests/unit/utils/test_warnings.py +++ b/tests/unit/utils/test_warnings.py @@ -3,7 +3,7 @@ :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` - tests.unit.utils.warnings_test + tests.unit.utils.test_warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test ``salt.utils.warn_until`` and ``salt.utils.kwargs_warn_until`` @@ -69,7 +69,7 @@ class WarnUntilTestCase(TestCase): # Let's set version info to (0, 17), a RuntimeError should be raised with self.assertRaisesRegexp( RuntimeError, - r'The warning triggered on filename \'(.*)warnings_test.py\', ' + r'The warning triggered on filename \'(.*)test_warnings.py\', ' r'line number ([\d]+), is supposed to be shown until version ' r'0.17.0 is released. Current version is now 0.17.0. ' r'Please remove the warning.'): @@ -78,7 +78,7 @@ class WarnUntilTestCase(TestCase): # Let's set version info to (0, 17), a RuntimeError should be raised with self.assertRaisesRegexp( RuntimeError, - r'The warning triggered on filename \'(.*)warnings_test.py\', ' + r'The warning triggered on filename \'(.*)test_warnings.py\', ' r'line number ([\d]+), is supposed to be shown until version ' r'(.*) is released. Current version is now ' r'([\d.]+). Please remove the warning.'): @@ -88,7 +88,7 @@ class WarnUntilTestCase(TestCase): # because we're only after the RuntimeError with self.assertRaisesRegexp( RuntimeError, - r'The warning triggered on filename \'(.*)warnings_test.py\', ' + r'The warning triggered on filename \'(.*)test_warnings.py\', ' r'line number ([\d]+), is supposed to be shown until version ' r'0.17.0 is released. Current version is now ' r'(.*). Please remove the warning.'): @@ -98,7 +98,7 @@ class WarnUntilTestCase(TestCase): with self.assertRaisesRegexp( RuntimeError, - r'The warning triggered on filename \'(.*)warnings_test.py\', ' + r'The warning triggered on filename \'(.*)test_warnings.py\', ' r'line number ([\d]+), is supposed to be shown until version ' r'(.*) is released. Current version is now ' r'(.*). Please remove the warning.'): @@ -152,7 +152,7 @@ class WarnUntilTestCase(TestCase): # regardless of whether or not we pass any **kwargs. with self.assertRaisesRegexp( RuntimeError, - r'The warning triggered on filename \'(.*)warnings_test.py\', ' + r'The warning triggered on filename \'(.*)test_warnings.py\', ' r'line number ([\d]+), is supposed to be shown until version ' r'0.17.0 is released. Current version is now 0.17.0. ' r'Please remove the warning.'): @@ -160,7 +160,7 @@ class WarnUntilTestCase(TestCase): with self.assertRaisesRegexp( RuntimeError, - r'The warning triggered on filename \'(.*)warnings_test.py\', ' + r'The warning triggered on filename \'(.*)test_warnings.py\', ' r'line number ([\d]+), is supposed to be shown until version ' r'0.17.0 is released. Current version is now 0.17.0. ' r'Please remove the warning.'): From 5a952ae861fdbdbd90b4a02291a32bcbe087695e Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 15:26:11 +0000 Subject: [PATCH 141/370] Allow getting the actual application for testing --- salt/netapi/rest_tornado/__init__.py | 41 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/salt/netapi/rest_tornado/__init__.py b/salt/netapi/rest_tornado/__init__.py index 374d85a9cf..ec24d99fb8 100644 --- a/salt/netapi/rest_tornado/__init__.py +++ b/salt/netapi/rest_tornado/__init__.py @@ -36,26 +36,14 @@ def __virtual__(): return False -def start(): - ''' - Start the saltnado! - ''' +def get_application(opts): try: from . import saltnado except ImportError as err: logger.error('ImportError! {0}'.format(str(err))) return None - mod_opts = __opts__.get(__virtualname__, {}) - - if 'num_processes' not in mod_opts: - mod_opts['num_processes'] = 1 - - if mod_opts['num_processes'] > 1 and mod_opts.get('debug', False) is True: - raise Exception(( - 'Tornado\'s debug implementation is not compatible with multiprocess. ' - 'Either disable debug, or set num_processes to 1.' - )) + mod_opts = opts.get(__virtualname__, {}) paths = [ (r"/", saltnado.SaltAPIHandler), @@ -73,7 +61,7 @@ def start(): if mod_opts.get('websockets', False): from . import saltnado_websockets - token_pattern = r"([0-9A-Fa-f]{{{0}}})".format(len(getattr(hashlib, __opts__.get('hash_type', 'md5'))().hexdigest())) + token_pattern = r"([0-9A-Fa-f]{{{0}}})".format(len(getattr(hashlib, opts.get('hash_type', 'md5'))().hexdigest())) all_events_pattern = r"/all_events/{0}".format(token_pattern) formatted_events_pattern = r"/formatted_events/{0}".format(token_pattern) logger.debug("All events URL pattern is {0}".format(all_events_pattern)) @@ -89,9 +77,26 @@ def start(): application = tornado.web.Application(paths, debug=mod_opts.get('debug', False)) - application.opts = __opts__ + application.opts = opts application.mod_opts = mod_opts - application.auth = salt.auth.LoadAuth(__opts__) + application.auth = salt.auth.LoadAuth(opts) + return application + + +def start(): + ''' + Start the saltnado! + ''' + mod_opts = __opts__.get(__virtualname__, {}) + + if 'num_processes' not in mod_opts: + mod_opts['num_processes'] = 1 + + if mod_opts['num_processes'] > 1 and mod_opts.get('debug', False) is True: + raise Exception(( + 'Tornado\'s debug implementation is not compatible with multiprocess. ' + 'Either disable debug, or set num_processes to 1.' + )) # the kwargs for the HTTPServer kwargs = {} @@ -109,7 +114,7 @@ def start(): ssl_opts.update({'keyfile': mod_opts['ssl_key']}) kwargs['ssl_options'] = ssl_opts - http_server = tornado.httpserver.HTTPServer(application, **kwargs) + http_server = tornado.httpserver.HTTPServer(get_application(__opts__), **kwargs) try: http_server.bind(mod_opts['port'], address=mod_opts.get('address'), From 12e9fb5da6bc193f74a868ade77463b440f84e7e Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 15:26:45 +0000 Subject: [PATCH 142/370] I got `None` in data which is not iterable. Account for that. --- salt/netapi/rest_tornado/saltnado.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/netapi/rest_tornado/saltnado.py b/salt/netapi/rest_tornado/saltnado.py index c8cbb15a7b..6230d4d31b 100644 --- a/salt/netapi/rest_tornado/saltnado.py +++ b/salt/netapi/rest_tornado/saltnado.py @@ -539,7 +539,7 @@ class BaseSaltAPIHandler(tornado.web.RequestHandler, SaltClientsMixIn): # pylin data = self.deserialize(self.request.body) self.raw_data = copy(data) - if 'arg' in data and not isinstance(data['arg'], list): + if data and 'arg' in data and not isinstance(data['arg'], list): data['arg'] = [data['arg']] if not isinstance(data, list): From bdb3cc3d891d76947248384634f7e10b30ca7772 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 15:28:21 +0000 Subject: [PATCH 143/370] Test websockets against the actual tornado application created in salt --- .../unit/netapi/rest_tornado/test_handlers.py | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/tests/unit/netapi/rest_tornado/test_handlers.py b/tests/unit/netapi/rest_tornado/test_handlers.py index 0802b7e809..3f58c4ba7a 100644 --- a/tests/unit/netapi/rest_tornado/test_handlers.py +++ b/tests/unit/netapi/rest_tornado/test_handlers.py @@ -5,6 +5,8 @@ from __future__ import absolute_import import json import yaml import os +import copy +import hashlib # Import Salt Testing Libs from salttesting.unit import skipIf @@ -14,14 +16,13 @@ import integration # pylint: disable=import-error # Import Salt libs try: + from salt.netapi import rest_tornado from salt.netapi.rest_tornado import saltnado - from salt.netapi.rest_tornado import saltnado_websockets HAS_TORNADO = True except ImportError: HAS_TORNADO = False import salt.auth - # Import 3rd-party libs # pylint: disable=import-error try: @@ -286,10 +287,10 @@ class TestBaseSaltAPIHandler(SaltnadoTestCase): Test transformations low data of the function _get_lowstate ''' valid_lowstate = [{ - "client": "local", - "tgt": "*", - "fun": "test.fib", - "arg": ["10"] + u"client": u"local", + u"tgt": u"*", + u"fun": u"test.fib", + u"arg": [u"10"] }] # Case 1. dictionary type of lowstate @@ -308,12 +309,12 @@ class TestBaseSaltAPIHandler(SaltnadoTestCase): self.assertEqual(valid_lowstate, json.loads(response.body)['lowstate']) # Case 2. string type of arg - request_lowstate = [{ + request_lowstate = { "client": "local", "tgt": "*", "fun": "test.fib", "arg": "10" - }] + } response = self.fetch('/', method='POST', @@ -596,14 +597,9 @@ class TestSaltAuthHandler(SaltnadoTestCase): class TestWebsocketSaltAPIHandler(SaltnadoTestCase): def get_app(self): - - urls = [ - ('/login', saltnado.SaltAuthHandler), - (r"/hook/([0-9A-Fa-f]{32})", saltnado_websockets.AllEventsHandler)] - - application = self.build_tornado_app(urls) - - return application + opts = copy.deepcopy(self.opts) + opts.setdefault('rest_tornado', {})['websockets'] = True + return rest_tornado.get_application(opts) @gen_test def test_websocket_handler_upgrade_to_websocket(self): @@ -613,7 +609,7 @@ class TestWebsocketSaltAPIHandler(SaltnadoTestCase): headers={'Content-Type': self.content_type_map['form']}) token = json.loads(response.body)['return'][0]['token'] - url = 'ws://127.0.0.1:{0}/hook/{1}'.format(self.get_http_port(), token) + url = 'ws://127.0.0.1:{0}/all_events/{1}'.format(self.get_http_port(), token) request = HTTPRequest(url, headers={'Origin': 'http://example.com', 'Host': 'example.com'}) ws = yield websocket_connect(request) @@ -625,9 +621,9 @@ class TestWebsocketSaltAPIHandler(SaltnadoTestCase): """ A bad token should returns a 401 during a websocket connect """ - token = 'A'*32 + token = 'A'*len(getattr(hashlib, self.opts.get('hash_type', 'md5'))().hexdigest()) - url = 'ws://127.0.0.1:{0}/hook/{1}'.format(self.get_http_port(), token) + url = 'ws://127.0.0.1:{0}/all_events/{1}'.format(self.get_http_port(), token) request = HTTPRequest(url, headers={'Origin': 'http://example.com', 'Host': 'example.com'}) try: @@ -645,7 +641,7 @@ class TestWebsocketSaltAPIHandler(SaltnadoTestCase): headers={'Content-Type': self.content_type_map['form']}) token = json.loads(response.body)['return'][0]['token'] - url = 'ws://127.0.0.1:{0}/hook/{1}'.format(self.get_http_port(), token) + url = 'ws://127.0.0.1:{0}/all_events/{1}'.format(self.get_http_port(), token) request = HTTPRequest(url, headers={'Origin': 'http://foo.bar', 'Host': 'example.com'}) ws = yield websocket_connect(request) @@ -661,7 +657,7 @@ class TestWebsocketSaltAPIHandler(SaltnadoTestCase): body=urlencode(self.auth_creds), headers={'Content-Type': self.content_type_map['form']}) token = json.loads(response.body)['return'][0]['token'] - url = 'ws://127.0.0.1:{0}/hook/{1}'.format(self.get_http_port(), token) + url = 'ws://127.0.0.1:{0}/all_events/{1}'.format(self.get_http_port(), token) # Example.com should works request = HTTPRequest(url, headers={'Origin': 'http://example.com', @@ -687,7 +683,7 @@ class TestWebsocketSaltAPIHandler(SaltnadoTestCase): body=urlencode(self.auth_creds), headers={'Content-Type': self.content_type_map['form']}) token = json.loads(response.body)['return'][0]['token'] - url = 'ws://127.0.0.1:{0}/hook/{1}'.format(self.get_http_port(), token) + url = 'ws://127.0.0.1:{0}/all_events/{1}'.format(self.get_http_port(), token) # Example.com should works request = HTTPRequest(url, headers={'Origin': 'http://example.com', From ad3dbee189ac900baf3a84f3b0e843d202f369f8 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 23:07:36 +0000 Subject: [PATCH 144/370] Add test case to make sure we always proper test module names from now on --- tests/unit/test_test_module_names.py | 84 ++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 tests/unit/test_test_module_names.py diff --git a/tests/unit/test_test_module_names.py b/tests/unit/test_test_module_names.py new file mode 100644 index 0000000000..11a2d93275 --- /dev/null +++ b/tests/unit/test_test_module_names.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +''' + tests.unit.doc_test + ~~~~~~~~~~~~~~~~~~~~ +''' + +# Import Python libs +from __future__ import absolute_import +import os + +# Import Salt Testing libs +from salttesting import TestCase + + +# Import Salt libs +import integration + +EXCLUDED_DIRS = [ + 'tests/pkg', + 'tests/perf', + 'tests/unit/utils/cache_mods', + 'tests/unit/modules/inspectlib', + 'tests/unit/modules/zypp/', + 'tests/unit/templates/files', + 'tests/integration/files/', + 'tests/integration/cloud/helpers', +] +EXCLUDED_FILES = [ + 'tests/eventlisten.py', + 'tests/buildpackage.py', + 'tests/saltsh.py', + 'tests/minionswarm.py', + 'tests/wheeltest.py', + 'tests/runtests.py', + 'tests/jenkins.py', + 'tests/salt-tcpdump.py', + 'tests/conftest.py', + 'tests/packdump.py', + 'tests/consist.py', + 'tests/modparser.py', + 'tests/committer_parser.py', + 'tests/integration/utils/testprogram.py', + 'tests/utils/cptestcase.py' +] + + +class BadTestModuleNamesTestCase(TestCase): + ''' + Unit test case for testing bad names for test modules + ''' + + maxDiff = None + + def test_module_name(self): + ''' + Make sure all test modules conform to the test_*.py naming scheme + ''' + excluded_dirs = tuple(EXCLUDED_DIRS) + code_dir = integration.CODE_DIR + tests_dir = os.path.join(code_dir, 'tests') + bad_names = [] + for root, dirs, files in os.walk(tests_dir): + reldir = os.path.relpath(root, code_dir) + if reldir.startswith(excluded_dirs) or reldir.endswith('__pycache__'): + continue + for fname in files: + if fname == '__init__.py' or not fname.endswith('.py'): + continue + relpath = os.path.join(reldir, fname) + if relpath in EXCLUDED_FILES: + continue + if not fname.startswith('test_'): + bad_names.append(relpath) + + error_msg = '\n\nPlease rename the following files:\n' + for path in bad_names: + directory, filename = path.rsplit(os.sep, 1) + filename, ext = os.path.splitext(filename) + error_msg += ' {} -> {}/test_{}.py\n'.format(path, directory, filename.split('_test')[0]) + + error_msg += '\nIf you believe one of the entries above should be ignored, please add it to either\n' + error_msg += '\'EXCLUDED_DIRS\' or \'EXCLUDED_FILES\' in \'tests/unit/test_module_names.py\'.\n' + error_msg += 'If it is a tests module, then please rename as suggested.' + self.assertEqual([], bad_names, error_msg) From f2b8afef63b7554968e0407e10d1cc08feaf2cf4 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Feb 2017 23:20:02 +0000 Subject: [PATCH 145/370] Only start the test_daemon fixture on integration tests --- tests/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index e904ea2e8c..aafd95f61c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -254,6 +254,8 @@ def pytest_collection_modifyitems(items): for item in items: fspath = str(item.fspath) if '/integration/' in fspath: + if 'test_daemon' not in item.fixturenames: + item.fixturenames.append('test_daemon') item.add_marker(pytest.mark.integration) for kind in ('cli', 'client', 'cloud', 'fileserver', 'loader', 'minion', 'modules', 'netapi', 'output', 'reactor', 'renderers', 'runners', 'sdb', 'shell', @@ -537,7 +539,7 @@ def session_pillar_tree_root_dir(session_integration_files_dir): # <---- Fixtures Overrides ------------------------------------------------------------------------------------------- # ----- Custom Fixtures Definitions ---------------------------------------------------------------------------------> -@pytest.fixture(scope='session', autouse=True) +@pytest.fixture(scope='session') def test_daemon(request): from collections import namedtuple from integration import TestDaemon, PNUM From 62cf3c454e6eaa59b8a309e2c42ed9a06807e4fe Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 14:54:39 +0000 Subject: [PATCH 146/370] Add LoaderModuleMockMixin --- tests/unit/test_test_module_names.py | 3 +- tests/utils/mixins.py | 89 ++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/utils/mixins.py diff --git a/tests/unit/test_test_module_names.py b/tests/unit/test_test_module_names.py index 11a2d93275..731729602e 100644 --- a/tests/unit/test_test_module_names.py +++ b/tests/unit/test_test_module_names.py @@ -40,7 +40,8 @@ EXCLUDED_FILES = [ 'tests/modparser.py', 'tests/committer_parser.py', 'tests/integration/utils/testprogram.py', - 'tests/utils/cptestcase.py' + 'tests/utils/cptestcase.py', + 'tests/utils/mixins.py' ] diff --git a/tests/utils/mixins.py b/tests/utils/mixins.py new file mode 100644 index 0000000000..098376cba0 --- /dev/null +++ b/tests/utils/mixins.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + :copyright: © 2017 by the SaltStack Team, see AUTHORS for more details. + :license: Apache 2.0, see LICENSE for more details. + + + tests.utils.mixins + ~~~~~~~~~~~~~~~~~~ + + Unittest TestCase mixin classes +''' +# Import python libs +from __future__ import absolute_import + +try: + from salttesting.mixins import LoaderModuleMockMixin +except ImportError: + # Import python libs + import copy + + # Import 3rd-party libs + import salt.ext.six as six + + class _FixLoaderModuleMockMixinMroOrder(type): + ''' + This metaclass will make sure that LoaderModuleMockMixin will always come as the first + base class in order for LoaderModuleMockMixin.setUp to actually run + ''' + def __new__(mcs, cls_name, cls_bases, cls_dict): + if cls_name == 'LoaderModuleMockMixin': + return super(_FixLoaderModuleMockMixinMroOrder, mcs).__new__(mcs, cls_name, cls_bases, cls_dict) + bases = list(cls_bases) + for idx, base in enumerate(bases): + if base.__name__ == 'LoaderModuleMockMixin': + bases.insert(0, bases.pop(idx)) + break + return super(_FixLoaderModuleMockMixinMroOrder, mcs).__new__(mcs, cls_name, tuple(bases), cls_dict) + + class LoaderModuleMockMixin(six.with_metaclass(_FixLoaderModuleMockMixinMroOrder, object)): + def setUp(self): + loader_module = getattr(self, 'loader_module', None) + if loader_module is not None: + from salttesting.mock import NO_MOCK, NO_MOCK_REASON + if NO_MOCK: + self.skipTest(NO_MOCK_REASON) + + loader_module_name = loader_module.__name__ + loader_module_globals = getattr(self, 'loader_module_globals', None) + loader_module_blacklisted_dunders = getattr(self, 'loader_module_blacklisted_dunders', ()) + if loader_module_globals is None: + loader_module_globals = {} + elif callable(loader_module_globals): + loader_module_globals = loader_module_globals() + else: + loader_module_globals = copy.deepcopy(loader_module_globals) + + salt_dunders = ( + '__opts__', '__salt__', '__runner__', '__context__', '__utils__', + '__ext_pillar__', '__thorium__', '__states__', '__serializers__', '__ret__', + '__grains__', '__pillar__', '__sdb__', + # Proxy is commented out on purpose since some code in salt expects a NameError + # and is most of the time not a required dunder + # '__proxy__' + ) + for dunder_name in salt_dunders: + if dunder_name not in loader_module_globals: + if dunder_name in loader_module_blacklisted_dunders: + continue + loader_module_globals[dunder_name] = {} + + for key in loader_module_globals: + if not hasattr(loader_module, key): + if key in salt_dunders: + setattr(loader_module, key, {}) + else: + setattr(loader_module, key, None) + + if loader_module_globals: + from salttesting.mock import patch + patcher = patch.multiple(loader_module_name, **loader_module_globals) + patcher.start() + + def cleanup(patcher, loader_module_globals): + patcher.stop() + del loader_module_globals + + self.addCleanup(cleanup, patcher, loader_module_globals) + super(LoaderModuleMockMixin, self).setUp() From 019225ec47ddd0a2834ecc5b6875d4d8d74e4e53 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 15:36:49 +0000 Subject: [PATCH 147/370] Code cleanup. We aren't even using mock! --- tests/unit/acl/test_client.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/unit/acl/test_client.py b/tests/unit/acl/test_client.py index a5bcfc6eb5..6d0f08d217 100644 --- a/tests/unit/acl/test_client.py +++ b/tests/unit/acl/test_client.py @@ -7,17 +7,9 @@ from __future__ import absolute_import from salt import acl # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( - NO_MOCK, - NO_MOCK_REASON, -) -from salttesting.helpers import ensure_in_syspath - -ensure_in_syspath('../../') +from salttesting import TestCase -@skipIf(NO_MOCK, NO_MOCK_REASON) class ClientACLTestCase(TestCase): ''' Unit tests for salt.acl.ClientACL @@ -68,8 +60,3 @@ class ClientACLTestCase(TestCase): self.assertTrue(client_acl.cmd_is_blacklisted(['cmd.run', 'state.sls'])) self.assertFalse(client_acl.cmd_is_blacklisted(['state.highstate', 'state.sls'])) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ClientACLTestCase, needs_daemon=False) From 5fb0aa5dcff238beebfae080d20508e098c7580a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 16:02:23 +0000 Subject: [PATCH 148/370] Code cleanup --- tests/unit/cli/test_batch.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/unit/cli/test_batch.py b/tests/unit/cli/test_batch.py index 77396897d2..a58350e2a3 100644 --- a/tests/unit/cli/test_batch.py +++ b/tests/unit/cli/test_batch.py @@ -12,9 +12,6 @@ from salt.cli.batch import Batch # Import Salt Testing Libs from salttesting import skipIf, TestCase from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath - -ensure_in_syspath('../../') @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -62,8 +59,3 @@ class BatchTestCase(TestCase): ''' ret = Batch.get_bnum(self.batch) self.assertEqual(ret, None) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BatchTestCase, needs_daemon=False) From 7fff27627a5924e6c5c40109b79a7337d31a06b9 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 16:05:58 +0000 Subject: [PATCH 149/370] Code cleanup --- tests/unit/config/test_api.py | 9 +-------- tests/unit/config/test_config.py | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/tests/unit/config/test_api.py b/tests/unit/config/test_api.py index ae1790bb5a..51b031248d 100644 --- a/tests/unit/config/test_api.py +++ b/tests/unit/config/test_api.py @@ -8,7 +8,7 @@ from __future__ import absolute_import # Import Salt Testing libs from salttesting import skipIf, TestCase -from salttesting.helpers import destructiveTest, ensure_in_syspath +from salttesting.helpers import destructiveTest from salttesting.mock import ( MagicMock, NO_MOCK, @@ -16,8 +16,6 @@ from salttesting.mock import ( patch ) -ensure_in_syspath('../../') - # Import Salt libs import salt.config @@ -112,8 +110,3 @@ class APIConfigTestCase(TestCase): # Reset DEFAULT_API_OPTS settings as to not interfere with other unit tests salt.config.DEFAULT_API_OPTS = default_api_opts - - -if __name__ == '__main__': - from integration import run_tests - run_tests(APIConfigTestCase, needs_daemon=False) diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index ae7eee9eba..b943c8a24d 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -15,11 +15,8 @@ import shutil import tempfile # Import Salt Testing libs -from salttesting import TestCase -from salttesting.mock import MagicMock, patch -from salttesting.helpers import ensure_in_syspath - -ensure_in_syspath('../') +from salttesting import skipIf, TestCase +from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # Import Salt libs import salt.minion @@ -494,6 +491,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): # cloud_config tests + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('salt.config.load_config', MagicMock(return_value={})) def test_cloud_config_double_master_path(self): ''' @@ -502,6 +500,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertRaises(SaltCloudConfigError, sconfig.cloud_config, PATH, master_config_path='foo', master_config='bar') + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('salt.config.load_config', MagicMock(return_value={})) def test_cloud_config_double_providers_path(self): ''' @@ -510,6 +509,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertRaises(SaltCloudConfigError, sconfig.cloud_config, PATH, providers_config_path='foo', providers_config='bar') + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('salt.config.load_config', MagicMock(return_value={})) def test_cloud_config_double_profiles_path(self): ''' @@ -518,6 +518,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertRaises(SaltCloudConfigError, sconfig.cloud_config, PATH, profiles_config_path='foo', profiles_config='bar') + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('salt.config.load_config', MagicMock(return_value={})) @patch('salt.config.apply_cloud_config', MagicMock(return_value={'providers': 'foo'})) @@ -529,6 +530,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertRaises(SaltCloudConfigError, sconfig.cloud_config, PATH, providers_config='bar') + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('salt.config.load_config', MagicMock(return_value={})) @patch('salt.config.apply_cloud_config', MagicMock(return_value={'providers': 'foo'})) @@ -541,6 +543,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertRaises(SaltCloudConfigError, sconfig.cloud_config, PATH, providers_config_path='bar') + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('os.path.isdir', MagicMock(return_value=True)) def test_cloud_config_deploy_scripts_search_path(self): ''' @@ -581,6 +584,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertRaises(SaltCloudConfigError, sconfig.apply_cloud_config, overrides, defaults=DEFAULT) + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('salt.config.old_to_new', MagicMock(return_value={'default_include': 'path/to/some/cloud/conf/file', 'providers': {'foo': {'bar': { @@ -594,6 +598,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): 'providers': {'foo': {'bar': {'driver': 'foo:bar'}}}} self.assertEqual(sconfig.apply_cloud_config(overrides, defaults=DEFAULT), ret) + @skipIf(NO_MOCK, NO_MOCK_REASON) @patch('salt.config.old_to_new', MagicMock(return_value={'default_include': 'path/to/some/cloud/conf/file', 'providers': {'foo': {'bar': { @@ -1055,6 +1060,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): # <---- Salt Cloud Configuration Tests --------------------------------------------- + @skipIf(NO_MOCK, NO_MOCK_REASON) def test_include_config_without_errors(self): ''' Tests that include_config function returns valid configuration @@ -1069,6 +1075,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertEqual(config_opts, configuration) + @skipIf(NO_MOCK, NO_MOCK_REASON) def test_include_config_with_errors(self): ''' Tests that include_config function returns valid configuration even on errors @@ -1083,6 +1090,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): self.assertEqual(config_opts, configuration) + @skipIf(NO_MOCK, NO_MOCK_REASON) def test_include_config_with_errors_exit(self): ''' Tests that include_config exits on errors @@ -1097,8 +1105,3 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn): config_path, verbose=False, exit_on_config_errors=True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ConfigTestCase, needs_daemon=False) From f7974b186b941f3525b7980063fd412b4a230e07 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 16:17:38 +0000 Subject: [PATCH 150/370] Code cleanup --- tests/unit/fileserver/test_gitfs.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/unit/fileserver/test_gitfs.py b/tests/unit/fileserver/test_gitfs.py index 216dbea8a8..e6de2f2290 100644 --- a/tests/unit/fileserver/test_gitfs.py +++ b/tests/unit/fileserver/test_gitfs.py @@ -18,8 +18,6 @@ except ImportError: # Import Salt Testing Libs from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -ensure_in_syspath('../../') import integration @@ -131,8 +129,3 @@ class GitfsConfigTestCase(TestCase): self.assertEqual(gitfs.remotes[1].mountpoint('baz'), 'abc') self.assertEqual(gitfs.remotes[1].ref('baz'), 'baz_branch') self.assertEqual(gitfs.remotes[1].root('baz'), 'baz_root') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GitfsConfigTestCase, needs_daemon=False) From 3a85996d2a21efddf638325aa61a042800b968c8 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 16:18:20 +0000 Subject: [PATCH 151/370] Code cleanup --- tests/unit/grains/test_core.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py index 56848933f2..5972b27e83 100644 --- a/tests/unit/grains/test_core.py +++ b/tests/unit/grains/test_core.py @@ -10,7 +10,6 @@ import platform # Import Salt Testing Libs from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath from salttesting.mock import ( MagicMock, patch, @@ -19,8 +18,6 @@ from salttesting.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs import salt.ext.six as six import salt.utils @@ -464,8 +461,3 @@ PATCHLEVEL = 3 self.assertEqual(os_grains.get('osrelease'), os_release_map['osrelease']) self.assertListEqual(list(os_grains.get('osrelease_info')), os_release_map['osrelease_info']) self.assertEqual(os_grains.get('osmajorrelease'), os_release_map['osmajorrelease']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CoreGrainsTestCase, needs_daemon=False) From ae46b0da3a4554941f5314c609f621cb01be8a03 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 16:39:31 +0000 Subject: [PATCH 152/370] Code cleanup --- tests/unit/modules/test_s6.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/unit/modules/test_s6.py b/tests/unit/modules/test_s6.py index a2e261851d..9199838367 100644 --- a/tests/unit/modules/test_s6.py +++ b/tests/unit/modules/test_s6.py @@ -16,10 +16,6 @@ from salttesting.mock import ( NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import s6 @@ -135,8 +131,3 @@ class S6TestCase(TestCase): with patch.object(os, 'listdir', MagicMock(return_value=['/etc/service'])): self.assertListEqual(s6.get_all(), ['/etc/service']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(S6TestCase, needs_daemon=False) From 8a0f9fa2fe4a4add2178224c04a2a1d000e8141b Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 21:07:02 +0000 Subject: [PATCH 153/370] The develop branch no longer targets python 2.6 --- .pylintrc | 1 + .testing.pylintrc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.pylintrc b/.pylintrc index 8d7b262df6..6fa3db810f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -70,6 +70,7 @@ disable=W0142, I0011, I0012, W1202, + E1320, E8402, E8731 # E8121, diff --git a/.testing.pylintrc b/.testing.pylintrc index 264006f364..ee106b8b8e 100644 --- a/.testing.pylintrc +++ b/.testing.pylintrc @@ -71,6 +71,7 @@ disable=R, E1101, E1103, E1136, + E1320, E8114, C0102, C0103, @@ -131,6 +132,7 @@ disable=R, # E1101 (no-member) [pylint isn't smart enough] # E1103 (maybe-no-member) # E1136 (unsubscriptable-object) +# E1320 (un-indexed-curly-braces-error) # E8114 (indentation-is-not-a-multiple-of-four-comment) # C0102 (blacklisted-name) [because it activates C0103 too] # C0103 (invalid-name) From 376f76f9ce1fc7f4e80858e5f260e38b9c49d716 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 20 Feb 2017 13:32:29 +0000 Subject: [PATCH 154/370] Add missing import --- salt/modules/archive.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/modules/archive.py b/salt/modules/archive.py index 0e7e77d18b..39a86245a1 100644 --- a/salt/modules/archive.py +++ b/salt/modules/archive.py @@ -35,6 +35,7 @@ from salt.exceptions import SaltInvocationError, CommandExecutionError import salt.utils import salt.utils.files import salt.utils.itertools +import salt.utils.templates # TODO: Check that the passed arguments are correct From 5d0110d98bdbdaf81ee09d8fbc4b273d3c8557ad Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 20 Feb 2017 13:52:12 +0000 Subject: [PATCH 155/370] Code cleanup --- tests/unit/modules/test_augeas_cfg.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/unit/modules/test_augeas_cfg.py b/tests/unit/modules/test_augeas_cfg.py index 22821dc5e1..916f62fdc5 100644 --- a/tests/unit/modules/test_augeas_cfg.py +++ b/tests/unit/modules/test_augeas_cfg.py @@ -16,12 +16,11 @@ from salttesting.mock import ( from salt.modules import augeas_cfg from salt.exceptions import SaltInvocationError # Make sure augeas python interface is installed -HAS_AUGEAS = augeas_cfg.__virtual__() -if HAS_AUGEAS == 'augeas': +if augeas_cfg.HAS_AUGEAS: from augeas import Augeas as _Augeas -@skipIf(HAS_AUGEAS != 'augeas', "augeas python is required for this test case") +@skipIf(augeas_cfg.HAS_AUGEAS is False, "python-augeas is required for this test case") class AugeasCfgTestCase(TestCase): ''' Test cases for salt.modules.augeas_cfg From 15376697f98bed7188085f75a1753d1152d5edf9 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 20 Feb 2017 15:25:06 +0000 Subject: [PATCH 156/370] Code cleanup --- tests/integration/modules/test_beacons.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/integration/modules/test_beacons.py b/tests/integration/modules/test_beacons.py index d233a32763..7841011d63 100644 --- a/tests/integration/modules/test_beacons.py +++ b/tests/integration/modules/test_beacons.py @@ -8,18 +8,13 @@ from __future__ import absolute_import import os # Salt Libs -from salt.modules import beacons from salt.exceptions import CommandExecutionError import integration import salt.utils # Salttesting libs from salttesting import skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath -ensure_in_syspath('../../') - -beacons.__opts__ = {} BEACON_CONF_DIR = os.path.join(integration.TMP, 'minion.d') if not os.path.exists(BEACON_CONF_DIR): @@ -37,8 +32,6 @@ else: IS_ADMIN = os.geteuid() == 0 -@skipIf(not IS_ADMIN, 'You must be root to run these tests') -@destructiveTest class BeaconsAddDeleteTest(integration.ModuleCase): ''' Tests the add and delete functions @@ -62,8 +55,6 @@ class BeaconsAddDeleteTest(integration.ModuleCase): self.run_function('beacons.save') -@skipIf(not IS_ADMIN, 'You must be root to run these tests') -@destructiveTest class BeaconsTest(integration.ModuleCase): ''' Tests the beacons execution module @@ -143,8 +134,3 @@ class BeaconsTest(integration.ModuleCase): self.assertEqual(ret, {'ps': {'apache2': 'stopped'}, 'enabled': True}) else: self.assertEqual(ret, {'ps': {'apache': 'stopped'}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests([BeaconsAddDeleteTest, BeaconsTest]) From 62f55073c92f2441afa053a56320ef2e87fec52f Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 19 Feb 2017 15:42:29 +0000 Subject: [PATCH 157/370] Fix test cases(no longer logging errors). --- tests/unit/beacons/test_glxinfo.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/unit/beacons/test_glxinfo.py b/tests/unit/beacons/test_glxinfo.py index 42bc3222fd..87e6367eb1 100644 --- a/tests/unit/beacons/test_glxinfo.py +++ b/tests/unit/beacons/test_glxinfo.py @@ -4,27 +4,25 @@ from __future__ import absolute_import # Salt libs -from salt.beacons import glxinfo +import salt.beacons.glxinfo as glxinfo # Salt testing libs from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock -# Globals - -glxinfo.__salt__ = {} - -ensure_in_syspath('../../') +# Import test suite libs +from tests.utils.mixins import LoaderModuleMockMixin @skipIf(NO_MOCK, NO_MOCK_REASON) -class GLXInfoBeaconTestCase(TestCase): +class GLXInfoBeaconTestCase(TestCase, LoaderModuleMockMixin): ''' Test case for salt.beacons.glxinfo ''' - def setUp(self): - glxinfo.last_state = {} + loader_module = glxinfo + loader_module_globals = { + 'last_state': {}, + } def test_no_adb_command(self): with patch('salt.utils.which') as mock: @@ -53,7 +51,6 @@ class GLXInfoBeaconTestCase(TestCase): ret = glxinfo.beacon(config) self.assertEqual(ret, []) - log_mock.info.assert_called_once_with('Configuration for glxinfo beacon must be a dict.') def test_no_user(self): config = {'screen_event': True} @@ -62,10 +59,7 @@ class GLXInfoBeaconTestCase(TestCase): glxinfo.log = log_mock ret = glxinfo.beacon(config) - self.assertEqual(ret, []) - log_mock.info.assert_called_once_with('Configuration for glxinfo beacon must include a user as ' - 'glxinfo is not available to root.') def test_screen_state(self): config = {'screen_event': True, 'user': 'frank'} From 41ef69b3ca178596b6dcb80f380808b7c0a50b3e Mon Sep 17 00:00:00 2001 From: Ivan Babrou Date: Fri, 17 Feb 2017 11:09:01 -0800 Subject: [PATCH 158/370] Document default permission modes for file module --- salt/states/file.py | 48 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 3f0ca30849..4c64df0d39 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -822,7 +822,10 @@ def symlink( mode The permissions to set on this file, aka 644, 0775, 4664. Not supported - on Windows + on Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. ''' name = os.path.expanduser(name) @@ -1284,7 +1287,10 @@ def managed(name, mode The permissions to set on this file, aka 644, 0775, 4664. Not supported - on Windows + on Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. template If this setting is applied, the named templating engine will be used to @@ -1307,6 +1313,9 @@ def managed(name, permissions for those directories. If this is not set, directories will be assigned permissions from the 'mode' argument. + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. + replace : True If set to ``False`` and the file already exists, the file will not be modified even if changes would otherwise be made. Permissions and @@ -1949,11 +1958,17 @@ def directory(name, dir_mode / mode The permissions mode to set any directories created. Not supported on - Windows + Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. file_mode The permissions mode to set any files created if 'mode' is run in - 'recurse'. This defaults to dir_mode. Not supported on Windows + 'recurse'. This defaults to dir_mode. Not supported on Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. makedirs If the directory is located in a path without a parent directory, then @@ -2290,15 +2305,24 @@ def recurse(name, dir_mode The permissions mode to set on any directories created. Not supported on - Windows + Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. file_mode The permissions mode to set on any files created. Not supported on - Windows + Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. sym_mode The permissions mode to set on any symlink created. Not supported on - Windows + Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. template If this setting is applied, the named templating engine will be used to @@ -4140,7 +4164,10 @@ def copy( The permissions to set on the copied file, aka 644, '0775', '4664'. If ``preserve`` is set to ``True``, then this will be ignored. - Not supported on Windows + Not supported on Windows. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. subdir .. versionadded:: 2015.5.0 @@ -4517,7 +4544,10 @@ def serialize(name, salt is running as on the minion mode - The permissions to set on this file, aka 644, 0775, 4664 + The permissions to set on this file, aka 644, 0775, 4664. + + The default mode for new files and directories corresponds umask of salt + process. For existing files and directories it's not enforced. backup Overrides the default backup mode for this specific file. From 2c576c1e6db2ad5818a7de3fe9e3c8f3b6fa6d39 Mon Sep 17 00:00:00 2001 From: Joe Niland Date: Fri, 24 Feb 2017 15:12:40 +1100 Subject: [PATCH 159/370] adding bower.prune module function and bower.pruned state function --- salt/modules/bower.py | 72 ++++++++++++++++++++++++++++++++++--------- salt/states/bower.py | 35 +++++++++++++++++++++ 2 files changed, 93 insertions(+), 14 deletions(-) diff --git a/salt/modules/bower.py b/salt/modules/bower.py index d0f435c7a6..b9a47d87ca 100644 --- a/salt/modules/bower.py +++ b/salt/modules/bower.py @@ -56,6 +56,22 @@ def _check_valid_version(): ) +def _construct_bower_command(bower_command): + ''' + Create bower command line string + ''' + if not bower_command: + raise CommandExecutionError('bower_command, e.g. install, must be specified') + + cmd = 'bower {0}'.format(bower_command) + cmd += ' --config.analytics false' + cmd += ' --config.interactive false' + cmd += ' --allow-root' + cmd += ' --json' + + return cmd + + def install(pkg, dir, pkgs=None, @@ -96,11 +112,7 @@ def install(pkg, ''' _check_valid_version() - cmd = 'bower install' - cmd += ' --config.analytics false' - cmd += ' --config.interactive false' - cmd += ' --allow-root' - cmd += ' --json' + cmd = _construct_bower_command('install') if pkg: cmd += ' "{0}"'.format(pkg) @@ -149,11 +161,7 @@ def uninstall(pkg, dir, runas=None, env=None): ''' _check_valid_version() - cmd = 'bower uninstall' - cmd += ' --config.analytics false' - cmd += ' --config.interactive false' - cmd += ' --allow-root' - cmd += ' --json' + cmd = _construct_bower_command('uninstall') cmd += ' "{0}"'.format(pkg) result = __salt__['cmd.run_all'](cmd, @@ -194,11 +202,8 @@ def list_(dir, runas=None, env=None): ''' _check_valid_version() - cmd = 'bower list --json' - cmd += ' --config.analytics false' - cmd += ' --config.interactive false' + cmd = _construct_bower_command('list') cmd += ' --offline' - cmd += ' --allow-root' result = __salt__['cmd.run_all'](cmd, cwd=dir, @@ -210,3 +215,42 @@ def list_(dir, runas=None, env=None): raise CommandExecutionError(result['stderr']) return json.loads(result['stdout'])['dependencies'] + + +def prune(dir, runas=None, env=None): + ''' + Remove extraneous local Bower packages, i.e. those not referenced in bower.json + + dir + The directory whose packages will be pruned + + runas + The user to run Bower with + + env + Environment variables to set when invoking Bower. Uses the same ``env`` + format as the :py:func:`cmd.run ` execution + function. + + CLI Example: + + .. code-block:: bash + + salt '*' bower.prune /path/to/project + + ''' + _check_valid_version() + + cmd = _construct_bower_command('prune') + + result = __salt__['cmd.run_all'](cmd, + cwd=dir, + runas=runas, + env=env, + python_shell=False) + + if result['retcode'] != 0: + raise CommandExecutionError(result['stderr']) + + # Bower returns an empty dictionary if nothing was pruned + return json.loads(result['stdout']) diff --git a/salt/states/bower.py b/salt/states/bower.py index 62a8471a1e..2dd09b4ad8 100644 --- a/salt/states/bower.py +++ b/salt/states/bower.py @@ -271,3 +271,38 @@ def bootstrap(name, user=None): ret['comment'] = 'Directory was successfully bootstrapped' return ret + + +def pruned(name, user=None, env=None): + ''' + Cleans up local bower_components directory. + + Will execute 'bower prune' on the specified directory (param: name) + + user + The user to run Bower with + + ''' + ret = {'name': name, 'result': None, 'comment': '', 'changes': {}} + + if __opts__['test']: + ret['result'] = None + ret['comment'] = 'Directory \'{0}\' is set to be pruned'.format( + name) + return ret + + try: + call = __salt__['bower.prune'](dir=name, runas=user, env=env) + except (CommandNotFoundError, CommandExecutionError) as err: + ret['result'] = False + ret['comment'] = 'Error pruning \'{0}\': {1}'.format(name, err) + return ret + + ret['result'] = True + if call: + ret['comment'] = 'Directory \'{0}\' was successfully pruned'.format(name) + ret['changes'] = {'old': [], 'new': call} + else: + ret['comment'] = 'No packages were pruned from directory \'{0}\''.format(name) + + return ret From cfb29ccca4cabbbbd8072cbc7cd67fd75141ff2b Mon Sep 17 00:00:00 2001 From: Matthew Richardson Date: Tue, 28 Jun 2016 10:14:44 +0100 Subject: [PATCH 160/370] Add support for git_pillar 'mountpoint' parameter. (#34210) - Create links/ directory in git_pillar cachedir - Symlink repo to links/repo.hash/repo.mountpoint - Use links/repo.hash as the pillar_dir --- salt/config/__init__.py | 2 ++ salt/pillar/git_pillar.py | 2 +- salt/utils/gitfs.py | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 05d8738313..0e3a17efda 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -575,6 +575,7 @@ VALID_OPTS = { 'git_pillar_env': str, 'git_pillar_root': str, 'git_pillar_ssl_verify': bool, + 'git_pillar_mountpoint': str, 'git_pillar_global_lock': bool, 'git_pillar_user': str, 'git_pillar_password': str, @@ -1087,6 +1088,7 @@ DEFAULT_MINION_OPTS = { 'git_pillar_env': '', 'git_pillar_root': '', 'git_pillar_ssl_verify': True, + 'git_pillar_mountpoint': '', 'git_pillar_global_lock': True, 'git_pillar_user': '', 'git_pillar_password': '', diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index 86b770bf68..adc00ccdca 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -324,7 +324,7 @@ except ImportError: HAS_GITPYTHON = False # pylint: enable=import-error -PER_REMOTE_OVERRIDES = ('env', 'root', 'ssl_verify', 'refspecs') +PER_REMOTE_OVERRIDES = ('env', 'root', 'ssl_verify', 'refspecs', 'mountpoint') # Set up logging log = logging.getLogger(__name__) diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index a912b33a70..17146642eb 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -2642,6 +2642,9 @@ class GitPillar(GitBase): Checkout the targeted branches/tags from the git_pillar remotes ''' self.pillar_dirs = {} + linkdir = os.path.join(self.cache_root, 'links') + if not os.path.isdir(linkdir): + os.makedirs(linkdir) for repo in self.remotes: cachedir = self.do_checkout(repo) if cachedir is not None: @@ -2651,7 +2654,17 @@ class GitPillar(GitBase): else: base_branch = self.opts['{0}_base'.format(self.role)] env = 'base' if repo.branch == base_branch else repo.branch - self.pillar_dirs[cachedir] = env + if repo.mountpoint: + lcachedir = os.path.join(linkdir, repo.hash) + if not os.path.isdir(lcachedir): + os.makedirs(lcachedir) + lcachelink = os.path.join(lcachedir, repo.mountpoint.lstrip('/')) + if not os.path.islink(lcachelink): + os.symlink(cachedir, lcachelink) + self.pillar_dirs[lcachedir] = env + else: + self.pillar_dirs[cachedir] = env + def update(self): ''' From 2c007a4c11d1cb7f4f0e84e457953b7444fad3c1 Mon Sep 17 00:00:00 2001 From: Matthew Richardson Date: Tue, 5 Jul 2016 11:25:06 +0100 Subject: [PATCH 161/370] Add git_pillar_mountpoint to DEFAULT_MASTER_OPTS. --- salt/config/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 0e3a17efda..14a17ad27a 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -1310,6 +1310,7 @@ DEFAULT_MASTER_OPTS = { 'git_pillar_env': '', 'git_pillar_root': '', 'git_pillar_ssl_verify': True, + 'git_pillar_mountpoint': '', 'git_pillar_global_lock': True, 'git_pillar_user': '', 'git_pillar_password': '', From 2db0f2af4d48bd0b6d7c4c6384e0caba9d4c0095 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sun, 8 Jan 2017 22:26:21 -0600 Subject: [PATCH 162/370] Add versionadded for pillarenv_from_saltenv I forgot to add this when initially implementing this feature. --- doc/ref/configuration/minion.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst index 0b9b93c3be..a9306ece3d 100644 --- a/doc/ref/configuration/minion.rst +++ b/doc/ref/configuration/minion.rst @@ -1785,6 +1785,8 @@ the environment setting, but for pillar instead of states. ``pillarenv_from_saltenv`` -------------------------- +.. versionadded:: Nitrogen + Default: ``False`` When set to ``True``, the :conf_minion:`pillarenv` value will assume the value From 862a3ec3096f30b4db78b44b73359370b858ffc1 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sun, 8 Jan 2017 22:27:32 -0600 Subject: [PATCH 163/370] Different default value in example for pillarenv --- doc/ref/configuration/minion.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst index a9306ece3d..d43581a6f8 100644 --- a/doc/ref/configuration/minion.rst +++ b/doc/ref/configuration/minion.rst @@ -1778,7 +1778,7 @@ the environment setting, but for pillar instead of states. .. code-block:: yaml - pillarenv: None + pillarenv: dev .. conf_minion:: pillarenv_from_saltenv From 008de6d6e2b798b7adb11192ea68a5ffe2698611 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sun, 8 Jan 2017 23:54:33 -0600 Subject: [PATCH 164/370] Use an OrderedDict for pillar_dirs --- salt/utils/gitfs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index 17146642eb..e2d2a0fc43 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -24,6 +24,7 @@ import salt.utils import salt.utils.itertools import salt.utils.url import salt.fileserver +from salt.utils.odict import OrderedDict from salt.utils.process import os_is_running as pid_exists from salt.exceptions import ( FileserverConfigError, @@ -2641,7 +2642,7 @@ class GitPillar(GitBase): ''' Checkout the targeted branches/tags from the git_pillar remotes ''' - self.pillar_dirs = {} + self.pillar_dirs = OrderedDict() linkdir = os.path.join(self.cache_root, 'links') if not os.path.isdir(linkdir): os.makedirs(linkdir) From 08383313557dbd26b5ee43ebbeb487ff0d79fc66 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 9 Jan 2017 01:24:18 -0600 Subject: [PATCH 165/370] Add git_pillar_includes config option --- doc/ref/configuration/master.rst | 23 +++++++++++++++++++++++ salt/config/__init__.py | 3 +++ 2 files changed, 26 insertions(+) diff --git a/doc/ref/configuration/master.rst b/doc/ref/configuration/master.rst index b5a431f6df..c7e4fe0a7f 100644 --- a/doc/ref/configuration/master.rst +++ b/doc/ref/configuration/master.rst @@ -3013,6 +3013,29 @@ they were created by a different master. .. __: http://www.gluster.org/ +.. conf_master:: git_pillar_includes + +``git_pillar_includes`` +*********************** + +.. versionadded:: Nitrogen + +Default: ``True`` + +Normally, when processing :ref:`git_pillar remotes +`, if more than one repo under the same ``git`` +section in the ``ext_pillar`` configuration refers to the same pillar +environment, then each repo in a given environment will have access to the +other repos' files to be referenced in their top files. However, it may be +desirable to disable this behavior. If so, set this value to ``False``. + +For a more detailed examination of how includes work, see :ref:`this +explanation ` from the git_pillar documentation. + +.. code-block:: yaml + + git_pillar_includes: False + .. _git-ext-pillar-auth-opts: Git External Pillar Authentication Options diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 14a17ad27a..cb5eb6949b 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -584,6 +584,7 @@ VALID_OPTS = { 'git_pillar_pubkey': str, 'git_pillar_passphrase': str, 'git_pillar_refspecs': list, + 'git_pillar_includes': bool, 'gitfs_remotes': list, 'gitfs_mountpoint': str, 'gitfs_root': str, @@ -1097,6 +1098,7 @@ DEFAULT_MINION_OPTS = { 'git_pillar_pubkey': '', 'git_pillar_passphrase': '', 'git_pillar_refspecs': _DFLT_REFSPECS, + 'git_pillar_includes': True, 'gitfs_remotes': [], 'gitfs_mountpoint': '', 'gitfs_root': '', @@ -1319,6 +1321,7 @@ DEFAULT_MASTER_OPTS = { 'git_pillar_pubkey': '', 'git_pillar_passphrase': '', 'git_pillar_refspecs': _DFLT_REFSPECS, + 'git_pillar_includes': True, 'gitfs_remotes': [], 'gitfs_mountpoint': '', 'gitfs_root': '', From cc2984e71ae5572b1b82f8df4c871ab2b5363b7d Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 9 Jan 2017 01:24:57 -0600 Subject: [PATCH 166/370] Add file-roots-directory-overlay anchor --- doc/ref/file_server/file_roots.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/ref/file_server/file_roots.rst b/doc/ref/file_server/file_roots.rst index a50411a6ad..dddd248785 100644 --- a/doc/ref/file_server/file_roots.rst +++ b/doc/ref/file_server/file_roots.rst @@ -25,6 +25,7 @@ environments are not isolated from each other. This allows for logical isolation of environments by the engineer using Salt, but also allows for information to be used in multiple environments. +.. _file-roots-directory-overlay: Directory Overlay ================= @@ -81,4 +82,4 @@ enable running Salt states without a Salt master. To use the local file server interface, copy the file server data to the minion and set the file_roots option on the minion to point to the directories copied from the master. Once the minion ``file_roots`` option has been set, change the ``file_client`` -option to local to make sure that the local file server interface is used. \ No newline at end of file +option to local to make sure that the local file server interface is used. From 8277e42bc1a49c2f44c17b9bb9c1d853f1527330 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 9 Jan 2017 01:25:18 -0600 Subject: [PATCH 167/370] Add pillar-environments anchor --- doc/topics/pillar/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/topics/pillar/index.rst b/doc/topics/pillar/index.rst index 96b0c92117..5e1d3cde9e 100644 --- a/doc/topics/pillar/index.rst +++ b/doc/topics/pillar/index.rst @@ -335,6 +335,7 @@ updated pillar data, but :py:func:`pillar.item `, ` will not see this data unless refreshed using :py:func:`saltutil.refresh_pillar `. +.. _pillar-environments: How Pillar Environments Are Handled =================================== From 0fdc5d48aead1fdf764b2e5b921a9bb022a552de Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 9 Jan 2017 01:26:16 -0600 Subject: [PATCH 168/370] git_pillar: Add documentation on multiple remotes and mountpoints --- salt/pillar/git_pillar.py | 176 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 169 insertions(+), 7 deletions(-) diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index adc00ccdca..42b4a3e677 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -298,6 +298,165 @@ instead of ``gitfs`` (e.g. :conf_master:`git_pillar_pubkey`, .. _GitPython: https://github.com/gitpython-developers/GitPython .. _pygit2: https://github.com/libgit2/pygit2 + +.. _git-pillar-multiple-repos: + +How Multiple Remotes Are Handled +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +As noted above, multiple remotes can be included in the same ``git`` ext_pillar +configuration. Consider the following: + +.. code-block:: yaml + + my_etcd_config: + etcd.host: 127.0.0.1 + etcd.port: 4001 + + ext_pillar: + - etcd: my_etcd_config + - git: + - master https://mydomain.tld/foo.git: + - root: pillar + - master https://mydomain.tld/bar.git + - master https://mydomain.tld/baz.git + - dev https://mydomain.tld/qux.git + - git: + - master https://mydomain.tld/abc.git + - dev https://mydomain.tld/123.git + +To understand how pillar data from these repos will be compiled, it's important +to know how Salt will process them. The following points should be kept in +mind: + +1. Each ext_pillar is called separately from the others. So, in the above + example, the :mod:`etcd ` ext_pillar will be evaluated + first, with the first group of git_pillar remotes evaluated next (and merged + into the etcd pillar data). Lastly, the second group of git_pillar remotes + will be evaluated, and then merged into the ext_pillar data evaluated before + it. + +2. Within a single group of git_pillar remotes, each remote will be evaluated in + order, with results merged together as each remote is evaluated. + + .. note:: + Prior to the Nitrogen release, remotes would be evaluated in a + non-deterministic order. + +3. By default, when a repo is evaluated, other remotes' which share its pillar + environment will have their files made available to the remote being + processed. + +The first point should be straightforward enough, but the second and third +could use some additional clarification. + +First, point #2. In the first group of git_pillar remotes, the top file and +pillar SLS files in the ``foo`` remote will be evaluated first. The ``bar`` +remote will be evaluated next, and its results will be merged into the pillar +data compiled when the ``foo`` remote was evaluated. As the subsequent remotes +are evaluated, their data will be merged in the same fashion. + +But wait, don't these repositories belong to more than one pillar environments? +Well, yes. The default method of generating pillar data compiles pillar data +from all environments. This behavior can be overridden using a ``pillarenv``. +Setting a :conf_minion:`pillarenv` in the minion config file will make that +minion tell the master to ignore any pillar data from environments which don't +match that pillarenv. A pillarenv can also be specified for a given minion or +set of minions when :mod:`running states `, by using he +``pillarenv`` argument. The CLI pillarenv will override one set in the minion +config file. So, assuming that a pillarenv of ``base`` was set for a minion, it +would not get any of the pillar variables configured in the ``qux`` remote, +since that remote is assigned to the ``dev`` environment. The only way to get +its pillar data would be to specify a pillarenv of ``dev``, which would mean +that it would then ignore any items from the ``base`` pillarenv. A more +detailed explanation of pillar environments can be found :ref:`here +`. + +Moving on to point #3, and looking at the example ext_pillar configuration, as +the ``foo`` remote is evaluated, it will also have access to the files from the +``bar`` and ``baz`` remotes, since all three are assigned to the ``base`` +pillar environment. So, if an SLS file referenced by the ``foo`` remotes's top +file does not exist in the ``foo`` remote, it will be searched for in the +``bar`` remote, followed by the ``baz`` remote. When it comes time to evaluate +the ``bar`` remote, SLS files referenced by the ``bar`` remote's top file will +first be looked for in the ``bar`` remote, followed by ``foo``, and ``baz``, +and when the ``baz`` remote is processed, SLS files will be looked for in +``baz``, followed by ``foo`` and ``bar``. This "failover" logic is called a +:ref:`directory overlay `, and it is also used by +:conf_master:`file_roots` and :conf_minion`pillar_roots`. The ordering of which +remote is checked for SLS files is determined by the order they are listed. +First the remote being processed is checked, then the others that share the +same environment are checked. However, before the Nitrogen release, since +evaluation was unordered, the remote being processed would be checked, followed +in no specific order by the other repos which share the same environment. + +Beginning with the Nitrogen release, this behavior of git_pillar remotes having +access to files in other repos which share the same environment can be disabled +by setting :conf_master:`git_pillar_includes` to ``False``. If this is done, +then all git_pillar remotes will only have access to their own SLS files. +Another way of ensuring that a git_pillar remote will not have access to SLS +files from other git_pillar remotes which share the same pillar environment is +to put them in a separate ``git`` section under ``ext_pillar``. Look again at +the example configuration above. In the second group of git_pillar remotes, the +``abc`` remote would not have access to the SLS files from the ``foo``, +``bar``, and ``baz`` remotes, and vice-versa. + +Mountpoints +~~~~~~~~~~~ + +.. versionadded:: Nitrogen + +Assume the following pillar top file: + +.. code-block:: yaml + + base: + 'web*': + - common + - web.server.nginx + - web.server.appdata + +Now, assume that you would like to configure the ``web.server.nginx`` and +``web.server.appdata`` SLS files in separate repos. This could be done using +the following ext_pillar configuration (assuming that +:conf_master:`git_pillar_includes` has not been set to ``False``): + +.. code-block:: yaml + + ext_pillar: + - git: + - master https://mydomain.tld/pillar-common.git + - master https://mydomain.tld/pillar-nginx.git + - master https://mydomain.tld/pillar-appdata.git + +However, in order to get the files in the second and third git_pillar remotes +to work, you would need to first create the directory structure underneath it +(i.e. place them underneath ``web/server/`` in the repository). This also makes +it tedious to reorganize the configuration, as changing ``web.server.nginx`` to +``web.nginx`` in the top file would require you to also move the SLS files in +the ``pillar-nginx`` up a directory level. + +For these reasons, much like gitfs, git_pillar now supports a "mountpoint" +feature. Using the following ext_pillar configuration, the SLS files in the +second and third git_pillar remotes can be placed in the root of the git +repository: + +.. code-block:: yaml + + ext_pillar: + - git: + - master https://mydomain.tld/pillar-common.git + - master https://mydomain.tld/pillar-nginx.git: + - mountpoint: web/server/ + - master https://mydomain.tld/pillar-appdata.git: + - mountpoint: web/server/ + +Now, if the top file changed the SLS target from ``web.server.nginx``, instead +of reorganizing the git repository, you would just need to adjust the +mountpoint to ``web/`` + +.. note:: + Leading and trailing slashes on the mountpoints are optional. ''' from __future__ import absolute_import @@ -395,8 +554,8 @@ def ext_pillar(minion_id, repo, pillar_dirs): ) for pillar_dir, env in six.iteritems(pillar.pillar_dirs): log.debug( - 'git_pillar is processing pillar SLS from {0} for pillar ' - 'env \'{1}\''.format(pillar_dir, env) + 'git_pillar is processing pillar SLS from %s for pillar ' + 'env \'%s\'', pillar_dir, env ) all_dirs = [d for (d, e) in six.iteritems(pillar.pillar_dirs) if env == e] @@ -449,9 +608,10 @@ class _LegacyGitPillar(object): self.repo = git.Repo.init(rp_) except (git.exc.NoSuchPathError, git.exc.InvalidGitRepositoryError) as exc: - log.error('GitPython exception caught while ' - 'initializing the repo: {0}. Maybe ' - 'git is not available.'.format(exc)) + log.error( + 'GitPython exception caught while initializing the repo: %s. ' + 'Maybe the git CLI program is not available.', exc + ) except Exception as exc: log.exception('Undefined exception in git pillar. ' 'This may be a bug should be reported to the ' @@ -502,8 +662,10 @@ class _LegacyGitPillar(object): log.debug('Legacy git_pillar: Updating \'%s\'', self.rp_location) self.repo.git.fetch() except git.exc.GitCommandError as exc: - log.error('Unable to fetch the latest changes from remote ' - '{0}: {1}'.format(self.rp_location, exc)) + log.error( + 'Unable to fetch the latest changes from remote %s: %s', + self.rp_location, exc + ) return False try: From 7756fece98339daf45eea8606f15b027540832e8 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 9 Jan 2017 16:44:25 -0600 Subject: [PATCH 169/370] Limit inclusion of dirs from the same environment in git_pillar This conditionally limits the inclusion of the cachedirs from other repos in the same environment when git_pillar_includes is not True. --- salt/pillar/git_pillar.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index 42b4a3e677..cffee8076c 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -557,17 +557,26 @@ def ext_pillar(minion_id, repo, pillar_dirs): 'git_pillar is processing pillar SLS from %s for pillar ' 'env \'%s\'', pillar_dir, env ) - all_dirs = [d for (d, e) in six.iteritems(pillar.pillar_dirs) - if env == e] - # Ensure that the current pillar_dir is first in the list, so that - # the pillar top.sls is sourced from the correct location. - pillar_roots = [pillar_dir] - pillar_roots.extend([x for x in all_dirs if x != pillar_dir]) if env == '__env__': env = opts.get('pillarenv') \ or opts.get('environment') \ or opts.get('git_pillar_base') + log.debug('__env__ maps to %s', env) + + pillar_roots = [pillar_dir] + + if __opts__['git_pillar_includes']: + # Add the rest of the pillar_dirs in this environment to the + # list, excluding the current pillar_dir being processed. This + # is because it was already specified above as the first in the + # list, so that its top file is sourced from the correct + # location and not from another git_pillar remote. + pillar_roots.extend( + [d for (d, e) in six.iteritems(pillar.pillar_dirs) + if env == e and d != pillar_dir] + ) + opts['pillar_roots'] = {env: pillar_roots} local_pillar = Pillar(opts, __grains__, minion_id, env) From aa273c23df4ab1dbb7b0d1912b54b30115f6fde5 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 9 Jan 2017 20:34:51 -0600 Subject: [PATCH 170/370] Remove git_pillar_mountpoint parameter This needs to be per-remote only. --- salt/config/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index cb5eb6949b..b765ada308 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -575,7 +575,6 @@ VALID_OPTS = { 'git_pillar_env': str, 'git_pillar_root': str, 'git_pillar_ssl_verify': bool, - 'git_pillar_mountpoint': str, 'git_pillar_global_lock': bool, 'git_pillar_user': str, 'git_pillar_password': str, @@ -1089,7 +1088,6 @@ DEFAULT_MINION_OPTS = { 'git_pillar_env': '', 'git_pillar_root': '', 'git_pillar_ssl_verify': True, - 'git_pillar_mountpoint': '', 'git_pillar_global_lock': True, 'git_pillar_user': '', 'git_pillar_password': '', @@ -1312,7 +1310,6 @@ DEFAULT_MASTER_OPTS = { 'git_pillar_env': '', 'git_pillar_root': '', 'git_pillar_ssl_verify': True, - 'git_pillar_mountpoint': '', 'git_pillar_global_lock': True, 'git_pillar_user': '', 'git_pillar_password': '', From e2bd8a809ca2d017d5e762c04c6ade695d31fab2 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:13:20 -0600 Subject: [PATCH 171/370] Make the git_pillar 'mountpoint' param per-remote-only --- salt/pillar/git_pillar.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index cffee8076c..94c936da3f 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -483,7 +483,8 @@ except ImportError: HAS_GITPYTHON = False # pylint: enable=import-error -PER_REMOTE_OVERRIDES = ('env', 'root', 'ssl_verify', 'refspecs', 'mountpoint') +PER_REMOTE_OVERRIDES = ('env', 'root', 'ssl_verify', 'refspecs') +PER_REMOTE_ONLY = ('name', 'mountpoint') # Set up logging log = logging.getLogger(__name__) @@ -537,7 +538,7 @@ def ext_pillar(minion_id, repo, pillar_dirs): opts['pillar_roots'] = {} opts['__git_pillar'] = True pillar = salt.utils.gitfs.GitPillar(opts) - pillar.init_remotes(repo, PER_REMOTE_OVERRIDES) + pillar.init_remotes(repo, PER_REMOTE_OVERRIDES, PER_REMOTE_ONLY) if __opts__.get('__role') == 'minion': # If masterless, fetch the remotes. We'll need to remove this once # we make the minion daemon able to run standalone. From 8ed98c41c9636a37d894a38b3f13c3c83267cf88 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:04:52 -0600 Subject: [PATCH 172/370] Use the git_pillar per-remote-only params in maint loop --- salt/daemons/masterapi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/daemons/masterapi.py b/salt/daemons/masterapi.py index bfc2dbd891..ac8961a0f8 100644 --- a/salt/daemons/masterapi.py +++ b/salt/daemons/masterapi.py @@ -90,7 +90,8 @@ def init_git_pillar(opts): pillar = salt.utils.gitfs.GitPillar(opts) pillar.init_remotes( opts_dict['git'], - git_pillar.PER_REMOTE_OVERRIDES + git_pillar.PER_REMOTE_OVERRIDES, + git_pillar.PER_REMOTE_ONLY ) ret.append(pillar) return ret From a9724eae77c1dbf542fe1028c5a18c5cdb2367f2 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:05:44 -0600 Subject: [PATCH 173/370] Use the git_pillar per-remote-only params in master pre-flight checks --- salt/master.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/salt/master.py b/salt/master.py index 848a6ff514..59becf941d 100644 --- a/salt/master.py +++ b/salt/master.py @@ -323,11 +323,8 @@ class Maintenance(SignalHandlingMultiprocessingProcess): for pillar in self.git_pillar: pillar.update() except Exception as exc: - log.error( - 'Exception \'{0}\' caught while updating git_pillar' - .format(exc), - exc_info_on_loglevel=logging.DEBUG - ) + log.error('Exception caught while updating git_pillar', + exc_info=True) def handle_schedule(self): ''' @@ -492,12 +489,15 @@ class Master(SMaster): try: new_opts = copy.deepcopy(self.opts) from salt.pillar.git_pillar \ - import PER_REMOTE_OVERRIDES as overrides + import PER_REMOTE_OVERRIDES as per_remote_overrides, \ + PER_REMOTE_ONLY as per_remote_only for repo in non_legacy_git_pillars: new_opts['ext_pillar'] = [repo] try: git_pillar = salt.utils.gitfs.GitPillar(new_opts) - git_pillar.init_remotes(repo['git'], overrides) + git_pillar.init_remotes(repo['git'], + per_remote_overrides, + per_remote_only) except FileserverConfigError as exc: critical_errors.append(exc.strerror) finally: From d7a706619a1dd9081163173b7bbffd63db87171e Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:06:31 -0600 Subject: [PATCH 174/370] Better logging when an ext_pillar fails to load --- salt/pillar/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/salt/pillar/__init__.py b/salt/pillar/__init__.py index 7a79652fcf..bf966239d7 100644 --- a/salt/pillar/__init__.py +++ b/salt/pillar/__init__.py @@ -10,6 +10,8 @@ import os import collections import logging import tornado.gen +import sys +import traceback # Import salt libs import salt.loader @@ -817,8 +819,13 @@ class Pillar(object): pillar_dirs, key) except Exception as exc: - errors.append('Failed to load ext_pillar {0}: {1}'.format( - key, exc)) + errors.append( + 'Failed to load ext_pillar {0}: {1}\n{2}'.format( + key, + exc.__str__(), + ''.join(traceback.format_tb(sys.exc_info()[2])), + ) + ) if ext: pillar = merge( pillar, From 5cd5b60d0ba7d65f8246069e7647dc196b1e7bcc Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:38:54 -0600 Subject: [PATCH 175/370] Pass commands as list of args This should future-proof the code against future changes WRT ``python_shell=False`` --- salt/modules/bower.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/salt/modules/bower.py b/salt/modules/bower.py index b9a47d87ca..853d94e670 100644 --- a/salt/modules/bower.py +++ b/salt/modules/bower.py @@ -14,6 +14,7 @@ from __future__ import absolute_import import json import logging import distutils.version # pylint: disable=import-error,no-name-in-module +import shlex # Import salt libs import salt.utils @@ -61,14 +62,13 @@ def _construct_bower_command(bower_command): Create bower command line string ''' if not bower_command: - raise CommandExecutionError('bower_command, e.g. install, must be specified') - - cmd = 'bower {0}'.format(bower_command) - cmd += ' --config.analytics false' - cmd += ' --config.interactive false' - cmd += ' --allow-root' - cmd += ' --json' + raise CommandExecutionError( + 'bower_command, e.g. install, must be specified') + cmd = ['bower'] + shlex.split(bower_command) + cmd.extend(['--config.analytics', 'false', + '--config.interactive', 'false', + '--allow-root', '--json']) return cmd @@ -115,9 +115,9 @@ def install(pkg, cmd = _construct_bower_command('install') if pkg: - cmd += ' "{0}"'.format(pkg) + cmd.append(pkg) elif pkgs: - cmd += ' "{0}"'.format('" "'.join(pkgs)) + cmd.extend(pkgs) result = __salt__['cmd.run_all'](cmd, cwd=dir, @@ -162,7 +162,7 @@ def uninstall(pkg, dir, runas=None, env=None): _check_valid_version() cmd = _construct_bower_command('uninstall') - cmd += ' "{0}"'.format(pkg) + cmd.append(pkg) result = __salt__['cmd.run_all'](cmd, cwd=dir, @@ -203,7 +203,7 @@ def list_(dir, runas=None, env=None): _check_valid_version() cmd = _construct_bower_command('list') - cmd += ' --offline' + cmd.append('--offline') result = __salt__['cmd.run_all'](cmd, cwd=dir, From 398f6f41e35dee5838bb1921919390d1687ca3d2 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 23:55:06 -0600 Subject: [PATCH 176/370] Add versionadded to new funcs --- salt/modules/bower.py | 2 ++ salt/states/bower.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/salt/modules/bower.py b/salt/modules/bower.py index 853d94e670..1df7214645 100644 --- a/salt/modules/bower.py +++ b/salt/modules/bower.py @@ -219,6 +219,8 @@ def list_(dir, runas=None, env=None): def prune(dir, runas=None, env=None): ''' + .. versionadded:: Nitrogen + Remove extraneous local Bower packages, i.e. those not referenced in bower.json dir diff --git a/salt/states/bower.py b/salt/states/bower.py index 2dd09b4ad8..3baca6ae74 100644 --- a/salt/states/bower.py +++ b/salt/states/bower.py @@ -275,6 +275,8 @@ def bootstrap(name, user=None): def pruned(name, user=None, env=None): ''' + .. versionadded:: Nitrogen + Cleans up local bower_components directory. Will execute 'bower prune' on the specified directory (param: name) From 81f36fe526aca6abe284b7264db454777f10e7fa Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Fri, 24 Feb 2017 06:56:34 +0100 Subject: [PATCH 177/370] Fix returning and logging error instead of just returning string. Kwarg roles moved to the end of the list of positional arguments to preserve API. --- salt/modules/mongodb.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py index 874d76ad59..88dae5ddb6 100644 --- a/salt/modules/mongodb.py +++ b/salt/modules/mongodb.py @@ -172,7 +172,9 @@ def version(user=None, password=None, host=None, port=None, database='admin', au ''' conn = _connect(user, password, host, port, authdb=authdb) if not conn: - return 'Failed to connect to mongo database' + err_msg = "Failed to connect to MongoDB database {0}:{1}".format(host, port) + log.error(err_msg) + return (False, err_msg) try: mdb = pymongo.database.Database(conn, database) @@ -253,8 +255,8 @@ def user_exists(name, user=None, password=None, host=None, port=None, return False -def user_create(name, passwd, roles=None, user=None, password=None, host=None, port=None, - database='admin', authdb=None): +def user_create(name, passwd, user=None, password=None, host=None, port=None, + database='admin', authdb=None, roles=None): ''' Create a Mongodb user From a4186af3239c3cdd09c928454ebf842defb44d49 Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Fri, 24 Feb 2017 07:39:52 +0100 Subject: [PATCH 178/370] Fix indentation. Replaced tabs with spaces --- salt/modules/mongodb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py index 88dae5ddb6..d9f91e5217 100644 --- a/salt/modules/mongodb.py +++ b/salt/modules/mongodb.py @@ -172,8 +172,8 @@ def version(user=None, password=None, host=None, port=None, database='admin', au ''' conn = _connect(user, password, host, port, authdb=authdb) if not conn: - err_msg = "Failed to connect to MongoDB database {0}:{1}".format(host, port) - log.error(err_msg) + err_msg = "Failed to connect to MongoDB database {0}:{1}".format(host, port) + log.error(err_msg) return (False, err_msg) try: From 17109e15223a71efed74a2376003c7f21f81bb59 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 24 Feb 2017 01:09:51 -0600 Subject: [PATCH 179/370] Fix misspelled argument in salt.modules.systemd.disable() --- salt/modules/systemd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/systemd.py b/salt/modules/systemd.py index 7b89014e1d..6d76c4af29 100644 --- a/salt/modules/systemd.py +++ b/salt/modules/systemd.py @@ -889,7 +889,7 @@ def disable(name, **kwargs): # pylint: disable=unused-argument return __salt__['cmd.retcode']( _systemctl_cmd('disable', name, systemd_scope=True), python_shell=False, - ignore_recode=True) == 0 + ignore_retcode=True) == 0 # The unused kwargs argument is required to maintain consistency with the API From ca54541abe3507f4fb2ed01745da318cb1c6ed4a Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 24 Feb 2017 01:12:42 -0600 Subject: [PATCH 180/370] Add missing unit test for disable func --- tests/unit/modules/systemd_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/modules/systemd_test.py b/tests/unit/modules/systemd_test.py index c98b386d53..f10bceae60 100644 --- a/tests/unit/modules/systemd_test.py +++ b/tests/unit/modules/systemd_test.py @@ -514,6 +514,9 @@ class SystemdScopeTestCase(TestCase): def test_enable(self): self._change_state('enable') + def test_disable(self): + self._change_state('disable') + def test_mask(self): self._mask_unmask('mask', False) From c49bb1e5817f3e5e0d3e987561f02e23b86912d8 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 24 Feb 2017 01:22:56 -0600 Subject: [PATCH 181/370] Remove redundant import --- salt/states/service.py | 1 - 1 file changed, 1 deletion(-) diff --git a/salt/states/service.py b/salt/states/service.py index bc0a270dac..655999995f 100644 --- a/salt/states/service.py +++ b/salt/states/service.py @@ -65,7 +65,6 @@ import time # Import Salt libs import salt.utils from salt.exceptions import CommandExecutionError -import salt.utils # Import 3rd-party libs import salt.ext.six as six From 1a1d40ada4764f4694bbb7e43a799924dff2c0b6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 16:57:54 +0000 Subject: [PATCH 182/370] Only convert bytes to strings under Python 3 --- salt/utils/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 8b46cd038d..d692ff95a7 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -3023,7 +3023,9 @@ def to_unicode(s, encoding=None): Given str or unicode, return unicode (str for python 3) ''' if six.PY3: - return to_str(s, encoding) + if isinstance(s, bytes): + return to_str(s, encoding) + return s else: if isinstance(s, str): return s.decode(encoding or __salt_system_encoding__) From f9015ff1e45142f80b3e88425a5f91284141e713 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 16:58:33 +0000 Subject: [PATCH 183/370] Don't even try to concatenate non string types --- salt/utils/locales.py | 13 +++++++------ tests/unit/utils/test_locales.py | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/salt/utils/locales.py b/salt/utils/locales.py index db638324e5..6da3b3e26a 100644 --- a/salt/utils/locales.py +++ b/salt/utils/locales.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import sys import salt.utils +import salt.ext.six as six from salt.utils.decorators import memoize as real_memoize -from salt.ext.six import string_types @real_memoize @@ -37,14 +37,15 @@ def sdecode(string_): ''' Since we don't know where a string is coming from and that string will need to be safely decoded, this function will attempt to decode the string - until if has a working string that does not stack trace + until it has a working string that does not stack trace ''' encodings = get_encodings() for encoding in encodings: try: decoded = salt.utils.to_unicode(string_, encoding) - # Make sure unicode string ops work - u' ' + decoded # pylint: disable=W0104 + if isinstance(decoded, six.string_types): + # Make sure unicode string ops work + u' ' + decoded # pylint: disable=W0104 return decoded except UnicodeDecodeError: continue @@ -56,7 +57,7 @@ def sdecode_if_string(value_): If the value is a string, run sdecode() on it to ensure it is parsed properly. If it is not a string, return it as-is ''' - if isinstance(value_, string_types): + if isinstance(value_, six.string_types): value_ = sdecode(value_) return value_ @@ -124,7 +125,7 @@ def decode_recursively(object_): if isinstance(object_, dict): return dict([(decode_recursively(key), decode_recursively(value)) for key, value in salt.ext.six.iteritems(object_)]) - elif isinstance(object_, string_types): + elif isinstance(object_, six.string_types): return sdecode(object_) else: return object_ diff --git a/tests/unit/utils/test_locales.py b/tests/unit/utils/test_locales.py index 0d319ee765..7c747f2221 100644 --- a/tests/unit/utils/test_locales.py +++ b/tests/unit/utils/test_locales.py @@ -37,6 +37,9 @@ class TestLocales(TestCase): self.assertEqual(locales.sdecode(b), b) # no decode with patch('salt.utils.locales.get_encodings', return_value=['utf-8']): self.assertEqual(locales.sdecode(b), u) + # Non strings are left untouched + with patch('salt.utils.locales.get_encodings', return_value=['utf-8']): + self.assertEqual(locales.sdecode(1), 1) def test_split_locale(self): self.assertDictEqual( From 9dcf83987779256c41b728d59426f9359905659c Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 17:04:34 +0000 Subject: [PATCH 184/370] Minor lint fixes --- salt/utils/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index d692ff95a7..edb430071c 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -1478,9 +1478,9 @@ def subdict_match(data, # We might want to search for a key return True elif subdict_match(target, - pattern, - regex_match=regex_match, - exact_match=exact_match): + pattern, + regex_match=regex_match, + exact_match=exact_match): return True if wildcard: for key in target.keys(): @@ -1629,7 +1629,7 @@ def sanitize_win_path_string(winpath): ''' intab = '<>:|?*' outtab = '_' * len(intab) - trantab = ''.maketrans(intab, outtab) if six.PY3 else string.maketrans(intab, outtab) + trantab = ''.maketrans(intab, outtab) if six.PY3 else string.maketrans(intab, outtab) # pylint: disable=no-member if isinstance(winpath, str): winpath = winpath.translate(trantab) elif isinstance(winpath, six.text_type): @@ -2218,8 +2218,8 @@ def date_cast(date): if HAS_TIMELIB: raise ValueError('Unable to parse {0}'.format(date)) - raise RuntimeError('Unable to parse {0}.' - ' Consider installing timelib'.format(date)) + raise RuntimeError( + 'Unable to parse {0}. Consider installing timelib'.format(date)) def date_format(date=None, format="%Y-%m-%d"): @@ -2398,7 +2398,7 @@ def kwargs_warn_until(kwargs, version, message='The following parameter(s) have been deprecated and ' 'will be removed in \'{0}\': {1}.'.format(version.string, - arg_names), + arg_names), category=category, stacklevel=stacklevel, _version_info_=_version_.info, @@ -2639,7 +2639,7 @@ def is_bin_str(data): trans = ''.maketrans('', '', text_characters) nontext = data.translate(trans) else: - trans = string.maketrans('', '') + trans = string.maketrans('', '') # pylint: disable=no-member nontext = data.translate(trans, text_characters) # If more than 30% non-text characters, then @@ -2996,7 +2996,7 @@ def to_str(s, encoding=None): else: if isinstance(s, bytearray): return str(s) - if isinstance(s, unicode): # pylint: disable=incompatible-py3-code + if isinstance(s, unicode): # pylint: disable=incompatible-py3-code,undefined-variable return s.encode(encoding or __salt_system_encoding__) raise TypeError('expected str, bytearray, or unicode') @@ -3029,7 +3029,7 @@ def to_unicode(s, encoding=None): else: if isinstance(s, str): return s.decode(encoding or __salt_system_encoding__) - return unicode(s) # pylint: disable=incompatible-py3-code + return unicode(s) # pylint: disable=incompatible-py3-code,undefined-variable def is_list(value): From a16d19bdd2031eec8f40b1b721429f7fb926d5c0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 18:27:16 +0000 Subject: [PATCH 185/370] Respect the LazyLoader `mod_dict_class` attribute if defined. --- salt/utils/lazy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/utils/lazy.py b/salt/utils/lazy.py index 9e6a5303da..78b6310ced 100644 --- a/salt/utils/lazy.py +++ b/salt/utils/lazy.py @@ -47,7 +47,7 @@ class LazyDict(collections.MutableMapping): Clear the dict ''' # create a dict to store loaded values in - self._dict = {} + self._dict = getattr(self, 'mod_dict_class', dict)() # have we already loded everything? self.loaded = False From 1b84bee06f049aedb27d7076fd2d65fc10ef453b Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 Feb 2017 18:30:51 +0000 Subject: [PATCH 186/370] Enforce and preserve module loading order. This is the only way we can have predictable results when overriding, for example, grains. --- salt/loader.py | 18 +++++++++--------- tests/integration/loader/test_ext_grains.py | 16 ++++------------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index 86914009fd..cb12cd9564 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -696,11 +696,11 @@ def grains(opts, force_refresh=False, proxy=None): if force_refresh: # if we refresh, lets reload grain modules funcs.clear() # Run core grains - for key, fun in six.iteritems(funcs): + for key in funcs: if not key.startswith('core.'): continue log.trace('Loading {0} grain'.format(key)) - ret = fun() + ret = funcs[key]() if not isinstance(ret, dict): continue if grains_deep_merge: @@ -709,7 +709,7 @@ def grains(opts, force_refresh=False, proxy=None): grains_data.update(ret) # Run the rest of the grains - for key, fun in six.iteritems(funcs): + for key in funcs: if key.startswith('core.') or key == '_errors': continue try: @@ -719,17 +719,17 @@ def grains(opts, force_refresh=False, proxy=None): # one parameter. Then the grains can have access to the # proxymodule for retrieving information from the connected # device. - if fun.__code__.co_argcount == 1: - ret = fun(proxy) + if funcs[key].__code__.co_argcount == 1: + ret = funcs[key](proxy) else: - ret = fun() + ret = funcs[key]() except Exception: if is_proxy(): log.info('The following CRITICAL message may not be an error; the proxy may not be completely established yet.') log.critical( 'Failed to load grains defined in grain file {0} in ' 'function {1}, error:\n'.format( - key, fun + key, funcs[key] ), exc_info=True ) @@ -1177,10 +1177,10 @@ class LazyLoader(salt.utils.lazy.LazyDict): # The files are added in order of priority, so order *must* be retained. self.file_mapping = salt.utils.odict.OrderedDict() - for mod_dir in self.module_dirs: + for mod_dir in sorted(self.module_dirs): files = [] try: - files = os.listdir(mod_dir) + files = sorted(os.listdir(mod_dir)) except OSError: continue # Next mod_dir for filename in files: diff --git a/tests/integration/loader/test_ext_grains.py b/tests/integration/loader/test_ext_grains.py index 83d2639166..2dd0d6fa17 100644 --- a/tests/integration/loader/test_ext_grains.py +++ b/tests/integration/loader/test_ext_grains.py @@ -10,9 +10,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath from salttesting.unit import skipIf -ensure_in_syspath('../') # Import salt libs import integration @@ -26,10 +24,10 @@ class LoaderGrainsTest(integration.ModuleCase): Test the loader standard behavior with external grains ''' - def setUp(self): - self.opts = minion_config(None) - self.opts['disable_modules'] = ['pillar'] - self.opts['grains'] = grains(self.opts) + #def setUp(self): + # self.opts = minion_config(None) + # self.opts['disable_modules'] = ['pillar'] + # self.opts['grains'] = grains(self.opts) def test_grains_overwrite(self): grains = self.run_function('grains.items') @@ -58,9 +56,3 @@ class LoaderGrainsMergeTest(integration.ModuleCase): self.assertIn('a_custom', __grain__) # Check that the grains are merged self.assertEqual({'k1': 'v1', 'k2': 'v2'}, __grain__['a_custom']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LoaderGrainsTest) - run_tests(LoaderGrainsMergeTest) From 8c4a1c9b02996a7133e1ac4ba12b5fa71c985a1a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 00:15:51 +0000 Subject: [PATCH 187/370] Don't even try to convert if not bytes, str or unicode --- salt/utils/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index edb430071c..3e77f8bf72 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -3022,14 +3022,15 @@ def to_unicode(s, encoding=None): ''' Given str or unicode, return unicode (str for python 3) ''' + if not isinstance(s, (bytes, six.string_types)): + return s if six.PY3: if isinstance(s, bytes): return to_str(s, encoding) - return s else: if isinstance(s, str): return s.decode(encoding or __salt_system_encoding__) - return unicode(s) # pylint: disable=incompatible-py3-code,undefined-variable + return s def is_list(value): From 0e1e13316905e78694f70b304cc5046ce462abbf Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 00:26:28 +0000 Subject: [PATCH 188/370] Fix a weird import issue ``` ImportError: Failed to import test module: unit.modules.docker_test Traceback (most recent call last): File "/usr/lib64/python2.7/unittest/loader.py", line 252, in _find_tests module = self._get_module_from_name(name) File "/usr/lib64/python2.7/unittest/loader.py", line 230, in _get_module_from_name __import__(name) File "/testing/tests/unit/modules/docker_test.py", line 39, in class DockerTestCase(TestCase): File "/testing/tests/unit/modules/docker_test.py", line 103, in DockerTestCase @skipIf(_docker_py_version() < (1, 4, 0), File "/testing/tests/unit/modules/docker_test.py", line 34, in _docker_py_version return docker_mod.docker.version_info AttributeError: 'module' object has no attribute 'version_info' ``` --- tests/unit/modules/test_docker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/modules/test_docker.py b/tests/unit/modules/test_docker.py index 64e0f6073d..4322af1441 100644 --- a/tests/unit/modules/test_docker.py +++ b/tests/unit/modules/test_docker.py @@ -30,8 +30,11 @@ docker_mod.__opts__ = {} def _docker_py_version(): - if docker_mod.HAS_DOCKER_PY: - return docker_mod.docker.version_info + try: + if docker_mod.HAS_DOCKER_PY: + return docker_mod.docker.version_info + except AttributeError: + pass return (0,) From b525382fb8a65f5aa33a15dcc62daf765e10849e Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Fri, 24 Feb 2017 12:12:31 +0100 Subject: [PATCH 189/370] Add function to obtain specific user info from MongoDB --- salt/modules/mongodb.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py index c9486933da..dfc3e1684a 100644 --- a/salt/modules/mongodb.py +++ b/salt/modules/mongodb.py @@ -156,6 +156,35 @@ def db_remove(name, user=None, password=None, host=None, port=None, authdb=None) return True +def user_find(name, user=None, password=None, host=None, port=None, + database='admin', authdb=None): + ''' + Get single user from MongoDB + + CLI Example: + + .. code-block:: bash + + salt '*' mongodb.user_find + ''' + conn = _connect(user, password, host, port, authdb=authdb) + if not conn: + err_msg = "Failed to connect to MongoDB database {0}:{1}".format(host, port) + log.error(err_msg) + return (False, err_msg) + + mdb = pymongo.database.Database(conn, database) + try: + return mdb.command("usersInfo", name)["users"] + except pymongo.errors.PyMongoError as err: + log.error( + 'Listing users failed with error: {0}'.format( + str(err) + ) + ) + return (False, str(err)) + + def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' List users of a Mongodb database From 88c2d9a5400d2459931faf5b2e2849f1036a1c92 Mon Sep 17 00:00:00 2001 From: Sebastian Marsching Date: Fri, 24 Feb 2017 13:02:52 +0100 Subject: [PATCH 190/370] Fix return data structure for runner (issue #39169). Previously, the return code of the runner (if any) was supplied in ret['data']['retcode']. This was problematic if ret['data'] was later processed by check_state_result. With this change, runners return the optional return code in ret['retcode'], like the other code (modules, etc.) already did before. --- salt/cli/run.py | 10 +++++++++- salt/runners/state.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/salt/cli/run.py b/salt/cli/run.py index cb8437999d..ed8cf9324c 100644 --- a/salt/cli/run.py +++ b/salt/cli/run.py @@ -39,7 +39,15 @@ class SaltRun(parsers.SaltRunOptionParser): pr = activate_profile(profiling_enabled) try: ret = runner.run() - if isinstance(ret, dict) and 'retcode' in ret.get('data', {}): + # In older versions ret['data']['retcode'] was used + # for signaling the return code. This has been + # changed for the orchestrate runner, but external + # runners might still use it. For this reason, we + # also check ret['data']['retcode'] if + # ret['retcode'] is not available. + if isinstance(ret, dict) and 'retcode' in ret: + self.exit(ret['retcode']) + elif isinstance(ret, dict) and 'retcode' in ret.get('data', {}): self.exit(ret['data']['retcode']) finally: output_profile( diff --git a/salt/runners/state.py b/salt/runners/state.py index f3bf831d92..3f93044fb4 100644 --- a/salt/runners/state.py +++ b/salt/runners/state.py @@ -57,9 +57,9 @@ def orchestrate(mods, saltenv='base', test=None, exclude=None, pillar=None): ret = {'data': {minion.opts['id']: running}, 'outputter': 'highstate'} res = salt.utils.check_state_result(ret['data']) if res: - ret['data']['retcode'] = 0 + ret['retcode'] = 0 else: - ret['data']['retcode'] = 1 + ret['retcode'] = 1 return ret # Aliases for orchestrate runner From 56d9adfbf69ee9fae1dedb4c2d7cb05a646226eb Mon Sep 17 00:00:00 2001 From: Drew Malone Date: Fri, 24 Feb 2017 08:58:37 -0500 Subject: [PATCH 191/370] issue 39642 - boto_vpc.nat_gateway_present should accept parameter allocation_id. --- salt/states/boto_vpc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/salt/states/boto_vpc.py b/salt/states/boto_vpc.py index a055e08a84..f0c04bb2e7 100644 --- a/salt/states/boto_vpc.py +++ b/salt/states/boto_vpc.py @@ -1279,7 +1279,7 @@ def route_table_absent(name, region=None, def nat_gateway_present(name, subnet_name=None, subnet_id=None, - region=None, key=None, keyid=None, profile=None): + region=None, key=None, keyid=None, profile=None, allocation_id=None): ''' Ensure a nat gateway exists within the specified subnet @@ -1304,6 +1304,10 @@ def nat_gateway_present(name, subnet_name=None, subnet_id=None, Id of the subnet within which the nat gateway should exist. Either subnet_name or subnet_id must be provided. + allocation_id + If specified, the elastic IP address referenced by the ID is + associated with the gateway. Otherwise, a new allocation_id is created and used. + region Region to connect to. @@ -1337,7 +1341,8 @@ def nat_gateway_present(name, subnet_name=None, subnet_id=None, r = __salt__['boto_vpc.create_nat_gateway'](subnet_name=subnet_name, subnet_id=subnet_id, region=region, key=key, - keyid=keyid, profile=profile) + keyid=keyid, profile=profile, + allocation_id=allocation_id) if not r.get('created'): ret['result'] = False ret['comment'] = 'Failed to create nat gateway: {0}.'.format(r['error']['message']) From c4988e874e756145192e32fc379945c8400937d8 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Fri, 24 Feb 2017 16:46:45 +0200 Subject: [PATCH 192/370] Improve and align dockerng execution module docs --- salt/modules/dockerng.py | 80 +++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/salt/modules/dockerng.py b/salt/modules/dockerng.py index f094d1f592..8b323e2d19 100644 --- a/salt/modules/dockerng.py +++ b/salt/modules/dockerng.py @@ -200,7 +200,10 @@ Functions ` - :py:func:`dockerng.disconnect_container_from_network ` - +- Salt Functions and States Execution + - :py:func:`dockerng.call ` + - :py:func:`dockerng.sls ` + - :py:func:`dockerng.sls_build ` .. _docker-execution-driver: @@ -5791,20 +5794,24 @@ def _gather_pillar(pillarenv, pillar_override, **grains): def call(name, function, *args, **kwargs): ''' - Executes a salt function inside a container + Executes a Salt function inside a running container + + .. versionadded:: 2016.11.0 + + The container does not need to have Salt installed, but Python is required. + + name + Container name or ID + + function + Salt execution module function CLI Example: .. code-block:: bash - salt myminion dockerng.call test.ping - salt myminion test.arg arg1 arg2 key1=val1 - - The container does not need to have Salt installed, but Python - is required. - - .. versionadded:: 2016.11.0 - + salt myminion dockerng.call compassionate_mirzakhani test.ping + salt myminion dockerng.call compassionate_mirzakhani test.arg arg1 arg2 key1=val1 ''' # where to put the salt-thin thin_dest_path = _generate_tmp_path() @@ -5859,22 +5866,29 @@ def call(name, function, *args, **kwargs): def sls(name, mods=None, saltenv='base', **kwargs): ''' - Apply the highstate defined by the specified modules. + Apply the states defined by the specified SLS modules to the running + container - For example, if your master defines the states ``web`` and ``rails``, you - can apply them to a container: - states by doing: + .. versionadded:: 2016.11.0 + + The container does not need to have Salt installed, but Python is required. + + name + Container name or ID + + mods : None + A string containing comma-separated list of SLS with defined states to + apply to the container. + + saltenv : base + Specify the environment from which to retrieve the SLS indicated by the + `mods` parameter. CLI Example: .. code-block:: bash salt myminion dockerng.sls compassionate_mirzakhani mods=rails,web - - The container does not need to have Salt installed, but Python - is required. - - .. versionadded:: 2016.11.0 ''' mods = [item.strip() for item in mods.split(',')] if mods else [] @@ -5931,24 +5945,32 @@ def sls(name, mods=None, saltenv='base', **kwargs): def sls_build(name, base='opensuse/python', mods=None, saltenv='base', **kwargs): ''' - Build a docker image using the specified sls modules and base image. + Build a Docker image using the specified SLS modules on top of base image - For example, if your master defines the states ``web`` and ``rails``, you - can build a docker image inside myminion that results of applying those - states by doing: + .. versionadded:: 2016.11.0 + + The base image does not need to have Salt installed, but Python is required. + + name + Image name to be built and committed + + base : opensuse/python + Name or ID of the base image + + mods : None + A string containing comma-separated list of SLS with defined states to + apply to the base image. + + saltenv : base + Specify the environment from which to retrieve the SLS indicated by the + `mods` parameter. CLI Example: .. code-block:: bash salt myminion dockerng.sls_build imgname base=mybase mods=rails,web - - The base image does not need to have Salt installed, but Python - is required. - - .. versionadded:: 2016.11.0 ''' - create_kwargs = salt.utils.clean_kwargs(**copy.deepcopy(kwargs)) for key in ('image', 'name', 'cmd', 'interactive', 'tty'): try: From ab7c4d404864d6325f5924a034baf501c12cf89d Mon Sep 17 00:00:00 2001 From: rallytime Date: Fri, 24 Feb 2017 09:10:41 -0700 Subject: [PATCH 193/370] Add pylint disable to global salt definition --- salt/scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/scripts.py b/salt/scripts.py index 84a7b47ce3..f6358c543e 100644 --- a/salt/scripts.py +++ b/salt/scripts.py @@ -432,7 +432,7 @@ def salt_cloud(): ''' # Define 'salt' global so we may use it after ImportError. Otherwise, # UnboundLocalError will be raised. - global salt + global salt # pylint: disable=W0602 try: # Late-imports for CLI performance From e50ae8dd37f1ed29176b4bf7951ee5d25a61b8c7 Mon Sep 17 00:00:00 2001 From: twangboy Date: Thu, 23 Feb 2017 14:21:49 -0700 Subject: [PATCH 194/370] Fix wheel tests --- salt/wheel/key.py | 6 ++++++ tests/integration/wheel/test_client.py | 3 +++ tests/whitelist.txt | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/salt/wheel/key.py b/salt/wheel/key.py index 44dc230e9b..b1e008c3fd 100644 --- a/salt/wheel/key.py +++ b/salt/wheel/key.py @@ -357,6 +357,12 @@ def gen(id_=None, keysize=2048): ret['priv'] = fp_.read() with salt.utils.fopen(pub) as fp_: ret['pub'] = fp_.read() + + # The priv key is given the Read-Only attribute. The causes `os.remove` to + # fail in Windows. + if salt.utils.is_windows(): + os.chmod(priv, 128) + os.remove(priv) os.remove(pub) return ret diff --git a/tests/integration/wheel/test_client.py b/tests/integration/wheel/test_client.py index 0d15137b93..a1e441c0f0 100644 --- a/tests/integration/wheel/test_client.py +++ b/tests/integration/wheel/test_client.py @@ -5,10 +5,12 @@ from __future__ import absolute_import # Import Salt Testing libs import integration +from salttesting import skipIf # Import Salt libs import salt.auth import salt.wheel +import salt.utils class WheelModuleTest(integration.TestCase, integration.AdaptedConfigurationTestCaseMixIn): @@ -74,6 +76,7 @@ class WheelModuleTest(integration.TestCase, integration.AdaptedConfigurationTest self.wheel.cmd_sync(low) + @skipIf(salt.utils.is_windows(), 'Causes pickling error on Windows') def test_cmd_async(self): low = { 'client': 'wheel_async', diff --git a/tests/whitelist.txt b/tests/whitelist.txt index 3e01b8c1d6..a80c33b71d 100644 --- a/tests/whitelist.txt +++ b/tests/whitelist.txt @@ -1,5 +1,7 @@ integration.client.runner +integration.client.standard integration.fileserver.fileclient_test +integration.fileserver.roots_test integration.loader.globals integration.loader.interfaces integration.loader.loader @@ -26,3 +28,5 @@ integration.runners.winrepo integration.states.host integration.states.renderers integration.utils.testprogram +integration.wheel.client +integration.wheel.key From 34659761e822b1be4f9414dd6c76c61d6a1d45d7 Mon Sep 17 00:00:00 2001 From: twangboy Date: Thu, 23 Feb 2017 14:39:46 -0700 Subject: [PATCH 195/370] Add issue number to skipIf --- tests/integration/wheel/test_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration/wheel/test_client.py b/tests/integration/wheel/test_client.py index a1e441c0f0..a59c262035 100644 --- a/tests/integration/wheel/test_client.py +++ b/tests/integration/wheel/test_client.py @@ -76,7 +76,10 @@ class WheelModuleTest(integration.TestCase, integration.AdaptedConfigurationTest self.wheel.cmd_sync(low) - @skipIf(salt.utils.is_windows(), 'Causes pickling error on Windows') + # Remove this skipIf when Issue #39616 is resolved + # https://github.com/saltstack/salt/issues/39616 + @skipIf(salt.utils.is_windows(), + 'Causes pickling error on Windows: Issue #39616') def test_cmd_async(self): low = { 'client': 'wheel_async', From fc718c140a736bd11c458d7df4dc556ec9890276 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:11:51 -0600 Subject: [PATCH 196/370] Flesh out the git_pillar mountpoints support --- salt/utils/gitfs.py | 142 ++++++++++++++++++++++++++++++++------------ 1 file changed, 105 insertions(+), 37 deletions(-) diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index e2d2a0fc43..160898de2c 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -86,13 +86,15 @@ try: GitError = pygit2.errors.GitError except AttributeError: GitError = Exception -except Exception as err: # cffi VerificationError also may happen - HAS_PYGIT2 = False # and pygit2 requrests re-compilation - # on a production system (!), - # but cffi might be absent as well! - # Therefore just a generic Exception class. - if not isinstance(err, ImportError): - log.error('Import pygit2 failed: %s', err) +except Exception as exc: + # Exceptions other than ImportError can be raised in cases where there is a + # problem with cffi (such as when python-cffi is upgraded and pygit2 tries + # to rebuild itself against the newer cffi). Therefore, we simply will + # catch a generic exception, and log the exception if it is anything other + # than an ImportError. + HAS_PYGIT2 = False + if not isinstance(exc, ImportError): + log.exception('Failed to import pygit2') # pylint: enable=import-error @@ -244,10 +246,10 @@ class GitProvider(object): else: msg = ( 'Invalid {0} configuration parameter \'{1}\' in ' - 'remote {2}. Valid parameters are: {3}.'.format( + 'remote \'{2}\'. Valid parameters are: {3}.'.format( self.role, param, - self.url, + self.id, ', '.join(valid_per_remote_params) ) ) @@ -315,11 +317,8 @@ class GitProvider(object): if not isinstance(self.url, six.string_types): log.critical( - 'Invalid {0} remote \'{1}\'. Remotes must be strings, you ' - 'may need to enclose the URL in quotes'.format( - self.role, - self.id - ) + 'Invalid %s remote \'%s\'. Remotes must be strings, you ' + 'may need to enclose the URL in quotes', self.role, self.id ) failhard(self.role) @@ -331,6 +330,15 @@ class GitProvider(object): self.hash = hash_type(self.id).hexdigest() self.cachedir_basename = getattr(self, 'name', self.hash) self.cachedir = salt.utils.path_join(cache_root, self.cachedir_basename) + self.linkdir = salt.utils.path_join(cache_root, + 'links', + self.cachedir_basename) + try: + # Remove linkdir if it exists + salt.utils.rm_rf(self.linkdir) + except OSError: + pass + if not os.path.isdir(self.cachedir): os.makedirs(self.cachedir) @@ -341,7 +349,7 @@ class GitProvider(object): '{2}'.format(self.role, self.id, exc)) if isinstance(self, GitPython): msg += ' Perhaps git is not available.' - log.critical(msg, exc_info_on_loglevel=logging.DEBUG) + log.critical(msg, exc_info=True) failhard(self.role) def _get_envs_from_ref_paths(self, refs): @@ -666,7 +674,7 @@ class GitProvider(object): self._get_lock_file(lock_type), exc ) - log.error(msg, exc_info_on_loglevel=logging.DEBUG) + log.error(msg, exc_info=True) raise GitLockError(exc.errno, msg) msg = 'Set {0} lock for {1} remote \'{2}\''.format( lock_type, @@ -1256,7 +1264,7 @@ class Pygit2(GitProvider): log.error( 'pygit2 was unable to get SHA for %s in %s remote ' '\'%s\'', local_ref, self.role, self.id, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) return None @@ -1334,7 +1342,7 @@ class Pygit2(GitProvider): 'Unable to resolve %s from %s remote \'%s\' ' 'to either an annotated or non-annotated tag', tag_ref, self.role, self.id, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) return None @@ -1350,7 +1358,7 @@ class Pygit2(GitProvider): log.error( 'Failed to checkout %s from %s remote \'%s\': %s', tgt_ref, self.role, self.id, exc, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) return None log.error( @@ -1507,19 +1515,19 @@ class Pygit2(GitProvider): 'You may need to add ssh:// to the repo string or ' 'libgit2 must be compiled with libssh2 to support ' 'SSH authentication.', self.role, self.id, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) elif 'authentication required but no callback set' in exc_str: log.error( '%s remote \'%s\' requires authentication, but no ' 'authentication configured', self.role, self.id, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) else: log.error( 'Error occurred fetching %s remote \'%s\': %s', self.role, self.id, exc, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) return False try: @@ -1801,13 +1809,21 @@ class GitBase(object): Base class for gitfs/git_pillar ''' def __init__(self, opts, valid_providers=VALID_PROVIDERS, cache_root=None): + ''' + IMPORTANT: If specifying a cache_root, understand that this is also + where the remotes will be cloned. A non-default cache_root is only + really designed right now for winrepo, as its repos need to be checked + out into the winrepo locations and not within the cachedir. + ''' self.opts = opts self.valid_providers = valid_providers self.get_provider() if cache_root is not None: - self.cache_root = cache_root + self.cache_root = self.remote_root = cache_root else: - self.cache_root = salt.utils.path_join(self.opts['cachedir'], self.role) + self.cache_root = salt.utils.path_join(self.opts['cachedir'], + self.role) + self.remote_root = salt.utils.path_join(self.cache_root, 'remotes') self.env_cache = salt.utils.path_join(self.cache_root, 'envs.p') self.hash_cachedir = salt.utils.path_join( self.cache_root, 'hash') @@ -2036,7 +2052,7 @@ class GitBase(object): log.error( 'Exception caught while fetching %s remote \'%s\': %s', self.role, repo.id, exc, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) return changed @@ -2318,7 +2334,7 @@ class GitBase(object): repo.role, repo.id, exc, - exc_info_on_loglevel=logging.DEBUG + exc_info=True ) break else: @@ -2643,9 +2659,7 @@ class GitPillar(GitBase): Checkout the targeted branches/tags from the git_pillar remotes ''' self.pillar_dirs = OrderedDict() - linkdir = os.path.join(self.cache_root, 'links') - if not os.path.isdir(linkdir): - os.makedirs(linkdir) + self.pillar_linked_dirs = [] for repo in self.remotes: cachedir = self.do_checkout(repo) if cachedir is not None: @@ -2655,17 +2669,71 @@ class GitPillar(GitBase): else: base_branch = self.opts['{0}_base'.format(self.role)] env = 'base' if repo.branch == base_branch else repo.branch - if repo.mountpoint: - lcachedir = os.path.join(linkdir, repo.hash) - if not os.path.isdir(lcachedir): - os.makedirs(lcachedir) - lcachelink = os.path.join(lcachedir, repo.mountpoint.lstrip('/')) - if not os.path.islink(lcachelink): - os.symlink(cachedir, lcachelink) - self.pillar_dirs[lcachedir] = env + if repo._mountpoint: + if self.link_mountpoint(repo, cachedir): + self.pillar_dirs[repo.linkdir] = env + self.pillar_linked_dirs.append(repo.linkdir) else: self.pillar_dirs[cachedir] = env + def link_mountpoint(self, repo, cachedir): + ''' + Ensure that the mountpoint is linked to the passed cachedir + ''' + lcachelink = salt.utils.path_join(repo.linkdir, repo._mountpoint) + if not os.path.islink(lcachelink): + ldirname = os.path.dirname(lcachelink) + try: + os.symlink(cachedir, lcachelink) + except OSError as exc: + if exc.errno == errno.ENOENT: + # The parent dir does not exist, create it and then + # re-attempt to create the symlink + try: + os.makedirs(ldirname) + except OSError as exc: + log.error( + 'Failed to create path %s: %s', + ldirname, exc.__str__() + ) + return False + else: + try: + os.symlink(cachedir, lcachelink) + except OSError: + log.error( + 'Could not create symlink to %s at path %s: %s', + cachedir, lcachelink, exc.__str__() + ) + return False + elif exc.errno == errno.EEXIST: + # A file or dir already exists at this path, remove it and + # then re-attempt to create the symlink + try: + salt.utils.rm_rf(lcachelink) + except OSError as exc: + log.error( + 'Failed to remove file/dir at path %s: %s', + lcachelink, exc.__str__() + ) + return False + else: + try: + os.symlink(cachedir, lcachelink) + except OSError: + log.error( + 'Could not create symlink to %s at path %s: %s', + cachedir, lcachelink, exc.__str__() + ) + return False + else: + # Other kind of error encountered + log.error( + 'Could not create symlink to %s at path %s: %s', + cachedir, lcachelink, exc.__str__() + ) + return False + return True def update(self): ''' From 7eb86ac82e8e77c85bd69ead7a9806ae33d7c765 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:12:16 -0600 Subject: [PATCH 197/370] Skip processing on mounted git_pillar dirs --- salt/pillar/git_pillar.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index 94c936da3f..c2e2b9eb22 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -554,10 +554,17 @@ def ext_pillar(minion_id, repo, pillar_dirs): False ) for pillar_dir, env in six.iteritems(pillar.pillar_dirs): - log.debug( - 'git_pillar is processing pillar SLS from %s for pillar ' - 'env \'%s\'', pillar_dir, env - ) + if pillar_dir in pillar.pillar_linked_dirs: + log.debug( + 'git_pillar is skipping processing on %s as it is a ' + 'mounted repo', pillar_dir + ) + continue + else: + log.debug( + 'git_pillar is processing pillar SLS from %s for pillar ' + 'env \'%s\'', pillar_dir, env + ) if env == '__env__': env = opts.get('pillarenv') \ From d6f50a85297a8c5dfbf32dab29d1601b60a4abfa Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 22:23:00 -0600 Subject: [PATCH 198/370] Add reminder not to disable git_pillar_includes --- salt/pillar/git_pillar.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index c2e2b9eb22..c400e18988 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -457,6 +457,10 @@ mountpoint to ``web/`` .. note:: Leading and trailing slashes on the mountpoints are optional. + +.. important:: + Use of the ``mountpoint`` feature requires that + :conf_master:`git_pillar_includes` is not disabled. ''' from __future__ import absolute_import From a5402eadbdb2f60e7082674ec78148b6fdbe2cf8 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 23:01:39 -0600 Subject: [PATCH 199/370] Fix a sentence in the docs that was unfinished --- salt/pillar/git_pillar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index c400e18988..aa0609ea65 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -453,7 +453,7 @@ repository: Now, if the top file changed the SLS target from ``web.server.nginx``, instead of reorganizing the git repository, you would just need to adjust the -mountpoint to ``web/`` +mountpoint to ``web/`` (and restart the ``salt-master`` daemon). .. note:: Leading and trailing slashes on the mountpoints are optional. From 9a2193e8f2a0a42f2ea46bf9b6269188683f75d9 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Feb 2017 23:09:10 -0600 Subject: [PATCH 200/370] Add git_pillar mountpoints feature to Nitrogen release notes --- doc/topics/releases/nitrogen.rst | 5 +++++ salt/pillar/git_pillar.py | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/topics/releases/nitrogen.rst b/doc/topics/releases/nitrogen.rst index 3bb68c0b29..a4466dd6f4 100644 --- a/doc/topics/releases/nitrogen.rst +++ b/doc/topics/releases/nitrogen.rst @@ -144,6 +144,11 @@ feature works can be found :ref:`here ` in the GitFS Walkthrough. The git_pillar and winrepo versions of this feature work the same as their GitFS counterpart. +git_pillar "mountpoints" Feature Added +====================================== + +See :ref:`here ` for detailed documentation. + ``dockerng`` State/Execution Module Renamed to ``docker`` ========================================================= diff --git a/salt/pillar/git_pillar.py b/salt/pillar/git_pillar.py index aa0609ea65..50c8c47de1 100644 --- a/salt/pillar/git_pillar.py +++ b/salt/pillar/git_pillar.py @@ -401,6 +401,8 @@ the example configuration above. In the second group of git_pillar remotes, the ``abc`` remote would not have access to the SLS files from the ``foo``, ``bar``, and ``baz`` remotes, and vice-versa. +.. _git-pillar-mountpoints: + Mountpoints ~~~~~~~~~~~ @@ -456,11 +458,11 @@ of reorganizing the git repository, you would just need to adjust the mountpoint to ``web/`` (and restart the ``salt-master`` daemon). .. note:: - Leading and trailing slashes on the mountpoints are optional. - -.. important:: - Use of the ``mountpoint`` feature requires that - :conf_master:`git_pillar_includes` is not disabled. + - Leading and trailing slashes on the mountpoints are optional. + - Use of the ``mountpoint`` feature requires that + :conf_master:`git_pillar_includes` is not disabled. + - Content from mounted git_pillar repos can only be referenced by a top + file in the same pillar environment. ''' from __future__ import absolute_import From 89101fa342468bb25dfd62502344dc866c0e0c40 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 16 Feb 2017 14:33:21 -0600 Subject: [PATCH 201/370] allow sls_build to be used with states --- salt/modules/docker.py | 8 ++--- salt/states/docker.py | 52 +++++++++++++++++++++++++++++-- tests/unit/modules/test_docker.py | 15 +++++---- 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/salt/modules/docker.py b/salt/modules/docker.py index 15da476ed5..b835abdcb3 100644 --- a/salt/modules/docker.py +++ b/salt/modules/docker.py @@ -5981,7 +5981,6 @@ def sls_build(name, base='opensuse/python', mods=None, saltenv='base', # start a new container ret = create(image=base, - name=name, cmd='sleep infinity', interactive=True, tty=True, **create_kwargs) @@ -5994,13 +5993,12 @@ def sls_build(name, base='opensuse/python', mods=None, saltenv='base', # fail if the state was not successful if not dryrun and not salt.utils.check_state_result(ret): raise CommandExecutionError(ret) + if dryrun is False: + ret = commit(id_, name) finally: stop(id_) - - if dryrun: rm_(id_) - return ret - return commit(id_, name) + return ret def get_client_args(): diff --git a/salt/states/docker.py b/salt/states/docker.py index eee6bda412..8e0c5de94a 100644 --- a/salt/states/docker.py +++ b/salt/states/docker.py @@ -511,6 +511,9 @@ def image_present(name, insecure_registry=False, client_timeout=CLIENT_TIMEOUT, dockerfile=None, + sls=None, + base='opensuse/python', + saltenv='base', **kwargs): ''' Ensure that an image is present. The image can either be pulled from a @@ -546,7 +549,7 @@ def image_present(name, - build: /home/myuser/docker/myimage - dockerfile: Dockerfile.alternative - .. versionadded:: develop + .. versionadded:: 2016.11.0 The image will be built using :py:func:`docker.build ` and the specified image name and tag @@ -575,7 +578,33 @@ def image_present(name, Allows for an alternative Dockerfile to be specified. Path to alternative Dockefile is relative to the build path for the Docker container. - .. versionadded:: develop + .. versionadded:: 2016.11.0 + + sls + Allow for building images with ``dockerng.sls_build`` by specify the + sls files to build with. This can be a list or comma-seperated string. + + .. code-block:: yaml + + myuser/myimage:mytag: + dockerng.image_present: + - sls: + - webapp1 + - webapp2 + - base: centos + - saltenv: base + + .. versionadded: Nitrogen + + base + Base image with which to start ``dockerng.sls_build`` + + .. versionadded: Nitrogen + + saltenv + environment from which to pull sls files for ``dockerng.sls_build``. + + .. versionadded: Nitrogen ''' ret = {'name': name, 'changes': {}, @@ -605,7 +634,7 @@ def image_present(name, else: image_info = None - if build: + if build or sls: action = 'built' elif load: action = 'loaded' @@ -632,6 +661,23 @@ def image_present(name, if image_info is None or image_update['Id'] != image_info['Id'][:12]: ret['changes'] = image_update + elif sls: + if isinstance(sls, list): + sls = ','.join(sls) + try: + image_update = __salt__['dockerng.sls_build'](name=image, + base=base, + mods=sls, + saltenv=saltenv) + except Exception as exc: + ret['comment'] = ( + 'Encountered error using sls {0} for building {1}: {2}' + .format(sls, image, exc) + ) + return ret + if image_info is None or image_update['Id'] != image_info['Id'][:12]: + ret['changes'] = image_update + elif load: try: image_update = __salt__['docker.load'](path=load, image=image) diff --git a/tests/unit/modules/test_docker.py b/tests/unit/modules/test_docker.py index 4322af1441..b54df05ce3 100644 --- a/tests/unit/modules/test_docker.py +++ b/tests/unit/modules/test_docker.py @@ -641,6 +641,7 @@ class DockerTestCase(TestCase): docker_stop_mock = MagicMock( return_value={'state': {'old': 'running', 'new': 'stopped'}, 'result': True}) + docker_rm_mock = MagicMock(return_value={}) docker_commit_mock = MagicMock( return_value={'Id': 'ID2', 'Image': 'foo', 'Time_Elapsed': 42}) @@ -672,16 +673,18 @@ class DockerTestCase(TestCase): with patch.object(docker_mod, 'stop', docker_stop_mock): with patch.object(docker_mod, 'commit', docker_commit_mock): with patch.object(docker_mod, 'sls', docker_sls_mock): - ret = docker_mod.sls_build( - 'foo', - mods='foo', - ) + with patch.object(docker_mod, 'rm_', docker_rm_mock): + ret = docker_mod.sls_build( + 'foo', + mods='foo', + ) docker_create_mock.assert_called_once_with( cmd='sleep infinity', - image='opensuse/python', interactive=True, name='foo', tty=True) + image='opensuse/python', interactive=True, tty=True) docker_start_mock.assert_called_once_with('ID') docker_sls_mock.assert_called_once_with('ID', 'foo', 'base') docker_stop_mock.assert_called_once_with('ID') + docker_rm_mock.assert_called_once_with('ID') docker_commit_mock.assert_called_once_with('ID', 'foo') self.assertEqual( {'Id': 'ID2', 'Image': 'foo', 'Time_Elapsed': 42}, ret) @@ -735,7 +738,7 @@ class DockerTestCase(TestCase): ) docker_create_mock.assert_called_once_with( cmd='sleep infinity', - image='opensuse/python', interactive=True, name='foo', tty=True) + image='opensuse/python', interactive=True, tty=True) docker_start_mock.assert_called_once_with('ID') docker_sls_mock.assert_called_once_with('ID', 'foo', 'base') docker_stop_mock.assert_called_once_with('ID') From 8c26d5adc68adc5b8435a4f5ff8e1e024f17661b Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 24 Feb 2017 13:40:21 -0600 Subject: [PATCH 202/370] Handle deprecation of passing string kwargs in the WheelClient/RunnerClient All refs have been checked and confirmed to be passing args/kwargs in the correct way. This commit removes the deprecation notice and replaces it with a log message when string kwargs are passed. --- salt/client/mixins.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/salt/client/mixins.py b/salt/client/mixins.py index a7b783ce2f..13041c4e03 100644 --- a/salt/client/mixins.py +++ b/salt/client/mixins.py @@ -370,21 +370,14 @@ class SyncClientMixin(object): args = low['arg'] if 'kwarg' not in low: - if f_call is None: - f_call = salt.utils.format_call( - self.functions[fun], - low, - expected_extra_kws=CLIENT_INTERNAL_KEYWORDS - ) - kwargs = f_call.get('kwargs', {}) - - # throw a warning for the badly formed low data if we found - # kwargs using the old mechanism - if kwargs: - salt.utils.warn_until( - 'Nitrogen', - 'kwargs must be passed inside the low under "kwargs"' - ) + log.critical( + 'kwargs must be passed inside the low data within the ' + '\'kwarg\' key. See usage of ' + 'salt.utils.args.parse_input() and ' + 'salt.minion.load_args_and_kwargs() elsewhere in the ' + 'codebase.' + ) + kwargs = {} else: kwargs = low['kwarg'] From 1db4b5a7ada5116382b2ea52f5e9d408a6b6ba92 Mon Sep 17 00:00:00 2001 From: dharper Date: Fri, 24 Feb 2017 13:59:52 -0600 Subject: [PATCH 203/370] Checking instance exists in master._get_cached_minion_data when cache.fetch returns None --- salt/utils/master.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/salt/utils/master.py b/salt/utils/master.py index fe240700b4..afd1d4b15a 100644 --- a/salt/utils/master.py +++ b/salt/utils/master.py @@ -146,6 +146,8 @@ class MasterPillarUtil(object): if not salt.utils.verify.valid_id(self.opts, minion_id): continue mdata = self.cache.fetch('minions/{0}'.format(minion_id), 'data') + if not isinstance(mdata, dict): + continue if 'grains' in mdata: grains[minion_id] = mdata['grains'] if 'pillar' in mdata: From 91eb7210bb2f3d39e57d0bacac9b13a52858c8da Mon Sep 17 00:00:00 2001 From: Mike Place Date: Fri, 24 Feb 2017 13:44:54 -0700 Subject: [PATCH 204/370] Use salt's ordereddict for comparison Last thing needed for 2.6 compat --- salt/output/nested.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/output/nested.py b/salt/output/nested.py index 884ad693b9..7d21dba49f 100644 --- a/salt/output/nested.py +++ b/salt/output/nested.py @@ -25,7 +25,7 @@ Example output:: ''' from __future__ import absolute_import # Import python libs -import collections +import salt.utils.odict from numbers import Number # Import salt libs @@ -130,7 +130,7 @@ class NestDisplay(object): ) # respect key ordering of ordered dicts - if isinstance(ret, collections.OrderedDict): + if isinstance(ret, salt.utils.odict.OrderedDict): keys = ret.keys() else: keys = sorted(ret) From 9f80bbce07a6f6d3e773700c4687158cfbb83206 Mon Sep 17 00:00:00 2001 From: Sergey Kizunov Date: Thu, 23 Feb 2017 16:07:05 -0600 Subject: [PATCH 205/370] Fix issue where compile_pillar failure causes minion to exit If there is a failure in `Minion._post_master_init` (for example, the `compile_pillar` fails) and the `master_type` is `failover`, then `MinionManager._connect_minion` will catch the exception and then retry. However, the retry will cause the minion to exit because `opts['master']` is currently a string and not a list. Fix this case to enable the retry to not cause the minion to exit. Signed-off-by: Sergey Kizunov Conflicts: salt/minion.py --- salt/minion.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 03f01ad5b9..21d2d9f547 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -835,18 +835,21 @@ class MinionManager(MinionBase): ''' last = 0 # never have we signed in auth_wait = minion.opts['acceptance_wait_time'] + failed = False while True: try: - yield minion.connect_master() + yield minion.connect_master(failed=failed) minion.tune_in(start=False) break except SaltClientError as exc: + failed = True log.error('Error while bringing up minion for multi-master. Is master at {0} responding?'.format(minion.opts['master'])) last = time.time() if auth_wait < self.max_auth_wait: auth_wait += self.auth_wait yield tornado.gen.sleep(auth_wait) # TODO: log? except Exception as e: + failed = True log.critical('Unexpected error while connecting to {0}'.format(minion.opts['master']), exc_info=True) # Multi Master Tune In @@ -969,7 +972,7 @@ class Minion(MinionBase): time.sleep(1) sys.exit(0) - def sync_connect_master(self, timeout=None): + def sync_connect_master(self, timeout=None, failed=False): ''' Block until we are connected to a master ''' @@ -980,7 +983,7 @@ class Minion(MinionBase): self._sync_connect_master_success = True self.io_loop.stop() - self._connect_master_future = self.connect_master() + self._connect_master_future = self.connect_master(failed=failed) # finish connecting to master self._connect_master_future.add_done_callback(on_connect_master_future_done) if timeout: @@ -1000,11 +1003,11 @@ class Minion(MinionBase): raise SaltDaemonNotRunning('Failed to connect to the salt-master') @tornado.gen.coroutine - def connect_master(self): + def connect_master(self, failed=False): ''' Return a future which will complete when you are connected to a master ''' - master, self.pub_channel = yield self.eval_master(self.opts, self.timeout, self.safe) + master, self.pub_channel = yield self.eval_master(self.opts, self.timeout, self.safe, failed) yield self._post_master_init(master) # TODO: better name... @@ -2477,6 +2480,7 @@ class SyndicManager(MinionBase): ''' last = 0 # never have we signed in auth_wait = opts['acceptance_wait_time'] + failed = False while True: log.debug('Syndic attempting to connect to {0}'.format(opts['master'])) try: @@ -2485,7 +2489,7 @@ class SyndicManager(MinionBase): safe=False, io_loop=self.io_loop, ) - yield syndic.connect_master() + yield syndic.connect_master(failed=failed) # set up the syndic to handle publishes (specifically not event forwarding) syndic.tune_in_no_block() @@ -2495,6 +2499,7 @@ class SyndicManager(MinionBase): log.info('Syndic successfully connected to {0}'.format(opts['master'])) break except SaltClientError as exc: + failed = True log.error('Error while bringing up syndic for multi-syndic. Is master at {0} responding?'.format(opts['master'])) last = time.time() if auth_wait < self.max_auth_wait: @@ -2503,6 +2508,7 @@ class SyndicManager(MinionBase): except KeyboardInterrupt: raise except: # pylint: disable=W0702 + failed = True log.critical('Unexpected error while connecting to {0}'.format(opts['master']), exc_info=True) raise tornado.gen.Return(syndic) From 28564da9669ec5ce6fc6c6c36906afa9bce70bab Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 24 Feb 2017 01:06:19 -0600 Subject: [PATCH 206/370] Implement no_block for service.running/service.dead (systemd only) --- salt/modules/systemd.py | 68 ++++++++++++++++++++++++------ salt/states/service.py | 48 +++++++++++++++++++-- tests/unit/modules/test_systemd.py | 51 ++++++++++++++-------- 3 files changed, 131 insertions(+), 36 deletions(-) diff --git a/salt/modules/systemd.py b/salt/modules/systemd.py index a0bc289867..e49a41f1d7 100644 --- a/salt/modules/systemd.py +++ b/salt/modules/systemd.py @@ -274,7 +274,7 @@ def _runlevel(): return ret -def _systemctl_cmd(action, name=None, systemd_scope=False): +def _systemctl_cmd(action, name=None, systemd_scope=False, no_block=False): ''' Build a systemctl command line. Treat unit names without one of the valid suffixes as a service. @@ -285,6 +285,8 @@ def _systemctl_cmd(action, name=None, systemd_scope=False): and __salt__['config.get']('systemd.scope', True): ret.extend(['systemd-run', '--scope']) ret.append('systemctl') + if no_block: + ret.append('--no-block') if isinstance(action, six.string_types): action = shlex.split(action) ret.extend(action) @@ -731,7 +733,7 @@ def masked(name, runtime=False): return False -def start(name): +def start(name, no_block=False): ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to @@ -746,6 +748,11 @@ def start(name): Start the specified service with systemd + no_block : False + Set to ``True`` to start the service using ``--no-block``. + + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -755,11 +762,11 @@ def start(name): _check_for_unit_changes(name) unmask(name) return __salt__['cmd.retcode']( - _systemctl_cmd('start', name, systemd_scope=True), + _systemctl_cmd('start', name, systemd_scope=True, no_block=no_block), python_shell=False) == 0 -def stop(name): +def stop(name, no_block=False): ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to @@ -774,6 +781,11 @@ def stop(name): Stop the specified service with systemd + no_block : False + Set to ``True`` to start the service using ``--no-block``. + + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -782,11 +794,11 @@ def stop(name): ''' _check_for_unit_changes(name) return __salt__['cmd.retcode']( - _systemctl_cmd('stop', name, systemd_scope=True), + _systemctl_cmd('stop', name, systemd_scope=True, no_block=no_block), python_shell=False) == 0 -def restart(name): +def restart(name, no_block=False): ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to @@ -801,6 +813,11 @@ def restart(name): Restart the specified service with systemd + no_block : False + Set to ``True`` to start the service using ``--no-block``. + + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -810,11 +827,11 @@ def restart(name): _check_for_unit_changes(name) unmask(name) return __salt__['cmd.retcode']( - _systemctl_cmd('restart', name, systemd_scope=True), + _systemctl_cmd('restart', name, systemd_scope=True, no_block=no_block), python_shell=False) == 0 -def reload_(name): +def reload_(name, no_block=False): ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to @@ -829,6 +846,11 @@ def reload_(name): Reload the specified service with systemd + no_block : False + Set to ``True`` to start the service using ``--no-block``. + + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -838,11 +860,11 @@ def reload_(name): _check_for_unit_changes(name) unmask(name) return __salt__['cmd.retcode']( - _systemctl_cmd('reload', name, systemd_scope=True), + _systemctl_cmd('reload', name, systemd_scope=True, no_block=no_block), python_shell=False) == 0 -def force_reload(name): +def force_reload(name, no_block=True): ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to @@ -859,6 +881,11 @@ def force_reload(name): Force-reload the specified service with systemd + no_block : False + Set to ``True`` to start the service using ``--no-block``. + + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash @@ -868,7 +895,8 @@ def force_reload(name): _check_for_unit_changes(name) unmask(name) return __salt__['cmd.retcode']( - _systemctl_cmd('force-reload', name, systemd_scope=True), + _systemctl_cmd('force-reload', name, + systemd_scope=True, no_block=no_block), python_shell=False) == 0 @@ -908,12 +936,18 @@ def enable(name, **kwargs): # pylint: disable=unused-argument Enable the named service to start when the system boots + no_block : False + Set to ``True`` to start the service using ``--no-block``. + + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash salt '*' service.enable ''' + no_block = kwargs.pop('no_block', False) _check_for_unit_changes(name) unmask(name) if name in _get_sysv_services(): @@ -930,7 +964,7 @@ def enable(name, **kwargs): # pylint: disable=unused-argument python_shell=False, ignore_retcode=True) == 0 return __salt__['cmd.retcode']( - _systemctl_cmd('enable', name, systemd_scope=True), + _systemctl_cmd('enable', name, systemd_scope=True, no_block=no_block), python_shell=False, ignore_retcode=True) == 0 @@ -952,12 +986,18 @@ def disable(name, **kwargs): # pylint: disable=unused-argument Disable the named service to not start when the system boots + no_block : False + Set to ``True`` to start the service using ``--no-block``. + + .. versionadded:: Nitrogen + CLI Example: .. code-block:: bash salt '*' service.disable ''' + no_block = kwargs.pop('no_block', False) _check_for_unit_changes(name) if name in _get_sysv_services(): cmd = [] @@ -973,9 +1013,9 @@ def disable(name, **kwargs): # pylint: disable=unused-argument python_shell=False, ignore_retcode=True) == 0 return __salt__['cmd.retcode']( - _systemctl_cmd('disable', name, systemd_scope=True), + _systemctl_cmd('disable', name, systemd_scope=True, no_block=no_block), python_shell=False, - ignore_recode=True) == 0 + ignore_retcode=True) == 0 # The unused kwargs argument is required to maintain consistency with the API diff --git a/salt/states/service.py b/salt/states/service.py index 655999995f..12d3f5e342 100644 --- a/salt/states/service.py +++ b/salt/states/service.py @@ -64,6 +64,7 @@ import time # Import Salt libs import salt.utils +from salt.utils.args import get_function_argspec as _argspec from salt.exceptions import CommandExecutionError # Import 3rd-party libs @@ -293,7 +294,12 @@ def _available(name, ret): return avail -def running(name, enable=None, sig=None, init_delay=None, **kwargs): +def running(name, + enable=None, + sig=None, + init_delay=None, + no_block=False, + **kwargs): ''' Ensure that the service is running @@ -316,6 +322,11 @@ def running(name, enable=None, sig=None, init_delay=None, **kwargs): for requisite states wherein a dependent state might assume a service has started but is not yet fully initialized. + no_block : False + **For systemd minions only.** Starts the service using ``--no-block``. + + .. versionadded:: Nitrogen + .. note:: ``watch`` can be used with service.running to restart a service when another state changes ( example: a file.managed state that creates the @@ -371,7 +382,16 @@ def running(name, enable=None, sig=None, init_delay=None, **kwargs): if enable is True: ret.update(_enable(name, False, result=False, **kwargs)) - func_ret = __salt__['service.start'](name) + start_kwargs = {} + if no_block: + if 'no_block' in _argspec(__salt__['service.start']).args: + start_kwargs = {'no_block': no_block} + else: + ret.setdefault('warnings', []).append( + 'The \'no_block\' argument is not supported on this platform.' + ) + + func_ret = __salt__['service.start'](name, **start_kwargs) if not func_ret: ret['result'] = False @@ -416,7 +436,12 @@ def running(name, enable=None, sig=None, init_delay=None, **kwargs): return ret -def dead(name, enable=None, sig=None, init_delay=None, **kwargs): +def dead(name, + enable=None, + sig=None, + init_delay=None, + no_block=False, + **kwargs): ''' Ensure that the named service is dead by stopping the service if it is running @@ -434,6 +459,12 @@ def dead(name, enable=None, sig=None, init_delay=None, **kwargs): init_delay Add a sleep command (in seconds) before the check to make sure service is killed. + + .. versionadded:: Nitrogen + + no_block : False + **For systemd minions only.** Stops the service using ``--no-block``. + .. versionadded:: Nitrogen ''' ret = {'name': name, @@ -484,7 +515,16 @@ def dead(name, enable=None, sig=None, init_delay=None, **kwargs): ret['comment'] = 'Service {0} is set to be killed'.format(name) return ret - func_ret = __salt__['service.stop'](name) + stop_kwargs = {} + if no_block: + if 'no_block' in _argspec(__salt__['service.stop']).args: + stop_kwargs = {'no_block': no_block} + else: + ret.setdefault('warnings', []).append( + 'The \'no_block\' argument is not supported on this platform.' + ) + + func_ret = __salt__['service.stop'](name, **stop_kwargs) if not func_ret: ret['result'] = False ret['comment'] = 'Service {0} failed to die'.format(name) diff --git a/tests/unit/modules/test_systemd.py b/tests/unit/modules/test_systemd.py index 73a5930a61..59cb247320 100644 --- a/tests/unit/modules/test_systemd.py +++ b/tests/unit/modules/test_systemd.py @@ -286,7 +286,7 @@ class SystemdScopeTestCase(TestCase): 'stderr': '', 'pid': 12345}) - def _change_state(self, action): + def _change_state(self, action, no_block=False): ''' Common code for start/stop/restart/reload/force_reload tests ''' @@ -295,7 +295,11 @@ class SystemdScopeTestCase(TestCase): func = getattr(systemd, action) # Remove trailing _ in "reload_" action = action.rstrip('_').replace('_', '-') - systemctl_command = ['systemctl', action, self.unit_name + '.service'] + systemctl_command = ['systemctl'] + if no_block: + systemctl_command.append('--no-block') + systemctl_command.extend([action, self.unit_name + '.service']) + scope_prefix = ['systemd-run', '--scope'] assert_kwargs = {'python_shell': False} if action in ('enable', 'disable'): @@ -314,10 +318,10 @@ class SystemdScopeTestCase(TestCase): systemd.__salt__, {'config.get': self.mock_true, 'cmd.retcode': self.mock_success}): - ret = func(self.unit_name) + ret = func(self.unit_name, no_block=no_block) self.assertTrue(ret) self.mock_success.assert_called_with( - ['systemd-run', '--scope'] + systemctl_command, + scope_prefix + systemctl_command, **assert_kwargs) # Scope enabled, failed @@ -325,10 +329,10 @@ class SystemdScopeTestCase(TestCase): systemd.__salt__, {'config.get': self.mock_true, 'cmd.retcode': self.mock_failure}): - ret = func(self.unit_name) + ret = func(self.unit_name, no_block=no_block) self.assertFalse(ret) self.mock_failure.assert_called_with( - ['systemd-run', '--scope'] + systemctl_command, + scope_prefix + systemctl_command, **assert_kwargs) # Scope disabled, successful @@ -336,7 +340,7 @@ class SystemdScopeTestCase(TestCase): systemd.__salt__, {'config.get': self.mock_false, 'cmd.retcode': self.mock_success}): - ret = func(self.unit_name) + ret = func(self.unit_name, no_block=no_block) self.assertTrue(ret) self.mock_success.assert_called_with( systemctl_command, @@ -347,7 +351,7 @@ class SystemdScopeTestCase(TestCase): systemd.__salt__, {'config.get': self.mock_false, 'cmd.retcode': self.mock_failure}): - ret = func(self.unit_name) + ret = func(self.unit_name, no_block=no_block) self.assertFalse(ret) self.mock_failure.assert_called_with( systemctl_command, @@ -367,7 +371,7 @@ class SystemdScopeTestCase(TestCase): systemd.__salt__, {'config.get': scope_mock, 'cmd.retcode': self.mock_success}): - ret = func(self.unit_name) + ret = func(self.unit_name, no_block=no_block) self.assertTrue(ret) self.mock_success.assert_called_with( systemctl_command, @@ -378,7 +382,7 @@ class SystemdScopeTestCase(TestCase): systemd.__salt__, {'config.get': scope_mock, 'cmd.retcode': self.mock_failure}): - ret = func(self.unit_name) + ret = func(self.unit_name, no_block=no_block) self.assertFalse(ret) self.mock_failure.assert_called_with( systemctl_command, @@ -396,6 +400,7 @@ class SystemdScopeTestCase(TestCase): if runtime: systemctl_command.append('--runtime') systemctl_command.append(self.unit_name + '.service') + scope_prefix = ['systemd-run', '--scope'] args = [self.unit_name, runtime] @@ -427,7 +432,7 @@ class SystemdScopeTestCase(TestCase): ret = func(*args) self.assertTrue(ret) self.mock_run_all_success.assert_called_with( - ['systemd-run', '--scope'] + systemctl_command, + scope_prefix + systemctl_command, python_shell=False, redirect_stderr=True) @@ -440,7 +445,7 @@ class SystemdScopeTestCase(TestCase): CommandExecutionError, func, *args) self.mock_run_all_failure.assert_called_with( - ['systemd-run', '--scope'] + systemctl_command, + scope_prefix + systemctl_command, python_shell=False, redirect_stderr=True) @@ -504,22 +509,32 @@ class SystemdScopeTestCase(TestCase): redirect_stderr=True) def test_start(self): - self._change_state('start') + self._change_state('start', no_block=False) + self._change_state('start', no_block=True) def test_stop(self): - self._change_state('stop') + self._change_state('stop', no_block=False) + self._change_state('stop', no_block=True) def test_restart(self): - self._change_state('restart') + self._change_state('restart', no_block=False) + self._change_state('restart', no_block=True) def test_reload(self): - self._change_state('reload_') + self._change_state('reload_', no_block=False) + self._change_state('reload_', no_block=True) def test_force_reload(self): - self._change_state('force_reload') + self._change_state('force_reload', no_block=False) + self._change_state('force_reload', no_block=True) def test_enable(self): - self._change_state('enable') + self._change_state('enable', no_block=False) + self._change_state('enable', no_block=True) + + def test_disable(self): + self._change_state('disable', no_block=False) + self._change_state('disable', no_block=True) def test_mask(self): self._mask_unmask('mask', False) From f6b9152a9e4c7d592fac8fe3fa682be460fe70a4 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 24 Feb 2017 01:19:35 -0600 Subject: [PATCH 207/370] Add no_block feature to Nitrogen release notes --- doc/topics/releases/nitrogen.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/topics/releases/nitrogen.rst b/doc/topics/releases/nitrogen.rst index 3bb68c0b29..424e540064 100644 --- a/doc/topics/releases/nitrogen.rst +++ b/doc/topics/releases/nitrogen.rst @@ -52,9 +52,21 @@ Grains Changes may need to be adjusted to account for this change. - Add ability to specify disk backing mode in the VMWare salt cloud profile. +State Module Changes +==================== + +- The :py:func:`service.running ` and + :py:func:`service.dead ` states now support a + ``no_block`` argument which, when set to ``True`` on systemd minions, will + start/stop the service using the ``--no-block`` flag in the ``systemctl`` + command. On non-systemd minions, a warning will be issued. + Execution Module Changes ======================== +- Several functions in the :mod:`systemd ` execution + module have gained a ``no_block`` argument, which when set to ``True`` will + use ``--no-block`` in the ``systemctl`` command. - In the :mod:`solarisips ` ``pkg`` module, the default value for the ``refresh`` argument to the ``list_upgrades`` function has been changed from ``False`` to ``True``. This makes the function more From f43445d3de0e9300af6db0dc27d3dca67da0d560 Mon Sep 17 00:00:00 2001 From: twangboy Date: Fri, 24 Feb 2017 15:28:03 -0700 Subject: [PATCH 208/370] Fix test_rendering_includes for Windows --- tests/integration/renderers/test_pydsl.py | 48 +++++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/tests/integration/renderers/test_pydsl.py b/tests/integration/renderers/test_pydsl.py index 90d4426f0c..e5896f3a29 100644 --- a/tests/integration/renderers/test_pydsl.py +++ b/tests/integration/renderers/test_pydsl.py @@ -23,26 +23,40 @@ class PyDSLRendererIncludeTestCase(integration.ModuleCase): inability to load custom modules inside the pydsl renderers. This is a FIXME. ''' - try: - self.run_function('state.sls', ['pydsl.aaa']) + self.run_function('state.sls', ['pydsl.aaa']) - expected = textwrap.dedent('''\ - X1 - X2 - X3 - Y1 extended - Y2 extended - Y3 - hello red 1 - hello green 2 - hello blue 3 - ''') + expected = textwrap.dedent('''\ + X1 + X2 + X3 + Y1 extended + Y2 extended + Y3 + hello red 1 + hello green 2 + hello blue 3 + ''') - with salt.utils.fopen('/tmp/output', 'r') as f: - self.assertEqual(sorted(f.read()), sorted(expected)) + # Windows adds `linefeed` in addition to `newline`. There's also an + # unexplainable space before the `linefeed`... + if salt.utils.is_windows(): + expected = 'X1 \r\n' \ + 'X2 \r\n' \ + 'X3 \r\n' \ + 'Y1 extended \r\n' \ + 'Y2 extended \r\n' \ + 'Y3 \r\n' \ + 'hello red 1 \r\n' \ + 'hello green 2 \r\n' \ + 'hello blue 3 \r\n' + + with salt.utils.fopen('/tmp/output', 'r') as f: + ret = f.read() + + os.remove('/tmp/output') + + self.assertEqual(sorted(ret), sorted(expected)) - finally: - os.remove('/tmp/output') if __name__ == '__main__': from integration import run_tests From 7f79683691e5abd5bf04c6e888ae9e66a9330ac2 Mon Sep 17 00:00:00 2001 From: twangboy Date: Fri, 24 Feb 2017 15:31:55 -0700 Subject: [PATCH 209/370] Add to the whitelist --- tests/whitelist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/whitelist.txt b/tests/whitelist.txt index a80c33b71d..b789385ce8 100644 --- a/tests/whitelist.txt +++ b/tests/whitelist.txt @@ -22,6 +22,7 @@ integration.modules.state integration.modules.sysmod integration.modules.test integration.modules.useradd +integration.renderers.test_pydsl integration.runners.jobs integration.runners.salt integration.runners.winrepo From 4dbd7ead828a0d4596dd26563947d2d8693e9871 Mon Sep 17 00:00:00 2001 From: Sergey Kizunov Date: Fri, 24 Feb 2017 15:14:09 -0600 Subject: [PATCH 210/370] opkg: Add support for spaces in repo names Signed-off-by: Sergey Kizunov --- salt/modules/opkg.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/salt/modules/opkg.py b/salt/modules/opkg.py index 348bca9704..d0a2910293 100644 --- a/salt/modules/opkg.py +++ b/salt/modules/opkg.py @@ -38,7 +38,7 @@ from salt.exceptions import ( CommandExecutionError, MinionError, SaltInvocationError ) -REPO_REGEXP = r'^#?\s*(src|src/gz)\s+[^\s<>]+\s+[^\s<>]+' +REPO_REGEXP = r'^#?\s*(src|src/gz)\s+([^\s<>]+|"[^<>]+")\s+[^\s<>]+' OPKG_CONFDIR = '/etc/opkg' ATTR_MAP = { 'Architecture': 'arch', @@ -993,7 +993,7 @@ def list_repos(): line = line[1:] else: repo['enabled'] = True - cols = line.strip().split() + cols = salt.utils.shlex_split(line.strip()) if cols[0] in 'src': repo['compressed'] = False else: @@ -1038,7 +1038,7 @@ def _del_repo_from_file(alias, filepath): if regex.search(line): if line.startswith('#'): line = line[1:] - cols = line.strip().split() + cols = salt.utils.shlex_split(line.strip()) if alias != cols[1]: output.append(line) with open(filepath, 'w') as fhandle: @@ -1051,7 +1051,11 @@ def _add_new_repo(alias, uri, compressed, enabled=True): ''' repostr = '# ' if not enabled else '' repostr += 'src/gz ' if compressed else 'src ' - repostr += alias + ' ' + uri + '\n' + if ' ' in alias: + repostr += '"' + alias + '" ' + else: + repostr += alias + ' ' + repostr += uri + '\n' conffile = os.path.join(OPKG_CONFDIR, alias + '.conf') with open(conffile, 'a') as fhandle: @@ -1065,7 +1069,8 @@ def _mod_repo_in_file(alias, repostr, filepath): with open(filepath) as fhandle: output = [] for line in fhandle: - if alias not in line: + cols = salt.utils.shlex_split(line.strip()) + if alias not in cols: output.append(line) else: output.append(repostr + '\n') @@ -1161,7 +1166,11 @@ def mod_repo(alias, **kwargs): repostr += 'src/gz ' if kwargs['compressed'] else 'src' else: repostr += 'src/gz' if source['compressed'] else 'src' - repostr += ' {0}'.format(kwargs['alias'] if 'alias' in kwargs else alias) + repo_alias = kwargs['alias'] if 'alias' in kwargs else alias + if ' ' in repo_alias: + repostr += ' "{0}"'.format(repo_alias) + else: + repostr += ' {0}'.format(repo_alias) repostr += ' {0}'.format(kwargs['uri'] if 'uri' in kwargs else source['uri']) _mod_repo_in_file(alias, repostr, source['file']) elif uri and source['uri'] == uri: From fdcb2af61d2208a6416bf860fc3b38e5da4eb9d3 Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Fri, 24 Feb 2017 12:12:31 +0100 Subject: [PATCH 211/370] Add function to obtain specific user info from MongoDB --- salt/modules/mongodb.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py index d9f91e5217..80d362927c 100644 --- a/salt/modules/mongodb.py +++ b/salt/modules/mongodb.py @@ -188,6 +188,35 @@ def version(user=None, password=None, host=None, port=None, database='admin', au return str(err) +def user_find(name, user=None, password=None, host=None, port=None, + database='admin', authdb=None): + ''' + Get single user from MongoDB + + CLI Example: + + .. code-block:: bash + + salt '*' mongodb.user_find + ''' + conn = _connect(user, password, host, port, authdb=authdb) + if not conn: + err_msg = "Failed to connect to MongoDB database {0}:{1}".format(host, port) + log.error(err_msg) + return (False, err_msg) + + mdb = pymongo.database.Database(conn, database) + try: + return mdb.command("usersInfo", name)["users"] + except pymongo.errors.PyMongoError as err: + log.error( + 'Listing users failed with error: {0}'.format( + str(err) + ) + ) + return (False, str(err)) + + def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' List users of a Mongodb database From a597296fe68efc789136dcf349d82559b8b0e66c Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 24 Feb 2017 11:42:25 -0600 Subject: [PATCH 212/370] Handle deprecation of passing string args to load_args_and_kwargs I've checked all of the refs and confirmed that they already properly parse the input before passing the args to this function. We will now be ignoring unconditioned string kwargs passed to this function, and logging these incorrectly passed kwarg(s). --- salt/minion.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 66f2bbdf6d..20a7060f87 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -285,24 +285,15 @@ def load_args_and_kwargs(func, args, data=None, ignore_invalid=False): # above, that would result in a 2nd call to # salt.utils.cli.yamlify_arg(), which could mangle the input. _args.append(arg) - elif string_kwarg: - salt.utils.warn_until( - 'Nitrogen', - 'The list of function args and kwargs should be parsed ' - 'by salt.utils.args.parse_input() before calling ' - 'salt.minion.load_args_and_kwargs().' + if string_kwarg: + log.critical( + 'String kwarg(s) %s passed to ' + 'salt.minion.load_args_and_kwargs(). This is no longer ' + 'supported, so the kwarg(s) will be ignored. Arguments ' + 'passed to salt.minion.load_args_and_kwargs() should be ' + 'passed to salt.utils.args.parse_input() first to load ' + 'and condition them properly.', string_kwarg ) - if argspec.keywords or next(six.iterkeys(string_kwarg)) in argspec.args: - # Function supports **kwargs or is a positional argument to - # the function. - _kwargs.update(string_kwarg) - else: - # **kwargs not in argspec and parsed argument name not in - # list of positional arguments. This keyword argument is - # invalid. - for key, val in six.iteritems(string_kwarg): - invalid_kwargs.append('{0}={1}'.format(key, val)) - continue # if the arg is a dict with __kwarg__ == True, then its a kwarg elif isinstance(arg, dict) and arg.pop('__kwarg__', False) is True: From 0fe5c90a0583a4bd3e3b3dc3bb3d8c3a98f80d2e Mon Sep 17 00:00:00 2001 From: Ronald van Zantvoort Date: Sun, 26 Feb 2017 00:54:40 +0100 Subject: [PATCH 213/370] Py3 compat: Force minions to be a list for local serialized caches --- salt/returners/local_cache.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/returners/local_cache.py b/salt/returners/local_cache.py index d46cb1e70c..6c13f9c863 100644 --- a/salt/returners/local_cache.py +++ b/salt/returners/local_cache.py @@ -239,6 +239,7 @@ def save_minions(jid, minions, syndic_id=None): ''' Save/update the serialized list of minions for a given job ''' + minions = list(minions) log.debug( 'Adding minions for job %s%s: %s', jid, From 503216e5c50e2b4c72ca1d21c689f07f86485dec Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 25 Feb 2017 16:06:52 -0600 Subject: [PATCH 214/370] Add warnings to test suite when requisites are not installed Since we have recently changed the test suite to use new-style git_pillar, GitPython or Pygit2 is a hard dep for the test suite. Additionally, when starting up the daemons, if no IPv4 addresses can be detected (which can happen on docker containers which tend to have minimal installs) then the suite will time out trying to detect whether or not the minion/sub-minion has connected, which while it does not prove fatal for the test suite, it does make the suite take several minutes to start up and begin running tests. This is because the test suite invokes the manage.joined runner, which in turn invokes salt.utils.network.ip_addrs() to get the system's IP addresses to match against those which are connected. If it can't get the IP addresses, then the manage.joined runner returns an empty list, and the test suite believes that no minions have connected, and the function that periodically runs manage.joined will eventually time out. This commit adds messages to the console when no suitable gitfs provider is installed, and when salt.utils.network.ip_addrs() returns an empty list, to hopefully prompt the user to install the missing requisites. --- tests/integration/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 2d5b03a7d5..455b346202 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -60,6 +60,7 @@ import salt.runner import salt.output import salt.version import salt.utils +import salt.utils.network import salt.utils.process import salt.log.setup as salt_log_setup from salt.ext import six @@ -68,6 +69,12 @@ from salt.utils.immutabletypes import freeze from salt.utils.nb_popen import NonBlockingPopen from salt.exceptions import SaltClientError +try: + from salt.utils.gitfs import HAS_GITPYTHON, HAS_PYGIT2 + HAS_GITFS = HAS_GITPYTHON or HAS_PYGIT2 +except ImportError: + HAS_GITFS = False + try: from shlex import quote as _quote # pylint: disable=E0611 except ImportError: @@ -695,6 +702,14 @@ class TestDaemon(object): # Set up PATH to mockbin self._enter_mockbin() + if not HAS_GITFS: + sys.stdout.write( + ' * {LIGHT_RED}No suitable provider for git_pillar is installed. Install\n' + ' GitPython or Pygit2.{ENDC}\n'.format( + **self.colors + ) + ) + if self.parser.options.transport == 'zeromq': self.start_zeromq_daemons() elif self.parser.options.transport == 'raet': @@ -761,6 +776,13 @@ class TestDaemon(object): ''' Fire up the daemons used for zeromq tests ''' + if not salt.utils.network.ip_addrs(): + sys.stdout.write( + ' * {LIGHT_RED}Unable to list IPv4 addresses. Test suite startup will be\n' + ' slower. Install iproute/ifconfig to fix this.{ENDC}\n'.format( + **self.colors + ) + ) self.log_server = ThreadedSocketServer(('localhost', SALT_LOG_PORT), SocketServerRequestHandler) self.log_server_process = threading.Thread(target=self.log_server.serve_forever) self.log_server_process.daemon = True From 79a65aa3b4d641c16c4021f964a9435a77deef05 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 25 Feb 2017 16:35:29 -0600 Subject: [PATCH 215/370] Add GitPython to dev_python27.txt requirements file --- requirements/dev_python27.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/dev_python27.txt b/requirements/dev_python27.txt index 2a7221dbb5..59bffbc8e0 100644 --- a/requirements/dev_python27.txt +++ b/requirements/dev_python27.txt @@ -7,3 +7,4 @@ boto3>=1.2.1 moto>=0.3.6 SaltTesting SaltPyLint>=v2017.2.22 +GitPython>=0.3 From 36c928c53e2cb0c0bc451a0c93b2e2feb14e98fc Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 25 Feb 2017 19:56:16 -0600 Subject: [PATCH 216/370] Pass publish args through salt.utils.args.parse_input() --- salt/daemons/masterapi.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/salt/daemons/masterapi.py b/salt/daemons/masterapi.py index ac8961a0f8..0cf1ec4a22 100644 --- a/salt/daemons/masterapi.py +++ b/salt/daemons/masterapi.py @@ -29,6 +29,7 @@ import salt.minion import salt.search import salt.key import salt.fileserver +import salt.utils.args import salt.utils.atomicfile import salt.utils.event import salt.utils.verify @@ -845,7 +846,7 @@ class RemoteFuncs(object): opts = {} opts.update(self.opts) opts.update({'fun': load['fun'], - 'arg': load['arg'], + 'arg': salt.utils.args.parse_input(load['arg']), 'id': load['id'], 'doc': False, 'conf_file': self.opts['conf_file']}) @@ -895,7 +896,7 @@ class RemoteFuncs(object): # Set up the publication payload pub_load = { 'fun': load['fun'], - 'arg': load['arg'], + 'arg': salt.utils.args.parse_input(load['arg']), 'tgt_type': load.get('tgt_type', 'glob'), 'tgt': load['tgt'], 'ret': load['ret'], @@ -948,7 +949,7 @@ class RemoteFuncs(object): # Set up the publication payload pub_load = { 'fun': load['fun'], - 'arg': load['arg'], + 'arg': salt.utils.args.parse_input(load['arg']), 'tgt_type': load.get('tgt_type', 'glob'), 'tgt': load['tgt'], 'ret': load['ret'], @@ -1524,7 +1525,7 @@ class LocalFuncs(object): 'tgt': load['tgt'], 'user': load['user'], 'fun': load['fun'], - 'arg': load['arg'], + 'arg': salt.utils.args.parse_input(load['arg']), 'minions': minions, } @@ -1576,7 +1577,7 @@ class LocalFuncs(object): # way that won't have a negative impact. pub_load = { 'fun': load['fun'], - 'arg': load['arg'], + 'arg': salt.utils.args.parse_input(load['arg']), 'tgt': load['tgt'], 'jid': load['jid'], 'ret': load['ret'], From a3c20e7d7312a543f1b46c3c3065b79c9310f2e5 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 25 Feb 2017 20:07:16 -0600 Subject: [PATCH 217/370] Squelch warning for virtual grain https://github.com/saltstack/salt/pull/39504 fixed what was a legitimate bug, but in turn this causes this warning to be logged hundreds of times in the minion log on unprivileged containers. This commit changes the log level for this message to debug. --- salt/grains/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/grains/core.py b/salt/grains/core.py index 5a1948391e..c4137e4997 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -688,7 +688,7 @@ def _virtual(osdata): break else: if osdata['kernel'] not in skip_cmds: - log.warning( + log.debug( 'All tools for virtual hardware identification failed to ' 'execute because they do not exist on the system running this ' 'instance or the user does not have the necessary permissions ' From 9f6d08d606aa6d56016b59feee381a910692953e Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 25 Feb 2017 20:11:06 -0600 Subject: [PATCH 218/370] Update tests which used string kwargs --- tests/integration/__init__.py | 4 ++ tests/integration/client/test_kwarg.py | 50 ++++++++--------------- tests/integration/modules/test_cmdmod.py | 18 ++++---- tests/integration/modules/test_cp.py | 7 +--- tests/integration/modules/test_publish.py | 13 +++--- tests/integration/shell/test_arguments.py | 8 +++- 6 files changed, 47 insertions(+), 53 deletions(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 2d5b03a7d5..d61dfb7099 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -1741,6 +1741,10 @@ class ModuleCase(TestCase, SaltClientTestCaseMixIn): know_to_return_none = ( 'file.chown', 'file.chgrp', 'ssh.recv_known_host' ) + if 'f_arg' in kwargs: + kwargs['arg'] = kwargs.pop('f_arg') + if 'f_timeout' in kwargs: + kwargs['timeout'] = kwargs.pop('f_timeout') orig = self.client.cmd( minion_tgt, function, arg, timeout=timeout, kwarg=kwargs ) diff --git a/tests/integration/client/test_kwarg.py b/tests/integration/client/test_kwarg.py index 22a43c8935..5c69243479 100644 --- a/tests/integration/client/test_kwarg.py +++ b/tests/integration/client/test_kwarg.py @@ -21,18 +21,14 @@ class StdTest(integration.ModuleCase): ''' cmd_iter = self.client.cmd_cli( 'minion', - 'test.kwarg', - ['foo=bar', 'baz=quo'], + 'test.arg', + ['foo', 'bar', 'baz'], kwarg={'qux': 'quux'} ) for ret in cmd_iter: data = ret['minion']['ret'] - self.assertIn('foo', data) - self.assertIn('baz', data) - self.assertIn('qux', data) - self.assertEqual(data['foo'], 'bar') - self.assertEqual(data['baz'], 'quo') - self.assertEqual(data['qux'], 'quux') + self.assertEqual(data['args'], ['foo', 'bar', 'baz']) + self.assertEqual(data['kwargs']['qux'], 'quux') def test_iter(self): ''' @@ -40,18 +36,14 @@ class StdTest(integration.ModuleCase): ''' cmd_iter = self.client.cmd_iter( 'minion', - 'test.kwarg', - ['foo=bar', 'baz=quo'], + 'test.arg', + ['foo', 'bar', 'baz'], kwarg={'qux': 'quux'} ) for ret in cmd_iter: data = ret['minion']['ret'] - self.assertIn('foo', data) - self.assertIn('baz', data) - self.assertIn('qux', data) - self.assertEqual(data['foo'], 'bar') - self.assertEqual(data['baz'], 'quo') - self.assertEqual(data['qux'], 'quux') + self.assertEqual(data['args'], ['foo', 'bar', 'baz']) + self.assertEqual(data['kwargs']['qux'], 'quux') def test_iter_no_block(self): ''' @@ -59,20 +51,16 @@ class StdTest(integration.ModuleCase): ''' cmd_iter = self.client.cmd_iter_no_block( 'minion', - 'test.kwarg', - ['foo=bar', 'baz=quo'], + 'test.arg', + ['foo', 'bar', 'baz'], kwarg={'qux': 'quux'} ) for ret in cmd_iter: if ret is None: continue data = ret['minion']['ret'] - self.assertIn('foo', data) - self.assertIn('baz', data) - self.assertIn('qux', data) - self.assertEqual(data['foo'], 'bar') - self.assertEqual(data['baz'], 'quo') - self.assertEqual(data['qux'], 'quux') + self.assertEqual(data['args'], ['foo', 'bar', 'baz']) + self.assertEqual(data['kwargs']['qux'], 'quux') def test_full_returns(self): ''' @@ -80,17 +68,13 @@ class StdTest(integration.ModuleCase): ''' ret = self.client.cmd_full_return( 'minion', - 'test.kwarg', - ['foo=bar', 'baz=quo'], + 'test.arg', + ['foo', 'bar', 'baz'], kwarg={'qux': 'quux'} ) - data = ret['minion'] - self.assertIn('foo', data['ret']) - self.assertIn('baz', data['ret']) - self.assertIn('qux', data['ret']) - self.assertEqual(data['ret']['foo'], 'bar') - self.assertEqual(data['ret']['baz'], 'quo') - self.assertEqual(data['ret']['qux'], 'quux') + data = ret['minion']['ret'] + self.assertEqual(data['args'], ['foo', 'bar', 'baz']) + self.assertEqual(data['kwargs']['qux'], 'quux') def test_kwarg_type(self): ''' diff --git a/tests/integration/modules/test_cmdmod.py b/tests/integration/modules/test_cmdmod.py index ca6e4f13d5..8019c7d25e 100644 --- a/tests/integration/modules/test_cmdmod.py +++ b/tests/integration/modules/test_cmdmod.py @@ -262,19 +262,21 @@ class CMDModuleTest(integration.ModuleCase): ''' cmd.run trigger timeout ''' - out = self.run_function('cmd.run', ['sleep 2 && echo hello', 'timeout=1']) - - self.assertTrue( - 'Timed out' in self.run_function( - 'cmd.run', ['sleep 2 && echo hello', 'timeout=1'], python_shell=True)) + out = self.run_function('cmd.run', + ['sleep 2 && echo hello'], + f_timeout=1, + python_shell=True) + self.assertTrue('Timed out' in out) def test_timeout_success(self): ''' cmd.run sufficient timeout to succeed ''' - self.assertTrue( - 'hello' == self.run_function( - 'cmd.run', ['sleep 1 && echo hello', 'timeout=2'], python_shell=True)) + out = self.run_function('cmd.run', + ['sleep 1 && echo hello'], + f_timeout=2, + python_shell=True) + self.assertEqual(out, 'hello') def test_run_cwd_doesnt_exist_issue_7154(self): ''' diff --git a/tests/integration/modules/test_cp.py b/tests/integration/modules/test_cp.py index 0b70291be0..d14e11a39d 100644 --- a/tests/integration/modules/test_cp.py +++ b/tests/integration/modules/test_cp.py @@ -106,11 +106,8 @@ class CPModuleTest(integration.ModuleCase): tgt = os.path.join(integration.TMP, 'scene33') self.run_function( 'cp.get_template', - [ - 'salt://grail/scene33', - tgt, - 'spam=bacon', - ]) + ['salt://grail/scene33', tgt], + spam='bacon') with salt.utils.fopen(tgt, 'r') as scene: data = scene.read() self.assertIn('bacon', data) diff --git a/tests/integration/modules/test_publish.py b/tests/integration/modules/test_publish.py index 3e6952199e..52152dddbf 100644 --- a/tests/integration/modules/test_publish.py +++ b/tests/integration/modules/test_publish.py @@ -25,7 +25,8 @@ class PublishModuleTest(integration.ModuleCase, ret = self.run_function( 'publish.publish', - ['minion', 'test.kwarg', 'arg="cheese=spam"'] + ['minion', 'test.kwarg'], + f_arg='cheese=spam' ) ret = ret['minion'] @@ -45,7 +46,7 @@ class PublishModuleTest(integration.ModuleCase, self.assertTrue(name in ret) self.assertEqual(ret['cheese'], 'spam') - self.assertEqual(ret['__pub_arg'], ['cheese=spam']) + self.assertEqual(ret['__pub_arg'], [{'cheese': 'spam'}]) self.assertEqual(ret['__pub_id'], 'minion') self.assertEqual(ret['__pub_fun'], 'test.kwarg') @@ -99,7 +100,8 @@ class PublishModuleTest(integration.ModuleCase, ''' ret = self.run_function( 'publish.full_data', - ['minion', 'test.kwarg', 'arg="cheese=spam"'] + ['minion', 'test.kwarg'], + f_arg='cheese=spam' ) ret = ret['minion']['ret'] @@ -119,13 +121,14 @@ class PublishModuleTest(integration.ModuleCase, self.assertTrue(name in ret) self.assertEqual(ret['cheese'], 'spam') - self.assertEqual(ret['__pub_arg'], ['cheese=spam']) + self.assertEqual(ret['__pub_arg'], [{'cheese': 'spam'}]) self.assertEqual(ret['__pub_id'], 'minion') self.assertEqual(ret['__pub_fun'], 'test.kwarg') ret = self.run_function( 'publish.full_data', - ['minion', 'test.kwarg', 'cheese=spam'] + ['minion', 'test.kwarg'], + cheese='spam' ) self.assertIn( 'The following keyword arguments are not valid', ret diff --git a/tests/integration/shell/test_arguments.py b/tests/integration/shell/test_arguments.py index efa757a725..c3e66a2c44 100644 --- a/tests/integration/shell/test_arguments.py +++ b/tests/integration/shell/test_arguments.py @@ -13,6 +13,7 @@ ensure_in_syspath('../../') # Import Salt libs import integration +import salt.utils.args @requires_salt_modules('test.ping', 'test.arg') @@ -25,7 +26,7 @@ class ArgumentTestCase(integration.ModuleCase): ''' self.assertIn( ("ERROR executing 'test.ping': The following keyword arguments"), - self.run_function('test.ping', ['foo=bar']) + self.run_function('test.ping', foo='bar') ) def test_kwarg_name_containing_dashes(self): @@ -34,9 +35,12 @@ class ArgumentTestCase(integration.ModuleCase): are properly identified as kwargs. If this fails, then the KWARG_REGEX variable in salt/utils/__init__.py needs to be fixed. ''' + # We need to use parse_input here because run_function now requires + # kwargs to be passed in as *actual* kwargs, and dashes are not valid + # characters in Python kwargs. self.assertEqual( self.run_function( - 'test.arg', ['foo-bar=baz'] + 'test.arg', salt.utils.args.parse_input(['foo-bar=baz']) ).get('kwargs', {}).get('foo-bar'), 'baz' ) From e540b4616ebccb0971f5c3642344b09a2b72035b Mon Sep 17 00:00:00 2001 From: Mike Place Date: Sat, 25 Feb 2017 19:24:02 -0700 Subject: [PATCH 219/370] Update Solaris installation document The OpenCSW packages are no longer maintained. Include details about installing via setup.py. --- doc/topics/installation/solaris.rst | 126 ++-------------------------- 1 file changed, 8 insertions(+), 118 deletions(-) diff --git a/doc/topics/installation/solaris.rst b/doc/topics/installation/solaris.rst index c746932897..549f053fb2 100644 --- a/doc/topics/installation/solaris.rst +++ b/doc/topics/installation/solaris.rst @@ -2,129 +2,19 @@ Solaris ======= -Salt was added to the OpenCSW package repository in September of 2012 by Romeo -Theriault at version 0.10.2 of Salt. It has mainly been -tested on Solaris 10 (sparc), though it is built for and has been tested -minimally on Solaris 10 (x86), Solaris 9 (sparc/x86) and 11 (sparc/x86). -(Please let me know if you're using it on these platforms!) Most of the testing -has also just focused on the minion, though it has verified that the master -starts up successfully on Solaris 10. +Salt is known to work on Solaris but community packages are unmaintained. -Comments and patches for better support on these platforms is very welcome. +It is possible to install Salt on Solaris by using `setuptools`. -As of version 0.10.4, Solaris is well supported under salt, with all of the -following working well: - -1. remote execution -2. grain detection -3. service control with SMF -4. 'pkg' states with 'pkgadd' and 'pkgutil' modules -5. cron modules/states -6. user and group modules/states -7. shadow password management modules/states - -Salt is dependent on the following additional packages. These will -automatically be installed as dependencies of the ``py_salt`` package: - -- py_yaml -- py_pyzmq -- py_jinja2 -- py_msgpack_python -- py_m2crypto -- py_crypto -- python - -Installation -============ - -To install Salt from the OpenCSW package repository you first need to install -`pkgutil`_ assuming you don't already have it installed: - -On Solaris 10: +For example, to install the develop version of salt: .. code-block:: bash - pkgadd -d http://get.opencsw.org/now - -On Solaris 9: - -.. code-block:: bash - - wget http://mirror.opencsw.org/opencsw/pkgutil.pkg - pkgadd -d pkgutil.pkg all - -Once pkgutil is installed you'll need to edit it's config file -``/etc/opt/csw/pkgutil.conf`` to point it at the unstable catalog: - -.. code-block:: diff - - - #mirror=http://mirror.opencsw.org/opencsw/testing - + mirror=http://mirror.opencsw.org/opencsw/unstable - -OK, time to install salt. - -.. code-block:: bash - - # Update the catalog - root> /opt/csw/bin/pkgutil -U - # Install salt - root> /opt/csw/bin/pkgutil -i -y py_salt - -Minion Configuration -==================== - -Now that salt is installed you can find it's configuration files in -``/etc/opt/csw/salt/``. - -You'll want to edit the minion config file to set the name of your salt master -server: - -.. code-block:: diff - - - #master: salt - + master: your-salt-server - -If you would like to use `pkgutil`_ as the default package provider for your -Solaris minions, you can do so using the :conf_minion:`providers` option in the -minion config file. - -You can now start the salt minion like so: - -On Solaris 10: - -.. code-block:: bash - - svcadm enable salt-minion + git clone https://github.com/saltstack/salt + cd salt + sudo python setup.py install --force -On Solaris 9: +.. note:: -.. code-block:: bash - - /etc/init.d/salt-minion start - -You should now be able to log onto the salt master and check to see if the -salt-minion key is awaiting acceptance: - -.. code-block:: bash - - salt-key -l un - -Accept the key: - -.. code-block:: bash - - salt-key -a - -Run a simple test against the minion: - -.. code-block:: bash - - salt '' test.ping - -Troubleshooting -=============== - -Logs are in ``/var/log/salt`` - -.. _pkgutil: http://www.opencsw.org/manual/for-administrators/getting-started.html \ No newline at end of file + SaltStack does offer commerical support for Solaris which includes packages. From b02ef984f70d77a12b73183dbdc8dbc32e292fea Mon Sep 17 00:00:00 2001 From: Mike Place Date: Sat, 25 Feb 2017 19:34:39 -0700 Subject: [PATCH 220/370] Add comment --- salt/returners/local_cache.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/salt/returners/local_cache.py b/salt/returners/local_cache.py index 6c13f9c863..c2b58c1a14 100644 --- a/salt/returners/local_cache.py +++ b/salt/returners/local_cache.py @@ -239,7 +239,9 @@ def save_minions(jid, minions, syndic_id=None): ''' Save/update the serialized list of minions for a given job ''' + # Ensure we have a list for Python 3 compatability minions = list(minions) + log.debug( 'Adding minions for job %s%s: %s', jid, From 2cae9dd8a347e132211b4416cbb37e87c98cac1e Mon Sep 17 00:00:00 2001 From: dharper Date: Fri, 24 Feb 2017 13:59:52 -0600 Subject: [PATCH 221/370] Checking instance exists in master._get_cached_minion_data when cache.fetch returns None --- salt/cache/__init__.py | 4 ++-- salt/cache/consul.py | 2 +- salt/cache/localfs.py | 2 +- salt/cache/redis_cache.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/salt/cache/__init__.py b/salt/cache/__init__.py index f90e8674fb..e4176cd54e 100644 --- a/salt/cache/__init__.py +++ b/salt/cache/__init__.py @@ -143,8 +143,8 @@ class Cache(object): added by the driver itself. :return: - Return a python object fetched from the cache or None if the given - path or key not found. + Return a python object fetched from the cache or and empty dict if + the given path or key not found. :raises SaltCacheError: Raises an exception if cache driver detected an error accessing data diff --git a/salt/cache/consul.py b/salt/cache/consul.py index 0f86c1ae16..8fee000db5 100644 --- a/salt/cache/consul.py +++ b/salt/cache/consul.py @@ -104,7 +104,7 @@ def fetch(bank, key): try: _, value = api.kv.get(c_key) if value is None: - return value + return {} return __context__['serial'].loads(value['Value']) except Exception as exc: raise SaltCacheError( diff --git a/salt/cache/localfs.py b/salt/cache/localfs.py index 48bed3859e..339f9bf1bc 100644 --- a/salt/cache/localfs.py +++ b/salt/cache/localfs.py @@ -64,7 +64,7 @@ def fetch(bank, key, cachedir): key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key)) if not os.path.isfile(key_file): log.debug('Cache file "%s" does not exist', key_file) - return None + return {} try: with salt.utils.fopen(key_file, 'rb') as fh_: return __context__['serial'].load(fh_) diff --git a/salt/cache/redis_cache.py b/salt/cache/redis_cache.py index 975ac79d23..6678787efd 100644 --- a/salt/cache/redis_cache.py +++ b/salt/cache/redis_cache.py @@ -310,7 +310,7 @@ def fetch(bank, key): log.error(mesg) raise SaltCacheError(mesg) if redis_value is None: - return redis_value + return {} return __context__['serial'].loads(redis_value) From e2bd38a1dd3fcd6c8eceadcc64bd362407fb3da2 Mon Sep 17 00:00:00 2001 From: Dennis Harper Date: Sun, 26 Feb 2017 09:03:26 -0600 Subject: [PATCH 222/370] Update __init__.py --- salt/cache/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/cache/__init__.py b/salt/cache/__init__.py index e4176cd54e..542233dad5 100644 --- a/salt/cache/__init__.py +++ b/salt/cache/__init__.py @@ -143,7 +143,7 @@ class Cache(object): added by the driver itself. :return: - Return a python object fetched from the cache or and empty dict if + Return a python object fetched from the cache or an empty dict if the given path or key not found. :raises SaltCacheError: From 1d992f7bae8e6149b8a4ad0071a40911165c8540 Mon Sep 17 00:00:00 2001 From: Christian McHugh Date: Sun, 26 Feb 2017 17:29:47 +0000 Subject: [PATCH 223/370] Cleanup lint errors --- salt/states/zabbix_host.py | 4 ++-- salt/states/zabbix_usergroup.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/salt/states/zabbix_host.py b/salt/states/zabbix_host.py index de83e1d88e..c03aacf3d9 100644 --- a/salt/states/zabbix_host.py +++ b/salt/states/zabbix_host.py @@ -212,7 +212,8 @@ def present(host, groups, interfaces, **kwargs): if update_interfaces: if hostinterfaces: for interface in hostinterfaces: - __salt__['zabbix.hostinterface_delete'](interfaceids=interface['interfaceid'], **connection_args) + __salt__['zabbix.hostinterface_delete'](interfaceids=interface['interfaceid'], + **connection_args) hostid = __salt__['zabbix.host_get'](name=host, **connection_args)[0]['hostid'] @@ -423,7 +424,6 @@ def assign_templates(host, templates, **kwargs): if update_host_templates: update_output = __salt__['zabbix.host_update'](hostid, templates=(requested_template_ids), **connection_args) if update_output is False: - print("Failing out: update_output fale") ret['result'] = False ret['comment'] = comment_host_templates_notupdated return ret diff --git a/salt/states/zabbix_usergroup.py b/salt/states/zabbix_usergroup.py index cbbaa684a9..32ff9b3b31 100644 --- a/salt/states/zabbix_usergroup.py +++ b/salt/states/zabbix_usergroup.py @@ -101,21 +101,27 @@ def present(name, **kwargs): ret['comment'] = comment_usergroup_updated if update_debug_mode: - updated_debug = __salt__['zabbix.usergroup_update'](usrgrpid, debug_mode=kwargs['debug_mode'], **connection_args) + updated_debug = __salt__['zabbix.usergroup_update'](usrgrpid, + debug_mode=kwargs['debug_mode'], + **connection_args) if 'error' in updated_debug: error.append(updated_debug['error']) else: ret['changes']['debug_mode'] = kwargs['debug_mode'] if update_gui_access: - updated_gui = __salt__['zabbix.usergroup_update'](usrgrpid, gui_access=kwargs['gui_access'], **connection_args) + updated_gui = __salt__['zabbix.usergroup_update'](usrgrpid, + gui_access=kwargs['gui_access'], + **connection_args) if 'error' in updated_gui: error.append(updated_gui['error']) else: ret['changes']['gui_access'] = kwargs['gui_access'] if update_users_status: - updated_status = __salt__['zabbix.usergroup_update'](usrgrpid, users_status=kwargs['users_status'], **connection_args) + updated_status = __salt__['zabbix.usergroup_update'](usrgrpid, + users_status=kwargs['users_status'], + **connection_args) if 'error' in updated_status: error.append(updated_status['error']) else: From 5a3c099e4f9c57d90a6597ab14841779cb86ac21 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sun, 26 Feb 2017 12:21:00 -0600 Subject: [PATCH 224/370] Rewrite the tests_valid_docs test This uses a function in the runtests_helpers custom module to perform all the logic, and only returns what failed the test. This saves us from having to return the entire contents of sys.doc (as well as log all of the function calls), and also removes the need to run sys.doc in batches to get around the "max message size" issue. --- salt/minion.py | 16 +++- salt/modules/sysmod.py | 6 +- tests/integration/__init__.py | 7 ++ .../file/base/_modules/runtests_helpers.py | 70 ++++++++++++++++ .../integration/files/reactor-sync-minion.sls | 3 + tests/integration/modules/sysmod.py | 79 +------------------ 6 files changed, 102 insertions(+), 79 deletions(-) create mode 100644 tests/integration/files/reactor-sync-minion.sls diff --git a/salt/minion.py b/salt/minion.py index 21d2d9f547..84dc4f2b86 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -679,7 +679,13 @@ class SMinion(MinionBase): def gen_modules(self, initial_load=False): ''' - Load all of the modules for the minion + Tell the minion to reload the execution modules + + CLI Example: + + .. code-block:: bash + + salt '*' sys.reload_modules ''' self.opts['pillar'] = salt.pillar.get_pillar( self.opts, @@ -734,7 +740,13 @@ class MasterMinion(object): def gen_modules(self, initial_load=False): ''' - Load all of the modules for the minion + Tell the minion to reload the execution modules + + CLI Example: + + .. code-block:: bash + + salt '*' sys.reload_modules ''' self.utils = salt.loader.utils(self.opts) self.functions = salt.loader.minion_mods( diff --git a/salt/modules/sysmod.py b/salt/modules/sysmod.py index 574c8d1aa2..a7c731e93e 100644 --- a/salt/modules/sysmod.py +++ b/salt/modules/sysmod.py @@ -421,8 +421,10 @@ def reload_modules(): salt '*' sys.reload_modules ''' - # This is handled inside the minion.py file, the function is caught before - # it ever gets here + # This function is actually handled inside the minion.py file, the function + # is caught before it ever gets here. Therefore, the docstring above is + # only for the online docs, and ANY CHANGES made to it must also be made in + # each of the gen_modules() funcs in minion.py. return True diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 104566363a..d3a901ef8c 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -1138,6 +1138,13 @@ class TestDaemon(object): TMP_PRODENV_STATE_TREE ] } + master_opts.setdefault('reactor', []).append( + { + 'salt/minion/*/start': [ + os.path.join(FILES, 'reactor-sync-minion.sls') + ], + } + ) for opts_dict in (master_opts, syndic_master_opts): if 'ext_pillar' not in opts_dict: opts_dict['ext_pillar'] = [] diff --git a/tests/integration/files/file/base/_modules/runtests_helpers.py b/tests/integration/files/file/base/_modules/runtests_helpers.py index 238b79cc41..c725e02814 100644 --- a/tests/integration/files/file/base/_modules/runtests_helpers.py +++ b/tests/integration/files/file/base/_modules/runtests_helpers.py @@ -9,12 +9,16 @@ # Import python libs from __future__ import absolute_import +import fnmatch import os +import re import tempfile # Import salt libs import salt.utils +# Import 3rd-party libs +import salt.ext.six as six SYS_TMP_DIR = os.path.realpath( # Avoid ${TMPDIR} and gettempdir() on MacOS as they yield a base path too long @@ -29,9 +33,75 @@ TMP = os.path.join(SYS_TMP_DIR, 'salt-tests-tmpdir') def get_salt_temp_dir(): return TMP + def get_salt_temp_dir_for_path(*path): return os.path.join(TMP, *path) def get_sys_temp_dir_for_path(*path): return os.path.join(SYS_TMP_DIR, *path) + + +def get_invalid_docs(): + ''' + Outputs the functions which do not have valid CLI example, or are missing a + docstring. + ''' + allow_failure = ( + 'cmd.win_runas', + 'cp.recv', + 'glance.warn_until', + 'ipset.long_range', + 'libcloud_dns.get_driver', + 'log.critical', + 'log.debug', + 'log.error', + 'log.exception', + 'log.info', + 'log.warning', + 'lowpkg.bin_pkg_info', + 'lxc.run_cmd', + 'nspawn.restart', + 'nspawn.stop', + 'pkg.expand_repo_def', + 'pip.iteritems', + 'runtests_decorators.depends', + 'runtests_decorators.depends_will_fallback', + 'runtests_decorators.missing_depends', + 'runtests_decorators.missing_depends_will_fallback', + 'state.apply', + 'status.list2cmdline', + 'swift.head', + 'travisci.parse_qs', + 'vsphere.clean_kwargs', + 'vsphere.disconnect', + 'vsphere.get_service_instance_via_proxy', + 'vsphere.gets_service_instance_via_proxy', + 'vsphere.supports_proxies', + 'vsphere.test_vcenter_connection', + 'vsphere.wraps', + ) + allow_failure_glob = ( + 'runtests_helpers.*', + ) + nodoc = set() + noexample = set() + for fun, docstring in six.iteritems(__salt__['sys.doc']()): + if fun in allow_failure: + continue + else: + for pat in allow_failure_glob: + if fnmatch.fnmatch(fun, pat): + matched_glob = True + break + else: + matched_glob = False + if matched_glob: + continue + if not isinstance(docstring, six.string_types): + nodoc.add(fun) + elif not re.search(r'([E|e]xample(?:s)?)+(?:.*):?', docstring): + noexample.add(fun) + + return {'missing_docstring': sorted(nodoc), + 'missing_cli_example': sorted(noexample)} diff --git a/tests/integration/files/reactor-sync-minion.sls b/tests/integration/files/reactor-sync-minion.sls new file mode 100644 index 0000000000..bfd89b5439 --- /dev/null +++ b/tests/integration/files/reactor-sync-minion.sls @@ -0,0 +1,3 @@ +sync_minion: + local.saltutil.sync_all: + - tgt: {{ data['id'] }} diff --git a/tests/integration/modules/sysmod.py b/tests/integration/modules/sysmod.py index b432fd1c06..5f351a8491 100644 --- a/tests/integration/modules/sysmod.py +++ b/tests/integration/modules/sysmod.py @@ -2,10 +2,6 @@ # Import python libs from __future__ import absolute_import -import logging -import re - -log = logging.getLogger(__name__) # Import Salt Testing libs from salttesting.helpers import ensure_in_syspath @@ -14,9 +10,6 @@ ensure_in_syspath('../../') # Import salt libs import integration -# Import 3rd-party libs -import salt.ext.six as six - class SysModuleTest(integration.ModuleCase): ''' @@ -26,79 +19,15 @@ class SysModuleTest(integration.ModuleCase): ''' Make sure no functions are exposed that don't have valid docstrings ''' - mods = self.run_function('sys.list_modules') - nodoc = set() - noexample = set() - allow_failure = ( - 'cp.recv', - 'libcloud_dns.get_driver', - 'lxc.run_cmd', - 'ipset.long_range', - 'pkg.expand_repo_def', - 'runtests_decorators.depends', - 'runtests_decorators.depends_will_fallback', - 'runtests_decorators.missing_depends', - 'runtests_decorators.missing_depends_will_fallback', - 'swift.head', - 'glance.warn_until', - 'yumpkg.expand_repo_def', - 'yumpkg5.expand_repo_def', - 'container_resource.run', - 'nspawn.stop', - 'nspawn.restart', - 'lowpkg.bin_pkg_info', - 'state.apply', - 'pip.iteritems', - 'cmd.win_runas', - 'status.list2cmdline' - ) - - batches = 2 - mod_count = len(mods) - batch_size = mod_count / float(batches) - if batch_size.is_integer(): - batch_size = int(batch_size) - else: - # Check if the module count is evenly divisible by the number of - # batches. If not, increase the batch_size by the number of batches - # being run. This ensures that we get the correct number of - # batches, and that we don't end up running sys.doc an extra time - # to cover the remainder. For example, if we had a batch count of 2 - # and 121 modules, if we just divided by 2 we'd end up running - # sys.doc 3 times. - batch_size = int(batch_size) + batches - - log.debug('test_valid_docs batch size = %s', batch_size) - start = 0 - end = batch_size - while start <= mod_count: - log.debug('running sys.doc on mods[%s:%s]', start, end) - docs = self.run_function('sys.doc', mods[start:end]) - if docs == 'VALUE TRIMMED': - self.fail( - 'sys.doc output trimmed. It may be necessary to increase ' - 'the number of batches' - ) - for fun in docs: - if fun.startswith('runtests_helpers'): - continue - if fun in allow_failure: - continue - if not isinstance(docs[fun], six.string_types): - nodoc.add(fun) - elif not re.search(r'([E|e]xample(?:s)?)+(?:.*)::?', docs[fun]): - noexample.add(fun) - start += batch_size - end += batch_size - - if not nodoc and not noexample: + ret = self.run_function('runtests_helpers.get_invalid_docs') + if ret == {'missing_docstring': [], 'missing_cli_example': []}: return raise AssertionError( 'There are some functions which do not have a docstring or do not ' 'have an example:\nNo docstring:\n{0}\nNo example:\n{1}\n'.format( - '\n'.join([' - {0}'.format(f) for f in sorted(nodoc)]), - '\n'.join([' - {0}'.format(f) for f in sorted(noexample)]), + '\n'.join([' - {0}'.format(f) for f in ret['missing_docstring']]), + '\n'.join([' - {0}'.format(f) for f in ret['missing_cli_example']]), ) ) From 78a185ab11b23cfb59ec30cfa40883f48a8c564f Mon Sep 17 00:00:00 2001 From: Felix Dreissig Date: Sun, 26 Feb 2017 22:49:29 +0100 Subject: [PATCH 225/370] Fix comments about file backup directory The actual file state backup directory is called "file_backup" without a trailing 's'. --- conf/minion | 2 +- conf/proxy | 2 +- doc/man/salt.7 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/minion b/conf/minion index 17b31848d1..4ec93055d1 100644 --- a/conf/minion +++ b/conf/minion @@ -161,7 +161,7 @@ # strip_colors: False # Backup files that are replaced by file.managed and file.recurse under -# 'cachedir'/file_backups relative to their original location and appended +# 'cachedir'/file_backup relative to their original location and appended # with a timestamp. The only valid setting is "minion". Disabled by default. # # Alternatively this can be specified for each file in state files: diff --git a/conf/proxy b/conf/proxy index 240f9637ac..4754abd437 100644 --- a/conf/proxy +++ b/conf/proxy @@ -119,7 +119,7 @@ # strip_colors: False # Backup files that are replaced by file.managed and file.recurse under -# 'cachedir'/file_backups relative to their original location and appended +# 'cachedir'/file_backup relative to their original location and appended # with a timestamp. The only valid setting is "minion". Disabled by default. # # Alternatively this can be specified for each file in state files: diff --git a/doc/man/salt.7 b/doc/man/salt.7 index 66c64263df..ea368c3093 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -12459,7 +12459,7 @@ event that an error is introduced in the latest revision of the repo. # strip_colors: False # Backup files that are replaced by file.managed and file.recurse under -# \(aqcachedir\(aq/file_backups relative to their original location and appended +# \(aqcachedir\(aq/file_backup relative to their original location and appended # with a timestamp. The only valid setting is "minion". Disabled by default. # # Alternatively this can be specified for each file in state files: From 5371bc099695e0a676c0305297e184010a1ac740 Mon Sep 17 00:00:00 2001 From: Felix Dreissig Date: Sun, 26 Feb 2017 23:24:54 +0100 Subject: [PATCH 226/370] Fix comments about the "hash_type" option Previous mentions of the correct default value (it really is sha256) somehow got lost along the way. Also, some comments seem to have gotten duplicated instead of updated. --- conf/master | 8 ++++---- conf/minion | 9 +++------ doc/man/salt.7 | 29 +++++++++++++---------------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/conf/master b/conf/master index 3cad148c37..044aa23b6a 100644 --- a/conf/master +++ b/conf/master @@ -549,11 +549,11 @@ #default_top: base # The hash_type is the hash to use when discovering the hash of a file on -# the master server. The default is md5 but sha1, sha224, sha256, sha384 -# and sha512 are also supported. +# the master server. The default is sha256, but md5, sha1, sha224, sha384 and +# sha512 are also supported. # -# WARNING: While md5 is also supported, do not use it due to the high chance -# of possible collisions and thus security breach. +# WARNING: While md5 and sha1 are also supported, do not use them due to the +# high chance of possible collisions and thus security breach. # # Prior to changing this value, the master should be stopped and all Salt # caches should be cleared. diff --git a/conf/minion b/conf/minion index 17b31848d1..5ee794d910 100644 --- a/conf/minion +++ b/conf/minion @@ -574,14 +574,11 @@ #fileserver_limit_traversal: False # The hash_type is the hash to use when discovering the hash of a file on -# the local fileserver. The default is md5, but sha1, sha224, sha256, sha384 +# the local fileserver. The default is sha256, but md5, sha1, sha224, sha384 # and sha512 are also supported. # -# WARNING: While md5 and sha1 are also supported, do not use it due to the high chance -# of possible collisions and thus security breach. -# -# WARNING: While md5 is also supported, do not use it due to the high chance -# of possible collisions and thus security breach. +# WARNING: While md5 and sha1 are also supported, do not use them due to the +# high chance of possible collisions and thus security breach. # # Warning: Prior to changing this value, the minion should be stopped and all # Salt caches should be cleared. diff --git a/doc/man/salt.7 b/doc/man/salt.7 index 66c64263df..31a13d8ac9 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -6093,17 +6093,17 @@ fileserver_list_cache_time: 5 .UNINDENT .SS \fBhash_type\fP .sp -Default: \fBmd5\fP +Default: \fBsha256\fP .sp The hash_type is the hash to use when discovering the hash of a file on -the master server. The default is md5, but sha1, sha224, sha256, sha384, and +the master server. The default is sha256, but md5, sha1, sha224, sha384, and sha512 are also supported. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C -hash_type: md5 +hash_type: sha256 .ft P .fi .UNINDENT @@ -10539,17 +10539,17 @@ fileserver_limit_traversal: False .UNINDENT .SS \fBhash_type\fP .sp -Default: \fBmd5\fP +Default: \fBsha256\fP .sp The hash_type is the hash to use when discovering the hash of a file on the -local fileserver. The default is md5, but sha1, sha224, sha256, sha384, and +local fileserver. The default is sha256, but md5, sha1, sha224, sha384, and sha512 are also supported. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C -hash_type: md5 +hash_type: sha256 .ft P .fi .UNINDENT @@ -11776,11 +11776,11 @@ event that an error is introduced in the latest revision of the repo. #default_top: base # The hash_type is the hash to use when discovering the hash of a file on -# the master server. The default is md5 but sha1, sha224, sha256, sha384 -# and sha512 are also supported. +# the master server. The default is sha256, but md5, sha1, sha224, sha384 and +# sha512 are also supported. # -# WARNING: While md5 is also supported, do not use it due to the high chance -# of possible collisions and thus security breach. +# WARNING: While md5 and sha1 are also supported, do not use them due to the +# high chance of possible collisions and thus security breach. # # Prior to changing this value, the master should be stopped and all Salt # caches should be cleared. @@ -12867,14 +12867,11 @@ event that an error is introduced in the latest revision of the repo. #fileserver_limit_traversal: False # The hash_type is the hash to use when discovering the hash of a file on -# the local fileserver. The default is md5, but sha1, sha224, sha256, sha384 +# the local fileserver. The default is sha256, but md5, sha1, sha224, sha384 # and sha512 are also supported. # -# WARNING: While md5 and sha1 are also supported, do not use it due to the high chance -# of possible collisions and thus security breach. -# -# WARNING: While md5 is also supported, do not use it due to the high chance -# of possible collisions and thus security breach. +# WARNING: While md5 and sha1 are also supported, do not use them due to the +# high chance of possible collisions and thus security breach. # # Warning: Prior to changing this value, the minion should be stopped and all # Salt caches should be cleared. From 876c2c634e46d63a1acfc95f79741da7d93536e5 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 27 Feb 2017 00:35:48 -0600 Subject: [PATCH 227/370] Added range for minute and hour in cron module --- salt/modules/cron.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/salt/modules/cron.py b/salt/modules/cron.py index a4e6cb23a5..f67fb19217 100644 --- a/salt/modules/cron.py +++ b/salt/modules/cron.py @@ -408,6 +408,10 @@ def _get_cron_date_time(**kwargs): value = str(kwargs.get(param, '1')).lower() if value == 'random': ret[param] = str(random.sample(range_max[param], 1)[0]) + elif len(value.split(":")) == 2: + cron_range = sorted(value.split(":")) + start, end = int(cron_range[0]), int(cron_range[1]) + ret[param] = str(random.randint(start, end)) else: ret[param] = value From d4e3bab3e144e6ae030fb2180691c93c6761ef31 Mon Sep 17 00:00:00 2001 From: shellchen Date: Mon, 27 Feb 2017 15:11:32 +0800 Subject: [PATCH 228/370] fix custom conversions --- salt/modules/mysql.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index 2355e9a821..df0f476e6a 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -622,6 +622,22 @@ def query(database, query, **connection_args): conv_iter = iter(orig_conv) conv = dict(zip(conv_iter, [str] * len(orig_conv))) + # some converters are lists, do not break theses + conv_mysqldb = {'MYSQLDB': True} + if conv_mysqldb.get(MySQLdb.__package__.upper()): + conv[FIELD_TYPE.BLOB] = [ + (FLAG.BINARY, str), + ] + conv[FIELD_TYPE.STRING] = [ + (FLAG.BINARY, str), + ] + conv[FIELD_TYPE.VAR_STRING] = [ + (FLAG.BINARY, str), + ] + conv[FIELD_TYPE.VARCHAR] = [ + (FLAG.BINARY, str), + ] + connection_args.update({'connection_db': database, 'connection_conv': conv}) dbc = _connect(**connection_args) if dbc is None: From c71753197a8bfcf943188620f9fdd273c549f24f Mon Sep 17 00:00:00 2001 From: dharper Date: Fri, 24 Feb 2017 13:57:45 -0600 Subject: [PATCH 229/370] Checking instance exists in master._get_cached_minion_data when cache.fetch returns None --- tests/unit/cache/test_localfs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/cache/test_localfs.py b/tests/unit/cache/test_localfs.py index f6d2b97047..08b887aa14 100644 --- a/tests/unit/cache/test_localfs.py +++ b/tests/unit/cache/test_localfs.py @@ -102,10 +102,10 @@ class LocalFSTest(TestCase): @patch('os.path.isfile', MagicMock(return_value=False)) def test_fetch_return_when_cache_file_does_not_exist(self): ''' - Tests that the fetch function returns None when the cache key file doesn't - exist. + Tests that the fetch function returns an empty dic when the cache key file + doesn't exist. ''' - self.assertIsNone(localfs.fetch(bank='', key='', cachedir='')) + self.assertEqual(localfs.fetch(bank='', key='', cachedir=''), {}) @patch('os.path.isfile', MagicMock(return_value=True)) @patch('salt.utils.fopen', MagicMock(side_effect=IOError)) From 598c290dde3102047af5ef758f70215709865c4d Mon Sep 17 00:00:00 2001 From: Dennis Harper Date: Mon, 27 Feb 2017 10:15:06 -0600 Subject: [PATCH 230/370] Update __init__.py --- salt/cache/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/cache/__init__.py b/salt/cache/__init__.py index 542233dad5..431f5de81a 100644 --- a/salt/cache/__init__.py +++ b/salt/cache/__init__.py @@ -143,7 +143,7 @@ class Cache(object): added by the driver itself. :return: - Return a python object fetched from the cache or an empty dict if + Return a python object fetched from the cache or an empty dict if the given path or key not found. :raises SaltCacheError: From b6dea5efb9dc84da1721c4fea6c940c1ce6094ae Mon Sep 17 00:00:00 2001 From: Mike Place Date: Mon, 27 Feb 2017 09:59:25 -0700 Subject: [PATCH 231/370] Correct small bug with docs test. --- tests/integration/modules/test_sysmod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/modules/test_sysmod.py b/tests/integration/modules/test_sysmod.py index ad32111b4d..a2bfb8ff44 100644 --- a/tests/integration/modules/test_sysmod.py +++ b/tests/integration/modules/test_sysmod.py @@ -100,7 +100,7 @@ class SysModuleTest(integration.ModuleCase): continue if isinstance(docs, dict) and not isinstance(docs[fun], six.string_types): nodoc.add(fun) - elif not re.search(r'([E|e]xample(?:s)?)+(?:.*)::?', docs[fun]): + elif isinstance(docs, dict) and not re.search(r'([E|e]xample(?:s)?)+(?:.*)::?', docs[fun]): noexample.add(fun) start += batch_size end += batch_size From 9f370edfdcec09276309997c56ac500500258751 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 27 Feb 2017 12:04:23 -0500 Subject: [PATCH 232/370] Add act entry when a key is denied --- salt/transport/mixins/auth.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/salt/transport/mixins/auth.py b/salt/transport/mixins/auth.py index 808610a530..5a55a20186 100644 --- a/salt/transport/mixins/auth.py +++ b/salt/transport/mixins/auth.py @@ -243,6 +243,7 @@ class AESReqServerMixin(object): fp_.write(load['pub']) eload = {'result': False, 'id': load['id'], + 'act': 'denied', 'pub': load['pub']} self.event.fire_event(eload, salt.utils.event.tagify(prefix='auth')) return {'enc': 'clear', @@ -331,6 +332,7 @@ class AESReqServerMixin(object): fp_.write(load['pub']) eload = {'result': False, 'id': load['id'], + 'act': 'denied', 'pub': load['pub']} self.event.fire_event(eload, salt.utils.event.tagify(prefix='auth')) return {'enc': 'clear', From 73d1693557befff618fb7e5cec5053abfd9e8506 Mon Sep 17 00:00:00 2001 From: rallytime Date: Mon, 27 Feb 2017 10:18:58 -0700 Subject: [PATCH 233/370] [develop] Clean up pylint failures --- salt/states/loop.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/salt/states/loop.py b/salt/states/loop.py index db2506722c..4c8343e01a 100644 --- a/salt/states/loop.py +++ b/salt/states/loop.py @@ -4,6 +4,8 @@ Loop state Allows for looping over execution modules. +.. versionadded:: Nitrogen + .. code-block:: yaml wait_for_service_to_be_healthy: @@ -25,24 +27,23 @@ Allows for looping over execution modules. parameter which is literally evaluated within the state. Please use caution. ''' -from __future__ import absolute_import # Import python libs +from __future__ import absolute_import import logging import time -# Import salt libs -import salt.utils - # Initialize logging log = logging.getLogger(__name__) # Define the module's virtual name __virtualname__ = 'loop' + def __virtual__(): return True + def until(name, m_args=None, m_kwargs=None, @@ -103,7 +104,7 @@ def until(name, while not timed_out(): m_ret = __salt__[name](*m_args, **m_kwargs) - if eval(condition): + if eval(condition): # pylint: disable=W0123 ret['result'] = True ret['comment'] = 'Condition {0} was met'.format(condition) return ret From 1d2788e206a77e2d9ad3559cf14000b8d93c7e4c Mon Sep 17 00:00:00 2001 From: dharper Date: Fri, 24 Feb 2017 13:57:45 -0600 Subject: [PATCH 234/370] Checking instance exists in master._get_cached_minion_data when cache.fetch returns None --- salt/utils/master.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/salt/utils/master.py b/salt/utils/master.py index afd1d4b15a..5516b08d5a 100644 --- a/salt/utils/master.py +++ b/salt/utils/master.py @@ -147,6 +147,12 @@ class MasterPillarUtil(object): continue mdata = self.cache.fetch('minions/{0}'.format(minion_id), 'data') if not isinstance(mdata, dict): + log.warning( + 'cache.fetch should always return a dict. ReturnedType: {0}, MinionId: {1}'.format( + type(mdata).__name__, + minion_id + ) + ) continue if 'grains' in mdata: grains[minion_id] = mdata['grains'] From 88e8a1b1c6eaa4fda99380733c8b57b1d00bc109 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Mon, 27 Feb 2017 12:14:59 -0600 Subject: [PATCH 235/370] add syncing seperate cache modules on the salt master --- doc/ref/configuration/master.rst | 1 + salt/runners/saltutil.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/doc/ref/configuration/master.rst b/doc/ref/configuration/master.rst index b5a431f6df..3faed4081e 100644 --- a/doc/ref/configuration/master.rst +++ b/doc/ref/configuration/master.rst @@ -282,6 +282,7 @@ Valid options: - pillar - utils - sdb + - cache .. conf_master:: module_dirs diff --git a/salt/runners/saltutil.py b/salt/runners/saltutil.py index c593740e0c..904d6105eb 100644 --- a/salt/runners/saltutil.py +++ b/salt/runners/saltutil.py @@ -55,6 +55,7 @@ def sync_all(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ret['pillar'] = sync_pillar(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) ret['utils'] = sync_utils(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) ret['sdb'] = sync_sdb(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) + ret['cache'] = sync_cache(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist) return ret @@ -396,3 +397,29 @@ def sync_sdb(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ''' return salt.utils.extmods.sync(__opts__, 'sdb', saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist)[0] + + +def sync_cache(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): + ''' + .. versionadded:: Nitrogen + + Sync utils modules from ``salt://_cache`` to the master + + saltenv : base + The fileserver environment from which to sync. To sync from more than + one environment, pass a comma-separated list. + + extmod_whitelist : None + comma-seperated list of modules to sync + + extmod_blacklist : None + comma-seperated list of modules to blacklist based on type + + CLI Example: + + .. code-block:: bash + + salt-run saltutil.sync_cache + ''' + return salt.utils.extmods.sync(__opts__, 'cache', saltenv=saltenv, extmod_whitelist=extmod_whitelist, + extmod_blacklist=extmod_blacklist)[0] From 6dac1c710e376ada377b4bcb397615526dbd5996 Mon Sep 17 00:00:00 2001 From: Calle Pettersson Date: Sun, 26 Feb 2017 21:05:36 +0100 Subject: [PATCH 236/370] Vault: Add support for expanding lists in policies --- salt/modules/vault.py | 21 ++++- salt/runners/vault.py | 54 ++++++++++++- tests/unit/runners/test_vault.py | 132 +++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 tests/unit/runners/test_vault.py diff --git a/salt/modules/vault.py b/salt/modules/vault.py index b4c97923c5..348c0e9266 100644 --- a/salt/modules/vault.py +++ b/salt/modules/vault.py @@ -38,8 +38,25 @@ Functions to interact with Hashicorp Vault. Grains are also available, for example like this: ``my-policies/{grains[os]}`` - Optional. If policies is not configured, saltstack/minions and - saltstack/{minion} are used as defaults. + If a template contains a grain which evaluates to a list, it will be + expanded into multiple policies. For example, given the template + ``saltstack/by-role/{grains[roles]}``, and a minion having these grains: + + .. code-block: yaml + + grains: + roles: + - web + - database + + The minion will have the policies ``saltstack/by-role/web`` and + ``saltstack/by-role/database``. Note however that list members which do + not have simple string representations, such as dictionaries or objects, + do not work and will throw an exception. Strings and numbers are + examples of types which work well. + + Optional. If policies is not configured, ``saltstack/minions`` and + ``saltstack/{minion}`` are used as defaults. Add this segment to the master configuration file, or diff --git a/salt/runners/vault.py b/salt/runners/vault.py index 04476eb941..4a8a2c4dbe 100644 --- a/salt/runners/vault.py +++ b/salt/runners/vault.py @@ -11,6 +11,7 @@ documented in the execution module docs. from __future__ import absolute_import import base64 import logging +import string import requests import salt.crypt @@ -117,7 +118,58 @@ def _get_policies(minion_id, config): policies = [] for pattern in policy_patterns: - policies.append(pattern.format(**mappings)) + for expanded_pattern in _expand_pattern_lists(pattern, **mappings): + policies.append(expanded_pattern.format(**mappings)) log.debug('{0} policies: {1}'.format(minion_id, policies)) return policies + + +def _expand_pattern_lists(pattern, **mappings): + ''' + Expands the pattern for any list-valued mappings, such that for any list of + length N in the mappings present in the pattern, N copies of the pattern are + returned, each with an element of the list substituted. + + pattern: + A pattern to expand, for example ``by-role/{grains[roles]}`` + + mappings: + A dictionary of variables that can be expanded into the pattern. + + Example: Given the pattern `` by-role/{grains[roles]}`` and the below grains + + .. code-block:: yaml + + grains: + roles: + - web + - database + + This function will expand into two patterns, + ``[by-role/web, by-role/database]``. + + Note that this method does not expand any non-list patterns. + ''' + expanded_patterns = [] + f = string.Formatter() + ''' + This function uses a string.Formatter to get all the formatting tokens from + the pattern, then recursively replaces tokens whose expanded value is a + list. For a list with N items, it will create N new pattern strings and + then continue with the next token. In practice this is expected to not be + very expensive, since patterns will typically involve a handful of lists at + most. + ''' # pylint: disable=W0105 + for (_, field_name, _, _) in f.parse(pattern): + if field_name is None: + continue + (value, _) = f.get_field(field_name, None, mappings) + if isinstance(value, list): + token = '{{{0}}}'.format(field_name) + expanded = [pattern.replace(token, str(elem)) for elem in value] + for expanded_item in expanded: + result = _expand_pattern_lists(expanded_item, **mappings) + expanded_patterns += result + return expanded_patterns + return [pattern] diff --git a/tests/unit/runners/test_vault.py b/tests/unit/runners/test_vault.py new file mode 100644 index 0000000000..826ab0367c --- /dev/null +++ b/tests/unit/runners/test_vault.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +''' +Unit tests for the Vault runner +''' + +# Import Python Libs +from __future__ import absolute_import +import logging +from salt.ext import six +from salt.runners import vault + +# Import Salt Testing Libs +from salttesting import skipIf, TestCase +from salttesting.helpers import ensure_in_syspath +from salttesting.mock import ( + MagicMock, + patch, + NO_MOCK, + NO_MOCK_REASON +) + + +log = logging.getLogger(__name__) +ensure_in_syspath('../../') + +vault.__opts__ = {} + + +class VaultTest(TestCase): + ''' + Tests for the runner module of the Vault integration + ''' + + def setUp(self): + self.grains = { + 'id': 'test-minion', + 'roles': ['web', 'database'], + 'aux': ['foo', 'bar'], + 'deep': { + 'foo': { + 'bar': { + 'baz': [ + 'hello', + 'world' + ] + } + } + }, + 'dictlist': [ + {'foo': 'bar'}, + {'baz': 'qux'} + ] + } + + def test_pattern_list_expander(self): + ''' + Ensure _expand_pattern_lists works as intended: + - Expand list-valued patterns + - Do not change non-list-valued tokens + ''' + cases = { + 'no-tokens-to-replace': ['no-tokens-to-replace'], + 'single-dict:{minion}': ['single-dict:{minion}'], + 'single-list:{grains[roles]}': ['single-list:web', 'single-list:database'], + 'multiple-lists:{grains[roles]}+{grains[aux]}': [ + 'multiple-lists:web+foo', + 'multiple-lists:web+bar', + 'multiple-lists:database+foo', + 'multiple-lists:database+bar', + ], + 'single-list-with-dicts:{grains[id]}+{grains[roles]}+{grains[id]}': [ + 'single-list-with-dicts:{grains[id]}+web+{grains[id]}', + 'single-list-with-dicts:{grains[id]}+database+{grains[id]}' + ], + 'deeply-nested-list:{grains[deep][foo][bar][baz]}': [ + 'deeply-nested-list:hello', + 'deeply-nested-list:world' + ] + } + + # The mappings dict is assembled in _get_policies, so emulate here + mappings = {'minion': self.grains['id'], 'grains': self.grains} + for case, correct_output in six.iteritems(cases): + output = vault._expand_pattern_lists(case, **mappings) # pylint: disable=protected-access + diff = set(output).symmetric_difference(set(correct_output)) + if len(diff) != 0: + log.debug('Test {0} failed'.format(case)) + log.debug('Expected:\n\t{0}\nGot\n\t{1}'.format(output, correct_output)) + log.debug('Difference:\n\t{0}'.format(diff)) + self.assertEqual(output, correct_output) + + @skipIf(NO_MOCK, NO_MOCK_REASON) + def test_get_policies(self): + ''' + Ensure _get_policies works as intended, including expansion of lists + ''' + cases = { + 'no-tokens-to-replace': ['no-tokens-to-replace'], + 'single-dict:{minion}': ['single-dict:test-minion'], + 'single-list:{grains[roles]}': ['single-list:web', 'single-list:database'], + 'multiple-lists:{grains[roles]}+{grains[aux]}': [ + 'multiple-lists:web+foo', + 'multiple-lists:web+bar', + 'multiple-lists:database+foo', + 'multiple-lists:database+bar', + ], + 'single-list-with-dicts:{grains[id]}+{grains[roles]}+{grains[id]}': [ + 'single-list-with-dicts:test-minion+web+test-minion', + 'single-list-with-dicts:test-minion+database+test-minion' + ], + 'deeply-nested-list:{grains[deep][foo][bar][baz]}': [ + 'deeply-nested-list:hello', + 'deeply-nested-list:world' + ] + } + + with patch('salt.utils.minions.get_minion_data', + MagicMock(return_value=(None, self.grains, None))): + for case, correct_output in six.iteritems(cases): + test_config = {'policies': [case]} + output = vault._get_policies('test-minion', test_config) # pylint: disable=protected-access + diff = set(output).symmetric_difference(set(correct_output)) + if len(diff) != 0: + log.debug('Test {0} failed'.format(case)) + log.debug('Expected:\n\t{0}\nGot\n\t{1}'.format(output, correct_output)) + log.debug('Difference:\n\t{0}'.format(diff)) + self.assertEqual(output, correct_output) + + +if __name__ == '__main__': + from integration import run_tests # pylint: disable=import-error + run_tests(VaultTest, needs_daemon=False) From b434523a5164669f0b3d72a5a6fff0b4720aa967 Mon Sep 17 00:00:00 2001 From: twangboy Date: Mon, 27 Feb 2017 13:26:42 -0700 Subject: [PATCH 237/370] Fix job cache tests, add librato return tests --- .../integration/returners/test_local_cache.py | 22 +++++++++++++++++++ tests/whitelist.txt | 2 ++ 2 files changed, 24 insertions(+) diff --git a/tests/integration/returners/test_local_cache.py b/tests/integration/returners/test_local_cache.py index 8eb4eaf630..afa21244a2 100644 --- a/tests/integration/returners/test_local_cache.py +++ b/tests/integration/returners/test_local_cache.py @@ -110,6 +110,28 @@ class Local_CacheTest(integration.ShellCase): EMPTY_JID_DIR.append(new_jid_dir) os.makedirs(new_jid_dir) + # This needed due to a race condition in Windows + # `os.makedirs` hasn't released the handle before + # `local_cache.clean_old_jobs` tries to delete the new_jid_dir + if salt.utils.is_windows(): + import time + lock_dir = new_jid_dir + '.lckchk' + tries = 0 + while True: + tries += 1 + if tries > 10: + break + # Rename the directory and name it back + # If it fails, the directory handle is not released, try again + # If it succeeds, break and continue test + try: + os.rename(new_jid_dir, lock_dir) + time.sleep(1) + os.rename(lock_dir, new_jid_dir) + break + except WindowsError: + continue + # check dir exists self._check_dir_files('new_jid_dir was not created', EMPTY_JID_DIR, diff --git a/tests/whitelist.txt b/tests/whitelist.txt index a80c33b71d..e3c99a1b4c 100644 --- a/tests/whitelist.txt +++ b/tests/whitelist.txt @@ -22,6 +22,8 @@ integration.modules.state integration.modules.sysmod integration.modules.test integration.modules.useradd +integration.returners.test_librato_return +integration.returners.test_local_cache integration.runners.jobs integration.runners.salt integration.runners.winrepo From 559eb93576f76a7534fbb0a7c36f2fd22fe3b14d Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Mon, 27 Feb 2017 15:05:25 -0700 Subject: [PATCH 238/370] Strip shabang line from rendered HTTP data --- salt/utils/http.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/salt/utils/http.py b/salt/utils/http.py index 38aff41141..dcac036894 100644 --- a/salt/utils/http.py +++ b/salt/utils/http.py @@ -762,7 +762,11 @@ def _render(template, render, renderer, template_dict, opts): rend = salt.loader.render(opts, {}) blacklist = opts.get('renderer_blacklist') whitelist = opts.get('renderer_whitelist') - return compile_template(template, rend, renderer, blacklist, whitelist, **template_dict) + ret = compile_template(template, rend, renderer, blacklist, whitelist, **template_dict) + ret = ret.read() + if str(ret).startswith('#!') and not str(ret).startswith('#!/'): + ret = str(ret).split('\n', 1)[1] + return ret with salt.utils.fopen(template, 'r') as fh_: return fh_.read() From dc42987137817b70c8a59316e871254d5152ea19 Mon Sep 17 00:00:00 2001 From: twangboy Date: Mon, 27 Feb 2017 15:09:25 -0700 Subject: [PATCH 239/370] Add integration.sdb.test_env tests --- tests/whitelist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/whitelist.txt b/tests/whitelist.txt index a80c33b71d..21575df402 100644 --- a/tests/whitelist.txt +++ b/tests/whitelist.txt @@ -25,6 +25,7 @@ integration.modules.useradd integration.runners.jobs integration.runners.salt integration.runners.winrepo +integration.sdb.test_env integration.states.host integration.states.renderers integration.utils.testprogram From 20dd5593cd487e176ba4b41fd660d22ef9d2345e Mon Sep 17 00:00:00 2001 From: rallytime Date: Mon, 27 Feb 2017 15:50:32 -0700 Subject: [PATCH 240/370] Pylint fix --- salt/modules/win_iis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/win_iis.py b/salt/modules/win_iis.py index 836292c11f..3e873076e0 100644 --- a/salt/modules/win_iis.py +++ b/salt/modules/win_iis.py @@ -119,7 +119,7 @@ def _iisVersion(): try: items = json.loads(cmd_ret['stdout'], strict=False) except ValueError: - _LOG.error('Unable to parse return data as Json.') + log.error('Unable to parse return data as Json.') return -1 return decimal.Decimal("{0}.{1}".format(items[0]['MajorVersion'], items[0]['MinorVersion'])) From d1f0a74a7cb7257ecf71535361f999229ffbc753 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Mon, 27 Feb 2017 16:59:13 -0700 Subject: [PATCH 241/370] Add files section to FORMULA files --- salt/config/__init__.py | 1 + salt/spm/__init__.py | 45 ++++++++++++++++++++++++++++++++------ salt/spm/pkgfiles/local.py | 27 ++++++++++++++++++++--- tests/unit/test_spm.py | 1 + 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index b765ada308..1a1c175d89 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -1621,6 +1621,7 @@ DEFAULT_SPM_OPTS = { # If set, spm_node_type will be either master or minion, but they should # NOT be a default 'spm_node_type': '', + 'spm_share_dir': '/usr/share/salt/spm' # <---- Salt master settings overridden by SPM ---------------------- } diff --git a/salt/spm/__init__.py b/salt/spm/__init__.py index 446fa51f2c..ce4bebe6de 100644 --- a/salt/spm/__init__.py +++ b/salt/spm/__init__.py @@ -35,6 +35,15 @@ from salt.ext.six.moves import filter # Get logging started log = logging.getLogger(__name__) +FILE_TYPES = ('c', 'd', 'g', 'l', 'r', 's', 'm') +# c: config file +# d: documentation file +# g: ghost file (i.e. the file contents are not included in the package payload) +# l: license file +# r: readme file +# s: SLS file +# m: Salt module + class SPMException(Exception): ''' @@ -342,8 +351,10 @@ class SPMClient(object): else: response = http.query(dl_url, text=True) with salt.utils.fopen(out_file, 'w') as outf: - outf.write(response.get("text")) + outf.write(response.get('text')) + # First we download everything, then we install + for package in dl_list: # Kick off the install self._install_indv_pkg(package, out_file) return @@ -445,6 +456,7 @@ class SPMClient(object): raise SPMPackageError('Invalid package: the {0} was not found'.format(field)) pkg_files = formula_tar.getmembers() + # First pass: check for files that already exist existing_files = self._pkgfiles_fun('check_existing', pkg_name, pkg_files, formula_def) @@ -943,12 +955,31 @@ class SPMClient(object): formula_tar = tarfile.open(out_path, 'w:bz2') - try: - formula_tar.add(formula_path, formula_conf['name'], filter=self._exclude) - formula_tar.add(self.abspath, formula_conf['name'], filter=self._exclude) - except TypeError: - formula_tar.add(formula_path, formula_conf['name'], exclude=self._exclude) - formula_tar.add(self.abspath, formula_conf['name'], exclude=self._exclude) + if 'files' in formula_conf: + # This allows files to be added to the SPM file in a specific order. + # It also allows for files to be tagged as a certain type, as with + # RPM files. This tag is ignored here, but is used when installing + # the SPM file. + if isinstance(formula_conf['files'], list): + formula_dir = tarfile.TarInfo(formula_conf['name']) + formula_dir.type = tarfile.DIRTYPE + formula_tar.addfile(formula_dir) + for file_ in formula_conf['files']: + for ftype in FILE_TYPES: + if file_.startswith('{0}|'.format(ftype)): + file_ = file_.lstrip('{0}|'.format(ftype)) + formula_tar.add( + os.path.join(os.getcwd(), file_), + os.path.join(formula_conf['name'], file_), + ) + else: + # If no files are specified, then the whole directory will be added. + try: + formula_tar.add(formula_path, formula_conf['name'], filter=self._exclude) + formula_tar.add(self.abspath, formula_conf['name'], filter=self._exclude) + except TypeError: + formula_tar.add(formula_path, formula_conf['name'], exclude=self._exclude) + formula_tar.add(self.abspath, formula_conf['name'], exclude=self._exclude) formula_tar.close() self.ui.status('Built package {0}'.format(out_path)) diff --git a/salt/spm/pkgfiles/local.py b/salt/spm/pkgfiles/local.py index 7f266f3fe3..f46f09ddfd 100644 --- a/salt/spm/pkgfiles/local.py +++ b/salt/spm/pkgfiles/local.py @@ -13,6 +13,14 @@ import salt.syspaths # Get logging started log = logging.getLogger(__name__) +FILE_TYPES = ('c', 'd', 'g', 'l', 'r', 's', 'm') +# c: config file +# d: documentation file +# g: ghost file (i.e. the file contents are not included in the package payload) +# l: license file +# r: readme file +# s: SLS file +# m: Salt module def init(**kwargs): @@ -100,9 +108,22 @@ def install_file(package, formula_tar, member, formula_def, conn=None): tld = formula_def.get('top_level_dir', package) new_name = member.name.replace('{0}/'.format(package), '', 1) - if not new_name.startswith(tld) and not new_name.startswith('_') and not new_name.startswith('pillar.example'): - log.debug('{0} not in top level directory, not installing'.format(new_name)) - return False + if not new_name.startswith(tld) and not new_name.startswith('_') \ + and not new_name.startswith('pillar.example') and not new_name.startswith('README'): + log.debug('{0} not in top level directory, not installing'.format(new_name)) + return False + + for line in formula_def.get('files', []): + tag = '' + for ftype in FILE_TYPES: + if line.startswith('{0}|'.format(ftype)): + tag = line.split('|', 1)[0] + line = line.split('|', 1)[1] + if tag and new_name == line: + if tag in ('c', 'd', 'g', 'l', 'r'): + out_path = __opts__['spm_share_dir'] + elif tag in ('s', 'm'): + pass if new_name.startswith('{0}/_'.format(package)): if node_type in ('master', 'minion'): diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index 9b6e75c34d..d2af57966b 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -41,6 +41,7 @@ __opts__ = { 'verbose': False, 'cache': 'localfs', 'spm_repo_dups': 'ignore', + 'spm_share_dir': '/usr/share/salt/spm', } _F1 = { From ded8040b55fa03041eca3f0b45746d7b48f461fb Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Mon, 27 Feb 2017 17:51:00 -0700 Subject: [PATCH 242/370] Update docs --- doc/topics/spm/spm_formula.rst | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/doc/topics/spm/spm_formula.rst b/doc/topics/spm/spm_formula.rst index 2493527a22..c840b57e9e 100644 --- a/doc/topics/spm/spm_formula.rst +++ b/doc/topics/spm/spm_formula.rst @@ -107,6 +107,45 @@ A comma-separated list of optional packages that are recommended to be installed with the package. This list is displayed in an informational message when the package is installed to SPM. +files +~~~~~ +A files section can be added, to specify a list of files to add to the SPM. +Such a section might look like: + +.. code-block:: yaml + + files: + - _pillar + - FORMULA + - _runners + - d|mymodule/index.rst + - r|README.rst + +When ``files`` are specified, then only those files will be added to the SPM, +regardless of what other files exist in the directory. They will also be added +in the order specified, which is useful if you have a need to lay down files in +a specific order. + +As can be seen in the example above, you may also tag files as being a specific +type. This is done by pre-pending a filename with its type, followed by a pipe +(``|``) character. The above example contains a document file and a readme. The +available file types are: + +* ``c``: config file +* ``d``: documentation file +* ``g``: ghost file (i.e. the file contents are not included in the package payload) +* ``l``: license file +* ``r``: readme file +* ``s``: SLS file +* ``m``: Salt module + +The first 5 of these types (``c``, ``d``, ``g``, ``l``, ``r``) will be placed in +``/usr/share/salt/spm/`` by default. This can be changed by setting an +``spm_share_dir`` value in your ``/etc/salt/spm`` configuration file. + +The last two types (``s`` and ``m``) are currently ignored, but they are +reserved for future use. + Building a Package ------------------ Once a ``FORMULA`` file has been created, it is placed into the root of the From 40d08777c5258717fd52134ce6b375a8ff29d776 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Mon, 27 Feb 2017 17:54:33 -0700 Subject: [PATCH 243/370] Lint --- salt/spm/pkgfiles/local.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/spm/pkgfiles/local.py b/salt/spm/pkgfiles/local.py index f46f09ddfd..5ba797b83d 100644 --- a/salt/spm/pkgfiles/local.py +++ b/salt/spm/pkgfiles/local.py @@ -110,8 +110,8 @@ def install_file(package, formula_tar, member, formula_def, conn=None): new_name = member.name.replace('{0}/'.format(package), '', 1) if not new_name.startswith(tld) and not new_name.startswith('_') \ and not new_name.startswith('pillar.example') and not new_name.startswith('README'): - log.debug('{0} not in top level directory, not installing'.format(new_name)) - return False + log.debug('{0} not in top level directory, not installing'.format(new_name)) # pylint: disable=W0311 + return False # pylint: disable=W0311 for line in formula_def.get('files', []): tag = '' From 7b958fb389fa410c8a4a44b6706aa99cfc38945f Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 27 Feb 2017 20:21:53 -0600 Subject: [PATCH 244/370] Add options to skip fileserver/git_pillar preflight checks This commit also modifies the master config for the test suite to use this new option, so that a missing GitPython/Pygit2 will not crash the test suite's master. This should make the test suite run smoother by only negatively impacting those tests which require the pillar data provided by git_pillar, when a valid provider is not available. --- doc/ref/configuration/master.rst | 38 +++++++++++++++ salt/config/__init__.py | 4 ++ salt/daemons/masterapi.py | 22 +++++---- salt/master.py | 73 +++++++++++++++-------------- tests/integration/files/conf/master | 2 + 5 files changed, 96 insertions(+), 43 deletions(-) diff --git a/doc/ref/configuration/master.rst b/doc/ref/configuration/master.rst index fd10aad4f4..02328d85c6 100644 --- a/doc/ref/configuration/master.rst +++ b/doc/ref/configuration/master.rst @@ -1605,6 +1605,25 @@ on a large number of minions. fileserver_list_cache_time: 5 +.. conf_master:: fileserver_verify_config + +``fileserver_verify_config`` +------------------------------ + +.. versionadded:: Nitrogen + +Default: ``True`` + +By default, as the master starts it performs some sanity checks on the +configured fileserver backends. If any of these sanity checks fail (such as +when an invalid configuration is used), the master daemon will abort. + +To skip these sanity checks, set this option to ``False``. + +.. code-block:: yaml + + fileserver_verify_config: False + .. conf_master:: hash_type ``hash_type`` @@ -3168,6 +3187,25 @@ configured both globally and for individual remotes. - '+refs/pull/*/head:refs/remotes/origin/pr/*' - '+refs/pull/*/merge:refs/remotes/origin/merge/*' +.. conf_master:: git_pillar_verify_config + +``git_pillar_verify_config`` +---------------------------- + +.. versionadded:: Nitrogen + +Default: ``True`` + +By default, as the master starts it performs some sanity checks on the +configured git_pillar repositories. If any of these sanity checks fail (such as +when an invalid configuration is used), the master daemon will abort. + +To skip these sanity checks, set this option to ``False``. + +.. code-block:: yaml + + git_pillar_verify_config: False + .. _pillar-merging-opts: Pillar Merging Options diff --git a/salt/config/__init__.py b/salt/config/__init__.py index b765ada308..703917d5ac 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -584,6 +584,7 @@ VALID_OPTS = { 'git_pillar_passphrase': str, 'git_pillar_refspecs': list, 'git_pillar_includes': bool, + 'git_pillar_verify_config': bool, 'gitfs_remotes': list, 'gitfs_mountpoint': str, 'gitfs_root': str, @@ -685,6 +686,7 @@ VALID_OPTS = { 'fileserver_followsymlinks': bool, 'fileserver_ignoresymlinks': bool, 'fileserver_limit_traversal': bool, + 'fileserver_verify_config': bool, # The number of open files a daemon is allowed to have open. Frequently needs to be increased # higher than the system default in order to account for the way zeromq consumes file handles. @@ -1319,6 +1321,7 @@ DEFAULT_MASTER_OPTS = { 'git_pillar_passphrase': '', 'git_pillar_refspecs': _DFLT_REFSPECS, 'git_pillar_includes': True, + 'git_pillar_verify_config': True, 'gitfs_remotes': [], 'gitfs_mountpoint': '', 'gitfs_root': '', @@ -1393,6 +1396,7 @@ DEFAULT_MASTER_OPTS = { 'fileserver_followsymlinks': True, 'fileserver_ignoresymlinks': False, 'fileserver_limit_traversal': False, + 'fileserver_verify_config': True, 'max_open_files': 100000, 'hash_type': 'sha256', 'conf_file': os.path.join(salt.syspaths.CONFIG_DIR, 'master'), diff --git a/salt/daemons/masterapi.py b/salt/daemons/masterapi.py index ac8961a0f8..ecffec8bae 100644 --- a/salt/daemons/masterapi.py +++ b/salt/daemons/masterapi.py @@ -37,7 +37,7 @@ import salt.utils.gzip_util import salt.utils.jid from salt.pillar import git_pillar from salt.utils.event import tagify -from salt.exceptions import SaltMasterError +from salt.exceptions import FileserverConfigError, SaltMasterError # Import 3rd-party libs import salt.ext.six as six @@ -87,13 +87,19 @@ def init_git_pillar(opts): ) else: # New git_pillar code - pillar = salt.utils.gitfs.GitPillar(opts) - pillar.init_remotes( - opts_dict['git'], - git_pillar.PER_REMOTE_OVERRIDES, - git_pillar.PER_REMOTE_ONLY - ) - ret.append(pillar) + try: + pillar = salt.utils.gitfs.GitPillar(opts) + pillar.init_remotes( + opts_dict['git'], + git_pillar.PER_REMOTE_OVERRIDES, + git_pillar.PER_REMOTE_ONLY + ) + ret.append(pillar) + except FileserverConfigError: + if opts.get('git_pillar_verify_config', True): + raise + else: + log.critical('Could not initialize git_pillar') return ret diff --git a/salt/master.py b/salt/master.py index 59becf941d..0f7ed46d0c 100644 --- a/salt/master.py +++ b/salt/master.py @@ -455,19 +455,21 @@ class Master(SMaster): 'Cannot change to root directory ({1})'.format(err) ) - fileserver = salt.fileserver.Fileserver(self.opts) - if not fileserver.servers: - errors.append( - 'Failed to load fileserver backends, the configured backends ' - 'are: {0}'.format(', '.join(self.opts['fileserver_backend'])) - ) - else: - # Run init() for all backends which support the function, to - # double-check configuration - try: - fileserver.init() - except FileserverConfigError as exc: - critical_errors.append('{0}'.format(exc)) + if self.opts.get('fileserver_verify_config', True): + fileserver = salt.fileserver.Fileserver(self.opts) + if not fileserver.servers: + errors.append( + 'Failed to load fileserver backends, the configured backends ' + 'are: {0}'.format(', '.join(self.opts['fileserver_backend'])) + ) + else: + # Run init() for all backends which support the function, to + # double-check configuration + try: + fileserver.init() + except FileserverConfigError as exc: + critical_errors.append('{0}'.format(exc)) + if not self.opts['fileserver_backend']: errors.append('No fileserver backends are configured') @@ -480,28 +482,29 @@ class Master(SMaster): except OSError: pass - non_legacy_git_pillars = [ - x for x in self.opts.get('ext_pillar', []) - if 'git' in x - and not isinstance(x['git'], six.string_types) - ] - if non_legacy_git_pillars: - try: - new_opts = copy.deepcopy(self.opts) - from salt.pillar.git_pillar \ - import PER_REMOTE_OVERRIDES as per_remote_overrides, \ - PER_REMOTE_ONLY as per_remote_only - for repo in non_legacy_git_pillars: - new_opts['ext_pillar'] = [repo] - try: - git_pillar = salt.utils.gitfs.GitPillar(new_opts) - git_pillar.init_remotes(repo['git'], - per_remote_overrides, - per_remote_only) - except FileserverConfigError as exc: - critical_errors.append(exc.strerror) - finally: - del new_opts + if self.opts.get('git_pillar_verify_config', True): + non_legacy_git_pillars = [ + x for x in self.opts.get('ext_pillar', []) + if 'git' in x + and not isinstance(x['git'], six.string_types) + ] + if non_legacy_git_pillars: + try: + new_opts = copy.deepcopy(self.opts) + from salt.pillar.git_pillar \ + import PER_REMOTE_OVERRIDES as per_remote_overrides, \ + PER_REMOTE_ONLY as per_remote_only + for repo in non_legacy_git_pillars: + new_opts['ext_pillar'] = [repo] + try: + git_pillar = salt.utils.gitfs.GitPillar(new_opts) + git_pillar.init_remotes(repo['git'], + per_remote_overrides, + per_remote_only) + except FileserverConfigError as exc: + critical_errors.append(exc.strerror) + finally: + del new_opts if errors or critical_errors: for error in errors: diff --git a/tests/integration/files/conf/master b/tests/integration/files/conf/master index 3e7227018a..2d76e9e131 100644 --- a/tests/integration/files/conf/master +++ b/tests/integration/files/conf/master @@ -30,6 +30,8 @@ peer: '.*': - 'test.*' +git_pillar_verify_config: False + ext_pillar: - git: - master https://github.com/saltstack/pillar1.git From 42357c6d781e2635c22b3d1c0b69e5faf92189e7 Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Mon, 27 Feb 2017 11:32:41 +0100 Subject: [PATCH 245/370] Add support for user roles in present state --- salt/states/mongodb_user.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/salt/states/mongodb_user.py b/salt/states/mongodb_user.py index 65422a3d7b..94e2b74928 100644 --- a/salt/states/mongodb_user.py +++ b/salt/states/mongodb_user.py @@ -24,7 +24,8 @@ def present(name, password=None, host="localhost", port=27017, - authdb=None): + authdb=None, + roles=None): ''' Ensure that the user is present with the specified properties @@ -55,6 +56,9 @@ def present(name, authdb The database in which to authenticate + roles + The roles assigned to user specified with the ``name`` parameter + Example: .. code-block:: yaml @@ -63,9 +67,14 @@ def present(name, mongodb_user.present: - name: myapp - passwd: password-of-myapp + - database: admin # Connect as admin:sekrit - user: admin - password: sekrit + - roles: + - readWrite + - userAdmin + - dbOwner ''' ret = {'name': name, @@ -73,6 +82,10 @@ def present(name, 'result': True, 'comment': 'User {0} is already present'.format(name)} + # setup default empty roles if not provided to preserve previous API interface + if roles is None: + roles = [] + # Check for valid port try: port = int(port) @@ -84,6 +97,23 @@ def present(name, # check if user exists user_exists = __salt__['mongodb.user_exists'](name, user, password, host, port, database, authdb) if user_exists is True: + # obtain users specified by name query + users = __salt__['mongodb.user_find'](name, user, password, host, port, database, authdb) + # check each user occurrence + for usr in users: + # prepare empty list for current roles + current_roles = [] + # iterate over user roles and append each to current_roles list + for role in usr['roles']: + # check correct database to be sure to fill current_roles only for desired db + if role['db'] == database: + current_roles.append(role['role']) + + # fill changes if the roles and current roles differ + if not set(current_roles) == set(roles): + ret['changes'].update({name: {'database': database, 'roles': {'old': current_roles, 'new': roles}}}) + + __salt__['mongodb.user_create'](name, passwd, user, password, host, port, database=database, authdb=authdb, roles=roles) return ret # if the check does not return a boolean, return an error @@ -99,7 +129,7 @@ def present(name, ).format(name) return ret # The user is not present, make it! - if __salt__['mongodb.user_create'](name, passwd, user, password, host, port, database=database, authdb=authdb): + if __salt__['mongodb.user_create'](name, passwd, user, password, host, port, database=database, authdb=authdb, roles=roles): ret['comment'] = 'User {0} has been created'.format(name) ret['changes'][name] = 'Present' else: From 251c09edba1123160b68d06c3da41c55266db678 Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Mon, 27 Feb 2017 13:07:39 +0100 Subject: [PATCH 246/370] Fix user retriving. No need to call execution module function that iterates over every user in database --- salt/states/mongodb_user.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/states/mongodb_user.py b/salt/states/mongodb_user.py index 94e2b74928..c9a53b979b 100644 --- a/salt/states/mongodb_user.py +++ b/salt/states/mongodb_user.py @@ -95,9 +95,9 @@ def present(name, return ret # check if user exists - user_exists = __salt__['mongodb.user_exists'](name, user, password, host, port, database, authdb) - if user_exists is True: - # obtain users specified by name query + users = __salt__['mongodb.user_find'](name, user, password, host, port, database, authdb) + if len(users) > 0: + # check each user occurrence users = __salt__['mongodb.user_find'](name, user, password, host, port, database, authdb) # check each user occurrence for usr in users: From ee426562a7ced5fbf37b367537d8cb6bbe518639 Mon Sep 17 00:00:00 2001 From: alankrita Date: Tue, 28 Feb 2017 17:30:44 +0530 Subject: [PATCH 247/370] Fix error in Saltstack's rest auth "Authentication module threw 'status' " Fixes #39683 updated rest.auth method to get 'status' and 'dict' in the http.query result --- salt/auth/rest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/auth/rest.py b/salt/auth/rest.py index d572e0418e..1e5085774d 100644 --- a/salt/auth/rest.py +++ b/salt/auth/rest.py @@ -58,7 +58,8 @@ def auth(username, password): # Post to the API endpoint. If 200 is returned then the result will be the ACLs # for this user - result = salt.utils.http.query(url, method='POST', data=data) + result = salt.utils.http.query(url, method='POST', data=data, status=True, + decode=True) if result['status'] == 200: log.debug('eauth REST call returned 200: {0}'.format(result)) if result['dict'] is not None: From dc00f4621f65eeeed7d20244c70adcda3de98a73 Mon Sep 17 00:00:00 2001 From: Alex Zel Date: Tue, 28 Feb 2017 14:45:57 +0200 Subject: [PATCH 248/370] Update elasticsearch.py Add option for HTTP authentication with username and password. --- salt/modules/elasticsearch.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/salt/modules/elasticsearch.py b/salt/modules/elasticsearch.py index ed68130736..0f32b06b7d 100644 --- a/salt/modules/elasticsearch.py +++ b/salt/modules/elasticsearch.py @@ -101,6 +101,8 @@ def _get_instance(hosts=None, profile=None): use_ssl = _profile.get('use_ssl', False) ca_certs = _profile.get('ca_certs', False) verify_certs = _profile.get('verify_certs', False) + username = _profile.get('username', None) + password = _profile.get('password', None) if not hosts: hosts = ['127.0.0.1:9200'] @@ -114,6 +116,14 @@ def _get_instance(hosts=None, profile=None): ca_certs=ca_certs, verify_certs=verify_certs, ) + elif username and passowrd: + es = elasticsearch.Elasticsearch( + hosts, + use_ssl=use_ssl, + ca_certs=ca_certs, + verify_certs=verify_certs, + http_auth=(username, password) + ) else: # Custom connection class to use requests module with proxies class ProxyConnection(RequestsHttpConnection): From 3f92184b147e7a3f5a290de97a7b85699bc2b550 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 06:55:10 -0700 Subject: [PATCH 249/370] Lint --- salt/spm/pkgfiles/local.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/spm/pkgfiles/local.py b/salt/spm/pkgfiles/local.py index 5ba797b83d..a505d1d56b 100644 --- a/salt/spm/pkgfiles/local.py +++ b/salt/spm/pkgfiles/local.py @@ -108,10 +108,10 @@ def install_file(package, formula_tar, member, formula_def, conn=None): tld = formula_def.get('top_level_dir', package) new_name = member.name.replace('{0}/'.format(package), '', 1) - if not new_name.startswith(tld) and not new_name.startswith('_') \ - and not new_name.startswith('pillar.example') and not new_name.startswith('README'): - log.debug('{0} not in top level directory, not installing'.format(new_name)) # pylint: disable=W0311 - return False # pylint: disable=W0311 + if not new_name.startswith(tld) and not new_name.startswith('_') and not \ + new_name.startswith('pillar.example') and not new_name.startswith('README'): + log.debug('{0} not in top level directory, not installing'.format(new_name)) + return False for line in formula_def.get('files', []): tag = '' From 51167bc28a2331aac7a8caad158b5bbf5cbe15f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Coavoux?= Date: Tue, 28 Feb 2017 09:01:20 -0500 Subject: [PATCH 250/370] Enh: Support new version of tuned-adm binary Fixes #39692 --- salt/modules/tuned.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/salt/modules/tuned.py b/salt/modules/tuned.py index 431cd67b48..33a1485c99 100644 --- a/salt/modules/tuned.py +++ b/salt/modules/tuned.py @@ -45,9 +45,13 @@ def list_(): ''' result = __salt__['cmd.run']('tuned-adm list').splitlines() + # Remove "Available profiles:" result.pop(0) + # Remove "Current active profile:.*" result.pop() - result = [i.lstrip('- ') for i in result] + # Output can be : " - - " (v2.7.1) + # or " - " (v2.4.1) + result = [i.split('-')[1].strip() for i in result] return result From 1d86cf1161d2839778fcc7199a84f8bbac5df169 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Tue, 28 Feb 2017 16:23:53 +0200 Subject: [PATCH 251/370] DOCS: add 2nd level header for advanced targeting methods --- doc/topics/targeting/index.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/topics/targeting/index.rst b/doc/topics/targeting/index.rst index 19e4fa2850..780a4d8557 100644 --- a/doc/topics/targeting/index.rst +++ b/doc/topics/targeting/index.rst @@ -33,7 +33,7 @@ be called to execute a function, or a specific kernel. Calling via a grain is done by passing the -G option to salt, specifying a grain and a glob expression to match the value of the grain. The syntax for -the target is the grain key followed by a globexpression: "os:Arch*". +the target is the grain key followed by a glob expression: "os:Arch*". .. code-block:: bash @@ -48,7 +48,7 @@ grains.item salt function: salt '*' grains.items -more info on using targeting with grains can be found :ref:`here +More info on using targeting with grains can be found :ref:`here `. Compound Targeting @@ -73,7 +73,7 @@ is used with ``G@`` as well as a regular expression with ``E@``. The ``webser*`` target does not need to be prefaced with a target type specifier because it is a glob. -more info on using compound targeting can be found :ref:`here +More info on using compound targeting can be found :ref:`here `. Node Group Targeting @@ -94,6 +94,10 @@ shorthand for having to type out complicated compound expressions.  group2: 'G@os:Debian and foo.domain.com'  group3: 'G@os:Debian and N@group1' + +Advanced Targeting Methods +========================== + There are many ways to target individual minions or groups of minions in Salt: .. toctree:: From f454f536e5ff1bd2214459c08cd5a3c7c9184d6e Mon Sep 17 00:00:00 2001 From: Luke Hollins Date: Tue, 28 Feb 2017 09:56:51 -0500 Subject: [PATCH 252/370] Updated to match latest docker module changes --- salt/states/docker.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/salt/states/docker.py b/salt/states/docker.py index 8e0c5de94a..7b18c820ef 100644 --- a/salt/states/docker.py +++ b/salt/states/docker.py @@ -100,7 +100,7 @@ def _prep_input(kwargs): configure in an SLS file as a dictlist. If the data type is a string, then skip repacking and let _validate_input() try to sort it out. ''' - for kwarg in ('environment', 'lxc_conf'): + for kwarg in ('environment', 'lxc_conf', 'sysctls'): kwarg_value = kwargs.get(kwarg) if kwarg_value is not None \ and not isinstance(kwarg_value, six.string_types): @@ -433,6 +433,33 @@ def _compare(actual, create_kwargs, defaults_from_image): if data != actual_data: ret.update({item: {'old': actual_data, 'new': data}}) continue + elif item == 'sysctls': + if actual_data is None: + actual_data = [] + actual_sysctls = {} + for sysctl_var in actual_data: + try: + key, val = sysctl_var.split('=', 1) + except (AttributeError, ValueError): + log.warning( + 'Unexpected sysctl variable in inspect ' + 'output {0}'.format(sysctl_var) + ) + continue + else: + actual_sysctls[key] = val + log.trace('dockerng.running ({0}): munged actual value: {1}' + .format(item, actual_sysctls)) + sysctls_diff = {} + for key in data: + actual_val = actual_sysctls.get(key) + if data[key] != actual_val: + sysctls_ptr = sysctls_diff.setdefault(item, {}) + sysctls_ptr.setdefault('old', {})[key] = actual_val + sysctls_ptr.setdefault('new', {})[key] = data[key] + if sysctls_diff: + ret.update(sysctls_diff) + continue elif item == 'security_opt': if actual_data is None: actual_data = [] From b87377d800ee7968a356892b91eec46672b830e7 Mon Sep 17 00:00:00 2001 From: Luke Hollins Date: Tue, 28 Feb 2017 10:02:15 -0500 Subject: [PATCH 253/370] Sysctl doc changes --- salt/states/docker.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/salt/states/docker.py b/salt/states/docker.py index 7b18c820ef..ea002cd976 100644 --- a/salt/states/docker.py +++ b/salt/states/docker.py @@ -1673,6 +1673,34 @@ def running(name, `Configure logging drivers`_ documentation for more information. .. _`Configure logging drivers`: https://docs.docker.com/engine/admin/logging/overview/ + + sysctls + Either a list of variable/value mappings, or a list of strings in the + format ``VARNAME=value``. The below two examples are equivalent: + + .. code-block:: yaml + + foo: + docker.running: + - image: bar/baz:latest + - sysctls: + - VAR1: value + - VAR2: value + + .. code-block:: yaml + + foo: + docker.running: + - image: bar/baz:latest + - sysctls: + - VAR1=value + - VAR2=value + + .. note:: + + Values must be strings. Otherwise it will be considered + as an error. + ''' ret = {'name': name, 'changes': {}, From c423199c95ef713084c6284b667fe8b20b691b08 Mon Sep 17 00:00:00 2001 From: Alex Zel Date: Tue, 28 Feb 2017 17:54:30 +0200 Subject: [PATCH 254/370] Update elasticsearch.py --- salt/modules/elasticsearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/elasticsearch.py b/salt/modules/elasticsearch.py index 0f32b06b7d..81c249fe6c 100644 --- a/salt/modules/elasticsearch.py +++ b/salt/modules/elasticsearch.py @@ -116,7 +116,7 @@ def _get_instance(hosts=None, profile=None): ca_certs=ca_certs, verify_certs=verify_certs, ) - elif username and passowrd: + elif username and password: es = elasticsearch.Elasticsearch( hosts, use_ssl=use_ssl, From b5a7111ad9943289f8f404498ebe3e2bc82d40f5 Mon Sep 17 00:00:00 2001 From: rallytime Date: Tue, 28 Feb 2017 09:03:05 -0700 Subject: [PATCH 255/370] [2016.11] Bump latest release version to 2016.11.3 --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index e6bd6e55b1..1479d13a6a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -239,7 +239,7 @@ on_saltstack = 'SALT_ON_SALTSTACK' in os.environ project = 'Salt' version = salt.version.__version__ -latest_release = '2016.11.2' # latest release +latest_release = '2016.11.3' # latest release previous_release = '2016.3.5' # latest release from previous branch previous_release_dir = '2016.3' # path on web server for previous branch next_release = '' # next release From 7cc49adef5467fe86c3a2410594aa1ee70035280 Mon Sep 17 00:00:00 2001 From: rallytime Date: Tue, 28 Feb 2017 09:03:40 -0700 Subject: [PATCH 256/370] [develop] Bump latest release version to 2016.11.3 --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 6ea62db7aa..95e51130fe 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -244,7 +244,7 @@ on_saltstack = 'SALT_ON_SALTSTACK' in os.environ project = 'Salt' version = salt.version.__version__ -latest_release = '2016.11.2' # latest release +latest_release = '2016.11.3' # latest release previous_release = '2016.3.5' # latest release from previous branch previous_release_dir = '2016.3' # path on web server for previous branch next_release = '' # next release From f86b189260baf6b2d7391e919d4202ebd8058429 Mon Sep 17 00:00:00 2001 From: Luke Hollins Date: Tue, 28 Feb 2017 11:07:36 -0500 Subject: [PATCH 257/370] fixed variable name in copied code --- salt/modules/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/docker.py b/salt/modules/docker.py index ff7db2e59c..9e9a3d282b 100644 --- a/salt/modules/docker.py +++ b/salt/modules/docker.py @@ -1950,7 +1950,7 @@ def _validate_input(kwargs, .format(sysctl_var) ) else: - if key in sysctl_env: + if key in repacked_sysctl: raise SaltInvocationError( 'Duplicate sysctl variable \'{0}\'' .format(key) From c9bbca220286069accb67b25051d8c0519b279e6 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Tue, 28 Feb 2017 10:32:59 -0600 Subject: [PATCH 258/370] also return data Instead of only firing events with the data in it, return the data so it can be used elsewhere if it is needed. --- salt/runners/queue.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/runners/queue.py b/salt/runners/queue.py index 67a5650715..0641ad0bbb 100644 --- a/salt/runners/queue.py +++ b/salt/runners/queue.py @@ -190,3 +190,4 @@ def process_queue(queue, quantity=1, backend='sqlite'): 'queue': queue, } event.fire_event(data, tagify([queue, 'process'], prefix='queue')) + return data From ee0eaf43a882cdb36d342fd6fe02ea0234d62345 Mon Sep 17 00:00:00 2001 From: Tom Williams Date: Tue, 28 Feb 2017 11:59:02 -0500 Subject: [PATCH 259/370] INFRA-4510 - skip trying to add instances in non-running states to ELBs --- salt/states/boto_elb.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/salt/states/boto_elb.py b/salt/states/boto_elb.py index cacc6e05e6..1b0be55565 100644 --- a/salt/states/boto_elb.py +++ b/salt/states/boto_elb.py @@ -493,10 +493,13 @@ def present( if not instance_ids: instance_ids = [] if instance_names: + # AWS borks on adding instances in "non-running" states, so filter 'em out. + running_states = ('pending', 'rebooting', 'running', 'stopping', 'stopped') for n in instance_names: instance_ids += __salt__['boto_ec2.find_instances'](name=n, region=region, key=key, keyid=keyid, - profile=profile) + profile=profile, + in_states=running_states) # Backwards compat: Only touch attached instances if requested (e.g. if some are defined). if instance_ids: if __opts__['test']: From ddf8f87249e2d1fa511806a061678cd2da58e668 Mon Sep 17 00:00:00 2001 From: rallytime Date: Tue, 28 Feb 2017 10:36:11 -0700 Subject: [PATCH 260/370] Add some additional mocks for win_iis unit test --- tests/unit/modules/test_win_iis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/modules/test_win_iis.py b/tests/unit/modules/test_win_iis.py index 98b81f3a88..a3347cab24 100644 --- a/tests/unit/modules/test_win_iis.py +++ b/tests/unit/modules/test_win_iis.py @@ -344,7 +344,8 @@ class WinIisTestCase(TestCase): @patch('salt.modules.win_iis._list_certs', MagicMock(return_value={'9988776655443322111000AAABBBCCCDDDEEEFFF': None})) @patch('salt.modules.win_iis._srvmgr', - MagicMock(return_value={'retcode': 0})) + MagicMock(return_value={'retcode': 0, 'stdout': 10})) + @patch('json.loads', MagicMock(return_value=[{'MajorVersion': 10, 'MinorVersion': 0}])) @patch('salt.modules.win_iis.list_bindings', MagicMock(return_value=BINDING_LIST)) @patch('salt.modules.win_iis.list_cert_bindings', From 50cfa338ebc02620139c79db3b6a6d8edd4198ea Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Tue, 28 Feb 2017 12:00:22 -0600 Subject: [PATCH 261/370] Remove ext_pillar traceback from returned error d7a7066 was supposed to affect logging, not the error returned to the CLI. This corrects that oversight. --- salt/pillar/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/salt/pillar/__init__.py b/salt/pillar/__init__.py index bf966239d7..187668a3ba 100644 --- a/salt/pillar/__init__.py +++ b/salt/pillar/__init__.py @@ -820,12 +820,15 @@ class Pillar(object): key) except Exception as exc: errors.append( - 'Failed to load ext_pillar {0}: {1}\n{2}'.format( + 'Failed to load ext_pillar {0}: {1}'.format( key, exc.__str__(), - ''.join(traceback.format_tb(sys.exc_info()[2])), ) ) + log.error( + 'Execption caught loading ext_pillar \'%s\':\n%s', + key, ''.join(traceback.format_tb(sys.exc_info()[2])) + ) if ext: pillar = merge( pillar, From 85907d471efbda696ef3211dfabbc83181825093 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Tue, 28 Feb 2017 11:20:16 -0600 Subject: [PATCH 262/370] add runner queue processing --- salt/queues/pgjsonb_queue.py | 17 ++++++++++------- salt/runners/queue.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/salt/queues/pgjsonb_queue.py b/salt/queues/pgjsonb_queue.py index 08f42c2aec..93ea8ca314 100644 --- a/salt/queues/pgjsonb_queue.py +++ b/salt/queues/pgjsonb_queue.py @@ -45,6 +45,8 @@ from contextlib import contextmanager import json import sys +# import salt libs +import salt.ext.six as six from salt.exceptions import SaltInvocationError, SaltMasterError try: @@ -237,7 +239,7 @@ def pop(queue, quantity=1): ''' Pop one or more or all items from the queue return them. ''' - cmd = 'SELECT data FROM {0}'.format(queue) + cmd = 'SELECT id, data FROM {0}'.format(queue) if quantity != 'all': try: quantity = int(quantity) @@ -247,17 +249,18 @@ def pop(queue, quantity=1): raise SaltInvocationError(error_txt) cmd = ''.join([cmd, ' LIMIT {0};'.format(quantity)]) log.debug('SQL Query: {0}'.format(cmd)) + items = [] with _conn(commit=True) as cur: - items = [] cur.execute(cmd) result = cur.fetchall() if len(result) > 0: - items = [item[0] for item in result] - itemlist = "','".join(items) - del_cmd = '''DELETE FROM {0} WHERE data IN ('{1}');'''.format( - queue, itemlist) + ids = [six.text_type(item[0]) for item in result] + items = [item[1] for item in result] + idlist = "','".join(ids) + del_cmd = '''DELETE FROM {0} WHERE id IN ('{1}');'''.format( + queue, idlist) log.debug('SQL Query: {0}'.format(del_cmd)) cur.execute(del_cmd) - return [json.loads(x) for x in items] + return items diff --git a/salt/runners/queue.py b/salt/runners/queue.py index 0641ad0bbb..2e1a156715 100644 --- a/salt/runners/queue.py +++ b/salt/runners/queue.py @@ -191,3 +191,33 @@ def process_queue(queue, quantity=1, backend='sqlite'): } event.fire_event(data, tagify([queue, 'process'], prefix='queue')) return data + + +def __get_queue_opts(): + ''' + ''' + queue = __opts__.get('runner_queue', {}).get('queue') + backend = __opts__.get('runner_queue', {}).get('backend', 'pgjsonb') + return {'backend': backend, + 'queue': queue} + + +def insert_runner(fun, args=None, kwargs=None): + ''' + ''' + if args is None: + args = [] + if kwargs is None: + kwargs = {} + queue_kwargs = __get_queue_opts() + data = {'fun': fun, 'args': args, 'kwargs': kwargs} + return __salt__['queue.insert'](items=data, **queue_kwargs) + + +def process_runner(quantity=1): + ''' + ''' + queue_kwargs = __get_queue_opts() + data = process_queue(quantity=quantity, **queue_kwargs) + for job in data['items']: + __salt__[job['fun']](*job['args'], **job['kwargs']) From 6c5bc203442bdca5966ce09c0e9723380e54ab37 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 11:41:29 -0700 Subject: [PATCH 263/370] Handle paths for multiple operating systems --- salt/config/__init__.py | 2 +- salt/syspaths.py | 13 +++++++++++++ tests/unit/test_spm.py | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 1a1c175d89..79d5f0024d 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -1621,7 +1621,7 @@ DEFAULT_SPM_OPTS = { # If set, spm_node_type will be either master or minion, but they should # NOT be a default 'spm_node_type': '', - 'spm_share_dir': '/usr/share/salt/spm' + 'spm_share_dir': os.path.join(salt.syspaths.SHARE_DIR, 'spm'), # <---- Salt master settings overridden by SPM ---------------------- } diff --git a/salt/syspaths.py b/salt/syspaths.py index ba60602459..54b63e5d7c 100644 --- a/salt/syspaths.py +++ b/salt/syspaths.py @@ -74,6 +74,19 @@ if CONFIG_DIR is None: else: CONFIG_DIR = os.path.join(ROOT_DIR, 'etc', 'salt') +SHARE_DIR = __generated_syspaths.SHARE_DIR +if SHARE_DIR is None: + if __PLATFORM.startswith('win'): + SHARE_DIR = os.path.join(ROOT_DIR, 'share') + elif 'freebsd' in __PLATFORM: + SHARE_DIR = os.path.join(ROOT_DIR, 'usr', 'local', 'share', 'salt') + elif 'netbsd' in __PLATFORM: + SHARE_DIR = os.path.join(ROOT_DIR, 'usr', 'share', 'salt') + elif 'sunos5' in __PLATFORM: + SHARE_DIR = os.path.join(ROOT_DIR, 'usr', 'share', 'salt') + else: + SHARE_DIR = os.path.join(ROOT_DIR, 'usr', 'share', 'salt') + CACHE_DIR = __generated_syspaths.CACHE_DIR if CACHE_DIR is None: CACHE_DIR = os.path.join(ROOT_DIR, 'var', 'cache', 'salt') diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index d2af57966b..3cc58e806d 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -41,7 +41,7 @@ __opts__ = { 'verbose': False, 'cache': 'localfs', 'spm_repo_dups': 'ignore', - 'spm_share_dir': '/usr/share/salt/spm', + 'spm_share_dir': os.path.join(_TMP_SPM, 'share'), } _F1 = { From 423e6f74480dfee70d8c96f56ae2219991f9a49f Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 28 Feb 2017 11:48:56 -0700 Subject: [PATCH 264/370] Add docs for Kwargs in pkg.refresh_db --- salt/modules/win_pkg.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index c24d57cbae..6f064e0589 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -481,9 +481,28 @@ def _refresh_db_conditional(saltenv, **kwargs): def refresh_db(**kwargs): ''' - Fectches metadata files and calls :py:func:`pkg.genrepo + Fetches metadata files and calls :py:func:`pkg.genrepo ` to compile updated repository metadata. + Kwargs: + saltenv (str): Salt environment. Default: ``base`` + verbose (bool): + Return verbose data structure which includes 'success_list', a list + of all sls files and the package names contained within. Default + 'False' + failhard (bool): + If ``True``, an error will be raised if any repo SLS files failed to + process. If ``False``, no error will be raised, and a dictionary + containing the full results will be returned. + + Returns: + dict: A dictionary containing the results of the database refresh. + + .. Warning:: + When calling this command from a state using `module.run` be sure to + pass `failhard: False`. Otherwise the state will report failure if it + encounters a bad software definition file. + CLI Example: .. code-block:: bash From 3f187ba4e262cf84815f57dfb6bd4b1bf0bed2dd Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 12:00:11 -0700 Subject: [PATCH 265/370] Update __generated_syspaths --- salt/syspaths.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/syspaths.py b/salt/syspaths.py index 54b63e5d7c..bebc2eab9d 100644 --- a/salt/syspaths.py +++ b/salt/syspaths.py @@ -36,7 +36,8 @@ except ImportError: 'SRV_ROOT_DIR', 'BASE_FILE_ROOTS_DIR', 'BASE_PILLAR_ROOTS_DIR', 'BASE_THORIUM_ROOTS_DIR', 'BASE_MASTER_ROOTS_DIR', 'LOGS_DIR', 'PIDFILE_DIR', - 'SPM_FORMULA_PATH', 'SPM_PILLAR_PATH', 'SPM_REACTOR_PATH'): + 'SPM_FORMULA_PATH', 'SPM_PILLAR_PATH', 'SPM_REACTOR_PATH', + 'SHARE_DIR'): setattr(__generated_syspaths, key, None) From e05f3155f9bec74705da85e1c34fed9288adde60 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Tue, 28 Feb 2017 12:41:43 -0600 Subject: [PATCH 266/370] add documentation --- salt/runners/queue.py | 98 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 7 deletions(-) diff --git a/salt/runners/queue.py b/salt/runners/queue.py index 2e1a156715..8de471f65d 100644 --- a/salt/runners/queue.py +++ b/salt/runners/queue.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- ''' General management and processing of queues. +============================================ This runner facilitates interacting with various queue backends such as the included sqlite3 queue or the planned AWS SQS and Redis queues @@ -25,6 +26,42 @@ reactor is set up to match on event tags for a specific queue and then take infrastructure actions on those minion IDs. These actions might be to delete the minion's key from the master, use salt-cloud to destroy the vm, or some other custom action. + +Queued runners +============== + +Using the Salt Queues, references to the commandline arguments of other runners +can be saved to be processed later. The queue runners require a queue backend +that can store json data (default: :mod:`pgjsonb `). + +Once the queue is setup, the `runner_queue` will need to be configured. + +.. code-block:: yaml + + runner_queue: + queue: runners + backend: pgjsonb + +.. note:: only the queue is required, this defaults to using pgjsonb + +Once this is set, then the following can be added to the scheduler on the +master and it will run the specified amount of commands per time period. + +.. code-block:: yaml + + schedule: + runner queue: + schedule: + function: saltutil.runner + minutes: 1 + args: + - queue.process_runner + kwargs: + quantity: 2 + +The above configuration will pop 2 runner jobs off the runner queue, and then +run them. And it will do this every minute, unless there are any jobs that are +still running from the last time the process_runner task was executed. ''' # Import python libs @@ -193,31 +230,78 @@ def process_queue(queue, quantity=1, backend='sqlite'): return data -def __get_queue_opts(): +def __get_queue_opts(queue=None, backend=None): ''' + Get consistent opts for the queued runners ''' - queue = __opts__.get('runner_queue', {}).get('queue') - backend = __opts__.get('runner_queue', {}).get('backend', 'pgjsonb') + if queue is None: + queue = __opts__.get('runner_queue', {}).get('queue') + if backend is None: + backend = __opts__.get('runner_queue', {}).get('backend', 'pgjsonb') return {'backend': backend, 'queue': queue} -def insert_runner(fun, args=None, kwargs=None): +def insert_runner(fun, args=None, kwargs=None, queue=None, backend=None): ''' + Insert a reference to a runner into the queue so that it can be run later. + + fun + The runner function that is going to be run + + args + list or comma-seperated string of args to send to fun + + kwargs + dictionary of keyword arguments to send to fun + + queue + queue to insert the runner reference into + + backend + backend that to use for the queue + + CLI Example: + + .. code-block:: bash + + salt-run queue.insert_runner test.stdout_print + salt-run queue.insert_runner event.send test_insert_runner kwargs='{"data": {"foo": "bar"}}' + ''' if args is None: args = [] + elif isinstance(args, six.string_types): + args = args.split(',') if kwargs is None: kwargs = {} - queue_kwargs = __get_queue_opts() + queue_kwargs = __get_queue_opts(queue=queue, backend=backend) data = {'fun': fun, 'args': args, 'kwargs': kwargs} return __salt__['queue.insert'](items=data, **queue_kwargs) -def process_runner(quantity=1): +def process_runner(quantity=1, queue=None, backend=None): ''' + Process queued runners + + quantity + number of runners to process + + queue + queue to insert the runner reference into + + backend + backend that to use for the queue + + CLI Example: + + .. code-block:: bash + + salt-run queue.process_runner + salt-run queue.process_runner 5 + ''' - queue_kwargs = __get_queue_opts() + queue_kwargs = __get_queue_opts(queue=queue, backend=backend) data = process_queue(quantity=quantity, **queue_kwargs) for job in data['items']: __salt__[job['fun']](*job['args'], **job['kwargs']) From 63eb61024577c4a046fc07da2017f956809fab35 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Tue, 28 Feb 2017 11:18:11 -0800 Subject: [PATCH 267/370] Per #39710, missing parameter in the schedule.add function --- salt/modules/schedule.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/salt/modules/schedule.py b/salt/modules/schedule.py index ee2920eb43..8e5d2af95b 100644 --- a/salt/modules/schedule.py +++ b/salt/modules/schedule.py @@ -359,8 +359,9 @@ def build_schedule_item(name, **kwargs): else: schedule[name]['splay'] = kwargs['splay'] - for item in ['range', 'when', 'once', 'once_fmt', 'cron', 'returner', - 'return_config', 'return_kwargs', 'until', 'run_on_start']: + for item in ['range', 'when', 'once', 'once_fmt', 'cron', + 'returner', 'after', 'return_config', 'return_kwargs', + 'until', 'run_on_start']: if item in kwargs: schedule[name][item] = kwargs[item] From 4154910dd3ec9e0bdaa4f6496604ecd21c9ca52c Mon Sep 17 00:00:00 2001 From: Calle Pettersson Date: Tue, 28 Feb 2017 21:07:49 +0100 Subject: [PATCH 268/370] Vault: Handle patterns with non-existing keys --- salt/runners/vault.py | 7 +++++-- tests/unit/runners/test_vault.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/salt/runners/vault.py b/salt/runners/vault.py index 4a8a2c4dbe..6495220f44 100644 --- a/salt/runners/vault.py +++ b/salt/runners/vault.py @@ -118,8 +118,11 @@ def _get_policies(minion_id, config): policies = [] for pattern in policy_patterns: - for expanded_pattern in _expand_pattern_lists(pattern, **mappings): - policies.append(expanded_pattern.format(**mappings)) + try: + for expanded_pattern in _expand_pattern_lists(pattern, **mappings): + policies.append(expanded_pattern.format(**mappings)) + except KeyError: + log.warning('Could not resolve policy pattern {0}'.format(pattern)) log.debug('{0} policies: {1}'.format(minion_id, policies)) return policies diff --git a/tests/unit/runners/test_vault.py b/tests/unit/runners/test_vault.py index 826ab0367c..d219c8ab3d 100644 --- a/tests/unit/runners/test_vault.py +++ b/tests/unit/runners/test_vault.py @@ -111,7 +111,8 @@ class VaultTest(TestCase): 'deeply-nested-list:{grains[deep][foo][bar][baz]}': [ 'deeply-nested-list:hello', 'deeply-nested-list:world' - ] + ], + 'should-not-cause-an-exception,but-result-empty:{foo}': [] } with patch('salt.utils.minions.get_minion_data', From 878b21662e3f826a810ae9227af4dac0ff611dc1 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Tue, 28 Feb 2017 13:30:43 -0600 Subject: [PATCH 269/370] add test for queue --- salt/runners/queue.py | 2 +- tests/unit/runners/test_queue.py | 68 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/unit/runners/test_queue.py diff --git a/salt/runners/queue.py b/salt/runners/queue.py index 8de471f65d..76bc8f25e0 100644 --- a/salt/runners/queue.py +++ b/salt/runners/queue.py @@ -277,7 +277,7 @@ def insert_runner(fun, args=None, kwargs=None, queue=None, backend=None): kwargs = {} queue_kwargs = __get_queue_opts(queue=queue, backend=backend) data = {'fun': fun, 'args': args, 'kwargs': kwargs} - return __salt__['queue.insert'](items=data, **queue_kwargs) + return insert(items=data, **queue_kwargs) def process_runner(quantity=1, queue=None, backend=None): diff --git a/tests/unit/runners/test_queue.py b/tests/unit/runners/test_queue.py new file mode 100644 index 0000000000..6a20eee179 --- /dev/null +++ b/tests/unit/runners/test_queue.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +''' +unit tests for the cache runner +''' + +# Import Python Libs +from __future__ import absolute_import + +# Import Salt Testing Libs +from salttesting import skipIf, TestCase +from salttesting.helpers import ensure_in_syspath +from salttesting.mock import ( + NO_MOCK, + NO_MOCK_REASON, + MagicMock, + patch +) + +ensure_in_syspath('../../') + +# Import Salt Libs +from salt.runners import queue as queue_mod +from salt.queues import pgjsonb_queue + +queue_mod.__opts__ = {'sock_dir': '/var/run/salt/master', 'transport': 'zeromq'} +queue_mod.__salt__ = {} + +@skipIf(NO_MOCK, NO_MOCK_REASON) +class QueueTest(TestCase): + ''' + Validate the queue runner + ''' + + def test_insert_runner(self): + queue_insert = MagicMock(return_value=True) + with patch.object(queue_mod, 'insert', queue_insert): + queue_mod.insert_runner('test.stdout_print', queue='salt') + expected_call = { + 'queue': 'salt', + 'items': { + 'fun': 'test.stdout_print', + 'args': [], + 'kwargs': {}, + }, + 'backend': 'pgjsonb', + } + queue_insert.assert_called_once_with(**expected_call) + + def test_process_runner(self): + ret = [{ + 'fun': 'test.stdout_print', + 'args': [], + 'kwargs': {}, + }] + + queue_pop = MagicMock(return_value=ret) + test_stdout_print = MagicMock(return_value=True) + queue_mod.__salt__['test.stdout_print'] = test_stdout_print + with patch.object(queue_mod, 'pop', queue_pop): + queue_mod.process_runner(queue='salt') + queue_pop.assert_called_once_with(queue='salt', quantity=1, backend='pgjsonb') + test_stdout_print.assert_called_once_with() + queue_pop.assert_called_once_with(queue='salt', quantity=1, backend='pgjsonb') + + +if __name__ == '__main__': + from integration import run_tests + run_tests(QueueTest, needs_daemon=False) From 8649c4c22485b6d043c1c668c2851f48dd0eb8f8 Mon Sep 17 00:00:00 2001 From: Tom Williams Date: Thu, 23 Feb 2017 23:48:01 -0500 Subject: [PATCH 270/370] INFRA-4528 - Some docstring updates, and one new log.info() call, for makostack module. --- salt/pillar/makostack.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/salt/pillar/makostack.py b/salt/pillar/makostack.py index a658cbc73b..e42be2af97 100644 --- a/salt/pillar/makostack.py +++ b/salt/pillar/makostack.py @@ -10,19 +10,19 @@ ext_pillar, simply ported to use mako instead of jinja2 for templating. It supports the following features: - multiple config files that are mako templates with support for ``pillar``, - ``__grains__``, ``__salt__``, ``__opts__`` objects + ``__grains__``, ``__salt__``, ``__opts__`` objects. - a config file renders as an ordered list of files. Unless absolute, the paths of these files are relative to the current config file - if absolute, they will be treated literally. -- this list of files are read in ordered as mako templates with support for - ``stack``, ``pillar``, ``__grains__``, ``__salt__``, ``__opts__`` objects -- all these rendered files are then parsed as ``yaml`` -- then all yaml dicts are merged in order with support for the following +- this list of files are read in order as mako templates with support for + ``stack``, ``pillar``, ``__grains__``, ``__salt__``, ``__opts__`` objects. +- all these rendered files are then parsed as ``yaml``. +- then all yaml dicts are merged in order, with support for the following. merging strategies: ``merge-first``, ``merge-last``, ``remove``, and - ``overwrite`` + ``overwrite``. - stack config files can be matched based on ``pillar``, ``grains``, or ``opts`` values, which make it possible to support kind of self-contained - environments + environments. Configuration in Salt --------------------- @@ -41,7 +41,7 @@ MakoStack config file like below: .. code:: yaml ext_pillar: - - stack: /path/to/stack.cfg + - makostack: /path/to/stack.cfg List of config files ~~~~~~~~~~~~~~~~~~~~ @@ -51,7 +51,7 @@ You can also provide a list of config files: .. code:: yaml ext_pillar: - - stack: + - makostack: - /path/to/stack1.cfg - /path/to/stack2.cfg @@ -67,7 +67,7 @@ Here is an example of such a configuration, which should speak by itself: .. code:: yaml ext_pillar: - - stack: + - makostack: pillar:environment: dev: /path/to/dev/stack.cfg prod: /path/to/prod/stack.cfg @@ -78,7 +78,6 @@ Here is an example of such a configuration, which should speak by itself: opts:custom:opt: value: /path/to/stack0.cfg - Grafting data from files to arbitrary namespaces ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -431,7 +430,7 @@ def ext_pillar(minion_id, pillar, *args, **kwargs): else: namespace = None if not os.path.isfile(cfg): - log.warning('Ignoring pillar stack cfg "{0}": ' + log.warning('Ignoring Stack cfg "{0}": ' 'file does not exist'.format(cfg)) continue stack = _process_stack_cfg(cfg, stack, minion_id, pillar, namespace) @@ -459,18 +458,19 @@ def _process_stack_cfg(cfg, stack, minion_id, pillar, namespace): pillar=pillar, stack=stack) obj = yaml.safe_load(p) if not isinstance(obj, dict): - log.info('Ignoring pillar stack template "{0}": Can\'t parse ' + log.info('Ignoring Stack template "{0}": Can\'t parse ' 'as a valid yaml dictionary'.format(path)) continue if namespace: for sub in namespace.split(':')[::-1]: obj = {sub: obj} stack = _merge_dict(stack, obj) + log.info('Stack template {0} parsed'.format(path)) except exceptions.TopLevelLookupException as e: log.info('Stack template "{0}" not found.'.format(path)) continue except Exception as e: - log.info('Ignoring pillar stack template "{0}":'.format(path)) + log.info('Ignoring Stack template "{0}":'.format(path)) log.info('{0}'.format(exceptions.text_error_template().render())) continue return stack From 39bb623bdc363b5ef212b4a23d155fbf4d8883e9 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Tue, 28 Feb 2017 14:53:02 -0600 Subject: [PATCH 271/370] fix pylint --- salt/runners/queue.py | 6 +++--- tests/unit/runners/test_queue.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/runners/queue.py b/salt/runners/queue.py index 76bc8f25e0..fd66273fd9 100644 --- a/salt/runners/queue.py +++ b/salt/runners/queue.py @@ -70,8 +70,8 @@ from __future__ import absolute_import # Import salt libs import salt.loader -import salt.utils.event -from salt.utils.event import tagify +import salt.ext.six as six +from salt.utils.event import get_event, tagify from salt.exceptions import SaltInvocationError @@ -209,7 +209,7 @@ def process_queue(queue, quantity=1, backend='sqlite'): salt-run queue.process_queue myqueue all backend=sqlite ''' # get ready to send an event - event = salt.utils.event.get_event( + event = get_event( 'master', __opts__['sock_dir'], __opts__['transport'], diff --git a/tests/unit/runners/test_queue.py b/tests/unit/runners/test_queue.py index 6a20eee179..bab3e3dd22 100644 --- a/tests/unit/runners/test_queue.py +++ b/tests/unit/runners/test_queue.py @@ -20,11 +20,11 @@ ensure_in_syspath('../../') # Import Salt Libs from salt.runners import queue as queue_mod -from salt.queues import pgjsonb_queue queue_mod.__opts__ = {'sock_dir': '/var/run/salt/master', 'transport': 'zeromq'} queue_mod.__salt__ = {} + @skipIf(NO_MOCK, NO_MOCK_REASON) class QueueTest(TestCase): ''' From 7278a6c868bd82abd83409c8862996a9f5e0e501 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 12:10:48 +0000 Subject: [PATCH 272/370] You need to pass a list. How did this ever pass?! --- tests/integration/modules/test_cp.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/integration/modules/test_cp.py b/tests/integration/modules/test_cp.py index d14e11a39d..e9b0888d06 100644 --- a/tests/integration/modules/test_cp.py +++ b/tests/integration/modules/test_cp.py @@ -513,16 +513,16 @@ class CPModuleTest(integration.ModuleCase): log_to_xfer = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex) open(log_to_xfer, 'w').close() try: - self.run_function('cp.push', log_to_xfer) + self.run_function('cp.push', [log_to_xfer]) tgt_cache_file = os.path.join( - integration.TMP, - 'master-minion-root', - 'cache', - 'minions', - 'minion', - 'files', - tempfile.gettempdir(), - log_to_xfer) + integration.TMP, + 'master-minion-root', + 'cache', + 'minions', + 'minion', + 'files', + tempfile.gettempdir(), + log_to_xfer) self.assertTrue(os.path.isfile(tgt_cache_file), 'File was not cached on the master') finally: os.unlink(tgt_cache_file) From 1daa2e24cd849a2b3e15f9b0aa2355861d2f6477 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 18:06:53 +0000 Subject: [PATCH 273/370] Moved some test supporting modules to tests/support Previously they were in tests/utils which also had test case modules. --- .../netapi/rest_cherrypy/test_app.py | 28 ++-- .../netapi/rest_cherrypy/test_app_pam.py | 25 ++-- tests/support/__init__.py | 1 + tests/support/cherrypy_testclasses.py | 124 ++++++++++++++++++ tests/{utils => support}/cptestcase.py | 0 tests/{utils => support}/mixins.py | 0 tests/unit/netapi/rest_cherrypy/test_tools.py | 2 +- tests/unit/test_test_module_names.py | 3 +- tests/utils/__init__.py | 123 ----------------- 9 files changed, 144 insertions(+), 162 deletions(-) create mode 100644 tests/support/__init__.py create mode 100644 tests/support/cherrypy_testclasses.py rename tests/{utils => support}/cptestcase.py (100%) rename tests/{utils => support}/mixins.py (100%) diff --git a/tests/integration/netapi/rest_cherrypy/test_app.py b/tests/integration/netapi/rest_cherrypy/test_app.py index 629f762cc1..bf69365b9f 100644 --- a/tests/integration/netapi/rest_cherrypy/test_app.py +++ b/tests/integration/netapi/rest_cherrypy/test_app.py @@ -4,26 +4,14 @@ from __future__ import absolute_import import json -# Import salttesting libs -from salttesting.unit import skipIf -from salttesting.helpers import ensure_in_syspath -ensure_in_syspath('../../../') - -from tests.utils import BaseRestCherryPyTest +# Import test support libs +import tests.support.cherrypy_testclasses as cptc # Import 3rd-party libs -# pylint: disable=import-error,unused-import -from salt.ext.six.moves.urllib.parse import urlencode # pylint: disable=no-name-in-module -try: - import cherrypy - HAS_CHERRYPY = True -except ImportError: - HAS_CHERRYPY = False -# pylint: enable=import-error,unused-import +from salt.ext.six.moves.urllib.parse import urlencode # pylint: disable=no-name-in-module,import-error -@skipIf(HAS_CHERRYPY is False, 'CherryPy not installed') -class TestAuth(BaseRestCherryPyTest): +class TestAuth(cptc.BaseRestCherryPyTest): def test_get_root_noauth(self): ''' GET requests to the root URL should not require auth @@ -53,7 +41,7 @@ class TestAuth(BaseRestCherryPyTest): self.assertEqual(response.status, '401 Unauthorized') -class TestLogin(BaseRestCherryPyTest): +class TestLogin(cptc.BaseRestCherryPyTest): auth_creds = ( ('username', 'saltdev'), ('password', 'saltdev'), @@ -95,7 +83,7 @@ class TestLogin(BaseRestCherryPyTest): self.assertEqual(response.status, '200 OK') -class TestRun(BaseRestCherryPyTest): +class TestRun(cptc.BaseRestCherryPyTest): auth_creds = ( ('username', 'saltdev_auto'), ('password', 'saltdev'), @@ -134,7 +122,7 @@ class TestRun(BaseRestCherryPyTest): self.assertEqual(response.status, '401 Unauthorized') -class TestWebhookDisableAuth(BaseRestCherryPyTest): +class TestWebhookDisableAuth(cptc.BaseRestCherryPyTest): __opts__ = { 'rest_cherrypy': { 'port': 8000, @@ -155,7 +143,7 @@ class TestWebhookDisableAuth(BaseRestCherryPyTest): self.assertEqual(response.status, '200 OK') -class TestArgKwarg(BaseRestCherryPyTest): +class TestArgKwarg(cptc.BaseRestCherryPyTest): auth_creds = ( ('username', 'saltdev'), ('password', 'saltdev'), diff --git a/tests/integration/netapi/rest_cherrypy/test_app_pam.py b/tests/integration/netapi/rest_cherrypy/test_app_pam.py index c01d5e61fa..efeedb5eb7 100644 --- a/tests/integration/netapi/rest_cherrypy/test_app_pam.py +++ b/tests/integration/netapi/rest_cherrypy/test_app_pam.py @@ -9,26 +9,19 @@ import os # Import salttesting libs from salttesting.unit import skipIf -from salttesting.helpers import ( - ensure_in_syspath, - destructiveTest) -ensure_in_syspath('../../../') +from salttesting.helpers import destructiveTest -from tests.utils import BaseRestCherryPyTest +# Import test support libs +import tests.support.cherrypy_testclasses as cptc +from tests import integration # Import Salt Libs import salt.utils -from tests import integration # Import 3rd-party libs -# pylint: disable=import-error,unused-import -from salt.ext.six.moves.urllib.parse import urlencode # pylint: disable=no-name-in-module -try: +from salt.ext.six.moves.urllib.parse import urlencode # pylint: disable=no-name-in-module,import-error +if cptc.HAS_CHERRYPY: import cherrypy - HAS_CHERRYPY = True -except ImportError: - HAS_CHERRYPY = False -# pylint: enable=import-error,unused-import USERA = 'saltdev' USERA_PWD = 'saltdev' @@ -40,8 +33,8 @@ AUTH_CREDS = { 'eauth': 'pam'} -@skipIf(HAS_CHERRYPY is False, 'CherryPy not installed') -class TestAuthPAM(BaseRestCherryPyTest, integration.ModuleCase): +@skipIf(cptc.HAS_CHERRYPY is False, 'CherryPy not installed') +class TestAuthPAM(cptc.BaseRestCherryPyTest, integration.ModuleCase): ''' Test auth with pam using salt-api ''' @@ -137,5 +130,5 @@ class TestAuthPAM(BaseRestCherryPyTest, integration.ModuleCase): # Remove saltdev user if USERA in user_list: self.run_function('user.delete', [USERA], remove=True) - #need to exit cherypy engine + # need to exit cherypy engine cherrypy.engine.exit() diff --git a/tests/support/__init__.py b/tests/support/__init__.py new file mode 100644 index 0000000000..40a96afc6f --- /dev/null +++ b/tests/support/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/tests/support/cherrypy_testclasses.py b/tests/support/cherrypy_testclasses.py new file mode 100644 index 0000000000..83fc23b0a8 --- /dev/null +++ b/tests/support/cherrypy_testclasses.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import + +try: + import cherrypy + + HAS_CHERRYPY = True +except ImportError: + HAS_CHERRYPY = False + +import os + +import salt.config +from tests.integration import TMP_CONF_DIR + +if HAS_CHERRYPY: + from tests.support.cptestcase import BaseCherryPyTestCase + from salt.netapi.rest_cherrypy import app +else: + from salttesting.unit import ( + TestCase, + skipIf, + ) + + @skipIf(HAS_CHERRYPY is False, 'The CherryPy python package needs to be installed') + class BaseCherryPyTestCase(TestCase): + pass + + class BaseToolsTest(BaseCherryPyTestCase): + pass + + +class BaseRestCherryPyTest(BaseCherryPyTestCase): + ''' + A base TestCase subclass for the rest_cherrypy module + + This mocks all interactions with Salt-core and sets up a dummy + (unsubscribed) CherryPy web server. + ''' + __opts__ = None + + def __init__(self, *args, **kwargs): + super(BaseRestCherryPyTest, self).__init__(*args, **kwargs) + + master_conf = os.path.join(TMP_CONF_DIR, 'master') + self.config = salt.config.client_config(master_conf) + + def setUp(self, *args, **kwargs): + # Make a local reference to the CherryPy app so we can mock attributes. + self.app = app + + __opts__ = self.config.copy() + __opts__.update(self.__opts__ or { + 'external_auth': { + 'auto': { + 'saltdev': [ + '@wheel', + '@runner', + '.*', + ], + }, + 'pam': { + 'saltdev': [ + '@wheel', + '@runner', + '.*', + ], + + } + }, + 'rest_cherrypy': { + 'port': 8000, + 'debug': True, + }, + }) + + root, apiopts, conf = app.get_app(__opts__) + + cherrypy.tree.mount(root, '/', conf) + cherrypy.server.unsubscribe() + cherrypy.engine.start() + + def tearDown(self): + cherrypy.engine.exit() + + +class Root(object): + ''' + The simplest CherryPy app needed to test individual tools + ''' + exposed = True + + _cp_config = {} + + def GET(self): + return {'return': ['Hello world.']} + + def POST(self, *args, **kwargs): + return {'return': [{'args': args}, {'kwargs': kwargs}]} + + +if HAS_CHERRYPY: + class BaseToolsTest(BaseCherryPyTestCase): # pylint: disable=E0102 + ''' + A base class so tests can selectively turn individual tools on for testing + ''' + conf = { + '/': { + 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), + }, + } + + def setUp(self): + if not hasattr(self, '_cp_config'): + self._cp_config = {} + Root._cp_config = self._cp_config + root = Root() + + cherrypy.tree.mount(root, '/', self.conf) + cherrypy.server.unsubscribe() + cherrypy.engine.start() + + def tearDown(self): + cherrypy.engine.exit() diff --git a/tests/utils/cptestcase.py b/tests/support/cptestcase.py similarity index 100% rename from tests/utils/cptestcase.py rename to tests/support/cptestcase.py diff --git a/tests/utils/mixins.py b/tests/support/mixins.py similarity index 100% rename from tests/utils/mixins.py rename to tests/support/mixins.py diff --git a/tests/unit/netapi/rest_cherrypy/test_tools.py b/tests/unit/netapi/rest_cherrypy/test_tools.py index 4b19821457..867309cb91 100644 --- a/tests/unit/netapi/rest_cherrypy/test_tools.py +++ b/tests/unit/netapi/rest_cherrypy/test_tools.py @@ -8,7 +8,7 @@ import json import yaml from salt.ext.six.moves.urllib.parse import urlencode # pylint: disable=no-name-in-module,import-error -from tests.utils import BaseToolsTest +from tests.support.cherrypy_testclasses import BaseToolsTest class TestOutFormats(BaseToolsTest): diff --git a/tests/unit/test_test_module_names.py b/tests/unit/test_test_module_names.py index 731729602e..2489dc9833 100644 --- a/tests/unit/test_test_module_names.py +++ b/tests/unit/test_test_module_names.py @@ -18,6 +18,7 @@ import integration EXCLUDED_DIRS = [ 'tests/pkg', 'tests/perf', + 'tests/support', 'tests/unit/utils/cache_mods', 'tests/unit/modules/inspectlib', 'tests/unit/modules/zypp/', @@ -40,8 +41,6 @@ EXCLUDED_FILES = [ 'tests/modparser.py', 'tests/committer_parser.py', 'tests/integration/utils/testprogram.py', - 'tests/utils/cptestcase.py', - 'tests/utils/mixins.py' ] diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py index a24de791a4..40a96afc6f 100644 --- a/tests/utils/__init__.py +++ b/tests/utils/__init__.py @@ -1,124 +1 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - -try: - import cherrypy - - HAS_CHERRYPY = True -except ImportError: - HAS_CHERRYPY = False - -import os - -import salt.config -from ..integration import TMP_CONF_DIR - -if HAS_CHERRYPY: - from .cptestcase import BaseCherryPyTestCase - from salt.netapi.rest_cherrypy import app -else: - from salttesting.unit import ( - TestCase, - skipIf, - ) - - @skipIf(HAS_CHERRYPY is False, 'The CherryPy python package needs to be installed') - class BaseCherryPyTestCase(TestCase): - pass - - class BaseToolsTest(BaseCherryPyTestCase): - pass - - -class BaseRestCherryPyTest(BaseCherryPyTestCase): - ''' - A base TestCase subclass for the rest_cherrypy module - - This mocks all interactions with Salt-core and sets up a dummy - (unsubscribed) CherryPy web server. - ''' - __opts__ = None - - def __init__(self, *args, **kwargs): - super(BaseRestCherryPyTest, self).__init__(*args, **kwargs) - - master_conf = os.path.join(TMP_CONF_DIR, 'master') - self.config = salt.config.client_config(master_conf) - - def setUp(self, *args, **kwargs): - # Make a local reference to the CherryPy app so we can mock attributes. - self.app = app - - __opts__ = self.config.copy() - __opts__.update(self.__opts__ or { - 'external_auth': { - 'auto': { - 'saltdev': [ - '@wheel', - '@runner', - '.*', - ], - }, - 'pam': { - 'saltdev': [ - '@wheel', - '@runner', - '.*', - ], - - } - }, - 'rest_cherrypy': { - 'port': 8000, - 'debug': True, - }, - }) - - root, apiopts, conf = app.get_app(__opts__) - - cherrypy.tree.mount(root, '/', conf) - cherrypy.server.unsubscribe() - cherrypy.engine.start() - - def tearDown(self): - cherrypy.engine.exit() - - -class Root(object): - ''' - The simplest CherryPy app needed to test individual tools - ''' - exposed = True - - _cp_config = {} - - def GET(self): - return {'return': ['Hello world.']} - - def POST(self, *args, **kwargs): - return {'return': [{'args': args}, {'kwargs': kwargs}]} - - -if HAS_CHERRYPY: - class BaseToolsTest(BaseCherryPyTestCase): # pylint: disable=E0102 - ''' - A base class so tests can selectively turn individual tools on for testing - ''' - conf = { - '/': { - 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), - }, - } - - def setUp(self): - if not hasattr(self, '_cp_config'): - self._cp_config = {} - Root._cp_config = self._cp_config - root = Root() - - cherrypy.tree.mount(root, '/', self.conf) - cherrypy.server.unsubscribe() - cherrypy.engine.start() - - def tearDown(self): - cherrypy.engine.exit() From 2a9d2beb022b5f204a031ce80841f7f25492697a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 19:02:08 +0000 Subject: [PATCH 274/370] The order is shady under Py3 /cc @cachedout @rallytime --- tests/support/helpers.py | 77 ++++++++++++++++++++++ tests/unit/beacons/test_glxinfo.py | 2 +- tests/unit/serializers/test_serializers.py | 5 ++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 tests/support/helpers.py diff --git a/tests/support/helpers.py b/tests/support/helpers.py new file mode 100644 index 0000000000..83614becf5 --- /dev/null +++ b/tests/support/helpers.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +''' + :copyright: © 2017 by the SaltStack Team, see AUTHORS for more details. + :license: Apache 2.0, see LICENSE for more details. + + + tests.support.helpers + ~~~~~~~~~~~~~~~~~~~~~ + + Test support helpers +''' + +# Import python libs +from __future__ import absolute_import +import time +import inspect +import logging +import functools + +# Import 3rd-party libs +from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin + + +log = logging.getLogger(__name__) + + +def flaky(caller=None, condition=True): + ''' + Mark a test as flaky. The test will attempt to run five times, + looking for a successful run. After an immediate second try, + it will use an exponential backoff starting with one second. + + .. code-block:: python + + class MyTestCase(TestCase): + + @flaky + def test_sometimes_works(self): + pass + ''' + if caller is None: + return functools.partial(flaky, condition=condition) + + if isinstance(condition, bool) and condition is False: + # Don't even decorate + return caller + elif callable(condition): + if condition() is False: + # Don't even decorate + return caller + + if inspect.isclass(caller): + attrs = [n for n in dir(caller) if n.startswith('test_')] + for attrname in attrs: + try: + function = getattr(caller, attrname) + if not inspect.isfunction(function) and not inspect.ismethod(function): + continue + setattr(caller, attrname, flaky(caller=function, condition=condition)) + except Exception as exc: + log.exception(exc) + continue + return caller + + @functools.wraps(caller) + def wrap(cls): + for attempt in range(0, 4): + try: + return caller(cls) + except AssertionError as exc: + if attempt == 4: + raise exc + backoff_time = attempt ** 2 + log.info('Found AssertionError. Waiting %s seconds to retry.', backoff_time) + time.sleep(backoff_time) + return cls + return wrap diff --git a/tests/unit/beacons/test_glxinfo.py b/tests/unit/beacons/test_glxinfo.py index 87e6367eb1..97a8f1f59e 100644 --- a/tests/unit/beacons/test_glxinfo.py +++ b/tests/unit/beacons/test_glxinfo.py @@ -11,7 +11,7 @@ from salttesting import skipIf, TestCase from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock # Import test suite libs -from tests.utils.mixins import LoaderModuleMockMixin +from tests.support.mixins import LoaderModuleMockMixin @skipIf(NO_MOCK, NO_MOCK_REASON) diff --git a/tests/unit/serializers/test_serializers.py b/tests/unit/serializers/test_serializers.py index ea7c524afc..16d9794b01 100644 --- a/tests/unit/serializers/test_serializers.py +++ b/tests/unit/serializers/test_serializers.py @@ -14,15 +14,20 @@ from textwrap import dedent # Import 3rd party libs import jinja2 +import salt.ext.six as six # Import salt libs from salt.serializers import json, yamlex, yaml, msgpack, python, configparser from salt.serializers import SerializationError from salt.utils.odict import OrderedDict +# Import test support libs +from tests.support.helpers import flaky + SKIP_MESSAGE = '%s is unavailable, do prerequisites have been met?' +@flaky(condition=six.PY3) class TestSerializers(TestCase): @skipIf(not json.available, SKIP_MESSAGE % 'json') def test_serialize_json(self): From 53eff91efa662693547a7ddb7936d045d85c1920 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 19:39:06 +0000 Subject: [PATCH 275/370] Re-enable the test since we now have the flaky decorator --- tests/support/helpers.py | 4 ++-- tests/unit/transport/test_zeromq.py | 24 +++++++++--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/support/helpers.py b/tests/support/helpers.py index 83614becf5..68c3ae1d49 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -67,11 +67,11 @@ def flaky(caller=None, condition=True): for attempt in range(0, 4): try: return caller(cls) - except AssertionError as exc: + except Exception as exc: if attempt == 4: raise exc backoff_time = attempt ** 2 - log.info('Found AssertionError. Waiting %s seconds to retry.', backoff_time) + log.info('Found Exception. Waiting %s seconds to retry.', backoff_time) time.sleep(backoff_time) return cls return wrap diff --git a/tests/unit/transport/test_zeromq.py b/tests/unit/transport/test_zeromq.py index 061296de78..d997697705 100644 --- a/tests/unit/transport/test_zeromq.py +++ b/tests/unit/transport/test_zeromq.py @@ -10,14 +10,15 @@ import time import threading import platform +# Import 3rd-party libs import zmq.eventloop.ioloop # support pyzmq 13.0.x, TODO: remove once we force people to 14.0.x if not hasattr(zmq.eventloop.ioloop, 'ZMQIOLoop'): zmq.eventloop.ioloop.ZMQIOLoop = zmq.eventloop.ioloop.IOLoop from tornado.testing import AsyncTestCase - import tornado.gen +# Import Salt libs import salt.config import salt.ext.six as six import salt.utils @@ -25,16 +26,15 @@ import salt.transport.server import salt.transport.client import salt.exceptions + # Import Salt Testing libs from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -ensure_in_syspath('../') -import integration - -# Import Salt libs -from unit.transport.test_req import ReqChannelMixin -from unit.transport.test_pub import PubChannelMixin +# Import test support libs +import tests.integration as integration +from tests.support.helpers import flaky +from tests.unit.transport.test_req import ReqChannelMixin +from tests.unit.transport.test_pub import PubChannelMixin ON_SUSE = False if 'SuSE' in platform.dist(): @@ -117,7 +117,7 @@ class ClearReqTestCases(BaseZMQReqCase, ReqChannelMixin): raise tornado.gen.Return((payload, {'fun': 'send_clear'})) -@skipIf(True, 'Skipping flaky test until Jenkins is moved to C7.') +@flaky @skipIf(ON_SUSE, 'Skipping until https://github.com/saltstack/salt/issues/32902 gets fixed') class AESReqTestCases(BaseZMQReqCase, ReqChannelMixin): def setUp(self): @@ -221,9 +221,3 @@ class AsyncPubChannelTest(BaseZMQPubCase, PubChannelMixin): ''' def get_new_ioloop(self): return zmq.eventloop.ioloop.ZMQIOLoop() - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ClearReqTestCases, needs_daemon=False) - run_tests(AESReqTestCases, needs_daemon=False) From 08804932c3ff197e072147eedb8128dd283746e2 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 26 Feb 2017 14:20:41 +0000 Subject: [PATCH 276/370] Using pytest start_daemon --- tests/integration/__init__.py | 544 +++++++----------- .../files/engines/runtests_engine.py | 41 +- tests/runtests.py | 65 ++- tests/support/paths.py | 134 +++++ tests/support/processes.py | 192 +++++++ 5 files changed, 605 insertions(+), 371 deletions(-) create mode 100644 tests/support/paths.py create mode 100644 tests/support/processes.py diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 24ae66c446..c9ab2d856c 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -34,12 +34,19 @@ STATE_FUNCTION_RUNNING_RE = re.compile( r'''The function (?:"|')(?P.*)(?:"|') is running as PID ''' r'(?P[\d]+) and was started at (?P.*) with jid (?P[\d]+)' ) -INTEGRATION_TEST_DIR = os.path.dirname( - os.path.normpath(os.path.abspath(__file__)) -) + +TESTS_DIR = os.path.dirname(os.path.dirname(os.path.normpath(os.path.abspath(__file__)))) if os.name == 'nt': - INTEGRATION_TEST_DIR = INTEGRATION_TEST_DIR.replace('\\', '\\\\') -CODE_DIR = os.path.dirname(os.path.dirname(INTEGRATION_TEST_DIR)) + TESTS_DIR = TESTS_DIR.replace('\\', '\\\\') +CODE_DIR = os.path.dirname(TESTS_DIR) + +# Let's inject CODE_DIR so salt is importable if not there already +if CODE_DIR not in sys.path: + sys.path.insert(0, CODE_DIR) + +# Import salt tests support dirs +from tests.support.paths import * # pylint: disable=wildcard-import +from tests.support.processes import * # pylint: disable=wildcard-import # Import Salt Testing libs from salttesting import TestCase @@ -49,9 +56,6 @@ from salttesting.parser import PNUM, print_header, SaltTestcaseParser from salttesting.helpers import requires_sshd_server from salttesting.helpers import ensure_in_syspath, RedirectStdStreams -# Update sys.path -ensure_in_syspath(CODE_DIR) - # Import Salt libs import salt import salt.config @@ -103,6 +107,8 @@ if salt.utils.is_windows(): from tornado import gen from tornado import ioloop +# Import salt tests support libs +from tests.support.processes import SaltMaster, SaltMinion, SaltSyndic try: from salttesting.helpers import terminate_process_pid except ImportError: @@ -190,57 +196,6 @@ except ImportError: if children: psutil.wait_procs(children, timeout=1, callback=lambda proc: kill_children(children, kill=True)) - -SYS_TMP_DIR = os.path.realpath( - # Avoid ${TMPDIR} and gettempdir() on MacOS as they yield a base path too long - # for unix sockets: ``error: AF_UNIX path too long`` - # Gentoo Portage prefers ebuild tests are rooted in ${TMPDIR} - os.environ.get('TMPDIR', tempfile.gettempdir()) if not salt.utils.is_darwin() else '/tmp' -) -TMP = os.path.join(SYS_TMP_DIR, 'salt-tests-tmpdir') -FILES = os.path.join(INTEGRATION_TEST_DIR, 'files') -PYEXEC = 'python{0}.{1}'.format(*sys.version_info) -MOCKBIN = os.path.join(INTEGRATION_TEST_DIR, 'mockbin') -SCRIPT_DIR = os.path.join(CODE_DIR, 'scripts') -TMP_STATE_TREE = os.path.join(SYS_TMP_DIR, 'salt-temp-state-tree') -TMP_PRODENV_STATE_TREE = os.path.join(SYS_TMP_DIR, 'salt-temp-prodenv-state-tree') -TMP_CONF_DIR = os.path.join(TMP, 'config') -TMP_SUB_MINION_CONF_DIR = os.path.join(TMP_CONF_DIR, 'sub-minion') -TMP_SYNDIC_MINION_CONF_DIR = os.path.join(TMP_CONF_DIR, 'syndic-minion') -TMP_SYNDIC_MASTER_CONF_DIR = os.path.join(TMP_CONF_DIR, 'syndic-master') -CONF_DIR = os.path.join(INTEGRATION_TEST_DIR, 'files', 'conf') -PILLAR_DIR = os.path.join(FILES, 'pillar') -TMP_SCRIPT_DIR = os.path.join(TMP, 'scripts') -ENGINES_DIR = os.path.join(FILES, 'engines') -LOG_HANDLERS_DIR = os.path.join(FILES, 'log_handlers') - -SCRIPT_TEMPLATES = { - 'salt': [ - 'from salt.scripts import salt_main\n', - 'if __name__ == \'__main__\':\n' - ' salt_main()' - ], - 'salt-api': [ - 'import salt.cli\n', - 'def main():\n', - ' sapi = salt.cli.SaltAPI()', - ' sapi.start()\n', - 'if __name__ == \'__main__\':', - ' main()' - ], - 'common': [ - 'from salt.scripts import salt_{0}\n', - 'from salt.utils import is_windows\n\n', - 'if __name__ == \'__main__\':\n', - ' if is_windows():\n', - ' import os.path\n', - ' import py_compile\n', - ' cfile = os.path.splitext(__file__)[0] + ".pyc"\n', - ' if not os.path.exists(cfile):\n', - ' py_compile.compile(__file__, cfile)\n', - ' salt_{0}()' - ] -} RUNTIME_CONFIGS = {} log = logging.getLogger(__name__) @@ -409,273 +364,6 @@ class SocketServerRequestHandler(socketserver.StreamRequestHandler): log.exception(exc) -class ScriptPathMixin(object): - - def get_script_path(self, script_name): - ''' - Return the path to a testing runtime script - ''' - if not os.path.isdir(TMP_SCRIPT_DIR): - os.makedirs(TMP_SCRIPT_DIR) - - script_path = os.path.join(TMP_SCRIPT_DIR, - 'cli_{0}.py'.format(script_name.replace('-', '_'))) - - if not os.path.isfile(script_path): - log.info('Generating {0}'.format(script_path)) - - # Late import - import salt.utils - - with salt.utils.fopen(script_path, 'w') as sfh: - script_template = SCRIPT_TEMPLATES.get(script_name, None) - if script_template is None: - script_template = SCRIPT_TEMPLATES.get('common', None) - if script_template is None: - raise RuntimeError( - '{0} does not know how to handle the {1} script'.format( - self.__class__.__name__, - script_name - ) - ) - sfh.write( - '#!{0}\n\n'.format(sys.executable) + - 'import sys\n' + - 'CODE_DIR="{0}"\n'.format(CODE_DIR) + - 'if CODE_DIR not in sys.path:\n' + - ' sys.path.insert(0, CODE_DIR)\n\n' + - '\n'.join(script_template).format(script_name.replace('salt-', '')) - ) - fst = os.stat(script_path) - os.chmod(script_path, fst.st_mode | stat.S_IEXEC) - - log.info('Returning script path %r', script_path) - return script_path - - -class SaltScriptBase(ScriptPathMixin): - ''' - Base class for Salt CLI scripts - ''' - - cli_script_name = None - - def __init__(self, - config, - config_dir, - bin_dir_path, - io_loop=None): - self.config = config - self.config_dir = config_dir - self.bin_dir_path = bin_dir_path - self._io_loop = io_loop - - @property - def io_loop(self): - ''' - Return an IOLoop - ''' - if self._io_loop is None: - self._io_loop = ioloop.IOLoop.current() - return self._io_loop - - def get_script_args(self): # pylint: disable=no-self-use - ''' - Returns any additional arguments to pass to the CLI script - ''' - return [] - - -class SaltDaemonScriptBase(SaltScriptBase, ShellTestCase): - ''' - Base class for Salt Daemon CLI scripts - ''' - - def __init__(self, *args, **kwargs): - super(SaltDaemonScriptBase, self).__init__(*args, **kwargs) - self._running = multiprocessing.Event() - self._connectable = multiprocessing.Event() - self._process = None - - def is_alive(self): - ''' - Returns true if the process is alive - ''' - return self._running.is_set() - - def get_check_ports(self): # pylint: disable=no-self-use - ''' - Return a list of ports to check against to ensure the daemon is running - ''' - return [] - - def start(self): - ''' - Start the daemon subprocess - ''' - self._process = salt.utils.process.SignalHandlingMultiprocessingProcess( - target=self._start, args=(self._running,)) - self._process.start() - self._running.set() - return True - - def _start(self, running_event): - ''' - The actual, coroutine aware, start method - ''' - log.info('Starting %s %s DAEMON', self.display_name, self.__class__.__name__) - proc_args = [ - self.get_script_path(self.cli_script_name), - '-c', - self.config_dir, - ] + self.get_script_args() - if salt.utils.is_windows(): - # Windows need the python executable to come first - proc_args.insert(0, sys.executable) - log.info('Running \'%s\' from %s...', ' '.join(proc_args), self.__class__.__name__) - - try: - terminal = NonBlockingPopen(proc_args, cwd=CODE_DIR) - - while running_event.is_set() and terminal.poll() is None: - # We're not actually interested in processing the output, just consume it - if terminal.stdout is not None: - terminal.recv() - if terminal.stderr is not None: - terminal.recv_err() - time.sleep(0.125) - except (SystemExit, KeyboardInterrupt): - pass - - terminate_process_pid(terminal.pid) -# terminal.communicate() - - def terminate(self): - ''' - Terminate the started daemon - ''' - log.info('Terminating %s %s DAEMON', self.display_name, self.__class__.__name__) - self._running.clear() - self._connectable.clear() - time.sleep(0.0125) - terminate_process_pid(self._process.pid) -# self._process.join() - log.info('%s %s DAEMON terminated', self.display_name, self.__class__.__name__) - - def wait_until_running(self, timeout=None): - ''' - Blocking call to wait for the daemon to start listening - ''' - if self._connectable.is_set(): - return True - try: - return self.io_loop.run_sync(self._wait_until_running, timeout=timeout) - except ioloop.TimeoutError: - return False - - @gen.coroutine - def _wait_until_running(self): - ''' - The actual, coroutine aware, call to wait for the daemon to start listening - ''' - check_ports = self.get_check_ports() - log.debug( - '%s is checking the following ports to assure running status: %s', - self.__class__.__name__, - check_ports - ) - while self._running.is_set(): - if not check_ports: - self._connectable.set() - break - for port in set(check_ports): - if isinstance(port, int): - log.trace('Checking connectable status on port: %s', port) - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - conn = sock.connect_ex(('localhost', port)) - if conn == 0: - log.debug('Port %s is connectable!', port) - check_ports.remove(port) - try: - sock.shutdown(socket.SHUT_RDWR) - sock.close() - except socket.error as exc: - if not sys.platform.startswith('darwin'): - raise - try: - if exc.errno != errno.ENOTCONN: - raise - except AttributeError: - # This is not macOS !? - pass - del sock - elif isinstance(port, str): - joined = self.run_run('manage.joined', config_dir=self.config_dir) - joined = [x.lstrip('- ') for x in joined] - if port in joined: - check_ports.remove(port) - yield gen.sleep(0.125) - # A final sleep to allow the ioloop to do other things - yield gen.sleep(0.125) - log.info('All ports checked. %s running!', self.cli_script_name) - raise gen.Return(self._connectable.is_set()) - - -class SaltMinion(SaltDaemonScriptBase): - ''' - Class which runs the salt-minion daemon - ''' - - cli_script_name = 'salt-minion' - - def get_script_args(self): - script_args = ['-l', 'quiet'] - if salt.utils.is_windows() is False: - script_args.append('--disable-keepalive') - return script_args - - def get_check_ports(self): - if salt.utils.is_windows(): - return set([self.config['tcp_pub_port'], - self.config['tcp_pull_port']]) - else: - return set([self.config['id']]) - - -class SaltMaster(SaltDaemonScriptBase): - ''' - Class which runs the salt-minion daemon - ''' - - cli_script_name = 'salt-master' - - def get_check_ports(self): - #return set([self.config['runtests_conn_check_port']]) - return set([self.config['ret_port'], - self.config['publish_port']]) - # Disabled along with Pytest config until fixed. -# self.config['runtests_conn_check_port']]) - - def get_script_args(self): - #return ['-l', 'debug'] - return ['-l', 'quiet'] - - -class SaltSyndic(SaltDaemonScriptBase): - ''' - Class which runs the salt-syndic daemon - ''' - - cli_script_name = 'salt-syndic' - - def get_script_args(self): - #return ['-l', 'debug'] - return ['-l', 'quiet'] - - def get_check_ports(self): - return set() - - class TestDaemon(object): ''' Set up the master and minion daemons, and run related cases @@ -787,39 +475,184 @@ class TestDaemon(object): self.log_server_process = threading.Thread(target=self.log_server.serve_forever) self.log_server_process.daemon = True self.log_server_process.start() - - self.master_process = SaltMaster(self.master_opts, TMP_CONF_DIR, SCRIPT_DIR) - self.master_process.display_name = 'salt-master' - self.minion_process = SaltMinion(self.minion_opts, TMP_CONF_DIR, SCRIPT_DIR) - self.minion_process.display_name = 'salt-minion' - self.sub_minion_process = SaltMinion(self.sub_minion_opts, TMP_SUB_MINION_CONF_DIR, SCRIPT_DIR) - self.sub_minion_process.display_name = 'sub salt-minion' - self.smaster_process = SaltMaster(self.syndic_master_opts, TMP_SYNDIC_MASTER_CONF_DIR, SCRIPT_DIR) - self.smaster_process.display_name = 'syndic salt-master' - self.syndic_process = SaltSyndic(self.syndic_opts, TMP_SYNDIC_MINION_CONF_DIR, SCRIPT_DIR) - self.syndic_process.display_name = 'salt-syndic' - for process in (self.master_process, self.minion_process, self.sub_minion_process, - self.smaster_process, self.syndic_process): + try: sys.stdout.write( - ' * {LIGHT_YELLOW}Starting {0} ... {ENDC}'.format( - process.display_name, - **self.colors - ) + ' * {LIGHT_YELLOW}Starting salt-master ... {ENDC}'.format(**self.colors) ) sys.stdout.flush() - process.start() - process.wait_until_running(timeout=60) + self.master_process = start_daemon( + daemon_name='salt-master', + daemon_id=self.master_opts['id'], + daemon_log_prefix='salt-master/{}'.format(self.master_opts['id']), + daemon_cli_script_name='master', + daemon_config=self.master_opts, + daemon_config_dir=TMP_CONF_DIR, + daemon_class=SaltMaster, + bin_dir_path=SCRIPT_DIR, + fail_hard=True, + start_timeout=30) sys.stdout.write( '\r{0}\r'.format( ' ' * getattr(self.parser.options, 'output_columns', PNUM) ) ) sys.stdout.write( - ' * {LIGHT_GREEN}Starting {0} ... STARTED!\n{ENDC}'.format( - process.display_name, - **self.colors + ' * {LIGHT_GREEN}Starting salt-master ... STARTED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + except (RuntimeWarning, RuntimeError): + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) ) ) + sys.stdout.write( + ' * {LIGHT_RED}Starting salt-master ... FAILED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + + try: + sys.stdout.write( + ' * {LIGHT_YELLOW}Starting salt-minion ... {ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + self.minion_process = start_daemon( + daemon_name='salt-minion', + daemon_id=self.master_opts['id'], + daemon_log_prefix='salt-minion/{}'.format(self.minion_opts['id']), + daemon_cli_script_name='minion', + daemon_config=self.minion_opts, + daemon_config_dir=TMP_CONF_DIR, + daemon_class=SaltMinion, + bin_dir_path=SCRIPT_DIR, + fail_hard=True, + start_timeout=30) + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_GREEN}Starting salt-minion ... STARTED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + except (RuntimeWarning, RuntimeError): + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_RED}Starting salt-minion ... FAILED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + + try: + sys.stdout.write( + ' * {LIGHT_YELLOW}Starting sub salt-minion ... {ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + self.sub_minion_process = start_daemon( + daemon_name='sub salt-minion', + daemon_id=self.master_opts['id'], + daemon_log_prefix='sub-salt-minion/{}'.format(self.sub_minion_opts['id']), + daemon_cli_script_name='minion', + daemon_config=self.sub_minion_opts, + daemon_config_dir=TMP_SUB_MINION_CONF_DIR, + daemon_class=SaltMinion, + bin_dir_path=SCRIPT_DIR, + fail_hard=True, + start_timeout=30) + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_GREEN}Starting sub salt-minion ... STARTED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + except (RuntimeWarning, RuntimeError): + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_RED}Starting sub salt-minion ... FAILED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + + try: + sys.stdout.write( + ' * {LIGHT_YELLOW}Starting syndic salt-master ... {ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + self.smaster_process = start_daemon( + daemon_name='salt-smaster', + daemon_id=self.syndic_master_opts['id'], + daemon_log_prefix='salt-smaster/{}'.format(self.syndic_master_opts['id']), + daemon_cli_script_name='master', + daemon_config=self.syndic_master_opts, + daemon_config_dir=TMP_SYNDIC_MASTER_CONF_DIR, + daemon_class=SaltMaster, + bin_dir_path=SCRIPT_DIR, + fail_hard=True, + start_timeout=30) + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_GREEN}Starting syndic salt-master ... STARTED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + except (RuntimeWarning, RuntimeError): + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_RED}Starting syndic salt-master ... FAILED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + + try: + sys.stdout.write( + ' * {LIGHT_YELLOW}Starting salt-syndic ... {ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + self.syndic_process = start_daemon( + daemon_name='salt-syndic', + daemon_id=self.syndic_opts['id'], + daemon_log_prefix='salt-syndic/{}'.format(self.syndic_opts['id']), + daemon_cli_script_name='syndic', + daemon_config=self.syndic_opts, + daemon_config_dir=TMP_SYNDIC_MINION_CONF_DIR, + daemon_class=SaltSyndic, + bin_dir_path=SCRIPT_DIR, + fail_hard=True, + start_timeout=30) + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_GREEN}Starting salt-syndic ... STARTED!\n{ENDC}'.format(**self.colors) + ) + sys.stdout.flush() + except (RuntimeWarning, RuntimeError): + sys.stdout.write( + '\r{0}\r'.format( + ' ' * getattr(self.parser.options, 'output_columns', PNUM) + ) + ) + sys.stdout.write( + ' * {LIGHT_RED}Starting salt-syndic ... FAILED!\n{ENDC}'.format(**self.colors) + ) sys.stdout.flush() def start_raet_daemons(self): @@ -1185,7 +1018,22 @@ class TestDaemon(object): syndic_opts[optname] = optname_path syndic_master_opts[optname] = optname_path + master_opts['runtests_conn_check_port'] = get_unused_localhost_port() + minion_opts['runtests_conn_check_port'] = get_unused_localhost_port() + sub_minion_opts['runtests_conn_check_port'] = get_unused_localhost_port() + syndic_opts['runtests_conn_check_port'] = get_unused_localhost_port() + syndic_master_opts['runtests_conn_check_port'] = get_unused_localhost_port() + for conf in (master_opts, minion_opts, sub_minion_opts, syndic_opts, syndic_master_opts): + if 'engines' not in conf: + conf['engines'] = [] + conf['engines'].append({'salt_runtests': {}}) + + if 'engines_dirs' not in conf: + conf['engines_dirs'] = [] + + conf['engines_dirs'].insert(0, ENGINES_DIR) + if 'log_handlers_dirs' not in conf: conf['log_handlers_dirs'] = [] conf['log_handlers_dirs'].insert(0, LOG_HANDLERS_DIR) diff --git a/tests/integration/files/engines/runtests_engine.py b/tests/integration/files/engines/runtests_engine.py index 572b72c6ab..83a4bf8d42 100644 --- a/tests/integration/files/engines/runtests_engine.py +++ b/tests/integration/files/engines/runtests_engine.py @@ -37,24 +37,27 @@ def __virtual__(): def start(): - # Create our own IOLoop, we're in another process - io_loop = ioloop.IOLoop() - io_loop.make_current() - pytest_engine = PyTestEngine(__opts__, io_loop) # pylint: disable=undefined-variable - io_loop.add_callback(pytest_engine.start) - io_loop.start() + pytest_engine = PyTestEngine(__opts__) # pylint: disable=undefined-variable + pytest_engine.start() class PyTestEngine(object): - def __init__(self, opts, io_loop): + def __init__(self, opts): self.opts = opts - self.io_loop = io_loop self.sock = None - @gen.coroutine def start(self): + self.io_loop = ioloop.IOLoop() + self.io_loop.make_current() + self.io_loop.add_callback(self._start) + self.io_loop.start() + + @gen.coroutine + def _start(self): if self.opts['__role'] == 'minion': yield self.listen_to_minion_connected_event() + else: + self.io_loop.spawn_callback(self.fire_master_started_event) port = int(self.opts['runtests_conn_check_port']) log.info('Starting Pytest Engine(role=%s) on port %s', self.opts['__role'], port) @@ -91,9 +94,7 @@ class PyTestEngine(object): def listen_to_minion_connected_event(self): log.info('Listening for minion connected event...') minion_start_event_match = 'salt/minion/{0}/start'.format(self.opts['id']) - event_bus = salt.utils.event.get_master_event(self.opts, - self.opts['sock_dir'], - listen=True) + event_bus = salt.utils.event.get_master_event(self.opts, self.opts['sock_dir'], listen=True) event_bus.subscribe(minion_start_event_match) while True: event = event_bus.get_event(full=True, no_block=True) @@ -101,3 +102,19 @@ class PyTestEngine(object): log.info('Got minion connected event: %s', event) break yield gen.sleep(0.25) + + @gen.coroutine + def fire_master_started_event(self): + log.info('Firing salt-master started event...') + event_bus = salt.utils.event.get_master_event(self.opts, self.opts['sock_dir'], listen=False) + master_start_event_tag = 'salt/master/{0}/start'.format(self.opts['id']) + load = {'id': self.opts['id'], 'tag': master_start_event_tag, 'data': {}} + # One minute should be more than enough to fire these events every second in order + # for pytest-salt to pickup that the master is running + timeout = 60 + while True: + timeout -= 1 + event_bus.fire_event(load, master_start_event_tag, timeout=500) + if timeout <= 0: + break + yield gen.sleep(1) diff --git a/tests/runtests.py b/tests/runtests.py index da8d51cd1d..4e3f92226c 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -8,13 +8,59 @@ Discover all instances of unittest.TestCase in this directory. # Import python libs from __future__ import absolute_import, print_function import os +import imp import sys import time +TESTS_DIR = os.path.dirname(os.path.normpath(os.path.abspath(__file__))) +if os.name == 'nt': + TESTS_DIR = TESTS_DIR.replace('\\', '\\\\') +CODE_DIR = os.path.dirname(TESTS_DIR) +os.chdir(CODE_DIR) + +try: + import tests + if not tests.__file__.startswith(CODE_DIR): + print('Found tests module not from salt in {}'.format(tests.__file__)) + sys.modules.pop('tests') + module_dir = os.path.dirname(tests.__file__) + if module_dir in sys.path: + sys.path.remove(module_dir) + del tests +except ImportError: + pass + +#tests = imp.load_source('tests', os.path.join(TESTS_DIR, '__init__.py')) +#salt = imp.load_source('salt', os.path.join(CODE_DIR, 'salt', '__init__.py')) + +# Let's inject CODE_DIR so salt is importable if not there already +if TESTS_DIR in sys.path: + sys.path.remove(TESTS_DIR) +if CODE_DIR in sys.path and sys.path[0] != CODE_DIR: + sys.path.remove(CODE_DIR) +if CODE_DIR not in sys.path: + sys.path.insert(0, CODE_DIR) +if TESTS_DIR not in sys.path: + sys.path.insert(1, TESTS_DIR) + # Import salt libs -from integration import TestDaemon, TMP # pylint: disable=W0403 -from integration import SYS_TMP_DIR, INTEGRATION_TEST_DIR -from integration import CODE_DIR as SALT_ROOT +try: + from tests.support.paths import TMP, SYS_TMP_DIR, INTEGRATION_TEST_DIR + from tests.support.paths import CODE_DIR as SALT_ROOT +except ImportError as exc: + try: + import tests + print('Found tests module not from salt in {}'.format(tests.__file__)) + except ImportError: + print('Unable to import salt test module') + print(os.environ.get('PYTHONPATH')) + pass + print('Current sys.paths') + import pprint + pprint.pprint(sys.path) + raise exc + +from tests.integration import TestDaemon # pylint: disable=W0403 import salt.utils if not salt.utils.is_windows(): @@ -23,12 +69,9 @@ if not salt.utils.is_windows(): # Import Salt Testing libs from salttesting.parser import PNUM, print_header from salttesting.parser.cover import SaltCoverageTestingParser -try: - from salttesting.helpers import terminate_process_pid - RUNTESTS_WITH_HARD_KILL = True -except ImportError: - from integration import terminate_process_pid - RUNTESTS_WITH_HARD_KILL = False + +# Import test support libs +from tests.support.processes import collect_child_processes, terminate_process XML_OUTPUT_DIR = os.environ.get( 'SALT_XML_TEST_REPORTS_DIR', @@ -610,9 +653,9 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): return status def print_overall_testsuite_report(self): - if RUNTESTS_WITH_HARD_KILL is False: - terminate_process_pid(os.getpid(), only_children=True) + children = collect_child_processes(os.getpid()) SaltCoverageTestingParser.print_overall_testsuite_report(self) + terminate_process(children=children) def main(): diff --git a/tests/support/paths.py b/tests/support/paths.py new file mode 100644 index 0000000000..7de535791a --- /dev/null +++ b/tests/support/paths.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + :copyright: © 2017 by the SaltStack Team, see AUTHORS for more details. + :license: Apache 2.0, see LICENSE for more details. + + + tests.support.paths + ~~~~~~~~~~~~~~~~~~~ + + Tests related paths +''' + +# Import python libs +from __future__ import absolute_import +import os +import sys +import stat +import logging +import tempfile + +log = logging.getLogger(__name__) + +TESTS_DIR = os.path.dirname(os.path.dirname(os.path.normpath(os.path.abspath(__file__)))) +if os.name == 'nt': + TESTS_DIR = TESTS_DIR.replace('\\', '\\\\') +CODE_DIR = os.path.dirname(TESTS_DIR) +INTEGRATION_TEST_DIR = os.path.join(TESTS_DIR, 'integration') + +# Let's inject CODE_DIR so salt is importable if not there already +if TESTS_DIR in sys.path: + sys.path.remove(TESTS_DIR) +if CODE_DIR in sys.path and sys.path[0] != CODE_DIR: + sys.path.remove(CODE_DIR) +if CODE_DIR not in sys.path: + sys.path.insert(0, CODE_DIR) +if TESTS_DIR not in sys.path: + sys.path.insert(1, TESTS_DIR) + +SYS_TMP_DIR = os.path.realpath( + # Avoid ${TMPDIR} and gettempdir() on MacOS as they yield a base path too long + # for unix sockets: ``error: AF_UNIX path too long`` + # Gentoo Portage prefers ebuild tests are rooted in ${TMPDIR} + os.environ.get('TMPDIR', tempfile.gettempdir()) if not sys.platform.startswith('darwin') else '/tmp' +) +TMP = os.path.join(SYS_TMP_DIR, 'salt-tests-tmpdir') +FILES = os.path.join(INTEGRATION_TEST_DIR, 'files') +PYEXEC = 'python{0}.{1}'.format(*sys.version_info) +MOCKBIN = os.path.join(INTEGRATION_TEST_DIR, 'mockbin') +SCRIPT_DIR = os.path.join(CODE_DIR, 'scripts') +TMP_STATE_TREE = os.path.join(SYS_TMP_DIR, 'salt-temp-state-tree') +TMP_PRODENV_STATE_TREE = os.path.join(SYS_TMP_DIR, 'salt-temp-prodenv-state-tree') +TMP_CONF_DIR = os.path.join(TMP, 'config') +TMP_SUB_MINION_CONF_DIR = os.path.join(TMP_CONF_DIR, 'sub-minion') +TMP_SYNDIC_MINION_CONF_DIR = os.path.join(TMP_CONF_DIR, 'syndic-minion') +TMP_SYNDIC_MASTER_CONF_DIR = os.path.join(TMP_CONF_DIR, 'syndic-master') +CONF_DIR = os.path.join(INTEGRATION_TEST_DIR, 'files', 'conf') +PILLAR_DIR = os.path.join(FILES, 'pillar') +TMP_SCRIPT_DIR = os.path.join(TMP, 'scripts') +ENGINES_DIR = os.path.join(FILES, 'engines') +LOG_HANDLERS_DIR = os.path.join(FILES, 'log_handlers') + + +SCRIPT_TEMPLATES = { + 'salt': [ + 'from salt.scripts import salt_main\n', + 'if __name__ == \'__main__\':\n' + ' salt_main()' + ], + 'salt-api': [ + 'import salt.cli\n', + 'def main():\n', + ' sapi = salt.cli.SaltAPI()', + ' sapi.start()\n', + 'if __name__ == \'__main__\':', + ' main()' + ], + 'common': [ + 'from salt.scripts import salt_{0}\n', + 'from salt.utils import is_windows\n\n', + 'if __name__ == \'__main__\':\n', + ' if is_windows():\n', + ' import os.path\n', + ' import py_compile\n', + ' cfile = os.path.splitext(__file__)[0] + ".pyc"\n', + ' if not os.path.exists(cfile):\n', + ' py_compile.compile(__file__, cfile)\n', + ' salt_{0}()' + ] +} + + +class ScriptPathMixin(object): + + def get_script_path(self, script_name): + ''' + Return the path to a testing runtime script + ''' + if not os.path.isdir(TMP_SCRIPT_DIR): + os.makedirs(TMP_SCRIPT_DIR) + + script_path = os.path.join(TMP_SCRIPT_DIR, + 'cli_{0}.py'.format(script_name.replace('-', '_'))) + + if not os.path.isfile(script_path): + log.info('Generating {0}'.format(script_path)) + + # Late import + import salt.utils + + with salt.utils.fopen(script_path, 'w') as sfh: + script_template = SCRIPT_TEMPLATES.get(script_name, None) + if script_template is None: + script_template = SCRIPT_TEMPLATES.get('common', None) + if script_template is None: + raise RuntimeError( + '{0} does not know how to handle the {1} script'.format( + self.__class__.__name__, + script_name + ) + ) + sfh.write( + '#!{0}\n\n'.format(sys.executable) + + 'import sys\n' + + 'CODE_DIR="{0}"\n'.format(CODE_DIR) + + 'if CODE_DIR not in sys.path:\n' + + ' sys.path.insert(0, CODE_DIR)\n\n' + + '\n'.join(script_template).format(script_name.replace('salt-', '')) + ) + fst = os.stat(script_path) + os.chmod(script_path, fst.st_mode | stat.S_IEXEC) + + log.info('Returning script path %r', script_path) + return script_path diff --git a/tests/support/processes.py b/tests/support/processes.py new file mode 100644 index 0000000000..88c41b9c12 --- /dev/null +++ b/tests/support/processes.py @@ -0,0 +1,192 @@ +# -*- coding: utf-8 -*- +''' + :copyright: © 2017 by the SaltStack Team, see AUTHORS for more details. + :license: Apache 2.0, see LICENSE for more details. + + + tests.support.processes + ~~~~~~~~~~~~~~~~~~~~~~~ + + Process handling utilities +''' + +# Import python libs +from __future__ import absolute_import +import logging + +# Import pytest-salt libs +from pytestsalt.utils import SaltRunEventListener as PytestSaltRunEventListener +from pytestsalt.utils import collect_child_processes, terminate_process # pylint: disable=unused-import +from pytestsalt.fixtures.daemons import Salt as PytestSalt +from pytestsalt.fixtures.daemons import SaltKey as PytestSaltKey +from pytestsalt.fixtures.daemons import SaltRun as PytestSaltRun +from pytestsalt.fixtures.daemons import SaltCall as PytestSaltCall +from pytestsalt.fixtures.daemons import SaltMaster as PytestSaltMaster +from pytestsalt.fixtures.daemons import SaltMinion as PytestSaltMinion +from pytestsalt.fixtures.daemons import SaltSyndic as PytestSaltSyndic + +# Import tests support libs +from tests.support.paths import ScriptPathMixin + +log = logging.getLogger(__name__) + + +class SaltRunEventListener(ScriptPathMixin, PytestSaltRunEventListener): + ''' + Override this class's __init__ because there's no request argument since we're still + not running under pytest + ''' + + +class GetSaltRunFixtureMixin(ScriptPathMixin): + ''' + Override this classes `get_salt_run_fixture` because we're still not running under pytest + ''' + + def get_salt_run_fixture(self): + pass + + def get_salt_run_event_listener(self): + return SaltRunEventListener(None, + self.config, + self.config_dir, + self.bin_dir_path, + self.log_prefix, + cli_script_name='run') + + +class Salt(ScriptPathMixin, PytestSalt): + ''' + Class which runs salt-call commands + ''' + def __init__(self, *args, **kwargs): + super(Salt, self).__init__(None, *args, **kwargs) + + +class SaltCall(ScriptPathMixin, PytestSaltCall): + ''' + Class which runs salt-call commands + ''' + def __init__(self, *args, **kwargs): + super(SaltCall, self).__init__(None, *args, **kwargs) + + +class SaltKey(ScriptPathMixin, PytestSaltKey): + ''' + Class which runs salt-key commands + ''' + def __init__(self, *args, **kwargs): + super(SaltKey, self).__init__(None, *args, **kwargs) + + +class SaltRun(ScriptPathMixin, PytestSaltRun): + ''' + Class which runs salt-run commands + ''' + def __init__(self, *args, **kwargs): + super(SaltRun, self).__init__(None, *args, **kwargs) + + +class SaltMinion(GetSaltRunFixtureMixin, PytestSaltMinion): + ''' + Class which runs the salt-minion daemon + ''' + + +class SaltMaster(GetSaltRunFixtureMixin, PytestSaltMaster): + ''' + Class which runs the salt-master daemon + ''' + + +class SaltSyndic(GetSaltRunFixtureMixin, PytestSaltSyndic): + ''' + Class which runs the salt-syndic daemon + ''' + + +def start_daemon(daemon_name=None, + daemon_id=None, + daemon_log_prefix=None, + daemon_cli_script_name=None, + daemon_config=None, + daemon_config_dir=None, + daemon_class=None, + bin_dir_path=None, + fail_hard=False, + start_timeout=10, + slow_stop=False, + environ=None, + cwd=None): + ''' + Returns a running salt daemon + ''' + daemon_config['pytest_port'] = daemon_config['runtests_conn_check_port'] + request = None + if fail_hard: + fail_method = RuntimeError + else: + fail_method = RuntimeWarning + log.info('[%s] Starting pytest %s(%s)', daemon_name, daemon_log_prefix, daemon_id) + attempts = 0 + process = None + while attempts <= 3: # pylint: disable=too-many-nested-blocks + attempts += 1 + process = daemon_class(request, + daemon_config, + daemon_config_dir, + bin_dir_path, + daemon_log_prefix, + cli_script_name=daemon_cli_script_name, + slow_stop=slow_stop, + environ=environ, + cwd=cwd) + process.start() + if process.is_alive(): + try: + connectable = process.wait_until_running(timeout=start_timeout) + if connectable is False: + connectable = process.wait_until_running(timeout=start_timeout/2) + if connectable is False: + process.terminate() + if attempts >= 3: + fail_method( + 'The pytest {0}({1}) has failed to confirm running status ' + 'after {2} attempts'.format(daemon_name, daemon_id, attempts)) + continue + except Exception as exc: # pylint: disable=broad-except + log.exception('[%s] %s', daemon_log_prefix, exc, exc_info=True) + terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) + if attempts >= 3: + raise fail_method(str(exc)) + continue + log.info( + '[%s] The pytest %s(%s) is running and accepting commands ' + 'after %d attempts', + daemon_log_prefix, + daemon_name, + daemon_id, + attempts + ) + + def stop_daemon(): + log.info('[%s] Stopping pytest %s(%s)', daemon_log_prefix, daemon_name, daemon_id) + terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) + log.info('[%s] pytest %s(%s) stopped', daemon_log_prefix, daemon_name, daemon_id) + + # request.addfinalizer(stop_daemon) + return process + else: + terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) + continue + else: # pylint: disable=useless-else-on-loop + # Wrong, we have a return, its not useless + if process is not None: + terminate_process(process.pid, kill_children=True, slow_stop=slow_stop) + raise fail_method( + 'The pytest {0}({1}) has failed to start after {2} attempts'.format( + daemon_name, + daemon_id, + attempts-1 + ) + ) From 3beb3fb80194b9576f7a353298fedfcb35e9f781 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 27 Feb 2017 13:58:07 +0000 Subject: [PATCH 277/370] Move whatever we need from salttesting to salt. Let's drop the salttesting dependency cycle. --- tests/integration/__init__.py | 161 +-- tests/integration/cli/test_batch.py | 2 +- tests/integration/cli/test_grains.py | 2 +- tests/integration/client/test_kwarg.py | 2 +- tests/integration/client/test_runner.py | 2 +- tests/integration/client/test_standard.py | 2 +- tests/integration/client/test_syndic.py | 2 +- tests/integration/cloud/helpers/virtualbox.py | 2 +- .../cloud/providers/test_digital_ocean.py | 2 +- tests/integration/cloud/providers/test_ec2.py | 2 +- tests/integration/cloud/providers/test_gce.py | 2 +- .../cloud/providers/test_gogrid.py | 4 +- .../cloud/providers/test_joyent.py | 2 +- .../cloud/providers/test_linode.py | 2 +- .../cloud/providers/test_msazure.py | 4 +- .../cloud/providers/test_openstack.py | 4 +- .../cloud/providers/test_profitbricks.py | 4 +- .../cloud/providers/test_rackspace.py | 4 +- .../cloud/providers/test_virtualbox.py | 4 +- .../integration/cloud/providers/test_vultr.py | 2 +- .../integration/fileserver/test_fileclient.py | 6 +- tests/integration/fileserver/test_gitfs.py | 6 +- tests/integration/fileserver/test_roots.py | 6 +- tests/integration/grains/test_core.py | 4 +- tests/integration/loader/test_ext_grains.py | 2 +- tests/integration/loader/test_ext_modules.py | 2 +- tests/integration/loader/test_globals.py | 2 +- tests/integration/loader/test_interfaces.py | 4 +- tests/integration/loader/test_loader.py | 4 +- tests/integration/minion/test_blackout.py | 2 +- tests/integration/minion/test_pillar.py | 8 +- tests/integration/minion/test_timeout.py | 2 +- tests/integration/modules/test_aliases.py | 2 +- tests/integration/modules/test_archive.py | 4 +- tests/integration/modules/test_beacons.py | 2 +- tests/integration/modules/test_boto_iam.py | 4 +- tests/integration/modules/test_boto_sns.py | 4 +- tests/integration/modules/test_cmdmod.py | 6 +- tests/integration/modules/test_config.py | 2 +- tests/integration/modules/test_cp.py | 2 +- .../integration/modules/test_darwin_sysctl.py | 4 +- tests/integration/modules/test_data.py | 2 +- tests/integration/modules/test_decorators.py | 2 +- tests/integration/modules/test_disk.py | 4 +- tests/integration/modules/test_django.py | 6 +- tests/integration/modules/test_event.py | 2 +- tests/integration/modules/test_file.py | 6 +- tests/integration/modules/test_gem.py | 4 +- .../integration/modules/test_gentoolkitmod.py | 2 +- tests/integration/modules/test_git.py | 4 +- tests/integration/modules/test_grains.py | 4 +- tests/integration/modules/test_groupadd.py | 2 +- tests/integration/modules/test_hosts.py | 2 +- tests/integration/modules/test_key.py | 2 +- tests/integration/modules/test_linux_acl.py | 2 +- tests/integration/modules/test_locale.py | 4 +- tests/integration/modules/test_lxc.py | 4 +- .../integration/modules/test_mac_assistive.py | 4 +- tests/integration/modules/test_mac_brew.py | 4 +- .../integration/modules/test_mac_defaults.py | 4 +- tests/integration/modules/test_mac_desktop.py | 4 +- tests/integration/modules/test_mac_group.py | 4 +- .../integration/modules/test_mac_keychain.py | 4 +- tests/integration/modules/test_mac_pkgutil.py | 2 +- tests/integration/modules/test_mac_ports.py | 2 +- tests/integration/modules/test_mac_power.py | 4 +- tests/integration/modules/test_mac_service.py | 4 +- tests/integration/modules/test_mac_shadow.py | 2 +- .../modules/test_mac_softwareupdate.py | 2 +- tests/integration/modules/test_mac_system.py | 4 +- .../integration/modules/test_mac_timezone.py | 4 +- tests/integration/modules/test_mac_user.py | 4 +- tests/integration/modules/test_mac_xattr.py | 2 +- tests/integration/modules/test_mine.py | 2 +- tests/integration/modules/test_mysql.py | 4 +- tests/integration/modules/test_nilrt_ip.py | 4 +- tests/integration/modules/test_pillar.py | 4 +- tests/integration/modules/test_pip.py | 4 +- tests/integration/modules/test_pkg.py | 2 +- tests/integration/modules/test_publish.py | 2 +- tests/integration/modules/test_pw_user.py | 4 +- tests/integration/modules/test_rabbitmq.py | 4 +- tests/integration/modules/test_random_org.py | 6 +- tests/integration/modules/test_saltutil.py | 2 +- tests/integration/modules/test_shadow.py | 4 +- tests/integration/modules/test_ssh.py | 4 +- tests/integration/modules/test_state.py | 4 +- tests/integration/modules/test_supervisord.py | 4 +- tests/integration/modules/test_sysctl.py | 4 +- tests/integration/modules/test_sysmod.py | 2 +- tests/integration/modules/test_system.py | 4 +- tests/integration/modules/test_test.py | 2 +- tests/integration/modules/test_timezone.py | 2 +- tests/integration/modules/test_useradd.py | 4 +- tests/integration/modules/test_virt.py | 2 +- tests/integration/modules/test_virtualenv.py | 4 +- .../netapi/rest_cherrypy/test_app_pam.py | 4 +- .../netapi/rest_tornado/test_app.py | 4 +- tests/integration/netapi/test_client.py | 2 +- tests/integration/output/test_output.py | 4 +- tests/integration/reactor/test_reactor.py | 2 +- tests/integration/renderers/test_pydsl.py | 2 +- .../returners/test_librato_return.py | 2 +- .../integration/returners/test_local_cache.py | 2 +- tests/integration/runners/test_fileserver.py | 2 +- tests/integration/runners/test_jobs.py | 4 +- tests/integration/runners/test_manage.py | 2 +- .../runners/test_runner_returns.py | 2 +- tests/integration/runners/test_salt.py | 2 +- tests/integration/runners/test_state.py | 4 +- tests/integration/runners/test_winrepo.py | 6 +- tests/integration/sdb/test_env.py | 2 +- tests/integration/shell/test_arguments.py | 2 +- tests/integration/shell/test_auth.py | 4 +- tests/integration/shell/test_call.py | 8 +- tests/integration/shell/test_cloud.py | 6 +- tests/integration/shell/test_cp.py | 4 +- tests/integration/shell/test_enabled.py | 2 +- tests/integration/shell/test_key.py | 4 +- tests/integration/shell/test_master.py | 4 +- tests/integration/shell/test_master_tops.py | 2 +- tests/integration/shell/test_matcher.py | 4 +- tests/integration/shell/test_minion.py | 6 +- tests/integration/shell/test_proxy.py | 2 +- tests/integration/shell/test_runner.py | 6 +- tests/integration/shell/test_saltcli.py | 2 +- tests/integration/shell/test_syndic.py | 4 +- tests/integration/ssh/test_deploy.py | 4 +- tests/integration/states/test_alternatives.py | 4 +- tests/integration/states/test_archive.py | 4 +- tests/integration/states/test_boto_sns.py | 4 +- tests/integration/states/test_bower.py | 4 +- tests/integration/states/test_cmd.py | 2 +- tests/integration/states/test_compiler.py | 2 +- tests/integration/states/test_file.py | 4 +- tests/integration/states/test_git.py | 2 +- tests/integration/states/test_handle_error.py | 2 +- .../integration/states/test_handle_iorder.py | 2 +- tests/integration/states/test_host.py | 2 +- tests/integration/states/test_keystone.py | 4 +- tests/integration/states/test_match.py | 4 +- tests/integration/states/test_mysql.py | 4 +- tests/integration/states/test_network.py | 2 +- tests/integration/states/test_npm.py | 4 +- tests/integration/states/test_pip.py | 4 +- tests/integration/states/test_pkg.py | 4 +- tests/integration/states/test_pkgrepo.py | 4 +- .../integration/states/test_rabbitmq_user.py | 2 +- .../integration/states/test_rabbitmq_vhost.py | 2 +- tests/integration/states/test_renderers.py | 2 +- tests/integration/states/test_service.py | 4 +- tests/integration/states/test_ssh.py | 4 +- tests/integration/states/test_supervisord.py | 4 +- tests/integration/states/test_svn.py | 2 +- tests/integration/states/test_user.py | 4 +- tests/integration/states/test_virtualenv.py | 4 +- tests/integration/utils/test_reactor.py | 2 +- tests/integration/utils/testprogram.py | 2 +- tests/integration/wheel/test_client.py | 2 +- tests/runtests.py | 35 +- tests/support/case.py | 567 ++++++++ tests/support/cherrypy_testclasses.py | 5 +- tests/support/cptestcase.py | 2 +- tests/support/ext/__init__.py | 1 + tests/support/ext/console.py | 108 ++ tests/support/helpers.py | 1184 ++++++++++++++++- tests/support/mixins.py | 516 ++++++- tests/support/mock.py | 186 +++ tests/support/parser/__init__.py | 892 +++++++++++++ tests/support/parser/cover.py | 236 ++++ tests/support/runtests.py | 212 +++ tests/support/unit.py | 243 ++++ tests/support/xmlunit.py | 95 ++ tests/unit/__init__.py | 4 +- tests/unit/acl/test_client.py | 2 +- tests/unit/beacons/test_adb_beacon.py | 6 +- tests/unit/beacons/test_glxinfo.py | 4 +- tests/unit/beacons/test_inotify_beacon.py | 6 +- tests/unit/cache/test_localfs.py | 4 +- tests/unit/cli/test_batch.py | 4 +- tests/unit/cloud/clouds/test_dimensiondata.py | 6 +- tests/unit/cloud/clouds/test_ec2.py | 4 +- tests/unit/cloud/clouds/test_gce.py | 6 +- tests/unit/cloud/clouds/test_joyent.py | 6 +- tests/unit/cloud/clouds/test_linode.py | 6 +- tests/unit/cloud/clouds/test_opennebula.py | 6 +- tests/unit/cloud/clouds/test_saltify.py | 4 +- tests/unit/cloud/clouds/test_vmware.py | 6 +- tests/unit/cloud/test_libcloud.py | 4 +- tests/unit/config/schemas/test_ssh.py | 4 +- tests/unit/config/test_api.py | 6 +- tests/unit/config/test_config.py | 4 +- tests/unit/engines/test_sqs_events.py | 6 +- tests/unit/fileserver/test_gitfs.py | 2 +- tests/unit/fileserver/test_map.py | 2 +- tests/unit/grains/test_core.py | 4 +- tests/unit/modules/test_aliases.py | 6 +- tests/unit/modules/test_alternatives.py | 6 +- tests/unit/modules/test_apache.py | 4 +- tests/unit/modules/test_aptpkg.py | 6 +- tests/unit/modules/test_archive.py | 6 +- tests/unit/modules/test_artifactory.py | 6 +- tests/unit/modules/test_at.py | 4 +- tests/unit/modules/test_augeas_cfg.py | 4 +- tests/unit/modules/test_bluez.py | 4 +- tests/unit/modules/test_boto_apigateway.py | 6 +- tests/unit/modules/test_boto_cloudtrail.py | 6 +- .../modules/test_boto_cloudwatch_event.py | 6 +- .../unit/modules/test_boto_cognitoidentity.py | 8 +- .../modules/test_boto_elasticsearch_domain.py | 6 +- tests/unit/modules/test_boto_elb.py | 6 +- tests/unit/modules/test_boto_iot.py | 6 +- tests/unit/modules/test_boto_lambda.py | 6 +- tests/unit/modules/test_boto_s3_bucket.py | 6 +- tests/unit/modules/test_boto_secgroup.py | 6 +- tests/unit/modules/test_boto_vpc.py | 6 +- tests/unit/modules/test_bower.py | 6 +- tests/unit/modules/test_bridge.py | 4 +- tests/unit/modules/test_btrfs.py | 6 +- tests/unit/modules/test_cassandra.py | 4 +- tests/unit/modules/test_cassandra_cql.py | 4 +- tests/unit/modules/test_chef.py | 4 +- tests/unit/modules/test_cmdmod.py | 6 +- tests/unit/modules/test_composer.py | 4 +- tests/unit/modules/test_config.py | 6 +- tests/unit/modules/test_cp.py | 6 +- tests/unit/modules/test_cpan.py | 4 +- tests/unit/modules/test_cron.py | 6 +- tests/unit/modules/test_cyg.py | 6 +- tests/unit/modules/test_daemontools.py | 4 +- tests/unit/modules/test_data.py | 4 +- tests/unit/modules/test_ddns.py | 4 +- tests/unit/modules/test_deb_apache.py | 4 +- tests/unit/modules/test_deb_postgres.py | 6 +- tests/unit/modules/test_debconfmod.py | 4 +- tests/unit/modules/test_debian_ip.py | 4 +- tests/unit/modules/test_debian_service.py | 4 +- tests/unit/modules/test_defaults.py | 4 +- tests/unit/modules/test_devmap.py | 4 +- tests/unit/modules/test_dig.py | 6 +- tests/unit/modules/test_disk.py | 6 +- tests/unit/modules/test_djangomod.py | 4 +- tests/unit/modules/test_dnsmasq.py | 4 +- tests/unit/modules/test_dnsutil.py | 6 +- tests/unit/modules/test_docker.py | 6 +- tests/unit/modules/test_dpkg.py | 4 +- tests/unit/modules/test_drac.py | 4 +- tests/unit/modules/test_drbd.py | 4 +- tests/unit/modules/test_environ.py | 4 +- tests/unit/modules/test_etcd_mod.py | 6 +- tests/unit/modules/test_event.py | 4 +- tests/unit/modules/test_extfs.py | 4 +- tests/unit/modules/test_file.py | 6 +- tests/unit/modules/test_firewalld.py | 4 +- tests/unit/modules/test_gem.py | 6 +- tests/unit/modules/test_genesis.py | 4 +- tests/unit/modules/test_gentoo_service.py | 4 +- tests/unit/modules/test_git.py | 4 +- tests/unit/modules/test_glusterfs.py | 4 +- tests/unit/modules/test_gnomedesktop.py | 4 +- tests/unit/modules/test_grains.py | 6 +- tests/unit/modules/test_groupadd.py | 4 +- tests/unit/modules/test_grub_legacy.py | 4 +- tests/unit/modules/test_guestfs.py | 4 +- tests/unit/modules/test_hadoop.py | 4 +- tests/unit/modules/test_haproxyconn.py | 6 +- tests/unit/modules/test_hashutil.py | 4 +- tests/unit/modules/test_hg.py | 4 +- tests/unit/modules/test_hipchat.py | 4 +- tests/unit/modules/test_hosts.py | 4 +- tests/unit/modules/test_htpasswd.py | 4 +- tests/unit/modules/test_http.py | 4 +- tests/unit/modules/test_ilo.py | 4 +- tests/unit/modules/test_incron.py | 4 +- tests/unit/modules/test_influx08.py | 4 +- tests/unit/modules/test_ini_manage.py | 4 +- tests/unit/modules/test_inspect_collector.py | 6 +- tests/unit/modules/test_inspect_fsdb.py | 6 +- tests/unit/modules/test_introspect.py | 6 +- tests/unit/modules/test_ipset.py | 4 +- tests/unit/modules/test_iptables.py | 6 +- tests/unit/modules/test_jboss7.py | 6 +- tests/unit/modules/test_jboss7_cli.py | 4 +- tests/unit/modules/test_k8s.py | 4 +- tests/unit/modules/test_kapacitor.py | 4 +- tests/unit/modules/test_key.py | 4 +- tests/unit/modules/test_keyboard.py | 6 +- tests/unit/modules/test_keystone.py | 6 +- tests/unit/modules/test_kmod.py | 4 +- tests/unit/modules/test_launchctl.py | 4 +- tests/unit/modules/test_ldapmod.py | 6 +- tests/unit/modules/test_libcloud_dns.py | 6 +- tests/unit/modules/test_linux_acl.py | 6 +- tests/unit/modules/test_linux_lvm.py | 4 +- tests/unit/modules/test_linux_sysctl.py | 6 +- tests/unit/modules/test_localemod.py | 4 +- tests/unit/modules/test_locate.py | 6 +- tests/unit/modules/test_logadm.py | 4 +- tests/unit/modules/test_logrotate.py | 6 +- tests/unit/modules/test_lvs.py | 6 +- tests/unit/modules/test_mac_assistive.py | 6 +- tests/unit/modules/test_mac_brew.py | 6 +- tests/unit/modules/test_mac_defaults.py | 6 +- tests/unit/modules/test_mac_desktop.py | 6 +- tests/unit/modules/test_mac_group.py | 4 +- tests/unit/modules/test_mac_keychain.py | 6 +- tests/unit/modules/test_mac_package.py | 6 +- tests/unit/modules/test_mac_pkgutil.py | 4 +- tests/unit/modules/test_mac_power.py | 6 +- tests/unit/modules/test_mac_sysctl.py | 6 +- tests/unit/modules/test_mac_user.py | 6 +- tests/unit/modules/test_mac_xattr.py | 6 +- tests/unit/modules/test_mdadm.py | 6 +- tests/unit/modules/test_memcached.py | 6 +- tests/unit/modules/test_mine.py | 6 +- tests/unit/modules/test_mod_random.py | 6 +- tests/unit/modules/test_modjk.py | 6 +- tests/unit/modules/test_monit.py | 6 +- tests/unit/modules/test_moosefs.py | 6 +- tests/unit/modules/test_mount.py | 4 +- tests/unit/modules/test_munin.py | 6 +- tests/unit/modules/test_mysql.py | 6 +- tests/unit/modules/test_nagios.py | 6 +- tests/unit/modules/test_netscaler.py | 6 +- tests/unit/modules/test_network.py | 6 +- tests/unit/modules/test_network_utils.py | 2 +- tests/unit/modules/test_neutron.py | 6 +- tests/unit/modules/test_nfs3.py | 6 +- tests/unit/modules/test_nftables.py | 6 +- tests/unit/modules/test_nginx.py | 6 +- tests/unit/modules/test_nova.py | 4 +- tests/unit/modules/test_npm.py | 6 +- tests/unit/modules/test_openbsdpkg.py | 4 +- tests/unit/modules/test_openscap.py | 4 +- tests/unit/modules/test_openstack_config.py | 6 +- tests/unit/modules/test_oracle.py | 6 +- tests/unit/modules/test_pacman.py | 6 +- tests/unit/modules/test_pagerduty.py | 6 +- tests/unit/modules/test_pam.py | 6 +- tests/unit/modules/test_parallels.py | 6 +- tests/unit/modules/test_parted.py | 6 +- tests/unit/modules/test_pecl.py | 6 +- tests/unit/modules/test_pillar.py | 6 +- tests/unit/modules/test_pip.py | 6 +- tests/unit/modules/test_pkg_resource.py | 4 +- tests/unit/modules/test_pkgutil.py | 6 +- tests/unit/modules/test_portage_config.py | 6 +- tests/unit/modules/test_postfix.py | 6 +- tests/unit/modules/test_postgres.py | 6 +- tests/unit/modules/test_poudriere.py | 6 +- tests/unit/modules/test_powerpath.py | 6 +- tests/unit/modules/test_proxy.py | 6 +- tests/unit/modules/test_ps.py | 6 +- tests/unit/modules/test_publish.py | 6 +- tests/unit/modules/test_puppet.py | 6 +- tests/unit/modules/test_pw_group.py | 4 +- tests/unit/modules/test_pw_user.py | 4 +- tests/unit/modules/test_pyenv.py | 6 +- tests/unit/modules/test_qemu_img.py | 6 +- tests/unit/modules/test_qemu_nbd.py | 6 +- tests/unit/modules/test_rabbitmq.py | 6 +- tests/unit/modules/test_raet_publish.py | 6 +- tests/unit/modules/test_rbenv.py | 6 +- tests/unit/modules/test_rdp.py | 4 +- tests/unit/modules/test_redismod.py | 6 +- tests/unit/modules/test_reg_win.py | 4 +- tests/unit/modules/test_ret.py | 6 +- tests/unit/modules/test_rh_ip.py | 6 +- tests/unit/modules/test_rh_service.py | 6 +- tests/unit/modules/test_riak.py | 6 +- tests/unit/modules/test_rpm.py | 6 +- tests/unit/modules/test_rsync.py | 6 +- tests/unit/modules/test_rvm.py | 6 +- tests/unit/modules/test_s3.py | 6 +- tests/unit/modules/test_s6.py | 4 +- tests/unit/modules/test_saltcloudmod.py | 6 +- tests/unit/modules/test_schedule.py | 6 +- tests/unit/modules/test_scsi.py | 6 +- tests/unit/modules/test_sdb.py | 6 +- tests/unit/modules/test_seed.py | 6 +- tests/unit/modules/test_sensors.py | 6 +- .../unit/modules/test_serverdensity_device.py | 6 +- tests/unit/modules/test_service.py | 6 +- tests/unit/modules/test_servicenow.py | 6 +- tests/unit/modules/test_shadow.py | 4 +- tests/unit/modules/test_smf.py | 6 +- tests/unit/modules/test_smtp.py | 6 +- tests/unit/modules/test_snapper.py | 6 +- tests/unit/modules/test_solr.py | 6 +- tests/unit/modules/test_sqlite3.py | 6 +- tests/unit/modules/test_ssh.py | 6 +- tests/unit/modules/test_state.py | 6 +- tests/unit/modules/test_status.py | 6 +- tests/unit/modules/test_supervisord.py | 6 +- tests/unit/modules/test_svn.py | 6 +- tests/unit/modules/test_swift.py | 6 +- tests/unit/modules/test_sysbench.py | 6 +- tests/unit/modules/test_syslog_ng.py | 6 +- tests/unit/modules/test_sysmod.py | 6 +- tests/unit/modules/test_system.py | 6 +- tests/unit/modules/test_systemd.py | 6 +- tests/unit/modules/test_timezone.py | 6 +- tests/unit/modules/test_tls.py | 6 +- tests/unit/modules/test_twilio_notify.py | 6 +- tests/unit/modules/test_udev.py | 6 +- tests/unit/modules/test_uptime.py | 6 +- tests/unit/modules/test_useradd.py | 4 +- tests/unit/modules/test_uwsgi.py | 6 +- tests/unit/modules/test_varnish.py | 6 +- tests/unit/modules/test_virt.py | 6 +- tests/unit/modules/test_virtualenv.py | 6 +- tests/unit/modules/test_vsphere.py | 6 +- tests/unit/modules/test_win_autoruns.py | 6 +- tests/unit/modules/test_win_certutil.py | 6 +- tests/unit/modules/test_win_disk.py | 6 +- tests/unit/modules/test_win_dism.py | 6 +- tests/unit/modules/test_win_dns_client.py | 6 +- tests/unit/modules/test_win_firewall.py | 6 +- tests/unit/modules/test_win_groupadd.py | 6 +- tests/unit/modules/test_win_iis.py | 6 +- tests/unit/modules/test_win_ip.py | 6 +- tests/unit/modules/test_win_license.py | 6 +- tests/unit/modules/test_win_network.py | 6 +- tests/unit/modules/test_win_ntp.py | 6 +- tests/unit/modules/test_win_path.py | 6 +- tests/unit/modules/test_win_pki.py | 6 +- tests/unit/modules/test_win_powercfg.py | 6 +- tests/unit/modules/test_win_service.py | 6 +- tests/unit/modules/test_win_shadow.py | 6 +- tests/unit/modules/test_win_snmp.py | 6 +- tests/unit/modules/test_win_status.py | 6 +- tests/unit/modules/test_win_system.py | 6 +- tests/unit/modules/test_win_timezone.py | 6 +- tests/unit/modules/test_xapi.py | 6 +- tests/unit/modules/test_zcbuildout.py | 4 +- tests/unit/modules/test_zfs.py | 6 +- tests/unit/modules/test_znc.py | 6 +- tests/unit/modules/test_zpool.py | 6 +- tests/unit/modules/test_zypper.py | 6 +- .../unit/netapi/rest_tornado/test_handlers.py | 6 +- tests/unit/netapi/rest_tornado/test_utils.py | 4 +- tests/unit/output/test_json_out.py | 4 +- tests/unit/output/test_yaml_out.py | 4 +- tests/unit/pillar/test_consul.py | 6 +- tests/unit/pillar/test_git.py | 4 +- tests/unit/pillar/test_hg.py | 4 +- tests/unit/pillar/test_mysql.py | 6 +- tests/unit/pillar/test_nodegroups.py | 6 +- tests/unit/pillar/test_sqlcipher.py | 6 +- tests/unit/pillar/test_sqlite3.py | 6 +- tests/unit/renderers/test_gpg.py | 6 +- tests/unit/renderers/test_yaml.py | 4 +- tests/unit/renderers/test_yamlex.py | 4 +- tests/unit/returners/test_local_cache.py | 6 +- tests/unit/returners/test_smtp_return.py | 6 +- tests/unit/runners/test_cache.py | 6 +- tests/unit/runners/test_jobs.py | 6 +- tests/unit/serializers/test_serializers.py | 4 +- tests/unit/ssh/test_ssh_single.py | 6 +- tests/unit/states/test_alias.py | 6 +- tests/unit/states/test_alternatives.py | 6 +- tests/unit/states/test_apache.py | 6 +- tests/unit/states/test_apache_conf.py | 6 +- tests/unit/states/test_apache_module.py | 6 +- tests/unit/states/test_apache_site.py | 6 +- tests/unit/states/test_apt.py | 6 +- tests/unit/states/test_archive.py | 6 +- tests/unit/states/test_artifactory.py | 6 +- tests/unit/states/test_at.py | 6 +- tests/unit/states/test_augeas.py | 6 +- tests/unit/states/test_aws_sqs.py | 6 +- tests/unit/states/test_blockdev.py | 6 +- tests/unit/states/test_boto_apigateway.py | 6 +- tests/unit/states/test_boto_asg.py | 6 +- tests/unit/states/test_boto_cloudtrail.py | 6 +- .../unit/states/test_boto_cloudwatch_alarm.py | 6 +- .../unit/states/test_boto_cloudwatch_event.py | 8 +- .../unit/states/test_boto_cognitoidentity.py | 8 +- tests/unit/states/test_boto_dynamodb.py | 6 +- tests/unit/states/test_boto_ec2.py | 6 +- tests/unit/states/test_boto_elasticache.py | 6 +- .../states/test_boto_elasticsearch_domain.py | 6 +- tests/unit/states/test_boto_elb.py | 6 +- tests/unit/states/test_boto_iam_role.py | 6 +- tests/unit/states/test_boto_iot.py | 6 +- tests/unit/states/test_boto_kinesis.py | 6 +- tests/unit/states/test_boto_lambda.py | 6 +- tests/unit/states/test_boto_lc.py | 6 +- tests/unit/states/test_boto_route53.py | 6 +- tests/unit/states/test_boto_s3_bucket.py | 6 +- tests/unit/states/test_boto_secgroup.py | 4 +- tests/unit/states/test_boto_sns.py | 6 +- tests/unit/states/test_boto_sqs.py | 6 +- tests/unit/states/test_boto_vpc.py | 6 +- tests/unit/states/test_bower.py | 6 +- tests/unit/states/test_chef.py | 6 +- tests/unit/states/test_cloud.py | 6 +- tests/unit/states/test_cmd.py | 6 +- tests/unit/states/test_composer.py | 6 +- tests/unit/states/test_cron.py | 6 +- tests/unit/states/test_cyg.py | 6 +- tests/unit/states/test_ddns.py | 6 +- tests/unit/states/test_debconfmod.py | 6 +- tests/unit/states/test_disk.py | 6 +- tests/unit/states/test_docker.py | 6 +- tests/unit/states/test_drac.py | 6 +- tests/unit/states/test_environ.py | 6 +- tests/unit/states/test_eselect.py | 6 +- tests/unit/states/test_event.py | 6 +- tests/unit/states/test_file.py | 6 +- tests/unit/states/test_gem.py | 6 +- tests/unit/states/test_glusterfs.py | 6 +- tests/unit/states/test_gnomedesktop.py | 6 +- tests/unit/states/test_grafana.py | 6 +- tests/unit/states/test_grafana_datasource.py | 6 +- tests/unit/states/test_grains.py | 6 +- tests/unit/states/test_group.py | 6 +- tests/unit/states/test_hg.py | 6 +- tests/unit/states/test_hipchat.py | 6 +- tests/unit/states/test_host.py | 6 +- tests/unit/states/test_htpasswd.py | 6 +- tests/unit/states/test_http.py | 6 +- tests/unit/states/test_incron.py | 6 +- tests/unit/states/test_influxdb08_database.py | 6 +- tests/unit/states/test_influxdb08_user.py | 6 +- tests/unit/states/test_ini_manage.py | 6 +- tests/unit/states/test_ipmi.py | 6 +- tests/unit/states/test_ipset.py | 6 +- tests/unit/states/test_iptables.py | 6 +- tests/unit/states/test_jboss7.py | 6 +- tests/unit/states/test_kapacitor.py | 4 +- tests/unit/states/test_keyboard.py | 6 +- tests/unit/states/test_keystone.py | 6 +- tests/unit/states/test_kmod.py | 6 +- tests/unit/states/test_layman.py | 6 +- tests/unit/states/test_ldap.py | 6 +- tests/unit/states/test_libcloud_dns.py | 6 +- tests/unit/states/test_libvirt.py | 6 +- tests/unit/states/test_linux_acl.py | 6 +- tests/unit/states/test_locale.py | 6 +- tests/unit/states/test_lvm.py | 6 +- tests/unit/states/test_lvs_server.py | 6 +- tests/unit/states/test_lvs_service.py | 6 +- tests/unit/states/test_lxc.py | 6 +- tests/unit/states/test_mac_assistive.py | 6 +- tests/unit/states/test_mac_defaults.py | 6 +- tests/unit/states/test_mac_keychain.py | 6 +- tests/unit/states/test_mac_package.py | 6 +- tests/unit/states/test_mac_xattr.py | 6 +- tests/unit/states/test_makeconf.py | 6 +- tests/unit/states/test_mdadm.py | 6 +- tests/unit/states/test_memcached.py | 6 +- tests/unit/states/test_modjk.py | 6 +- tests/unit/states/test_modjk_worker.py | 6 +- tests/unit/states/test_module.py | 6 +- tests/unit/states/test_mongodb_database.py | 6 +- tests/unit/states/test_mongodb_user.py | 6 +- tests/unit/states/test_mount.py | 6 +- tests/unit/states/test_mysql_grants.py | 6 +- tests/unit/states/test_mysql_query.py | 6 +- tests/unit/states/test_mysql_user.py | 6 +- tests/unit/states/test_network.py | 6 +- tests/unit/states/test_nftables.py | 6 +- tests/unit/states/test_npm.py | 6 +- tests/unit/states/test_ntp.py | 6 +- tests/unit/states/test_openstack_config.py | 6 +- tests/unit/states/test_openvswitch_port.py | 6 +- tests/unit/states/test_pagerduty.py | 6 +- tests/unit/states/test_pecl.py | 6 +- tests/unit/states/test_pip.py | 6 +- tests/unit/states/test_pkgng.py | 6 +- tests/unit/states/test_portage_config.py | 6 +- tests/unit/states/test_ports.py | 6 +- tests/unit/states/test_postgres.py | 6 +- tests/unit/states/test_postgres_cluster.py | 6 +- tests/unit/states/test_postgres_database.py | 6 +- tests/unit/states/test_postgres_extension.py | 6 +- tests/unit/states/test_postgres_group.py | 6 +- tests/unit/states/test_postgres_initdb.py | 6 +- tests/unit/states/test_postgres_language.py | 6 +- tests/unit/states/test_postgres_privileges.py | 6 +- tests/unit/states/test_postgres_schema.py | 6 +- tests/unit/states/test_postgres_user.py | 6 +- tests/unit/states/test_powerpath.py | 6 +- tests/unit/states/test_process.py | 6 +- tests/unit/states/test_proxy.py | 6 +- tests/unit/states/test_pyenv.py | 6 +- tests/unit/states/test_pyrax_queues.py | 6 +- tests/unit/states/test_quota.py | 6 +- tests/unit/states/test_rabbitmq_cluster.py | 6 +- tests/unit/states/test_rabbitmq_plugin.py | 6 +- tests/unit/states/test_rabbitmq_policy.py | 6 +- tests/unit/states/test_rabbitmq_vhost.py | 6 +- tests/unit/states/test_rbenv.py | 6 +- tests/unit/states/test_rdp.py | 6 +- tests/unit/states/test_redismod.py | 6 +- tests/unit/states/test_reg.py | 6 +- tests/unit/states/test_rvm.py | 6 +- tests/unit/states/test_saltmod.py | 6 +- tests/unit/states/test_schedule.py | 6 +- tests/unit/states/test_selinux.py | 6 +- .../unit/states/test_serverdensity_device.py | 6 +- tests/unit/states/test_service.py | 6 +- tests/unit/states/test_slack.py | 6 +- tests/unit/states/test_smtp.py | 6 +- tests/unit/states/test_splunk_search.py | 6 +- tests/unit/states/test_ssh_auth.py | 6 +- tests/unit/states/test_ssh_known_hosts.py | 6 +- tests/unit/states/test_status.py | 6 +- tests/unit/states/test_supervisord.py | 6 +- tests/unit/states/test_svn.py | 6 +- tests/unit/states/test_sysctl.py | 6 +- tests/unit/states/test_syslog_ng.py | 6 +- tests/unit/states/test_sysrc.py | 6 +- tests/unit/states/test_test.py | 6 +- tests/unit/states/test_timezone.py | 6 +- tests/unit/states/test_tomcat.py | 6 +- tests/unit/states/test_user.py | 6 +- tests/unit/states/test_vbox_guest.py | 6 +- tests/unit/states/test_virtualenv_mod.py | 6 +- tests/unit/states/test_win_certutil.py | 6 +- tests/unit/states/test_win_dism.py | 6 +- tests/unit/states/test_win_dns_client.py | 6 +- tests/unit/states/test_win_firewall.py | 6 +- tests/unit/states/test_win_license.py | 6 +- tests/unit/states/test_win_network.py | 6 +- tests/unit/states/test_win_path.py | 6 +- tests/unit/states/test_win_pki.py | 6 +- tests/unit/states/test_win_powercfg.py | 6 +- tests/unit/states/test_win_servermanager.py | 6 +- tests/unit/states/test_win_snmp.py | 6 +- tests/unit/states/test_win_system.py | 6 +- tests/unit/states/test_win_update.py | 6 +- tests/unit/states/test_winrepo.py | 6 +- tests/unit/states/test_xmpp.py | 6 +- tests/unit/states/test_zcbuildout.py | 4 +- tests/unit/states/test_zk_concurrency.py | 6 +- tests/unit/templates/test_jinja.py | 6 +- tests/unit/test_auth.py | 6 +- tests/unit/test_client.py | 6 +- tests/unit/test_conf.py | 6 +- tests/unit/test_context.py | 4 +- tests/unit/test_crypt.py | 6 +- tests/unit/test_daemons.py | 6 +- tests/unit/test_doc.py | 4 +- tests/unit/test_files.py | 4 +- tests/unit/test_log.py | 4 +- tests/unit/test_map_conf.py | 6 +- tests/unit/test_minion.py | 6 +- tests/unit/test_payload.py | 6 +- tests/unit/test_pillar.py | 6 +- tests/unit/test_pydsl.py | 4 +- tests/unit/test_pyobjects.py | 4 +- tests/unit/test_simple.py | 4 +- tests/unit/test_spm.py | 4 +- tests/unit/test_state.py | 6 +- tests/unit/test_stateconf.py | 4 +- tests/unit/test_statemod.py | 6 +- tests/unit/test_target.py | 2 +- tests/unit/test_template.py | 4 +- tests/unit/test_test_module_names.py | 2 +- tests/unit/test_version.py | 4 +- tests/unit/transport/test_ipc.py | 4 +- tests/unit/transport/test_tcp.py | 4 +- tests/unit/transport/test_zeromq.py | 2 +- tests/unit/utils/test_aggregation.py | 4 +- tests/unit/utils/test_args.py | 6 +- tests/unit/utils/test_boto.py | 6 +- tests/unit/utils/test_cache.py | 4 +- tests/unit/utils/test_cloud.py | 4 +- tests/unit/utils/test_configcomparer.py | 4 +- tests/unit/utils/test_context.py | 4 +- tests/unit/utils/test_decorators.py | 4 +- tests/unit/utils/test_dictupdate.py | 4 +- tests/unit/utils/test_disk_cache.py | 4 +- tests/unit/utils/test_etcd_util.py | 6 +- tests/unit/utils/test_event.py | 9 +- tests/unit/utils/test_extend.py | 6 +- tests/unit/utils/test_filebuffer.py | 4 +- tests/unit/utils/test_find.py | 4 +- tests/unit/utils/test_format_call.py | 4 +- tests/unit/utils/test_gitfs.py | 6 +- tests/unit/utils/test_http.py | 6 +- tests/unit/utils/test_immutabletypes.py | 4 +- tests/unit/utils/test_kwarg_regex.py | 4 +- tests/unit/utils/test_locales.py | 6 +- tests/unit/utils/test_mac_utils.py | 6 +- tests/unit/utils/test_minions.py | 4 +- tests/unit/utils/test_network.py | 8 +- tests/unit/utils/test_parsers.py | 6 +- tests/unit/utils/test_path_join.py | 4 +- tests/unit/utils/test_process.py | 4 +- tests/unit/utils/test_rsax931.py | 4 +- .../utils/test_runtime_whitespace_regex.py | 4 +- tests/unit/utils/test_safe_walk.py | 4 +- tests/unit/utils/test_sanitizers.py | 6 +- tests/unit/utils/test_schedule.py | 6 +- tests/unit/utils/test_schema.py | 4 +- tests/unit/utils/test_systemd.py | 4 +- tests/unit/utils/test_url.py | 6 +- tests/unit/utils/test_utils.py | 6 +- tests/unit/utils/test_validate_net.py | 6 +- tests/unit/utils/test_verify.py | 6 +- tests/unit/utils/test_vt.py | 4 +- tests/unit/utils/test_warnings.py | 4 +- tests/unit/utils/test_which.py | 6 +- tests/unit/utils/test_yamlloader.py | 6 +- tests/unit/utils/vmware_test/test_cluster.py | 4 +- tests/unit/utils/vmware_test/test_common.py | 4 +- .../unit/utils/vmware_test/test_connection.py | 4 +- .../unit/utils/vmware_test/test_datacenter.py | 4 +- tests/unit/utils/vmware_test/test_host.py | 4 +- 712 files changed, 5921 insertions(+), 1989 deletions(-) create mode 100644 tests/support/case.py create mode 100644 tests/support/ext/__init__.py create mode 100644 tests/support/ext/console.py create mode 100644 tests/support/mock.py create mode 100644 tests/support/parser/__init__.py create mode 100644 tests/support/parser/cover.py create mode 100644 tests/support/runtests.py create mode 100644 tests/support/unit.py create mode 100644 tests/support/xmlunit.py diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index c9ab2d856c..40f04998f8 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -47,14 +47,12 @@ if CODE_DIR not in sys.path: # Import salt tests support dirs from tests.support.paths import * # pylint: disable=wildcard-import from tests.support.processes import * # pylint: disable=wildcard-import - -# Import Salt Testing libs -from salttesting import TestCase -from salttesting.case import ShellTestCase -from salttesting.mixins import CheckShellBinaryNameAndVersionMixIn -from salttesting.parser import PNUM, print_header, SaltTestcaseParser -from salttesting.helpers import requires_sshd_server -from salttesting.helpers import ensure_in_syspath, RedirectStdStreams +from tests.support.unit import TestCase +from tests.support.case import ShellTestCase +from tests.support.mixins import CheckShellBinaryNameAndVersionMixin, ShellCaseCommonTestsMixin +from tests.support.parser import PNUM, print_header, SaltTestcaseParser +from tests.support.helpers import requires_sshd_server +from tests.support.helpers import ensure_in_syspath, RedirectStdStreams # Import Salt libs import salt @@ -109,92 +107,6 @@ from tornado import ioloop # Import salt tests support libs from tests.support.processes import SaltMaster, SaltMinion, SaltSyndic -try: - from salttesting.helpers import terminate_process_pid -except ImportError: - # Once the latest salt-testing works against salt's develop branch - # uncomment the following 2 lines and delete the function defined - # in this except - #print('Please upgrade your version of salt-testing') - #sys.exit(1) - - import psutil - - def terminate_process_pid(pid, only_children=False): - children = [] - process = None - - # Let's begin the shutdown routines - try: - process = psutil.Process(pid) - if hasattr(process, 'children'): - children = process.children(recursive=True) - except psutil.NoSuchProcess: - log.info('No process with the PID %s was found running', pid) - - if process and only_children is False: - try: - cmdline = process.cmdline() - except psutil.AccessDenied: - # macOS denies us access to the above information - cmdline = None - if not cmdline: - try: - cmdline = process.as_dict() - except psutil.NoSuchProcess as exc: - log.debug('No such process found. Stacktrace: {0}'.format(exc)) - - if psutil.pid_exists(pid): - log.info('Terminating process: %s', cmdline) - process.terminate() - try: - process.wait(timeout=10) - except psutil.TimeoutExpired: - pass - - if psutil.pid_exists(pid): - log.warning('Killing process: %s', cmdline) - process.kill() - - if psutil.pid_exists(pid): - log.warning('Process left behind which we were unable to kill: %s', cmdline) - if children: - # Lets log and kill any child processes which salt left behind - def kill_children(_children, kill=False): - for child in _children[:][::-1]: # Iterate over a reversed copy of the list - try: - if not kill and child.status() == psutil.STATUS_ZOMBIE: - # Zombie processes will exit once child processes also exit - continue - try: - cmdline = child.cmdline() - except psutil.AccessDenied as err: - log.debug('Cannot obtain child process cmdline: %s', err) - cmdline = '' - if not cmdline: - cmdline = child.as_dict() - if kill: - log.warning('Killing child process left behind: %s', cmdline) - child.kill() - else: - log.warning('Terminating child process left behind: %s', cmdline) - child.terminate() - if not psutil.pid_exists(child.pid): - _children.remove(child) - except psutil.NoSuchProcess: - _children.remove(child) - try: - kill_children([child for child in children if child.is_running() - and not any(sys.argv[0] in cmd for cmd in child.cmdline())]) - except psutil.AccessDenied: - # OSX denies us access to the above information - kill_children(children) - - if children: - psutil.wait_procs(children, timeout=3, callback=lambda proc: kill_children(children, kill=True)) - - if children: - psutil.wait_procs(children, timeout=1, callback=lambda proc: kill_children(children, kill=True)) RUNTIME_CONFIGS = {} @@ -1829,67 +1741,6 @@ class ShellCase(AdaptedConfigurationTestCaseMixIn, ShellTestCase, ScriptPathMixi timeout=timeout) -class ShellCaseCommonTestsMixIn(CheckShellBinaryNameAndVersionMixIn): - - _call_binary_expected_version_ = salt.version.__version__ - - def test_salt_with_git_version(self): - if getattr(self, '_call_binary_', None) is None: - self.skipTest('\'_call_binary_\' not defined.') - from salt.utils import which - from salt.version import __version_info__, SaltStackVersion - git = which('git') - if not git: - self.skipTest('The git binary is not available') - - # Let's get the output of git describe - process = subprocess.Popen( - [git, 'describe', '--tags', '--first-parent', '--match', 'v[0-9]*'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True, - cwd=CODE_DIR - ) - out, err = process.communicate() - if process.returncode != 0: - process = subprocess.Popen( - [git, 'describe', '--tags', '--match', 'v[0-9]*'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True, - cwd=CODE_DIR - ) - out, err = process.communicate() - if not out: - self.skipTest( - 'Failed to get the output of \'git describe\'. ' - 'Error: \'{0}\''.format( - salt.utils.to_str(err) - ) - ) - - parsed_version = SaltStackVersion.parse(out) - - if parsed_version.info < __version_info__: - self.skipTest( - 'We\'re likely about to release a new version. This test ' - 'would fail. Parsed(\'{0}\') < Expected(\'{1}\')'.format( - parsed_version.info, __version_info__ - ) - ) - elif parsed_version.info != __version_info__: - self.skipTest( - 'In order to get the proper salt version with the ' - 'git hash you need to update salt\'s local git ' - 'tags. Something like: \'git fetch --tags\' or ' - '\'git fetch --tags upstream\' if you followed ' - 'salt\'s contribute documentation. The version ' - 'string WILL NOT include the git hash.' - ) - out = '\n'.join(self.run_script(self._call_binary_, '--version')) - self.assertIn(parsed_version.string, out) - - @requires_sshd_server class SSHCase(ShellCase): ''' diff --git a/tests/integration/cli/test_batch.py b/tests/integration/cli/test_batch.py index 0ec86bf0b3..263aae64c0 100644 --- a/tests/integration/cli/test_batch.py +++ b/tests/integration/cli/test_batch.py @@ -6,7 +6,7 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/cli/test_grains.py b/tests/integration/cli/test_grains.py index 4b1d49393b..85f8d60a82 100644 --- a/tests/integration/cli/test_grains.py +++ b/tests/integration/cli/test_grains.py @@ -21,7 +21,7 @@ import integration import salt.utils # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/client/test_kwarg.py b/tests/integration/client/test_kwarg.py index 5c69243479..de90740f2f 100644 --- a/tests/integration/client/test_kwarg.py +++ b/tests/integration/client/test_kwarg.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/client/test_runner.py b/tests/integration/client/test_runner.py index c00948f7f1..81da86c903 100644 --- a/tests/integration/client/test_runner.py +++ b/tests/integration/client/test_runner.py @@ -5,7 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs import integration -from salttesting import skipIf +from tests.support.unit import skipIf # Import Salt libs import salt.runner diff --git a/tests/integration/client/test_standard.py b/tests/integration/client/test_standard.py index d54b563725..2a7c39f2df 100644 --- a/tests/integration/client/test_standard.py +++ b/tests/integration/client/test_standard.py @@ -5,7 +5,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/client/test_syndic.py b/tests/integration/client/test_syndic.py index 8967453d2e..99ccd52664 100644 --- a/tests/integration/client/test_syndic.py +++ b/tests/integration/client/test_syndic.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/cloud/helpers/virtualbox.py b/tests/integration/cloud/helpers/virtualbox.py index 37841a4f65..6e64ea18ed 100644 --- a/tests/integration/cloud/helpers/virtualbox.py +++ b/tests/integration/cloud/helpers/virtualbox.py @@ -8,7 +8,7 @@ import os import unittest # Import Salt Testing libs -from salttesting import skipIf +from tests.support.unit import skipIf # Import Salt libs import salt.ext.six as six diff --git a/tests/integration/cloud/providers/test_digital_ocean.py b/tests/integration/cloud/providers/test_digital_ocean.py index 169c3316bf..702260972a 100644 --- a/tests/integration/cloud/providers/test_digital_ocean.py +++ b/tests/integration/cloud/providers/test_digital_ocean.py @@ -10,7 +10,7 @@ import random import string # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_ec2.py b/tests/integration/cloud/providers/test_ec2.py index f7bfe39938..f63510e2a9 100644 --- a/tests/integration/cloud/providers/test_ec2.py +++ b/tests/integration/cloud/providers/test_ec2.py @@ -14,7 +14,7 @@ import integration from salt.config import cloud_providers_config # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_gce.py b/tests/integration/cloud/providers/test_gce.py index 65e03c1efd..9f64f86dcb 100644 --- a/tests/integration/cloud/providers/test_gce.py +++ b/tests/integration/cloud/providers/test_gce.py @@ -15,7 +15,7 @@ import integration from salt.config import cloud_providers_config # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_gogrid.py b/tests/integration/cloud/providers/test_gogrid.py index 5913455f1d..b54b79bfa2 100644 --- a/tests/integration/cloud/providers/test_gogrid.py +++ b/tests/integration/cloud/providers/test_gogrid.py @@ -10,8 +10,8 @@ import random import string # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath, expensiveTest -from salttesting import skipIf +from tests.support.helpers import ensure_in_syspath, expensiveTest +from tests.support.unit import skipIf ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_joyent.py b/tests/integration/cloud/providers/test_joyent.py index d1f18c8158..6b894380e4 100644 --- a/tests/integration/cloud/providers/test_joyent.py +++ b/tests/integration/cloud/providers/test_joyent.py @@ -10,7 +10,7 @@ import random import string # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_linode.py b/tests/integration/cloud/providers/test_linode.py index d92958aafd..cb06d9c853 100644 --- a/tests/integration/cloud/providers/test_linode.py +++ b/tests/integration/cloud/providers/test_linode.py @@ -10,7 +10,7 @@ import random import string # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_msazure.py b/tests/integration/cloud/providers/test_msazure.py index 73f8a71d36..8c0e987ea0 100644 --- a/tests/integration/cloud/providers/test_msazure.py +++ b/tests/integration/cloud/providers/test_msazure.py @@ -11,8 +11,8 @@ import string from distutils.version import LooseVersion # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_openstack.py b/tests/integration/cloud/providers/test_openstack.py index f406ebe033..5cc1ae95b6 100644 --- a/tests/integration/cloud/providers/test_openstack.py +++ b/tests/integration/cloud/providers/test_openstack.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath ) diff --git a/tests/integration/cloud/providers/test_profitbricks.py b/tests/integration/cloud/providers/test_profitbricks.py index 43e089b3d0..63f2dfa817 100644 --- a/tests/integration/cloud/providers/test_profitbricks.py +++ b/tests/integration/cloud/providers/test_profitbricks.py @@ -10,8 +10,8 @@ import random import string # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_rackspace.py b/tests/integration/cloud/providers/test_rackspace.py index 9e44f67f2d..4936ddd19d 100644 --- a/tests/integration/cloud/providers/test_rackspace.py +++ b/tests/integration/cloud/providers/test_rackspace.py @@ -10,8 +10,8 @@ import random import string # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/cloud/providers/test_virtualbox.py b/tests/integration/cloud/providers/test_virtualbox.py index 477514dbd5..50f32eaca4 100644 --- a/tests/integration/cloud/providers/test_virtualbox.py +++ b/tests/integration/cloud/providers/test_virtualbox.py @@ -10,8 +10,8 @@ import logging import socket # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath from integration.cloud.helpers.virtualbox import VirtualboxTestCase, VirtualboxCloudTestCase, CONFIG_NAME, \ PROVIDER_NAME, \ diff --git a/tests/integration/cloud/providers/test_vultr.py b/tests/integration/cloud/providers/test_vultr.py index 19da880fec..1401269fed 100644 --- a/tests/integration/cloud/providers/test_vultr.py +++ b/tests/integration/cloud/providers/test_vultr.py @@ -11,7 +11,7 @@ import string import time # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath, expensiveTest +from tests.support.helpers import ensure_in_syspath, expensiveTest ensure_in_syspath('../../../') diff --git a/tests/integration/fileserver/test_fileclient.py b/tests/integration/fileserver/test_fileclient.py index 86a439915c..fb1382448a 100644 --- a/tests/integration/fileserver/test_fileclient.py +++ b/tests/integration/fileserver/test_fileclient.py @@ -12,9 +12,9 @@ import shutil log = logging.getLogger(__name__) # Import Salt Testing libs -from salttesting.unit import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../..') # Import salt libs diff --git a/tests/integration/fileserver/test_gitfs.py b/tests/integration/fileserver/test_gitfs.py index 531a0d16bd..36d969051d 100644 --- a/tests/integration/fileserver/test_gitfs.py +++ b/tests/integration/fileserver/test_gitfs.py @@ -10,9 +10,9 @@ import pwd import shutil # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../..') diff --git a/tests/integration/fileserver/test_roots.py b/tests/integration/fileserver/test_roots.py index 2c0aa4d55e..c22f73840d 100644 --- a/tests/integration/fileserver/test_roots.py +++ b/tests/integration/fileserver/test_roots.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../..') # Import salt libs diff --git a/tests/integration/grains/test_core.py b/tests/integration/grains/test_core.py index fa12ed327e..5978eac24c 100644 --- a/tests/integration/grains/test_core.py +++ b/tests/integration/grains/test_core.py @@ -7,8 +7,8 @@ Test the core grains from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/loader/test_ext_grains.py b/tests/integration/loader/test_ext_grains.py index 2dd0d6fa17..043658731b 100644 --- a/tests/integration/loader/test_ext_grains.py +++ b/tests/integration/loader/test_ext_grains.py @@ -10,7 +10,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.unit import skipIf +from tests.support.unit import skipIf # Import salt libs import integration diff --git a/tests/integration/loader/test_ext_modules.py b/tests/integration/loader/test_ext_modules.py index 3e6f26ff4f..5caa1d04ef 100644 --- a/tests/integration/loader/test_ext_modules.py +++ b/tests/integration/loader/test_ext_modules.py @@ -13,7 +13,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') # Import salt libs diff --git a/tests/integration/loader/test_globals.py b/tests/integration/loader/test_globals.py index ea870af207..1a2079bc44 100644 --- a/tests/integration/loader/test_globals.py +++ b/tests/integration/loader/test_globals.py @@ -10,7 +10,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/loader/test_interfaces.py b/tests/integration/loader/test_interfaces.py index a23211b5be..0ca1a0ba0c 100644 --- a/tests/integration/loader/test_interfaces.py +++ b/tests/integration/loader/test_interfaces.py @@ -10,8 +10,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/loader/test_loader.py b/tests/integration/loader/test_loader.py index 57b5a67dcf..77f3168fa4 100644 --- a/tests/integration/loader/test_loader.py +++ b/tests/integration/loader/test_loader.py @@ -18,8 +18,8 @@ import collections log = logging.getLogger(__name__) # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/minion/test_blackout.py b/tests/integration/minion/test_blackout.py index 5d59b624dd..ae173b55ce 100644 --- a/tests/integration/minion/test_blackout.py +++ b/tests/integration/minion/test_blackout.py @@ -10,7 +10,7 @@ from time import sleep import textwrap # Import Salt Testing libs -from salttesting.helpers import destructiveTest, ensure_in_syspath +from tests.support.helpers import destructiveTest, ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/integration/minion/test_pillar.py b/tests/integration/minion/test_pillar.py index 9cf9b9bd2e..fb8187fc64 100644 --- a/tests/integration/minion/test_pillar.py +++ b/tests/integration/minion/test_pillar.py @@ -5,9 +5,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, requires_system_grains -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, requires_system_grains +from tests.support.mock import NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../..') @@ -24,7 +24,7 @@ from subprocess import Popen, PIPE, STDOUT log = logging.getLogger(__name__) # Import 3rd-party libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('..') import salt.ext.six as six diff --git a/tests/integration/minion/test_timeout.py b/tests/integration/minion/test_timeout.py index 3b0ee0f6fe..c0f7145bfe 100644 --- a/tests/integration/minion/test_timeout.py +++ b/tests/integration/minion/test_timeout.py @@ -8,7 +8,7 @@ from __future__ import absolute_import # Import Salt Testing libs import integration -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/integration/modules/test_aliases.py b/tests/integration/modules/test_aliases.py index 9c2b48b3ec..a24b1621da 100644 --- a/tests/integration/modules/test_aliases.py +++ b/tests/integration/modules/test_aliases.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_archive.py b/tests/integration/modules/test_archive.py index 6c6ba7c4e4..f44136c4cc 100644 --- a/tests/integration/modules/test_archive.py +++ b/tests/integration/modules/test_archive.py @@ -9,8 +9,8 @@ import shutil import textwrap # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath ) diff --git a/tests/integration/modules/test_beacons.py b/tests/integration/modules/test_beacons.py index 7841011d63..bac0d7ba39 100644 --- a/tests/integration/modules/test_beacons.py +++ b/tests/integration/modules/test_beacons.py @@ -13,7 +13,7 @@ import integration import salt.utils # Salttesting libs -from salttesting import skipIf +from tests.support.unit import skipIf BEACON_CONF_DIR = os.path.join(integration.TMP, 'minion.d') diff --git a/tests/integration/modules/test_boto_iam.py b/tests/integration/modules/test_boto_iam.py index ca821c2299..445a2a14c0 100644 --- a/tests/integration/modules/test_boto_iam.py +++ b/tests/integration/modules/test_boto_iam.py @@ -7,8 +7,8 @@ Validate the boto_iam module from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/integration/modules/test_boto_sns.py b/tests/integration/modules/test_boto_sns.py index ee27370e28..f0cf7fb1c0 100644 --- a/tests/integration/modules/test_boto_sns.py +++ b/tests/integration/modules/test_boto_sns.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import re # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/integration/modules/test_cmdmod.py b/tests/integration/modules/test_cmdmod.py index 8019c7d25e..a19abfd713 100644 --- a/tests/integration/modules/test_cmdmod.py +++ b/tests/integration/modules/test_cmdmod.py @@ -8,13 +8,13 @@ import textwrap import tempfile # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, skip_if_binaries_missing ) -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_config.py b/tests/integration/modules/test_config.py index de3f43d9fd..9319bdcb4a 100644 --- a/tests/integration/modules/test_config.py +++ b/tests/integration/modules/test_config.py @@ -7,7 +7,7 @@ Validate the config system from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_cp.py b/tests/integration/modules/test_cp.py index e9b0888d06..4c6da5c980 100644 --- a/tests/integration/modules/test_cp.py +++ b/tests/integration/modules/test_cp.py @@ -8,7 +8,7 @@ import hashlib import tempfile # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_darwin_sysctl.py b/tests/integration/modules/test_darwin_sysctl.py index 45eacc32e9..878d57dabc 100644 --- a/tests/integration/modules/test_darwin_sysctl.py +++ b/tests/integration/modules/test_darwin_sysctl.py @@ -15,8 +15,8 @@ import salt.utils.files from salt.exceptions import CommandExecutionError # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_data.py b/tests/integration/modules/test_data.py index 55d7836c72..e70db58856 100644 --- a/tests/integration/modules/test_data.py +++ b/tests/integration/modules/test_data.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_decorators.py b/tests/integration/modules/test_decorators.py index e50969889d..bd8c953e56 100644 --- a/tests/integration/modules/test_decorators.py +++ b/tests/integration/modules/test_decorators.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_disk.py b/tests/integration/modules/test_disk.py index f7ae34a9e0..3e02f2c5cb 100644 --- a/tests/integration/modules/test_disk.py +++ b/tests/integration/modules/test_disk.py @@ -6,8 +6,8 @@ import os import shutil # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import (ensure_in_syspath, destructiveTest) +from tests.support.unit import skipIf +from tests.support.helpers import (ensure_in_syspath, destructiveTest) ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_django.py b/tests/integration/modules/test_django.py index e5c26306d7..1e1babee17 100644 --- a/tests/integration/modules/test_django.py +++ b/tests/integration/modules/test_django.py @@ -6,9 +6,9 @@ Test the django module from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_event.py b/tests/integration/modules/test_event.py index 82183d0047..fe365f7caa 100644 --- a/tests/integration/modules/test_event.py +++ b/tests/integration/modules/test_event.py @@ -13,7 +13,7 @@ import time import threading # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_file.py b/tests/integration/modules/test_file.py index 3ce1b916fe..6320adae69 100644 --- a/tests/integration/modules/test_file.py +++ b/tests/integration/modules/test_file.py @@ -10,9 +10,9 @@ import shutil import sys # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, MagicMock +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, MagicMock ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_gem.py b/tests/integration/modules/test_gem.py index ca1cb39b98..08a1d074c7 100644 --- a/tests/integration/modules/test_gem.py +++ b/tests/integration/modules/test_gem.py @@ -7,8 +7,8 @@ Integration tests for Ruby Gem module from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_gentoolkitmod.py b/tests/integration/modules/test_gentoolkitmod.py index 2e24766801..a48784fb6b 100644 --- a/tests/integration/modules/test_gentoolkitmod.py +++ b/tests/integration/modules/test_gentoolkitmod.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_git.py b/tests/integration/modules/test_git.py index f64c5d5b7f..c402d07f4c 100644 --- a/tests/integration/modules/test_git.py +++ b/tests/integration/modules/test_git.py @@ -21,8 +21,8 @@ import tempfile # Import Salt Testing libs from distutils.version import LooseVersion -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, skip_if_binaries_missing diff --git a/tests/integration/modules/test_grains.py b/tests/integration/modules/test_grains.py index 1f986a440e..8cb0a8b805 100644 --- a/tests/integration/modules/test_grains.py +++ b/tests/integration/modules/test_grains.py @@ -9,8 +9,8 @@ import os import time # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import destructiveTest, ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_groupadd.py b/tests/integration/modules/test_groupadd.py index 886b83b13f..e783258c21 100644 --- a/tests/integration/modules/test_groupadd.py +++ b/tests/integration/modules/test_groupadd.py @@ -6,7 +6,7 @@ import string import random # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_hosts.py b/tests/integration/modules/test_hosts.py index f7a2369617..f22f5f0846 100644 --- a/tests/integration/modules/test_hosts.py +++ b/tests/integration/modules/test_hosts.py @@ -8,7 +8,7 @@ import os import shutil # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_key.py b/tests/integration/modules/test_key.py index b86f3e194c..6101ef0953 100644 --- a/tests/integration/modules/test_key.py +++ b/tests/integration/modules/test_key.py @@ -5,7 +5,7 @@ from __future__ import absolute_import import re # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_linux_acl.py b/tests/integration/modules/test_linux_acl.py index 61819a4954..6355609d7b 100644 --- a/tests/integration/modules/test_linux_acl.py +++ b/tests/integration/modules/test_linux_acl.py @@ -6,7 +6,7 @@ import os import shutil # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, skip_if_binaries_missing +from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing import salt.utils ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_locale.py b/tests/integration/modules/test_locale.py index eca6fb0af3..737ea77167 100644 --- a/tests/integration/modules/test_locale.py +++ b/tests/integration/modules/test_locale.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( ensure_in_syspath, requires_salt_modules, requires_system_grains, diff --git a/tests/integration/modules/test_lxc.py b/tests/integration/modules/test_lxc.py index 3370012c8e..d96964f7b1 100644 --- a/tests/integration/modules/test_lxc.py +++ b/tests/integration/modules/test_lxc.py @@ -8,12 +8,12 @@ Test the lxc module from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ( +from tests.support.helpers import ( ensure_in_syspath, skip_if_not_root, skip_if_binaries_missing ) -from salttesting import skipIf +from tests.support.unit import skipIf ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mac_assistive.py b/tests/integration/modules/test_mac_assistive.py index 35ec90f0ed..77bcfd521e 100644 --- a/tests/integration/modules/test_mac_assistive.py +++ b/tests/integration/modules/test_mac_assistive.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_mac_brew.py b/tests/integration/modules/test_mac_brew.py index a5f8e65960..bbd5f88e1b 100644 --- a/tests/integration/modules/test_mac_brew.py +++ b/tests/integration/modules/test_mac_brew.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, ) diff --git a/tests/integration/modules/test_mac_defaults.py b/tests/integration/modules/test_mac_defaults.py index 3dfeb559a0..657d96eb6b 100644 --- a/tests/integration/modules/test_mac_defaults.py +++ b/tests/integration/modules/test_mac_defaults.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_mac_desktop.py b/tests/integration/modules/test_mac_desktop.py index a596fa129d..f19acb28fe 100644 --- a/tests/integration/modules/test_mac_desktop.py +++ b/tests/integration/modules/test_mac_desktop.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_mac_group.py b/tests/integration/modules/test_mac_group.py index 99cfdad701..79ba420ab7 100644 --- a/tests/integration/modules/test_mac_group.py +++ b/tests/integration/modules/test_mac_group.py @@ -10,8 +10,8 @@ import random import string # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_mac_keychain.py b/tests/integration/modules/test_mac_keychain.py index cc44b74624..e8c2e7c645 100644 --- a/tests/integration/modules/test_mac_keychain.py +++ b/tests/integration/modules/test_mac_keychain.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_mac_pkgutil.py b/tests/integration/modules/test_mac_pkgutil.py index 8ee15698a7..d849488193 100644 --- a/tests/integration/modules/test_mac_pkgutil.py +++ b/tests/integration/modules/test_mac_pkgutil.py @@ -8,7 +8,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mac_ports.py b/tests/integration/modules/test_mac_ports.py index 786ca00874..1b5cd23aff 100644 --- a/tests/integration/modules/test_mac_ports.py +++ b/tests/integration/modules/test_mac_ports.py @@ -7,7 +7,7 @@ integration tests for mac_ports from __future__ import absolute_import, print_function # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mac_power.py b/tests/integration/modules/test_mac_power.py index 026cccebc9..f47d667a1b 100644 --- a/tests/integration/modules/test_mac_power.py +++ b/tests/integration/modules/test_mac_power.py @@ -7,8 +7,8 @@ integration tests for mac_power from __future__ import absolute_import, print_function # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest # Import salt libs import integration diff --git a/tests/integration/modules/test_mac_service.py b/tests/integration/modules/test_mac_service.py index f3cc35ae1d..5f22d06376 100644 --- a/tests/integration/modules/test_mac_service.py +++ b/tests/integration/modules/test_mac_service.py @@ -7,8 +7,8 @@ integration tests for mac_service from __future__ import absolute_import, print_function # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mac_shadow.py b/tests/integration/modules/test_mac_shadow.py index c3bca54c00..6a86517651 100644 --- a/tests/integration/modules/test_mac_shadow.py +++ b/tests/integration/modules/test_mac_shadow.py @@ -10,7 +10,7 @@ import random import string # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import ensure_in_syspath, destructiveTest from salt.ext.six.moves import range ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_mac_softwareupdate.py b/tests/integration/modules/test_mac_softwareupdate.py index 51978328c3..8caba94f10 100644 --- a/tests/integration/modules/test_mac_softwareupdate.py +++ b/tests/integration/modules/test_mac_softwareupdate.py @@ -7,7 +7,7 @@ integration tests for mac_softwareupdate from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mac_system.py b/tests/integration/modules/test_mac_system.py index add68e6702..117b41dd40 100644 --- a/tests/integration/modules/test_mac_system.py +++ b/tests/integration/modules/test_mac_system.py @@ -9,8 +9,8 @@ import random import string # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest from salt.ext.six.moves import range ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_mac_timezone.py b/tests/integration/modules/test_mac_timezone.py index e9a0a3b896..6ad8f962a8 100644 --- a/tests/integration/modules/test_mac_timezone.py +++ b/tests/integration/modules/test_mac_timezone.py @@ -15,8 +15,8 @@ from __future__ import absolute_import import datetime # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mac_user.py b/tests/integration/modules/test_mac_user.py index d7e512237d..ba384facd9 100644 --- a/tests/integration/modules/test_mac_user.py +++ b/tests/integration/modules/test_mac_user.py @@ -10,8 +10,8 @@ import random import string # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_mac_xattr.py b/tests/integration/modules/test_mac_xattr.py index 8b13203e30..d707f5d479 100644 --- a/tests/integration/modules/test_mac_xattr.py +++ b/tests/integration/modules/test_mac_xattr.py @@ -8,7 +8,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mine.py b/tests/integration/modules/test_mine.py index 665c3c8fb8..ce6b312a4a 100644 --- a/tests/integration/modules/test_mine.py +++ b/tests/integration/modules/test_mine.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import time # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_mysql.py b/tests/integration/modules/test_mysql.py index 580815e668..6f1d2034ce 100644 --- a/tests/integration/modules/test_mysql.py +++ b/tests/integration/modules/test_mysql.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath ) diff --git a/tests/integration/modules/test_nilrt_ip.py b/tests/integration/modules/test_nilrt_ip.py index 1f7dab1743..c7bc1b027e 100644 --- a/tests/integration/modules/test_nilrt_ip.py +++ b/tests/integration/modules/test_nilrt_ip.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import time # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_pillar.py b/tests/integration/modules/test_pillar.py index 3d55b4c13f..fcd9f4d589 100644 --- a/tests/integration/modules/test_pillar.py +++ b/tests/integration/modules/test_pillar.py @@ -5,8 +5,8 @@ from __future__ import absolute_import from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( ensure_in_syspath, requires_network ) diff --git a/tests/integration/modules/test_pip.py b/tests/integration/modules/test_pip.py index 403aa8b01d..27ba29fc40 100644 --- a/tests/integration/modules/test_pip.py +++ b/tests/integration/modules/test_pip.py @@ -15,8 +15,8 @@ import re import tempfile # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_pkg.py b/tests/integration/modules/test_pkg.py index d00d93bd6e..1892f2e6d5 100644 --- a/tests/integration/modules/test_pkg.py +++ b/tests/integration/modules/test_pkg.py @@ -3,7 +3,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ( +from tests.support.helpers import ( destructiveTest, requires_network, requires_salt_modules, diff --git a/tests/integration/modules/test_publish.py b/tests/integration/modules/test_publish.py index 52152dddbf..bcf5de3bfa 100644 --- a/tests/integration/modules/test_publish.py +++ b/tests/integration/modules/test_publish.py @@ -4,7 +4,7 @@ from __future__ import absolute_import, print_function # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_pw_user.py b/tests/integration/modules/test_pw_user.py index 9fe7e21cc6..c13522397d 100644 --- a/tests/integration/modules/test_pw_user.py +++ b/tests/integration/modules/test_pw_user.py @@ -12,8 +12,8 @@ import string import random # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import destructiveTest, ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_rabbitmq.py b/tests/integration/modules/test_rabbitmq.py index 9395bb592d..b6f77b6d39 100644 --- a/tests/integration/modules/test_rabbitmq.py +++ b/tests/integration/modules/test_rabbitmq.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, requires_salt_modules +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, requires_salt_modules ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_random_org.py b/tests/integration/modules/test_random_org.py index f30a208446..ef1b98b413 100644 --- a/tests/integration/modules/test_random_org.py +++ b/tests/integration/modules/test_random_org.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_saltutil.py b/tests/integration/modules/test_saltutil.py index 3be8ec4919..e54a80ac04 100644 --- a/tests/integration/modules/test_saltutil.py +++ b/tests/integration/modules/test_saltutil.py @@ -8,7 +8,7 @@ from __future__ import absolute_import import time # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_shadow.py b/tests/integration/modules/test_shadow.py index fba830fff5..40cd4cdc12 100644 --- a/tests/integration/modules/test_shadow.py +++ b/tests/integration/modules/test_shadow.py @@ -10,8 +10,8 @@ import string import os # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, destructiveTest from salt.ext.six.moves import range ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_ssh.py b/tests/integration/modules/test_ssh.py index f46bd95de9..d5209a37d2 100644 --- a/tests/integration/modules/test_ssh.py +++ b/tests/integration/modules/test_ssh.py @@ -9,8 +9,8 @@ import os import shutil # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath, skip_if_binaries_missing +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing ensure_in_syspath('../../') diff --git a/tests/integration/modules/test_state.py b/tests/integration/modules/test_state.py index 057e2cb1e4..41eb470d3f 100644 --- a/tests/integration/modules/test_state.py +++ b/tests/integration/modules/test_state.py @@ -9,8 +9,8 @@ import threading import time # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_supervisord.py b/tests/integration/modules/test_supervisord.py index 36141d6045..b0ffb6f3d2 100644 --- a/tests/integration/modules/test_supervisord.py +++ b/tests/integration/modules/test_supervisord.py @@ -7,8 +7,8 @@ import time import subprocess # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_sysctl.py b/tests/integration/modules/test_sysctl.py index 728dd10d15..1dd6341c78 100644 --- a/tests/integration/modules/test_sysctl.py +++ b/tests/integration/modules/test_sysctl.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import sys # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_sysmod.py b/tests/integration/modules/test_sysmod.py index 5f351a8491..c96e9ba0ea 100644 --- a/tests/integration/modules/test_sysmod.py +++ b/tests/integration/modules/test_sysmod.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_system.py b/tests/integration/modules/test_system.py index 210d75fe49..263798065d 100644 --- a/tests/integration/modules/test_system.py +++ b/tests/integration/modules/test_system.py @@ -9,8 +9,8 @@ import signal import subprocess # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath ) diff --git a/tests/integration/modules/test_test.py b/tests/integration/modules/test_test.py index b2b2f900af..626d240ec6 100644 --- a/tests/integration/modules/test_test.py +++ b/tests/integration/modules/test_test.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_timezone.py b/tests/integration/modules/test_timezone.py index 6b3754f5c2..5380a6425c 100644 --- a/tests/integration/modules/test_timezone.py +++ b/tests/integration/modules/test_timezone.py @@ -9,7 +9,7 @@ Linux and Solaris are supported from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_useradd.py b/tests/integration/modules/test_useradd.py index 7cf4a18848..307ce2366a 100644 --- a/tests/integration/modules/test_useradd.py +++ b/tests/integration/modules/test_useradd.py @@ -7,8 +7,8 @@ import string import random # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/modules/test_virt.py b/tests/integration/modules/test_virt.py index 2076d5909f..a685d892f2 100644 --- a/tests/integration/modules/test_virt.py +++ b/tests/integration/modules/test_virt.py @@ -7,7 +7,7 @@ Validate the virt module from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, requires_salt_modules +from tests.support.helpers import ensure_in_syspath, requires_salt_modules ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/modules/test_virtualenv.py b/tests/integration/modules/test_virtualenv.py index fb65fbeaf7..f485f72307 100644 --- a/tests/integration/modules/test_virtualenv.py +++ b/tests/integration/modules/test_virtualenv.py @@ -6,8 +6,8 @@ import os import tempfile # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/netapi/rest_cherrypy/test_app_pam.py b/tests/integration/netapi/rest_cherrypy/test_app_pam.py index efeedb5eb7..c0ef9cbed1 100644 --- a/tests/integration/netapi/rest_cherrypy/test_app_pam.py +++ b/tests/integration/netapi/rest_cherrypy/test_app_pam.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import salttesting libs -from salttesting.unit import skipIf -from salttesting.helpers import destructiveTest +from tests.support.unit import skipIf +from tests.support.helpers import destructiveTest # Import test support libs import tests.support.cherrypy_testclasses as cptc diff --git a/tests/integration/netapi/rest_tornado/test_app.py b/tests/integration/netapi/rest_tornado/test_app.py index acfe98aafc..ee9ec9f992 100644 --- a/tests/integration/netapi/rest_tornado/test_app.py +++ b/tests/integration/netapi/rest_tornado/test_app.py @@ -12,8 +12,8 @@ from salt.netapi.rest_tornado import saltnado from unit.netapi.rest_tornado.test_handlers import SaltnadoTestCase # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../../') diff --git a/tests/integration/netapi/test_client.py b/tests/integration/netapi/test_client.py index bd6ab7f5a0..cb435721e7 100644 --- a/tests/integration/netapi/test_client.py +++ b/tests/integration/netapi/test_client.py @@ -6,7 +6,7 @@ import os # Import Salt Testing libs from integration import TMP_CONF_DIR -from salttesting import TestCase +from tests.support.unit import TestCase # Import Salt libs import salt.config diff --git a/tests/integration/output/test_output.py b/tests/integration/output/test_output.py index 5223ad9116..c9bd9e1f78 100644 --- a/tests/integration/output/test_output.py +++ b/tests/integration/output/test_output.py @@ -9,8 +9,8 @@ import os import traceback # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath -from salttesting.mixins import RUNTIME_VARS +from tests.support.helpers import ensure_in_syspath +from tests.support.mixins import RUNTIME_VARS ensure_in_syspath('../../') diff --git a/tests/integration/reactor/test_reactor.py b/tests/integration/reactor/test_reactor.py index 2d4d4d510d..788740d174 100644 --- a/tests/integration/reactor/test_reactor.py +++ b/tests/integration/reactor/test_reactor.py @@ -11,7 +11,7 @@ from __future__ import absolute_import # Import Salt testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/integration/renderers/test_pydsl.py b/tests/integration/renderers/test_pydsl.py index 90d4426f0c..06d393832b 100644 --- a/tests/integration/renderers/test_pydsl.py +++ b/tests/integration/renderers/test_pydsl.py @@ -6,7 +6,7 @@ import os import textwrap # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/integration/returners/test_librato_return.py b/tests/integration/returners/test_librato_return.py index 7fbc3845ac..ff12409d8c 100644 --- a/tests/integration/returners/test_librato_return.py +++ b/tests/integration/returners/test_librato_return.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/returners/test_local_cache.py b/tests/integration/returners/test_local_cache.py index 8eb4eaf630..aa13d0dffa 100644 --- a/tests/integration/returners/test_local_cache.py +++ b/tests/integration/returners/test_local_cache.py @@ -8,7 +8,7 @@ import logging import os # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/runners/test_fileserver.py b/tests/integration/runners/test_fileserver.py index 653a92459d..3b0ca952de 100644 --- a/tests/integration/runners/test_fileserver.py +++ b/tests/integration/runners/test_fileserver.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import contextlib # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/runners/test_jobs.py b/tests/integration/runners/test_jobs.py index 57ac15ae74..cc3f63f72e 100644 --- a/tests/integration/runners/test_jobs.py +++ b/tests/integration/runners/test_jobs.py @@ -6,8 +6,8 @@ Tests for the salt-run command from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/runners/test_manage.py b/tests/integration/runners/test_manage.py index 21e3998509..b7d8b59a34 100644 --- a/tests/integration/runners/test_manage.py +++ b/tests/integration/runners/test_manage.py @@ -6,7 +6,7 @@ Tests for the salt-run command from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/runners/test_runner_returns.py b/tests/integration/runners/test_runner_returns.py index f8a60ddb5a..8b0c8e6b6a 100644 --- a/tests/integration/runners/test_runner_returns.py +++ b/tests/integration/runners/test_runner_returns.py @@ -10,7 +10,7 @@ import tempfile import yaml # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/runners/test_salt.py b/tests/integration/runners/test_salt.py index 8e804c88e4..6b4ae620dc 100644 --- a/tests/integration/runners/test_salt.py +++ b/tests/integration/runners/test_salt.py @@ -8,7 +8,7 @@ Tests for the salt runner from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/runners/test_state.py b/tests/integration/runners/test_state.py index 3ca74e915b..c999d2410d 100644 --- a/tests/integration/runners/test_state.py +++ b/tests/integration/runners/test_state.py @@ -16,8 +16,8 @@ import threading from salt.ext.six.moves import queue # Import Salt Testing Libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') import integration diff --git a/tests/integration/runners/test_winrepo.py b/tests/integration/runners/test_winrepo.py index 7e1d5563d6..72ddb35c0d 100644 --- a/tests/integration/runners/test_winrepo.py +++ b/tests/integration/runners/test_winrepo.py @@ -8,9 +8,9 @@ import tempfile # Import Salt Testing Libs from salt.runners import winrepo -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../../') # Import Salt Libs diff --git a/tests/integration/sdb/test_env.py b/tests/integration/sdb/test_env.py index cbecfab0bc..65f2178c2f 100644 --- a/tests/integration/sdb/test_env.py +++ b/tests/integration/sdb/test_env.py @@ -7,7 +7,7 @@ import os import textwrap # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') import integration diff --git a/tests/integration/shell/test_arguments.py b/tests/integration/shell/test_arguments.py index c3e66a2c44..f479e8d5fe 100644 --- a/tests/integration/shell/test_arguments.py +++ b/tests/integration/shell/test_arguments.py @@ -7,7 +7,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, requires_salt_modules +from tests.support.helpers import ensure_in_syspath, requires_salt_modules ensure_in_syspath('../../') diff --git a/tests/integration/shell/test_auth.py b/tests/integration/shell/test_auth.py index 73710200ff..b39b9db471 100644 --- a/tests/integration/shell/test_auth.py +++ b/tests/integration/shell/test_auth.py @@ -12,8 +12,8 @@ import grp import random # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( ensure_in_syspath, destructiveTest) ensure_in_syspath('../../') diff --git a/tests/integration/shell/test_call.py b/tests/integration/shell/test_call.py index 7479916cd6..572b8d6da0 100644 --- a/tests/integration/shell/test_call.py +++ b/tests/integration/shell/test_call.py @@ -19,9 +19,9 @@ from datetime import datetime import logging # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.helpers import ( destructiveTest ) ensure_in_syspath('../../') @@ -45,7 +45,7 @@ _PKG_TARGETS = { _PKGS_INSTALLED = set() -class CallTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixIn): +class CallTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixin): _call_binary_ = 'salt-call' diff --git a/tests/integration/shell/test_cloud.py b/tests/integration/shell/test_cloud.py index d3e553cba7..b151323f62 100644 --- a/tests/integration/shell/test_cloud.py +++ b/tests/integration/shell/test_cloud.py @@ -12,8 +12,8 @@ from __future__ import absolute_import, print_function # Import salt testing libs -from salttesting.unit import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') # Import salt libs @@ -32,7 +32,7 @@ except ImportError: @skipIf(HAS_LIBCLOUD is False, 'salt-cloud requires >= libcloud 0.11.4') class SaltCloudCliTest(integration.ShellCase, - integration.ShellCaseCommonTestsMixIn): + integration.ShellCaseCommonTestsMixin): _call_binary_ = 'salt-cloud' diff --git a/tests/integration/shell/test_cp.py b/tests/integration/shell/test_cp.py index 441116ca71..1e5498435b 100644 --- a/tests/integration/shell/test_cp.py +++ b/tests/integration/shell/test_cp.py @@ -15,7 +15,7 @@ import pipes import shutil # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs @@ -26,7 +26,7 @@ import salt.utils import salt.ext.six as six -class CopyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn): +class CopyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixin): _call_binary_ = 'salt-cp' diff --git a/tests/integration/shell/test_enabled.py b/tests/integration/shell/test_enabled.py index f96e41b051..cbbf792819 100644 --- a/tests/integration/shell/test_enabled.py +++ b/tests/integration/shell/test_enabled.py @@ -6,7 +6,7 @@ import os import textwrap # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/shell/test_key.py b/tests/integration/shell/test_key.py index aeba671829..2392e1adc4 100644 --- a/tests/integration/shell/test_key.py +++ b/tests/integration/shell/test_key.py @@ -8,7 +8,7 @@ import shutil import tempfile # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs @@ -20,7 +20,7 @@ USERA_PWD = 'saltdev' HASHED_USERA_PWD = '$6$SALTsalt$ZZFD90fKFWq8AGmmX0L3uBtS9fXL62SrTk5zcnQ6EkD6zoiM3kB88G1Zvs0xm/gZ7WXJRs5nsTBybUvGSqZkT.' -class KeyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn): +class KeyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixin): ''' Test salt-key script ''' diff --git a/tests/integration/shell/test_master.py b/tests/integration/shell/test_master.py index f7fd41d944..5d17d655e8 100644 --- a/tests/integration/shell/test_master.py +++ b/tests/integration/shell/test_master.py @@ -15,7 +15,7 @@ import signal import shutil # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs @@ -25,7 +25,7 @@ from integration.utils import testprogram import salt.utils -class MasterTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixIn): +class MasterTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixin): _call_binary_ = 'salt-master' diff --git a/tests/integration/shell/test_master_tops.py b/tests/integration/shell/test_master_tops.py index 0c310ee13e..217eab23cd 100644 --- a/tests/integration/shell/test_master_tops.py +++ b/tests/integration/shell/test_master_tops.py @@ -8,7 +8,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/shell/test_matcher.py b/tests/integration/shell/test_matcher.py index 9fb3496de6..50831d024e 100644 --- a/tests/integration/shell/test_matcher.py +++ b/tests/integration/shell/test_matcher.py @@ -8,7 +8,7 @@ import shutil import time # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs @@ -20,7 +20,7 @@ def minion_in_returns(minion, lines): return bool([True for line in lines if line == '{0}:'.format(minion)]) -class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn): +class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixin): ''' Test salt matchers ''' diff --git a/tests/integration/shell/test_minion.py b/tests/integration/shell/test_minion.py index 1223d51478..7f1f88b8b1 100644 --- a/tests/integration/shell/test_minion.py +++ b/tests/integration/shell/test_minion.py @@ -19,8 +19,8 @@ import shutil import logging # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') @@ -36,7 +36,7 @@ log = logging.getLogger(__name__) DEBUG = True -class MinionTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixIn): +class MinionTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixin): ''' Various integration tests for the salt-minion executable. ''' diff --git a/tests/integration/shell/test_proxy.py b/tests/integration/shell/test_proxy.py index a7bc047315..91b1fff34c 100644 --- a/tests/integration/shell/test_proxy.py +++ b/tests/integration/shell/test_proxy.py @@ -11,7 +11,7 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/shell/test_runner.py b/tests/integration/shell/test_runner.py index b2dc23f168..f9906f1d40 100644 --- a/tests/integration/shell/test_runner.py +++ b/tests/integration/shell/test_runner.py @@ -11,8 +11,8 @@ import yaml import shutil # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs @@ -25,7 +25,7 @@ USERA_PWD = 'saltdev' HASHED_USERA_PWD = '$6$SALTsalt$ZZFD90fKFWq8AGmmX0L3uBtS9fXL62SrTk5zcnQ6EkD6zoiM3kB88G1Zvs0xm/gZ7WXJRs5nsTBybUvGSqZkT.' -class RunTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixIn): +class RunTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixin): ''' Test the salt-run command ''' diff --git a/tests/integration/shell/test_saltcli.py b/tests/integration/shell/test_saltcli.py index e867fd0faf..2fbef8b3d4 100644 --- a/tests/integration/shell/test_saltcli.py +++ b/tests/integration/shell/test_saltcli.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/shell/test_syndic.py b/tests/integration/shell/test_syndic.py index 5b0c4937cd..453677a83d 100644 --- a/tests/integration/shell/test_syndic.py +++ b/tests/integration/shell/test_syndic.py @@ -16,7 +16,7 @@ import shutil import logging # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs @@ -28,7 +28,7 @@ import salt.utils log = logging.getLogger(__name__) -class SyndicTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixIn): +class SyndicTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixin): ''' Test the salt-syndic command ''' diff --git a/tests/integration/ssh/test_deploy.py b/tests/integration/ssh/test_deploy.py index 346bbfe3a2..f2ac34e659 100644 --- a/tests/integration/ssh/test_deploy.py +++ b/tests/integration/ssh/test_deploy.py @@ -6,8 +6,8 @@ salt-ssh testing from __future__ import absolute_import # Import salttesting libs -from salttesting.unit import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/integration/states/test_alternatives.py b/tests/integration/states/test_alternatives.py index 0eb7f33c48..e00363d0a6 100644 --- a/tests/integration/states/test_alternatives.py +++ b/tests/integration/states/test_alternatives.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import destructiveTest, ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_archive.py b/tests/integration/states/test_archive.py index 9a86c768f0..5dd59f4b29 100644 --- a/tests/integration/states/test_archive.py +++ b/tests/integration/states/test_archive.py @@ -14,8 +14,8 @@ import tornado.ioloop import tornado.web # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_boto_sns.py b/tests/integration/states/test_boto_sns.py index 2f4feafee2..9ab2b343b7 100644 --- a/tests/integration/states/test_boto_sns.py +++ b/tests/integration/states/test_boto_sns.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import re # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/integration/states/test_bower.py b/tests/integration/states/test_bower.py index 8430d7bde6..a8b8142b2c 100644 --- a/tests/integration/states/test_bower.py +++ b/tests/integration/states/test_bower.py @@ -7,8 +7,8 @@ from __future__ import absolute_import import json # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import destructiveTest, ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_cmd.py b/tests/integration/states/test_cmd.py index 7e8f268d07..d6c2130657 100644 --- a/tests/integration/states/test_cmd.py +++ b/tests/integration/states/test_cmd.py @@ -10,7 +10,7 @@ import textwrap import tempfile # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_compiler.py b/tests/integration/states/test_compiler.py index af0083f7ec..fe9047b228 100644 --- a/tests/integration/states/test_compiler.py +++ b/tests/integration/states/test_compiler.py @@ -7,7 +7,7 @@ tests for host state from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index a70c50037c..6b856ccafd 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -19,8 +19,8 @@ import textwrap import filecmp # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, with_system_user_and_group diff --git a/tests/integration/states/test_git.py b/tests/integration/states/test_git.py index 02c2fb5fba..7de11b629e 100644 --- a/tests/integration/states/test_git.py +++ b/tests/integration/states/test_git.py @@ -14,7 +14,7 @@ import subprocess import tempfile # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath, skip_if_binaries_missing +from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_handle_error.py b/tests/integration/states/test_handle_error.py index a845e2f3c1..713fdb2ddd 100644 --- a/tests/integration/states/test_handle_error.py +++ b/tests/integration/states/test_handle_error.py @@ -7,7 +7,7 @@ tests for host state from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_handle_iorder.py b/tests/integration/states/test_handle_iorder.py index 7ef1864cdd..8abd515b9e 100644 --- a/tests/integration/states/test_handle_iorder.py +++ b/tests/integration/states/test_handle_iorder.py @@ -7,7 +7,7 @@ tests for host state from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_host.py b/tests/integration/states/test_host.py index 8c399640a0..9196d63c98 100644 --- a/tests/integration/states/test_host.py +++ b/tests/integration/states/test_host.py @@ -9,7 +9,7 @@ import os import shutil # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_keystone.py b/tests/integration/states/test_keystone.py index 98de22a2d9..73a2fe7efa 100644 --- a/tests/integration/states/test_keystone.py +++ b/tests/integration/states/test_keystone.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath ) diff --git a/tests/integration/states/test_match.py b/tests/integration/states/test_match.py index a1efba98da..4909a6dce3 100644 --- a/tests/integration/states/test_match.py +++ b/tests/integration/states/test_match.py @@ -12,8 +12,8 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_mysql.py b/tests/integration/states/test_mysql.py index e8fb2be36b..7b0198e9be 100644 --- a/tests/integration/states/test_mysql.py +++ b/tests/integration/states/test_mysql.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath ) diff --git a/tests/integration/states/test_network.py b/tests/integration/states/test_network.py index 1d61a1bc3f..7ed7d43b5d 100644 --- a/tests/integration/states/test_network.py +++ b/tests/integration/states/test_network.py @@ -12,7 +12,7 @@ from __future__ import absolute_import import integration # Salttesting libs -from salttesting.helpers import destructiveTest, ensure_in_syspath +from tests.support.helpers import destructiveTest, ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/integration/states/test_npm.py b/tests/integration/states/test_npm.py index 250e3bf178..289e5f58ba 100644 --- a/tests/integration/states/test_npm.py +++ b/tests/integration/states/test_npm.py @@ -8,8 +8,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath, requires_network +from tests.support.unit import skipIf +from tests.support.helpers import destructiveTest, ensure_in_syspath, requires_network ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_pip.py b/tests/integration/states/test_pip.py index 00cbc1f492..f94081e414 100644 --- a/tests/integration/states/test_pip.py +++ b/tests/integration/states/test_pip.py @@ -16,8 +16,8 @@ import glob import shutil # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, requires_system_grains, with_system_user diff --git a/tests/integration/states/test_pkg.py b/tests/integration/states/test_pkg.py index e084c57f79..098b67b592 100644 --- a/tests/integration/states/test_pkg.py +++ b/tests/integration/states/test_pkg.py @@ -10,8 +10,8 @@ import os import time # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains, diff --git a/tests/integration/states/test_pkgrepo.py b/tests/integration/states/test_pkgrepo.py index a7f52c3ce4..f7dc893288 100644 --- a/tests/integration/states/test_pkgrepo.py +++ b/tests/integration/states/test_pkgrepo.py @@ -7,8 +7,8 @@ tests for pkgrepo states from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/states/test_rabbitmq_user.py b/tests/integration/states/test_rabbitmq_user.py index 3c65f1697c..bf67efdbd6 100644 --- a/tests/integration/states/test_rabbitmq_user.py +++ b/tests/integration/states/test_rabbitmq_user.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_rabbitmq_vhost.py b/tests/integration/states/test_rabbitmq_vhost.py index 552b314bfc..9c54899bb3 100644 --- a/tests/integration/states/test_rabbitmq_vhost.py +++ b/tests/integration/states/test_rabbitmq_vhost.py @@ -8,7 +8,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_renderers.py b/tests/integration/states/test_renderers.py index 61ea0ffb72..fcf89808a9 100644 --- a/tests/integration/states/test_renderers.py +++ b/tests/integration/states/test_renderers.py @@ -7,7 +7,7 @@ Integration tests for renderer functions from __future__ import absolute_import # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt Libs diff --git a/tests/integration/states/test_service.py b/tests/integration/states/test_service.py index 0f62c371e9..3cddeed42b 100644 --- a/tests/integration/states/test_service.py +++ b/tests/integration/states/test_service.py @@ -6,8 +6,8 @@ Tests for the service state from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( ensure_in_syspath, destructiveTest ) diff --git a/tests/integration/states/test_ssh.py b/tests/integration/states/test_ssh.py index 81e8e30657..36c357bd21 100644 --- a/tests/integration/states/test_ssh.py +++ b/tests/integration/states/test_ssh.py @@ -9,8 +9,8 @@ import os import shutil # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, with_system_user, diff --git a/tests/integration/states/test_supervisord.py b/tests/integration/states/test_supervisord.py index d49b662fe8..d48c943f45 100644 --- a/tests/integration/states/test_supervisord.py +++ b/tests/integration/states/test_supervisord.py @@ -11,8 +11,8 @@ import time import subprocess # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_svn.py b/tests/integration/states/test_svn.py index 600599fc7a..4fb9d28ce6 100644 --- a/tests/integration/states/test_svn.py +++ b/tests/integration/states/test_svn.py @@ -11,7 +11,7 @@ import shutil import socket # Import Salt Testing libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/states/test_user.py b/tests/integration/states/test_user.py index 22ed655a00..28eca85c6a 100644 --- a/tests/integration/states/test_user.py +++ b/tests/integration/states/test_user.py @@ -15,8 +15,8 @@ from random import randint import grp # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( destructiveTest, ensure_in_syspath, requires_system_grains diff --git a/tests/integration/states/test_virtualenv.py b/tests/integration/states/test_virtualenv.py index 4f46353da4..186b554c0b 100644 --- a/tests/integration/states/test_virtualenv.py +++ b/tests/integration/states/test_virtualenv.py @@ -13,8 +13,8 @@ import os import shutil # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import destructiveTest, ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/integration/utils/test_reactor.py b/tests/integration/utils/test_reactor.py index 2b2e2dfe39..ab3576055d 100644 --- a/tests/integration/utils/test_reactor.py +++ b/tests/integration/utils/test_reactor.py @@ -13,7 +13,7 @@ import integration from salt.utils.process import clean_proc from salt.utils import event -from salttesting.mock import patch +from tests.support.mock import patch @contextmanager diff --git a/tests/integration/utils/testprogram.py b/tests/integration/utils/testprogram.py index 4fb8799a6d..48b4927750 100644 --- a/tests/integration/utils/testprogram.py +++ b/tests/integration/utils/testprogram.py @@ -26,7 +26,7 @@ import salt.utils.psutil_compat as psutils import salt.defaults.exitcodes as exitcodes import salt.ext.six as six -from salttesting import TestCase +from tests.support.unit import TestCase import integration diff --git a/tests/integration/wheel/test_client.py b/tests/integration/wheel/test_client.py index a59c262035..7de272fa77 100644 --- a/tests/integration/wheel/test_client.py +++ b/tests/integration/wheel/test_client.py @@ -5,7 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs import integration -from salttesting import skipIf +from tests.support.unit import skipIf # Import Salt libs import salt.auth diff --git a/tests/runtests.py b/tests/runtests.py index 4e3f92226c..ddf8104941 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -8,7 +8,6 @@ Discover all instances of unittest.TestCase in this directory. # Import python libs from __future__ import absolute_import, print_function import os -import imp import sys import time @@ -16,7 +15,18 @@ TESTS_DIR = os.path.dirname(os.path.normpath(os.path.abspath(__file__))) if os.name == 'nt': TESTS_DIR = TESTS_DIR.replace('\\', '\\\\') CODE_DIR = os.path.dirname(TESTS_DIR) -os.chdir(CODE_DIR) + +# Let's inject CODE_DIR so salt is importable if not there already +if '' in sys.path: + sys.path.remove('') +if TESTS_DIR in sys.path: + sys.path.remove(TESTS_DIR) +if CODE_DIR in sys.path and sys.path[0] != CODE_DIR: + sys.path.remove(CODE_DIR) +if CODE_DIR not in sys.path: + sys.path.insert(0, CODE_DIR) +if TESTS_DIR not in sys.path: + sys.path.insert(1, TESTS_DIR) try: import tests @@ -30,19 +40,6 @@ try: except ImportError: pass -#tests = imp.load_source('tests', os.path.join(TESTS_DIR, '__init__.py')) -#salt = imp.load_source('salt', os.path.join(CODE_DIR, 'salt', '__init__.py')) - -# Let's inject CODE_DIR so salt is importable if not there already -if TESTS_DIR in sys.path: - sys.path.remove(TESTS_DIR) -if CODE_DIR in sys.path and sys.path[0] != CODE_DIR: - sys.path.remove(CODE_DIR) -if CODE_DIR not in sys.path: - sys.path.insert(0, CODE_DIR) -if TESTS_DIR not in sys.path: - sys.path.insert(1, TESTS_DIR) - # Import salt libs try: from tests.support.paths import TMP, SYS_TMP_DIR, INTEGRATION_TEST_DIR @@ -53,9 +50,9 @@ except ImportError as exc: print('Found tests module not from salt in {}'.format(tests.__file__)) except ImportError: print('Unable to import salt test module') - print(os.environ.get('PYTHONPATH')) + print('PYTHONPATH:', os.environ.get('PYTHONPATH')) pass - print('Current sys.paths') + print('Current sys.path:') import pprint pprint.pprint(sys.path) raise exc @@ -67,8 +64,8 @@ if not salt.utils.is_windows(): import resource # Import Salt Testing libs -from salttesting.parser import PNUM, print_header -from salttesting.parser.cover import SaltCoverageTestingParser +from tests.support.parser import PNUM, print_header +from tests.support.parser.cover import SaltCoverageTestingParser # Import test support libs from tests.support.processes import collect_child_processes, terminate_process diff --git a/tests/support/case.py b/tests/support/case.py new file mode 100644 index 0000000000..94c3a04c47 --- /dev/null +++ b/tests/support/case.py @@ -0,0 +1,567 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + + + ==================================== + Custom Salt TestCase Implementations + ==================================== + + Custom reusable :class:`TestCase` + implementations. +''' +# pylint: disable=repr-flag-used-in-string + +# Import python libs +from __future__ import absolute_import +import os +import re +import sys +import json +import time +import stat +import errno +import signal +import logging +import tempfile +import subprocess +from datetime import datetime, timedelta + +# Import salt testing libs +from tests.support.unit import TestCase +from tests.support.helpers import RedirectStdStreams +from tests.support.runtests import RUNTIME_VARS +from tests.support.mixins import AdaptedConfigurationTestCaseMixin, SaltClientTestCaseMixin + +# Try to import salt: needed for __salt_system_encoding__ reference +try: + current_module_names = sys.modules.keys() + import salt # pylint: disable=unused-import + + for name in sys.modules.keys(): + if name not in current_module_names: + del sys.modules[name] +except ImportError: + pass + +STATE_FUNCTION_RUNNING_RE = re.compile( + r'''The function (?:"|')(?P.*)(?:"|') is running as PID ''' + r'(?P[\d]+) and was started at (?P.*) with jid (?P[\d]+)' +) +SCRIPT_TEMPLATES = { + 'salt': [ + 'from salt.scripts import salt_main\n', + 'if __name__ == \'__main__\':' + ' salt_main()' + ], + 'salt-api': [ + 'import salt.cli\n', + 'def main():', + ' sapi = salt.cli.SaltAPI()', + ' sapi.run()\n', + 'if __name__ == \'__main__\':', + ' main()' + ], + 'common': [ + 'from salt.scripts import salt_{0}\n', + 'if __name__ == \'__main__\':', + ' salt_{0}()' + ] +} + +log = logging.getLogger(__name__) + + +class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin): + ''' + Execute a test for a shell command + ''' + + def get_script_path(self, script_name): + ''' + Return the path to a testing runtime script + ''' + if not os.path.isdir(RUNTIME_VARS.TMP_SCRIPT_DIR): + os.makedirs(RUNTIME_VARS.TMP_SCRIPT_DIR) + + script_path = os.path.join(RUNTIME_VARS.TMP_SCRIPT_DIR, script_name) + if not os.path.isfile(script_path): + log.debug('Generating {0}'.format(script_path)) + + # Late import + import salt.utils + + with salt.utils.fopen(script_path, 'w') as sfh: + script_template = SCRIPT_TEMPLATES.get(script_name, None) + if script_template is None: + script_template = SCRIPT_TEMPLATES.get('common', None) + if script_template is None: + raise RuntimeError( + '{0} does not know how to handle the {1} script'.format( + self.__class__.__name__, + script_name + ) + ) + sfh.write( + '#!{0}\n'.format(sys.executable) + + '\n'.join(script_template).format(script_name.replace('salt-', '')) + ) + st = os.stat(script_path) + os.chmod(script_path, st.st_mode | stat.S_IEXEC) + + return script_path + + def run_salt(self, arg_str, with_retcode=False, catch_stderr=False, timeout=15): + r''' + Run the ``salt`` CLI tool with the provided arguments + + .. code-block:: python + + class MatchTest(ShellTestCase): + def test_list(self): + """ + test salt -L matcher + """ + data = self.run_salt('-L minion test.ping') + data = '\n'.join(data) + self.assertIn('minion', data) + ''' + arg_str = '-c {0} {1}'.format(self.get_config_dir(), arg_str) + return self.run_script('salt', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) + + def run_ssh(self, arg_str, with_retcode=False, timeout=25, catch_stderr=False): + ''' + Execute salt-ssh + ''' + arg_str = '-c {0} -i --priv {1} --roster-file {2} localhost {3} --out=json'.format( + self.get_config_dir(), + os.path.join(RUNTIME_VARS.TMP_CONF_DIR, 'key_test'), + os.path.join(RUNTIME_VARS.TMP_CONF_DIR, 'roster'), + arg_str + ) + return self.run_script('salt-ssh', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr, raw=True) + + def run_run(self, arg_str, with_retcode=False, catch_stderr=False, async=False, timeout=60, config_dir=None): + ''' + Execute salt-run + ''' + arg_str = '-c {0}{async_flag} -t {timeout} {1}'.format(config_dir or self.get_config_dir(), + arg_str, + timeout=timeout, + async_flag=' --async' if async else '') + return self.run_script('salt-run', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) + + def run_run_plus(self, fun, *arg, **kwargs): + ''' + Execute the runner function and return the return data and output in a dict + ''' + ret = {'fun': fun} + + # Late import + import salt.config + import salt.output + import salt.runner + from salt.ext.six.moves import cStringIO + + opts = salt.config.master_config( + self.get_config_file_path('master') + ) + + opts_arg = list(arg) + if kwargs: + opts_arg.append({'__kwarg__': True}) + opts_arg[-1].update(kwargs) + + opts.update({'doc': False, 'fun': fun, 'arg': opts_arg}) + with RedirectStdStreams(): + runner = salt.runner.Runner(opts) + ret['return'] = runner.run() + try: + ret['jid'] = runner.jid + except AttributeError: + ret['jid'] = None + + # Compile output + # TODO: Support outputters other than nested + opts['color'] = False + opts['output_file'] = cStringIO() + try: + salt.output.display_output(ret['return'], opts=opts) + ret['out'] = opts['output_file'].getvalue() + finally: + opts['output_file'].close() + + return ret + + def run_key(self, arg_str, catch_stderr=False, with_retcode=False): + ''' + Execute salt-key + ''' + arg_str = '-c {0} {1}'.format(self.get_config_dir(), arg_str) + return self.run_script( + 'salt-key', + arg_str, + catch_stderr=catch_stderr, + with_retcode=with_retcode + ) + + def run_cp(self, arg_str, with_retcode=False, catch_stderr=False): + ''' + Execute salt-cp + ''' + arg_str = '--config-dir {0} {1}'.format(self.get_config_dir(), arg_str) + return self.run_script('salt-cp', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) + + def run_call(self, arg_str, with_retcode=False, catch_stderr=False): + arg_str = '--config-dir {0} {1}'.format(self.get_config_dir(), arg_str) + return self.run_script('salt-call', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) + + def run_cloud(self, arg_str, catch_stderr=False, timeout=None): + ''' + Execute salt-cloud + ''' + arg_str = '-c {0} {1}'.format(self.get_config_dir(), arg_str) + return self.run_script('salt-cloud', arg_str, catch_stderr, timeout) + + def run_script(self, + script, + arg_str, + catch_stderr=False, + with_retcode=False, + # FIXME A timeout of zero or disabling timeouts may not return results! + timeout=15, + raw=False): + ''' + Execute a script with the given argument string + ''' + script_path = self.get_script_path(script) + if not os.path.isfile(script_path): + return False + + python_path = os.environ.get('PYTHONPATH', None) + + if sys.platform.startswith('win'): + cmd = 'set PYTHONPATH=' + else: + cmd = 'PYTHONPATH=' + + if python_path is not None: + cmd += '{0}:'.format(python_path) + + if sys.version_info[0] < 3: + cmd += '{0} '.format(':'.join(sys.path[1:])) + else: + cmd += '{0} '.format(':'.join(sys.path[0:])) + cmd += 'python{0}.{1} '.format(*sys.version_info) + cmd += '{0} '.format(script_path) + cmd += '{0} '.format(arg_str) + + tmp_file = tempfile.SpooledTemporaryFile() + + popen_kwargs = { + 'shell': True, + 'stdout': tmp_file, + 'universal_newlines': True + } + + if catch_stderr is True: + popen_kwargs['stderr'] = subprocess.PIPE + + if not sys.platform.lower().startswith('win'): + popen_kwargs['close_fds'] = True + + def detach_from_parent_group(): + # detach from parent group (no more inherited signals!) + os.setpgrp() + + popen_kwargs['preexec_fn'] = detach_from_parent_group + + elif sys.platform.lower().startswith('win') and timeout is not None: + raise RuntimeError('Timeout is not supported under windows') + + process = subprocess.Popen(cmd, **popen_kwargs) + + if timeout is not None: + stop_at = datetime.now() + timedelta(seconds=timeout) + term_sent = False + while True: + process.poll() + time.sleep(0.1) + if datetime.now() > stop_at: + if term_sent is False: + # Kill the process group since sending the term signal + # would only terminate the shell, not the command + # executed in the shell + os.killpg(os.getpgid(process.pid), signal.SIGINT) + term_sent = True + continue + + try: + # As a last resort, kill the process group + os.killpg(os.getpgid(process.pid), signal.SIGKILL) + except OSError as exc: + if exc.errno != 3: + raise + + out = [ + 'Process took more than {0} seconds to complete. ' + 'Process Killed!'.format(timeout) + ] + if catch_stderr: + err = ['Process killed, unable to catch stderr output'] + if with_retcode: + return out, err, process.returncode + else: + return out, err + if with_retcode: + return out, process.returncode + else: + return out + + if process.returncode is not None: + break + tmp_file.seek(0) + + if sys.version_info >= (3,): + try: + out = tmp_file.read().decode(__salt_system_encoding__) + except (NameError, UnicodeDecodeError): + # Let's cross our fingers and hope for the best + out = tmp_file.read().decode('utf-8') + else: + out = tmp_file.read() + + if catch_stderr: + if sys.version_info < (2, 7): + # On python 2.6, the subprocess'es communicate() method uses + # select which, is limited by the OS to 1024 file descriptors + # We need more available descriptors to run the tests which + # need the stderr output. + # So instead of .communicate() we wait for the process to + # finish, but, as the python docs state "This will deadlock + # when using stdout=PIPE and/or stderr=PIPE and the child + # process generates enough output to a pipe such that it + # blocks waiting for the OS pipe buffer to accept more data. + # Use communicate() to avoid that." <- a catch, catch situation + # + # Use this work around were it's needed only, python 2.6 + process.wait() + err = process.stderr.read() + else: + _, err = process.communicate() + # Force closing stderr/stdout to release file descriptors + if process.stdout is not None: + process.stdout.close() + if process.stderr is not None: + process.stderr.close() + # pylint: disable=maybe-no-member + try: + if with_retcode: + if out is not None and err is not None: + if not raw: + return out.splitlines(), err.splitlines(), process.returncode + else: + return out, err, process.returncode + return out.splitlines(), [], process.returncode + else: + if out is not None and err is not None: + if not raw: + return out.splitlines(), err.splitlines() + else: + return out, err + if not raw: + return out.splitlines(), [] + else: + return out, [] + finally: + try: + process.terminate() + except OSError as err: + # process already terminated + pass + # pylint: enable=maybe-no-member + + # TODO Remove this? + process.communicate() + if process.stdout is not None: + process.stdout.close() + + try: + if with_retcode: + if not raw: + return out.splitlines(), process.returncode + else: + return out, process.returncode + else: + if not raw: + return out.splitlines() + else: + return out + finally: + try: + if os.path.exists(tmp_file.name): + if isinstance(tmp_file.name, str): + # tmp_file.name is an int when using SpooledTemporaryFiles + # int types cannot be used with os.remove() in Python 3 + os.remove(tmp_file.name) + else: + # Clean up file handles + tmp_file.close() + process.terminate() + except OSError as err: + # process already terminated + pass + + +class ModuleCase(TestCase, SaltClientTestCaseMixin): + ''' + Execute a module function + ''' + + def minion_run(self, _function, *args, **kw): + ''' + Run a single salt function on the 'minion' target and condition + the return down to match the behavior of the raw function call + ''' + return self.run_function(_function, args, **kw) + + def run_function(self, function, arg=(), minion_tgt='minion', timeout=25, + **kwargs): + ''' + Run a single salt function and condition the return down to match the + behavior of the raw function call + ''' + know_to_return_none = ( + 'file.chown', 'file.chgrp', 'ssh.recv_known_host' + ) + orig = self.client.cmd( + minion_tgt, function, arg, timeout=timeout, kwarg=kwargs + ) + + if minion_tgt not in orig: + self.skipTest( + 'WARNING(SHOULD NOT HAPPEN #1935): Failed to get a reply ' + 'from the minion \'{0}\'. Command output: {1}'.format( + minion_tgt, orig + ) + ) + elif orig[minion_tgt] is None and function not in know_to_return_none: + self.skipTest( + 'WARNING(SHOULD NOT HAPPEN #1935): Failed to get \'{0}\' from ' + 'the minion \'{1}\'. Command output: {2}'.format( + function, minion_tgt, orig + ) + ) + + # Try to match stalled state functions + orig[minion_tgt] = self._check_state_return( + orig[minion_tgt], func=function + ) + + return orig[minion_tgt] + + def run_state(self, function, **kwargs): + ''' + Run the state.single command and return the state return structure + ''' + ret = self.run_function('state.single', [function], **kwargs) + return self._check_state_return(ret) + + def _check_state_return(self, ret, func='state.single'): + if isinstance(ret, dict): + # This is the supposed return format for state calls + return ret + + # Late import + import salt._compat + + if isinstance(ret, list): + jids = [] + # These are usually errors + for item in ret[:]: + if not isinstance(item, salt._compat.string_types): + # We don't know how to handle this + continue + match = STATE_FUNCTION_RUNNING_RE.match(item) + if not match: + # We don't know how to handle this + continue + jid = match.group('jid') + if jid in jids: + continue + + jids.append(jid) + + job_data = self.run_function( + 'saltutil.find_job', [jid] + ) + job_kill = self.run_function('saltutil.kill_job', [jid]) + msg = ( + 'A running state.single was found causing a state lock. ' + 'Job details: {0!r} Killing Job Returned: {1!r}'.format( + job_data, job_kill + ) + ) + ret.append('[TEST SUITE ENFORCED]{0}' + '[/TEST SUITE ENFORCED]'.format(msg)) + return ret + + +class SyndicCase(TestCase, SaltClientTestCaseMixin): + ''' + Execute a syndic based execution test + ''' + _salt_client_config_file_name_ = 'syndic_master' + + def run_function(self, function, arg=()): + ''' + Run a single salt function and condition the return down to match the + behavior of the raw function call + ''' + orig = self.client.cmd('minion', function, arg, timeout=25) + if 'minion' not in orig: + self.skipTest( + 'WARNING(SHOULD NOT HAPPEN #1935): Failed to get a reply ' + 'from the minion. Command output: {0}'.format(orig) + ) + return orig['minion'] + + +class SSHCase(ShellTestCase): + ''' + Execute a command via salt-ssh + ''' + def _arg_str(self, function, arg): + return '{0} {1}'.format(function, ' '.join(arg)) + + def run_function(self, function, arg=(), timeout=25, **kwargs): + ret = self.run_ssh(self._arg_str(function, arg)) + try: + return json.loads(ret)['localhost'] + except Exception: + return ret + + +class ClientCase(AdaptedConfigurationTestCaseMixin, TestCase): + ''' + A base class containing relevant options for starting the various Salt + Python API entrypoints + ''' + def get_opts(self): + # Late import + import salt.config + + return salt.config.client_config(self.get_config_file_path('master')) + + def mkdir_p(self, path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise + +# ----- Backwards Compatible Imports --------------------------------------------------------------------------------> +from tests.support.mixins import ShellCaseCommonTestsMixin # pylint: disable=unused-import +# <---- Backwards Compatible Imports --------------------------------------------------------------------------------- diff --git a/tests/support/cherrypy_testclasses.py b/tests/support/cherrypy_testclasses.py index 83fc23b0a8..2b89c13307 100644 --- a/tests/support/cherrypy_testclasses.py +++ b/tests/support/cherrypy_testclasses.py @@ -17,10 +17,7 @@ if HAS_CHERRYPY: from tests.support.cptestcase import BaseCherryPyTestCase from salt.netapi.rest_cherrypy import app else: - from salttesting.unit import ( - TestCase, - skipIf, - ) + from tests.support.unit import TestCase, skipIf @skipIf(HAS_CHERRYPY is False, 'The CherryPy python package needs to be installed') class BaseCherryPyTestCase(TestCase): diff --git a/tests/support/cptestcase.py b/tests/support/cptestcase.py index cb72f983c6..59db85420f 100644 --- a/tests/support/cptestcase.py +++ b/tests/support/cptestcase.py @@ -32,7 +32,7 @@ from __future__ import absolute_import, print_function # Import Salt Testing libs -from salttesting.case import TestCase +from tests.support.case import TestCase # Import 3rd-party libs # pylint: disable=import-error diff --git a/tests/support/ext/__init__.py b/tests/support/ext/__init__.py new file mode 100644 index 0000000000..40a96afc6f --- /dev/null +++ b/tests/support/ext/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/tests/support/ext/console.py b/tests/support/ext/console.py new file mode 100644 index 0000000000..45a191158d --- /dev/null +++ b/tests/support/ext/console.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +# vim: sw=4 ts=4 fenc=utf-8 +''' +getTerminalSize() + - get width and height of console + - works on linux,os x,windows,cygwin(windows) + - taken from http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python +''' + +# Import python libs +from __future__ import absolute_import, print_function +import os +import platform +import struct +import ctypes +import subprocess +import fcntl +import termios + +__all__ = ['getTerminalSize'] + + +def getTerminalSize(): + current_os = platform.system() + tuple_xy = None + if current_os == 'Windows': + tuple_xy = _getTerminalSize_windows() + if tuple_xy is None: + tuple_xy = _getTerminalSize_tput() + # needed for window's python in cygwin's xterm! + if current_os == 'Linux' or current_os == 'Darwin' or \ + current_os.startswith('CYGWIN'): + tuple_xy = _getTerminalSize_linux() + if tuple_xy is None: + tuple_xy = (80, 25) # default value + return tuple_xy + + +def _getTerminalSize_windows(): + res = None + try: + # stdin handle is -10 + # stdout handle is -11 + # stderr handle is -12 + + h = ctypes.windll.kernel32.GetStdHandle(-12) + csbi = ctypes.create_string_buffer(22) + res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(h, csbi) + except Exception: + return None + if res: + (bufx, bufy, curx, cury, wattr, + left, top, right, bottom, maxx, maxy) = struct.unpack( + 'hhhhHhhhhhh', csbi.raw) + sizex = right - left + 1 + sizey = bottom - top + 1 + return sizex, sizey + else: + return None + + +def _getTerminalSize_tput(): + # get terminal width + # src: http://stackoverflow.com/questions/263890/how-do-i-find-the-width-height-of-a-terminal-window + try: + proc = subprocess.Popen( + ['tput', 'cols'], stdin=subprocess.PIPE, stdout=subprocess.PIPE + ) + output = proc.communicate(input=None) + cols = int(output[0]) + proc = subprocess.Popen( + ['tput', 'lines'], stdin=subprocess.PIPE, stdout=subprocess.PIPE + ) + output = proc.communicate(input=None) + rows = int(output[0]) + return (cols, rows) + except Exception: + return None + + +def _getTerminalSize_linux(): + def ioctl_GWINSZ(fd): + try: + cr = struct.unpack( + 'hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234') + ) + except Exception: + return None + return cr + cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) + if not cr: + try: + fd = os.open(os.ctermid(), os.O_RDONLY) + cr = ioctl_GWINSZ(fd) + os.close(fd) + except Exception: + pass + if not cr: + try: + cr = (os.environ['LINES'], os.environ['COLUMNS']) + except Exception: + return None + return int(cr[1]), int(cr[0]) + + +if __name__ == '__main__': + sizex, sizey = getTerminalSize() + print('width = {0} height = {1}'.format(sizex, sizey)) diff --git a/tests/support/helpers.py b/tests/support/helpers.py index 68c3ae1d49..a67973f471 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -1,29 +1,113 @@ # -*- coding: utf-8 -*- ''' - :copyright: © 2017 by the SaltStack Team, see AUTHORS for more details. + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + :copyright: © 2013-2017 by the SaltStack Team, see AUTHORS for more details. :license: Apache 2.0, see LICENSE for more details. tests.support.helpers ~~~~~~~~~~~~~~~~~~~~~ - Test support helpers + Unit testing helpers ''' +# pylint: disable=repr-flag-used-in-string -# Import python libs +# Import Python libs from __future__ import absolute_import +import os +import sys import time +import errno +import types +import signal +import socket import inspect import logging import functools # Import 3rd-party libs +import psutil +import salt.ext.six as six from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin +if six.PY2: + import __builtin__ as pybuiltins # pylint: disable=incompatible-py3-code,import-error +else: + import builtins as pybuiltins # pylint: disable=import-error +# Import Salt Tests Support libs +from tests.support.unit import skip, _id log = logging.getLogger(__name__) +def destructiveTest(caller): + ''' + Mark a test case as a destructive test for example adding or removing users + from your system. + + .. code-block:: python + + class MyTestCase(TestCase): + + @destructiveTest + def test_create_user(self): + pass + ''' + if inspect.isclass(caller): + # We're decorating a class + old_setup = getattr(caller, 'setUp', None) + + def setUp(self, *args, **kwargs): + if os.environ.get('DESTRUCTIVE_TESTS', 'False').lower() == 'false': + self.skipTest('Destructive tests are disabled') + if old_setup is not None: + old_setup(self, *args, **kwargs) + caller.setUp = setUp + return caller + + # We're simply decorating functions + @functools.wraps(caller) + def wrap(cls): + if os.environ.get('DESTRUCTIVE_TESTS', 'False').lower() == 'false': + cls.skipTest('Destructive tests are disabled') + return caller(cls) + return wrap + + +def expensiveTest(caller): + ''' + Mark a test case as an expensive test, for example, a test which can cost + money(Salt's cloud provider tests). + + .. code-block:: python + + class MyTestCase(TestCase): + + @expensiveTest + def test_create_user(self): + pass + ''' + if inspect.isclass(caller): + # We're decorating a class + old_setup = getattr(caller, 'setUp', None) + + def setUp(self, *args, **kwargs): + if os.environ.get('EXPENSIVE_TESTS', 'False').lower() == 'false': + self.skipTest('Expensive tests are disabled') + if old_setup is not None: + old_setup(self, *args, **kwargs) + caller.setUp = setUp + return caller + + # We're simply decorating functions + @functools.wraps(caller) + def wrap(cls): + if os.environ.get('EXPENSIVE_TESTS', 'False').lower() == 'false': + cls.skipTest('Expensive tests are disabled') + return caller(cls) + return wrap + + def flaky(caller=None, condition=True): ''' Mark a test as flaky. The test will attempt to run five times, @@ -75,3 +159,1097 @@ def flaky(caller=None, condition=True): time.sleep(backoff_time) return cls return wrap + + +def requires_sshd_server(caller): + ''' + Mark a test as requiring the tests SSH daemon running. + + .. code-block:: python + + class MyTestCase(TestCase): + + @requiresSshdServer + def test_create_user(self): + pass + ''' + if inspect.isclass(caller): + # We're decorating a class + old_setup = getattr(caller, 'setUp', None) + + def setUp(self, *args, **kwargs): + if os.environ.get('SSH_DAEMON_RUNNING', 'False').lower() == 'false': + self.skipTest('SSH tests are disabled') + if old_setup is not None: + old_setup(self, *args, **kwargs) + caller.setUp = setUp + return caller + + # We're simply decorating functions + @functools.wraps(caller) + def wrap(cls): + if os.environ.get('SSH_DAEMON_RUNNING', 'False').lower() == 'false': + cls.skipTest('SSH tests are disabled') + return caller(cls) + return wrap + + +class RedirectStdStreams(object): + ''' + Temporarily redirect system output to file like objects. + Default is to redirect to `os.devnull`, which just mutes output, `stdout` + and `stderr`. + ''' + + def __init__(self, stdout=None, stderr=None): + if stdout is None: + stdout = open(os.devnull, 'w') + if stderr is None: + stderr = open(os.devnull, 'w') + + self.__stdout = stdout + self.__stderr = stderr + self.__redirected = False + + def __enter__(self): + self.redirect() + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.unredirect() + + def redirect(self): + self.old_stdout = sys.stdout + self.old_stdout.flush() + self.old_stderr = sys.stderr + self.old_stderr.flush() + sys.stdout = self.__stdout + sys.stderr = self.__stderr + self.__redirected = True + + def unredirect(self): + if not self.__redirected: + return + try: + self.__stdout.flush() + self.__stdout.close() + except ValueError: + # already closed? + pass + try: + self.__stderr.flush() + self.__stderr.close() + except ValueError: + # already closed? + pass + + sys.stdout = self.old_stdout + sys.stderr = self.old_stderr + + def flush(self): + if self.__redirected: + try: + self.__stdout.flush() + except Exception: + pass + try: + self.__stderr.flush() + except Exception: + pass + + +class TestsLoggingHandler(object): + ''' + Simple logging handler which can be used to test if certain logging + messages get emitted or not: + + .. code-block:: python + + with TestsLoggingHandler() as handler: + # (...) Do what ever you wish here + handler.messages # here are the emitted log messages + + ''' + def __init__(self, level=0, format='%(levelname)s:%(message)s'): + self.level = level + self.format = format + self.activated = False + self.prev_logging_level = None + + def activate(self): + class Handler(logging.Handler): + def __init__(self, level): + logging.Handler.__init__(self, level) + self.messages = [] + + def emit(self, record): + self.messages.append(self.format(record)) + + self.handler = Handler(self.level) + formatter = logging.Formatter(self.format) + self.handler.setFormatter(formatter) + logging.root.addHandler(self.handler) + self.activated = True + # Make sure we're running with the lowest logging level with our + # tests logging handler + current_logging_level = logging.root.getEffectiveLevel() + if current_logging_level > logging.DEBUG: + self.prev_logging_level = current_logging_level + logging.root.setLevel(0) + + def deactivate(self): + if not self.activated: + return + logging.root.removeHandler(self.handler) + # Restore previous logging level if changed + if self.prev_logging_level is not None: + logging.root.setLevel(self.prev_logging_level) + + @property + def messages(self): + if not self.activated: + return [] + return self.handler.messages + + def clear(self): + self.handler.messages = [] + + def __enter__(self): + self.activate() + return self + + def __exit__(self, type, value, traceback): + self.deactivate() + self.activated = False + + # Mimic some handler attributes and methods + @property + def lock(self): + if self.activated: + return self.handler.lock + + def createLock(self): + if self.activated: + return self.handler.createLock() + + def acquire(self): + if self.activated: + return self.handler.acquire() + + def release(self): + if self.activated: + return self.handler.release() + + +def relative_import(import_name, relative_from='../'): + ''' + Update sys.path to include `relative_from` before importing `import_name` + ''' + try: + return __import__(import_name) + except ImportError: + previous_frame = inspect.getframeinfo(inspect.currentframe().f_back) + sys.path.insert( + 0, os.path.realpath( + os.path.join( + os.path.abspath( + os.path.dirname(previous_frame.filename) + ), + relative_from + ) + ) + ) + return __import__(import_name) + + +def ensure_in_syspath(*ensure_paths): + ''' + Make sure that any path passed in `ensure_paths` exists in sys.path + ''' + + previous_frame = None + + for ensure_path in ensure_paths: + if ensure_path in sys.path: + # If it's already in sys.path, nothing to do + continue + + # We reached here? Then ensure_path is not present in sys.path + if os.path.isabs(ensure_path): + # It's an absolute path? Then include it in sys.path + sys.path.insert(0, ensure_path) + continue + + # If we reached here, it means it's a relative path. Lets compute the + # relation into a real path + if previous_frame is None: + previous_frame = inspect.getframeinfo( + inspect.currentframe().f_back + ) + + realpath = os.path.realpath( + os.path.join( + os.path.abspath( + os.path.dirname(previous_frame.filename) + ), + ensure_path + ) + ) + + if not os.path.exists(realpath): + # The path does not exist? Don't even inject it into sys.path + continue + + if realpath in sys.path: + # The path is already present in sys.path? Nothing else to do. + continue + + # Inject the computed path into sys.path + sys.path.insert(0, realpath) + + +class ForceImportErrorOn(object): + ''' + This class is meant to be used in mock'ed test cases which require an + ``ImportError`` to be raised. + + >>> import os.path + >>> with ForceImportErrorOn('os.path'): + ... import os.path + ... + Traceback (most recent call last): + File "", line 2, in + File "salttesting/helpers.py", line 263, in __import__ + 'Forced ImportError raised for {0!r}'.format(name) + ImportError: Forced ImportError raised for 'os.path' + >>> + + + >>> with ForceImportErrorOn(('os', 'path')): + ... import os.path + ... sys.modules.pop('os', None) + ... from os import path + ... + + Traceback (most recent call last): + File "", line 4, in + File "salttesting/helpers.py", line 288, in __fake_import__ + name, ', '.join(fromlist) + ImportError: Forced ImportError raised for 'from os import path' + >>> + + + >>> with ForceImportErrorOn(('os', 'path'), 'os.path'): + ... import os.path + ... sys.modules.pop('os', None) + ... from os import path + ... + Traceback (most recent call last): + File "", line 2, in + File "salttesting/helpers.py", line 281, in __fake_import__ + 'Forced ImportError raised for {0!r}'.format(name) + ImportError: Forced ImportError raised for 'os.path' + >>> + ''' + def __init__(self, *module_names): + self.__module_names = {} + for entry in module_names: + if isinstance(entry, (list, tuple)): + modname = entry[0] + self.__module_names[modname] = set(entry[1:]) + else: + self.__module_names[entry] = None + + def patch_import_function(self): + self.__original_import = pybuiltins.__import__ + pybuiltins.__import__ = self.__fake_import__ + + def restore_import_funtion(self): + pybuiltins.__import__ = self.__original_import + + def __fake_import__(self, name, globals_, locals_, fromlist, level=-1): + if name in self.__module_names: + importerror_fromlist = self.__module_names.get(name) + if importerror_fromlist is None: + raise ImportError( + 'Forced ImportError raised for {0!r}'.format(name) + ) + + if importerror_fromlist.intersection(set(fromlist)): + raise ImportError( + 'Forced ImportError raised for {0!r}'.format( + 'from {0} import {1}'.format( + name, ', '.join(fromlist) + ) + ) + ) + + return self.__original_import(name, globals_, locals_, fromlist, level) + + def __enter__(self): + self.patch_import_function() + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.restore_import_funtion() + + +class MockWraps(object): + ''' + Helper class to be used with the mock library. + To be used in the ``wraps`` keyword of ``Mock`` or ``MagicMock`` where you + want to trigger a side effect for X times, and afterwards, call the + original and un-mocked method. + + As an example: + + >>> def original(): + ... print 'original' + ... + >>> def side_effect(): + ... print 'side effect' + ... + >>> mw = MockWraps(original, 2, side_effect) + >>> mw() + side effect + >>> mw() + side effect + >>> mw() + original + >>> + + ''' + def __init__(self, original, expected_failures, side_effect): + self.__original = original + self.__expected_failures = expected_failures + self.__side_effect = side_effect + self.__call_counter = 0 + + def __call__(self, *args, **kwargs): + try: + if self.__call_counter < self.__expected_failures: + if isinstance(self.__side_effect, types.FunctionType): + return self.__side_effect() + raise self.__side_effect + return self.__original(*args, **kwargs) + finally: + self.__call_counter += 1 + + +def requires_network(only_local_network=False): + ''' + Simple decorator which is supposed to skip a test case in case there's no + network connection to the internet. + ''' + def decorator(func): + @functools.wraps(func) + def wrapper(cls): + has_local_network = False + # First lets try if we have a local network. Inspired in + # verify_socket + try: + pubsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + retsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + pubsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + pubsock.bind(('', 18000)) + pubsock.close() + retsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + retsock.bind(('', 18001)) + retsock.close() + has_local_network = True + except socket.error: + # I wonder if we just have IPV6 support? + try: + pubsock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + retsock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + pubsock.setsockopt( + socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 + ) + pubsock.bind(('', 18000)) + pubsock.close() + retsock.setsockopt( + socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 + ) + retsock.bind(('', 18001)) + retsock.close() + has_local_network = True + except socket.error: + # Let's continue + pass + + if only_local_network is True: + if has_local_network is False: + # Since we're only supposed to check local network, and no + # local network was detected, skip the test + cls.skipTest('No local network was detected') + return func(cls) + + # We are using the google.com DNS records as numerical IPs to avoid + # DNS lookups which could greatly slow down this check + for addr in ('173.194.41.198', '173.194.41.199', '173.194.41.200', + '173.194.41.201', '173.194.41.206', '173.194.41.192', + '173.194.41.193', '173.194.41.194', '173.194.41.195', + '173.194.41.196', '173.194.41.197'): + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(0.25) + sock.connect((addr, 80)) + sock.close() + # We connected? Stop the loop + break + except socket.error: + # Let's check the next IP + continue + else: + cls.skipTest('No internet network connection was detected') + return func(cls) + return wrapper + return decorator + + +def with_system_user(username, on_existing='delete', delete=True): + ''' + Create and optionally destroy a system user to be used within a test + case. The system user is crated using the ``user`` salt module. + + The decorated testcase function must accept 'username' as an argument. + + :param username: The desired username for the system user. + :param on_existing: What to do when the desired username is taken. The + available options are: + + * nothing: Do nothing, act as if the user was created. + * delete: delete and re-create the existing user + * skip: skip the test case + ''' + if on_existing not in ('nothing', 'delete', 'skip'): + raise RuntimeError( + 'The value of \'on_existing\' can only be one of, ' + '\'nothing\', \'delete\' and \'skip\'' + ) + + if not isinstance(delete, bool): + raise RuntimeError( + 'The value of \'delete\' can only be \'True\' or \'False\'' + ) + + def decorator(func): + + @functools.wraps(func) + def wrap(cls): + + # Let's add the user to the system. + log.debug('Creating system user {0!r}'.format(username)) + create_user = cls.run_function('user.add', [username]) + if not create_user: + log.debug('Failed to create system user') + # The user was not created + if on_existing == 'skip': + cls.skipTest( + 'Failed to create system user {0!r}'.format( + username + ) + ) + + if on_existing == 'delete': + log.debug( + 'Deleting the system user {0!r}'.format( + username + ) + ) + delete_user = cls.run_function( + 'user.delete', [username, True, True] + ) + if not delete_user: + cls.skipTest( + 'A user named {0!r} already existed on the ' + 'system and re-creating it was not possible' + .format(username) + ) + log.debug( + 'Second time creating system user {0!r}'.format( + username + ) + ) + create_user = cls.run_function('user.add', [username]) + if not create_user: + cls.skipTest( + 'A user named {0!r} already existed, was deleted ' + 'as requested, but re-creating it was not possible' + .format(username) + ) + + failure = None + try: + try: + return func(cls, username) + except Exception as exc: # pylint: disable=W0703 + log.error( + 'Running {0!r} raised an exception: {1}'.format( + func, exc + ), + exc_info=True + ) + # Store the original exception details which will be raised + # a little further down the code + failure = sys.exc_info() + finally: + if delete: + delete_user = cls.run_function( + 'user.delete', [username, True, True] + ) + if not delete_user: + if failure is None: + log.warning( + 'Although the actual test-case did not fail, ' + 'deleting the created system user {0!r} ' + 'afterwards did.'.format(username) + ) + else: + log.warning( + 'The test-case failed and also did the removal' + ' of the system user {0!r}'.format(username) + ) + if failure is not None: + # If an exception was thrown, raise it + six.reraise(failure[0], failure[1], failure[2]) + return wrap + return decorator + + +def with_system_group(group, on_existing='delete', delete=True): + ''' + Create and optionally destroy a system group to be used within a test + case. The system user is crated using the ``group`` salt module. + + The decorated testcase function must accept 'group' as an argument. + + :param group: The desired group name for the system user. + :param on_existing: What to do when the desired username is taken. The + available options are: + + * nothing: Do nothing, act as if the group was created + * delete: delete and re-create the existing user + * skip: skip the test case + ''' + if on_existing not in ('nothing', 'delete', 'skip'): + raise RuntimeError( + 'The value of \'on_existing\' can only be one of, ' + '\'nothing\', \'delete\' and \'skip\'' + ) + + if not isinstance(delete, bool): + raise RuntimeError( + 'The value of \'delete\' can only be \'True\' or \'False\'' + ) + + def decorator(func): + + @functools.wraps(func) + def wrap(cls): + + # Let's add the user to the system. + log.debug('Creating system group {0!r}'.format(group)) + create_group = cls.run_function('group.add', [group]) + if not create_group: + log.debug('Failed to create system group') + # The group was not created + if on_existing == 'skip': + cls.skipTest( + 'Failed to create system group {0!r}'.format(group) + ) + + if on_existing == 'delete': + log.debug( + 'Deleting the system group {0!r}'.format(group) + ) + delete_group = cls.run_function('group.delete', [group]) + if not delete_group: + cls.skipTest( + 'A group named {0!r} already existed on the ' + 'system and re-creating it was not possible' + .format(group) + ) + log.debug( + 'Second time creating system group {0!r}'.format( + group + ) + ) + create_group = cls.run_function('group.add', [group]) + if not create_group: + cls.skipTest( + 'A group named {0!r} already existed, was deleted ' + 'as requested, but re-creating it was not possible' + .format(group) + ) + + failure = None + try: + try: + return func(cls, group) + except Exception as exc: # pylint: disable=W0703 + log.error( + 'Running {0!r} raised an exception: {1}'.format( + func, exc + ), + exc_info=True + ) + # Store the original exception details which will be raised + # a little further down the code + failure = sys.exc_info() + finally: + if delete: + delete_group = cls.run_function('group.delete', [group]) + if not delete_group: + if failure is None: + log.warning( + 'Although the actual test-case did not fail, ' + 'deleting the created system group {0!r} ' + 'afterwards did.'.format(group) + ) + else: + log.warning( + 'The test-case failed and also did the removal' + ' of the system group {0!r}'.format(group) + ) + if failure is not None: + # If an exception was thrown, raise it + six.reraise(failure[0], failure[1], failure[2]) + return wrap + return decorator + + +def with_system_user_and_group(username, group, + on_existing='delete', delete=True): + ''' + Create and optionally destroy a system user and group to be used within a + test case. The system user is crated using the ``user`` salt module, and + the system group is created with the ``group`` salt module. + + The decorated testcase function must accept both the 'username' and 'group' + arguments. + + :param username: The desired username for the system user. + :param group: The desired name for the system group. + :param on_existing: What to do when the desired username is taken. The + available options are: + + * nothing: Do nothing, act as if the user was created. + * delete: delete and re-create the existing user + * skip: skip the test case + ''' + if on_existing not in ('nothing', 'delete', 'skip'): + raise RuntimeError( + 'The value of \'on_existing\' can only be one of, ' + '\'nothing\', \'delete\' and \'skip\'' + ) + + if not isinstance(delete, bool): + raise RuntimeError( + 'The value of \'delete\' can only be \'True\' or \'False\'' + ) + + def decorator(func): + + @functools.wraps(func) + def wrap(cls): + + # Let's add the user to the system. + log.debug('Creating system user {0!r}'.format(username)) + create_user = cls.run_function('user.add', [username]) + log.debug('Creating system group {0!r}'.format(group)) + create_group = cls.run_function('group.add', [group]) + if not create_user: + log.debug('Failed to create system user') + # The user was not created + if on_existing == 'skip': + cls.skipTest( + 'Failed to create system user {0!r}'.format( + username + ) + ) + + if on_existing == 'delete': + log.debug( + 'Deleting the system user {0!r}'.format( + username + ) + ) + delete_user = cls.run_function( + 'user.delete', [username, True, True] + ) + if not delete_user: + cls.skipTest( + 'A user named {0!r} already existed on the ' + 'system and re-creating it was not possible' + .format(username) + ) + log.debug( + 'Second time creating system user {0!r}'.format( + username + ) + ) + create_user = cls.run_function('user.add', [username]) + if not create_user: + cls.skipTest( + 'A user named {0!r} already existed, was deleted ' + 'as requested, but re-creating it was not possible' + .format(username) + ) + if not create_group: + log.debug('Failed to create system group') + # The group was not created + if on_existing == 'skip': + cls.skipTest( + 'Failed to create system group {0!r}'.format(group) + ) + + if on_existing == 'delete': + log.debug( + 'Deleting the system group {0!r}'.format(group) + ) + delete_group = cls.run_function('group.delete', [group]) + if not delete_group: + cls.skipTest( + 'A group named {0!r} already existed on the ' + 'system and re-creating it was not possible' + .format(group) + ) + log.debug( + 'Second time creating system group {0!r}'.format( + group + ) + ) + create_group = cls.run_function('group.add', [group]) + if not create_group: + cls.skipTest( + 'A group named {0!r} already existed, was deleted ' + 'as requested, but re-creating it was not possible' + .format(group) + ) + + failure = None + try: + try: + return func(cls, username, group) + except Exception as exc: # pylint: disable=W0703 + log.error( + 'Running {0!r} raised an exception: {1}'.format( + func, exc + ), + exc_info=True + ) + # Store the original exception details which will be raised + # a little further down the code + failure = sys.exc_info() + finally: + if delete: + delete_user = cls.run_function( + 'user.delete', [username, True, True] + ) + delete_group = cls.run_function('group.delete', [group]) + if not delete_user: + if failure is None: + log.warning( + 'Although the actual test-case did not fail, ' + 'deleting the created system user {0!r} ' + 'afterwards did.'.format(username) + ) + else: + log.warning( + 'The test-case failed and also did the removal' + ' of the system user {0!r}'.format(username) + ) + if not delete_group: + if failure is None: + log.warning( + 'Although the actual test-case did not fail, ' + 'deleting the created system group {0!r} ' + 'afterwards did.'.format(group) + ) + else: + log.warning( + 'The test-case failed and also did the removal' + ' of the system group {0!r}'.format(group) + ) + if failure is not None: + # If an exception was thrown, raise it + six.reraise(failure[0], failure[1], failure[2]) + return wrap + return decorator + + +def requires_system_grains(func): + ''' + Function decorator which loads and passes the system's grains to the test + case. + ''' + @functools.wraps(func) + def decorator(cls): + if not hasattr(cls, 'run_function'): + raise RuntimeError( + '{0} does not have the \'run_function\' method which is ' + 'necessary to collect the system grains'.format( + cls.__class__.__name__ + ) + ) + return func(cls, grains=cls.run_function('grains.items')) + return decorator + + +def requires_salt_modules(*names): + ''' + Makes sure the passed salt module is available. Skips the test if not + + .. versionadded:: 0.5.2 + ''' + def decorator(caller): + + if inspect.isclass(caller): + # We're decorating a class + old_setup = getattr(caller, 'setUp', None) + + def setUp(self, *args, **kwargs): + if old_setup is not None: + old_setup(self, *args, **kwargs) + + if not hasattr(self, 'run_function'): + raise RuntimeError( + '{0} does not have the \'run_function\' method which ' + 'is necessary to collect the loaded modules'.format( + self.__class__.__name__ + ) + ) + + for name in names: + if not hasattr(self, '__salt_sys_docs__'): + # cache salts documentation + self.__salt_sys_docs__ = self.run_function('sys.doc') + if name not in self.__salt_sys_docs__: + self.skipTest('Salt module {0!r} is not available'.format(name)) + caller.setUp = setUp + return caller + + # We're simply decorating functions + @functools.wraps(caller) + def wrapper(cls): + + if not hasattr(cls, 'run_function'): + raise RuntimeError( + '{0} does not have the \'run_function\' method which is ' + 'necessary to collect the loaded modules'.format( + cls.__class__.__name__ + ) + ) + + for name in names: + if name not in cls.run_function('sys.doc'): + cls.skipTest( + 'Salt module {0!r} is not available'.format(name) + ) + break + + return caller(cls) + return wrapper + return decorator + + +def skip_if_binaries_missing(*binaries, **kwargs): + import salt.utils + if len(binaries) == 1: + if isinstance(binaries[0], (list, tuple, set, frozenset)): + binaries = binaries[0] + check_all = kwargs.pop('check_all', False) + message = kwargs.pop('message', None) + if kwargs: + raise RuntimeError( + 'The only supported keyword argument is \'check_all\' and ' + '\'message\'. Invalid keyword arguments: {0}'.format( + ', '.join(kwargs.keys()) + ) + ) + if check_all: + for binary in binaries: + if salt.utils.which(binary) is None: + return skip( + '{0}The {1!r} binary was not found'.format( + message and '{0}. '.format(message) or '', + binary + ) + ) + elif salt.utils.which_bin(binaries) is None: + return skip( + '{0}None of the following binaries was found: {1}'.format( + message and '{0}. '.format(message) or '', + ', '.join(binaries) + ) + ) + return _id + + +def skip_if_not_root(func): + if os.getuid() != 0: + func.__unittest_skip__ = True + func.__unittest_skip_why__ = 'You must be logged in as root to run this test' + return func + + +if sys.platform.startswith('win'): + SIGTERM = signal.CTRL_BREAK_EVENT # pylint: disable=no-member +else: + SIGTERM = signal.SIGTERM + + +def collect_child_processes(pid): + ''' + Try to collect any started child processes of the provided pid + ''' + # Let's get the child processes of the started subprocess + try: + parent = psutil.Process(pid) + if hasattr(parent, 'children'): + children = parent.children(recursive=True) + else: + children = [] + except psutil.NoSuchProcess: + children = [] + return children[::-1] # return a reversed list of the children + + +def _terminate_process_list(process_list, kill=False, slow_stop=False): + for process in process_list[:][::-1]: # Iterate over a reversed copy of the list + if not psutil.pid_exists(process.pid): + process_list.remove(process) + continue + try: + if not kill and process.status() == psutil.STATUS_ZOMBIE: + # Zombie processes will exit once child processes also exit + continue + try: + cmdline = process.cmdline() + except psutil.AccessDenied: + # OSX is more restrictive about the above information + cmdline = None + if not cmdline: + try: + cmdline = process.as_dict() + except Exception: + cmdline = 'UNKNOWN PROCESS' + if kill: + log.info('Killing process(%s): %s', process.pid, cmdline) + process.kill() + else: + log.info('Terminating process(%s): %s', process.pid, cmdline) + try: + if slow_stop: + # Allow coverage data to be written down to disk + process.send_signal(SIGTERM) + try: + process.wait(2) + except psutil.TimeoutExpired: + if psutil.pid_exists(process.pid): + continue + else: + process.terminate() + except OSError as exc: + if exc.errno not in (errno.ESRCH, errno.EACCES): + raise + if not psutil.pid_exists(process.pid): + process_list.remove(process) + except psutil.NoSuchProcess: + process_list.remove(process) + + +def terminate_process_list(process_list, kill=False, slow_stop=False): + + def on_process_terminated(proc): + log.info('Process %s terminated with exit code: %s', getattr(proc, '_cmdline', proc), proc.returncode) + + # Try to terminate processes with the provided kill and slow_stop parameters + log.info('Terminating process list. 1st step. kill: %s, slow stop: %s', kill, slow_stop) + + # Cache the cmdline since that will be inaccessible once the process is terminated + for proc in process_list: + try: + cmdline = proc.cmdline() + except (psutil.NoSuchProcess, psutil.AccessDenied): + # OSX is more restrictive about the above information + cmdline = None + if not cmdline: + try: + cmdline = proc + except (psutil.NoSuchProcess, psutil.AccessDenied): + cmdline = ''.format(proc) + proc._cmdline = cmdline + _terminate_process_list(process_list, kill=kill, slow_stop=slow_stop) + psutil.wait_procs(process_list, timeout=15, callback=on_process_terminated) + + if process_list: + # If there's still processes to be terminated, retry and kill them if slow_stop is False + log.info('Terminating process list. 2nd step. kill: %s, slow stop: %s', slow_stop is False, slow_stop) + _terminate_process_list(process_list, kill=slow_stop is False, slow_stop=slow_stop) + psutil.wait_procs(process_list, timeout=10, callback=on_process_terminated) + + if process_list: + # If there's still processes to be terminated, just kill them, no slow stopping now + log.info('Terminating process list. 3rd step. kill: True, slow stop: False') + _terminate_process_list(process_list, kill=True, slow_stop=False) + psutil.wait_procs(process_list, timeout=5, callback=on_process_terminated) + + if process_list: + # In there's still processes to be terminated, log a warning about it + log.warning('Some processes failed to properly terminate: %s', process_list) + + +def terminate_process(pid=None, process=None, children=None, kill_children=False, slow_stop=False): + ''' + Try to terminate/kill the started processe + ''' + children = children or [] + process_list = [] + + def on_process_terminated(proc): + log.info('Process %s terminated with exit code: %s', getattr(proc, '_cmdline', proc), proc.returncode) + + if pid and not process: + try: + process = psutil.Process(pid) + process_list.append(process) + except psutil.NoSuchProcess: + # Process is already gone + process = None + + if kill_children: + if process: + if not children: + children = collect_child_processes(process.pid) + else: + # Let's collect children again since there might be new ones + children.extend(collect_child_processes(pid)) + if children: + process_list.extend(children) + + if process_list: + if process: + log.info('Stopping process %s and respective children: %s', process, children) + else: + log.info('Terminating process list: %s', process_list) + terminate_process_list(process_list, kill=slow_stop is False, slow_stop=slow_stop) + if process and psutil.pid_exists(process.pid): + log.warning('Process left behind which we were unable to kill: %s', process) + + +def terminate_process_pid(pid, only_children=False): + children = [] + process = None + + # Let's begin the shutdown routines + try: + process = psutil.Process(pid) + children = collect_child_processes(pid) + except psutil.NoSuchProcess: + log.info('No process with the PID %s was found running', pid) + + if only_children: + return terminate_process(children=children, kill_children=True, slow_stop=True) + return terminate_process(pid=pid, process=process, children=children, kill_children=True, slow_stop=True) diff --git a/tests/support/mixins.py b/tests/support/mixins.py index 098376cba0..edfb887dfc 100644 --- a/tests/support/mixins.py +++ b/tests/support/mixins.py @@ -1,89 +1,465 @@ # -*- coding: utf-8 -*- ''' :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` - :copyright: © 2017 by the SaltStack Team, see AUTHORS for more details. - :license: Apache 2.0, see LICENSE for more details. + ============= + Class Mix-Ins + ============= - tests.utils.mixins - ~~~~~~~~~~~~~~~~~~ - - Unittest TestCase mixin classes + Some reusable class Mixins ''' +# pylint: disable=repr-flag-used-in-string + # Import python libs from __future__ import absolute_import +import os +import copy +import pprint +import logging +import warnings +import subprocess -try: - from salttesting.mixins import LoaderModuleMockMixin -except ImportError: - # Import python libs - import copy +# Import Salt Testing Libs +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.paths import CODE_DIR +from tests.support.runtests import RUNTIME_VARS - # Import 3rd-party libs - import salt.ext.six as six +# Import salt libs +import salt.version - class _FixLoaderModuleMockMixinMroOrder(type): - ''' - This metaclass will make sure that LoaderModuleMockMixin will always come as the first - base class in order for LoaderModuleMockMixin.setUp to actually run - ''' - def __new__(mcs, cls_name, cls_bases, cls_dict): - if cls_name == 'LoaderModuleMockMixin': - return super(_FixLoaderModuleMockMixinMroOrder, mcs).__new__(mcs, cls_name, cls_bases, cls_dict) - bases = list(cls_bases) - for idx, base in enumerate(bases): - if base.__name__ == 'LoaderModuleMockMixin': - bases.insert(0, bases.pop(idx)) - break - return super(_FixLoaderModuleMockMixinMroOrder, mcs).__new__(mcs, cls_name, tuple(bases), cls_dict) +# Import 3rd-party libs +import salt.ext.six as six - class LoaderModuleMockMixin(six.with_metaclass(_FixLoaderModuleMockMixinMroOrder, object)): - def setUp(self): - loader_module = getattr(self, 'loader_module', None) - if loader_module is not None: - from salttesting.mock import NO_MOCK, NO_MOCK_REASON - if NO_MOCK: - self.skipTest(NO_MOCK_REASON) +log = logging.getLogger(__name__) - loader_module_name = loader_module.__name__ - loader_module_globals = getattr(self, 'loader_module_globals', None) - loader_module_blacklisted_dunders = getattr(self, 'loader_module_blacklisted_dunders', ()) - if loader_module_globals is None: - loader_module_globals = {} - elif callable(loader_module_globals): - loader_module_globals = loader_module_globals() - else: - loader_module_globals = copy.deepcopy(loader_module_globals) - salt_dunders = ( - '__opts__', '__salt__', '__runner__', '__context__', '__utils__', - '__ext_pillar__', '__thorium__', '__states__', '__serializers__', '__ret__', - '__grains__', '__pillar__', '__sdb__', - # Proxy is commented out on purpose since some code in salt expects a NameError - # and is most of the time not a required dunder - # '__proxy__' +class CheckShellBinaryNameAndVersionMixin(object): + ''' + Simple class mix-in to subclass in companion to :class:`ShellTestCase` which + adds a test case to verify proper version report from Salt's CLI tools. + ''' + + _call_binary_ = None + _call_binary_expected_version_ = None + + def test_version_includes_binary_name(self): + if getattr(self, '_call_binary_', None) is None: + self.skipTest('\'_call_binary_\' not defined.') + + if self._call_binary_expected_version_ is None: + # Late import + self._call_binary_expected_version_ = salt.version.__version__ + + out = '\n'.join(self.run_script(self._call_binary_, '--version')) + self.assertIn(self._call_binary_, out) + self.assertIn(self._call_binary_expected_version_, out) + + +class SaltReturnAssertsMixin(object): + ''' + Mix-in class to add as a companion to the TestCase class or it's subclasses which + adds test assertions for Salt's return data. + + .. code-block: python + + from tests.support.case import ModuleCase + from tests.support.mixins import SaltReturnAssertsMixin + + class FooTestCase(ModuleCase, SaltReturnAssertsMixin): + + def test_bar(self): + ret = self.run_function('publish.publish', ['minion', 'test.ping']) + self.assertReturnSaltType(ret) + ''' + + def assertReturnSaltType(self, ret): + try: + self.assertTrue(isinstance(ret, dict)) + except AssertionError: + raise AssertionError( + '{0} is not dict. Salt returned: {1}'.format( + type(ret).__name__, ret ) - for dunder_name in salt_dunders: - if dunder_name not in loader_module_globals: - if dunder_name in loader_module_blacklisted_dunders: - continue - loader_module_globals[dunder_name] = {} + ) - for key in loader_module_globals: - if not hasattr(loader_module, key): - if key in salt_dunders: - setattr(loader_module, key, {}) - else: - setattr(loader_module, key, None) + def assertReturnNonEmptySaltType(self, ret): + self.assertReturnSaltType(ret) + try: + self.assertNotEqual(ret, {}) + except AssertionError: + raise AssertionError( + '{} is equal to {}. Salt returned an empty dictionary.' + ) - if loader_module_globals: - from salttesting.mock import patch - patcher = patch.multiple(loader_module_name, **loader_module_globals) - patcher.start() + def __return_valid_keys(self, keys): + if isinstance(keys, tuple): + # If it's a tuple, turn it into a list + keys = list(keys) + elif isinstance(keys, six.string_types): + # If it's a basestring , make it a one item list + keys = [keys] + elif not isinstance(keys, list): + # If we've reached here, it's a bad type passed to keys + raise RuntimeError('The passed keys need to be a list') + return keys - def cleanup(patcher, loader_module_globals): - patcher.stop() - del loader_module_globals + def __getWithinSaltReturn(self, ret, keys): + self.assertReturnNonEmptySaltType(ret) + keys = self.__return_valid_keys(keys) + okeys = keys[:] + for part in six.itervalues(ret): + try: + ret_item = part[okeys.pop(0)] + except (KeyError, TypeError): + raise AssertionError( + 'Could not get ret{0} from salt\'s return: {1}'.format( + ''.join(['[{0!r}]'.format(k) for k in keys]), part + ) + ) + while okeys: + try: + ret_item = ret_item[okeys.pop(0)] + except (KeyError, TypeError): + raise AssertionError( + 'Could not get ret{0} from salt\'s return: {1}'.format( + ''.join(['[{0!r}]'.format(k) for k in keys]), part + ) + ) + return ret_item - self.addCleanup(cleanup, patcher, loader_module_globals) - super(LoaderModuleMockMixin, self).setUp() + def assertSaltTrueReturn(self, ret): + try: + self.assertTrue(self.__getWithinSaltReturn(ret, 'result')) + except AssertionError: + log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) + try: + raise AssertionError( + '{result} is not True. Salt Comment:\n{comment}'.format( + **(ret.values()[0]) + ) + ) + except (AttributeError, IndexError): + raise AssertionError( + 'Failed to get result. Salt Returned:\n{0}'.format( + pprint.pformat(ret) + ) + ) + + def assertSaltFalseReturn(self, ret): + try: + self.assertFalse(self.__getWithinSaltReturn(ret, 'result')) + except AssertionError: + log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) + try: + raise AssertionError( + '{result} is not False. Salt Comment:\n{comment}'.format( + **(ret.values()[0]) + ) + ) + except (AttributeError, IndexError): + raise AssertionError( + 'Failed to get result. Salt Returned: {0}'.format(ret) + ) + + def assertSaltNoneReturn(self, ret): + try: + self.assertIsNone(self.__getWithinSaltReturn(ret, 'result')) + except AssertionError: + log.info('Salt Full Return:\n{0}'.format(pprint.pformat(ret))) + try: + raise AssertionError( + '{result} is not None. Salt Comment:\n{comment}'.format( + **(ret.values()[0]) + ) + ) + except (AttributeError, IndexError): + raise AssertionError( + 'Failed to get result. Salt Returned: {0}'.format(ret) + ) + + def assertInSaltComment(self, in_comment, ret): + return self.assertIn( + in_comment, self.__getWithinSaltReturn(ret, 'comment') + ) + + def assertNotInSaltComment(self, not_in_comment, ret): + return self.assertNotIn( + not_in_comment, self.__getWithinSaltReturn(ret, 'comment') + ) + + def assertSaltCommentRegexpMatches(self, ret, pattern): + return self.assertInSaltReturnRegexpMatches(ret, pattern, 'comment') + + def assertInSalStatetWarning(self, in_comment, ret): + return self.assertIn( + in_comment, self.__getWithinSaltReturn(ret, 'warnings') + ) + + def assertNotInSaltStateWarning(self, not_in_comment, ret): + return self.assertNotIn( + not_in_comment, self.__getWithinSaltReturn(ret, 'warnings') + ) + + def assertInSaltReturn(self, item_to_check, ret, keys): + return self.assertIn( + item_to_check, self.__getWithinSaltReturn(ret, keys) + ) + + def assertNotInSaltReturn(self, item_to_check, ret, keys): + return self.assertNotIn( + item_to_check, self.__getWithinSaltReturn(ret, keys) + ) + + def assertInSaltReturnRegexpMatches(self, ret, pattern, keys=()): + return self.assertRegexpMatches( + self.__getWithinSaltReturn(ret, keys), pattern + ) + + def assertSaltStateChangesEqual(self, ret, comparison, keys=()): + keys = ['changes'] + self.__return_valid_keys(keys) + return self.assertEqual( + self.__getWithinSaltReturn(ret, keys), comparison + ) + + def assertSaltStateChangesNotEqual(self, ret, comparison, keys=()): + keys = ['changes'] + self.__return_valid_keys(keys) + return self.assertNotEqual( + self.__getWithinSaltReturn(ret, keys), comparison + ) + + +class AdaptedConfigurationTestCaseMixin(object): + + __slots__ = () + + def get_config_dir(self): + return RUNTIME_VARS.TMP_CONF_DIR + + def get_config_file_path(self, filename): + return os.path.join(RUNTIME_VARS.TMP_CONF_DIR, filename) + + @property + def master_opts(self): + # Late import + import salt.config + + warnings.warn( + 'Please stop using the \'master_opts\' attribute in \'{0}.{1}\' and instead ' + 'import \'RUNTIME_VARS\' from {2!r} and instantiate the master configuration like ' + '\'salt.config.master_config(os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "master"))\''.format( + self.__class__.__module__, + self.__class__.__name__, + __name__ + ), + DeprecationWarning, + ) + return salt.config.master_config( + self.get_config_file_path('master') + ) + + @property + def minion_opts(self): + ''' + Return the options used for the minion + ''' + # Late import + import salt.config + + warnings.warn( + 'Please stop using the \'minion_opts\' attribute in \'{0}.{1}\' and instead ' + 'import \'RUNTIME_VARS\' from {2!r} and instantiate the minion configuration like ' + '\'salt.config.minion_config(os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "minion"))\''.format( + self.__class__.__module__, + self.__class__.__name__, + __name__ + ), + DeprecationWarning, + ) + return salt.config.minion_config( + self.get_config_file_path('minion') + ) + + @property + def sub_minion_opts(self): + ''' + Return the options used for the sub-minion + ''' + # Late import + import salt.config + + warnings.warn( + 'Please stop using the \'sub_minion_opts\' attribute in \'{0}.{1}\' and instead ' + 'import \'RUNTIME_VARS\' from {2!r} and instantiate the sub-minion configuration like ' + '\'salt.config.minion_config(os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "sub_minion_opts"))\''.format( + self.__class__.__module__, + self.__class__.__name__, + __name__ + ), + DeprecationWarning, + ) + return salt.config.minion_config( + self.get_config_file_path('sub_minion') + ) + + +class SaltClientTestCaseMixin(AdaptedConfigurationTestCaseMixin): + ''' + Mix-in class that provides a ``client`` attribute which returns a Salt + :class:`LocalClient`. + + .. code-block:: python + + class LocalClientTestCase(TestCase, SaltClientTestCaseMixin): + + def test_check_pub_data(self): + just_minions = {'minions': ['m1', 'm2']} + jid_no_minions = {'jid': '1234', 'minions': []} + valid_pub_data = {'minions': ['m1', 'm2'], 'jid': '1234'} + + self.assertRaises(EauthAuthenticationError, + self.client._check_pub_data, None) + self.assertDictEqual({}, + self.client._check_pub_data(just_minions), + 'Did not handle lack of jid correctly') + + self.assertDictEqual( + {}, + self.client._check_pub_data({'jid': '0'}), + 'Passing JID of zero is not handled gracefully') + ''' + _salt_client_config_file_name_ = 'master' + + @property + def client(self): + # Late import + import salt.client + return salt.client.get_local_client( + self.get_config_file_path(self._salt_client_config_file_name_) + ) + + +class ShellCaseCommonTestsMixin(CheckShellBinaryNameAndVersionMixin): + + _call_binary_expected_version_ = salt.version.__version__ + + def test_salt_with_git_version(self): + if getattr(self, '_call_binary_', None) is None: + self.skipTest('\'_call_binary_\' not defined.') + from salt.utils import which + from salt.version import __version_info__, SaltStackVersion + git = which('git') + if not git: + self.skipTest('The git binary is not available') + + # Let's get the output of git describe + process = subprocess.Popen( + [git, 'describe', '--tags', '--first-parent', '--match', 'v[0-9]*'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True, + cwd=CODE_DIR + ) + out, err = process.communicate() + if process.returncode != 0: + process = subprocess.Popen( + [git, 'describe', '--tags', '--match', 'v[0-9]*'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True, + cwd=CODE_DIR + ) + out, err = process.communicate() + if not out: + self.skipTest( + 'Failed to get the output of \'git describe\'. ' + 'Error: \'{0}\''.format( + salt.utils.to_str(err) + ) + ) + + parsed_version = SaltStackVersion.parse(out) + + if parsed_version.info < __version_info__: + self.skipTest( + 'We\'re likely about to release a new version. This test ' + 'would fail. Parsed(\'{0}\') < Expected(\'{1}\')'.format( + parsed_version.info, __version_info__ + ) + ) + elif parsed_version.info != __version_info__: + self.skipTest( + 'In order to get the proper salt version with the ' + 'git hash you need to update salt\'s local git ' + 'tags. Something like: \'git fetch --tags\' or ' + '\'git fetch --tags upstream\' if you followed ' + 'salt\'s contribute documentation. The version ' + 'string WILL NOT include the git hash.' + ) + out = '\n'.join(self.run_script(self._call_binary_, '--version')) + self.assertIn(parsed_version.string, out) + + +class _FixLoaderModuleMockMixinMroOrder(type): + ''' + This metaclass will make sure that LoaderModuleMockMixin will always come as the first + base class in order for LoaderModuleMockMixin.setUp to actually run + ''' + def __new__(mcs, cls_name, cls_bases, cls_dict): + if cls_name == 'LoaderModuleMockMixin': + return super(_FixLoaderModuleMockMixinMroOrder, mcs).__new__(mcs, cls_name, cls_bases, cls_dict) + bases = list(cls_bases) + for idx, base in enumerate(bases): + if base.__name__ == 'LoaderModuleMockMixin': + bases.insert(0, bases.pop(idx)) + break + return super(_FixLoaderModuleMockMixinMroOrder, mcs).__new__(mcs, cls_name, tuple(bases), cls_dict) + + +class LoaderModuleMockMixin(six.with_metaclass(_FixLoaderModuleMockMixinMroOrder, object)): + def setUp(self): + loader_module = getattr(self, 'loader_module', None) + if loader_module is not None: + if NO_MOCK: + self.skipTest(NO_MOCK_REASON) + + loader_module_name = loader_module.__name__ + loader_module_globals = getattr(self, 'loader_module_globals', None) + loader_module_blacklisted_dunders = getattr(self, 'loader_module_blacklisted_dunders', ()) + if loader_module_globals is None: + loader_module_globals = {} + elif callable(loader_module_globals): + loader_module_globals = loader_module_globals() + else: + loader_module_globals = copy.deepcopy(loader_module_globals) + + salt_dunders = ( + '__opts__', '__salt__', '__runner__', '__context__', '__utils__', + '__ext_pillar__', '__thorium__', '__states__', '__serializers__', '__ret__', + '__grains__', '__pillar__', '__sdb__', + # Proxy is commented out on purpose since some code in salt expects a NameError + # and is most of the time not a required dunder + # '__proxy__' + ) + for dunder_name in salt_dunders: + if dunder_name not in loader_module_globals: + if dunder_name in loader_module_blacklisted_dunders: + continue + loader_module_globals[dunder_name] = {} + + for key in loader_module_globals: + if not hasattr(loader_module, key): + if key in salt_dunders: + setattr(loader_module, key, {}) + else: + setattr(loader_module, key, None) + + if loader_module_globals: + patcher = patch.multiple(loader_module_name, **loader_module_globals) + patcher.start() + + def cleanup(patcher, loader_module_globals): + patcher.stop() + del loader_module_globals + + self.addCleanup(cleanup, patcher, loader_module_globals) + super(LoaderModuleMockMixin, self).setUp() diff --git a/tests/support/mock.py b/tests/support/mock.py new file mode 100644 index 0000000000..899493ef14 --- /dev/null +++ b/tests/support/mock.py @@ -0,0 +1,186 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + + tests.support.mock + ~~~~~~~~~~~~~~~~~~ + + Helper module that wraps :mod:`mock ` and provides + some fake objects in order to properly set the function/class decorators + and yet skip the test cases execution. +''' +# pylint: disable=unused-import,function-redefined + +from __future__ import absolute_import +import sys + +try: + if sys.version_info >= (3,): + # Python 3 + from unittest.mock import ( + Mock, + MagicMock, + patch, + sentinel, + DEFAULT, + # ANY and call will be imported further down + create_autospec, + FILTER_DIR, + NonCallableMock, + NonCallableMagicMock, + PropertyMock, + __version__ as __mock_version + ) + else: + from mock import ( + Mock, + MagicMock, + patch, + sentinel, + DEFAULT, + # ANY and call will be imported further down + create_autospec, + FILTER_DIR, + NonCallableMock, + NonCallableMagicMock, + PropertyMock, + __version__ as __mock_version + ) + NO_MOCK = False + NO_MOCK_REASON = '' + mock_version = [] + for __part in __mock_version.split('.'): + try: + mock_version.append(int(__part)) + except ValueError: + # Non-integer value (ex. '1a') + mock_version.append(__part) + mock_version = tuple(mock_version) +except ImportError as exc: + NO_MOCK = True + NO_MOCK_REASON = 'mock python module is unavailable' + mock_version = (0, 0, 0) + + # Let's not fail on imports by providing fake objects and classes + + class MagicMock(object): + + __name__ = '{0}.fakemock'.format(__name__) + + def __init__(self, *args, **kwargs): + pass + + def dict(self, *args, **kwargs): + return self + + def multiple(self, *args, **kwargs): + return self + + def __call__(self, *args, **kwargs): + return self + + Mock = MagicMock + patch = MagicMock() + sentinel = object() + DEFAULT = object() + create_autospec = MagicMock() + FILTER_DIR = True + NonCallableMock = MagicMock() + NonCallableMagicMock = MagicMock() + mock_open = object() + PropertyMock = object() + call = tuple + ANY = object() + + +if NO_MOCK is False: + try: + if sys.version_info >= (3,): + # Python 3 + from unittest.mock import call, ANY + else: + from mock import call, ANY + except ImportError: + NO_MOCK = True + NO_MOCK_REASON = 'you need to upgrade your mock version to >= 0.8.0' + + +if sys.version_info >= (3,): + from mock import mock_open +else: + # backport mock_open from the python 3 unittest.mock library so that we can + # mock read, readline, readlines, and file iteration properly + + file_spec = None + + def _iterate_read_data(read_data): + # Helper for mock_open: + # Retrieve lines from read_data via a generator so that separate calls to + # readline, read, and readlines are properly interleaved + data_as_list = ['{0}\n'.format(l) for l in read_data.split('\n')] + + if data_as_list[-1] == '\n': + # If the last line ended in a newline, the list comprehension will have an + # extra entry that's just a newline. Remove this. + data_as_list = data_as_list[:-1] + else: + # If there wasn't an extra newline by itself, then the file being + # emulated doesn't have a newline to end the last line remove the + # newline that our naive format() added + data_as_list[-1] = data_as_list[-1][:-1] + + for line in data_as_list: + yield line + + def mock_open(mock=None, read_data=''): + """ + A helper function to create a mock to replace the use of `open`. It works + for `open` called directly or used as a context manager. + + The `mock` argument is the mock object to configure. If `None` (the + default) then a `MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + + `read_data` is a string for the `read` methoddline`, and `readlines` of the + file handle to return. This is an empty string by default. + """ + def _readlines_side_effect(*args, **kwargs): + if handle.readlines.return_value is not None: + return handle.readlines.return_value + return list(_data) + + def _read_side_effect(*args, **kwargs): + if handle.read.return_value is not None: + return handle.read.return_value + return ''.join(_data) + + def _readline_side_effect(): + if handle.readline.return_value is not None: + while True: + yield handle.readline.return_value + for line in _data: + yield line + + global file_spec + if file_spec is None: + file_spec = file + + if mock is None: + mock = MagicMock(name='open', spec=open) + + handle = MagicMock(spec=file_spec) + handle.__enter__.return_value = handle + + _data = _iterate_read_data(read_data) + + handle.write.return_value = None + handle.read.return_value = None + handle.readline.return_value = None + handle.readlines.return_value = None + + handle.read.side_effect = _read_side_effect + handle.readline.side_effect = _readline_side_effect() + handle.readlines.side_effect = _readlines_side_effect + + mock.return_value = handle + return mock diff --git a/tests/support/parser/__init__.py b/tests/support/parser/__init__.py new file mode 100644 index 0000000000..e0116770b9 --- /dev/null +++ b/tests/support/parser/__init__.py @@ -0,0 +1,892 @@ +# -*- coding: utf-8 -*- +''' + tests.support.parser + ~~~~~~~~~~~~~~~~~~~~ + + Salt Tests CLI access classes + + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + :copyright: © 2013-2017 by the SaltStack Team, see AUTHORS for more details + :license: Apache 2.0, see LICENSE for more details. +''' +# pylint: disable=repr-flag-used-in-string + +from __future__ import absolute_import, print_function +import os +import sys +import time +import signal +import shutil +import logging +import platform +import optparse +import tempfile +import traceback +import subprocess +import warnings +from functools import partial +from contextlib import closing + +import six +from tests.support import helpers +from tests.support.unit import TestLoader, TextTestRunner +from tests.support.xmlunit import HAS_XMLRUNNER, XMLTestRunner +try: + from tests.support.ext import console + WIDTH, HEIGHT = console.getTerminalSize() + PNUM = WIDTH +except Exception: # pylint: disable=broad-except + PNUM = 70 + +# This is a completely random and meaningful number intended to identify our +# own signal triggering. +WEIRD_SIGNAL_NUM = -45654 + + +# Let's setup a global exception hook handler which will log all exceptions +# Store a reference to the original handler +__GLOBAL_EXCEPTION_HANDLER = sys.excepthook + + +def __global_logging_exception_handler(exc_type, exc_value, exc_traceback): + ''' + This function will log all python exceptions. + ''' + # Log the exception + logging.getLogger(__name__).error( + 'An un-handled exception was caught by salt-testing\'s global ' + 'exception handler:\n{0}: {1}\n{2}'.format( + exc_type.__name__, + exc_value, + ''.join(traceback.format_exception( + exc_type, exc_value, exc_traceback + )).strip() + ) + ) + # Call the original sys.excepthook + __GLOBAL_EXCEPTION_HANDLER(exc_type, exc_value, exc_traceback) + + +# Set our own exception handler as the one to use +sys.excepthook = __global_logging_exception_handler + + +def print_header(header, sep='~', top=True, bottom=True, inline=False, + centered=False, width=PNUM): + ''' + Allows some pretty printing of headers on the console, either with a + "ruler" on bottom and/or top, inline, centered, etc. + ''' + if top and not inline: + print(sep * width) + + if centered and not inline: + fmt = u'{0:^{width}}' + elif inline and not centered: + fmt = u'{0:{sep}<{width}}' + elif inline and centered: + fmt = u'{0:{sep}^{width}}' + else: + fmt = u'{0}' + print(fmt.format(header, sep=sep, width=width)) + + if bottom and not inline: + print(sep * width) + + +class SaltTestingParser(optparse.OptionParser): + support_docker_execution = False + support_destructive_tests_selection = False + support_expensive_tests_selection = False + source_code_basedir = None + + _known_interpreters = { + 'salttest/arch': 'python2', + 'salttest/centos-5': 'python2.6', + 'salttest/centos-6': 'python2.6', + 'salttest/debian-7': 'python2.7', + 'salttest/opensuse-12.3': 'python2.7', + 'salttest/ubuntu-12.04': 'python2.7', + 'salttest/ubuntu-12.10': 'python2.7', + 'salttest/ubuntu-13.04': 'python2.7', + 'salttest/ubuntu-13.10': 'python2.7', + 'salttest/py3': 'python3' + } + + def __init__(self, testsuite_directory, *args, **kwargs): + if kwargs.pop('html_output_from_env', None) is not None or \ + kwargs.pop('html_output_dir', None) is not None: + warnings.warn( + 'The unit tests HTML support was removed from {0}. Please ' + 'stop passing \'html_output_dir\' or \'html_output_from_env\' ' + 'as arguments to {0}'.format(self.__class__.__name__), + category=DeprecationWarning, + stacklevel=2 + ) + + # Get XML output settings + xml_output_dir_env_var = kwargs.pop( + 'xml_output_from_env', + 'XML_TESTS_OUTPUT_DIR' + ) + xml_output_dir = kwargs.pop('xml_output_dir', None) + + if xml_output_dir_env_var in os.environ: + xml_output_dir = os.environ.get(xml_output_dir_env_var) + if not xml_output_dir: + xml_output_dir = os.path.join( + tempfile.gettempdir() if platform.system() != 'Darwin' else '/tmp', + 'xml-tests-output' + ) + self.xml_output_dir = xml_output_dir + + # Get the desired logfile to use while running tests + self.tests_logfile = kwargs.pop('tests_logfile', None) + + optparse.OptionParser.__init__(self, *args, **kwargs) + self.testsuite_directory = testsuite_directory + self.testsuite_results = [] + + self.test_selection_group = optparse.OptionGroup( + self, + 'Tests Selection Options', + 'Select which tests are to be executed' + ) + if self.support_destructive_tests_selection is True: + self.test_selection_group.add_option( + '--run-destructive', + action='store_true', + default=False, + help=('Run destructive tests. These tests can include adding ' + 'or removing users from your system for example. ' + 'Default: %default') + ) + if self.support_expensive_tests_selection is True: + self.test_selection_group.add_option( + '--run-expensive', + action='store_true', + default=False, + help=('Run expensive tests. Expensive tests are any tests that, ' + 'once configured, cost money to run, such as creating or ' + 'destroying cloud instances on a cloud provider.') + ) + + self.test_selection_group.add_option( + '-n', + '--name', + dest='name', + action='append', + default=None, + help=('Specific test name to run. A named test is the module path ' + 'relative to the tests directory') + ) + self.test_selection_group.add_option( + '--names-file', + dest='names_file', + default=None, + help=('The location of a newline delimited file of test names to ' + 'run') + ) + self.add_option_group(self.test_selection_group) + + if self.support_docker_execution is True: + self.docked_selection_group = optparse.OptionGroup( + self, + 'Docked Tests Execution', + 'Run the tests suite under a Docker container. This allows, ' + 'for example, to run destructive tests on your machine ' + 'without actually breaking it in any way.' + ) + self.docked_selection_group.add_option( + '--docked', + default=None, + metavar='CONTAINER', + help='Run the tests suite in the chosen Docker container' + ) + self.docked_selection_group.add_option( + '--docked-interpreter', + default=None, + metavar='PYTHON_INTERPRETER', + help='The python binary name to use when calling the tests ' + 'suite.' + ) + self.docked_selection_group.add_option( + '--docked-skip-delete', + default=False, + action='store_true', + help='Skip docker container deletion on exit. Default: False' + ) + self.docked_selection_group.add_option( + '--docked-skip-delete-on-errors', + default=False, + action='store_true', + help='Skip docker container deletion on exit if errors ' + 'occurred. Default: False' + ) + self.docked_selection_group.add_option( + '--docker-binary', + help='The docker binary on the host system. Default: %default', + default='/usr/bin/docker', + ) + self.add_option_group(self.docked_selection_group) + + self.output_options_group = optparse.OptionGroup( + self, 'Output Options' + ) + self.output_options_group.add_option( + '-v', + '--verbose', + dest='verbosity', + default=1, + action='count', + help='Verbose test runner output' + ) + self.output_options_group.add_option( + '--output-columns', + default=PNUM, + type=int, + help='Number of maximum columns to use on the output' + ) + self.output_options_group.add_option( + '--tests-logfile', + default=self.tests_logfile, + help='The path to the tests suite logging logfile' + ) + if self.xml_output_dir is not None: + self.output_options_group.add_option( + '-x', + '--xml', + '--xml-out', + dest='xml_out', + default=False, + help='XML test runner output(Output directory: {0})'.format( + self.xml_output_dir + ) + ) + self.output_options_group.add_option( + '--no-report', + default=False, + action='store_true', + help='Do NOT show the overall tests result' + ) + self.add_option_group(self.output_options_group) + + self.fs_cleanup_options_group = optparse.OptionGroup( + self, 'File system cleanup Options' + ) + self.fs_cleanup_options_group.add_option( + '--clean', + dest='clean', + default=True, + action='store_true', + help=('Clean up test environment before and after running the ' + 'tests suite (default behaviour)') + ) + self.fs_cleanup_options_group.add_option( + '--no-clean', + dest='clean', + action='store_false', + help=('Don\'t clean up test environment before and after the ' + 'tests suite execution (speed up test process)') + ) + self.add_option_group(self.fs_cleanup_options_group) + self.setup_additional_options() + + def parse_args(self, args=None, values=None): + self.options, self.args = optparse.OptionParser.parse_args(self, args, values) + if self.options.names_file: + with open(self.options.names_file, 'rb') as fp_: + lines = [] + for line in fp_.readlines(): + lines.append(line.strip()) + if self.options.name: + self.options.name.extend(lines) + else: + self.options.name = lines + + print_header(u'', inline=True, width=self.options.output_columns) + self.pre_execution_cleanup() + + if self.support_docker_execution and self.options.docked is not None: + if self.source_code_basedir is None: + raise RuntimeError( + 'You need to define the \'source_code_basedir\' attribute ' + 'in {0!r}.'.format(self.__class__.__name__) + ) + + if '/' not in self.options.docked: + self.options.docked = 'salttest/{0}'.format( + self.options.docked + ) + + if self.options.docked_interpreter is None: + self.options.docked_interpreter = self._known_interpreters.get( + self.options.docked, 'python' + ) + + # No more processing should be done. We'll exit with the return + # code we get from the docker container execution + self.exit(self.run_suite_in_docker()) + + # Validate options after checking that we're not goint to execute the + # tests suite under a docker container + self._validate_options() + + print(' * Current Directory: {0}'.format(os.getcwd())) + print(' * Test suite is running under PID {0}'.format(os.getpid())) + + self._setup_logging() + try: + return (self.options, self.args) + finally: + print_header(u'', inline=True, width=self.options.output_columns) + + def setup_additional_options(self): + ''' + Subclasses should add additional options in this overridden method + ''' + + def _validate_options(self): + ''' + Validate the default available options + ''' + if self.xml_output_dir is not None and self.options.xml_out and HAS_XMLRUNNER is False: + self.error( + '\'--xml\' is not available. The xmlrunner library is not ' + 'installed.' + ) + + if self.options.xml_out: + # Override any environment setting with the passed value + self.xml_output_dir = self.options.xml_out + + if self.xml_output_dir is not None and self.options.xml_out: + if not os.path.isdir(self.xml_output_dir): + os.makedirs(self.xml_output_dir) + print( + ' * Generated unit test XML reports will be stored ' + 'at {0!r}'.format(self.xml_output_dir) + ) + + self.validate_options() + + if self.support_destructive_tests_selection: + # Set the required environment variable in order to know if + # destructive tests should be executed or not. + os.environ['DESTRUCTIVE_TESTS'] = str(self.options.run_destructive) + + if self.support_expensive_tests_selection: + # Set the required environment variable in order to know if + # expensive tests should be executed or not. + os.environ['EXPENSIVE_TESTS'] = str(self.options.run_expensive) + + def validate_options(self): + ''' + Validate the provided options. Override this method to run your own + validation procedures. + ''' + + def _setup_logging(self): + ''' + Setup python's logging system to work with/for the tests suite + ''' + # Setup tests logging + formatter = logging.Formatter( + '%(asctime)s,%(msecs)03.0f [%(name)-5s:%(lineno)-4d]' + '[%(levelname)-8s] %(message)s', + datefmt='%H:%M:%S' + ) + if not hasattr(logging, 'TRACE'): + logging.TRACE = 5 + logging.addLevelName(logging.TRACE, 'TRACE') + if not hasattr(logging, 'GARBAGE'): + logging.GARBAGE = 1 + logging.addLevelName(logging.GARBAGE, 'GARBAGE') + + # Default logging level: ERROR + logging.root.setLevel(logging.NOTSET) + + if self.options.tests_logfile: + filehandler = logging.FileHandler( + mode='w', # Not preserved between re-runs + filename=self.options.tests_logfile + ) + # The logs of the file are the most verbose possible + filehandler.setLevel(logging.DEBUG) + filehandler.setFormatter(formatter) + logging.root.addHandler(filehandler) + + print(' * Logging tests on {0}'.format(self.options.tests_logfile)) + + # With greater verbosity we can also log to the console + if self.options.verbosity >= 2: + consolehandler = logging.StreamHandler(sys.stderr) + consolehandler.setFormatter(formatter) + if self.options.verbosity >= 6: # -vvvvv + logging_level = logging.GARBAGE + elif self.options.verbosity == 5: # -vvvv + logging_level = logging.TRACE + elif self.options.verbosity == 4: # -vvv + logging_level = logging.DEBUG + print('DEBUG') + elif self.options.verbosity == 3: # -vv + print('INFO') + logging_level = logging.INFO + else: + logging_level = logging.ERROR + consolehandler.setLevel(logging_level) + logging.root.addHandler(consolehandler) + logging.getLogger(__name__).info('Runtests logging has been setup') + + def pre_execution_cleanup(self): + ''' + Run any initial clean up operations. If sub-classed, don't forget to + call SaltTestingParser.pre_execution_cleanup(self) from the overridden + method. + ''' + if self.options.clean is True: + for path in (self.xml_output_dir,): + if path is None: + continue + if os.path.isdir(path): + shutil.rmtree(path) + + def run_suite(self, path, display_name, suffix='test_*.py', + load_from_name=False, additional_test_dirs=None): + ''' + Execute a unit test suite + ''' + loaded_custom = False + loader = TestLoader() + try: + if load_from_name: + tests = loader.loadTestsFromName(display_name) + else: + if additional_test_dirs is None or self.testsuite_directory.startswith(path): + tests = loader.discover(path, suffix, self.testsuite_directory) + else: + tests = loader.discover(path, suffix) + loaded_custom = True + except (AttributeError, ImportError): + print('Could not locate test \'{0}\'. Exiting.'.format(display_name)) + sys.exit(1) + + if additional_test_dirs and not loaded_custom: + for test_dir in additional_test_dirs: + additional_tests = loader.discover(test_dir, suffix, test_dir) + tests.addTests(additional_tests) + + header = '{0} Tests'.format(display_name) + print_header('Starting {0}'.format(header), + width=self.options.output_columns) + + if self.options.xml_out: + runner = XMLTestRunner( + stream=sys.stdout, + output=self.xml_output_dir, + verbosity=self.options.verbosity + ).run(tests) + self.testsuite_results.append((header, runner)) + else: + runner = TextTestRunner( + stream=sys.stdout, + verbosity=self.options.verbosity).run(tests) + self.testsuite_results.append((header, runner)) + return runner.wasSuccessful() + + def print_overall_testsuite_report(self): + ''' + Print a nicely formatted report about the test suite results + ''' + print() + print_header( + u' Overall Tests Report ', sep=u'=', centered=True, inline=True, + width=self.options.output_columns + ) + + failures = errors = skipped = passed = 0 + no_problems_found = True + for (name, results) in self.testsuite_results: + failures += len(results.failures) + errors += len(results.errors) + skipped += len(results.skipped) + passed += results.testsRun - len( + results.failures + results.errors + results.skipped + ) + + if not results.failures and not results.errors and \ + not results.skipped: + continue + + no_problems_found = False + + print_header( + u'*** {0} '.format(name), sep=u'*', inline=True, + width=self.options.output_columns + ) + if results.skipped: + print_header( + u' -------- Skipped Tests ', sep='-', inline=True, + width=self.options.output_columns + ) + maxlen = len( + max([testcase.id() for (testcase, reason) in + results.skipped], key=len) + ) + fmt = u' -> {0: <{maxlen}} -> {1}' + for testcase, reason in results.skipped: + print(fmt.format(testcase.id(), reason, maxlen=maxlen)) + print_header(u' ', sep='-', inline=True, + width=self.options.output_columns) + + if results.errors: + print_header( + u' -------- Tests with Errors ', sep='-', inline=True, + width=self.options.output_columns + ) + for testcase, reason in results.errors: + print_header( + u' -> {0} '.format(testcase.id()), + sep=u'.', inline=True, + width=self.options.output_columns + ) + for line in reason.rstrip().splitlines(): + print(' {0}'.format(line.rstrip())) + print_header(u' ', sep=u'.', inline=True, + width=self.options.output_columns) + print_header(u' ', sep='-', inline=True, + width=self.options.output_columns) + + if results.failures: + print_header( + u' -------- Failed Tests ', sep='-', inline=True, + width=self.options.output_columns + ) + for testcase, reason in results.failures: + print_header( + u' -> {0} '.format(testcase.id()), + sep=u'.', inline=True, + width=self.options.output_columns + ) + for line in reason.rstrip().splitlines(): + print(' {0}'.format(line.rstrip())) + print_header(u' ', sep=u'.', inline=True, + width=self.options.output_columns) + print_header(u' ', sep='-', inline=True, + width=self.options.output_columns) + + if no_problems_found: + print_header( + u'*** No Problems Found While Running Tests ', + sep=u'*', inline=True, width=self.options.output_columns + ) + + print_header(u'', sep=u'=', inline=True, + width=self.options.output_columns) + total = sum([passed, skipped, errors, failures]) + print( + '{0} (total={1}, skipped={2}, passed={3}, failures={4}, ' + 'errors={5}) '.format( + (errors or failures) and 'FAILED' or 'OK', + total, skipped, passed, failures, errors + ) + ) + print_header( + ' Overall Tests Report ', sep='=', centered=True, inline=True, + width=self.options.output_columns + ) + + def post_execution_cleanup(self): + ''' + Run any final clean-up operations. If sub-classed, don't forget to + call SaltTestingParser.post_execution_cleanup(self) from the overridden + method. + ''' + + def finalize(self, exit_code=0): + ''' + Run the finalization procedures. Show report, clean-up file-system, etc + ''' + if self.options.no_report is False: + self.print_overall_testsuite_report() + self.post_execution_cleanup() + # Brute force approach to terminate this process and it's children + logging.getLogger(__name__).info('Terminating test suite child processes.') + helpers.terminate_process_pid(os.getpid(), only_children=True) + logging.getLogger(__name__).info('Terminating test suite child processes if any are still found running.') + helpers.terminate_process_pid(os.getpid(), only_children=True) + logging.getLogger(__name__).info( + 'Test suite execution finalized with exit code: {0}'.format( + exit_code + ) + ) + self.exit(exit_code) + + def run_suite_in_docker(self): + ''' + Run the tests suite in a Docker container + ''' + def stop_running_docked_container(cid, signum=None, frame=None): + # Allow some time for the container to stop if it's going to be + # stopped by docker or any signals docker might have received + time.sleep(0.5) + + print_header('', inline=True, width=self.options.output_columns) + + # Let's check if, in fact, the container is stopped + scode_call = subprocess.Popen( + [self.options.docker_binary, 'inspect', '--format={{.State.Running}}', cid], + env=os.environ.copy(), + close_fds=True, + stdout=subprocess.PIPE + ) + scode_call.wait() + parsed_scode = scode_call.stdout.read().strip() + if six.PY3: + parsed_scode = parsed_scode.decode(__salt_system_encoding__) + if parsed_scode != 'false': + # If the container is still running, let's make sure it + # properly stops + sys.stdout.write(' * Making sure the container is stopped. CID: ') + sys.stdout.flush() + + stop_call = subprocess.Popen( + [self.options.docker_binary, 'stop', '--time=15', cid], + env=os.environ.copy(), + close_fds=True, + stdout=subprocess.PIPE + ) + stop_call.wait() + output = stop_call.stdout.read().strip() + if six.PY3: + output = output.decode(__salt_system_encoding__) + print(output) + sys.stdout.flush() + time.sleep(0.5) + + # Let's get the container's exit code. We can't trust on Popen's + # returncode because it's not reporting the proper one? Still + # haven't narrowed it down why. + sys.stdout.write(' * Container exit code: ') + sys.stdout.flush() + rcode_call = subprocess.Popen( + [self.options.docker_binary, 'inspect', '--format={{.State.ExitCode}}', cid], + env=os.environ.copy(), + close_fds=True, + stdout=subprocess.PIPE + ) + rcode_call.wait() + parsed_rcode = rcode_call.stdout.read().strip() + if six.PY3: + parsed_rcode = parsed_rcode.decode(__salt_system_encoding__) + try: + returncode = int(parsed_rcode) + except ValueError: + returncode = -1 + print(parsed_rcode) + sys.stdout.flush() + + if self.options.docked_skip_delete is False and \ + (self.options.docked_skip_delete_on_errors is False or + (self.options.docked_skip_delete_on_error and returncode == 0)): + sys.stdout.write(' * Cleaning Up Temporary Docker Container. CID: ') + sys.stdout.flush() + cleanup_call = subprocess.Popen( + [self.options.docker_binary, 'rm', cid], + env=os.environ.copy(), + close_fds=True, + stdout=subprocess.PIPE + ) + cleanup_call.wait() + output = cleanup_call.stdout.read().strip() + if six.PY3: + output = output.decode(__salt_system_encoding__) + print(output) + + if 'DOCKER_CIDFILE' not in os.environ: + # The CID file was not created "from the outside", so delete it + os.unlink(cidfile) + + print_header('', inline=True, width=self.options.output_columns) + # Finally, EXIT! + sys.exit(returncode) + + # Let's start the Docker container and run the tests suite there + if '/' not in self.options.docked: + container = 'salttest/{0}'.format(self.options.docked) + else: + container = self.options.docked + + calling_args = [self.options.docked_interpreter, + '/salt-source/tests/runtests.py'] + for option in self._get_all_options(): + if option.dest is None: + # For example --version + continue + + if option.dest and (option.dest in ('verbosity',) or + option.dest.startswith('docked')): + # We don't need to pass any docker related arguments inside the + # container, and verbose will be handled bellow + continue + + default = self.defaults.get(option.dest) + value = getattr(self.options, option.dest, default) + + if default == value: + # This is the default value, no need to pass the option to the + # parser + continue + + if option.action.startswith('store_'): + calling_args.append(option.get_opt_string()) + + elif option.action == 'append': + for val in (value is not None and value or default): + calling_args.extend([option.get_opt_string(), str(val)]) + elif option.action == 'count': + calling_args.extend([option.get_opt_string()] * value) + else: + calling_args.extend( + [option.get_opt_string(), + str(value is not None and value or default)] + ) + + if not self.options.run_destructive: + calling_args.append('--run-destructive') + + if self.options.verbosity > 1: + calling_args.append( + '-{0}'.format('v' * (self.options.verbosity - 1)) + ) + + sys.stdout.write(' * Docker command: {0}\n'.format(' '.join(calling_args))) + sys.stdout.write(' * Running the tests suite under the {0!r} docker ' + 'container. CID: '.format(container)) + sys.stdout.flush() + + cidfile = os.environ.get( + 'DOCKER_CIDFILE', + tempfile.mktemp(prefix='docked-testsuite-', suffix='.cid') + ) + call = subprocess.Popen( + [self.options.docker_binary, + 'run', + # '--rm=true', Do not remove the container automatically, we need + # to get information back, even for stopped containers + '--tty', + '--interactive', + '-v', + '{0}:/salt-source'.format(self.source_code_basedir), + '-w', + '/salt-source', + '-e', + 'SHELL=/bin/sh', + '-e', + 'COLUMNS={0}'.format(WIDTH), + '-e', + 'LINES={0}'.format(HEIGHT), + '--cidfile={0}'.format(cidfile), + container, + # We need to pass the runtests.py arguments as a single string so + # that the start-me-up.sh script can handle them properly + ' '.join(calling_args), + ], + env=os.environ.copy(), + close_fds=True, + ) + + cid = None + cid_printed = terminating = exiting = False + signal_handler_installed = signalled = False + + time.sleep(0.25) + + while True: + try: + time.sleep(0.15) + if cid_printed is False: + with closing(open(cidfile)) as cidfile_fd: + cid = cidfile_fd.read() + if cid: + print(cid) + sys.stdout.flush() + cid_printed = True + # Install our signal handler to properly shutdown + # the docker container + for sig in (signal.SIGTERM, signal.SIGINT, + signal.SIGHUP, signal.SIGQUIT): + signal.signal( + sig, + partial(stop_running_docked_container, cid) + ) + signal_handler_installed = True + + if exiting: + break + elif terminating and not exiting: + exiting = True + call.kill() + break + elif signalled and not terminating: + terminating = True + call.terminate() + else: + call.poll() + if call.returncode is not None: + # Finished + break + except KeyboardInterrupt: + print('Caught CTRL-C, exiting...') + signalled = True + call.send_signal(signal.SIGINT) + + call.wait() + time.sleep(0.25) + + # Finish up + if signal_handler_installed: + stop_running_docked_container( + cid, + signum=(signal.SIGINT if signalled else WEIRD_SIGNAL_NUM) + ) + else: + sys.exit(call.returncode) + + +class SaltTestcaseParser(SaltTestingParser): + ''' + Option parser to run one or more ``unittest.case.TestCase``, ie, no + discovery involved. + ''' + def __init__(self, *args, **kwargs): + SaltTestingParser.__init__(self, None, *args, **kwargs) + self.usage = '%prog [options]' + self.option_groups.remove(self.test_selection_group) + if self.has_option('--xml-out'): + self.remove_option('--xml-out') + + def get_prog_name(self): + return '{0} {1}'.format(sys.executable.split(os.sep)[-1], sys.argv[0]) + + def run_testcase(self, testcase): + ''' + Run one or more ``unittest.case.TestCase`` + ''' + header = '' + loader = TestLoader() + if isinstance(testcase, list): + for case in testcase: + tests = loader.loadTestsFromTestCase(case) + else: + tests = loader.loadTestsFromTestCase(testcase) + + if not isinstance(testcase, list): + header = '{0} Tests'.format(testcase.__name__) + print_header('Starting {0}'.format(header), + width=self.options.output_columns) + + runner = TextTestRunner( + verbosity=self.options.verbosity).run(tests) + self.testsuite_results.append((header, runner)) + return runner.wasSuccessful() diff --git a/tests/support/parser/cover.py b/tests/support/parser/cover.py new file mode 100644 index 0000000000..868dabad9a --- /dev/null +++ b/tests/support/parser/cover.py @@ -0,0 +1,236 @@ +# -*- coding: utf-8 -*- +''' + tests.support.parser.cover + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Code coverage aware testing parser + + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + :copyright: © 2013 by the SaltStack Team, see AUTHORS for more details. + :license: Apache 2.0, see LICENSE for more details. +''' +# pylint: disable=repr-flag-used-in-string + +# Import python libs +from __future__ import absolute_import, print_function +import os +import re +import sys +import json +import shutil +import warnings + +# Import salt testing libs +from tests.support.parser import SaltTestingParser + +# Import coverage libs +try: + import coverage + COVERAGE_AVAILABLE = True +except ImportError: + COVERAGE_AVAILABLE = False + +try: + import multiprocessing.util + # Force forked multiprocessing processes to be measured as well + + def multiprocessing_stop(coverage_object): + ''' + Save the multiprocessing process coverage object + ''' + coverage_object.stop() + coverage_object.save() + + def multiprocessing_start(obj): + coverage_options = json.loads(os.environ.get('COVERAGE_OPTIONS', '{}')) + if not coverage_options: + return + + if coverage_options.get('data_suffix', False) is False: + return + + coverage_object = coverage.coverage(**coverage_options) + coverage_object.start() + + multiprocessing.util.Finalize( + None, + multiprocessing_stop, + args=(coverage_object,), + exitpriority=1000 + ) + + if COVERAGE_AVAILABLE: + multiprocessing.util.register_after_fork( + multiprocessing_start, + multiprocessing_start + ) +except ImportError: + pass + +if COVERAGE_AVAILABLE: + # Cover any processes if the environ variables are present + coverage.process_startup() + + +class SaltCoverageTestingParser(SaltTestingParser): + ''' + Code coverage aware testing option parser + ''' + def __init__(self, *args, **kwargs): + if kwargs.pop('html_output_from_env', None) is not None or \ + kwargs.pop('html_output_dir', None) is not None: + warnings.warn( + 'The unit tests HTML support was removed from {0}. Please ' + 'stop passing \'html_output_dir\' or \'html_output_from_env\' ' + 'as arguments to {0}'.format(self.__class__.__name__), + category=DeprecationWarning, + stacklevel=2 + ) + + SaltTestingParser.__init__(self, *args, **kwargs) + self.code_coverage = None + + # Add the coverage related options + self.output_options_group.add_option( + '--coverage', + default=False, + action='store_true', + help='Run tests and report code coverage' + ) + self.output_options_group.add_option( + '--no-processes-coverage', + default=False, + action='store_true', + help='Do not track subprocess and/or multiprocessing processes' + ) + self.output_options_group.add_option( + '--coverage-xml', + default=None, + help='If provided, the path to where a XML report of the code ' + 'coverage will be written to' + ) + self.output_options_group.add_option( + '--coverage-html', + default=None, + help=('The directory where the generated HTML coverage report ' + 'will be saved to. The directory, if existing, will be ' + 'deleted before the report is generated.') + ) + + def _validate_options(self): + if (self.options.coverage_xml or self.options.coverage_html) and \ + not self.options.coverage: + self.options.coverage = True + + if self.options.coverage is True and COVERAGE_AVAILABLE is False: + self.error( + 'Cannot run tests with coverage report. ' + 'Please install coverage>=3.5.3' + ) + + if self.options.coverage is True: + coverage_version = tuple([ + int(part) for part in re.search( + r'([0-9.]+)', coverage.__version__).group(0).split('.') + ]) + if coverage_version < (3, 5, 3): + # Should we just print the error instead of exiting? + self.error( + 'Versions lower than 3.5.3 of the coverage library are ' + 'know to produce incorrect results. Please consider ' + 'upgrading...' + ) + SaltTestingParser._validate_options(self) + + def pre_execution_cleanup(self): + if self.options.coverage_html is not None: + if os.path.isdir(self.options.coverage_html): + shutil.rmtree(self.options.coverage_html) + if self.options.coverage_xml is not None: + if os.path.isfile(self.options.coverage_xml): + os.unlink(self.options.coverage_xml) + SaltTestingParser.pre_execution_cleanup(self) + + def start_coverage(self, **coverage_options): + ''' + Start code coverage. + + You can pass any coverage options as keyword arguments. For the + available options please see: + http://nedbatchelder.com/code/coverage/api.html + ''' + if self.options.coverage is False: + return + + if coverage_options.pop('track_processes', None) is not None: + raise RuntimeWarning( + 'Please stop passing \'track_processes\' to ' + '\'start_coverage()\'. It\'s now the default and ' + '\'--no-processes-coverage\' was added to the parser to ' + 'disable it.' + ) + print(' * Starting Coverage') + + if self.options.no_processes_coverage is False: + # Update environ so that any subprocess started on tests are also + # included in the report + coverage_options['data_suffix'] = True + os.environ['COVERAGE_PROCESS_START'] = '1' + os.environ['COVERAGE_OPTIONS'] = json.dumps(coverage_options) + + # Setup coverage + self.code_coverage = coverage.coverage(**coverage_options) + self.code_coverage.start() + + def stop_coverage(self, save_coverage=True): + ''' + Stop code coverage. + ''' + if self.options.coverage is False: + return + + # Clean up environment + os.environ.pop('COVERAGE_OPTIONS', None) + os.environ.pop('COVERAGE_PROCESS_START', None) + + print(' * Stopping coverage') + self.code_coverage.stop() + if save_coverage: + print(' * Saving coverage info') + self.code_coverage.save() + + if self.options.no_processes_coverage is False: + # Combine any multiprocessing coverage data files + sys.stdout.write(' * Combining multiple coverage info files ... ') + sys.stdout.flush() + self.code_coverage.combine() + print('Done.') + + if self.options.coverage_xml is not None: + sys.stdout.write( + ' * Generating Coverage XML Report At {0!r} ... '.format( + self.options.coverage_xml + ) + ) + sys.stdout.flush() + self.code_coverage.xml_report( + outfile=self.options.coverage_xml + ) + print('Done.') + + if self.options.coverage_html is not None: + sys.stdout.write( + ' * Generating Coverage HTML Report Under {0!r} ... '.format( + self.options.coverage_html + ) + ) + sys.stdout.flush() + self.code_coverage.html_report( + directory=self.options.coverage_html + ) + print('Done.') + + def finalize(self, exit_code=0): + if self.options.coverage is True: + self.stop_coverage(save_coverage=True) + SaltTestingParser.finalize(self, exit_code) diff --git a/tests/support/runtests.py b/tests/support/runtests.py new file mode 100644 index 0000000000..add3104400 --- /dev/null +++ b/tests/support/runtests.py @@ -0,0 +1,212 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + + .. _runtime_vars: + + Runtime Variables + ----------------- + + :command:`salt-runtests` provides a variable, :py:attr:`RUNTIME_VARS` which has some common paths defined at + startup: + + .. autoattribute:: tests.support.runtests.RUNTIME_VARS + :annotation: + + :TMP: Tests suite temporary directory + :TMP_CONF_DIR: Configuration directory from where the daemons that :command:`salt-runtests` starts get their + configuration files. + :TMP_CONF_MASTER_INCLUDES: Salt Master configuration files includes directory. See + :salt_conf_master:`default_include`. + :TMP_CONF_MINION_INCLUDES: Salt Minion configuration files includes directory. Seei + :salt_conf_minion:`include`. + :TMP_CONF_CLOUD_INCLUDES: Salt cloud configuration files includes directory. The same as the salt master and + minion includes configuration, though under a different directory name. + :TMP_CONF_CLOUD_PROFILE_INCLUDES: Salt cloud profiles configuration files includes directory. Same as above. + :TMP_CONF_CLOUD_PROVIDER_INCLUDES: Salt cloud providers configuration files includes directory. Same as above. + :TMP_SCRIPT_DIR: Temporary scripts directory from where the Salt CLI tools will be called when running tests. + :TMP_SALT_INTEGRATION_FILES: Temporary directory from where Salt's test suite integration files are copied to. + :TMP_BASEENV_STATE_TREE: Salt master's **base** environment state tree directory + :TMP_PRODENV_STATE_TREE: Salt master's **production** environment state tree directory + :TMP_BASEENV_PILLAR_TREE: Salt master's **base** environment pillar tree directory + :TMP_PRODENV_PILLAR_TREE: Salt master's **production** environment pillar tree directory + + + Use it on your test case in case of need. As simple as: + + .. code-block:: python + + import os + from tests.support.runtests import RUNTIME_VARS + + # Path to the testing minion configuration file + minion_config_path = os.path.join(RUNTIME_VARS.TMP_CONF_DIR, 'minion') + + .. _`pytest`: http://pytest.org + .. _`nose`: https://nose.readthedocs.org + ''' + +# Import Python modules +from __future__ import absolute_import, print_function +import os +import json +import shutil +import logging +import platform +import tempfile +import multiprocessing + +# Import 3rd-party libs +import salt.ext.six as six +try: + import coverage # pylint: disable=import-error + HAS_COVERAGE = True +except ImportError: + HAS_COVERAGE = False + +try: + import multiprocessing.util + # Force forked multiprocessing processes to be measured as well + + def multiprocessing_stop(coverage_object): + ''' + Save the multiprocessing process coverage object + ''' + coverage_object.stop() + coverage_object.save() + + def multiprocessing_start(obj): + coverage_options = json.loads(os.environ.get('SALT_RUNTESTS_COVERAGE_OPTIONS', '{}')) + if not coverage_options: + return + + if coverage_options.get('data_suffix', False) is False: + return + + coverage_object = coverage.coverage(**coverage_options) + coverage_object.start() + + multiprocessing.util.Finalize( + None, + multiprocessing_stop, + args=(coverage_object,), + exitpriority=1000 + ) + + if HAS_COVERAGE: + multiprocessing.util.register_after_fork( + multiprocessing_start, + multiprocessing_start + ) +except ImportError: + pass + +log = logging.getLogger(__name__) + + +class RootsDict(dict): + def merge(self, data): + for key, values in six.iteritems(data): + if key not in self: + self[key] = values + continue + for value in values: + if value not in self[key]: + self[key].append(value) + return self + + def to_dict(self): + return dict(self) + + +def recursive_copytree(source, destination, overwrite=False): + for root, dirs, files in os.walk(source): + for item in dirs: + src_path = os.path.join(root, item) + dst_path = os.path.join(destination, src_path.replace(source, '').lstrip(os.sep)) + if not os.path.exists(dst_path): + log.debug('Creating directory: {0}'.format(dst_path)) + os.makedirs(dst_path) + for item in files: + src_path = os.path.join(root, item) + dst_path = os.path.join(destination, src_path.replace(source, '').lstrip(os.sep)) + if os.path.exists(dst_path) and not overwrite: + if os.stat(src_path).st_mtime > os.stat(dst_path).st_mtime: + log.debug('Copying {0} to {1}'.format(src_path, dst_path)) + shutil.copy2(src_path, dst_path) + else: + if not os.path.isdir(os.path.dirname(dst_path)): + log.debug('Creating directory: {0}'.format(os.path.dirname(dst_path))) + os.makedirs(os.path.dirname(dst_path)) + log.debug('Copying {0} to {1}'.format(src_path, dst_path)) + shutil.copy2(src_path, dst_path) + + +class RuntimeVars(object): + + __self_attributes__ = ('_vars', '_locked', 'lock') + + def __init__(self, **kwargs): + self._vars = kwargs + self._locked = False + + def lock(self): + # Late import + from salt.utils.immutabletypes import freeze + frozen_vars = freeze(self._vars.copy()) + self._vars = frozen_vars + self._locked = True + + def __iter__(self): + for name, value in six.iteritems(self._vars): + yield name, value + + def __getattribute__(self, name): + if name in object.__getattribute__(self, '_vars'): + return object.__getattribute__(self, '_vars')[name] + return object.__getattribute__(self, name) + + def __setattr__(self, name, value): + if getattr(self, '_locked', False) is True: + raise RuntimeError( + 'After {0} is locked, no additional data can be added to it'.format( + self.__class__.__name__ + ) + ) + if name in object.__getattribute__(self, '__self_attributes__'): + object.__setattr__(self, name, value) + return + self._vars[name] = value +# <---- Helper Methods ----------------------------------------------------------------------------------------------- + +# ----- Global Variables --------------------------------------------------------------------------------------------> +CONF_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), '_saltconf') +SYS_TMP_DIR = os.path.realpath( + # Avoid ${TMPDIR} and gettempdir() on MacOS as they yield a base path too long for unix sockets: + # 'error: AF_UNIX path too long' + # Gentoo Portage prefers ebuild tests are rooted in ${TMPDIR} + os.environ.get('TMPDIR', tempfile.gettempdir()) if platform.system() != 'Darwin' else '/tmp' +) +__TMP = os.path.join(SYS_TMP_DIR, 'salt-tests-tmpdir') +XML_OUTPUT_DIR = os.environ.get('SALT_XML_TEST_REPORTS_DIR', os.path.join(__TMP, 'xml-test-reports')) +# <---- Global Variables --------------------------------------------------------------------------------------------- + + +# ----- Tests Runtime Variables -------------------------------------------------------------------------------------> + +RUNTIME_VARS = RuntimeVars( + TMP=__TMP, + TMP_CONF_DIR=os.path.join(__TMP, 'conf'), + TMP_CONF_MASTER_INCLUDES=os.path.join(__TMP, 'conf', 'master.d'), + TMP_CONF_MINION_INCLUDES=os.path.join(__TMP, 'conf', 'minion.d'), + TMP_CONF_CLOUD_INCLUDES=os.path.join(__TMP, 'conf', 'cloud.conf.d'), + TMP_CONF_CLOUD_PROFILE_INCLUDES=os.path.join(__TMP, 'conf', 'cloud.profiles.d'), + TMP_CONF_CLOUD_PROVIDER_INCLUDES=os.path.join(__TMP, 'conf', 'cloud.providers.d'), + TMP_SCRIPT_DIR=os.path.join(__TMP, 'scripts'), + TMP_SALT_INTEGRATION_FILES=os.path.join(__TMP, 'integration-files'), + TMP_BASEENV_STATE_TREE=os.path.join(__TMP, 'integration-files', 'file', 'base'), + TMP_PRODENV_STATE_TREE=os.path.join(__TMP, 'integration-files', 'file', 'prod'), + TMP_BASEENV_PILLAR_TREE=os.path.join(__TMP, 'integration-files', 'pillar', 'base'), + TMP_PRODENV_PILLAR_TREE=os.path.join(__TMP, 'integration-files', 'pillar', 'prod') +) +# <---- Tests Runtime Variables -------------------------------------------------------------------------------------- diff --git a/tests/support/unit.py b/tests/support/unit.py new file mode 100644 index 0000000000..24101b680b --- /dev/null +++ b/tests/support/unit.py @@ -0,0 +1,243 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + + + ============================ + Unittest Compatibility Layer + ============================ + + Compatibility layer to use :mod:`unittest ` under Python + 2.7 or `unittest2`_ under Python 2.6 without having to worry about which is + in use. + + .. attention:: + + Please refer to Python's :mod:`unittest ` + documentation as the ultimate source of information, this is just a + compatibility layer. + + .. _`unittest2`: https://pypi.python.org/pypi/unittest2 +''' +# pylint: disable=unused-import + +# Import python libs +from __future__ import absolute_import +import sys +import logging +try: + import psutil + HAS_PSUTIL = True +except ImportError: + HAS_PSUTIL = False + +# Set SHOW_PROC to True to show +# process details when running in verbose mode +# i.e. [CPU:15.1%|MEM:48.3%|Z:0] +SHOW_PROC = False + +# support python < 2.7 via unittest2 +if sys.version_info < (2, 7): + try: + # pylint: disable=import-error + from unittest2 import ( + TestLoader as _TestLoader, + TextTestRunner as __TextTestRunner, + TestCase as __TestCase, + expectedFailure, + TestSuite as _TestSuite, + skip, + skipIf, + TestResult as _TestResult, + TextTestResult as __TextTestResult + ) + from unittest2.case import _id + # pylint: enable=import-error + + class NewStyleClassMixin(object): + ''' + Simple new style class to make pylint shut up! + + And also to avoid errors like: + + 'Cannot create a consistent method resolution order (MRO) for bases' + ''' + + class TestLoader(_TestLoader, NewStyleClassMixin): + pass + + class _TextTestRunner(__TextTestRunner, NewStyleClassMixin): + pass + + class _TestCase(__TestCase, NewStyleClassMixin): + pass + + class TestSuite(_TestSuite, NewStyleClassMixin): + pass + + class TestResult(_TestResult, NewStyleClassMixin): + pass + + class _TextTestResult(__TextTestResult, NewStyleClassMixin): + pass + + except ImportError: + raise SystemExit('You need to install unittest2 to run the salt tests') +else: + from unittest import ( + TestLoader, + TextTestRunner as _TextTestRunner, + TestCase as _TestCase, + expectedFailure, + TestSuite, + skip, + skipIf, + TestResult, + TextTestResult as _TextTestResult + ) + from unittest.case import _id + + +class TestCase(_TestCase): + + # pylint: disable=expected-an-indented-block-comment +## Commented out because it may be causing tests to hang +## at the end of the run +# +# _cwd = os.getcwd() +# _chdir_counter = 0 + +# @classmethod +# def tearDownClass(cls): +# ''' +# Overriden method for tearing down all classes in salttesting +# +# This hard-resets the environment between test classes +# ''' +# # Compare where we are now compared to where we were when we began this family of tests +# if not cls._cwd == os.getcwd() and cls._chdir_counter > 0: +# os.chdir(cls._cwd) +# print('\nWARNING: A misbehaving test has modified the working directory!\nThe test suite has reset the working directory ' +# 'on tearDown() to {0}\n'.format(cls._cwd)) +# cls._chdir_counter += 1 + # pylint: enable=expected-an-indented-block-comment + + def shortDescription(self): + desc = _TestCase.shortDescription(self) + if HAS_PSUTIL and SHOW_PROC: + proc_info = '' + found_zombies = 0 + try: + for proc in psutil.process_iter(): + if proc.status == psutil.STATUS_ZOMBIE: + found_zombies += 1 + proc_info = '[CPU:{0}%|MEM:{1}%|Z:{2}] {short_desc}'.format(psutil.cpu_percent(), + psutil.virtual_memory().percent, + found_zombies, + short_desc=desc if desc else '') + except Exception: + pass + return proc_info + else: + return _TestCase.shortDescription(self) + + def assertEquals(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('assertEquals', 'assertEqual') + ) + # return _TestCase.assertEquals(self, *args, **kwargs) + + def failUnlessEqual(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('failUnlessEqual', 'assertEqual') + ) + # return _TestCase.failUnlessEqual(self, *args, **kwargs) + + def failIfEqual(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('failIfEqual', 'assertNotEqual') + ) + # return _TestCase.failIfEqual(self, *args, **kwargs) + + def failUnless(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('failUnless', 'assertTrue') + ) + # return _TestCase.failUnless(self, *args, **kwargs) + + def assert_(self, *args, **kwargs): + # The unittest2 library uses this deprecated method, we can't raise + # the exception. + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('assert_', 'assertTrue') + ) + # return _TestCase.assert_(self, *args, **kwargs) + + def failIf(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('failIf', 'assertFalse') + ) + # return _TestCase.failIf(self, *args, **kwargs) + + def failUnlessRaises(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('failUnlessRaises', 'assertRaises') + ) + # return _TestCase.failUnlessRaises(self, *args, **kwargs) + + def failUnlessAlmostEqual(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('failUnlessAlmostEqual', 'assertAlmostEqual') + ) + # return _TestCase.failUnlessAlmostEqual(self, *args, **kwargs) + + def failIfAlmostEqual(self, *args, **kwargs): + raise DeprecationWarning( + 'The {0}() function is deprecated. Please start using {1}() ' + 'instead.'.format('failIfAlmostEqual', 'assertNotAlmostEqual') + ) + # return _TestCase.failIfAlmostEqual(self, *args, **kwargs) + + +class TextTestResult(_TextTestResult): + ''' + Custom TestResult class whith logs the start and the end of a test + ''' + + def startTest(self, test): + logging.getLogger(__name__).debug( + '>>>>> START >>>>> {0}'.format(test.id()) + ) + return super(TextTestResult, self).startTest(test) + + def stopTest(self, test): + logging.getLogger(__name__).debug( + '<<<<< END <<<<<<< {0}'.format(test.id()) + ) + return super(TextTestResult, self).stopTest(test) + + +class TextTestRunner(_TextTestRunner): + ''' + Custom Text tests runner to log the start and the end of a test case + ''' + resultclass = TextTestResult + + +__all__ = [ + 'TestLoader', + 'TextTestRunner', + 'TestCase', + 'expectedFailure', + 'TestSuite', + 'skipIf', + 'TestResult' +] diff --git a/tests/support/xmlunit.py b/tests/support/xmlunit.py new file mode 100644 index 0000000000..483261e65d --- /dev/null +++ b/tests/support/xmlunit.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +''' + :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` + :copyright: © 2014 by the SaltStack Team, see AUTHORS for more details. + :license: Apache 2.0, see LICENSE for more details. + + + tests.support.xmlunit + ~~~~~~~~~~~~~~~~~~~ + + XML Unit Tests +''' + +# Import python libs +from __future__ import absolute_import +import sys +import logging + +# Import 3rd-party libs +import salt.ext.six as six +from salt.ext.six.moves import StringIO # pylint: disable=import-error + +log = logging.getLogger(__name__) + + +try: + import xmlrunner.runner + import xmlrunner.result + HAS_XMLRUNNER = True + + class _DelegateIO(object): + ''' + This class defines an object that captures whatever is written to + a stream or file. + ''' + + def __init__(self, delegate): + self._captured = StringIO() + self.delegate = delegate + + def write(self, text): + if six.PY2 and isinstance(text, six.text_type): + text = text.encode(__salt_system_encoding__) + self._captured.write(text) + self.delegate.write(text) + + def __getattr__(self, attr): + try: + return getattr(self._captured, attr) + except AttributeError: + return getattr(self.delegate, attr) + + class _XMLTestResult(xmlrunner.result._XMLTestResult): + def startTest(self, test): + logging.getLogger(__name__).debug( + '>>>>> START >>>>> {0}'.format(test.id()) + ) + # xmlrunner classes are NOT new-style classes + xmlrunner.result._XMLTestResult.startTest(self, test) + if self.buffer: + # Let's override the values of self._stdXXX_buffer + # We want a similar sys.stdXXX file like behaviour + self._stderr_buffer = _DelegateIO(sys.__stderr__) + self._stdout_buffer = _DelegateIO(sys.__stdout__) + sys.stderr = self._stderr_buffer + sys.stdout = self._stdout_buffer + + def stopTest(self, test): + logging.getLogger(__name__).debug( + '<<<<< END <<<<<<< {0}'.format(test.id()) + ) + # xmlrunner classes are NOT new-style classes + return xmlrunner.result._XMLTestResult.stopTest(self, test) + + class XMLTestRunner(xmlrunner.runner.XMLTestRunner): + def _make_result(self): + return _XMLTestResult( + self.stream, + self.descriptions, + self.verbosity, + self.elapsed_times + ) + + def run(self, test): + result = xmlrunner.runner.XMLTestRunner.run(self, test) + self.stream.writeln('Finished generating XML reports') + return result + +except ImportError: + HAS_XMLRUNNER = False + + class XMLTestRunner(object): + ''' + This is a dumb class just so we don't break projects at import time + ''' diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 752c6d9f7b..d6649135f6 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -5,8 +5,8 @@ A lightweight version of tests.integration for testing of unit tests This test class will not import the salt minion, runner and config modules. ''' from __future__ import absolute_import -from salttesting.case import TestCase -from salttesting.parser import SaltTestcaseParser +from tests.support.case import TestCase +from tests.support.parser import SaltTestcaseParser __all__ = ['run_tests', 'ModuleTestCase'] diff --git a/tests/unit/acl/test_client.py b/tests/unit/acl/test_client.py index 6d0f08d217..fdacb2b2c3 100644 --- a/tests/unit/acl/test_client.py +++ b/tests/unit/acl/test_client.py @@ -7,7 +7,7 @@ from __future__ import absolute_import from salt import acl # Import Salt Testing Libs -from salttesting import TestCase +from tests.support.unit import TestCase class ClientACLTestCase(TestCase): diff --git a/tests/unit/beacons/test_adb_beacon.py b/tests/unit/beacons/test_adb_beacon.py index 871a09478e..b41342a125 100644 --- a/tests/unit/beacons/test_adb_beacon.py +++ b/tests/unit/beacons/test_adb_beacon.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.beacons import adb # Salt testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock # Globals diff --git a/tests/unit/beacons/test_glxinfo.py b/tests/unit/beacons/test_glxinfo.py index 97a8f1f59e..c0fb4d9b5a 100644 --- a/tests/unit/beacons/test_glxinfo.py +++ b/tests/unit/beacons/test_glxinfo.py @@ -7,8 +7,8 @@ from __future__ import absolute_import import salt.beacons.glxinfo as glxinfo # Salt testing libs -from salttesting import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock # Import test suite libs from tests.support.mixins import LoaderModuleMockMixin diff --git a/tests/unit/beacons/test_inotify_beacon.py b/tests/unit/beacons/test_inotify_beacon.py index c40fedcd52..4b0e560e1e 100644 --- a/tests/unit/beacons/test_inotify_beacon.py +++ b/tests/unit/beacons/test_inotify_beacon.py @@ -10,9 +10,9 @@ import tempfile from salt.beacons import inotify # Salt testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import destructiveTest, ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import destructiveTest, ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON # Third-party libs try: diff --git a/tests/unit/cache/test_localfs.py b/tests/unit/cache/test_localfs.py index 08b887aa14..87f203873d 100644 --- a/tests/unit/cache/test_localfs.py +++ b/tests/unit/cache/test_localfs.py @@ -10,8 +10,8 @@ import tempfile # Import Salt Testing libs import integration -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, diff --git a/tests/unit/cli/test_batch.py b/tests/unit/cli/test_batch.py index a58350e2a3..2034cbbf5f 100644 --- a/tests/unit/cli/test_batch.py +++ b/tests/unit/cli/test_batch.py @@ -10,8 +10,8 @@ from __future__ import absolute_import from salt.cli.batch import Batch # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import skipIf, TestCase +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON @skipIf(NO_MOCK, NO_MOCK_REASON) diff --git a/tests/unit/cloud/clouds/test_dimensiondata.py b/tests/unit/cloud/clouds/test_dimensiondata.py index 646fb2513c..33525aa163 100644 --- a/tests/unit/cloud/clouds/test_dimensiondata.py +++ b/tests/unit/cloud/clouds/test_dimensiondata.py @@ -22,9 +22,9 @@ from salt.cloud.clouds import dimensiondata from salt.exceptions import SaltCloudSystemExit # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../../') diff --git a/tests/unit/cloud/clouds/test_ec2.py b/tests/unit/cloud/clouds/test_ec2.py index 0b2059e1ef..5696535e28 100644 --- a/tests/unit/cloud/clouds/test_ec2.py +++ b/tests/unit/cloud/clouds/test_ec2.py @@ -10,8 +10,8 @@ from salt.cloud.clouds import ec2 from salt.exceptions import SaltCloudSystemExit # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON @skipIf(NO_MOCK, NO_MOCK_REASON) diff --git a/tests/unit/cloud/clouds/test_gce.py b/tests/unit/cloud/clouds/test_gce.py index 54fabaa586..5da051628f 100644 --- a/tests/unit/cloud/clouds/test_gce.py +++ b/tests/unit/cloud/clouds/test_gce.py @@ -22,9 +22,9 @@ from salt.cloud.clouds import gce from salt.exceptions import SaltCloudSystemExit # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../../') diff --git a/tests/unit/cloud/clouds/test_joyent.py b/tests/unit/cloud/clouds/test_joyent.py index f464568f0c..b2e17be994 100644 --- a/tests/unit/cloud/clouds/test_joyent.py +++ b/tests/unit/cloud/clouds/test_joyent.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/cloud/clouds/test_linode.py b/tests/unit/cloud/clouds/test_linode.py index e9fd489fec..6bc357eb13 100644 --- a/tests/unit/cloud/clouds/test_linode.py +++ b/tests/unit/cloud/clouds/test_linode.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../../') diff --git a/tests/unit/cloud/clouds/test_opennebula.py b/tests/unit/cloud/clouds/test_opennebula.py index 16687fd45e..ab969c75d0 100644 --- a/tests/unit/cloud/clouds/test_opennebula.py +++ b/tests/unit/cloud/clouds/test_opennebula.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../../') diff --git a/tests/unit/cloud/clouds/test_saltify.py b/tests/unit/cloud/clouds/test_saltify.py index ba70edb6e9..7c8069c435 100644 --- a/tests/unit/cloud/clouds/test_saltify.py +++ b/tests/unit/cloud/clouds/test_saltify.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.mock import MagicMock +from tests.support.unit import TestCase +from tests.support.mock import MagicMock # Import Salt Libs from salt.cloud.clouds import saltify diff --git a/tests/unit/cloud/clouds/test_vmware.py b/tests/unit/cloud/clouds/test_vmware.py index 05090ba428..781e31bbd3 100644 --- a/tests/unit/cloud/clouds/test_vmware.py +++ b/tests/unit/cloud/clouds/test_vmware.py @@ -11,9 +11,9 @@ from __future__ import absolute_import from copy import deepcopy # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath from salt import config ensure_in_syspath('../../../') diff --git a/tests/unit/cloud/test_libcloud.py b/tests/unit/cloud/test_libcloud.py index 259b0f24e4..143c0f9f03 100644 --- a/tests/unit/cloud/test_libcloud.py +++ b/tests/unit/cloud/test_libcloud.py @@ -10,13 +10,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase +from tests.support.unit import TestCase # Import Salt Libs import salt.cloud.libcloudfuncs as libcloud # Import Salt Testing Libs -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/config/schemas/test_ssh.py b/tests/unit/config/schemas/test_ssh.py index 3848d02050..ee6990a797 100644 --- a/tests/unit/config/schemas/test_ssh.py +++ b/tests/unit/config/schemas/test_ssh.py @@ -10,8 +10,8 @@ from __future__ import absolute_import, print_function from distutils.version import LooseVersion as _LooseVersion # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/config/test_api.py b/tests/unit/config/test_api.py index 51b031248d..0a539126d1 100644 --- a/tests/unit/config/test_api.py +++ b/tests/unit/config/test_api.py @@ -7,9 +7,9 @@ tests.unit.api_config_test from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import destructiveTest -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import destructiveTest +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index d21e4496f2..19700c4d88 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -15,8 +15,8 @@ import shutil import tempfile # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # Import Salt libs import salt.minion diff --git a/tests/unit/engines/test_sqs_events.py b/tests/unit/engines/test_sqs_events.py index b23d22c321..fb2a61aec4 100644 --- a/tests/unit/engines/test_sqs_events.py +++ b/tests/unit/engines/test_sqs_events.py @@ -6,14 +6,14 @@ unit tests for the sqs_events engine from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/fileserver/test_gitfs.py b/tests/unit/fileserver/test_gitfs.py index e6de2f2290..26c83d8e74 100644 --- a/tests/unit/fileserver/test_gitfs.py +++ b/tests/unit/fileserver/test_gitfs.py @@ -17,7 +17,7 @@ except ImportError: HAS_GITPYTHON = False # Import Salt Testing Libs -from salttesting import TestCase, skipIf +from tests.support.unit import TestCase, skipIf import integration diff --git a/tests/unit/fileserver/test_map.py b/tests/unit/fileserver/test_map.py index e5ccf19559..c7f5588c1b 100644 --- a/tests/unit/fileserver/test_map.py +++ b/tests/unit/fileserver/test_map.py @@ -7,7 +7,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase +from tests.support.unit import TestCase from salt import fileserver diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py index 5972b27e83..03042ed2d1 100644 --- a/tests/unit/grains/test_core.py +++ b/tests/unit/grains/test_core.py @@ -9,8 +9,8 @@ import os import platform # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, mock_open, diff --git a/tests/unit/modules/test_aliases.py b/tests/unit/modules/test_aliases.py index c5b2a5c554..1e0d7dde20 100644 --- a/tests/unit/modules/test_aliases.py +++ b/tests/unit/modules/test_aliases.py @@ -11,9 +11,9 @@ from salt.modules import aliases from salt.exceptions import SaltInvocationError # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_alternatives.py b/tests/unit/modules/test_alternatives.py index 5bb3e91738..31a4c892a0 100644 --- a/tests/unit/modules/test_alternatives.py +++ b/tests/unit/modules/test_alternatives.py @@ -11,9 +11,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath, TestsLoggingHandler -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath, TestsLoggingHandler +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_apache.py b/tests/unit/modules/test_apache.py index e87e079178..1ab8afb05b 100644 --- a/tests/unit/modules/test_apache.py +++ b/tests/unit/modules/test_apache.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, mock_open, diff --git a/tests/unit/modules/test_aptpkg.py b/tests/unit/modules/test_aptpkg.py index d7f3cd18bb..4b82685e7a 100644 --- a/tests/unit/modules/test_aptpkg.py +++ b/tests/unit/modules/test_aptpkg.py @@ -15,9 +15,9 @@ from salt.exceptions import CommandExecutionError, SaltInvocationError from salt.modules import aptpkg # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_archive.py b/tests/unit/modules/test_archive.py index 8d738a27f4..98915fbdb7 100644 --- a/tests/unit/modules/test_archive.py +++ b/tests/unit/modules/test_archive.py @@ -11,9 +11,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch from salt.ext.six.moves import zip ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_artifactory.py b/tests/unit/modules/test_artifactory.py index 3cdb846d83..b92c7043c2 100644 --- a/tests/unit/modules/test_artifactory.py +++ b/tests/unit/modules/test_artifactory.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/unit/modules/test_at.py b/tests/unit/modules/test_at.py index 44fb0d8931..bbe3c60e4f 100644 --- a/tests/unit/modules/test_at.py +++ b/tests/unit/modules/test_at.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_augeas_cfg.py b/tests/unit/modules/test_augeas_cfg.py index 916f62fdc5..705c1a0b7e 100644 --- a/tests/unit/modules/test_augeas_cfg.py +++ b/tests/unit/modules/test_augeas_cfg.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, ) diff --git a/tests/unit/modules/test_bluez.py b/tests/unit/modules/test_bluez.py index 7d9d840703..4f6fa18ce9 100644 --- a/tests/unit/modules/test_bluez.py +++ b/tests/unit/modules/test_bluez.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_boto_apigateway.py b/tests/unit/modules/test_boto_apigateway.py index 0ed863dde2..e26134b320 100644 --- a/tests/unit/modules/test_boto_apigateway.py +++ b/tests/unit/modules/test_boto_apigateway.py @@ -9,9 +9,9 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_cloudtrail.py b/tests/unit/modules/test_boto_cloudtrail.py index 264a795825..b971c68b58 100644 --- a/tests/unit/modules/test_boto_cloudtrail.py +++ b/tests/unit/modules/test_boto_cloudtrail.py @@ -7,14 +7,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_cloudwatch_event.py b/tests/unit/modules/test_boto_cloudwatch_event.py index 9f6855d2bb..1069cbe047 100644 --- a/tests/unit/modules/test_boto_cloudwatch_event.py +++ b/tests/unit/modules/test_boto_cloudwatch_event.py @@ -6,14 +6,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_cognitoidentity.py b/tests/unit/modules/test_boto_cognitoidentity.py index 5e97d2230a..b8b668c115 100644 --- a/tests/unit/modules/test_boto_cognitoidentity.py +++ b/tests/unit/modules/test_boto_cognitoidentity.py @@ -8,9 +8,9 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') @@ -20,7 +20,7 @@ import salt.loader from salt.modules import boto_cognitoidentity # Import Mock libraries -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # Import 3rd-party libs diff --git a/tests/unit/modules/test_boto_elasticsearch_domain.py b/tests/unit/modules/test_boto_elasticsearch_domain.py index a9a8be0672..4039da6e22 100644 --- a/tests/unit/modules/test_boto_elasticsearch_domain.py +++ b/tests/unit/modules/test_boto_elasticsearch_domain.py @@ -9,14 +9,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_elb.py b/tests/unit/modules/test_boto_elb.py index 20912199e7..e526eb68f5 100644 --- a/tests/unit/modules/test_boto_elb.py +++ b/tests/unit/modules/test_boto_elb.py @@ -50,9 +50,9 @@ import salt.loader from salt.modules import boto_elb # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_iot.py b/tests/unit/modules/test_boto_iot.py index d271d071e5..051ec43f41 100644 --- a/tests/unit/modules/test_boto_iot.py +++ b/tests/unit/modules/test_boto_iot.py @@ -7,14 +7,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_lambda.py b/tests/unit/modules/test_boto_lambda.py index 7b0d6886db..f44a3b1186 100644 --- a/tests/unit/modules/test_boto_lambda.py +++ b/tests/unit/modules/test_boto_lambda.py @@ -8,14 +8,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_s3_bucket.py b/tests/unit/modules/test_boto_s3_bucket.py index 80e494006a..e153ecdc35 100644 --- a/tests/unit/modules/test_boto_s3_bucket.py +++ b/tests/unit/modules/test_boto_s3_bucket.py @@ -8,14 +8,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_secgroup.py b/tests/unit/modules/test_boto_secgroup.py index 29aa9e12e4..9a79b29efe 100644 --- a/tests/unit/modules/test_boto_secgroup.py +++ b/tests/unit/modules/test_boto_secgroup.py @@ -8,9 +8,9 @@ from copy import deepcopy from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module # Import Salt Testing Libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_boto_vpc.py b/tests/unit/modules/test_boto_vpc.py index 093909cccd..2c9f93b475 100644 --- a/tests/unit/modules/test_boto_vpc.py +++ b/tests/unit/modules/test_boto_vpc.py @@ -12,9 +12,9 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_bower.py b/tests/unit/modules/test_bower.py index 806b546e2c..d190ca773c 100644 --- a/tests/unit/modules/test_bower.py +++ b/tests/unit/modules/test_bower.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_bridge.py b/tests/unit/modules/test_bridge.py index f1b4ce19a8..a904bc1092 100644 --- a/tests/unit/modules/test_bridge.py +++ b/tests/unit/modules/test_bridge.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_btrfs.py b/tests/unit/modules/test_btrfs.py index 40d116095d..85d5353c93 100644 --- a/tests/unit/modules/test_btrfs.py +++ b/tests/unit/modules/test_btrfs.py @@ -5,8 +5,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, patch, @@ -14,7 +14,7 @@ from salttesting.mock import ( NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_cassandra.py b/tests/unit/modules/test_cassandra.py index 9ce0b0df18..713affab2f 100644 --- a/tests/unit/modules/test_cassandra.py +++ b/tests/unit/modules/test_cassandra.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_cassandra_cql.py b/tests/unit/modules/test_cassandra_cql.py index 0b9da16cab..e5cd5b5888 100644 --- a/tests/unit/modules/test_cassandra_cql.py +++ b/tests/unit/modules/test_cassandra_cql.py @@ -9,8 +9,8 @@ from __future__ import absolute_import import ssl # Import Salt Testing libs -from salttesting.unit import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_chef.py b/tests/unit/modules/test_chef.py index ca2d71e54d..28822a0e20 100644 --- a/tests/unit/modules/test_chef.py +++ b/tests/unit/modules/test_chef.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_cmdmod.py b/tests/unit/modules/test_cmdmod.py index bf3f0e88ab..b4b1df0382 100644 --- a/tests/unit/modules/test_cmdmod.py +++ b/tests/unit/modules/test_cmdmod.py @@ -13,15 +13,15 @@ from salt.log import LOG_LEVELS import salt.utils # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_composer.py b/tests/unit/modules/test_composer.py index 0ecf007331..a87ea9847e 100644 --- a/tests/unit/modules/test_composer.py +++ b/tests/unit/modules/test_composer.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_config.py b/tests/unit/modules/test_config.py index a5ca217abb..8c01e51d4c 100644 --- a/tests/unit/modules/test_config.py +++ b/tests/unit/modules/test_config.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_cp.py b/tests/unit/modules/test_cp.py index f209b3f226..b7c84db343 100644 --- a/tests/unit/modules/test_cp.py +++ b/tests/unit/modules/test_cp.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( Mock, MagicMock, mock_open, diff --git a/tests/unit/modules/test_cpan.py b/tests/unit/modules/test_cpan.py index e19a2d9758..af8845b7f5 100644 --- a/tests/unit/modules/test_cpan.py +++ b/tests/unit/modules/test_cpan.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_cron.py b/tests/unit/modules/test_cron.py index c351daf731..075037d664 100644 --- a/tests/unit/modules/test_cron.py +++ b/tests/unit/modules/test_cron.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_cyg.py b/tests/unit/modules/test_cyg.py index 43ec8f0b70..40e662385d 100644 --- a/tests/unit/modules/test_cyg.py +++ b/tests/unit/modules/test_cyg.py @@ -4,9 +4,9 @@ # from __future__ import absolute_import # # Import Salt Testing libs -# from salttesting import skipIf, TestCase -# from salttesting.helpers import ensure_in_syspath -# from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +# from tests.support.unit import skipIf, TestCase +# from tests.support.helpers import ensure_in_syspath +# from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # ensure_in_syspath('../../') # # Import salt libs diff --git a/tests/unit/modules/test_daemontools.py b/tests/unit/modules/test_daemontools.py index 90b556618c..07ce91441f 100644 --- a/tests/unit/modules/test_daemontools.py +++ b/tests/unit/modules/test_daemontools.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_data.py b/tests/unit/modules/test_data.py index c350ea030e..a46ac81e9c 100644 --- a/tests/unit/modules/test_data.py +++ b/tests/unit/modules/test_data.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, mock_open, diff --git a/tests/unit/modules/test_ddns.py b/tests/unit/modules/test_ddns.py index 7b29122f8a..419bc227cc 100644 --- a/tests/unit/modules/test_ddns.py +++ b/tests/unit/modules/test_ddns.py @@ -15,8 +15,8 @@ except ImportError: # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, patch, diff --git a/tests/unit/modules/test_deb_apache.py b/tests/unit/modules/test_deb_apache.py index ab4274f989..849c0a46cb 100644 --- a/tests/unit/modules/test_deb_apache.py +++ b/tests/unit/modules/test_deb_apache.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_deb_postgres.py b/tests/unit/modules/test_deb_postgres.py index 83db135b95..e5652504e8 100644 --- a/tests/unit/modules/test_deb_postgres.py +++ b/tests/unit/modules/test_deb_postgres.py @@ -5,9 +5,9 @@ from __future__ import absolute_import, print_function import os # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch ensure_in_syspath( os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../../')) ensure_in_syspath( diff --git a/tests/unit/modules/test_debconfmod.py b/tests/unit/modules/test_debconfmod.py index 4cc8935a91..04e23c84a7 100644 --- a/tests/unit/modules/test_debconfmod.py +++ b/tests/unit/modules/test_debconfmod.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_debian_ip.py b/tests/unit/modules/test_debian_ip.py index c49400bfa3..fd845ee6c9 100644 --- a/tests/unit/modules/test_debian_ip.py +++ b/tests/unit/modules/test_debian_ip.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_debian_service.py b/tests/unit/modules/test_debian_service.py index d119e6e9e2..4b6808cd98 100644 --- a/tests/unit/modules/test_debian_service.py +++ b/tests/unit/modules/test_debian_service.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_defaults.py b/tests/unit/modules/test_defaults.py index 90178a417a..5ad293e791 100644 --- a/tests/unit/modules/test_defaults.py +++ b/tests/unit/modules/test_defaults.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_devmap.py b/tests/unit/modules/test_devmap.py index ca552f2d4f..0e1209fb38 100644 --- a/tests/unit/modules/test_devmap.py +++ b/tests/unit/modules/test_devmap.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_dig.py b/tests/unit/modules/test_dig.py index 7562d268a4..c229282fbe 100644 --- a/tests/unit/modules/test_dig.py +++ b/tests/unit/modules/test_dig.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_disk.py b/tests/unit/modules/test_disk.py index ec162f7459..d82c2c1bb3 100644 --- a/tests/unit/modules/test_disk.py +++ b/tests/unit/modules/test_disk.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/unit/modules/test_djangomod.py b/tests/unit/modules/test_djangomod.py index 856190ef7d..fb4067076e 100644 --- a/tests/unit/modules/test_djangomod.py +++ b/tests/unit/modules/test_djangomod.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_dnsmasq.py b/tests/unit/modules/test_dnsmasq.py index 3e63dd49b3..e04c42963c 100644 --- a/tests/unit/modules/test_dnsmasq.py +++ b/tests/unit/modules/test_dnsmasq.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, patch, diff --git a/tests/unit/modules/test_dnsutil.py b/tests/unit/modules/test_dnsutil.py index 3380d091e8..0754c83978 100644 --- a/tests/unit/modules/test_dnsutil.py +++ b/tests/unit/modules/test_dnsutil.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import logging # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, mock_open, diff --git a/tests/unit/modules/test_docker.py b/tests/unit/modules/test_docker.py index b54df05ce3..b36b707948 100644 --- a/tests/unit/modules/test_docker.py +++ b/tests/unit/modules/test_docker.py @@ -7,9 +7,9 @@ Unit tests for the docker module from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, Mock, NO_MOCK, diff --git a/tests/unit/modules/test_dpkg.py b/tests/unit/modules/test_dpkg.py index 67ca84f9b7..a789344d12 100644 --- a/tests/unit/modules/test_dpkg.py +++ b/tests/unit/modules/test_dpkg.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_drac.py b/tests/unit/modules/test_drac.py index 67f5732d8f..108b1146d0 100644 --- a/tests/unit/modules/test_drac.py +++ b/tests/unit/modules/test_drac.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_drbd.py b/tests/unit/modules/test_drbd.py index ab7d677a59..34c9b19f84 100644 --- a/tests/unit/modules/test_drbd.py +++ b/tests/unit/modules/test_drbd.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_environ.py b/tests/unit/modules/test_environ.py index 0c1c67ef64..2c61fc11d1 100644 --- a/tests/unit/modules/test_environ.py +++ b/tests/unit/modules/test_environ.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_etcd_mod.py b/tests/unit/modules/test_etcd_mod.py index f3f59be936..f7220db8b8 100644 --- a/tests/unit/modules/test_etcd_mod.py +++ b/tests/unit/modules/test_etcd_mod.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( create_autospec, MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_event.py b/tests/unit/modules/test_event.py index e4168389cf..687c16600b 100644 --- a/tests/unit/modules/test_event.py +++ b/tests/unit/modules/test_event.py @@ -4,8 +4,8 @@ ''' from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_extfs.py b/tests/unit/modules/test_extfs.py index 27427fecec..2a4c7ebbeb 100644 --- a/tests/unit/modules/test_extfs.py +++ b/tests/unit/modules/test_extfs.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON # Import Salt Libs from salt.modules import extfs diff --git a/tests/unit/modules/test_file.py b/tests/unit/modules/test_file.py index 73b30bc852..1085dbf3b2 100644 --- a/tests/unit/modules/test_file.py +++ b/tests/unit/modules/test_file.py @@ -7,9 +7,9 @@ import tempfile import textwrap # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_firewalld.py b/tests/unit/modules/test_firewalld.py index c3b3495861..7f916f0fd1 100644 --- a/tests/unit/modules/test_firewalld.py +++ b/tests/unit/modules/test_firewalld.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_gem.py b/tests/unit/modules/test_gem.py index 8a4399861a..9701592e8e 100644 --- a/tests/unit/modules/test_gem.py +++ b/tests/unit/modules/test_gem.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_genesis.py b/tests/unit/modules/test_genesis.py index cbee47f09d..1beea11eaf 100644 --- a/tests/unit/modules/test_genesis.py +++ b/tests/unit/modules/test_genesis.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_gentoo_service.py b/tests/unit/modules/test_gentoo_service.py index 26c823495e..29bfd70ba5 100644 --- a/tests/unit/modules/test_gentoo_service.py +++ b/tests/unit/modules/test_gentoo_service.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs from mock import call -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_git.py b/tests/unit/modules/test_git.py index 7fee538581..bcdb438b1a 100644 --- a/tests/unit/modules/test_git.py +++ b/tests/unit/modules/test_git.py @@ -12,8 +12,8 @@ import subprocess from distutils.version import LooseVersion # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_glusterfs.py b/tests/unit/modules/test_glusterfs.py index 5a609c41d2..20b6d4f4da 100644 --- a/tests/unit/modules/test_glusterfs.py +++ b/tests/unit/modules/test_glusterfs.py @@ -8,8 +8,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_gnomedesktop.py b/tests/unit/modules/test_gnomedesktop.py index 826a29355e..9a186c3138 100644 --- a/tests/unit/modules/test_gnomedesktop.py +++ b/tests/unit/modules/test_gnomedesktop.py @@ -6,8 +6,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON diff --git a/tests/unit/modules/test_grains.py b/tests/unit/modules/test_grains.py index 216e8195ae..d9897a31a3 100644 --- a/tests/unit/modules/test_grains.py +++ b/tests/unit/modules/test_grains.py @@ -5,9 +5,9 @@ from __future__ import absolute_import import copy # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_groupadd.py b/tests/unit/modules/test_groupadd.py index b03fa622d6..08d5540f7b 100644 --- a/tests/unit/modules/test_groupadd.py +++ b/tests/unit/modules/test_groupadd.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON # Import Salt Libs from salt.modules import groupadd diff --git a/tests/unit/modules/test_grub_legacy.py b/tests/unit/modules/test_grub_legacy.py index f80a957b79..db5b65f6d0 100644 --- a/tests/unit/modules/test_grub_legacy.py +++ b/tests/unit/modules/test_grub_legacy.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, patch, diff --git a/tests/unit/modules/test_guestfs.py b/tests/unit/modules/test_guestfs.py index 97d29d6ae1..0bbd82d701 100644 --- a/tests/unit/modules/test_guestfs.py +++ b/tests/unit/modules/test_guestfs.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_hadoop.py b/tests/unit/modules/test_hadoop.py index 6a002a114c..b2b0cfb597 100644 --- a/tests/unit/modules/test_hadoop.py +++ b/tests/unit/modules/test_hadoop.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_haproxyconn.py b/tests/unit/modules/test_haproxyconn.py index 558ea61c10..b032db1cf6 100644 --- a/tests/unit/modules/test_haproxyconn.py +++ b/tests/unit/modules/test_haproxyconn.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_hashutil.py b/tests/unit/modules/test_hashutil.py index 15963f95a9..a944cb87c3 100644 --- a/tests/unit/modules/test_hashutil.py +++ b/tests/unit/modules/test_hashutil.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import os # Import salt testing libs -from salttesting.case import ModuleCase -from salttesting.mixins import RUNTIME_VARS +from tests.support.case import ModuleCase +from tests.support.mixins import RUNTIME_VARS # Import Salt libs import salt.config diff --git a/tests/unit/modules/test_hg.py b/tests/unit/modules/test_hg.py index 9e3c8c878a..33546e2eff 100644 --- a/tests/unit/modules/test_hg.py +++ b/tests/unit/modules/test_hg.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_hipchat.py b/tests/unit/modules/test_hipchat.py index 44eb32cb94..987192ad75 100644 --- a/tests/unit/modules/test_hipchat.py +++ b/tests/unit/modules/test_hipchat.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_hosts.py b/tests/unit/modules/test_hosts.py index db51b115bb..9a9b3a62eb 100644 --- a/tests/unit/modules/test_hosts.py +++ b/tests/unit/modules/test_hosts.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.mock import ( MagicMock, mock_open, patch, diff --git a/tests/unit/modules/test_htpasswd.py b/tests/unit/modules/test_htpasswd.py index 58b5c3387b..900cb097f1 100644 --- a/tests/unit/modules/test_htpasswd.py +++ b/tests/unit/modules/test_htpasswd.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_http.py b/tests/unit/modules/test_http.py index 1cf7018c83..bc98352b49 100644 --- a/tests/unit/modules/test_http.py +++ b/tests/unit/modules/test_http.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON diff --git a/tests/unit/modules/test_ilo.py b/tests/unit/modules/test_ilo.py index 5cccee1201..6c3c912f4a 100644 --- a/tests/unit/modules/test_ilo.py +++ b/tests/unit/modules/test_ilo.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_incron.py b/tests/unit/modules/test_incron.py index 4875e3f153..7a39cd7ec3 100644 --- a/tests/unit/modules/test_incron.py +++ b/tests/unit/modules/test_incron.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_influx08.py b/tests/unit/modules/test_influx08.py index a1495bd7e0..819e0cc218 100644 --- a/tests/unit/modules/test_influx08.py +++ b/tests/unit/modules/test_influx08.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_ini_manage.py b/tests/unit/modules/test_ini_manage.py index 69faf567b3..75fd8ac9e4 100644 --- a/tests/unit/modules/test_ini_manage.py +++ b/tests/unit/modules/test_ini_manage.py @@ -6,8 +6,8 @@ import os import tempfile # Import Salt Testing libs -from salttesting.unit import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_inspect_collector.py b/tests/unit/modules/test_inspect_collector.py index 9105670526..fce1b5f930 100644 --- a/tests/unit/modules/test_inspect_collector.py +++ b/tests/unit/modules/test_inspect_collector.py @@ -21,8 +21,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, @@ -30,7 +30,7 @@ from salttesting.mock import ( ) from salt.modules.inspectlib.collector import Inspector -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_inspect_fsdb.py b/tests/unit/modules/test_inspect_fsdb.py index b614fbb966..a166655ab7 100644 --- a/tests/unit/modules/test_inspect_fsdb.py +++ b/tests/unit/modules/test_inspect_fsdb.py @@ -22,10 +22,10 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.mock import MagicMock, patch +from tests.support.unit import TestCase +from tests.support.mock import MagicMock, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.modules.inspectlib.fsdb import CsvDB from salt.modules.inspectlib.entities import CsvDBEntity from salt.utils.odict import OrderedDict diff --git a/tests/unit/modules/test_introspect.py b/tests/unit/modules/test_introspect.py index 6245774005..a1ed9a9ed2 100644 --- a/tests/unit/modules/test_introspect.py +++ b/tests/unit/modules/test_introspect.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_ipset.py b/tests/unit/modules/test_ipset.py index a5934a709d..00c73c6aa8 100644 --- a/tests/unit/modules/test_ipset.py +++ b/tests/unit/modules/test_ipset.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_iptables.py b/tests/unit/modules/test_iptables.py index fc577df42c..0b0c26b4f8 100644 --- a/tests/unit/modules/test_iptables.py +++ b/tests/unit/modules/test_iptables.py @@ -8,14 +8,14 @@ from __future__ import absolute_import import uuid # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_jboss7.py b/tests/unit/modules/test_jboss7.py index 3654b43025..4749900874 100644 --- a/tests/unit/modules/test_jboss7.py +++ b/tests/unit/modules/test_jboss7.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import salt testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_jboss7_cli.py b/tests/unit/modules/test_jboss7_cli.py index e74828c543..f9ba34e4be 100644 --- a/tests/unit/modules/test_jboss7_cli.py +++ b/tests/unit/modules/test_jboss7_cli.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import re # Import salt testing libs -from salttesting.unit import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') from salt.modules import jboss7_cli diff --git a/tests/unit/modules/test_k8s.py b/tests/unit/modules/test_k8s.py index 3c6f730c9d..33a924341a 100644 --- a/tests/unit/modules/test_k8s.py +++ b/tests/unit/modules/test_k8s.py @@ -12,8 +12,8 @@ import time from subprocess import Popen, PIPE # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath, skip_if_binaries_missing +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_kapacitor.py b/tests/unit/modules/test_kapacitor.py index 7d936e5d0d..880f0f2872 100644 --- a/tests/unit/modules/test_kapacitor.py +++ b/tests/unit/modules/test_kapacitor.py @@ -8,8 +8,8 @@ import json from salt.modules import kapacitor # Import Salt testing libs -from salttesting import TestCase -from salttesting.mock import Mock, patch +from tests.support.unit import TestCase +from tests.support.mock import Mock, patch kapacitor.__salt__ = { 'pkg.version': Mock(return_value='9999'), diff --git a/tests/unit/modules/test_key.py b/tests/unit/modules/test_key.py index ff56d76b5a..850d776f4e 100644 --- a/tests/unit/modules/test_key.py +++ b/tests/unit/modules/test_key.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_keyboard.py b/tests/unit/modules/test_keyboard.py index f036c120b5..ce1113963d 100644 --- a/tests/unit/modules/test_keyboard.py +++ b/tests/unit/modules/test_keyboard.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_keystone.py b/tests/unit/modules/test_keystone.py index 1594138a76..46cc1915df 100644 --- a/tests/unit/modules/test_keystone.py +++ b/tests/unit/modules/test_keystone.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_kmod.py b/tests/unit/modules/test_kmod.py index 307b523a83..e95908ca17 100644 --- a/tests/unit/modules/test_kmod.py +++ b/tests/unit/modules/test_kmod.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, patch +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, patch # Import Salt Libs from salt.modules import kmod diff --git a/tests/unit/modules/test_launchctl.py b/tests/unit/modules/test_launchctl.py index c6111ebbf8..fef3ce7ad8 100644 --- a/tests/unit/modules/test_launchctl.py +++ b/tests/unit/modules/test_launchctl.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_ldapmod.py b/tests/unit/modules/test_ldapmod.py index 2e3a3ef4b2..98b326a825 100644 --- a/tests/unit/modules/test_ldapmod.py +++ b/tests/unit/modules/test_ldapmod.py @@ -8,14 +8,14 @@ from __future__ import absolute_import import time # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_libcloud_dns.py b/tests/unit/modules/test_libcloud_dns.py index 4541d3d03d..26597cc976 100644 --- a/tests/unit/modules/test_libcloud_dns.py +++ b/tests/unit/modules/test_libcloud_dns.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf +from tests.support.unit import skipIf from tests.unit import ModuleTestCase, hasDependency -from salttesting.mock import ( +from tests.support.mock import ( patch, MagicMock, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.modules import libcloud_dns ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_linux_acl.py b/tests/unit/modules/test_linux_acl.py index 385f9599b9..adadadbbf0 100644 --- a/tests/unit/modules/test_linux_acl.py +++ b/tests/unit/modules/test_linux_acl.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_linux_lvm.py b/tests/unit/modules/test_linux_lvm.py index 10b3b1b7cd..a10e83ea7e 100644 --- a/tests/unit/modules/test_linux_lvm.py +++ b/tests/unit/modules/test_linux_lvm.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os.path # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_linux_sysctl.py b/tests/unit/modules/test_linux_sysctl.py index 81972cbda1..1381f5fc20 100644 --- a/tests/unit/modules/test_linux_sysctl.py +++ b/tests/unit/modules/test_linux_sysctl.py @@ -12,9 +12,9 @@ from salt.modules import systemd from salt.exceptions import CommandExecutionError # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, mock_open, patch, diff --git a/tests/unit/modules/test_localemod.py b/tests/unit/modules/test_localemod.py index b5cedfd8a6..60a51ae331 100644 --- a/tests/unit/modules/test_localemod.py +++ b/tests/unit/modules/test_localemod.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, Mock, patch, diff --git a/tests/unit/modules/test_locate.py b/tests/unit/modules/test_locate.py index ab1a698056..cd388f0984 100644 --- a/tests/unit/modules/test_locate.py +++ b/tests/unit/modules/test_locate.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_logadm.py b/tests/unit/modules/test_logadm.py index a4b99fa86b..d1297e5426 100644 --- a/tests/unit/modules/test_logadm.py +++ b/tests/unit/modules/test_logadm.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_logrotate.py b/tests/unit/modules/test_logrotate.py index a68b20240e..25a44b530d 100644 --- a/tests/unit/modules/test_logrotate.py +++ b/tests/unit/modules/test_logrotate.py @@ -11,14 +11,14 @@ from salt.exceptions import SaltInvocationError from salt.modules import logrotate # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_lvs.py b/tests/unit/modules/test_lvs.py index 5cce5ff2c5..79283fe0fe 100644 --- a/tests/unit/modules/test_lvs.py +++ b/tests/unit/modules/test_lvs.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mac_assistive.py b/tests/unit/modules/test_mac_assistive.py index f2c162f698..7d7f4f184c 100644 --- a/tests/unit/modules/test_mac_assistive.py +++ b/tests/unit/modules/test_mac_assistive.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/modules/test_mac_brew.py b/tests/unit/modules/test_mac_brew.py index e110e93ccf..88d630a29e 100644 --- a/tests/unit/modules/test_mac_brew.py +++ b/tests/unit/modules/test_mac_brew.py @@ -11,9 +11,9 @@ from salt.modules import mac_brew from salt.exceptions import CommandExecutionError # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mac_defaults.py b/tests/unit/modules/test_mac_defaults.py index e0462a676c..e4d1efafcf 100644 --- a/tests/unit/modules/test_mac_defaults.py +++ b/tests/unit/modules/test_mac_defaults.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import mac_defaults as macdefaults # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/modules/test_mac_desktop.py b/tests/unit/modules/test_mac_desktop.py index 1573fbe68c..48fe9fe157 100644 --- a/tests/unit/modules/test_mac_desktop.py +++ b/tests/unit/modules/test_mac_desktop.py @@ -7,14 +7,14 @@ Unit Tests for the mac_desktop execution module. from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mac_group.py b/tests/unit/modules/test_mac_group.py index 58ffa4dc75..dd3d54f0c1 100644 --- a/tests/unit/modules/test_mac_group.py +++ b/tests/unit/modules/test_mac_group.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import grp # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.mock import MagicMock, patch +from tests.support.unit import TestCase +from tests.support.mock import MagicMock, patch # Import Salt Libs from salt.modules import mac_group diff --git a/tests/unit/modules/test_mac_keychain.py b/tests/unit/modules/test_mac_keychain.py index 428b7c66f7..75697a4032 100644 --- a/tests/unit/modules/test_mac_keychain.py +++ b/tests/unit/modules/test_mac_keychain.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import mac_keychain as keychain # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/modules/test_mac_package.py b/tests/unit/modules/test_mac_package.py index adbc4c98bc..da05fbd9ae 100644 --- a/tests/unit/modules/test_mac_package.py +++ b/tests/unit/modules/test_mac_package.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import mac_package as macpackage # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, call diff --git a/tests/unit/modules/test_mac_pkgutil.py b/tests/unit/modules/test_mac_pkgutil.py index 9107d154d9..e9e5af7f56 100644 --- a/tests/unit/modules/test_mac_pkgutil.py +++ b/tests/unit/modules/test_mac_pkgutil.py @@ -7,8 +7,8 @@ from __future__ import absolute_import from salt.modules import mac_pkgutil # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch mac_pkgutil.__salt__ = {} diff --git a/tests/unit/modules/test_mac_power.py b/tests/unit/modules/test_mac_power.py index 615b9b600b..53ecd68e53 100644 --- a/tests/unit/modules/test_mac_power.py +++ b/tests/unit/modules/test_mac_power.py @@ -7,9 +7,9 @@ mac_power tests from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mac_sysctl.py b/tests/unit/modules/test_mac_sysctl.py index 533397bcfc..6b8293f88a 100644 --- a/tests/unit/modules/test_mac_sysctl.py +++ b/tests/unit/modules/test_mac_sysctl.py @@ -11,9 +11,9 @@ from salt.modules import mac_sysctl from salt.exceptions import CommandExecutionError # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, mock_open, patch, diff --git a/tests/unit/modules/test_mac_user.py b/tests/unit/modules/test_mac_user.py index 5d66564c39..a5a6a0cf72 100644 --- a/tests/unit/modules/test_mac_user.py +++ b/tests/unit/modules/test_mac_user.py @@ -9,9 +9,9 @@ import grp import pwd # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mac_xattr.py b/tests/unit/modules/test_mac_xattr.py index 85cd23fe37..3daa532734 100644 --- a/tests/unit/modules/test_mac_xattr.py +++ b/tests/unit/modules/test_mac_xattr.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mdadm.py b/tests/unit/modules/test_mdadm.py index 041ef03a5b..e5a175c2eb 100644 --- a/tests/unit/modules/test_mdadm.py +++ b/tests/unit/modules/test_mdadm.py @@ -11,9 +11,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_memcached.py b/tests/unit/modules/test_memcached.py index 368f4c99d5..f8c6e0890c 100644 --- a/tests/unit/modules/test_memcached.py +++ b/tests/unit/modules/test_memcached.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mine.py b/tests/unit/modules/test_mine.py index cdf85c4413..835cc171d9 100644 --- a/tests/unit/modules/test_mine.py +++ b/tests/unit/modules/test_mine.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mod_random.py b/tests/unit/modules/test_mod_random.py index 0d95883ed0..f60b71bad3 100644 --- a/tests/unit/modules/test_mod_random.py +++ b/tests/unit/modules/test_mod_random.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_modjk.py b/tests/unit/modules/test_modjk.py index 475968da56..e6aa9d42fa 100644 --- a/tests/unit/modules/test_modjk.py +++ b/tests/unit/modules/test_modjk.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_monit.py b/tests/unit/modules/test_monit.py index 7c5c5099fc..7adfd79f31 100644 --- a/tests/unit/modules/test_monit.py +++ b/tests/unit/modules/test_monit.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_moosefs.py b/tests/unit/modules/test_moosefs.py index 39bff085f3..61a75b659e 100644 --- a/tests/unit/modules/test_moosefs.py +++ b/tests/unit/modules/test_moosefs.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_mount.py b/tests/unit/modules/test_mount.py index 139d3265d0..ad5427c135 100644 --- a/tests/unit/modules/test_mount.py +++ b/tests/unit/modules/test_mount.py @@ -7,8 +7,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, patch, diff --git a/tests/unit/modules/test_munin.py b/tests/unit/modules/test_munin.py index 18b140bf51..55df2b481f 100644 --- a/tests/unit/modules/test_munin.py +++ b/tests/unit/modules/test_munin.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../..') diff --git a/tests/unit/modules/test_mysql.py b/tests/unit/modules/test_mysql.py index 623a53382d..87f61241f6 100644 --- a/tests/unit/modules/test_mysql.py +++ b/tests/unit/modules/test_mysql.py @@ -11,9 +11,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_nagios.py b/tests/unit/modules/test_nagios.py index ddde0032c2..1c8bb27a5a 100644 --- a/tests/unit/modules/test_nagios.py +++ b/tests/unit/modules/test_nagios.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_netscaler.py b/tests/unit/modules/test_netscaler.py index 324afecc2f..f891a7dbef 100644 --- a/tests/unit/modules/test_netscaler.py +++ b/tests/unit/modules/test_netscaler.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_network.py b/tests/unit/modules/test_network.py index 276bbed5db..56738370a1 100644 --- a/tests/unit/modules/test_network.py +++ b/tests/unit/modules/test_network.py @@ -9,8 +9,8 @@ import socket import os.path # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, patch, @@ -18,7 +18,7 @@ from salttesting.mock import ( NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_network_utils.py b/tests/unit/modules/test_network_utils.py index 7c0946b127..c30f7c97e0 100644 --- a/tests/unit/modules/test_network_utils.py +++ b/tests/unit/modules/test_network_utils.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting.case import ModuleCase +from tests.support.case import ModuleCase # Import Salt libs import salt.loader diff --git a/tests/unit/modules/test_neutron.py b/tests/unit/modules/test_neutron.py index 16c73fbed1..87b48e1dd4 100644 --- a/tests/unit/modules/test_neutron.py +++ b/tests/unit/modules/test_neutron.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_nfs3.py b/tests/unit/modules/test_nfs3.py index e84215dc9d..0628aac9e8 100644 --- a/tests/unit/modules/test_nfs3.py +++ b/tests/unit/modules/test_nfs3.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( mock_open, patch, NO_MOCK, diff --git a/tests/unit/modules/test_nftables.py b/tests/unit/modules/test_nftables.py index e8d5cb5307..b4eae6b430 100644 --- a/tests/unit/modules/test_nftables.py +++ b/tests/unit/modules/test_nftables.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, mock_open, patch, @@ -16,7 +16,7 @@ from salttesting.mock import ( NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_nginx.py b/tests/unit/modules/test_nginx.py index a4f1c34bc4..8e310f58c2 100644 --- a/tests/unit/modules/test_nginx.py +++ b/tests/unit/modules/test_nginx.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch ensure_in_syspath('../../') # Import Salt Module diff --git a/tests/unit/modules/test_nova.py b/tests/unit/modules/test_nova.py index ea1dd86ed9..9ce018261f 100644 --- a/tests/unit/modules/test_nova.py +++ b/tests/unit/modules/test_nova.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_npm.py b/tests/unit/modules/test_npm.py index 262a02af9b..6dbbe26885 100644 --- a/tests/unit/modules/test_npm.py +++ b/tests/unit/modules/test_npm.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_openbsdpkg.py b/tests/unit/modules/test_openbsdpkg.py index 80b8cce368..fe8fd97e0d 100644 --- a/tests/unit/modules/test_openbsdpkg.py +++ b/tests/unit/modules/test_openbsdpkg.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, call, diff --git a/tests/unit/modules/test_openscap.py b/tests/unit/modules/test_openscap.py index 327af75238..d90b5a95b0 100644 --- a/tests/unit/modules/test_openscap.py +++ b/tests/unit/modules/test_openscap.py @@ -5,8 +5,8 @@ from subprocess import PIPE from salt.modules import openscap -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( Mock, MagicMock, patch, diff --git a/tests/unit/modules/test_openstack_config.py b/tests/unit/modules/test_openstack_config.py index b11eac61f5..9f8013986e 100644 --- a/tests/unit/modules/test_openstack_config.py +++ b/tests/unit/modules/test_openstack_config.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_oracle.py b/tests/unit/modules/test_oracle.py index 159cc37abd..7d5df1a8ba 100644 --- a/tests/unit/modules/test_oracle.py +++ b/tests/unit/modules/test_oracle.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_pacman.py b/tests/unit/modules/test_pacman.py index 0404ab1c9f..7bbb07175d 100644 --- a/tests/unit/modules/test_pacman.py +++ b/tests/unit/modules/test_pacman.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_pagerduty.py b/tests/unit/modules/test_pagerduty.py index b3a4e80a9b..4fce593ff8 100644 --- a/tests/unit/modules/test_pagerduty.py +++ b/tests/unit/modules/test_pagerduty.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( patch, MagicMock, NO_MOCK, diff --git a/tests/unit/modules/test_pam.py b/tests/unit/modules/test_pam.py index a225f96e59..a12721827c 100644 --- a/tests/unit/modules/test_pam.py +++ b/tests/unit/modules/test_pam.py @@ -8,15 +8,15 @@ from __future__ import absolute_import import sys # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, mock_open, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_parallels.py b/tests/unit/modules/test_parallels.py index 9c1a4a95c8..6fe34ab19a 100644 --- a/tests/unit/modules/test_parallels.py +++ b/tests/unit/modules/test_parallels.py @@ -9,9 +9,9 @@ from salt.modules import parallels from salt.exceptions import SaltInvocationError # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath # Import third party libs import salt.ext.six as six diff --git a/tests/unit/modules/test_parted.py b/tests/unit/modules/test_parted.py index 22d964eaad..131b27999e 100644 --- a/tests/unit/modules/test_parted.py +++ b/tests/unit/modules/test_parted.py @@ -11,9 +11,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_pecl.py b/tests/unit/modules/test_pecl.py index dcbe7f3e3a..c3572b4353 100644 --- a/tests/unit/modules/test_pecl.py +++ b/tests/unit/modules/test_pecl.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_pillar.py b/tests/unit/modules/test_pillar.py index da1d39d1ac..e01b3f933d 100644 --- a/tests/unit/modules/test_pillar.py +++ b/tests/unit/modules/test_pillar.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_pip.py b/tests/unit/modules/test_pip.py index 9870bb2355..d17b9362bc 100644 --- a/tests/unit/modules/test_pip.py +++ b/tests/unit/modules/test_pip.py @@ -5,9 +5,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_pkg_resource.py b/tests/unit/modules/test_pkg_resource.py index 0db33f6a44..3862a1f0d5 100644 --- a/tests/unit/modules/test_pkg_resource.py +++ b/tests/unit/modules/test_pkg_resource.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import yaml # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_pkgutil.py b/tests/unit/modules/test_pkgutil.py index 5fdfd02b3f..3d6842ae63 100644 --- a/tests/unit/modules/test_pkgutil.py +++ b/tests/unit/modules/test_pkgutil.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_portage_config.py b/tests/unit/modules/test_portage_config.py index 6275442cea..dca1bae480 100644 --- a/tests/unit/modules/test_portage_config.py +++ b/tests/unit/modules/test_portage_config.py @@ -9,9 +9,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_postfix.py b/tests/unit/modules/test_postfix.py index d9be2b305e..a963c4d910 100644 --- a/tests/unit/modules/test_postfix.py +++ b/tests/unit/modules/test_postfix.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_postgres.py b/tests/unit/modules/test_postgres.py index c5d562865c..b0ed2d7f65 100644 --- a/tests/unit/modules/test_postgres.py +++ b/tests/unit/modules/test_postgres.py @@ -6,9 +6,9 @@ from mock import call import re # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_poudriere.py b/tests/unit/modules/test_poudriere.py index c883ce2d22..d88c88480d 100644 --- a/tests/unit/modules/test_poudriere.py +++ b/tests/unit/modules/test_poudriere.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, mock_open, @@ -16,7 +16,7 @@ from salttesting.mock import ( NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath import os ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_powerpath.py b/tests/unit/modules/test_powerpath.py index c9f1bdbbf7..fd4277a59d 100644 --- a/tests/unit/modules/test_powerpath.py +++ b/tests/unit/modules/test_powerpath.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_proxy.py b/tests/unit/modules/test_proxy.py index 3338861fa3..6273c9c90f 100644 --- a/tests/unit/modules/test_proxy.py +++ b/tests/unit/modules/test_proxy.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import proxy as proxy # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/modules/test_ps.py b/tests/unit/modules/test_ps.py index a0accb1161..9545e5edb8 100644 --- a/tests/unit/modules/test_ps.py +++ b/tests/unit/modules/test_ps.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch, call, Mock +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch, call, Mock ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_publish.py b/tests/unit/modules/test_publish.py index f74721fae1..2cb323a2a8 100644 --- a/tests/unit/modules/test_publish.py +++ b/tests/unit/modules/test_publish.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_puppet.py b/tests/unit/modules/test_puppet.py index 2cdd6969b4..b71e5903b8 100644 --- a/tests/unit/modules/test_puppet.py +++ b/tests/unit/modules/test_puppet.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( mock_open, MagicMock, patch, diff --git a/tests/unit/modules/test_pw_group.py b/tests/unit/modules/test_pw_group.py index 696111f417..ad51429a77 100644 --- a/tests/unit/modules/test_pw_group.py +++ b/tests/unit/modules/test_pw_group.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_pw_user.py b/tests/unit/modules/test_pw_user.py index b146c5e534..b0643c066a 100644 --- a/tests/unit/modules/test_pw_user.py +++ b/tests/unit/modules/test_pw_user.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_pyenv.py b/tests/unit/modules/test_pyenv.py index d5b7728bef..0d60d4f257 100644 --- a/tests/unit/modules/test_pyenv.py +++ b/tests/unit/modules/test_pyenv.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_qemu_img.py b/tests/unit/modules/test_qemu_img.py index ae1541e9bc..e6fd14e318 100644 --- a/tests/unit/modules/test_qemu_img.py +++ b/tests/unit/modules/test_qemu_img.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_qemu_nbd.py b/tests/unit/modules/test_qemu_nbd.py index ee3e3a6706..0fc395ecf5 100644 --- a/tests/unit/modules/test_qemu_nbd.py +++ b/tests/unit/modules/test_qemu_nbd.py @@ -10,15 +10,15 @@ import glob import tempfile # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rabbitmq.py b/tests/unit/modules/test_rabbitmq.py index 1312d07fc9..ae4c639fee 100644 --- a/tests/unit/modules/test_rabbitmq.py +++ b/tests/unit/modules/test_rabbitmq.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_raet_publish.py b/tests/unit/modules/test_raet_publish.py index ad8c764bd2..883591df60 100644 --- a/tests/unit/modules/test_raet_publish.py +++ b/tests/unit/modules/test_raet_publish.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rbenv.py b/tests/unit/modules/test_rbenv.py index cb5b314cf9..ed0cbcc4f4 100644 --- a/tests/unit/modules/test_rbenv.py +++ b/tests/unit/modules/test_rbenv.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rdp.py b/tests/unit/modules/test_rdp.py index 0c27fc9c17..689e4fd1de 100644 --- a/tests/unit/modules/test_rdp.py +++ b/tests/unit/modules/test_rdp.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/modules/test_redismod.py b/tests/unit/modules/test_redismod.py index c0e0363880..da44cad8fe 100644 --- a/tests/unit/modules/test_redismod.py +++ b/tests/unit/modules/test_redismod.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_reg_win.py b/tests/unit/modules/test_reg_win.py index ac73f46d6a..8a7bacc1db 100644 --- a/tests/unit/modules/test_reg_win.py +++ b/tests/unit/modules/test_reg_win.py @@ -13,8 +13,8 @@ from __future__ import unicode_literals import sys import time # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import destructiveTest +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import destructiveTest # Import Salt Libs from salt.modules import reg as win_mod_reg from salt.ext import six diff --git a/tests/unit/modules/test_ret.py b/tests/unit/modules/test_ret.py index 253e2152e9..3adc3aba86 100644 --- a/tests/unit/modules/test_ret.py +++ b/tests/unit/modules/test_ret.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rh_ip.py b/tests/unit/modules/test_rh_ip.py index 3457ecb48f..971c537799 100644 --- a/tests/unit/modules/test_rh_ip.py +++ b/tests/unit/modules/test_rh_ip.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rh_service.py b/tests/unit/modules/test_rh_service.py index 963783446d..32b78c4f20 100644 --- a/tests/unit/modules/test_rh_service.py +++ b/tests/unit/modules/test_rh_service.py @@ -8,15 +8,15 @@ from __future__ import absolute_import import textwrap # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_riak.py b/tests/unit/modules/test_riak.py index c8dc26e36d..ca86721204 100644 --- a/tests/unit/modules/test_riak.py +++ b/tests/unit/modules/test_riak.py @@ -6,13 +6,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rpm.py b/tests/unit/modules/test_rpm.py index 6caf39dde8..5b587054c5 100644 --- a/tests/unit/modules/test_rpm.py +++ b/tests/unit/modules/test_rpm.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rsync.py b/tests/unit/modules/test_rsync.py index 8ef652f04f..12a7a021f6 100644 --- a/tests/unit/modules/test_rsync.py +++ b/tests/unit/modules/test_rsync.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_rvm.py b/tests/unit/modules/test_rvm.py index eb6b4cc1da..9ab766c711 100644 --- a/tests/unit/modules/test_rvm.py +++ b/tests/unit/modules/test_rvm.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_s3.py b/tests/unit/modules/test_s3.py index cd063e8c39..ef6f164518 100644 --- a/tests/unit/modules/test_s3.py +++ b/tests/unit/modules/test_s3.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_s6.py b/tests/unit/modules/test_s6.py index 9199838367..b8b7081a5d 100644 --- a/tests/unit/modules/test_s6.py +++ b/tests/unit/modules/test_s6.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_saltcloudmod.py b/tests/unit/modules/test_saltcloudmod.py index 8e6a21942e..a06d53a1cd 100644 --- a/tests/unit/modules/test_saltcloudmod.py +++ b/tests/unit/modules/test_saltcloudmod.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_schedule.py b/tests/unit/modules/test_schedule.py index 2d7a1394c2..37c63ad840 100644 --- a/tests/unit/modules/test_schedule.py +++ b/tests/unit/modules/test_schedule.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath import os import integration diff --git a/tests/unit/modules/test_scsi.py b/tests/unit/modules/test_scsi.py index f1b73a713c..9670cc9002 100644 --- a/tests/unit/modules/test_scsi.py +++ b/tests/unit/modules/test_scsi.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_sdb.py b/tests/unit/modules/test_sdb.py index 3655a6f7af..c667bc5fa1 100644 --- a/tests/unit/modules/test_sdb.py +++ b/tests/unit/modules/test_sdb.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_seed.py b/tests/unit/modules/test_seed.py index 44fcd5c5d2..d3585cd3d9 100644 --- a/tests/unit/modules/test_seed.py +++ b/tests/unit/modules/test_seed.py @@ -8,8 +8,8 @@ import os import shutil # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, @@ -19,7 +19,7 @@ from salttesting.mock import ( # Import Salt Libs import salt.utils.odict from salt.modules import seed -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_sensors.py b/tests/unit/modules/test_sensors.py index 73b2d79a2e..2351fb94b5 100644 --- a/tests/unit/modules/test_sensors.py +++ b/tests/unit/modules/test_sensors.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_serverdensity_device.py b/tests/unit/modules/test_serverdensity_device.py index 2fad768427..8a1d3e4a89 100644 --- a/tests/unit/modules/test_serverdensity_device.py +++ b/tests/unit/modules/test_serverdensity_device.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_service.py b/tests/unit/modules/test_service.py index 825c536585..f821cb653e 100644 --- a/tests/unit/modules/test_service.py +++ b/tests/unit/modules/test_service.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_servicenow.py b/tests/unit/modules/test_servicenow.py index 7b835e96ab..4339fa5387 100644 --- a/tests/unit/modules/test_servicenow.py +++ b/tests/unit/modules/test_servicenow.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf +from tests.support.unit import skipIf from tests.unit import ModuleTestCase, hasDependency -from salttesting.mock import ( +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.modules import servicenow ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_shadow.py b/tests/unit/modules/test_shadow.py index 0a3de7ee52..12b5efe6b6 100644 --- a/tests/unit/modules/test_shadow.py +++ b/tests/unit/modules/test_shadow.py @@ -8,8 +8,8 @@ from __future__ import absolute_import # Import Salt Testing libs from salt.utils import is_linux -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_smf.py b/tests/unit/modules/test_smf.py index d541c8dbf2..d26114747d 100644 --- a/tests/unit/modules/test_smf.py +++ b/tests/unit/modules/test_smf.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_smtp.py b/tests/unit/modules/test_smtp.py index 7ea6f3e2da..0d214987ab 100644 --- a/tests/unit/modules/test_smtp.py +++ b/tests/unit/modules/test_smtp.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_snapper.py b/tests/unit/modules/test_snapper.py index a5d9b7686e..f550dd68b7 100644 --- a/tests/unit/modules/test_snapper.py +++ b/tests/unit/modules/test_snapper.py @@ -11,15 +11,15 @@ from __future__ import absolute_import import sys # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch, mock_open, ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_solr.py b/tests/unit/modules/test_solr.py index b6ba30b080..a81b27dc9a 100644 --- a/tests/unit/modules/test_solr.py +++ b/tests/unit/modules/test_solr.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_sqlite3.py b/tests/unit/modules/test_sqlite3.py index 3f221cc023..a3cb7ef589 100644 --- a/tests/unit/modules/test_sqlite3.py +++ b/tests/unit/modules/test_sqlite3.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_ssh.py b/tests/unit/modules/test_ssh.py index 5958144ab9..a063da6500 100644 --- a/tests/unit/modules/test_ssh.py +++ b/tests/unit/modules/test_ssh.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) diff --git a/tests/unit/modules/test_state.py b/tests/unit/modules/test_state.py index aea035c0da..ecff57459c 100644 --- a/tests/unit/modules/test_state.py +++ b/tests/unit/modules/test_state.py @@ -8,10 +8,10 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import TestCase, skipIf +from tests.support.unit import TestCase, skipIf from salt.exceptions import SaltInvocationError -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, mock_open, diff --git a/tests/unit/modules/test_status.py b/tests/unit/modules/test_status.py index 1a78474e4a..5ebec273e4 100644 --- a/tests/unit/modules/test_status.py +++ b/tests/unit/modules/test_status.py @@ -8,9 +8,9 @@ from salt.modules import status from salt.exceptions import CommandExecutionError # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, mock_open, diff --git a/tests/unit/modules/test_supervisord.py b/tests/unit/modules/test_supervisord.py index ed36e18a67..94d6aec7f0 100644 --- a/tests/unit/modules/test_supervisord.py +++ b/tests/unit/modules/test_supervisord.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_svn.py b/tests/unit/modules/test_svn.py index bc7b0bf6bc..0b380f1f7d 100644 --- a/tests/unit/modules/test_svn.py +++ b/tests/unit/modules/test_svn.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_swift.py b/tests/unit/modules/test_swift.py index 25ea4a6423..a1157b00cf 100644 --- a/tests/unit/modules/test_swift.py +++ b/tests/unit/modules/test_swift.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_sysbench.py b/tests/unit/modules/test_sysbench.py index a236229f34..ff156a8a8e 100644 --- a/tests/unit/modules/test_sysbench.py +++ b/tests/unit/modules/test_sysbench.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_syslog_ng.py b/tests/unit/modules/test_syslog_ng.py index 66f4f61a52..f1eb551018 100644 --- a/tests/unit/modules/test_syslog_ng.py +++ b/tests/unit/modules/test_syslog_ng.py @@ -8,9 +8,9 @@ from __future__ import absolute_import from textwrap import dedent # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_sysmod.py b/tests/unit/modules/test_sysmod.py index 6fd7e6094c..8f12f5bf54 100644 --- a/tests/unit/modules/test_sysmod.py +++ b/tests/unit/modules/test_sysmod.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_system.py b/tests/unit/modules/test_system.py index 33279cdfa4..e9322536d6 100644 --- a/tests/unit/modules/test_system.py +++ b/tests/unit/modules/test_system.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_systemd.py b/tests/unit/modules/test_systemd.py index 59cb247320..f79e2d8e24 100644 --- a/tests/unit/modules/test_systemd.py +++ b/tests/unit/modules/test_systemd.py @@ -9,9 +9,9 @@ import os # Import Salt Testing Libs from salt.exceptions import CommandExecutionError -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_timezone.py b/tests/unit/modules/test_timezone.py index cc1d9ed7bd..3a9f1eb0ef 100644 --- a/tests/unit/modules/test_timezone.py +++ b/tests/unit/modules/test_timezone.py @@ -7,9 +7,9 @@ import os # Import Salt Testing Libs from salt.exceptions import CommandExecutionError, SaltInvocationError -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON diff --git a/tests/unit/modules/test_tls.py b/tests/unit/modules/test_tls.py index 8009d2f941..fa50a55f1d 100644 --- a/tests/unit/modules/test_tls.py +++ b/tests/unit/modules/test_tls.py @@ -20,15 +20,15 @@ except Exception: NO_PYOPENSSL = True # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( mock_open, MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import destructiveTest +from tests.support.helpers import destructiveTest # Import Salt Libs from salt.modules import tls diff --git a/tests/unit/modules/test_twilio_notify.py b/tests/unit/modules/test_twilio_notify.py index f114bc4b4c..97426317f9 100644 --- a/tests/unit/modules/test_twilio_notify.py +++ b/tests/unit/modules/test_twilio_notify.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_udev.py b/tests/unit/modules/test_udev.py index f40c3afda9..955dcac5e7 100644 --- a/tests/unit/modules/test_udev.py +++ b/tests/unit/modules/test_udev.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_uptime.py b/tests/unit/modules/test_uptime.py index 8e7d33806a..91e7b9a606 100644 --- a/tests/unit/modules/test_uptime.py +++ b/tests/unit/modules/test_uptime.py @@ -4,9 +4,9 @@ from __future__ import absolute_import, print_function # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch ensure_in_syspath('../../') ensure_in_syspath('../../../') diff --git a/tests/unit/modules/test_useradd.py b/tests/unit/modules/test_useradd.py index cc9e610366..d48d16a2ce 100644 --- a/tests/unit/modules/test_useradd.py +++ b/tests/unit/modules/test_useradd.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_uwsgi.py b/tests/unit/modules/test_uwsgi.py index ac0add0b70..859197c812 100644 --- a/tests/unit/modules/test_uwsgi.py +++ b/tests/unit/modules/test_uwsgi.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, Mock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, Mock, patch from salt.modules import uwsgi diff --git a/tests/unit/modules/test_varnish.py b/tests/unit/modules/test_varnish.py index 7cc180e48e..1ac809bc15 100644 --- a/tests/unit/modules/test_varnish.py +++ b/tests/unit/modules/test_varnish.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py index 8ddbf0423e..2f613ed7aa 100644 --- a/tests/unit/modules/test_virt.py +++ b/tests/unit/modules/test_virt.py @@ -6,9 +6,9 @@ import sys import re # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_virtualenv.py b/tests/unit/modules/test_virtualenv.py index 5f686266c1..ed006ad161 100644 --- a/tests/unit/modules/test_virtualenv.py +++ b/tests/unit/modules/test_virtualenv.py @@ -12,13 +12,13 @@ from __future__ import absolute_import import sys # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ( ensure_in_syspath, TestsLoggingHandler, ForceImportErrorOn ) -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/modules/test_vsphere.py b/tests/unit/modules/test_vsphere.py index 1250d47310..998b057eec 100644 --- a/tests/unit/modules/test_vsphere.py +++ b/tests/unit/modules/test_vsphere.py @@ -14,14 +14,14 @@ from salt.modules import vsphere from salt.exceptions import CommandExecutionError, VMwareSaltError # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_autoruns.py b/tests/unit/modules/test_win_autoruns.py index c598f8bb06..c886325e53 100644 --- a/tests/unit/modules/test_win_autoruns.py +++ b/tests/unit/modules/test_win_autoruns.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_certutil.py b/tests/unit/modules/test_win_certutil.py index 07a0a6b4e5..a343fe42d9 100644 --- a/tests/unit/modules/test_win_certutil.py +++ b/tests/unit/modules/test_win_certutil.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import win_certutil as certutil # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/modules/test_win_disk.py b/tests/unit/modules/test_win_disk.py index c035b24882..e94be03d0a 100644 --- a/tests/unit/modules/test_win_disk.py +++ b/tests/unit/modules/test_win_disk.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_dism.py b/tests/unit/modules/test_win_dism.py index 1cdf8ef8c2..95f83c49f8 100644 --- a/tests/unit/modules/test_win_dism.py +++ b/tests/unit/modules/test_win_dism.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import win_dism as dism # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/modules/test_win_dns_client.py b/tests/unit/modules/test_win_dns_client.py index 372c3a9c00..f997c5e2da 100644 --- a/tests/unit/modules/test_win_dns_client.py +++ b/tests/unit/modules/test_win_dns_client.py @@ -9,8 +9,8 @@ import sys import types # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, Mock, @@ -18,7 +18,7 @@ from salttesting.mock import ( NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_firewall.py b/tests/unit/modules/test_win_firewall.py index b302ff81a4..ce2672afec 100644 --- a/tests/unit/modules/test_win_firewall.py +++ b/tests/unit/modules/test_win_firewall.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, call ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_groupadd.py b/tests/unit/modules/test_win_groupadd.py index 357e36c92e..6c182014ed 100644 --- a/tests/unit/modules/test_win_groupadd.py +++ b/tests/unit/modules/test_win_groupadd.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_iis.py b/tests/unit/modules/test_win_iis.py index a3347cab24..f525089daa 100644 --- a/tests/unit/modules/test_win_iis.py +++ b/tests/unit/modules/test_win_iis.py @@ -15,9 +15,9 @@ from salt.exceptions import SaltInvocationError from salt.modules import win_iis # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_win_ip.py b/tests/unit/modules/test_win_ip.py index 29c4b6a3a9..5992e96d5d 100644 --- a/tests/unit/modules/test_win_ip.py +++ b/tests/unit/modules/test_win_ip.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_license.py b/tests/unit/modules/test_win_license.py index 7006b5bb4a..c27a11af42 100644 --- a/tests/unit/modules/test_win_license.py +++ b/tests/unit/modules/test_win_license.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import win_license as license # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/modules/test_win_network.py b/tests/unit/modules/test_win_network.py index bdf9312776..a73ab617a8 100644 --- a/tests/unit/modules/test_win_network.py +++ b/tests/unit/modules/test_win_network.py @@ -10,8 +10,8 @@ import sys import types # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, Mock, @@ -19,7 +19,7 @@ from salttesting.mock import ( NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_ntp.py b/tests/unit/modules/test_win_ntp.py index cead3dbceb..4712cc0f49 100644 --- a/tests/unit/modules/test_win_ntp.py +++ b/tests/unit/modules/test_win_ntp.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_path.py b/tests/unit/modules/test_win_path.py index 579ba00574..b722c343d6 100644 --- a/tests/unit/modules/test_win_path.py +++ b/tests/unit/modules/test_win_path.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_win_pki.py b/tests/unit/modules/test_win_pki.py index 5ac0fa07b5..d3d172be84 100644 --- a/tests/unit/modules/test_win_pki.py +++ b/tests/unit/modules/test_win_pki.py @@ -13,9 +13,9 @@ from __future__ import absolute_import from salt.modules import win_pki # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_win_powercfg.py b/tests/unit/modules/test_win_powercfg.py index 775da9060a..1bbb1f39d7 100644 --- a/tests/unit/modules/test_win_powercfg.py +++ b/tests/unit/modules/test_win_powercfg.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.modules import win_powercfg as powercfg # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/modules/test_win_service.py b/tests/unit/modules/test_win_service.py index f56ee435ee..f63f68cbb2 100644 --- a/tests/unit/modules/test_win_service.py +++ b/tests/unit/modules/test_win_service.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_win_shadow.py b/tests/unit/modules/test_win_shadow.py index 0ab1031982..74e60e994c 100644 --- a/tests/unit/modules/test_win_shadow.py +++ b/tests/unit/modules/test_win_shadow.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_win_snmp.py b/tests/unit/modules/test_win_snmp.py index 7cb3643e1a..89fe9913a8 100644 --- a/tests/unit/modules/test_win_snmp.py +++ b/tests/unit/modules/test_win_snmp.py @@ -13,9 +13,9 @@ from __future__ import absolute_import from salt.modules import win_snmp # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_win_status.py b/tests/unit/modules/test_win_status.py index 7b62da80b5..61eb89e18d 100644 --- a/tests/unit/modules/test_win_status.py +++ b/tests/unit/modules/test_win_status.py @@ -9,8 +9,8 @@ import types import salt.ext.six as six # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # wmi and pythoncom modules are platform specific... @@ -20,7 +20,7 @@ sys.modules['wmi'] = wmi pythoncom = types.ModuleType('pythoncom') sys.modules['pythoncom'] = pythoncom -from salttesting.mock import NO_MOCK, Mock, patch, ANY +from tests.support.mock import NO_MOCK, Mock, patch, ANY if NO_MOCK is False: WMI = Mock() diff --git a/tests/unit/modules/test_win_system.py b/tests/unit/modules/test_win_system.py index 91c667384c..fcd5187f3e 100644 --- a/tests/unit/modules/test_win_system.py +++ b/tests/unit/modules/test_win_system.py @@ -8,9 +8,9 @@ from __future__ import absolute_import from datetime import datetime # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_win_timezone.py b/tests/unit/modules/test_win_timezone.py index 208633cd5c..ed756e4587 100644 --- a/tests/unit/modules/test_win_timezone.py +++ b/tests/unit/modules/test_win_timezone.py @@ -7,13 +7,13 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_xapi.py b/tests/unit/modules/test_xapi.py index 7c02098a7f..bd69a51439 100644 --- a/tests/unit/modules/test_xapi.py +++ b/tests/unit/modules/test_xapi.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( mock_open, MagicMock, patch, diff --git a/tests/unit/modules/test_zcbuildout.py b/tests/unit/modules/test_zcbuildout.py index 36434ddbcd..e11bbf1a56 100644 --- a/tests/unit/modules/test_zcbuildout.py +++ b/tests/unit/modules/test_zcbuildout.py @@ -15,8 +15,8 @@ from salt.ext.six.moves.urllib.request import urlopen # pylint: enable=import-error,no-name-in-module,redefined-builtin # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ( ensure_in_syspath, requires_network, skip_if_binaries_missing diff --git a/tests/unit/modules/test_zfs.py b/tests/unit/modules/test_zfs.py index 130e7bcb3e..c31e9b7b8e 100644 --- a/tests/unit/modules/test_zfs.py +++ b/tests/unit/modules/test_zfs.py @@ -10,11 +10,11 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath # Import Mock libraries -from salttesting.mock import ( +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_znc.py b/tests/unit/modules/test_znc.py index 9f7aec9291..5919249f9c 100644 --- a/tests/unit/modules/test_znc.py +++ b/tests/unit/modules/test_znc.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/modules/test_zpool.py b/tests/unit/modules/test_zpool.py index 37d3018dc9..c661f796c9 100644 --- a/tests/unit/modules/test_zpool.py +++ b/tests/unit/modules/test_zpool.py @@ -10,11 +10,11 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath # Import Mock libraries -from salttesting.mock import ( +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/modules/test_zypper.py b/tests/unit/modules/test_zypper.py index 5f1ff8ea0c..146a7ca110 100644 --- a/tests/unit/modules/test_zypper.py +++ b/tests/unit/modules/test_zypper.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( Mock, MagicMock, call, diff --git a/tests/unit/netapi/rest_tornado/test_handlers.py b/tests/unit/netapi/rest_tornado/test_handlers.py index 3f58c4ba7a..b23b91772e 100644 --- a/tests/unit/netapi/rest_tornado/test_handlers.py +++ b/tests/unit/netapi/rest_tornado/test_handlers.py @@ -9,8 +9,8 @@ import copy import hashlib # Import Salt Testing Libs -from salttesting.unit import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../..') import integration # pylint: disable=import-error @@ -43,7 +43,7 @@ import salt.ext.six as six from salt.ext.six.moves.urllib.parse import urlencode, urlparse # pylint: disable=no-name-in-module # pylint: enable=import-error -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch @skipIf(HAS_TORNADO is False, 'The tornado package needs to be installed') # pylint: disable=W0223 diff --git a/tests/unit/netapi/rest_tornado/test_utils.py b/tests/unit/netapi/rest_tornado/test_utils.py index b3d0f476e3..db512fcc0d 100644 --- a/tests/unit/netapi/rest_tornado/test_utils.py +++ b/tests/unit/netapi/rest_tornado/test_utils.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting.unit import skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../..') # Import 3rd-party libs diff --git a/tests/unit/output/test_json_out.py b/tests/unit/output/test_json_out.py index 7e2c4ee48f..931be7a091 100644 --- a/tests/unit/output/test_json_out.py +++ b/tests/unit/output/test_json_out.py @@ -8,8 +8,8 @@ from __future__ import absolute_import import json # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/output/test_yaml_out.py b/tests/unit/output/test_yaml_out.py index b8d1511771..14a484675e 100644 --- a/tests/unit/output/test_yaml_out.py +++ b/tests/unit/output/test_yaml_out.py @@ -7,8 +7,8 @@ unittests for yaml outputter from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/pillar/test_consul.py b/tests/unit/pillar/test_consul.py index 730f77bdc3..9cce5b1a3e 100644 --- a/tests/unit/pillar/test_consul.py +++ b/tests/unit/pillar/test_consul.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/pillar/test_git.py b/tests/unit/pillar/test_git.py index a36f6d480f..926c217b86 100644 --- a/tests/unit/pillar/test_git.py +++ b/tests/unit/pillar/test_git.py @@ -18,8 +18,8 @@ import subprocess import yaml # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON import integration diff --git a/tests/unit/pillar/test_hg.py b/tests/unit/pillar/test_hg.py index a5a592e9c1..648a32ecf5 100644 --- a/tests/unit/pillar/test_hg.py +++ b/tests/unit/pillar/test_hg.py @@ -11,8 +11,8 @@ import subprocess import yaml # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON import integration diff --git a/tests/unit/pillar/test_mysql.py b/tests/unit/pillar/test_mysql.py index 46c62e83c8..35597b0286 100644 --- a/tests/unit/pillar/test_mysql.py +++ b/tests/unit/pillar/test_mysql.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/pillar/test_nodegroups.py b/tests/unit/pillar/test_nodegroups.py index 95b9c1a819..17c73bbf6d 100644 --- a/tests/unit/pillar/test_nodegroups.py +++ b/tests/unit/pillar/test_nodegroups.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, MagicMock +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, MagicMock ensure_in_syspath('../../') diff --git a/tests/unit/pillar/test_sqlcipher.py b/tests/unit/pillar/test_sqlcipher.py index f12cdcc66c..c609e06c74 100644 --- a/tests/unit/pillar/test_sqlcipher.py +++ b/tests/unit/pillar/test_sqlcipher.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/pillar/test_sqlite3.py b/tests/unit/pillar/test_sqlite3.py index 32d889971c..928bc63c5a 100644 --- a/tests/unit/pillar/test_sqlite3.py +++ b/tests/unit/pillar/test_sqlite3.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/renderers/test_gpg.py b/tests/unit/renderers/test_gpg.py index 601d171f42..6cf22eba7f 100644 --- a/tests/unit/renderers/test_gpg.py +++ b/tests/unit/renderers/test_gpg.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/renderers/test_yaml.py b/tests/unit/renderers/test_yaml.py index 45af476ab7..cb2f531548 100644 --- a/tests/unit/renderers/test_yaml.py +++ b/tests/unit/renderers/test_yaml.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/renderers/test_yamlex.py b/tests/unit/renderers/test_yamlex.py index d588747503..fdf805c181 100644 --- a/tests/unit/renderers/test_yamlex.py +++ b/tests/unit/renderers/test_yamlex.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../..') diff --git a/tests/unit/returners/test_local_cache.py b/tests/unit/returners/test_local_cache.py index 76f5e7371d..fa9375492c 100644 --- a/tests/unit/returners/test_local_cache.py +++ b/tests/unit/returners/test_local_cache.py @@ -13,9 +13,9 @@ import shutil import tempfile # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import destructiveTest, ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import destructiveTest, ensure_in_syspath +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, diff --git a/tests/unit/returners/test_smtp_return.py b/tests/unit/returners/test_smtp_return.py index 065825d13e..22107046a0 100644 --- a/tests/unit/returners/test_smtp_return.py +++ b/tests/unit/returners/test_smtp_return.py @@ -11,9 +11,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/runners/test_cache.py b/tests/unit/runners/test_cache.py index 11f610e23b..3f2a15d261 100644 --- a/tests/unit/runners/test_cache.py +++ b/tests/unit/runners/test_cache.py @@ -7,9 +7,9 @@ unit tests for the cache runner from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, patch diff --git a/tests/unit/runners/test_jobs.py b/tests/unit/runners/test_jobs.py index c2893f9e94..c6224b6efe 100644 --- a/tests/unit/runners/test_jobs.py +++ b/tests/unit/runners/test_jobs.py @@ -7,9 +7,9 @@ unit tests for the jobs runner from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, patch diff --git a/tests/unit/serializers/test_serializers.py b/tests/unit/serializers/test_serializers.py index 16d9794b01..8899402150 100644 --- a/tests/unit/serializers/test_serializers.py +++ b/tests/unit/serializers/test_serializers.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/ssh/test_ssh_single.py b/tests/unit/ssh/test_ssh_single.py index cd6938f40c..c32bece7f1 100644 --- a/tests/unit/ssh/test_ssh_single.py +++ b/tests/unit/ssh/test_ssh_single.py @@ -9,9 +9,9 @@ import tempfile import os.path # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../') diff --git a/tests/unit/states/test_alias.py b/tests/unit/states/test_alias.py index 28927e0f8a..9da97de8d8 100644 --- a/tests/unit/states/test_alias.py +++ b/tests/unit/states/test_alias.py @@ -7,9 +7,9 @@ unit tests for the alias state from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_alternatives.py b/tests/unit/states/test_alternatives.py index 5a4de2edbb..2c418f321b 100644 --- a/tests/unit/states/test_alternatives.py +++ b/tests/unit/states/test_alternatives.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_apache.py b/tests/unit/states/test_apache.py index cc652da972..c134f2d561 100644 --- a/tests/unit/states/test_apache.py +++ b/tests/unit/states/test_apache.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch, mock_open) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_apache_conf.py b/tests/unit/states/test_apache_conf.py index 91b83eedf0..787506fdb4 100644 --- a/tests/unit/states/test_apache_conf.py +++ b/tests/unit/states/test_apache_conf.py @@ -3,15 +3,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_apache_module.py b/tests/unit/states/test_apache_module.py index db026d7671..4601fd94fc 100644 --- a/tests/unit/states/test_apache_module.py +++ b/tests/unit/states/test_apache_module.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_apache_site.py b/tests/unit/states/test_apache_site.py index 36f805bdf8..2cd059bcbb 100644 --- a/tests/unit/states/test_apache_site.py +++ b/tests/unit/states/test_apache_site.py @@ -3,15 +3,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_apt.py b/tests/unit/states/test_apt.py index 5cbcaf6b44..cf9f128157 100644 --- a/tests/unit/states/test_apt.py +++ b/tests/unit/states/test_apt.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_archive.py b/tests/unit/states/test_archive.py index 1d55e484ba..149cee4bc8 100644 --- a/tests/unit/states/test_archive.py +++ b/tests/unit/states/test_archive.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_artifactory.py b/tests/unit/states/test_artifactory.py index c85025b34a..bf56a03a74 100644 --- a/tests/unit/states/test_artifactory.py +++ b/tests/unit/states/test_artifactory.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_at.py b/tests/unit/states/test_at.py index a487270be8..52a6a0b207 100644 --- a/tests/unit/states/test_at.py +++ b/tests/unit/states/test_at.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_augeas.py b/tests/unit/states/test_augeas.py index c49ef5e62f..509ed9ece8 100644 --- a/tests/unit/states/test_augeas.py +++ b/tests/unit/states/test_augeas.py @@ -9,8 +9,8 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( mock_open, NO_MOCK, NO_MOCK_REASON, @@ -18,7 +18,7 @@ from salttesting.mock import ( patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_aws_sqs.py b/tests/unit/states/test_aws_sqs.py index 4d810cdc18..df9974b3e9 100644 --- a/tests/unit/states/test_aws_sqs.py +++ b/tests/unit/states/test_aws_sqs.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_blockdev.py b/tests/unit/states/test_blockdev.py index 857c8aa2ca..ca8f56df8d 100644 --- a/tests/unit/states/test_blockdev.py +++ b/tests/unit/states/test_blockdev.py @@ -7,14 +7,14 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_apigateway.py b/tests/unit/states/test_boto_apigateway.py index daae8a15de..4b8d4e0c6a 100644 --- a/tests/unit/states/test_boto_apigateway.py +++ b/tests/unit/states/test_boto_apigateway.py @@ -10,9 +10,9 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_asg.py b/tests/unit/states/test_boto_asg.py index b0cb673983..c0a3dbd307 100644 --- a/tests/unit/states/test_boto_asg.py +++ b/tests/unit/states/test_boto_asg.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_cloudtrail.py b/tests/unit/states/test_boto_cloudtrail.py index 5067efcf5a..38d27ad625 100644 --- a/tests/unit/states/test_boto_cloudtrail.py +++ b/tests/unit/states/test_boto_cloudtrail.py @@ -7,14 +7,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_cloudwatch_alarm.py b/tests/unit/states/test_boto_cloudwatch_alarm.py index cfaef3111d..e97b43ecd4 100644 --- a/tests/unit/states/test_boto_cloudwatch_alarm.py +++ b/tests/unit/states/test_boto_cloudwatch_alarm.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_cloudwatch_event.py b/tests/unit/states/test_boto_cloudwatch_event.py index 028541619c..917d95f3da 100644 --- a/tests/unit/states/test_boto_cloudwatch_event.py +++ b/tests/unit/states/test_boto_cloudwatch_event.py @@ -6,9 +6,9 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') @@ -20,7 +20,7 @@ import salt.loader import logging # Import Mock libraries -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # pylint: disable=import-error,no-name-in-module from unit.modules.test_boto_cloudwatch_event import BotoCloudWatchEventTestCaseMixin diff --git a/tests/unit/states/test_boto_cognitoidentity.py b/tests/unit/states/test_boto_cognitoidentity.py index b464cce1cc..d79ff0eb73 100644 --- a/tests/unit/states/test_boto_cognitoidentity.py +++ b/tests/unit/states/test_boto_cognitoidentity.py @@ -7,9 +7,9 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') @@ -21,7 +21,7 @@ import salt.loader import logging # Import Mock libraries -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # pylint: disable=import-error,no-name-in-module from unit.modules.test_boto_cognitoidentity import BotoCognitoIdentityTestCaseMixin diff --git a/tests/unit/states/test_boto_dynamodb.py b/tests/unit/states/test_boto_dynamodb.py index 2b9ee3ba6b..2d0e1bf2a2 100644 --- a/tests/unit/states/test_boto_dynamodb.py +++ b/tests/unit/states/test_boto_dynamodb.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_ec2.py b/tests/unit/states/test_boto_ec2.py index 599f856c7f..272d5c7c94 100644 --- a/tests/unit/states/test_boto_ec2.py +++ b/tests/unit/states/test_boto_ec2.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_elasticache.py b/tests/unit/states/test_boto_elasticache.py index 8a6501d418..4e67a5f6c8 100644 --- a/tests/unit/states/test_boto_elasticache.py +++ b/tests/unit/states/test_boto_elasticache.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_elasticsearch_domain.py b/tests/unit/states/test_boto_elasticsearch_domain.py index ca5b45273a..d0c1956964 100644 --- a/tests/unit/states/test_boto_elasticsearch_domain.py +++ b/tests/unit/states/test_boto_elasticsearch_domain.py @@ -8,14 +8,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_elb.py b/tests/unit/states/test_boto_elb.py index 47030435cc..05364863aa 100644 --- a/tests/unit/states/test_boto_elb.py +++ b/tests/unit/states/test_boto_elb.py @@ -7,14 +7,14 @@ from __future__ import absolute_import import copy # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_iam_role.py b/tests/unit/states/test_boto_iam_role.py index 03a2820c2a..ae95056d58 100644 --- a/tests/unit/states/test_boto_iam_role.py +++ b/tests/unit/states/test_boto_iam_role.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_iot.py b/tests/unit/states/test_boto_iot.py index 4d7149a206..4719a2ee19 100644 --- a/tests/unit/states/test_boto_iot.py +++ b/tests/unit/states/test_boto_iot.py @@ -8,14 +8,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_kinesis.py b/tests/unit/states/test_boto_kinesis.py index e83a9fe74d..7f692d0c55 100644 --- a/tests/unit/states/test_boto_kinesis.py +++ b/tests/unit/states/test_boto_kinesis.py @@ -3,14 +3,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_lambda.py b/tests/unit/states/test_boto_lambda.py index 986a8ff4aa..81b28a5661 100644 --- a/tests/unit/states/test_boto_lambda.py +++ b/tests/unit/states/test_boto_lambda.py @@ -9,14 +9,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_lc.py b/tests/unit/states/test_boto_lc.py index 405d3e9d6c..cf77d269ad 100644 --- a/tests/unit/states/test_boto_lc.py +++ b/tests/unit/states/test_boto_lc.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import SaltInvocationError ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_route53.py b/tests/unit/states/test_boto_route53.py index 6389b3fbd1..54ac114f8f 100644 --- a/tests/unit/states/test_boto_route53.py +++ b/tests/unit/states/test_boto_route53.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_s3_bucket.py b/tests/unit/states/test_boto_s3_bucket.py index fe430cdf62..bf3619605a 100644 --- a/tests/unit/states/test_boto_s3_bucket.py +++ b/tests/unit/states/test_boto_s3_bucket.py @@ -9,14 +9,14 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_secgroup.py b/tests/unit/states/test_boto_secgroup.py index 69d5274d3f..d78052b7f3 100644 --- a/tests/unit/states/test_boto_secgroup.py +++ b/tests/unit/states/test_boto_secgroup.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting.case import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.case import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_sns.py b/tests/unit/states/test_boto_sns.py index 7df1e0cb3f..d50d51cbe2 100644 --- a/tests/unit/states/test_boto_sns.py +++ b/tests/unit/states/test_boto_sns.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_sqs.py b/tests/unit/states/test_boto_sqs.py index a973f706cc..b8c587c3fd 100644 --- a/tests/unit/states/test_boto_sqs.py +++ b/tests/unit/states/test_boto_sqs.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_boto_vpc.py b/tests/unit/states/test_boto_vpc.py index 3c274bbb13..7b16fafb1c 100644 --- a/tests/unit/states/test_boto_vpc.py +++ b/tests/unit/states/test_boto_vpc.py @@ -8,9 +8,9 @@ import random import string # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_bower.py b/tests/unit/states/test_bower.py index 160e33f25b..d01e58595b 100644 --- a/tests/unit/states/test_bower.py +++ b/tests/unit/states/test_bower.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_chef.py b/tests/unit/states/test_chef.py index 926068120e..a133a3f09c 100644 --- a/tests/unit/states/test_chef.py +++ b/tests/unit/states/test_chef.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_cloud.py b/tests/unit/states/test_cloud.py index 68a5abc065..100af324fb 100644 --- a/tests/unit/states/test_cloud.py +++ b/tests/unit/states/test_cloud.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_cmd.py b/tests/unit/states/test_cmd.py index 84fbcb588a..dcd706b9f2 100644 --- a/tests/unit/states/test_cmd.py +++ b/tests/unit/states/test_cmd.py @@ -7,14 +7,14 @@ from __future__ import absolute_import import os.path # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError ensure_in_syspath('../../') diff --git a/tests/unit/states/test_composer.py b/tests/unit/states/test_composer.py index 5b8730ef55..5036419bf6 100644 --- a/tests/unit/states/test_composer.py +++ b/tests/unit/states/test_composer.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import SaltException ensure_in_syspath('../../') diff --git a/tests/unit/states/test_cron.py b/tests/unit/states/test_cron.py index 741411d827..2d52a43af2 100644 --- a/tests/unit/states/test_cron.py +++ b/tests/unit/states/test_cron.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/states/test_cyg.py b/tests/unit/states/test_cyg.py index 01b846eb50..b1bd3e65b7 100644 --- a/tests/unit/states/test_cyg.py +++ b/tests/unit/states/test_cyg.py @@ -1,9 +1,9 @@ # # -*- coding: utf-8 -*- # # Import Salt Testing libs -# from salttesting import skipIf, TestCase -# from salttesting.helpers import ensure_in_syspath -# from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +# from tests.support.unit import skipIf, TestCase +# from tests.support.helpers import ensure_in_syspath +# from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # ensure_in_syspath('../../') # # Late import so mock can do its job diff --git a/tests/unit/states/test_ddns.py b/tests/unit/states/test_ddns.py index ca7195620d..6f9711fc38 100644 --- a/tests/unit/states/test_ddns.py +++ b/tests/unit/states/test_ddns.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_debconfmod.py b/tests/unit/states/test_debconfmod.py index 2abbc76ed3..c1bd91bcdd 100644 --- a/tests/unit/states/test_debconfmod.py +++ b/tests/unit/states/test_debconfmod.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_disk.py b/tests/unit/states/test_disk.py index 639fb1f0f9..ea7ca2ca87 100644 --- a/tests/unit/states/test_disk.py +++ b/tests/unit/states/test_disk.py @@ -6,14 +6,14 @@ Tests for disk state from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_docker.py b/tests/unit/states/test_docker.py index ccd8dfdb43..64d975fb07 100644 --- a/tests/unit/states/test_docker.py +++ b/tests/unit/states/test_docker.py @@ -7,10 +7,10 @@ Unit tests for the docker state from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase +from tests.support.unit import skipIf, TestCase from salt.exceptions import SaltInvocationError -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, Mock, NO_MOCK, diff --git a/tests/unit/states/test_drac.py b/tests/unit/states/test_drac.py index 24d7d4c7ca..5a84573cb4 100644 --- a/tests/unit/states/test_drac.py +++ b/tests/unit/states/test_drac.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_environ.py b/tests/unit/states/test_environ.py index 2e7620e05f..6e66bb4d5d 100644 --- a/tests/unit/states/test_environ.py +++ b/tests/unit/states/test_environ.py @@ -5,9 +5,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_eselect.py b/tests/unit/states/test_eselect.py index d5658ebfe8..2bfe3a5d14 100644 --- a/tests/unit/states/test_eselect.py +++ b/tests/unit/states/test_eselect.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_event.py b/tests/unit/states/test_event.py index bfc14d02f5..f58f6d5b49 100644 --- a/tests/unit/states/test_event.py +++ b/tests/unit/states/test_event.py @@ -9,9 +9,9 @@ from __future__ import absolute_import from salt.states import event # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_file.py b/tests/unit/states/test_file.py index 50951cfd85..d44946a1c7 100644 --- a/tests/unit/states/test_file.py +++ b/tests/unit/states/test_file.py @@ -15,9 +15,9 @@ except ImportError: NO_DATEUTIL_REASON = 'python-dateutil is not installed' # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import destructiveTest, ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import destructiveTest, ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_gem.py b/tests/unit/states/test_gem.py index ef0c40ea01..872ad3d8b4 100644 --- a/tests/unit/states/test_gem.py +++ b/tests/unit/states/test_gem.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Late import so mock can do its job diff --git a/tests/unit/states/test_glusterfs.py b/tests/unit/states/test_glusterfs.py index be97d60895..611d97f956 100644 --- a/tests/unit/states/test_glusterfs.py +++ b/tests/unit/states/test_glusterfs.py @@ -7,14 +7,14 @@ from __future__ import absolute_import import socket # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_gnomedesktop.py b/tests/unit/states/test_gnomedesktop.py index 6a0cdbd1a5..8b1a49e8f0 100644 --- a/tests/unit/states/test_gnomedesktop.py +++ b/tests/unit/states/test_gnomedesktop.py @@ -6,12 +6,12 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_grafana.py b/tests/unit/states/test_grafana.py index dc70151ad0..7c402c44af 100644 --- a/tests/unit/states/test_grafana.py +++ b/tests/unit/states/test_grafana.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import SaltInvocationError import json diff --git a/tests/unit/states/test_grafana_datasource.py b/tests/unit/states/test_grafana_datasource.py index 5c6cf2866b..9f282945f1 100644 --- a/tests/unit/states/test_grafana_datasource.py +++ b/tests/unit/states/test_grafana_datasource.py @@ -3,8 +3,8 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, Mock, @@ -12,7 +12,7 @@ from salttesting.mock import ( patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_grains.py b/tests/unit/states/test_grains.py index d3992baa8a..5a1a2ef097 100644 --- a/tests/unit/states/test_grains.py +++ b/tests/unit/states/test_grains.py @@ -10,9 +10,9 @@ import os import yaml # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/states/test_group.py b/tests/unit/states/test_group.py index 09f9396102..dcada1f72c 100644 --- a/tests/unit/states/test_group.py +++ b/tests/unit/states/test_group.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_hg.py b/tests/unit/states/test_hg.py index b12dd9075b..24520a5570 100644 --- a/tests/unit/states/test_hg.py +++ b/tests/unit/states/test_hg.py @@ -10,9 +10,9 @@ import os from salt.states import hg # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_hipchat.py b/tests/unit/states/test_hipchat.py index 8ee5ffe824..31e4e70d58 100644 --- a/tests/unit/states/test_hipchat.py +++ b/tests/unit/states/test_hipchat.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_host.py b/tests/unit/states/test_host.py index f15b4d16df..ab523eba74 100644 --- a/tests/unit/states/test_host.py +++ b/tests/unit/states/test_host.py @@ -9,9 +9,9 @@ from __future__ import absolute_import from salt.states import host # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_htpasswd.py b/tests/unit/states/test_htpasswd.py index 61142a7bb7..63f8ad0f04 100644 --- a/tests/unit/states/test_htpasswd.py +++ b/tests/unit/states/test_htpasswd.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_http.py b/tests/unit/states/test_http.py index c8bdbb78de..2bb84028da 100644 --- a/tests/unit/states/test_http.py +++ b/tests/unit/states/test_http.py @@ -9,9 +9,9 @@ from __future__ import absolute_import from salt.states import http # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_incron.py b/tests/unit/states/test_incron.py index 2902aa406e..5b7fe1b40b 100644 --- a/tests/unit/states/test_incron.py +++ b/tests/unit/states/test_incron.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_influxdb08_database.py b/tests/unit/states/test_influxdb08_database.py index b555eca028..1d0463a05f 100644 --- a/tests/unit/states/test_influxdb08_database.py +++ b/tests/unit/states/test_influxdb08_database.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_influxdb08_user.py b/tests/unit/states/test_influxdb08_user.py index 3404c3fdd8..67c16da15c 100644 --- a/tests/unit/states/test_influxdb08_user.py +++ b/tests/unit/states/test_influxdb08_user.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ini_manage.py b/tests/unit/states/test_ini_manage.py index fc39b2e55b..12832c9f7d 100644 --- a/tests/unit/states/test_ini_manage.py +++ b/tests/unit/states/test_ini_manage.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ipmi.py b/tests/unit/states/test_ipmi.py index ba2273b798..f415dd07de 100644 --- a/tests/unit/states/test_ipmi.py +++ b/tests/unit/states/test_ipmi.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ipset.py b/tests/unit/states/test_ipset.py index fe5a243399..865df3875b 100644 --- a/tests/unit/states/test_ipset.py +++ b/tests/unit/states/test_ipset.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, call, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_iptables.py b/tests/unit/states/test_iptables.py index 8ebb50ee06..16405783c3 100644 --- a/tests/unit/states/test_iptables.py +++ b/tests/unit/states/test_iptables.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_jboss7.py b/tests/unit/states/test_jboss7.py index 66e6f282b4..e4cd8444f6 100644 --- a/tests/unit/states/test_jboss7.py +++ b/tests/unit/states/test_jboss7.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/unit/states/test_kapacitor.py b/tests/unit/states/test_kapacitor.py index 390e06ac7d..e8161b7dcd 100644 --- a/tests/unit/states/test_kapacitor.py +++ b/tests/unit/states/test_kapacitor.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt testing libs -from salttesting import TestCase -from salttesting.mock import Mock, patch, mock_open +from tests.support.unit import TestCase +from tests.support.mock import Mock, patch, mock_open # Import Salt libs from salt.states import kapacitor diff --git a/tests/unit/states/test_keyboard.py b/tests/unit/states/test_keyboard.py index bd5af7a438..3b8f862d63 100644 --- a/tests/unit/states/test_keyboard.py +++ b/tests/unit/states/test_keyboard.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_keystone.py b/tests/unit/states/test_keystone.py index 59a2309d49..3fce2faba2 100644 --- a/tests/unit/states/test_keystone.py +++ b/tests/unit/states/test_keystone.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_kmod.py b/tests/unit/states/test_kmod.py index 6ab39907db..fb76adbb4d 100644 --- a/tests/unit/states/test_kmod.py +++ b/tests/unit/states/test_kmod.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_layman.py b/tests/unit/states/test_layman.py index 1358a37ef0..c6d2cafa21 100644 --- a/tests/unit/states/test_layman.py +++ b/tests/unit/states/test_layman.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ldap.py b/tests/unit/states/test_ldap.py index 015b70982a..a6d9c8fc1c 100644 --- a/tests/unit/states/test_ldap.py +++ b/tests/unit/states/test_ldap.py @@ -15,9 +15,9 @@ import copy import salt.ext.six as six import salt.states.ldap -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, patch, diff --git a/tests/unit/states/test_libcloud_dns.py b/tests/unit/states/test_libcloud_dns.py index 6befc6b3c2..9fb7f70cba 100644 --- a/tests/unit/states/test_libcloud_dns.py +++ b/tests/unit/states/test_libcloud_dns.py @@ -7,15 +7,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf +from tests.support.unit import skipIf from tests.unit import ModuleTestCase, hasDependency -from salttesting.mock import ( +from tests.support.mock import ( patch, MagicMock, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.states import libcloud_dns ensure_in_syspath('../../') diff --git a/tests/unit/states/test_libvirt.py b/tests/unit/states/test_libvirt.py index 7a76df73f7..00ea8bc6db 100644 --- a/tests/unit/states/test_libvirt.py +++ b/tests/unit/states/test_libvirt.py @@ -7,15 +7,15 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, mock_open, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_linux_acl.py b/tests/unit/states/test_linux_acl.py index d78a275e9d..bbdd6f8ae9 100644 --- a/tests/unit/states/test_linux_acl.py +++ b/tests/unit/states/test_linux_acl.py @@ -7,14 +7,14 @@ from __future__ import absolute_import import sys # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_locale.py b/tests/unit/states/test_locale.py index e843e24777..d2ab1526a7 100644 --- a/tests/unit/states/test_locale.py +++ b/tests/unit/states/test_locale.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_lvm.py b/tests/unit/states/test_lvm.py index 243f1d1a65..597175c3fe 100644 --- a/tests/unit/states/test_lvm.py +++ b/tests/unit/states/test_lvm.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_lvs_server.py b/tests/unit/states/test_lvs_server.py index e71442b602..448a96f712 100644 --- a/tests/unit/states/test_lvs_server.py +++ b/tests/unit/states/test_lvs_server.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_lvs_service.py b/tests/unit/states/test_lvs_service.py index 6373708935..82a6411464 100644 --- a/tests/unit/states/test_lvs_service.py +++ b/tests/unit/states/test_lvs_service.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_lxc.py b/tests/unit/states/test_lxc.py index 260a50b768..26be980fde 100644 --- a/tests/unit/states/test_lxc.py +++ b/tests/unit/states/test_lxc.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_mac_assistive.py b/tests/unit/states/test_mac_assistive.py index f67d7e2b8d..f51a2aa0d3 100644 --- a/tests/unit/states/test_mac_assistive.py +++ b/tests/unit/states/test_mac_assistive.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import mac_assistive as assistive # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_mac_defaults.py b/tests/unit/states/test_mac_defaults.py index 180c4126b3..d77f55450f 100644 --- a/tests/unit/states/test_mac_defaults.py +++ b/tests/unit/states/test_mac_defaults.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import mac_defaults as macdefaults # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_mac_keychain.py b/tests/unit/states/test_mac_keychain.py index 600040f523..28d285f23f 100644 --- a/tests/unit/states/test_mac_keychain.py +++ b/tests/unit/states/test_mac_keychain.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import mac_keychain as keychain # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, call diff --git a/tests/unit/states/test_mac_package.py b/tests/unit/states/test_mac_package.py index 575d163b69..3adb8088a0 100644 --- a/tests/unit/states/test_mac_package.py +++ b/tests/unit/states/test_mac_package.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import mac_package as macpackage # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_mac_xattr.py b/tests/unit/states/test_mac_xattr.py index 39c4446adc..56a0e0f15c 100644 --- a/tests/unit/states/test_mac_xattr.py +++ b/tests/unit/states/test_mac_xattr.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import mac_xattr as xattr # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_makeconf.py b/tests/unit/states/test_makeconf.py index fd4009ec98..8966c02ce3 100644 --- a/tests/unit/states/test_makeconf.py +++ b/tests/unit/states/test_makeconf.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_mdadm.py b/tests/unit/states/test_mdadm.py index 9b71eda662..81e1b4d508 100644 --- a/tests/unit/states/test_mdadm.py +++ b/tests/unit/states/test_mdadm.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_memcached.py b/tests/unit/states/test_memcached.py index 58c4347422..17d5db1dbf 100644 --- a/tests/unit/states/test_memcached.py +++ b/tests/unit/states/test_memcached.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError ensure_in_syspath('../../') diff --git a/tests/unit/states/test_modjk.py b/tests/unit/states/test_modjk.py index 77ac659570..a5bbaa6990 100644 --- a/tests/unit/states/test_modjk.py +++ b/tests/unit/states/test_modjk.py @@ -6,12 +6,12 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_modjk_worker.py b/tests/unit/states/test_modjk_worker.py index eb14b80892..43b40085d6 100644 --- a/tests/unit/states/test_modjk_worker.py +++ b/tests/unit/states/test_modjk_worker.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_module.py b/tests/unit/states/test_module.py index 352ba7c330..5c932a126c 100644 --- a/tests/unit/states/test_module.py +++ b/tests/unit/states/test_module.py @@ -11,9 +11,9 @@ from inspect import ArgSpec from salt.states import module # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_mongodb_database.py b/tests/unit/states/test_mongodb_database.py index 3f6ce0b048..e488f5af5e 100644 --- a/tests/unit/states/test_mongodb_database.py +++ b/tests/unit/states/test_mongodb_database.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_mongodb_user.py b/tests/unit/states/test_mongodb_user.py index 31e1f03295..3de6191a0c 100644 --- a/tests/unit/states/test_mongodb_user.py +++ b/tests/unit/states/test_mongodb_user.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_mount.py b/tests/unit/states/test_mount.py index cdb2d5a53e..81570be5fd 100644 --- a/tests/unit/states/test_mount.py +++ b/tests/unit/states/test_mount.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_mysql_grants.py b/tests/unit/states/test_mysql_grants.py index de1ea02b99..646dbece9a 100644 --- a/tests/unit/states/test_mysql_grants.py +++ b/tests/unit/states/test_mysql_grants.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_mysql_query.py b/tests/unit/states/test_mysql_query.py index 6e924c869e..86015a89cf 100644 --- a/tests/unit/states/test_mysql_query.py +++ b/tests/unit/states/test_mysql_query.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_mysql_user.py b/tests/unit/states/test_mysql_user.py index 4f62e96f65..7329af2640 100644 --- a/tests/unit/states/test_mysql_user.py +++ b/tests/unit/states/test_mysql_user.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_network.py b/tests/unit/states/test_network.py index c668d2e72d..c2ce0b8375 100644 --- a/tests/unit/states/test_network.py +++ b/tests/unit/states/test_network.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import sys # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_nftables.py b/tests/unit/states/test_nftables.py index 7e01528477..61575c01ab 100644 --- a/tests/unit/states/test_nftables.py +++ b/tests/unit/states/test_nftables.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_npm.py b/tests/unit/states/test_npm.py index 6462c688cc..7b2c370b00 100644 --- a/tests/unit/states/test_npm.py +++ b/tests/unit/states/test_npm.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ntp.py b/tests/unit/states/test_ntp.py index 216dbe76cf..4f8bb9dc55 100644 --- a/tests/unit/states/test_ntp.py +++ b/tests/unit/states/test_ntp.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_openstack_config.py b/tests/unit/states/test_openstack_config.py index bfc8b4c109..ec001bc4f8 100644 --- a/tests/unit/states/test_openstack_config.py +++ b/tests/unit/states/test_openstack_config.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError ensure_in_syspath('../../') diff --git a/tests/unit/states/test_openvswitch_port.py b/tests/unit/states/test_openvswitch_port.py index 663f0f726f..daa2656cbf 100644 --- a/tests/unit/states/test_openvswitch_port.py +++ b/tests/unit/states/test_openvswitch_port.py @@ -3,14 +3,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, NO_MOCK, NO_MOCK_REASON, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_pagerduty.py b/tests/unit/states/test_pagerduty.py index f8ba788863..c7eba0f747 100644 --- a/tests/unit/states/test_pagerduty.py +++ b/tests/unit/states/test_pagerduty.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_pecl.py b/tests/unit/states/test_pecl.py index 197ae594fa..c364732c90 100644 --- a/tests/unit/states/test_pecl.py +++ b/tests/unit/states/test_pecl.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_pip.py b/tests/unit/states/test_pip.py index 35e4e9ed08..1c1d078fe7 100644 --- a/tests/unit/states/test_pip.py +++ b/tests/unit/states/test_pip.py @@ -11,9 +11,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/states/test_pkgng.py b/tests/unit/states/test_pkgng.py index 4a9fc6d856..3fad7036ad 100644 --- a/tests/unit/states/test_pkgng.py +++ b/tests/unit/states/test_pkgng.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_portage_config.py b/tests/unit/states/test_portage_config.py index 69c70208c4..5d309f70e8 100644 --- a/tests/unit/states/test_portage_config.py +++ b/tests/unit/states/test_portage_config.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ports.py b/tests/unit/states/test_ports.py index 0016d0adaa..ca978d3d09 100644 --- a/tests/unit/states/test_ports.py +++ b/tests/unit/states/test_ports.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import SaltInvocationError ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres.py b/tests/unit/states/test_postgres.py index 0ffc186378..e323e5a78f 100644 --- a/tests/unit/states/test_postgres.py +++ b/tests/unit/states/test_postgres.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, Mock, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_cluster.py b/tests/unit/states/test_postgres_cluster.py index 0c1d072787..9e18689021 100644 --- a/tests/unit/states/test_postgres_cluster.py +++ b/tests/unit/states/test_postgres_cluster.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_database.py b/tests/unit/states/test_postgres_database.py index bf5b9b538e..bc3d1d0966 100644 --- a/tests/unit/states/test_postgres_database.py +++ b/tests/unit/states/test_postgres_database.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_extension.py b/tests/unit/states/test_postgres_extension.py index b3e66bcaa4..b4f38b70de 100644 --- a/tests/unit/states/test_postgres_extension.py +++ b/tests/unit/states/test_postgres_extension.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_group.py b/tests/unit/states/test_postgres_group.py index 8979806982..d53d755fa5 100644 --- a/tests/unit/states/test_postgres_group.py +++ b/tests/unit/states/test_postgres_group.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_initdb.py b/tests/unit/states/test_postgres_initdb.py index 7ff7a03b8f..f0889d4691 100644 --- a/tests/unit/states/test_postgres_initdb.py +++ b/tests/unit/states/test_postgres_initdb.py @@ -4,15 +4,15 @@ ''' from __future__ import absolute_import -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_language.py b/tests/unit/states/test_postgres_language.py index 12e2e29603..0799eecab5 100644 --- a/tests/unit/states/test_postgres_language.py +++ b/tests/unit/states/test_postgres_language.py @@ -4,15 +4,15 @@ ''' from __future__ import absolute_import -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_privileges.py b/tests/unit/states/test_postgres_privileges.py index 0e8995c427..ee390c2124 100644 --- a/tests/unit/states/test_postgres_privileges.py +++ b/tests/unit/states/test_postgres_privileges.py @@ -4,15 +4,15 @@ ''' from __future__ import absolute_import -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_schema.py b/tests/unit/states/test_postgres_schema.py index 6502364913..f3e43dc727 100644 --- a/tests/unit/states/test_postgres_schema.py +++ b/tests/unit/states/test_postgres_schema.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_postgres_user.py b/tests/unit/states/test_postgres_user.py index 6226d3b6ff..f78670d3dd 100644 --- a/tests/unit/states/test_postgres_user.py +++ b/tests/unit/states/test_postgres_user.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_powerpath.py b/tests/unit/states/test_powerpath.py index 2cca9818fe..610334c2c2 100644 --- a/tests/unit/states/test_powerpath.py +++ b/tests/unit/states/test_powerpath.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_process.py b/tests/unit/states/test_process.py index 832504389e..5afe077a47 100644 --- a/tests/unit/states/test_process.py +++ b/tests/unit/states/test_process.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_proxy.py b/tests/unit/states/test_proxy.py index 8496128999..d6392f78ff 100644 --- a/tests/unit/states/test_proxy.py +++ b/tests/unit/states/test_proxy.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_pyenv.py b/tests/unit/states/test_pyenv.py index 2fdf9f9fe1..0b1f6001ed 100644 --- a/tests/unit/states/test_pyenv.py +++ b/tests/unit/states/test_pyenv.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_pyrax_queues.py b/tests/unit/states/test_pyrax_queues.py index 145833863d..621d9c8e1b 100644 --- a/tests/unit/states/test_pyrax_queues.py +++ b/tests/unit/states/test_pyrax_queues.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_quota.py b/tests/unit/states/test_quota.py index c34562c6a8..d7b879b80f 100644 --- a/tests/unit/states/test_quota.py +++ b/tests/unit/states/test_quota.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_rabbitmq_cluster.py b/tests/unit/states/test_rabbitmq_cluster.py index 0777c7625a..e838c36dd0 100644 --- a/tests/unit/states/test_rabbitmq_cluster.py +++ b/tests/unit/states/test_rabbitmq_cluster.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_rabbitmq_plugin.py b/tests/unit/states/test_rabbitmq_plugin.py index 801ddea2fc..761a0960ac 100644 --- a/tests/unit/states/test_rabbitmq_plugin.py +++ b/tests/unit/states/test_rabbitmq_plugin.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_rabbitmq_policy.py b/tests/unit/states/test_rabbitmq_policy.py index a51e0b3d21..0c5c8b6cc4 100644 --- a/tests/unit/states/test_rabbitmq_policy.py +++ b/tests/unit/states/test_rabbitmq_policy.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_rabbitmq_vhost.py b/tests/unit/states/test_rabbitmq_vhost.py index 45c77ca198..9ceac0f2ac 100644 --- a/tests/unit/states/test_rabbitmq_vhost.py +++ b/tests/unit/states/test_rabbitmq_vhost.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_rbenv.py b/tests/unit/states/test_rbenv.py index 56ef9714f0..766deda257 100644 --- a/tests/unit/states/test_rbenv.py +++ b/tests/unit/states/test_rbenv.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_rdp.py b/tests/unit/states/test_rdp.py index f577350d68..d2981174bc 100644 --- a/tests/unit/states/test_rdp.py +++ b/tests/unit/states/test_rdp.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_redismod.py b/tests/unit/states/test_redismod.py index 366ac5cb4e..79ce98157a 100644 --- a/tests/unit/states/test_redismod.py +++ b/tests/unit/states/test_redismod.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_reg.py b/tests/unit/states/test_reg.py index b9cecb2c48..26ae16c55e 100644 --- a/tests/unit/states/test_reg.py +++ b/tests/unit/states/test_reg.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_rvm.py b/tests/unit/states/test_rvm.py index 86061c63a6..6b21201d13 100644 --- a/tests/unit/states/test_rvm.py +++ b/tests/unit/states/test_rvm.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/states/test_saltmod.py b/tests/unit/states/test_saltmod.py index c585fc603d..f1a6d547c6 100644 --- a/tests/unit/states/test_saltmod.py +++ b/tests/unit/states/test_saltmod.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath import salt.utils.event import time diff --git a/tests/unit/states/test_schedule.py b/tests/unit/states/test_schedule.py index 701134a3a2..557caeda72 100644 --- a/tests/unit/states/test_schedule.py +++ b/tests/unit/states/test_schedule.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_selinux.py b/tests/unit/states/test_selinux.py index 6b5982bea6..aa45bfaa63 100644 --- a/tests/unit/states/test_selinux.py +++ b/tests/unit/states/test_selinux.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_serverdensity_device.py b/tests/unit/states/test_serverdensity_device.py index e0b09e0bcb..2792a58dfb 100644 --- a/tests/unit/states/test_serverdensity_device.py +++ b/tests/unit/states/test_serverdensity_device.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_service.py b/tests/unit/states/test_service.py index 8b521196f8..e622e07cf6 100644 --- a/tests/unit/states/test_service.py +++ b/tests/unit/states/test_service.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_slack.py b/tests/unit/states/test_slack.py index 57fd6f1573..56ba96fdd8 100644 --- a/tests/unit/states/test_slack.py +++ b/tests/unit/states/test_slack.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_smtp.py b/tests/unit/states/test_smtp.py index fff89f9247..80e927d0fd 100644 --- a/tests/unit/states/test_smtp.py +++ b/tests/unit/states/test_smtp.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_splunk_search.py b/tests/unit/states/test_splunk_search.py index 00bde217f1..610368948f 100644 --- a/tests/unit/states/test_splunk_search.py +++ b/tests/unit/states/test_splunk_search.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ssh_auth.py b/tests/unit/states/test_ssh_auth.py index 085d6e68fd..96b3d99017 100644 --- a/tests/unit/states/test_ssh_auth.py +++ b/tests/unit/states/test_ssh_auth.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_ssh_known_hosts.py b/tests/unit/states/test_ssh_known_hosts.py index e94b8c78a6..3e4103ce71 100644 --- a/tests/unit/states/test_ssh_known_hosts.py +++ b/tests/unit/states/test_ssh_known_hosts.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath import os ensure_in_syspath('../../') diff --git a/tests/unit/states/test_status.py b/tests/unit/states/test_status.py index ef7a07c216..edd31212e0 100644 --- a/tests/unit/states/test_status.py +++ b/tests/unit/states/test_status.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_supervisord.py b/tests/unit/states/test_supervisord.py index ff38a8862c..4a985647e0 100644 --- a/tests/unit/states/test_supervisord.py +++ b/tests/unit/states/test_supervisord.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/states/test_svn.py b/tests/unit/states/test_svn.py index 87f5660cca..9b2dc203be 100644 --- a/tests/unit/states/test_svn.py +++ b/tests/unit/states/test_svn.py @@ -10,9 +10,9 @@ import os from salt.states import svn # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_sysctl.py b/tests/unit/states/test_sysctl.py index 01af495975..a3f9777fc3 100644 --- a/tests/unit/states/test_sysctl.py +++ b/tests/unit/states/test_sysctl.py @@ -6,15 +6,15 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError ensure_in_syspath('../../') diff --git a/tests/unit/states/test_syslog_ng.py b/tests/unit/states/test_syslog_ng.py index 4262f5cceb..9b0d062070 100644 --- a/tests/unit/states/test_syslog_ng.py +++ b/tests/unit/states/test_syslog_ng.py @@ -10,9 +10,9 @@ import re import tempfile import os -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/states/test_sysrc.py b/tests/unit/states/test_sysrc.py index b7e2362d94..7306804d4f 100644 --- a/tests/unit/states/test_sysrc.py +++ b/tests/unit/states/test_sysrc.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_test.py b/tests/unit/states/test_test.py index cf60ceeb44..a5bf73ff25 100644 --- a/tests/unit/states/test_test.py +++ b/tests/unit/states/test_test.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( patch, MagicMock, NO_MOCK, diff --git a/tests/unit/states/test_timezone.py b/tests/unit/states/test_timezone.py index 8409bd7710..d75717ea90 100644 --- a/tests/unit/states/test_timezone.py +++ b/tests/unit/states/test_timezone.py @@ -8,9 +8,9 @@ from __future__ import absolute_import # Import Salt Testing Libs from salt.exceptions import CommandExecutionError -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_tomcat.py b/tests/unit/states/test_tomcat.py index a2643c16f3..698a667d23 100644 --- a/tests/unit/states/test_tomcat.py +++ b/tests/unit/states/test_tomcat.py @@ -10,9 +10,9 @@ from __future__ import absolute_import from salt.states import tomcat # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_user.py b/tests/unit/states/test_user.py index acd0afe066..9bc26d2b18 100644 --- a/tests/unit/states/test_user.py +++ b/tests/unit/states/test_user.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_vbox_guest.py b/tests/unit/states/test_vbox_guest.py index 4959707bb9..144bfe795f 100644 --- a/tests/unit/states/test_vbox_guest.py +++ b/tests/unit/states/test_vbox_guest.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_virtualenv_mod.py b/tests/unit/states/test_virtualenv_mod.py index c8e79f0cd0..10ac633ab2 100644 --- a/tests/unit/states/test_virtualenv_mod.py +++ b/tests/unit/states/test_virtualenv_mod.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_certutil.py b/tests/unit/states/test_win_certutil.py index c76f03e081..b0f0efb581 100644 --- a/tests/unit/states/test_win_certutil.py +++ b/tests/unit/states/test_win_certutil.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import win_certutil as certutil # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_win_dism.py b/tests/unit/states/test_win_dism.py index 367627630b..09979057e2 100644 --- a/tests/unit/states/test_win_dism.py +++ b/tests/unit/states/test_win_dism.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import win_dism as dism # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_win_dns_client.py b/tests/unit/states/test_win_dns_client.py index 6bb1309c66..f15f5d428d 100644 --- a/tests/unit/states/test_win_dns_client.py +++ b/tests/unit/states/test_win_dns_client.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_firewall.py b/tests/unit/states/test_win_firewall.py index 03a3122804..8115c4410a 100644 --- a/tests/unit/states/test_win_firewall.py +++ b/tests/unit/states/test_win_firewall.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_license.py b/tests/unit/states/test_win_license.py index 8531c8693b..88358ba606 100644 --- a/tests/unit/states/test_win_license.py +++ b/tests/unit/states/test_win_license.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import win_license as license # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch ) diff --git a/tests/unit/states/test_win_network.py b/tests/unit/states/test_win_network.py index a53d6a488c..1e0115b590 100644 --- a/tests/unit/states/test_win_network.py +++ b/tests/unit/states/test_win_network.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_path.py b/tests/unit/states/test_win_path.py index 31744930e4..d96b1142ef 100644 --- a/tests/unit/states/test_win_path.py +++ b/tests/unit/states/test_win_path.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_pki.py b/tests/unit/states/test_win_pki.py index 0414b26e6d..166582d4ee 100644 --- a/tests/unit/states/test_win_pki.py +++ b/tests/unit/states/test_win_pki.py @@ -13,9 +13,9 @@ from __future__ import absolute_import from salt.states import win_pki # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_powercfg.py b/tests/unit/states/test_win_powercfg.py index 45de9f0b12..638028f72c 100644 --- a/tests/unit/states/test_win_powercfg.py +++ b/tests/unit/states/test_win_powercfg.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.states import win_powercfg as powercfg # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, diff --git a/tests/unit/states/test_win_servermanager.py b/tests/unit/states/test_win_servermanager.py index c0334ba27f..c158d71c4e 100644 --- a/tests/unit/states/test_win_servermanager.py +++ b/tests/unit/states/test_win_servermanager.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_snmp.py b/tests/unit/states/test_win_snmp.py index b9be991a34..a47eb30179 100644 --- a/tests/unit/states/test_win_snmp.py +++ b/tests/unit/states/test_win_snmp.py @@ -14,9 +14,9 @@ from salt.states import win_snmp import salt.ext.six as six # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_system.py b/tests/unit/states/test_win_system.py index 252bc5e38d..2acb60168a 100644 --- a/tests/unit/states/test_win_system.py +++ b/tests/unit/states/test_win_system.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_win_update.py b/tests/unit/states/test_win_update.py index b67bbf089b..37c8c462cb 100644 --- a/tests/unit/states/test_win_update.py +++ b/tests/unit/states/test_win_update.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_winrepo.py b/tests/unit/states/test_winrepo.py index 7066fba4fa..e5ecb6df31 100644 --- a/tests/unit/states/test_winrepo.py +++ b/tests/unit/states/test_winrepo.py @@ -9,9 +9,9 @@ from __future__ import absolute_import # Import Salt Testing Libs import salt.config from salt.syspaths import BASE_FILE_ROOTS_DIR -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_xmpp.py b/tests/unit/states/test_xmpp.py index 6dd1325f3e..1107c93ff4 100644 --- a/tests/unit/states/test_xmpp.py +++ b/tests/unit/states/test_xmpp.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/states/test_zcbuildout.py b/tests/unit/states/test_zcbuildout.py index 6fa2d8d419..e6aca373d5 100644 --- a/tests/unit/states/test_zcbuildout.py +++ b/tests/unit/states/test_zcbuildout.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ( +from tests.support.unit import skipIf +from tests.support.helpers import ( ensure_in_syspath, requires_network, ) diff --git a/tests/unit/states/test_zk_concurrency.py b/tests/unit/states/test_zk_concurrency.py index eeab539e55..8e7a35ec54 100644 --- a/tests/unit/states/test_zk_concurrency.py +++ b/tests/unit/states/test_zk_concurrency.py @@ -6,14 +6,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/templates/test_jinja.py b/tests/unit/templates/test_jinja.py index ff1e889eee..d633e09325 100644 --- a/tests/unit/templates/test_jinja.py +++ b/tests/unit/templates/test_jinja.py @@ -12,9 +12,9 @@ import pprint import re # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.case import ModuleCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.case import ModuleCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/test_auth.py b/tests/unit/test_auth.py index 47a5f6d37a..a671957e6d 100644 --- a/tests/unit/test_auth.py +++ b/tests/unit/test_auth.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, call, NO_MOCK, NO_MOCK_REASON, MagicMock +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, call, NO_MOCK, NO_MOCK_REASON, MagicMock ensure_in_syspath('../') diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index b753eb1a0c..7d4ce63c7d 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../') # Import Salt libs diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index cce0023423..72189579bf 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, ) diff --git a/tests/unit/test_context.py b/tests/unit/test_context.py index 4b2cc22266..1b1808b357 100644 --- a/tests/unit/test_context.py +++ b/tests/unit/test_context.py @@ -13,9 +13,9 @@ import threading import time # Import Salt Testing libs -from salttesting import TestCase +from tests.support.unit import TestCase from salt.ext.six.moves import range -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/unit/test_crypt.py b/tests/unit/test_crypt.py index f548820397..40d879697f 100644 --- a/tests/unit/test_crypt.py +++ b/tests/unit/test_crypt.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # salt testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, call, mock_open, NO_MOCK, NO_MOCK_REASON, MagicMock +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, call, mock_open, NO_MOCK, NO_MOCK_REASON, MagicMock ensure_in_syspath('../') diff --git a/tests/unit/test_daemons.py b/tests/unit/test_daemons.py index f83048bb7e..c99a963861 100644 --- a/tests/unit/test_daemons.py +++ b/tests/unit/test_daemons.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, MagicMock, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, MagicMock, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../') diff --git a/tests/unit/test_doc.py b/tests/unit/test_doc.py index f4f6a217a8..b3af08c003 100644 --- a/tests/unit/test_doc.py +++ b/tests/unit/test_doc.py @@ -8,8 +8,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/unit/test_files.py b/tests/unit/test_files.py index 30608d732b..d333ab56a6 100644 --- a/tests/unit/test_files.py +++ b/tests/unit/test_files.py @@ -11,8 +11,8 @@ import shutil import tempfile # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py index b5374979bb..7bd4d2e174 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_log.py @@ -15,8 +15,8 @@ import logging from salt.ext.six.moves import StringIO # Import Salt Testing libs -from salttesting.case import TestCase -from salttesting.helpers import ensure_in_syspath, TestsLoggingHandler +from tests.support.case import TestCase +from tests.support.helpers import ensure_in_syspath, TestsLoggingHandler ensure_in_syspath('../') diff --git a/tests/unit/test_map_conf.py b/tests/unit/test_map_conf.py index aa10afcc01..06854049dd 100644 --- a/tests/unit/test_map_conf.py +++ b/tests/unit/test_map_conf.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/test_minion.py b/tests/unit/test_minion.py index 1a43de7bdd..f905b01f0e 100644 --- a/tests/unit/test_minion.py +++ b/tests/unit/test_minion.py @@ -9,9 +9,9 @@ import copy import os # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock # Import salt libs from salt import minion diff --git a/tests/unit/test_payload.py b/tests/unit/test_payload.py index 77a4a8ac34..e222c90bf0 100644 --- a/tests/unit/test_payload.py +++ b/tests/unit/test_payload.py @@ -14,9 +14,9 @@ import errno import threading # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath, MockWraps -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath, MockWraps +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch ensure_in_syspath('../') # Import salt libs diff --git a/tests/unit/test_pillar.py b/tests/unit/test_pillar.py index c9c3a46dd9..5dd067e5a6 100644 --- a/tests/unit/test_pillar.py +++ b/tests/unit/test_pillar.py @@ -12,9 +12,9 @@ from __future__ import absolute_import import tempfile # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch ensure_in_syspath('../') # Import salt libs diff --git a/tests/unit/test_pydsl.py b/tests/unit/test_pydsl.py index 14fe7a5c7a..6a09a7577c 100644 --- a/tests/unit/test_pydsl.py +++ b/tests/unit/test_pydsl.py @@ -10,8 +10,8 @@ import textwrap import copy # Import Salt Testing libs -from salttesting.unit import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/unit/test_pyobjects.py b/tests/unit/test_pyobjects.py index 255ada9ddd..a4283ecc2f 100644 --- a/tests/unit/test_pyobjects.py +++ b/tests/unit/test_pyobjects.py @@ -8,8 +8,8 @@ import tempfile import uuid # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/unit/test_simple.py b/tests/unit/test_simple.py index fd7c43051a..2fb8451d67 100644 --- a/tests/unit/test_simple.py +++ b/tests/unit/test_simple.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, expectedFailure -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, expectedFailure +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index 9b6e75c34d..2f8a9190a4 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -7,8 +7,8 @@ import shutil import tempfile # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath, destructiveTest +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath, destructiveTest import salt.config import salt.spm diff --git a/tests/unit/test_state.py b/tests/unit/test_state.py index 8fcc59d5f5..6d0c0d1751 100644 --- a/tests/unit/test_state.py +++ b/tests/unit/test_state.py @@ -12,9 +12,9 @@ import tempfile # Import Salt Testing libs import integration -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch ensure_in_syspath('../') diff --git a/tests/unit/test_stateconf.py b/tests/unit/test_stateconf.py index eca74a8080..2d8fa96d4c 100644 --- a/tests/unit/test_stateconf.py +++ b/tests/unit/test_stateconf.py @@ -7,8 +7,8 @@ import os.path import tempfile # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/unit/test_statemod.py b/tests/unit/test_statemod.py index 86b788b847..4e1d985885 100644 --- a/tests/unit/test_statemod.py +++ b/tests/unit/test_statemod.py @@ -9,9 +9,9 @@ import tempfile import os.path # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON ensure_in_syspath('../') diff --git a/tests/unit/test_target.py b/tests/unit/test_target.py index 493c8e8b93..c37a3e03da 100644 --- a/tests/unit/test_target.py +++ b/tests/unit/test_target.py @@ -15,7 +15,7 @@ import salt.utils.minions import salt.config # Import Salt Testing libs -from salttesting import TestCase, skipIf +from tests.support.unit import TestCase, skipIf import logging diff --git a/tests/unit/test_template.py b/tests/unit/test_template.py index 48ff4643dc..5585de0e8a 100644 --- a/tests/unit/test_template.py +++ b/tests/unit/test_template.py @@ -7,8 +7,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/unit/test_test_module_names.py b/tests/unit/test_test_module_names.py index 2489dc9833..a7c632963a 100644 --- a/tests/unit/test_test_module_names.py +++ b/tests/unit/test_test_module_names.py @@ -9,7 +9,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import TestCase +from tests.support.unit import TestCase # Import Salt libs diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py index af6aafa64c..b70b503ea2 100644 --- a/tests/unit/test_version.py +++ b/tests/unit/test_version.py @@ -14,8 +14,8 @@ from __future__ import absolute_import import re # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') diff --git a/tests/unit/transport/test_ipc.py b/tests/unit/transport/test_ipc.py index 128a6867b6..7ae724ec4b 100644 --- a/tests/unit/transport/test_ipc.py +++ b/tests/unit/transport/test_ipc.py @@ -24,8 +24,8 @@ from salt.ext.six.moves import range # Import Salt Testing libs import integration -from salttesting.mock import MagicMock -from salttesting.helpers import ensure_in_syspath +from tests.support.mock import MagicMock +from tests.support.helpers import ensure_in_syspath log = logging.getLogger(__name__) diff --git a/tests/unit/transport/test_tcp.py b/tests/unit/transport/test_tcp.py index bece048655..2baf7cc173 100644 --- a/tests/unit/transport/test_tcp.py +++ b/tests/unit/transport/test_tcp.py @@ -20,8 +20,8 @@ import salt.transport.client import salt.exceptions # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../') import integration diff --git a/tests/unit/transport/test_zeromq.py b/tests/unit/transport/test_zeromq.py index d997697705..75404055d0 100644 --- a/tests/unit/transport/test_zeromq.py +++ b/tests/unit/transport/test_zeromq.py @@ -28,7 +28,7 @@ import salt.exceptions # Import Salt Testing libs -from salttesting import TestCase, skipIf +from tests.support.unit import TestCase, skipIf # Import test support libs import tests.integration as integration diff --git a/tests/unit/utils/test_aggregation.py b/tests/unit/utils/test_aggregation.py index a23f8420e0..0c7104a72e 100644 --- a/tests/unit/utils/test_aggregation.py +++ b/tests/unit/utils/test_aggregation.py @@ -4,8 +4,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_args.py b/tests/unit/utils/test_args.py index a66d0f6b15..eda348ef28 100644 --- a/tests/unit/utils/test_args.py +++ b/tests/unit/utils/test_args.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.utils import args # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_boto.py b/tests/unit/utils/test_boto.py index 467edabda8..b4ec3f4b69 100644 --- a/tests/unit/utils/test_boto.py +++ b/tests/unit/utils/test_boto.py @@ -5,9 +5,9 @@ from __future__ import absolute_import from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module # Import Salt Testing libs -from salttesting.unit import skipIf, TestCase -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import Salt libs diff --git a/tests/unit/utils/test_cache.py b/tests/unit/utils/test_cache.py index c71ba54eae..288ebb57b7 100644 --- a/tests/unit/utils/test_cache.py +++ b/tests/unit/utils/test_cache.py @@ -14,8 +14,8 @@ import tempfile import shutil # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_cloud.py b/tests/unit/utils/test_cloud.py index 311e009dac..b0e517093d 100644 --- a/tests/unit/utils/test_cloud.py +++ b/tests/unit/utils/test_cloud.py @@ -15,8 +15,8 @@ import os import tempfile # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_configcomparer.py b/tests/unit/utils/test_configcomparer.py index 4d5be6da5d..9ec5136446 100644 --- a/tests/unit/utils/test_configcomparer.py +++ b/tests/unit/utils/test_configcomparer.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import copy # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_context.py b/tests/unit/utils/test_context.py index 5249d56747..58bf11ec23 100644 --- a/tests/unit/utils/test_context.py +++ b/tests/unit/utils/test_context.py @@ -9,8 +9,8 @@ import os import shutil # Import Salt testing libraries -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON from salt.utils.cache import context_cache # Import Salt libraries diff --git a/tests/unit/utils/test_decorators.py b/tests/unit/utils/test_decorators.py index 407834017d..f5eead3fac 100644 --- a/tests/unit/utils/test_decorators.py +++ b/tests/unit/utils/test_decorators.py @@ -8,8 +8,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath from salt.utils import decorators from salt.version import SaltStackVersion from salt.exceptions import CommandExecutionError diff --git a/tests/unit/utils/test_dictupdate.py b/tests/unit/utils/test_dictupdate.py index 137dd98cc1..5893d514f4 100644 --- a/tests/unit/utils/test_dictupdate.py +++ b/tests/unit/utils/test_dictupdate.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import copy # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_disk_cache.py b/tests/unit/utils/test_disk_cache.py index d639b948ae..6be7b32031 100644 --- a/tests/unit/utils/test_disk_cache.py +++ b/tests/unit/utils/test_disk_cache.py @@ -14,8 +14,8 @@ import tempfile import time # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_etcd_util.py b/tests/unit/utils/test_etcd_util.py index 88170ff8a0..5320a339c2 100644 --- a/tests/unit/utils/test_etcd_util.py +++ b/tests/unit/utils/test_etcd_util.py @@ -7,14 +7,14 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -from salttesting.helpers import ensure_in_syspath +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_event.py b/tests/unit/utils/test_event.py index 0aedd7d608..ce381c47ba 100644 --- a/tests/unit/utils/test_event.py +++ b/tests/unit/utils/test_event.py @@ -22,10 +22,7 @@ from contextlib import contextmanager from multiprocessing import Process # Import Salt Testing libs -from salttesting import (expectedFailure, skipIf) -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -ensure_in_syspath('../../') +from tests.support.unit import expectedFailure, skipIf, TestCase # Import salt libs import integration @@ -368,7 +365,3 @@ class TestAsyncEventPublisher(AsyncTestCase): self.assertEqual(self.tag, 'evt1') self.data.pop('_stamp') # drop the stamp self.assertEqual(self.data, {'data': 'foo1'}) - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestSaltEvent, needs_daemon=False) diff --git a/tests/unit/utils/test_extend.py b/tests/unit/utils/test_extend.py index f63a4896f7..28f9a88d86 100644 --- a/tests/unit/utils/test_extend.py +++ b/tests/unit/utils/test_extend.py @@ -14,9 +14,9 @@ import shutil from datetime import date # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_filebuffer.py b/tests/unit/utils/test_filebuffer.py index 069d13fdc3..e5f81a2bfd 100644 --- a/tests/unit/utils/test_filebuffer.py +++ b/tests/unit/utils/test_filebuffer.py @@ -11,8 +11,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_find.py b/tests/unit/utils/test_find.py index b1b885b648..08e21babec 100644 --- a/tests/unit/utils/test_find.py +++ b/tests/unit/utils/test_find.py @@ -9,8 +9,8 @@ import tempfile import stat # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_format_call.py b/tests/unit/utils/test_format_call.py index fa008626b0..28bff8f6cd 100644 --- a/tests/unit/utils/test_format_call.py +++ b/tests/unit/utils/test_format_call.py @@ -13,8 +13,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_gitfs.py b/tests/unit/utils/test_gitfs.py index 3f672b350a..a5f9799864 100644 --- a/tests/unit/utils/test_gitfs.py +++ b/tests/unit/utils/test_gitfs.py @@ -8,9 +8,9 @@ any remotes. from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_http.py b/tests/unit/utils/test_http.py index fe2ff1e931..014e3c77b0 100644 --- a/tests/unit/utils/test_http.py +++ b/tests/unit/utils/test_http.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_immutabletypes.py b/tests/unit/utils/test_immutabletypes.py index 81caed2a9e..76ecf43c71 100644 --- a/tests/unit/utils/test_immutabletypes.py +++ b/tests/unit/utils/test_immutabletypes.py @@ -13,8 +13,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_kwarg_regex.py b/tests/unit/utils/test_kwarg_regex.py index 037e24e543..b87b05a385 100644 --- a/tests/unit/utils/test_kwarg_regex.py +++ b/tests/unit/utils/test_kwarg_regex.py @@ -11,8 +11,8 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_locales.py b/tests/unit/utils/test_locales.py index 7c747f2221..77d0e00edb 100644 --- a/tests/unit/utils/test_locales.py +++ b/tests/unit/utils/test_locales.py @@ -4,9 +4,9 @@ from __future__ import absolute_import # salt testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON # salt libs ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_mac_utils.py b/tests/unit/utils/test_mac_utils.py index 49fa79f13c..597ca9d871 100644 --- a/tests/unit/utils/test_mac_utils.py +++ b/tests/unit/utils/test_mac_utils.py @@ -7,9 +7,9 @@ mac_utils tests from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON from salt.ext.six.moves import range ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_minions.py b/tests/unit/utils/test_minions.py index 73acb379bf..4360e551cc 100644 --- a/tests/unit/utils/test_minions.py +++ b/tests/unit/utils/test_minions.py @@ -7,8 +7,8 @@ from __future__ import absolute_import from salt.utils import minions # Import Salt Testing Libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_network.py b/tests/unit/utils/test_network.py index a13492f8f8..1f7ad1b040 100644 --- a/tests/unit/utils/test_network.py +++ b/tests/unit/utils/test_network.py @@ -3,10 +3,10 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import skipIf -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock +from tests.support.unit import skipIf +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_parsers.py b/tests/unit/utils/test_parsers.py index 490be91414..af592c357d 100644 --- a/tests/unit/utils/test_parsers.py +++ b/tests/unit/utils/test_parsers.py @@ -8,9 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath, destructiveTest -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ensure_in_syspath, destructiveTest +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/utils/test_path_join.py b/tests/unit/utils/test_path_join.py index 9b8e451e8e..80286486fb 100644 --- a/tests/unit/utils/test_path_join.py +++ b/tests/unit/utils/test_path_join.py @@ -18,8 +18,8 @@ import tempfile # Import Salt Testing libs import salt.utils -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_process.py b/tests/unit/utils/test_process.py index a530c2872d..44776bbc69 100644 --- a/tests/unit/utils/test_process.py +++ b/tests/unit/utils/test_process.py @@ -9,8 +9,8 @@ import signal import multiprocessing # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_rsax931.py b/tests/unit/utils/test_rsax931.py index dc4c20d7b2..aca7a27cb5 100644 --- a/tests/unit/utils/test_rsax931.py +++ b/tests/unit/utils/test_rsax931.py @@ -7,8 +7,8 @@ Test the RSA ANSI X9.31 signer and verifier from __future__ import absolute_import # salt testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_runtime_whitespace_regex.py b/tests/unit/utils/test_runtime_whitespace_regex.py index 20f911b9eb..83684c9227 100644 --- a/tests/unit/utils/test_runtime_whitespace_regex.py +++ b/tests/unit/utils/test_runtime_whitespace_regex.py @@ -12,8 +12,8 @@ from __future__ import absolute_import import re # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_safe_walk.py b/tests/unit/utils/test_safe_walk.py index 400ae3bdc1..76105e65a2 100644 --- a/tests/unit/utils/test_safe_walk.py +++ b/tests/unit/utils/test_safe_walk.py @@ -8,8 +8,8 @@ from shutil import rmtree from tempfile import mkdtemp # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_sanitizers.py b/tests/unit/utils/test_sanitizers.py index e9c333149c..c53600017b 100644 --- a/tests/unit/utils/test_sanitizers.py +++ b/tests/unit/utils/test_sanitizers.py @@ -8,9 +8,9 @@ from salt.ext.six import text_type as text from salt.utils.sanitizers import clean # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_schedule.py b/tests/unit/utils/test_schedule.py index a7d8c06bec..0cbaa577cc 100644 --- a/tests/unit/utils/test_schedule.py +++ b/tests/unit/utils/test_schedule.py @@ -9,9 +9,9 @@ import os import copy # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import skipIf, TestCase +from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_schema.py b/tests/unit/utils/test_schema.py index 67aac1b5da..eee89720a6 100644 --- a/tests/unit/utils/test_schema.py +++ b/tests/unit/utils/test_schema.py @@ -12,8 +12,8 @@ import yaml from distutils.version import LooseVersion as _LooseVersion # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_systemd.py b/tests/unit/utils/test_systemd.py index 9449600f18..d32c403f88 100644 --- a/tests/unit/utils/test_systemd.py +++ b/tests/unit/utils/test_systemd.py @@ -6,8 +6,8 @@ import errno import os # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.mock import Mock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.unit import TestCase, skipIf +from tests.support.mock import Mock, patch, NO_MOCK, NO_MOCK_REASON # Import Salt libs from salt.exceptions import SaltInvocationError diff --git a/tests/unit/utils/test_url.py b/tests/unit/utils/test_url.py index b1e93af93b..8bb6e8ac1a 100644 --- a/tests/unit/utils/test_url.py +++ b/tests/unit/utils/test_url.py @@ -7,9 +7,9 @@ from __future__ import absolute_import import salt.utils.url # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 43b98bc64f..372b4bccc2 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import ( patch, DEFAULT, create_autospec, NO_MOCK, diff --git a/tests/unit/utils/test_validate_net.py b/tests/unit/utils/test_validate_net.py index 7d29c392f0..e019b7b848 100644 --- a/tests/unit/utils/test_validate_net.py +++ b/tests/unit/utils/test_validate_net.py @@ -7,9 +7,9 @@ from __future__ import absolute_import from salt.utils.validate import net # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') diff --git a/tests/unit/utils/test_verify.py b/tests/unit/utils/test_verify.py index 7aff44d935..d8b80b4e60 100644 --- a/tests/unit/utils/test_verify.py +++ b/tests/unit/utils/test_verify.py @@ -15,13 +15,13 @@ import tempfile import socket # Import Salt Testing libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ( +from tests.support.unit import skipIf, TestCase +from tests.support.helpers import ( ensure_in_syspath, requires_network, TestsLoggingHandler ) -from salttesting.mock import ( +from tests.support.mock import ( MagicMock, patch, NO_MOCK, diff --git a/tests/unit/utils/test_vt.py b/tests/unit/utils/test_vt.py index 91ed33a976..c753ab12f5 100644 --- a/tests/unit/utils/test_vt.py +++ b/tests/unit/utils/test_vt.py @@ -18,8 +18,8 @@ import subprocess import time # Import Salt Testing libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_warnings.py b/tests/unit/utils/test_warnings.py index b6dd8dd658..533c84c889 100644 --- a/tests/unit/utils/test_warnings.py +++ b/tests/unit/utils/test_warnings.py @@ -15,8 +15,8 @@ import sys import warnings # Import Salt Testing libs -from salttesting import TestCase -from salttesting.helpers import ensure_in_syspath +from tests.support.unit import TestCase +from tests.support.helpers import ensure_in_syspath ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_which.py b/tests/unit/utils/test_which.py index 363806f076..31cc1ac38f 100644 --- a/tests/unit/utils/test_which.py +++ b/tests/unit/utils/test_which.py @@ -5,9 +5,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from salttesting import skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch +from tests.support.unit import skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch ensure_in_syspath('../../') # Import salt libs diff --git a/tests/unit/utils/test_yamlloader.py b/tests/unit/utils/test_yamlloader.py index 1817021abc..9386d23b9e 100644 --- a/tests/unit/utils/test_yamlloader.py +++ b/tests/unit/utils/test_yamlloader.py @@ -12,9 +12,9 @@ from salt.utils.yamlloader import SaltYamlSafeLoader import salt.utils # Import Salt Testing Libs -from salttesting import TestCase, skipIf -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import patch, NO_MOCK, NO_MOCK_REASON, mock_open +from tests.support.unit import TestCase, skipIf +from tests.support.helpers import ensure_in_syspath +from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON, mock_open ensure_in_syspath('../../') diff --git a/tests/unit/utils/vmware_test/test_cluster.py b/tests/unit/utils/vmware_test/test_cluster.py index 2ea3ec6956..c4584379ed 100644 --- a/tests/unit/utils/vmware_test/test_cluster.py +++ b/tests/unit/utils/vmware_test/test_cluster.py @@ -9,8 +9,8 @@ Tests for cluster related functions in salt.utils.vmware from __future__ import absolute_import import logging # Import Salt testing libraries -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call # Import Salt libraries from salt.exceptions import VMwareApiError, VMwareRuntimeError, \ VMwareObjectRetrievalError diff --git a/tests/unit/utils/vmware_test/test_common.py b/tests/unit/utils/vmware_test/test_common.py index 910bbb93fd..7acc92a41b 100644 --- a/tests/unit/utils/vmware_test/test_common.py +++ b/tests/unit/utils/vmware_test/test_common.py @@ -10,8 +10,8 @@ from __future__ import absolute_import import logging # Import Salt testing libraries -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call, \ +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call, \ PropertyMock # Import Salt libraries diff --git a/tests/unit/utils/vmware_test/test_connection.py b/tests/unit/utils/vmware_test/test_connection.py index 4071774000..b18be0fb85 100644 --- a/tests/unit/utils/vmware_test/test_connection.py +++ b/tests/unit/utils/vmware_test/test_connection.py @@ -13,8 +13,8 @@ import ssl import sys # Import Salt testing libraries -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call, \ +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call, \ PropertyMock import salt.exceptions as excs diff --git a/tests/unit/utils/vmware_test/test_datacenter.py b/tests/unit/utils/vmware_test/test_datacenter.py index 827b4e9506..b3f09d1c7f 100644 --- a/tests/unit/utils/vmware_test/test_datacenter.py +++ b/tests/unit/utils/vmware_test/test_datacenter.py @@ -9,8 +9,8 @@ Tests for datacenter related functions in salt.utils.vmware from __future__ import absolute_import import logging # Import Salt testing libraries -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock from salt.exceptions import VMwareObjectRetrievalError, VMwareApiError, \ VMwareRuntimeError diff --git a/tests/unit/utils/vmware_test/test_host.py b/tests/unit/utils/vmware_test/test_host.py index 751f3258b8..b4042adf50 100644 --- a/tests/unit/utils/vmware_test/test_host.py +++ b/tests/unit/utils/vmware_test/test_host.py @@ -10,8 +10,8 @@ from __future__ import absolute_import import logging # Import Salt testing libraries -from salttesting import TestCase, skipIf -from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock +from tests.support.unit import TestCase, skipIf +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock # Import Salt libraries import salt.utils.vmware From 037dfb3ecedb399ce9b0b62a3c532ddcb2b94612 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 28 Feb 2017 15:56:06 -0700 Subject: [PATCH 278/370] Fix lint error --- tests/integration/returners/test_local_cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/returners/test_local_cache.py b/tests/integration/returners/test_local_cache.py index afa21244a2..acf24fcdfb 100644 --- a/tests/integration/returners/test_local_cache.py +++ b/tests/integration/returners/test_local_cache.py @@ -129,7 +129,7 @@ class Local_CacheTest(integration.ShellCase): time.sleep(1) os.rename(lock_dir, new_jid_dir) break - except WindowsError: + except WindowsError: # pylint: disable=E0602 continue # check dir exists From fa56515bd35f27438ab624aa213a9c9aca6d5b57 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 28 Feb 2017 17:58:58 -0500 Subject: [PATCH 279/370] Handle edge case: password and empty_password both set Handle the case where a user mistakenly passes both the password and empty_password=True arguments. Instead of throwing as weird key error, simply log a warning message and fail gracefully. Fixes #39741 --- salt/states/user.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/states/user.py b/salt/states/user.py index 009a0fdf52..75e9ef8852 100644 --- a/salt/states/user.py +++ b/salt/states/user.py @@ -497,6 +497,9 @@ def present(name, if key == 'passwd' and not empty_password: __salt__['shadow.set_password'](name, password) continue + if key == 'passwd' and empty_password: + log.warn("No password will be set when empty_password=True") + continue if key == 'date': __salt__['shadow.set_date'](name, date) continue From 40a64191a106b895820ee7d4e101957a91a56990 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 27 Feb 2017 15:59:04 +0000 Subject: [PATCH 280/370] Absolute imports and A LOT of code cleanup. --- doc/man/salt.7 | 4 +- doc/topics/development/tests/index.rst | 8 +-- doc/topics/development/tests/integration.rst | 20 +++--- doc/topics/development/tests/unit.rst | 34 +++------- doc/topics/tutorials/writing_tests.rst | 4 +- .../unit/modules/test_{{module_name}}.py | 4 +- .../tests/unit/states/test_{{module_name}}.py | 4 +- tests/conftest.py | 3 +- tests/integration/__init__.py | 64 +------------------ tests/integration/cli/test_batch.py | 11 +--- tests/integration/cli/test_custom_module.py | 7 +- tests/integration/cli/test_grains.py | 10 +-- tests/integration/client/test_kwarg.py | 11 +--- tests/integration/client/test_runner.py | 7 +- tests/integration/client/test_standard.py | 9 +-- tests/integration/client/test_syndic.py | 11 +--- tests/integration/cloud/helpers/virtualbox.py | 2 +- .../cloud/providers/test_digital_ocean.py | 11 +--- tests/integration/cloud/providers/test_ec2.py | 11 +--- tests/integration/cloud/providers/test_gce.py | 11 +--- .../cloud/providers/test_gogrid.py | 11 +--- .../cloud/providers/test_joyent.py | 11 +--- .../cloud/providers/test_linode.py | 11 +--- .../cloud/providers/test_msazure.py | 11 +--- .../cloud/providers/test_openstack.py | 14 +--- .../cloud/providers/test_profitbricks.py | 11 +--- .../cloud/providers/test_rackspace.py | 11 +--- .../cloud/providers/test_virtualbox.py | 56 ++++++++-------- .../integration/cloud/providers/test_vultr.py | 11 +--- .../integration/fileserver/test_fileclient.py | 12 +--- tests/integration/fileserver/test_gitfs.py | 8 +-- tests/integration/fileserver/test_roots.py | 9 +-- tests/integration/grains/test_core.py | 5 +- tests/integration/loader/test_ext_grains.py | 2 +- tests/integration/loader/test_ext_modules.py | 11 +--- tests/integration/loader/test_globals.py | 10 +-- tests/integration/loader/test_interfaces.py | 8 --- tests/integration/loader/test_loader.py | 6 +- tests/integration/minion/test_blackout.py | 11 +--- tests/integration/minion/test_pillar.py | 24 +++---- tests/integration/minion/test_timeout.py | 10 +-- tests/integration/modules/test_aliases.py | 11 +--- tests/integration/modules/test_archive.py | 13 +--- tests/integration/modules/test_beacons.py | 2 +- tests/integration/modules/test_boto_iam.py | 6 +- tests/integration/modules/test_boto_sns.py | 6 +- tests/integration/modules/test_cmdmod.py | 8 +-- tests/integration/modules/test_config.py | 11 +--- tests/integration/modules/test_cp.py | 8 +-- .../integration/modules/test_darwin_sysctl.py | 9 +-- tests/integration/modules/test_data.py | 10 +-- tests/integration/modules/test_decorators.py | 11 +--- tests/integration/modules/test_disk.py | 10 +-- tests/integration/modules/test_django.py | 9 +-- tests/integration/modules/test_event.py | 9 +-- tests/integration/modules/test_file.py | 9 +-- tests/integration/modules/test_gem.py | 9 +-- .../integration/modules/test_gentoolkitmod.py | 11 +--- tests/integration/modules/test_git.py | 11 +--- tests/integration/modules/test_grains.py | 13 +--- tests/integration/modules/test_groupadd.py | 10 +-- tests/integration/modules/test_hosts.py | 9 +-- tests/integration/modules/test_key.py | 10 +-- tests/integration/modules/test_linux_acl.py | 11 +--- tests/integration/modules/test_locale.py | 4 +- tests/integration/modules/test_lxc.py | 10 +-- .../integration/modules/test_mac_assistive.py | 11 +--- tests/integration/modules/test_mac_brew.py | 13 +--- .../integration/modules/test_mac_defaults.py | 10 +-- tests/integration/modules/test_mac_desktop.py | 12 +--- tests/integration/modules/test_mac_group.py | 9 +-- .../integration/modules/test_mac_keychain.py | 9 +-- tests/integration/modules/test_mac_pkgutil.py | 10 +-- tests/integration/modules/test_mac_ports.py | 10 +-- tests/integration/modules/test_mac_power.py | 15 +---- tests/integration/modules/test_mac_service.py | 10 +-- tests/integration/modules/test_mac_shadow.py | 12 +--- .../modules/test_mac_softwareupdate.py | 10 +-- tests/integration/modules/test_mac_system.py | 12 +--- .../integration/modules/test_mac_timezone.py | 10 +-- tests/integration/modules/test_mac_user.py | 9 +-- tests/integration/modules/test_mac_xattr.py | 9 +-- tests/integration/modules/test_mine.py | 10 +-- tests/integration/modules/test_mysql.py | 12 +--- tests/integration/modules/test_nilrt_ip.py | 10 +-- tests/integration/modules/test_pillar.py | 14 +--- tests/integration/modules/test_pip.py | 9 +-- tests/integration/modules/test_pkg.py | 11 +--- tests/integration/modules/test_publish.py | 11 +--- tests/integration/modules/test_pw_user.py | 12 +--- tests/integration/modules/test_rabbitmq.py | 13 +--- tests/integration/modules/test_random_org.py | 14 ---- tests/integration/modules/test_saltutil.py | 13 +--- tests/integration/modules/test_shadow.py | 12 +--- tests/integration/modules/test_ssh.py | 11 +--- tests/integration/modules/test_state.py | 9 +-- tests/integration/modules/test_supervisord.py | 9 +-- tests/integration/modules/test_sysctl.py | 11 +--- tests/integration/modules/test_sysmod.py | 11 +--- tests/integration/modules/test_system.py | 15 +---- tests/integration/modules/test_test.py | 13 +--- tests/integration/modules/test_timezone.py | 11 +--- tests/integration/modules/test_useradd.py | 10 +-- tests/integration/modules/test_virt.py | 12 +--- tests/integration/modules/test_virtualenv.py | 9 +-- .../netapi/rest_cherrypy/test_app_pam.py | 2 +- .../netapi/rest_tornado/test_app.py | 16 +---- tests/integration/netapi/test_client.py | 7 +- tests/integration/output/test_output.py | 11 +--- tests/integration/reactor/test_reactor.py | 10 +-- tests/integration/renderers/test_pydsl.py | 10 +-- .../returners/test_librato_return.py | 8 +-- .../integration/returners/test_local_cache.py | 12 +--- tests/integration/runners/test_fileserver.py | 10 +-- tests/integration/runners/test_jobs.py | 11 +--- tests/integration/runners/test_manage.py | 11 +--- .../runners/test_runner_returns.py | 4 +- tests/integration/runners/test_salt.py | 11 +--- tests/integration/runners/test_state.py | 11 +--- tests/integration/runners/test_winrepo.py | 11 +--- tests/integration/sdb/test_env.py | 11 +--- tests/integration/shell/test_arguments.py | 11 +--- tests/integration/shell/test_auth.py | 12 +--- tests/integration/shell/test_call.py | 15 +---- tests/integration/shell/test_cloud.py | 9 +-- tests/integration/shell/test_cp.py | 9 +-- tests/integration/shell/test_enabled.py | 10 +-- tests/integration/shell/test_key.py | 9 +-- tests/integration/shell/test_master.py | 22 +++---- tests/integration/shell/test_master_tops.py | 10 +-- tests/integration/shell/test_matcher.py | 9 +-- tests/integration/shell/test_minion.py | 19 ++---- tests/integration/shell/test_proxy.py | 21 ++---- tests/integration/shell/test_runner.py | 10 +-- tests/integration/shell/test_saltcli.py | 11 +--- tests/integration/shell/test_syndic.py | 10 +-- tests/integration/ssh/test_deploy.py | 8 +-- tests/integration/states/test_alternatives.py | 7 +- tests/integration/states/test_archive.py | 9 +-- tests/integration/states/test_boto_sns.py | 6 +- tests/integration/states/test_bower.py | 10 +-- tests/integration/states/test_cmd.py | 9 +-- tests/integration/states/test_compiler.py | 11 +--- tests/integration/states/test_file.py | 9 +-- tests/integration/states/test_git.py | 10 +-- tests/integration/states/test_handle_error.py | 11 +--- .../integration/states/test_handle_iorder.py | 11 +--- tests/integration/states/test_host.py | 9 +-- tests/integration/states/test_keystone.py | 14 +--- tests/integration/states/test_match.py | 9 +-- tests/integration/states/test_mysql.py | 13 +--- tests/integration/states/test_network.py | 15 +---- tests/integration/states/test_npm.py | 10 +-- tests/integration/states/test_pip.py | 2 +- tests/integration/states/test_pkg.py | 8 +-- tests/integration/states/test_pkgrepo.py | 9 +-- .../integration/states/test_rabbitmq_user.py | 11 +--- .../integration/states/test_rabbitmq_vhost.py | 11 +--- tests/integration/states/test_renderers.py | 11 +--- tests/integration/states/test_service.py | 12 +--- tests/integration/states/test_ssh.py | 9 +-- tests/integration/states/test_supervisord.py | 9 +-- tests/integration/states/test_svn.py | 11 +--- tests/integration/states/test_user.py | 13 +--- tests/integration/states/test_virtualenv.py | 10 +-- tests/integration/utils/test_reactor.py | 2 +- tests/integration/utils/testprogram.py | 7 +- tests/integration/wheel/test_client.py | 7 +- tests/integration/wheel/test_key.py | 6 +- tests/support/helpers.py | 46 ------------- tests/unit/__init__.py | 17 +---- tests/unit/beacons/test_adb_beacon.py | 12 ++-- tests/unit/beacons/test_inotify_beacon.py | 10 +-- tests/unit/cache/test_localfs.py | 2 +- tests/unit/cloud/clouds/test_dimensiondata.py | 7 -- tests/unit/cloud/clouds/test_gce.py | 7 -- tests/unit/cloud/clouds/test_joyent.py | 8 --- tests/unit/cloud/clouds/test_linode.py | 8 --- tests/unit/cloud/clouds/test_opennebula.py | 8 --- tests/unit/cloud/clouds/test_saltify.py | 5 -- tests/unit/cloud/clouds/test_vmware.py | 10 +-- tests/unit/cloud/test_libcloud.py | 10 --- tests/unit/config/schemas/test_ssh.py | 3 - tests/unit/config/test_config.py | 2 +- tests/unit/engines/test_sqs_events.py | 9 --- tests/unit/fileserver/test_gitfs.py | 2 +- tests/unit/modules/test_aliases.py | 8 --- tests/unit/modules/test_alternatives.py | 9 +-- tests/unit/modules/test_apache.py | 5 -- tests/unit/modules/test_aptpkg.py | 8 --- tests/unit/modules/test_archive.py | 11 +--- tests/unit/modules/test_artifactory.py | 2 - tests/unit/modules/test_at.py | 4 -- tests/unit/modules/test_augeas_cfg.py | 5 -- tests/unit/modules/test_bluez.py | 4 -- tests/unit/modules/test_boto_apigateway.py | 7 -- tests/unit/modules/test_boto_cloudtrail.py | 12 +--- .../modules/test_boto_cloudwatch_event.py | 8 --- .../unit/modules/test_boto_cognitoidentity.py | 7 -- .../modules/test_boto_elasticsearch_domain.py | 8 --- tests/unit/modules/test_boto_elb.py | 7 -- tests/unit/modules/test_boto_iot.py | 9 --- tests/unit/modules/test_boto_lambda.py | 8 --- tests/unit/modules/test_boto_s3_bucket.py | 8 --- tests/unit/modules/test_boto_secgroup.py | 8 --- tests/unit/modules/test_boto_vpc.py | 7 -- tests/unit/modules/test_bower.py | 9 --- tests/unit/modules/test_bridge.py | 5 -- tests/unit/modules/test_btrfs.py | 9 --- tests/unit/modules/test_cassandra.py | 5 -- tests/unit/modules/test_cassandra_cql.py | 8 --- tests/unit/modules/test_chef.py | 5 -- tests/unit/modules/test_cmdmod.py | 8 --- tests/unit/modules/test_composer.py | 5 -- tests/unit/modules/test_config.py | 8 --- tests/unit/modules/test_cp.py | 8 --- tests/unit/modules/test_cpan.py | 5 -- tests/unit/modules/test_cron.py | 11 ---- tests/unit/modules/test_cyg.py | 7 -- tests/unit/modules/test_daemontools.py | 5 -- tests/unit/modules/test_data.py | 5 -- tests/unit/modules/test_ddns.py | 5 -- tests/unit/modules/test_deb_apache.py | 4 -- tests/unit/modules/test_deb_postgres.py | 11 ---- tests/unit/modules/test_debconfmod.py | 5 -- tests/unit/modules/test_debian_ip.py | 5 -- tests/unit/modules/test_debian_service.py | 5 -- tests/unit/modules/test_defaults.py | 5 -- tests/unit/modules/test_devmap.py | 5 -- tests/unit/modules/test_dig.py | 7 -- tests/unit/modules/test_disk.py | 7 -- tests/unit/modules/test_djangomod.py | 5 -- tests/unit/modules/test_dnsmasq.py | 5 -- tests/unit/modules/test_dnsutil.py | 8 --- tests/unit/modules/test_docker.py | 8 --- tests/unit/modules/test_dpkg.py | 5 -- tests/unit/modules/test_drac.py | 5 -- tests/unit/modules/test_drbd.py | 5 -- tests/unit/modules/test_environ.py | 5 -- tests/unit/modules/test_etcd_mod.py | 8 --- tests/unit/modules/test_event.py | 4 -- tests/unit/modules/test_extfs.py | 4 -- tests/unit/modules/test_file.py | 11 ---- tests/unit/modules/test_firewalld.py | 4 -- tests/unit/modules/test_gem.py | 7 -- tests/unit/modules/test_genesis.py | 5 -- tests/unit/modules/test_gentoo_service.py | 5 -- tests/unit/modules/test_git.py | 5 -- tests/unit/modules/test_glusterfs.py | 5 -- tests/unit/modules/test_gnomedesktop.py | 5 -- tests/unit/modules/test_grains.py | 8 --- tests/unit/modules/test_groupadd.py | 5 -- tests/unit/modules/test_grub_legacy.py | 5 -- tests/unit/modules/test_guestfs.py | 5 -- tests/unit/modules/test_hadoop.py | 5 -- tests/unit/modules/test_haproxyconn.py | 9 --- tests/unit/modules/test_hashutil.py | 6 -- tests/unit/modules/test_hg.py | 5 -- tests/unit/modules/test_hipchat.py | 5 -- tests/unit/modules/test_hosts.py | 4 -- tests/unit/modules/test_htpasswd.py | 4 -- tests/unit/modules/test_http.py | 4 -- tests/unit/modules/test_ilo.py | 5 -- tests/unit/modules/test_incron.py | 5 -- tests/unit/modules/test_influx08.py | 4 -- tests/unit/modules/test_ini_manage.py | 8 --- tests/unit/modules/test_inspect_collector.py | 4 +- tests/unit/modules/test_inspect_fsdb.py | 3 - tests/unit/modules/test_introspect.py | 8 --- tests/unit/modules/test_ipset.py | 5 -- tests/unit/modules/test_iptables.py | 8 --- tests/unit/modules/test_jboss7.py | 2 - tests/unit/modules/test_jboss7_cli.py | 3 +- tests/unit/modules/test_k8s.py | 23 +++---- tests/unit/modules/test_key.py | 5 -- tests/unit/modules/test_keyboard.py | 8 --- tests/unit/modules/test_keystone.py | 9 --- tests/unit/modules/test_kmod.py | 5 -- tests/unit/modules/test_launchctl.py | 5 -- tests/unit/modules/test_ldapmod.py | 8 --- tests/unit/modules/test_libcloud_dns.py | 7 -- tests/unit/modules/test_linux_acl.py | 2 - tests/unit/modules/test_linux_lvm.py | 4 -- tests/unit/modules/test_linux_sysctl.py | 8 --- tests/unit/modules/test_localemod.py | 5 -- tests/unit/modules/test_locate.py | 8 --- tests/unit/modules/test_logadm.py | 5 -- tests/unit/modules/test_logrotate.py | 8 --- tests/unit/modules/test_lvs.py | 8 --- tests/unit/modules/test_mac_assistive.py | 8 --- tests/unit/modules/test_mac_brew.py | 8 --- tests/unit/modules/test_mac_defaults.py | 8 --- tests/unit/modules/test_mac_desktop.py | 8 --- tests/unit/modules/test_mac_group.py | 5 -- tests/unit/modules/test_mac_keychain.py | 7 -- tests/unit/modules/test_mac_package.py | 7 -- tests/unit/modules/test_mac_power.py | 8 --- tests/unit/modules/test_mac_sysctl.py | 8 --- tests/unit/modules/test_mac_user.py | 8 --- tests/unit/modules/test_mac_xattr.py | 8 --- tests/unit/modules/test_mdadm.py | 6 -- tests/unit/modules/test_memcached.py | 8 --- tests/unit/modules/test_mine.py | 8 --- tests/unit/modules/test_mod_random.py | 8 --- tests/unit/modules/test_modjk.py | 9 --- tests/unit/modules/test_monit.py | 7 -- tests/unit/modules/test_moosefs.py | 8 --- tests/unit/modules/test_mount.py | 4 -- tests/unit/modules/test_munin.py | 8 --- tests/unit/modules/test_mysql.py | 8 --- tests/unit/modules/test_nagios.py | 8 --- tests/unit/modules/test_netscaler.py | 9 --- tests/unit/modules/test_network.py | 9 --- tests/unit/modules/test_network_utils.py | 5 -- tests/unit/modules/test_neutron.py | 9 --- tests/unit/modules/test_nfs3.py | 8 --- tests/unit/modules/test_nftables.py | 9 --- tests/unit/modules/test_nginx.py | 7 -- tests/unit/modules/test_nova.py | 5 -- tests/unit/modules/test_npm.py | 9 --- tests/unit/modules/test_openbsdpkg.py | 5 -- tests/unit/modules/test_openstack_config.py | 9 --- tests/unit/modules/test_oracle.py | 8 --- tests/unit/modules/test_pacman.py | 8 --- tests/unit/modules/test_pagerduty.py | 8 --- tests/unit/modules/test_pam.py | 9 --- tests/unit/modules/test_parallels.py | 7 -- tests/unit/modules/test_parted.py | 7 -- tests/unit/modules/test_pecl.py | 9 --- tests/unit/modules/test_pillar.py | 9 --- tests/unit/modules/test_pip.py | 7 -- tests/unit/modules/test_pkg_resource.py | 5 -- tests/unit/modules/test_pkgutil.py | 9 --- tests/unit/modules/test_portage_config.py | 6 -- tests/unit/modules/test_postfix.py | 9 --- tests/unit/modules/test_postgres.py | 6 -- tests/unit/modules/test_poudriere.py | 12 +--- tests/unit/modules/test_powerpath.py | 9 --- tests/unit/modules/test_proxy.py | 7 -- tests/unit/modules/test_ps.py | 8 --- tests/unit/modules/test_publish.py | 9 --- tests/unit/modules/test_puppet.py | 7 -- tests/unit/modules/test_pw_group.py | 5 -- tests/unit/modules/test_pw_user.py | 4 -- tests/unit/modules/test_pyenv.py | 9 --- tests/unit/modules/test_qemu_img.py | 9 --- tests/unit/modules/test_qemu_nbd.py | 9 --- tests/unit/modules/test_rabbitmq.py | 9 --- tests/unit/modules/test_raet_publish.py | 9 --- tests/unit/modules/test_rbenv.py | 9 --- tests/unit/modules/test_rdp.py | 5 -- tests/unit/modules/test_redismod.py | 9 --- tests/unit/modules/test_reg_win.py | 4 -- tests/unit/modules/test_ret.py | 9 --- tests/unit/modules/test_rh_ip.py | 9 --- tests/unit/modules/test_rh_service.py | 9 --- tests/unit/modules/test_riak.py | 8 --- tests/unit/modules/test_rpm.py | 8 --- tests/unit/modules/test_rsync.py | 9 --- tests/unit/modules/test_rvm.py | 8 --- tests/unit/modules/test_s3.py | 9 --- tests/unit/modules/test_saltcloudmod.py | 8 --- tests/unit/modules/test_schedule.py | 17 ++--- tests/unit/modules/test_scsi.py | 9 --- tests/unit/modules/test_sdb.py | 9 --- tests/unit/modules/test_seed.py | 9 --- tests/unit/modules/test_sensors.py | 9 --- .../unit/modules/test_serverdensity_device.py | 9 --- tests/unit/modules/test_service.py | 9 --- tests/unit/modules/test_servicenow.py | 7 -- tests/unit/modules/test_shadow.py | 6 -- tests/unit/modules/test_smf.py | 9 --- tests/unit/modules/test_smtp.py | 9 --- tests/unit/modules/test_snapper.py | 8 --- tests/unit/modules/test_solr.py | 9 --- tests/unit/modules/test_sqlite3.py | 9 --- tests/unit/modules/test_ssh.py | 7 -- tests/unit/modules/test_state.py | 7 -- tests/unit/modules/test_status.py | 8 --- tests/unit/modules/test_supervisord.py | 11 +--- tests/unit/modules/test_svn.py | 9 --- tests/unit/modules/test_swift.py | 9 --- tests/unit/modules/test_sysbench.py | 9 --- tests/unit/modules/test_syslog_ng.py | 10 --- tests/unit/modules/test_sysmod.py | 9 --- tests/unit/modules/test_system.py | 9 --- tests/unit/modules/test_systemd.py | 8 --- tests/unit/modules/test_timezone.py | 8 --- tests/unit/modules/test_tls.py | 6 +- tests/unit/modules/test_twilio_notify.py | 9 --- tests/unit/modules/test_udev.py | 9 --- tests/unit/modules/test_uptime.py | 7 -- tests/unit/modules/test_useradd.py | 5 -- tests/unit/modules/test_uwsgi.py | 9 +-- tests/unit/modules/test_varnish.py | 9 --- tests/unit/modules/test_virt.py | 7 -- tests/unit/modules/test_virtualenv.py | 12 +--- tests/unit/modules/test_vsphere.py | 3 - tests/unit/modules/test_win_autoruns.py | 9 --- tests/unit/modules/test_win_certutil.py | 8 --- tests/unit/modules/test_win_disk.py | 9 --- tests/unit/modules/test_win_dism.py | 7 -- tests/unit/modules/test_win_dns_client.py | 9 --- tests/unit/modules/test_win_firewall.py | 9 --- tests/unit/modules/test_win_groupadd.py | 9 --- tests/unit/modules/test_win_iis.py | 7 -- tests/unit/modules/test_win_ip.py | 9 --- tests/unit/modules/test_win_license.py | 7 -- tests/unit/modules/test_win_network.py | 9 --- tests/unit/modules/test_win_ntp.py | 9 --- tests/unit/modules/test_win_path.py | 8 --- tests/unit/modules/test_win_pki.py | 8 --- tests/unit/modules/test_win_powercfg.py | 7 -- tests/unit/modules/test_win_service.py | 7 -- tests/unit/modules/test_win_shadow.py | 9 --- tests/unit/modules/test_win_snmp.py | 8 --- tests/unit/modules/test_win_status.py | 19 +----- tests/unit/modules/test_win_system.py | 7 -- tests/unit/modules/test_win_timezone.py | 9 --- tests/unit/modules/test_xapi.py | 7 -- tests/unit/modules/test_zcbuildout.py | 18 +----- tests/unit/modules/test_zfs.py | 9 --- tests/unit/modules/test_znc.py | 9 --- tests/unit/modules/test_zpool.py | 9 --- tests/unit/modules/test_zypper.py | 7 -- .../unit/netapi/rest_tornado/test_handlers.py | 9 +-- tests/unit/netapi/rest_tornado/test_utils.py | 4 +- tests/unit/output/test_json_out.py | 8 --- tests/unit/output/test_yaml_out.py | 8 --- tests/unit/pillar/test_consul.py | 8 --- tests/unit/pillar/test_git.py | 7 +- tests/unit/pillar/test_hg.py | 2 +- tests/unit/pillar/test_mysql.py | 8 --- tests/unit/pillar/test_nodegroups.py | 3 - tests/unit/pillar/test_sqlcipher.py | 8 --- tests/unit/pillar/test_sqlite3.py | 8 --- tests/unit/renderers/test_gpg.py | 8 --- tests/unit/renderers/test_yaml.py | 3 - tests/unit/renderers/test_yamlex.py | 7 -- tests/unit/returners/test_local_cache.py | 9 +-- tests/unit/returners/test_smtp_return.py | 6 -- tests/unit/runners/test_cache.py | 8 --- tests/unit/runners/test_jobs.py | 8 --- tests/unit/runners/test_queue.py | 12 +--- tests/unit/runners/test_vault.py | 16 ++--- tests/unit/serializers/test_serializers.py | 11 +--- tests/unit/ssh/test_ssh_single.py | 9 +-- tests/unit/states/test_alias.py | 8 --- tests/unit/states/test_alternatives.py | 9 --- tests/unit/states/test_apache.py | 9 --- tests/unit/states/test_apache_conf.py | 9 --- tests/unit/states/test_apache_module.py | 9 --- tests/unit/states/test_apache_site.py | 9 --- tests/unit/states/test_apt.py | 9 --- tests/unit/states/test_archive.py | 7 -- tests/unit/states/test_artifactory.py | 9 --- tests/unit/states/test_at.py | 9 --- tests/unit/states/test_augeas.py | 9 --- tests/unit/states/test_aws_sqs.py | 9 --- tests/unit/states/test_blockdev.py | 9 --- tests/unit/states/test_boto_apigateway.py | 5 +- tests/unit/states/test_boto_asg.py | 9 --- tests/unit/states/test_boto_cloudtrail.py | 5 +- .../unit/states/test_boto_cloudwatch_alarm.py | 9 --- .../unit/states/test_boto_cloudwatch_event.py | 5 +- .../unit/states/test_boto_cognitoidentity.py | 5 +- tests/unit/states/test_boto_dynamodb.py | 9 --- tests/unit/states/test_boto_ec2.py | 9 --- tests/unit/states/test_boto_elasticache.py | 9 --- .../states/test_boto_elasticsearch_domain.py | 5 +- tests/unit/states/test_boto_elb.py | 9 --- tests/unit/states/test_boto_iam_role.py | 9 --- tests/unit/states/test_boto_iot.py | 5 +- tests/unit/states/test_boto_kinesis.py | 9 --- tests/unit/states/test_boto_lambda.py | 5 +- tests/unit/states/test_boto_lc.py | 8 --- tests/unit/states/test_boto_route53.py | 9 --- tests/unit/states/test_boto_s3_bucket.py | 5 +- tests/unit/states/test_boto_secgroup.py | 7 -- tests/unit/states/test_boto_sns.py | 9 --- tests/unit/states/test_boto_sqs.py | 9 --- tests/unit/states/test_boto_vpc.py | 5 +- tests/unit/states/test_bower.py | 9 --- tests/unit/states/test_chef.py | 9 --- tests/unit/states/test_cloud.py | 9 --- tests/unit/states/test_cmd.py | 8 --- tests/unit/states/test_composer.py | 8 --- tests/unit/states/test_cron.py | 7 -- tests/unit/states/test_cyg.py | 7 -- tests/unit/states/test_ddns.py | 9 --- tests/unit/states/test_debconfmod.py | 9 --- tests/unit/states/test_disk.py | 9 --- tests/unit/states/test_docker.py | 8 --- tests/unit/states/test_drac.py | 9 --- tests/unit/states/test_environ.py | 7 -- tests/unit/states/test_eselect.py | 9 --- tests/unit/states/test_event.py | 8 --- tests/unit/states/test_file.py | 10 +-- tests/unit/states/test_gem.py | 6 -- tests/unit/states/test_glusterfs.py | 9 --- tests/unit/states/test_gnomedesktop.py | 9 --- tests/unit/states/test_grafana.py | 13 +--- tests/unit/states/test_grafana_datasource.py | 4 -- tests/unit/states/test_grains.py | 10 +-- tests/unit/states/test_group.py | 8 --- tests/unit/states/test_hg.py | 8 --- tests/unit/states/test_hipchat.py | 9 --- tests/unit/states/test_host.py | 8 --- tests/unit/states/test_htpasswd.py | 9 --- tests/unit/states/test_http.py | 8 --- tests/unit/states/test_incron.py | 9 --- tests/unit/states/test_influxdb08_database.py | 9 --- tests/unit/states/test_influxdb08_user.py | 9 --- tests/unit/states/test_ini_manage.py | 9 --- tests/unit/states/test_ipmi.py | 9 --- tests/unit/states/test_ipset.py | 4 -- tests/unit/states/test_iptables.py | 8 --- tests/unit/states/test_jboss7.py | 2 - tests/unit/states/test_keyboard.py | 9 --- tests/unit/states/test_keystone.py | 9 --- tests/unit/states/test_kmod.py | 9 --- tests/unit/states/test_layman.py | 9 --- tests/unit/states/test_ldap.py | 9 --- tests/unit/states/test_libcloud_dns.py | 7 -- tests/unit/states/test_libvirt.py | 9 --- tests/unit/states/test_linux_acl.py | 9 --- tests/unit/states/test_locale.py | 8 --- tests/unit/states/test_lvm.py | 9 --- tests/unit/states/test_lvs_server.py | 9 --- tests/unit/states/test_lvs_service.py | 9 --- tests/unit/states/test_lxc.py | 9 --- tests/unit/states/test_mac_assistive.py | 8 --- tests/unit/states/test_mac_defaults.py | 8 --- tests/unit/states/test_mac_keychain.py | 8 --- tests/unit/states/test_mac_package.py | 7 -- tests/unit/states/test_mac_xattr.py | 8 --- tests/unit/states/test_makeconf.py | 9 --- tests/unit/states/test_mdadm.py | 8 --- tests/unit/states/test_memcached.py | 8 --- tests/unit/states/test_modjk.py | 9 --- tests/unit/states/test_modjk_worker.py | 9 --- tests/unit/states/test_module.py | 8 --- tests/unit/states/test_mongodb_database.py | 9 --- tests/unit/states/test_mongodb_user.py | 9 --- tests/unit/states/test_mount.py | 9 --- tests/unit/states/test_mysql_grants.py | 9 --- tests/unit/states/test_mysql_query.py | 9 --- tests/unit/states/test_mysql_user.py | 9 --- tests/unit/states/test_network.py | 8 --- tests/unit/states/test_nftables.py | 8 --- tests/unit/states/test_npm.py | 8 --- tests/unit/states/test_ntp.py | 9 --- tests/unit/states/test_openstack_config.py | 8 --- tests/unit/states/test_openvswitch_port.py | 10 --- tests/unit/states/test_pagerduty.py | 9 --- tests/unit/states/test_pecl.py | 9 --- tests/unit/states/test_pip.py | 9 +-- tests/unit/states/test_pkgng.py | 9 --- tests/unit/states/test_portage_config.py | 9 --- tests/unit/states/test_ports.py | 8 --- tests/unit/states/test_postgres.py | 10 --- tests/unit/states/test_postgres_cluster.py | 9 --- tests/unit/states/test_postgres_database.py | 9 --- tests/unit/states/test_postgres_extension.py | 9 --- tests/unit/states/test_postgres_group.py | 9 --- tests/unit/states/test_postgres_initdb.py | 4 -- tests/unit/states/test_postgres_language.py | 4 -- tests/unit/states/test_postgres_privileges.py | 4 -- tests/unit/states/test_postgres_schema.py | 9 --- tests/unit/states/test_postgres_user.py | 9 --- tests/unit/states/test_powerpath.py | 9 --- tests/unit/states/test_process.py | 9 --- tests/unit/states/test_proxy.py | 8 --- tests/unit/states/test_pyenv.py | 9 --- tests/unit/states/test_pyrax_queues.py | 9 --- tests/unit/states/test_quota.py | 9 --- tests/unit/states/test_rabbitmq_cluster.py | 8 --- tests/unit/states/test_rabbitmq_plugin.py | 9 --- tests/unit/states/test_rabbitmq_policy.py | 9 --- tests/unit/states/test_rabbitmq_vhost.py | 9 --- tests/unit/states/test_rbenv.py | 9 --- tests/unit/states/test_rdp.py | 9 --- tests/unit/states/test_redismod.py | 9 --- tests/unit/states/test_reg.py | 9 --- tests/unit/states/test_rvm.py | 7 -- tests/unit/states/test_saltmod.py | 13 +--- tests/unit/states/test_schedule.py | 9 --- tests/unit/states/test_selinux.py | 9 --- .../unit/states/test_serverdensity_device.py | 9 --- tests/unit/states/test_service.py | 8 --- tests/unit/states/test_slack.py | 9 --- tests/unit/states/test_smtp.py | 9 --- tests/unit/states/test_splunk_search.py | 9 --- tests/unit/states/test_ssh_auth.py | 9 --- tests/unit/states/test_ssh_known_hosts.py | 10 +-- tests/unit/states/test_status.py | 9 --- tests/unit/states/test_supervisord.py | 9 --- tests/unit/states/test_svn.py | 8 --- tests/unit/states/test_sysctl.py | 8 --- tests/unit/states/test_syslog_ng.py | 9 --- tests/unit/states/test_sysrc.py | 8 --- tests/unit/states/test_test.py | 7 -- tests/unit/states/test_timezone.py | 8 --- tests/unit/states/test_tomcat.py | 9 --- tests/unit/states/test_user.py | 8 --- tests/unit/states/test_vbox_guest.py | 8 --- tests/unit/states/test_virtualenv_mod.py | 10 +-- tests/unit/states/test_win_certutil.py | 8 --- tests/unit/states/test_win_dism.py | 8 --- tests/unit/states/test_win_dns_client.py | 8 --- tests/unit/states/test_win_firewall.py | 8 --- tests/unit/states/test_win_license.py | 7 -- tests/unit/states/test_win_network.py | 8 --- tests/unit/states/test_win_path.py | 8 --- tests/unit/states/test_win_pki.py | 8 --- tests/unit/states/test_win_powercfg.py | 8 --- tests/unit/states/test_win_servermanager.py | 8 --- tests/unit/states/test_win_snmp.py | 8 --- tests/unit/states/test_win_system.py | 8 --- tests/unit/states/test_win_update.py | 8 --- tests/unit/states/test_winrepo.py | 10 +-- tests/unit/states/test_xmpp.py | 8 --- tests/unit/states/test_zcbuildout.py | 16 +---- tests/unit/states/test_zk_concurrency.py | 9 --- tests/unit/templates/test_jinja.py | 10 +-- tests/unit/test_auth.py | 10 +-- tests/unit/test_client.py | 9 +-- tests/unit/test_conf.py | 8 --- tests/unit/test_context.py | 2 - tests/unit/test_crypt.py | 8 --- tests/unit/test_daemons.py | 9 +-- tests/unit/test_doc.py | 10 +-- tests/unit/test_files.py | 2 - tests/unit/test_log.py | 9 +-- tests/unit/test_map_conf.py | 8 --- tests/unit/test_minion.py | 8 --- tests/unit/test_payload.py | 9 +-- tests/unit/test_pillar.py | 7 -- tests/unit/test_pydsl.py | 11 +--- tests/unit/test_pyobjects.py | 10 +-- tests/unit/test_simple.py | 7 -- tests/unit/test_spm.py | 10 +-- tests/unit/test_state.py | 10 +-- tests/unit/test_stateconf.py | 10 +-- tests/unit/test_statemod.py | 10 +-- tests/unit/test_template.py | 7 -- tests/unit/test_test_module_names.py | 2 +- tests/unit/test_version.py | 8 --- tests/unit/transport/test_ipc.py | 10 +-- tests/unit/transport/test_tcp.py | 13 +--- tests/unit/utils/test_aggregation.py | 7 -- tests/unit/utils/test_args.py | 8 --- tests/unit/utils/test_boto.py | 7 -- tests/unit/utils/test_cache.py | 7 -- tests/unit/utils/test_cloud.py | 8 +-- tests/unit/utils/test_configcomparer.py | 8 --- tests/unit/utils/test_decorators.py | 8 --- tests/unit/utils/test_dictupdate.py | 8 --- tests/unit/utils/test_disk_cache.py | 7 -- tests/unit/utils/test_etcd_util.py | 8 --- tests/unit/utils/test_event.py | 2 +- tests/unit/utils/test_extend.py | 9 +-- tests/unit/utils/test_filebuffer.py | 7 -- tests/unit/utils/test_find.py | 12 +--- tests/unit/utils/test_format_call.py | 7 -- tests/unit/utils/test_gitfs.py | 7 -- tests/unit/utils/test_http.py | 8 --- tests/unit/utils/test_immutabletypes.py | 7 -- tests/unit/utils/test_kwarg_regex.py | 8 --- tests/unit/utils/test_locales.py | 7 -- tests/unit/utils/test_mac_utils.py | 8 --- tests/unit/utils/test_minions.py | 8 --- tests/unit/utils/test_network.py | 7 -- tests/unit/utils/test_parsers.py | 21 +----- tests/unit/utils/test_path_join.py | 7 -- tests/unit/utils/test_process.py | 10 --- tests/unit/utils/test_rsax931.py | 8 --- .../utils/test_runtime_whitespace_regex.py | 7 -- tests/unit/utils/test_safe_walk.py | 9 +-- tests/unit/utils/test_sanitizers.py | 8 --- tests/unit/utils/test_schedule.py | 11 +--- tests/unit/utils/test_schema.py | 9 --- tests/unit/utils/test_systemd.py | 5 -- tests/unit/utils/test_url.py | 8 --- tests/unit/utils/test_utils.py | 7 -- tests/unit/utils/test_validate_net.py | 8 --- tests/unit/utils/test_verify.py | 9 +-- tests/unit/utils/test_vt.py | 7 -- tests/unit/utils/test_warnings.py | 7 -- tests/unit/utils/test_which.py | 9 +-- tests/unit/utils/test_yamlloader.py | 9 --- tests/unit/utils/vmware_test/test_cluster.py | 7 -- tests/unit/utils/vmware_test/test_common.py | 10 --- .../unit/utils/vmware_test/test_connection.py | 9 --- .../unit/utils/vmware_test/test_datacenter.py | 5 -- tests/unit/utils/vmware_test/test_host.py | 5 -- 696 files changed, 413 insertions(+), 5580 deletions(-) diff --git a/doc/man/salt.7 b/doc/man/salt.7 index 8db58781c4..4413384493 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -292066,7 +292066,7 @@ the test method: .nf .ft C import integration -from salttesting.helpers import destructiveTest +from tests.support.helpers import destructiveTest class PkgTest(integration.ModuleCase): @destructiveTest @@ -292162,7 +292162,7 @@ can be used .nf .ft C # Import logging handler -from salttesting.helpers import TestsLoggingHandler +from tests.support.helpers import TestsLoggingHandler # .. inside test with TestsLoggingHandler() as handler: diff --git a/doc/topics/development/tests/index.rst b/doc/topics/development/tests/index.rst index 0d06472fc5..f5eebb2413 100644 --- a/doc/topics/development/tests/index.rst +++ b/doc/topics/development/tests/index.rst @@ -429,7 +429,7 @@ Test Helpers ------------ Several Salt-specific helpers are available. A full list is available by inspecting -functions exported in `salttesting.helpers`. +functions exported in `tests.support.helpers`. `@expensiveTest` -- Designates a test which typically requires a relatively costly external resource, like a cloud virtual machine. This decorator is not normally @@ -453,10 +453,10 @@ the test will be skipped if the binaries are not all present on the system. `@skip_if_not_root` -- If the test is not executed as root, it will be skipped. `@with_system_user` -- Creates and optionally destroys a system user within a test case. -See implementation details in `salttesting.helpers` for details. +See implementation details in `tests.support.helpers` for details. `@with_system_group` -- Creates and optionally destroys a system group within a test case. -See implementation details in `salttesting.helpers` for details. +See implementation details in `tests.support.helpers` for details. `@with_system_user_and_group` -- Creates and optionally destroys a system user and group -within a test case. See implementation details in `salttesting.helpers` for details. +within a test case. See implementation details in `tests.support.helpers` for details. diff --git a/doc/topics/development/tests/integration.rst b/doc/topics/development/tests/integration.rst index 57c10e31f0..100a17afbc 100644 --- a/doc/topics/development/tests/integration.rst +++ b/doc/topics/development/tests/integration.rst @@ -272,7 +272,7 @@ Now the workhorse method ``run_function`` can be used to test a module: .. code-block:: python import os - import integration + import tests.integration as integration class TestModuleTest(integration.ModuleCase): @@ -312,7 +312,7 @@ Validating the shell commands can be done via shell tests: import shutil import tempfile - import integration + import tests.integration as integration class KeyTest(integration.ShellCase): ''' @@ -345,7 +345,7 @@ Testing salt-ssh functionality can be done using the SSHCase test class: .. code-block:: python - import integration + import tests.integration as integration class SSHGrainsTest(integration.SSHCase): ''' @@ -370,7 +370,7 @@ on a minion event bus. .. code-block:: python - import integration + import tests.integration as integration class TestEvent(integration.SaltEventAssertsMixin): ''' @@ -392,7 +392,7 @@ Testing Salt's Syndic can be done via the SyndicCase test class: .. code-block:: python - import integration + import tests.integration as integration class TestSyndic(integration.SyndicCase): ''' @@ -438,11 +438,9 @@ to test states: import shutil # Import Salt Testing libs - from salttesting.helpers import ensure_in_syspath - ensure_in_syspath('../../') + import tests.integration as integration # Import salt libs - import integration import salt.utils HFILE = os.path.join(integration.TMP, 'hosts') @@ -506,8 +504,8 @@ the test method: .. code-block:: python - import integration - from salttesting.helpers import destructiveTest + import tests.integration as integration + from tests.support.helpers import destructiveTest class DestructiveExampleModuleTest(integration.ModuleCase): ''' @@ -628,7 +626,7 @@ the test function: .. code-block:: python - from salttesting.helpers import expensiveTest + from tests.support.helpers import expensiveTest @expensiveTest def test_instance(self): diff --git a/doc/topics/development/tests/unit.rst b/doc/topics/development/tests/unit.rst index cc91d51fca..8dd2f97441 100644 --- a/doc/topics/development/tests/unit.rst +++ b/doc/topics/development/tests/unit.rst @@ -122,14 +122,13 @@ Most commonly, the following imports are necessary to create a unit test: .. code-block:: python # Import Salt Testing libs - from salttesting import skipIf, TestCase - from salttesting.helpers import ensure_in_syspath + from tests.support.unit import skipIf, TestCase If you need mock support to your tests, please also import: .. code-block:: python - from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call + from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call Evaluating Truth @@ -183,13 +182,13 @@ additional imports for MagicMock: .. code-block:: python # Import Salt Testing libs - from salttesting import TestCase + from tests.support.unit import TestCase # Import Salt execution module to test from salt.modules import db # Import Mock libraries - from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call + from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call # Create test case class and inherit from Salt's customized TestCase # Skip this test case if we don't have access to mock! @@ -259,7 +258,7 @@ we might write the skeleton for testing ``fib.py``: .. code-block:: python # Import Salt Testing libs - from salttesting import TestCase + from tests.support.unit import TestCase # Import Salt execution module to test from salt.modules import fib @@ -339,17 +338,14 @@ will also redefine the ``__salt__`` dictionary such that it only contains from salt.modules import linux_sysctl # Import Salt Testing Libs - from salttesting import skipIf, TestCase - from salttesting.helpers import ensure_in_syspath - from salttesting.mock import ( + from tests.support.unit import skipIf, TestCase + from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) - ensure_in_syspath('../../') - # Globals linux_sysctl.__salt__ = {} @@ -368,11 +364,6 @@ will also redefine the ``__salt__`` dictionary such that it only contains with patch.dict(linux_sysctl.__salt__, {'cmd.run': mock_cmd}): self.assertEqual(linux_sysctl.get('net.ipv4.ip_forward'), 1) - - if __name__ == '__main__': - from integration import run_tests - run_tests(LinuxSysctlTestCase, needs_daemon=False) - Since ``get()`` has only one raise or return statement and that statement is a success condition, the test function is simply named ``test_get()``. As described, the single function call parameter, ``name`` is mocked with @@ -450,17 +441,14 @@ with. from salt.exceptions import CommandExecutionError # Import Salt Testing Libs - from salttesting import skipIf, TestCase - from salttesting.helpers import ensure_in_syspath - from salttesting.mock import ( + from tests.support.unit import skipIf, TestCase + from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) - ensure_in_syspath('../../') - # Globals linux_sysctl.__salt__ = {} @@ -510,7 +498,3 @@ with. with patch.dict(linux_sysctl.__salt__, {'cmd.run_all': mock_cmd}): self.assertEqual(linux_sysctl.assign( 'net.ipv4.ip_forward', 1), ret) - - if __name__ == '__main__': - from integration import run_tests - run_tests(LinuxSysctlTestCase, needs_daemon=False) diff --git a/doc/topics/tutorials/writing_tests.rst b/doc/topics/tutorials/writing_tests.rst index 9dc4cda486..24436dc981 100644 --- a/doc/topics/tutorials/writing_tests.rst +++ b/doc/topics/tutorials/writing_tests.rst @@ -379,7 +379,7 @@ the test method: .. code-block:: python import integration - from salttesting.helpers import destructiveTest + from tests.support.helpers import destructiveTest class PkgTest(integration.ModuleCase): @destructiveTest @@ -462,7 +462,7 @@ can be used .. code-block:: python # Import logging handler - from salttesting.helpers import TestsLoggingHandler + from tests.support.helpers import TestsLoggingHandler # .. inside test with TestsLoggingHandler() as handler: diff --git a/templates/test_module/tests/unit/modules/test_{{module_name}}.py b/templates/test_module/tests/unit/modules/test_{{module_name}}.py index 7cc2f4f073..b560aef36a 100644 --- a/templates/test_module/tests/unit/modules/test_{{module_name}}.py +++ b/templates/test_module/tests/unit/modules/test_{{module_name}}.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf +from tests.support.unit import skipIf from tests.unit import ModuleTestCase, hasDependency -from salttesting.mock import ( +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON diff --git a/templates/test_state/tests/unit/states/test_{{module_name}}.py b/templates/test_state/tests/unit/states/test_{{module_name}}.py index 8aba4e8440..219e5865a6 100644 --- a/templates/test_state/tests/unit/states/test_{{module_name}}.py +++ b/templates/test_state/tests/unit/states/test_{{module_name}}.py @@ -7,9 +7,9 @@ from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf +from tests.support.unit import skipIf from tests.unit import ModuleTestCase, hasDependency -from salttesting.mock import ( +from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON diff --git a/tests/conftest.py b/tests/conftest.py index aafd95f61c..a95e945476 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -542,7 +542,8 @@ def session_pillar_tree_root_dir(session_integration_files_dir): @pytest.fixture(scope='session') def test_daemon(request): from collections import namedtuple - from integration import TestDaemon, PNUM + from tests.integration import TestDaemon + from tests.support.parser import PNUM values = (('transport', request.config.getoption('--transport')), ('sysinfo', request.config.getoption('--sysinfo')), ('no_colors', request.config.getoption('--no-colors')), diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 40f04998f8..9586115f89 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -51,8 +51,7 @@ from tests.support.unit import TestCase from tests.support.case import ShellTestCase from tests.support.mixins import CheckShellBinaryNameAndVersionMixin, ShellCaseCommonTestsMixin from tests.support.parser import PNUM, print_header, SaltTestcaseParser -from tests.support.helpers import requires_sshd_server -from tests.support.helpers import ensure_in_syspath, RedirectStdStreams +from tests.support.helpers import requires_sshd_server, RedirectStdStreams # Import Salt libs import salt @@ -167,67 +166,6 @@ atexit.register(close_open_sockets, _RUNTESTS_PORTS) SALT_LOG_PORT = get_unused_localhost_port() -def run_tests(*test_cases, **kwargs): - ''' - Run integration tests for the chosen test cases. - - Function uses optparse to set up test environment - ''' - - needs_daemon = kwargs.pop('needs_daemon', True) - if kwargs: - raise RuntimeError( - 'The \'run_tests\' function only accepts \'needs_daemon\' as a ' - 'keyword argument' - ) - - class TestcaseParser(SaltTestcaseParser): - def setup_additional_options(self): - self.add_option( - '--sysinfo', - default=False, - action='store_true', - help='Print some system information.' - ) - self.output_options_group.add_option( - '--no-colors', - '--no-colours', - default=False, - action='store_true', - help='Disable colour printing.' - ) - if needs_daemon: - self.add_option( - '--transport', - default='zeromq', - choices=('zeromq', 'raet', 'tcp'), - help=('Select which transport to run the integration tests with, ' - 'zeromq, raet, or tcp. Default: %default') - ) - - def validate_options(self): - SaltTestcaseParser.validate_options(self) - # Transplant configuration - transport = None - if needs_daemon: - transport = self.options.transport - TestDaemon.transplant_configs(transport=transport) - - def run_testcase(self, testcase, needs_daemon=True): # pylint: disable=W0221 - if needs_daemon: - print(' * Setting up Salt daemons to execute tests') - with TestDaemon(self): - return SaltTestcaseParser.run_testcase(self, testcase) - return SaltTestcaseParser.run_testcase(self, testcase) - - parser = TestcaseParser() - parser.parse_args() - for case in test_cases: - if parser.run_testcase(case, needs_daemon=needs_daemon) is False: - parser.finalize(1) - parser.finalize(0) - - class ThreadingMixIn(socketserver.ThreadingMixIn): daemon_threads = True diff --git a/tests/integration/cli/test_batch.py b/tests/integration/cli/test_batch.py index 263aae64c0..2b5f6a44e7 100644 --- a/tests/integration/cli/test_batch.py +++ b/tests/integration/cli/test_batch.py @@ -6,12 +6,7 @@ from __future__ import absolute_import # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - -# Import Salt Libs -import integration +import tests.integration as integration class BatchTest(integration.ShellCase): @@ -60,7 +55,3 @@ class BatchTest(integration.ShellCase): ''' cmd = self.run_salt(' "*" state.single test.fail_without_changes name=test_me -b 25%', with_retcode=True) self.assertEqual(cmd[-1], 2) - -if __name__ == '__main__': - from integration import run_tests - run_tests(BatchTest) diff --git a/tests/integration/cli/test_custom_module.py b/tests/integration/cli/test_custom_module.py index 70a08696ca..0054c497d3 100644 --- a/tests/integration/cli/test_custom_module.py +++ b/tests/integration/cli/test_custom_module.py @@ -38,7 +38,7 @@ from __future__ import absolute_import # Import Salt Libs -import integration +import tests.integration as integration class SSHCustomModuleTest(integration.SSHCase): @@ -78,8 +78,3 @@ class SSHCustomModuleTest(integration.SSHCase): raise AssertionError(cmd[key]['comment']) cmd_ret = cmd[key]['changes'].get('ret', None) self.assertEqual(cmd_ret, expected[key]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SSHCustomModuleTest) diff --git a/tests/integration/cli/test_grains.py b/tests/integration/cli/test_grains.py index 85f8d60a82..b1c675af08 100644 --- a/tests/integration/cli/test_grains.py +++ b/tests/integration/cli/test_grains.py @@ -17,13 +17,10 @@ from __future__ import absolute_import import os # Import Salt Libs -import integration import salt.utils # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') +import tests.integration as integration class GrainsTargetingTest(integration.ShellCase): @@ -90,8 +87,3 @@ class SSHGrainsTest(integration.SSHCase): ''' cmd = self.run_function('grains.get', ['id']) self.assertEqual(cmd, 'localhost') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SSHGrainsTest) diff --git a/tests/integration/client/test_kwarg.py b/tests/integration/client/test_kwarg.py index de90740f2f..9a957f6502 100644 --- a/tests/integration/client/test_kwarg.py +++ b/tests/integration/client/test_kwarg.py @@ -4,11 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class StdTest(integration.ModuleCase): @@ -93,8 +89,3 @@ class StdTest(integration.ModuleCase): self.assertIn('int', data['args'][1]) self.assertIn('dict', data['kwargs']['outer']) self.assertIn('str', data['kwargs']['inner']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StdTest) diff --git a/tests/integration/client/test_runner.py b/tests/integration/client/test_runner.py index 81da86c903..3f26cbf122 100644 --- a/tests/integration/client/test_runner.py +++ b/tests/integration/client/test_runner.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -import integration +import tests.integration as integration from tests.support.unit import skipIf # Import Salt libs @@ -100,8 +100,3 @@ class RunnerModuleTest(integration.TestCase, integration.AdaptedConfigurationTes 'bar': 'Bar!', } self.runner.cmd_sync(low) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RunnerModuleTest, needs_daemon=True) diff --git a/tests/integration/client/test_standard.py b/tests/integration/client/test_standard.py index 2a7c39f2df..3ea384a094 100644 --- a/tests/integration/client/test_standard.py +++ b/tests/integration/client/test_standard.py @@ -5,11 +5,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils @@ -149,8 +147,3 @@ class StdTest(integration.ModuleCase): finally: os.unlink(key_file) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StdTest) diff --git a/tests/integration/client/test_syndic.py b/tests/integration/client/test_syndic.py index 99ccd52664..3f968d4124 100644 --- a/tests/integration/client/test_syndic.py +++ b/tests/integration/client/test_syndic.py @@ -4,11 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class TestSyndic(integration.SyndicCase): @@ -32,8 +28,3 @@ class TestSyndic(integration.SyndicCase): )[0], 6765 ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestSyndic) diff --git a/tests/integration/cloud/helpers/virtualbox.py b/tests/integration/cloud/helpers/virtualbox.py index 6e64ea18ed..45017cd61a 100644 --- a/tests/integration/cloud/helpers/virtualbox.py +++ b/tests/integration/cloud/helpers/virtualbox.py @@ -12,7 +12,7 @@ from tests.support.unit import skipIf # Import Salt libs import salt.ext.six as six -import integration +import tests.integration as integration import salt.utils.virtualbox # Create the cloud instance name to be used throughout the tests diff --git a/tests/integration/cloud/providers/test_digital_ocean.py b/tests/integration/cloud/providers/test_digital_ocean.py index 702260972a..dafdef6c61 100644 --- a/tests/integration/cloud/providers/test_digital_ocean.py +++ b/tests/integration/cloud/providers/test_digital_ocean.py @@ -10,12 +10,10 @@ import random import string # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +import tests.integration as integration +from tests.support.helpers import expensiveTest # Import Salt Libs -import integration from salt.config import cloud_providers_config # Import 3rd-party libs @@ -177,8 +175,3 @@ class DigitalOceanTest(integration.ShellCase): # To run this for each test when not all tests create instances. if INSTANCE_NAME in [i.strip() for i in self.run_cloud('--query')]: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DigitalOceanTest) diff --git a/tests/integration/cloud/providers/test_ec2.py b/tests/integration/cloud/providers/test_ec2.py index f63510e2a9..f0e384d7ad 100644 --- a/tests/integration/cloud/providers/test_ec2.py +++ b/tests/integration/cloud/providers/test_ec2.py @@ -10,13 +10,11 @@ import random import string # Import Salt Libs -import integration from salt.config import cloud_providers_config # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +import tests.integration as integration +from tests.support.helpers import expensiveTest # Import Third-Party Libs from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin @@ -127,8 +125,3 @@ class EC2Test(integration.ShellCase): # if test instance is still present, delete it if ret_str in query: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EC2Test) diff --git a/tests/integration/cloud/providers/test_gce.py b/tests/integration/cloud/providers/test_gce.py index 9f64f86dcb..09e6b6b44d 100644 --- a/tests/integration/cloud/providers/test_gce.py +++ b/tests/integration/cloud/providers/test_gce.py @@ -11,13 +11,11 @@ import random import string # Import Salt Libs -import integration from salt.config import cloud_providers_config # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +import tests.integration as integration +from tests.support.helpers import expensiveTest # Import Third-Party Libs from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin @@ -157,8 +155,3 @@ class GCETest(integration.ShellCase): # if test instance is still present, delete it if ret_str in query: self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GCETest) diff --git a/tests/integration/cloud/providers/test_gogrid.py b/tests/integration/cloud/providers/test_gogrid.py index b54b79bfa2..22f2c84bfa 100644 --- a/tests/integration/cloud/providers/test_gogrid.py +++ b/tests/integration/cloud/providers/test_gogrid.py @@ -10,13 +10,11 @@ import random import string # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath, expensiveTest +import tests.integration as integration +from tests.support.helpers import expensiveTest from tests.support.unit import skipIf -ensure_in_syspath('../../../') - # Import Salt Libs -import integration from salt.config import cloud_providers_config from salt.ext.six.moves import range @@ -111,8 +109,3 @@ class GoGridTest(integration.ShellCase): # if test instance is still present, delete it if ret_str in query: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GoGridTest) diff --git a/tests/integration/cloud/providers/test_joyent.py b/tests/integration/cloud/providers/test_joyent.py index 6b894380e4..88364f7525 100644 --- a/tests/integration/cloud/providers/test_joyent.py +++ b/tests/integration/cloud/providers/test_joyent.py @@ -10,12 +10,10 @@ import random import string # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +import tests.integration as integration +from tests.support.helpers import expensiveTest # Import Salt Libs -import integration from salt.config import cloud_providers_config from salt.ext.six.moves import range # pylint: disable=redefined-builtin @@ -111,8 +109,3 @@ class JoyentTest(integration.ShellCase): # if test instance is still present, delete it if ret_str in query: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(JoyentTest) diff --git a/tests/integration/cloud/providers/test_linode.py b/tests/integration/cloud/providers/test_linode.py index cb06d9c853..d944bcac57 100644 --- a/tests/integration/cloud/providers/test_linode.py +++ b/tests/integration/cloud/providers/test_linode.py @@ -10,12 +10,10 @@ import random import string # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +import tests.integration as integration +from tests.support.helpers import expensiveTest # Import Salt Libs -import integration from salt.config import cloud_providers_config from salt.ext.six.moves import range @@ -109,8 +107,3 @@ class LinodeTest(integration.ShellCase): # if test instance is still present, delete it if ret_str in query: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(LinodeTest) diff --git a/tests/integration/cloud/providers/test_msazure.py b/tests/integration/cloud/providers/test_msazure.py index 8c0e987ea0..95ec2ff90b 100644 --- a/tests/integration/cloud/providers/test_msazure.py +++ b/tests/integration/cloud/providers/test_msazure.py @@ -11,13 +11,11 @@ import string from distutils.version import LooseVersion # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +from tests.support.helpers import expensiveTest # Import Salt Libs -import integration from salt.config import cloud_providers_config # Import Third-Party Libs @@ -177,8 +175,3 @@ class AzureTest(integration.ShellCase): if ret_str in query: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(AzureTest) diff --git a/tests/integration/cloud/providers/test_openstack.py b/tests/integration/cloud/providers/test_openstack.py index 5cc1ae95b6..da2686fe99 100644 --- a/tests/integration/cloud/providers/test_openstack.py +++ b/tests/integration/cloud/providers/test_openstack.py @@ -8,15 +8,10 @@ from __future__ import absolute_import import logging # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest -# Import salt libs -import integration log = logging.getLogger(__name__) NO_KEYSTONE = False @@ -161,8 +156,3 @@ class OpenstackTest(integration.ModuleCase, tenant_name='admin') driver.authenticate() self.assertTrue(driver.auth_token) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(OpenstackTest) diff --git a/tests/integration/cloud/providers/test_profitbricks.py b/tests/integration/cloud/providers/test_profitbricks.py index 63f2dfa817..fc04933aeb 100644 --- a/tests/integration/cloud/providers/test_profitbricks.py +++ b/tests/integration/cloud/providers/test_profitbricks.py @@ -10,13 +10,11 @@ import random import string # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +from tests.support.helpers import expensiveTest # Import Salt Libs -import integration from salt.config import cloud_providers_config from salt.ext.six.moves import range @@ -134,8 +132,3 @@ class ProfitBricksTest(integration.ShellCase): # if test instance is still present, delete it if ret in query: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(ProfitBricksTest) diff --git a/tests/integration/cloud/providers/test_rackspace.py b/tests/integration/cloud/providers/test_rackspace.py index 4936ddd19d..4baefab25c 100644 --- a/tests/integration/cloud/providers/test_rackspace.py +++ b/tests/integration/cloud/providers/test_rackspace.py @@ -10,13 +10,11 @@ import random import string # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +from tests.support.helpers import expensiveTest # Import Salt Libs -import integration from salt.config import cloud_providers_config from salt.ext.six.moves import range @@ -119,8 +117,3 @@ class RackspaceTest(integration.ShellCase): # if test instance is still present, delete it if ret in query: self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(RackspaceTest) diff --git a/tests/integration/cloud/providers/test_virtualbox.py b/tests/integration/cloud/providers/test_virtualbox.py index 50f32eaca4..6b87053101 100644 --- a/tests/integration/cloud/providers/test_virtualbox.py +++ b/tests/integration/cloud/providers/test_virtualbox.py @@ -10,32 +10,37 @@ import logging import socket # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath - -from integration.cloud.helpers.virtualbox import VirtualboxTestCase, VirtualboxCloudTestCase, CONFIG_NAME, \ - PROVIDER_NAME, \ - PROFILE_NAME, BASE_BOX_NAME, INSTANCE_NAME, BOOTABLE_BASE_BOX_NAME, DEPLOY_PROFILE_NAME - -ensure_in_syspath('../../../') +from tests.integration.cloud.helpers.virtualbox import (VirtualboxTestCase, + VirtualboxCloudTestCase, + CONFIG_NAME, + PROVIDER_NAME, + PROFILE_NAME, + BASE_BOX_NAME, + INSTANCE_NAME, + BOOTABLE_BASE_BOX_NAME, + DEPLOY_PROFILE_NAME) # Import Salt Libs import salt.ext.six as six from salt.ext.six.moves import range -import integration from salt.config import cloud_providers_config, vm_profiles_config -from salt.utils.virtualbox import vb_xpcom_to_attribute_dict, vb_clone_vm, vb_destroy_machine, vb_create_machine, \ - vb_get_box, vb_machine_exists, XPCOM_ATTRIBUTES, vb_start_vm, vb_stop_vm, \ - vb_get_network_addresses, vb_wait_for_network_address, machine_get_machinestate_str, HAS_LIBS +from salt.utils.virtualbox import (vb_xpcom_to_attribute_dict, + vb_clone_vm, + vb_destroy_machine, + vb_create_machine, + vb_get_box, + vb_machine_exists, + XPCOM_ATTRIBUTES, + vb_start_vm, + vb_stop_vm, + vb_get_network_addresses, + vb_wait_for_network_address, + machine_get_machinestate_str, + HAS_LIBS) -# Setup logging -log = logging.getLogger() log = logging.getLogger(__name__) -# log_handler = logging.StreamHandler() -# log_handler.setLevel(logging.INFO) -# log.addHandler(log_handler) -# log.setLevel(logging.INFO) -info = log.info # As described in the documentation of list_nodes (this may change with time) MINIMAL_MACHINE_ATTRIBUTES = [ @@ -300,7 +305,7 @@ class VirtualboxProviderHeavyTests(VirtualboxCloudTestCase): def test_start_stop_action(self): res = self.run_cloud_action("start", BOOTABLE_BASE_BOX_NAME, timeout=10) - info(res) + log.info(res) machine = res.get(BOOTABLE_BASE_BOX_NAME) self.assertIsNotNone(machine) @@ -309,7 +314,7 @@ class VirtualboxProviderHeavyTests(VirtualboxCloudTestCase): self.assertEqual(state, expected_state) res = self.run_cloud_action("stop", BOOTABLE_BASE_BOX_NAME, timeout=10) - info(res) + log.info(res) machine = res.get(BOOTABLE_BASE_BOX_NAME) self.assertIsNotNone(machine) @@ -425,7 +430,7 @@ class XpcomConversionTests(unittest.TestCase): self.assertIsNotNone(expected_attributes, "%s is unknown") - for key in ret.keys(): + for key in ret: self.assertIn(key, expected_attributes) def test_override_attributes(self): @@ -460,7 +465,7 @@ class XpcomConversionTests(unittest.TestCase): self.assertDictEqual(ret, expected_machine) ret_keys = ret.keys() - for key in expected_extras.keys(): + for key in expected_extras: self.assertIn(key, ret_keys) def test_extra_nonexistant_attributes(self): @@ -481,10 +486,3 @@ class XpcomConversionTests(unittest.TestCase): ret = vb_xpcom_to_attribute_dict(xpcom, extra_attributes=expected_extras) self.assertDictEqual(ret, expected_extra_dict) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - - run_tests(VirtualboxProviderTest) - # unittest.main() diff --git a/tests/integration/cloud/providers/test_vultr.py b/tests/integration/cloud/providers/test_vultr.py index 1401269fed..945f199635 100644 --- a/tests/integration/cloud/providers/test_vultr.py +++ b/tests/integration/cloud/providers/test_vultr.py @@ -11,12 +11,10 @@ import string import time # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath, expensiveTest - -ensure_in_syspath('../../../') +import tests.integration as integration +from tests.support.helpers import expensiveTest # Import Salt Libs -import integration from salt.config import cloud_providers_config # Import 3rd-party libs @@ -188,8 +186,3 @@ class VultrTest(integration.ShellCase): self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500) time.sleep(30) ct = ct + 1 - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VultrTest) diff --git a/tests/integration/fileserver/test_fileclient.py b/tests/integration/fileserver/test_fileclient.py index fb1382448a..1d96f7d26c 100644 --- a/tests/integration/fileserver/test_fileclient.py +++ b/tests/integration/fileserver/test_fileclient.py @@ -12,16 +12,15 @@ import shutil log = logging.getLogger(__name__) # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import destructiveTest from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../..') # Import salt libs -import integration import salt.utils from salt import fileclient -from salt.ext import six +import salt.ext.six as six SALTENVS = ('base', 'dev') FS_ROOT = os.path.join(integration.TMP, 'fileclient_fs_root') @@ -351,8 +350,3 @@ class FileclientCacheTest(integration.ModuleCase): log.debug('cache_loc = %s', cache_loc) log.debug('content = %s', content) self.assertTrue(saltenv in content) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(FileClientTest) diff --git a/tests/integration/fileserver/test_gitfs.py b/tests/integration/fileserver/test_gitfs.py index 36d969051d..ff6cd04fef 100644 --- a/tests/integration/fileserver/test_gitfs.py +++ b/tests/integration/fileserver/test_gitfs.py @@ -10,14 +10,11 @@ import pwd import shutil # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../..') - # Import salt libs -import integration from salt.fileserver import gitfs gitfs.__opts__ = {'cachedir': '/tmp/gitfs_test_cache', @@ -133,6 +130,3 @@ class GitFSTest(integration.ModuleCase): '__role': self.master_opts['__role']}): ret = gitfs.envs() self.assertIn('base', ret) - -if __name__ == '__main__': - integration.run_tests(GitFSTest) diff --git a/tests/integration/fileserver/test_roots.py b/tests/integration/fileserver/test_roots.py index c22f73840d..92c549a015 100644 --- a/tests/integration/fileserver/test_roots.py +++ b/tests/integration/fileserver/test_roots.py @@ -8,13 +8,11 @@ from __future__ import absolute_import import os # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../..') # Import salt libs -import integration from salt.fileserver import roots from salt import fileclient import salt.utils @@ -211,8 +209,3 @@ class RootsLimitTraversalTest(integration.ModuleCase): self.assertIn('test_deep.test', ret) self.assertIn('test_deep.a.test', ret) self.assertNotIn('test_deep.b.2.test', ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RootsTest, RootsLimitTraversalTest) diff --git a/tests/integration/grains/test_core.py b/tests/integration/grains/test_core.py index 5978eac24c..3d1b372be1 100644 --- a/tests/integration/grains/test_core.py +++ b/tests/integration/grains/test_core.py @@ -7,13 +7,10 @@ Test the core grains from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils if salt.utils.is_windows(): try: diff --git a/tests/integration/loader/test_ext_grains.py b/tests/integration/loader/test_ext_grains.py index 043658731b..54b680b932 100644 --- a/tests/integration/loader/test_ext_grains.py +++ b/tests/integration/loader/test_ext_grains.py @@ -13,7 +13,7 @@ from __future__ import absolute_import from tests.support.unit import skipIf # Import salt libs -import integration +import tests.integration as integration from salt.config import minion_config from salt.loader import grains diff --git a/tests/integration/loader/test_ext_modules.py b/tests/integration/loader/test_ext_modules.py index 5caa1d04ef..2f2854f2ad 100644 --- a/tests/integration/loader/test_ext_modules.py +++ b/tests/integration/loader/test_ext_modules.py @@ -13,11 +13,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../') - -# Import salt libs -import integration +import tests.integration as integration class LoaderOverridesTest(integration.ModuleCase): @@ -40,8 +36,3 @@ class LoaderOverridesTest(integration.ModuleCase): self.run_function('test.echo', arg=[text])[::-1], self.run_function('test.recho', arg=[text]), ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LoaderOverridesTest) diff --git a/tests/integration/loader/test_globals.py b/tests/integration/loader/test_globals.py index 1a2079bc44..a33c082f66 100644 --- a/tests/integration/loader/test_globals.py +++ b/tests/integration/loader/test_globals.py @@ -10,12 +10,9 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.loader import inspect import yaml @@ -142,8 +139,3 @@ class LoaderGlobalsTest(integration.ModuleCase): - __context__ # Context dict shared amongst all modules of the same type ''' self._verify_globals(salt.loader.render(self.master_opts, {})) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LoaderGlobalsTest, needs_daemon=False) diff --git a/tests/integration/loader/test_interfaces.py b/tests/integration/loader/test_interfaces.py index 0ca1a0ba0c..ff0576f8c7 100644 --- a/tests/integration/loader/test_interfaces.py +++ b/tests/integration/loader/test_interfaces.py @@ -11,14 +11,10 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.ext.six as six from salt.config import minion_config - import salt.loader # TODO: the rest of the public interfaces @@ -38,7 +34,3 @@ class RawModTest(TestCase): self.opts = minion_config(None) testmod = salt.loader.raw_mod(self.opts, 'module_we_do_not_have', None) self.assertEqual(testmod, {}) - -if __name__ == '__main__': - from integration import run_tests - run_tests(RawModTest) diff --git a/tests/integration/loader/test_loader.py b/tests/integration/loader/test_loader.py index 77f3168fa4..7f68eca772 100644 --- a/tests/integration/loader/test_loader.py +++ b/tests/integration/loader/test_loader.py @@ -19,11 +19,7 @@ log = logging.getLogger(__name__) # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - -import integration # pylint: disable=import-error +import tests.integration as integration # Import Salt libs import salt.utils diff --git a/tests/integration/minion/test_blackout.py b/tests/integration/minion/test_blackout.py index ae173b55ce..5962a52ad9 100644 --- a/tests/integration/minion/test_blackout.py +++ b/tests/integration/minion/test_blackout.py @@ -10,12 +10,10 @@ from time import sleep import textwrap # Import Salt Testing libs -from tests.support.helpers import destructiveTest, ensure_in_syspath - -ensure_in_syspath('../') +import tests.integration as integration +from tests.support.helpers import destructiveTest # Import Salt libs -import integration import salt.utils @@ -101,8 +99,3 @@ class MinionBlackoutTestCase(integration.ModuleCase): self.assertIn('Minion in blackout mode.', cloud_ret) finally: self.end_blackout() - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MinionBlackoutTestCase, needs_daemon=True) diff --git a/tests/integration/minion/test_pillar.py b/tests/integration/minion/test_pillar.py index fb8187fc64..0c93e23e00 100644 --- a/tests/integration/minion/test_pillar.py +++ b/tests/integration/minion/test_pillar.py @@ -2,16 +2,9 @@ ''' :codeauthor: :email:`Erik Johnson ` ''' -from __future__ import absolute_import - -# Import Salt Testing libs -from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, requires_system_grains -from tests.support.mock import NO_MOCK, NO_MOCK_REASON - -ensure_in_syspath('../..') # Import Python libs +from __future__ import absolute_import import copy import errno import logging @@ -21,18 +14,21 @@ import textwrap import yaml from subprocess import Popen, PIPE, STDOUT -log = logging.getLogger(__name__) +# Import Salt Testing libs +import tests.integration as integration +from tests.support.unit import skipIf +from tests.support.helpers import requires_system_grains +from tests.support.mock import NO_MOCK, NO_MOCK_REASON # Import 3rd-party libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('..') import salt.ext.six as six # Import salt libs -import integration import salt.utils from salt import pillar +log = logging.getLogger(__name__) + GPG_HOMEDIR = os.path.join(integration.TMP_CONF_DIR, 'gpgkeys') PILLAR_BASE = os.path.join(integration.TMP, 'test-decrypt-pillar', 'pillar') @@ -373,7 +369,3 @@ class DecryptGPGPillarTest(integration.ModuleCase): 'not a valid decryption renderer. Valid choices are: foo, bar' ] self.assertEqual(ret, expected) - - -if __name__ == '__main__': - integration.run_tests(DecryptGPGPillarTest) diff --git a/tests/integration/minion/test_timeout.py b/tests/integration/minion/test_timeout.py index c0f7145bfe..e0223bf2e7 100644 --- a/tests/integration/minion/test_timeout.py +++ b/tests/integration/minion/test_timeout.py @@ -7,10 +7,7 @@ Tests for various minion timeouts from __future__ import absolute_import # Import Salt Testing libs -import integration -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') +import tests.integration as integration class MinionTimeoutTestCase(integration.ShellCase): @@ -29,8 +26,3 @@ class MinionTimeoutTestCase(integration.ShellCase): ' may have returned error: {0}'.format(ret)) self.assertTrue('True' in ret[1], 'Minion did not return True after ' '{0} seconds.'.format(sleep_length)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MinionTimeoutTestCase, needs_daemon=True) diff --git a/tests/integration/modules/test_aliases.py b/tests/integration/modules/test_aliases.py index a24b1621da..0b03196900 100644 --- a/tests/integration/modules/test_aliases.py +++ b/tests/integration/modules/test_aliases.py @@ -4,11 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class AliasesTest(integration.ModuleCase): @@ -74,8 +70,3 @@ class AliasesTest(integration.ModuleCase): 'aliases.list_aliases') self.assertIsInstance(tgt_ret, dict) self.assertNotIn('alias=frank', tgt_ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AliasesTest) diff --git a/tests/integration/modules/test_archive.py b/tests/integration/modules/test_archive.py index f44136c4cc..6a3d859b12 100644 --- a/tests/integration/modules/test_archive.py +++ b/tests/integration/modules/test_archive.py @@ -9,15 +9,11 @@ import shutil import textwrap # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils # Import 3rd party libs @@ -264,8 +260,3 @@ class ArchiveTest(integration.ModuleCase): self._assert_artifacts_in_ret(ret) self._tear_down() - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ArchiveTest) diff --git a/tests/integration/modules/test_beacons.py b/tests/integration/modules/test_beacons.py index bac0d7ba39..5fa8413551 100644 --- a/tests/integration/modules/test_beacons.py +++ b/tests/integration/modules/test_beacons.py @@ -9,7 +9,7 @@ import os # Salt Libs from salt.exceptions import CommandExecutionError -import integration +import tests.integration as integration import salt.utils # Salttesting libs diff --git a/tests/integration/modules/test_boto_iam.py b/tests/integration/modules/test_boto_iam.py index 445a2a14c0..8b86e152ea 100644 --- a/tests/integration/modules/test_boto_iam.py +++ b/tests/integration/modules/test_boto_iam.py @@ -7,12 +7,8 @@ Validate the boto_iam module from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import Salt libs -import integration # Import 3rd-party libs NO_BOTO_MODULE = True diff --git a/tests/integration/modules/test_boto_sns.py b/tests/integration/modules/test_boto_sns.py index f0cf7fb1c0..c0d32d1e9b 100644 --- a/tests/integration/modules/test_boto_sns.py +++ b/tests/integration/modules/test_boto_sns.py @@ -8,12 +8,8 @@ from __future__ import absolute_import import re # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import Salt libs -import integration # Import 3rd-party libs NO_BOTO_MODULE = True diff --git a/tests/integration/modules/test_cmdmod.py b/tests/integration/modules/test_cmdmod.py index a19abfd713..434776553f 100644 --- a/tests/integration/modules/test_cmdmod.py +++ b/tests/integration/modules/test_cmdmod.py @@ -8,17 +8,15 @@ import textwrap import tempfile # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, skip_if_binaries_missing ) from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils @@ -294,7 +292,3 @@ class CMDModuleTest(integration.ModuleCase): pass else: raise RuntimeError - -if __name__ == '__main__': - from integration import run_tests - run_tests(CMDModuleTest) diff --git a/tests/integration/modules/test_config.py b/tests/integration/modules/test_config.py index 9319bdcb4a..8f5a216677 100644 --- a/tests/integration/modules/test_config.py +++ b/tests/integration/modules/test_config.py @@ -7,11 +7,7 @@ Validate the config system from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class ConfigTest(integration.ModuleCase): @@ -103,8 +99,3 @@ class ConfigTest(integration.ModuleCase): 'config.get', ['config_test:spam']), 'eggs') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ConfigTest) diff --git a/tests/integration/modules/test_cp.py b/tests/integration/modules/test_cp.py index 4c6da5c980..f358773be1 100644 --- a/tests/integration/modules/test_cp.py +++ b/tests/integration/modules/test_cp.py @@ -8,12 +8,10 @@ import hashlib import tempfile # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs import salt.ext.six as six -import integration import salt.utils @@ -526,7 +524,3 @@ class CPModuleTest(integration.ModuleCase): self.assertTrue(os.path.isfile(tgt_cache_file), 'File was not cached on the master') finally: os.unlink(tgt_cache_file) - -if __name__ == '__main__': - from integration import run_tests - run_tests(CPModuleTest) diff --git a/tests/integration/modules/test_darwin_sysctl.py b/tests/integration/modules/test_darwin_sysctl.py index 878d57dabc..765d405ad3 100644 --- a/tests/integration/modules/test_darwin_sysctl.py +++ b/tests/integration/modules/test_darwin_sysctl.py @@ -9,19 +9,17 @@ import os import random # Import Salt Libs -import integration import salt.utils import salt.utils.files from salt.exceptions import CommandExecutionError # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') # Module Variables ASSIGN_CMD = 'net.inet.icmp.icmplim' @@ -210,8 +208,3 @@ class DarwinSysctlModuleTest(integration.ModuleCase): if self.has_conf is False and os.path.isfile(CONFIG): # remove sysctl.conf created by tests os.remove(CONFIG) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DarwinSysctlModuleTest) diff --git a/tests/integration/modules/test_data.py b/tests/integration/modules/test_data.py index e70db58856..01b3b46d51 100644 --- a/tests/integration/modules/test_data.py +++ b/tests/integration/modules/test_data.py @@ -4,11 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class DataModuleTest(integration.ModuleCase): @@ -54,7 +50,3 @@ class DataModuleTest(integration.ModuleCase): self.assertTrue(self.run_function('data.update', ['spam', 'eggs'])) self.assertTrue(self.run_function('data.cas', ['spam', 'green', 'eggs'])) self.assertEqual(self.run_function('data.get', ['spam']), 'green') - -if __name__ == '__main__': - from integration import run_tests - run_tests(DataModuleTest) diff --git a/tests/integration/modules/test_decorators.py b/tests/integration/modules/test_decorators.py index bd8c953e56..b517bb1e36 100644 --- a/tests/integration/modules/test_decorators.py +++ b/tests/integration/modules/test_decorators.py @@ -4,11 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class DecoratorTest(integration.ModuleCase): @@ -60,8 +56,3 @@ class DecoratorTest(integration.ModuleCase): 'runtests_decorators.missing_depends_will_fallback' ) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DecoratorTest) diff --git a/tests/integration/modules/test_disk.py b/tests/integration/modules/test_disk.py index 3e02f2c5cb..37e29590af 100644 --- a/tests/integration/modules/test_disk.py +++ b/tests/integration/modules/test_disk.py @@ -6,12 +6,11 @@ import os import shutil # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import (ensure_in_syspath, destructiveTest) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils # Import 3rd-party libs @@ -86,8 +85,3 @@ class DiskModuleTest(integration.ModuleCase): self.assertTrue('free' in val) self.assertTrue('use' in val) self.assertTrue('filesystem' in val) - - -if __name__ == '__main__': - from integration import run_tests - run_tests([DiskModuleVirtualizationTest, DiskModuleTest]) diff --git a/tests/integration/modules/test_django.py b/tests/integration/modules/test_django.py index 1e1babee17..b473e62b45 100644 --- a/tests/integration/modules/test_django.py +++ b/tests/integration/modules/test_django.py @@ -6,13 +6,11 @@ Test the django module from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs -import integration from salt.modules import djangomod as django django.__salt__ = {} @@ -147,8 +145,3 @@ class DjangoModuleTest(integration.ModuleCase): python_shell=False, env=None ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DjangoModuleTest) diff --git a/tests/integration/modules/test_event.py b/tests/integration/modules/test_event.py index fe365f7caa..1b52cc2465 100644 --- a/tests/integration/modules/test_event.py +++ b/tests/integration/modules/test_event.py @@ -13,11 +13,9 @@ import time import threading # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration from salt.utils import event # Import 3rd-party libs @@ -117,8 +115,3 @@ class EventModuleTest(integration.ModuleCase): with self.assertRaises(Empty): eventfired = events.get(block=True, timeout=10) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EventModuleTest) diff --git a/tests/integration/modules/test_file.py b/tests/integration/modules/test_file.py index 6320adae69..cc769cc5a5 100644 --- a/tests/integration/modules/test_file.py +++ b/tests/integration/modules/test_file.py @@ -10,14 +10,11 @@ import shutil import sys # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, MagicMock -ensure_in_syspath('../../') - # Import salt libs -import integration import salt.utils from salt.modules import file as filemod @@ -252,7 +249,3 @@ class FileModuleTest(integration.ModuleCase): ret = filemod.source_list( [{'file://' + self.myfile: ''}], 'filehash', 'base') self.assertEqual(list(ret), ['file://' + self.myfile, 'filehash']) - -if __name__ == '__main__': - from integration import run_tests - run_tests(FileModuleTest) diff --git a/tests/integration/modules/test_gem.py b/tests/integration/modules/test_gem.py index 08a1d074c7..ab0a3e6d89 100644 --- a/tests/integration/modules/test_gem.py +++ b/tests/integration/modules/test_gem.py @@ -7,12 +7,11 @@ Integration tests for Ruby Gem module from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils import salt.utils.http @@ -141,7 +140,3 @@ class GemModuleTest(integration.ModuleCase): ''' ret = self.run_function('gem.update_system') self.assertTrue(ret) - -if __name__ == '__main__': - from integration import run_tests - run_tests(GemModuleTest) diff --git a/tests/integration/modules/test_gentoolkitmod.py b/tests/integration/modules/test_gentoolkitmod.py index a48784fb6b..cb74dc8d15 100644 --- a/tests/integration/modules/test_gentoolkitmod.py +++ b/tests/integration/modules/test_gentoolkitmod.py @@ -4,11 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class GentoolkitModuleTest(integration.ModuleCase): @@ -24,8 +20,3 @@ class GentoolkitModuleTest(integration.ModuleCase): def test_revdep_rebuild_true(self): ret = self.run_function('gentoolkit.revdep_rebuild') self.assertTrue(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GentoolkitModuleTest) diff --git a/tests/integration/modules/test_git.py b/tests/integration/modules/test_git.py index c402d07f4c..dd2df171cc 100644 --- a/tests/integration/modules/test_git.py +++ b/tests/integration/modules/test_git.py @@ -18,19 +18,17 @@ import shutil import subprocess import tarfile import tempfile +from distutils.version import LooseVersion # Import Salt Testing libs -from distutils.version import LooseVersion +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, skip_if_binaries_missing ) -ensure_in_syspath('../..') # Import salt libs -import integration import salt.utils log = logging.getLogger(__name__) @@ -976,8 +974,3 @@ class GitModuleTest(integration.ModuleCase): self.run_function('git.worktree_prune', [self.repo]), prune_message ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GitModuleTest) diff --git a/tests/integration/modules/test_grains.py b/tests/integration/modules/test_grains.py index 8cb0a8b805..5ca13c4f64 100644 --- a/tests/integration/modules/test_grains.py +++ b/tests/integration/modules/test_grains.py @@ -9,13 +9,9 @@ import os import time # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import destructiveTest, ensure_in_syspath - -ensure_in_syspath('../../') - -# Import salt libs -import integration +from tests.support.helpers import destructiveTest class TestModulesGrains(integration.ModuleCase): @@ -205,8 +201,3 @@ class GrainsAppendTestCase(integration.ModuleCase): # We should only have hit the grain key once. self.assertEqual(count, 1) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestModulesGrains) diff --git a/tests/integration/modules/test_groupadd.py b/tests/integration/modules/test_groupadd.py index e783258c21..efd57d11d9 100644 --- a/tests/integration/modules/test_groupadd.py +++ b/tests/integration/modules/test_groupadd.py @@ -6,12 +6,11 @@ import string import random # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import destructiveTest # Import salt libs from salt.ext.six.moves import range -import integration import salt.utils @@ -169,8 +168,3 @@ class GroupModuleTest(integration.ModuleCase): self.assertIn(self._user, str(ginfo)) self.assertNotIn(self._no_group, str(ginfo)) self.assertNotIn(self._no_user, str(ginfo)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GroupModuleTest) diff --git a/tests/integration/modules/test_hosts.py b/tests/integration/modules/test_hosts.py index f22f5f0846..71a109c11a 100644 --- a/tests/integration/modules/test_hosts.py +++ b/tests/integration/modules/test_hosts.py @@ -8,11 +8,9 @@ import os import shutil # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils HFN = os.path.join(integration.TMP, 'hosts') @@ -214,8 +212,3 @@ class HostsModuleTest(integration.ModuleCase): '192.168.1.1\t\thost1.fqdn.com host1 host1-reorder', '192.168.1.2\t\thost2.fqdn.com host2 oldhost2 host2-reorder', ]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HostsModuleTest) diff --git a/tests/integration/modules/test_key.py b/tests/integration/modules/test_key.py index 6101ef0953..4e4a1d6c28 100644 --- a/tests/integration/modules/test_key.py +++ b/tests/integration/modules/test_key.py @@ -5,11 +5,7 @@ from __future__ import absolute_import import re # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class KeyModuleTest(integration.ModuleCase): @@ -28,7 +24,3 @@ class KeyModuleTest(integration.ModuleCase): out = self.run_function('key.finger_master') match = re.match("([0-9a-z]{2}:){15,}[0-9a-z]{2}$", out) self.assertTrue(match) - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeyModuleTest) diff --git a/tests/integration/modules/test_linux_acl.py b/tests/integration/modules/test_linux_acl.py index 6355609d7b..6d2034e39e 100644 --- a/tests/integration/modules/test_linux_acl.py +++ b/tests/integration/modules/test_linux_acl.py @@ -6,12 +6,10 @@ import os import shutil # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing -import salt.utils -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import skip_if_binaries_missing # Import salt libs -import integration import salt.utils # from salt.modules import linux_acl as acl @@ -68,8 +66,3 @@ class LinuxAclModuleTest(integration.ModuleCase, 'group': [{'root': {'octal': 4, 'permissions': {'read': True, 'write': False, 'execute': False}}}], 'comment': {'owner': 'root', 'group': 'root', 'file': self.myfile}}} ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LinuxAclModuleTest) diff --git a/tests/integration/modules/test_locale.py b/tests/integration/modules/test_locale.py index 737ea77167..67e7b4d190 100644 --- a/tests/integration/modules/test_locale.py +++ b/tests/integration/modules/test_locale.py @@ -4,17 +4,15 @@ from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( - ensure_in_syspath, requires_salt_modules, requires_system_grains, destructiveTest, ) -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils diff --git a/tests/integration/modules/test_lxc.py b/tests/integration/modules/test_lxc.py index d96964f7b1..7f924b06fd 100644 --- a/tests/integration/modules/test_lxc.py +++ b/tests/integration/modules/test_lxc.py @@ -8,16 +8,12 @@ Test the lxc module from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.helpers import ( - ensure_in_syspath, skip_if_not_root, skip_if_binaries_missing ) from tests.support.unit import skipIf -ensure_in_syspath('../../') - -# Import salt libs -import integration # Import 3rd-party libs import salt.ext.six as six @@ -104,7 +100,3 @@ class LXCModuleTest(integration.ModuleCase): self.run_function('cmd.run', ['truncate -s 0 {0}'.format(f)]) self.assertEqual(conf.get('lxc.network.type'), 'macvlan') - -if __name__ == '__main__': - from integration import run_tests - run_tests(LXCModuleTest) diff --git a/tests/integration/modules/test_mac_assistive.py b/tests/integration/modules/test_mac_assistive.py index 77bcfd521e..67f914f87d 100644 --- a/tests/integration/modules/test_mac_assistive.py +++ b/tests/integration/modules/test_mac_assistive.py @@ -8,16 +8,12 @@ from __future__ import absolute_import import os # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') - -# Import Salt Libs -import integration OSA_SCRIPT = '/usr/bin/osascript' @@ -126,8 +122,3 @@ class MacAssistiveTest(integration.ModuleCase): self.assertFalse( self.run_function('assistive.enabled', [OSA_SCRIPT]) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacAssistiveTest) diff --git a/tests/integration/modules/test_mac_brew.py b/tests/integration/modules/test_mac_brew.py index bbd5f88e1b..2bb568684e 100644 --- a/tests/integration/modules/test_mac_brew.py +++ b/tests/integration/modules/test_mac_brew.py @@ -8,15 +8,11 @@ from __future__ import absolute_import import os # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath, -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import Salt Libs -import integration import salt.utils from salt.exceptions import CommandExecutionError @@ -188,8 +184,3 @@ class BrewModuleTest(integration.ModuleCase): self.run_function('pkg.remove', [ADD_PKG]) if DEL_PKG in pkg_list: self.run_function('pkg.remove', [DEL_PKG]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BrewModuleTest) diff --git a/tests/integration/modules/test_mac_defaults.py b/tests/integration/modules/test_mac_defaults.py index 657d96eb6b..7dc507924e 100644 --- a/tests/integration/modules/test_mac_defaults.py +++ b/tests/integration/modules/test_mac_defaults.py @@ -8,16 +8,12 @@ from __future__ import absolute_import import os # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') - -# Import Salt Libs -import integration DEFAULT_DOMAIN = 'com.apple.AppleMultitouchMouse' DEFAULT_KEY = 'MouseHorizontalScroll' @@ -59,7 +55,3 @@ class MacDefaultsModuleTest(integration.ModuleCase): DEFAULT_KEY]) self.assertTrue(read_domain) self.assertEqual(read_domain, DEFAULT_VALUE) - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacDefaultsModuleTest) diff --git a/tests/integration/modules/test_mac_desktop.py b/tests/integration/modules/test_mac_desktop.py index f19acb28fe..a253987074 100644 --- a/tests/integration/modules/test_mac_desktop.py +++ b/tests/integration/modules/test_mac_desktop.py @@ -8,18 +8,13 @@ from __future__ import absolute_import import os # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') - -# Import Salt Libs -import integration - @skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test') class MacDesktopTestCase(integration.ModuleCase): @@ -93,8 +88,3 @@ class MacDesktopTestCase(integration.ModuleCase): self.assertTrue( self.run_function('desktop.say', ['hello', 'world']) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacDesktopTestCase) diff --git a/tests/integration/modules/test_mac_group.py b/tests/integration/modules/test_mac_group.py index 79ba420ab7..08184c6d60 100644 --- a/tests/integration/modules/test_mac_group.py +++ b/tests/integration/modules/test_mac_group.py @@ -10,16 +10,14 @@ import random import string # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') # Import Salt Libs -import integration from salt.exceptions import CommandExecutionError # Import 3rd-party libs @@ -216,8 +214,3 @@ class MacGroupModuleTest(integration.ModuleCase): change_info = self.run_function('group.info', [CHANGE_GROUP]) if change_info: self.run_function('group.delete', [CHANGE_GROUP]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacGroupModuleTest) diff --git a/tests/integration/modules/test_mac_keychain.py b/tests/integration/modules/test_mac_keychain.py index e8c2e7c645..f1ca366857 100644 --- a/tests/integration/modules/test_mac_keychain.py +++ b/tests/integration/modules/test_mac_keychain.py @@ -8,16 +8,14 @@ from __future__ import absolute_import import os # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') # Import Salt Libs -import integration from salt.exceptions import CommandExecutionError CERT = os.path.join( @@ -125,8 +123,3 @@ class MacKeychainModuleTest(integration.ModuleCase): cert_default = 'com.apple.systemdefault' certs = self.run_function('keychain.list_certs') self.assertIn(cert_default, certs) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacKeychainModuleTest) diff --git a/tests/integration/modules/test_mac_pkgutil.py b/tests/integration/modules/test_mac_pkgutil.py index d849488193..061ba797c8 100644 --- a/tests/integration/modules/test_mac_pkgutil.py +++ b/tests/integration/modules/test_mac_pkgutil.py @@ -8,11 +8,10 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils TEST_PKG_URL = 'https://distfiles.macports.org/MacPorts/MacPorts-2.3.4-10.11-ElCapitan.pkg' @@ -88,8 +87,3 @@ class MacPkgutilModuleTest(integration.ModuleCase): # Test forget self.assertTrue(self.run_function('pkgutil.forget', [TEST_PKG_NAME])) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacPkgutilModuleTest) diff --git a/tests/integration/modules/test_mac_ports.py b/tests/integration/modules/test_mac_ports.py index 1b5cd23aff..ad4b7c2858 100644 --- a/tests/integration/modules/test_mac_ports.py +++ b/tests/integration/modules/test_mac_ports.py @@ -7,11 +7,10 @@ integration tests for mac_ports from __future__ import absolute_import, print_function # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils @@ -116,8 +115,3 @@ class MacPortsModuleTest(integration.ModuleCase): results = self.run_function('pkg.upgrade', refresh=False) self.assertIsInstance(results, dict) self.assertTrue(results['result']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacPortsModuleTest) diff --git a/tests/integration/modules/test_mac_power.py b/tests/integration/modules/test_mac_power.py index f47d667a1b..747cfe22ea 100644 --- a/tests/integration/modules/test_mac_power.py +++ b/tests/integration/modules/test_mac_power.py @@ -7,15 +7,13 @@ integration tests for mac_power from __future__ import absolute_import, print_function # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils -ensure_in_syspath('../../') - @skipIf(not salt.utils.is_darwin() or not salt.utils.which('systemsetup') @@ -330,12 +328,3 @@ class MacPowerModuleTestWakeOnModem(integration.ModuleCase): self.assertTrue( self.run_function('power.set_wake_on_modem', ['off'])) self.assertFalse(self.run_function('power.get_wake_on_modem')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacPowerModuleTest, - MacPowerModuleTestSleepOnPowerButton, - MacPowerModuleTestRestartPowerFailure, - MacPowerModuleTestWakeOnNet, - MacPowerModuleTestWakeOnModem) diff --git a/tests/integration/modules/test_mac_service.py b/tests/integration/modules/test_mac_service.py index 5f22d06376..81b74b2ce9 100644 --- a/tests/integration/modules/test_mac_service.py +++ b/tests/integration/modules/test_mac_service.py @@ -7,12 +7,11 @@ integration tests for mac_service from __future__ import absolute_import, print_function # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils @@ -220,8 +219,3 @@ class MacServiceModuleTest(integration.ModuleCase): services = self.run_function('service.get_enabled') self.assertIsInstance(services, list) self.assertIn('com.apple.coreservicesd', services) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacServiceModuleTest) diff --git a/tests/integration/modules/test_mac_shadow.py b/tests/integration/modules/test_mac_shadow.py index 6a86517651..498ab0ad96 100644 --- a/tests/integration/modules/test_mac_shadow.py +++ b/tests/integration/modules/test_mac_shadow.py @@ -10,13 +10,12 @@ import random import string # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, destructiveTest -from salt.ext.six.moves import range -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils +from salt.ext.six.moves import range def __random_string(size=6): @@ -244,8 +243,3 @@ class MacShadowModuleTest(integration.ModuleCase): self.assertEqual( self.run_function('shadow.set_password', [NO_USER, 'P@SSw0rd']), 'ERROR: User not found: {0}'.format(NO_USER)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacShadowModuleTest) diff --git a/tests/integration/modules/test_mac_softwareupdate.py b/tests/integration/modules/test_mac_softwareupdate.py index 8caba94f10..ccfd5088f2 100644 --- a/tests/integration/modules/test_mac_softwareupdate.py +++ b/tests/integration/modules/test_mac_softwareupdate.py @@ -7,11 +7,10 @@ integration tests for mac_softwareupdate from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils @@ -183,8 +182,3 @@ class MacSoftwareUpdateModuleTest(integration.ModuleCase): self.assertTrue(self.run_function('softwareupdate.reset_catalog')) self.assertEqual(self.run_function('softwareupdate.get_catalog'), 'Default') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacSoftwareUpdateModuleTest) diff --git a/tests/integration/modules/test_mac_system.py b/tests/integration/modules/test_mac_system.py index 117b41dd40..1055f13d7e 100644 --- a/tests/integration/modules/test_mac_system.py +++ b/tests/integration/modules/test_mac_system.py @@ -9,14 +9,13 @@ import random import string # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest -from salt.ext.six.moves import range -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils +from salt.ext.six.moves import range def __random_string(size=6): @@ -245,8 +244,3 @@ class MacSystemModuleTest(integration.ModuleCase): self.assertIn( 'Invalid value passed for arch', self.run_function('system.set_boot_arch', ['spongebob'])) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacSystemModuleTest) diff --git a/tests/integration/modules/test_mac_timezone.py b/tests/integration/modules/test_mac_timezone.py index 6ad8f962a8..eb24f7f55b 100644 --- a/tests/integration/modules/test_mac_timezone.py +++ b/tests/integration/modules/test_mac_timezone.py @@ -15,12 +15,11 @@ from __future__ import absolute_import import datetime # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils @@ -214,8 +213,3 @@ class MacTimezoneModuleTest(integration.ModuleCase): self.run_function('timezone.set_time_server', ['spongebob.com'])) self.assertEqual( self.run_function('timezone.get_time_server'), 'spongebob.com') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacTimezoneModuleTest) diff --git a/tests/integration/modules/test_mac_user.py b/tests/integration/modules/test_mac_user.py index ba384facd9..e90819b375 100644 --- a/tests/integration/modules/test_mac_user.py +++ b/tests/integration/modules/test_mac_user.py @@ -10,16 +10,14 @@ import random import string # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') # Import Salt Libs -import integration from salt.exceptions import CommandExecutionError # Import 3rd-party libs @@ -175,8 +173,3 @@ class MacUserModuleTest(integration.ModuleCase): change_info = self.run_function('user.info', [CHANGE_USER]) if change_info: self.run_function('user.delete', [CHANGE_USER]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacUserModuleTest) diff --git a/tests/integration/modules/test_mac_xattr.py b/tests/integration/modules/test_mac_xattr.py index d707f5d479..60c69f7afd 100644 --- a/tests/integration/modules/test_mac_xattr.py +++ b/tests/integration/modules/test_mac_xattr.py @@ -8,11 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils TEST_FILE = os.path.join(integration.TMP, 'xattr_test_file.txt') @@ -175,8 +173,3 @@ class MacXattrModuleTest(integration.ModuleCase): # Test file not found self.assertEqual(self.run_function('xattr.clear', [NO_FILE]), 'ERROR: File not found: {0}'.format(NO_FILE)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacXattrModuleTest) diff --git a/tests/integration/modules/test_mine.py b/tests/integration/modules/test_mine.py index ce6b312a4a..6b2d2f156d 100644 --- a/tests/integration/modules/test_mine.py +++ b/tests/integration/modules/test_mine.py @@ -7,11 +7,7 @@ from __future__ import absolute_import import time # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class MineTest(integration.ModuleCase): @@ -147,7 +143,3 @@ class MineTest(integration.ModuleCase): ['minion', 'test.echo'] ) self.assertEqual(ret_echo_stays['minion'], 'foo') - -if __name__ == '__main__': - from integration import run_tests - run_tests(MineTest) diff --git a/tests/integration/modules/test_mysql.py b/tests/integration/modules/test_mysql.py index 6f1d2034ce..c45a2593af 100644 --- a/tests/integration/modules/test_mysql.py +++ b/tests/integration/modules/test_mysql.py @@ -5,15 +5,11 @@ from __future__ import absolute_import import logging # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils from salt.modules import mysql as mysqlmod @@ -1633,7 +1629,3 @@ class MysqlModuleUserGrantTest(integration.ModuleCase, "GRANT USAGE ON *.* TO ''@'localhost'", "GRANT DELETE ON `test ``(:=salteeb)`.* TO ''@'localhost'" ]) - -if __name__ == '__main__': - from integration import run_tests - run_tests(MysqlModuleDbTest, MysqlModuleUserTest) diff --git a/tests/integration/modules/test_nilrt_ip.py b/tests/integration/modules/test_nilrt_ip.py index c7bc1b027e..89157211d3 100644 --- a/tests/integration/modules/test_nilrt_ip.py +++ b/tests/integration/modules/test_nilrt_ip.py @@ -8,12 +8,11 @@ from __future__ import absolute_import import time # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils @@ -111,8 +110,3 @@ class Nilrt_ipModuleTest(integration.ModuleCase): self.assertEqual(interface['ipv4']['address'], '192.168.10.4') self.assertEqual(interface['ipv4']['netmask'], '255.255.255.0') self.assertEqual(interface['ipv4']['gateway'], '192.168.10.1') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(Nilrt_ipModuleTest) diff --git a/tests/integration/modules/test_pillar.py b/tests/integration/modules/test_pillar.py index fcd9f4d589..854c257b0b 100644 --- a/tests/integration/modules/test_pillar.py +++ b/tests/integration/modules/test_pillar.py @@ -5,15 +5,9 @@ from __future__ import absolute_import from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - ensure_in_syspath, - requires_network -) -ensure_in_syspath('../../') - -# Import salt libs -import integration +from tests.support.helpers import requires_network GIT_PYTHON = '0.3.2' HAS_GIT_PYTHON = False @@ -123,7 +117,3 @@ class PillarModuleTest(integration.ModuleCase): self.assertDictContainsSubset( {'knights': ['Lancelot', 'Galahad', 'Bedevere', 'Robin']}, get_items) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PillarModuleTest) diff --git a/tests/integration/modules/test_pip.py b/tests/integration/modules/test_pip.py index 27ba29fc40..e40d9f9143 100644 --- a/tests/integration/modules/test_pip.py +++ b/tests/integration/modules/test_pip.py @@ -15,12 +15,10 @@ import re import tempfile # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES @@ -438,8 +436,3 @@ class PipModuleTest(integration.ModuleCase): shutil.rmtree(self.venv_test_dir) if os.path.isdir(self.pip_temp): shutil.rmtree(self.pip_temp) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PipModuleTest) diff --git a/tests/integration/modules/test_pkg.py b/tests/integration/modules/test_pkg.py index 1892f2e6d5..a1e43d954b 100644 --- a/tests/integration/modules/test_pkg.py +++ b/tests/integration/modules/test_pkg.py @@ -3,16 +3,12 @@ from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.helpers import ( destructiveTest, requires_network, requires_salt_modules, - ensure_in_syspath ) -ensure_in_syspath('../../') - -# Import salt libs -import integration class PkgModuleTest(integration.ModuleCase, @@ -302,8 +298,3 @@ class PkgModuleTest(integration.ModuleCase, self.assertNotEqual(ret, {}) if 'changes' in ret: self.assertNotEqual(ret['changes'], {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PkgModuleTest) diff --git a/tests/integration/modules/test_publish.py b/tests/integration/modules/test_publish.py index bcf5de3bfa..d4372bf2e7 100644 --- a/tests/integration/modules/test_publish.py +++ b/tests/integration/modules/test_publish.py @@ -4,11 +4,7 @@ from __future__ import absolute_import, print_function # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class PublishModuleTest(integration.ModuleCase, @@ -143,8 +139,3 @@ class PublishModuleTest(integration.ModuleCase, ['minion', 'cmd.run', ['echo foo']] ) self.assertEqual(ret, {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PublishModuleTest) diff --git a/tests/integration/modules/test_pw_user.py b/tests/integration/modules/test_pw_user.py index c13522397d..dc3bb5f7c5 100644 --- a/tests/integration/modules/test_pw_user.py +++ b/tests/integration/modules/test_pw_user.py @@ -12,12 +12,9 @@ import string import random # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import destructiveTest, ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +from tests.support.helpers import destructiveTest # Import 3rd-party libs from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin @@ -81,8 +78,3 @@ class PwUserModuleTest(integration.ModuleCase): except AssertionError: self.run_function('user.delete', [uname, True, True]) raise - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PwUserModuleTest) diff --git a/tests/integration/modules/test_rabbitmq.py b/tests/integration/modules/test_rabbitmq.py index b6f77b6d39..fe1834a64d 100644 --- a/tests/integration/modules/test_rabbitmq.py +++ b/tests/integration/modules/test_rabbitmq.py @@ -5,13 +5,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, requires_salt_modules - -ensure_in_syspath('../../') - -# Import salt libs -import integration +from tests.support.helpers import requires_salt_modules @skipIf(os.geteuid() != 0, 'You must be root to run this test') @@ -28,8 +24,3 @@ class RabbitModuleTest(integration.ModuleCase): ''' ret = self.run_function('rabbitmq.user_exists', ['null_user']) self.assertEqual(ret, False) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitModuleTest) diff --git a/tests/integration/modules/test_random_org.py b/tests/integration/modules/test_random_org.py index ef1b98b413..624dc585f0 100644 --- a/tests/integration/modules/test_random_org.py +++ b/tests/integration/modules/test_random_org.py @@ -8,14 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.mock import ( - NO_MOCK, - NO_MOCK_REASON -) - -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs import salt.utils.http @@ -36,7 +28,6 @@ def check_status(): @skipIf(not check_status(), 'random.org is not available') -@skipIf(NO_MOCK, NO_MOCK_REASON) class RandomOrgTestCase(TestCase): ''' Test cases for salt.modules.random_org @@ -307,8 +298,3 @@ class RandomOrgTestCase(TestCase): api_version='1', number=5, size=8, format='hex'), ret6) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RandomOrgTestCase, needs_daemon=False) diff --git a/tests/integration/modules/test_saltutil.py b/tests/integration/modules/test_saltutil.py index e54a80ac04..0df09a4f22 100644 --- a/tests/integration/modules/test_saltutil.py +++ b/tests/integration/modules/test_saltutil.py @@ -8,12 +8,7 @@ from __future__ import absolute_import import time # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - -# Import Salt libs -import integration +import tests.integration as integration class SaltUtilModuleTest(integration.ModuleCase): @@ -154,9 +149,3 @@ class SaltUtilSyncModuleTest(integration.ModuleCase): ret = self.run_function('saltutil.sync_all', extmod_whitelist={'modules': ['runtests_decorators']}, extmod_blacklist={'modules': ['runtests_decorators']}) self.assertEqual(ret, expected_return) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SaltUtilModuleTest) - run_tests(SaltUtilSyncModuleTest) diff --git a/tests/integration/modules/test_shadow.py b/tests/integration/modules/test_shadow.py index 40cd4cdc12..d0d61c2b8f 100644 --- a/tests/integration/modules/test_shadow.py +++ b/tests/integration/modules/test_shadow.py @@ -10,14 +10,13 @@ import string import os # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, destructiveTest -from salt.ext.six.moves import range -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils +from salt.ext.six.moves import range @skipIf(not salt.utils.is_linux(), 'These tests can only be run on linux') @@ -232,8 +231,3 @@ class ShadowModuleTest(integration.ModuleCase): #restore shadow file with salt.utils.fopen('/etc/shadow', 'w') as sFile: sFile.write(shadow) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ShadowModuleTest) diff --git a/tests/integration/modules/test_ssh.py b/tests/integration/modules/test_ssh.py index d5209a37d2..eb1307a971 100644 --- a/tests/integration/modules/test_ssh.py +++ b/tests/integration/modules/test_ssh.py @@ -9,13 +9,11 @@ import os import shutil # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing -ensure_in_syspath('../../') - +from tests.support.helpers import skip_if_binaries_missing # Import salt libs -import integration import salt.utils import salt.utils.http @@ -239,8 +237,3 @@ class SSHModuleTest(integration.ModuleCase): exc, ret ) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SSHModuleTest) diff --git a/tests/integration/modules/test_state.py b/tests/integration/modules/test_state.py index 41eb470d3f..d1e1ff8c8c 100644 --- a/tests/integration/modules/test_state.py +++ b/tests/integration/modules/test_state.py @@ -9,12 +9,10 @@ import threading import time # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES @@ -1237,8 +1235,3 @@ class StateModuleTest(integration.ModuleCase, self.assertIn('Attempt 4:', state_run[retry_state]['comment']) self.assertNotIn('Attempt 15:', state_run[retry_state]['comment']) self.assertEqual(state_run[retry_state]['result'], True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StateModuleTest) diff --git a/tests/integration/modules/test_supervisord.py b/tests/integration/modules/test_supervisord.py index b0ffb6f3d2..8f97b056d6 100644 --- a/tests/integration/modules/test_supervisord.py +++ b/tests/integration/modules/test_supervisord.py @@ -7,12 +7,10 @@ import time import subprocess # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES @@ -225,8 +223,3 @@ class SupervisordModuleTest(integration.ModuleCase): 'supervisord.status', ['sleep_service'], conf_file=self.supervisor_conf, bin_env=self.venv_dir) self.assertTrue(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SupervisordModuleTest) diff --git a/tests/integration/modules/test_sysctl.py b/tests/integration/modules/test_sysctl.py index 1dd6341c78..fb665c506b 100644 --- a/tests/integration/modules/test_sysctl.py +++ b/tests/integration/modules/test_sysctl.py @@ -5,12 +5,8 @@ from __future__ import absolute_import import sys # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration class SysctlModuleTest(integration.ModuleCase): @@ -53,8 +49,3 @@ class SysctlModuleTest(integration.ModuleCase): self.assertEqual( ret.get('kern.ostype'), 'Darwin', 'Incorrect kern.ostype' ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SysctlModuleTest) diff --git a/tests/integration/modules/test_sysmod.py b/tests/integration/modules/test_sysmod.py index c96e9ba0ea..c94bc2fcde 100644 --- a/tests/integration/modules/test_sysmod.py +++ b/tests/integration/modules/test_sysmod.py @@ -4,11 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class SysModuleTest(integration.ModuleCase): @@ -30,8 +26,3 @@ class SysModuleTest(integration.ModuleCase): '\n'.join([' - {0}'.format(f) for f in ret['missing_cli_example']]), ) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SysModuleTest) diff --git a/tests/integration/modules/test_system.py b/tests/integration/modules/test_system.py index 263798065d..8e992c382f 100644 --- a/tests/integration/modules/test_system.py +++ b/tests/integration/modules/test_system.py @@ -9,19 +9,14 @@ import signal import subprocess # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath -) -from salt.ext.six.moves import range - -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils import salt.states.file +from salt.ext.six.moves import range log = logging.getLogger(__name__) @@ -338,7 +333,3 @@ class SystemModuleTest(integration.ModuleCase): if self.run_function('grains.get', ['os_family']) == 'NILinuxRT': self.assertTrue(self.run_function('system._has_settable_hwclock')) self.assertTrue(self._hwclock_has_compare()) - -if __name__ == '__main__': - from integration import run_tests - run_tests(SystemModuleTest) diff --git a/tests/integration/modules/test_test.py b/tests/integration/modules/test_test.py index 626d240ec6..b3ee3be1cd 100644 --- a/tests/integration/modules/test_test.py +++ b/tests/integration/modules/test_test.py @@ -4,13 +4,11 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.version -from salt import config +import salt.config class TestModuleTest(integration.ModuleCase, @@ -47,7 +45,7 @@ class TestModuleTest(integration.ModuleCase, ''' test.get_opts ''' - opts = config.minion_config( + opts = salt.config.minion_config( self.get_config_file_path('minion') ) self.assertEqual( @@ -95,8 +93,3 @@ class TestModuleTest(integration.ModuleCase, test.outputter ''' self.assertEqual(self.run_function('test.outputter', ['text']), 'text') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestModuleTest) diff --git a/tests/integration/modules/test_timezone.py b/tests/integration/modules/test_timezone.py index 5380a6425c..6d8e38e0ce 100644 --- a/tests/integration/modules/test_timezone.py +++ b/tests/integration/modules/test_timezone.py @@ -9,11 +9,7 @@ Linux and Solaris are supported from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class TimezoneLinuxModuleTest(integration.ModuleCase): @@ -46,8 +42,3 @@ class TimezoneSolarisModuleTest(integration.ModuleCase): timescale = ['UTC', 'localtime'] ret = self.run_function('timezone.get_hwclock') self.assertIn(ret, timescale) - - -if __name__ == '__main__': - from integration import run_tests - run_tests([TimezoneLinuxModuleTest, TimezoneSolarisModuleTest]) diff --git a/tests/integration/modules/test_useradd.py b/tests/integration/modules/test_useradd.py index 307ce2366a..645f9c2b0f 100644 --- a/tests/integration/modules/test_useradd.py +++ b/tests/integration/modules/test_useradd.py @@ -7,17 +7,15 @@ import string import random # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') # Import salt libs import salt.utils -import integration # Import 3rd-party libs from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin @@ -199,9 +197,3 @@ class UseraddModuleTestWindows(integration.ModuleCase): finally: self.run_function('user.delete', [user_name, True, True]) self.run_function('group.delete', [group_name]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UseraddModuleTestLinux, - UseraddModuleTestWindows) diff --git a/tests/integration/modules/test_virt.py b/tests/integration/modules/test_virt.py index a685d892f2..50e5b0758e 100644 --- a/tests/integration/modules/test_virt.py +++ b/tests/integration/modules/test_virt.py @@ -7,11 +7,8 @@ Validate the virt module from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, requires_salt_modules -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration +from tests.support.helpers import requires_salt_modules @requires_salt_modules('virt.get_profiles') @@ -45,8 +42,3 @@ class VirtTest(integration.ModuleCase): self.assertTrue(diskp[0]['system'].get('model', '') == 'scsi') self.assertTrue(diskp[0]['system'].get('format', '') == 'vmdk') self.assertTrue(diskp[0]['system'].get('size', '') == '8192') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VirtTest) diff --git a/tests/integration/modules/test_virtualenv.py b/tests/integration/modules/test_virtualenv.py index f485f72307..52f1b95f6a 100644 --- a/tests/integration/modules/test_virtualenv.py +++ b/tests/integration/modules/test_virtualenv.py @@ -6,12 +6,10 @@ import os import tempfile # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES @@ -57,8 +55,3 @@ class VirtualenvModuleTest(integration.ModuleCase): def tearDown(self): self.run_function('file.remove', [self.venv_test_dir]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VirtualenvModuleTest) diff --git a/tests/integration/netapi/rest_cherrypy/test_app_pam.py b/tests/integration/netapi/rest_cherrypy/test_app_pam.py index c0ef9cbed1..37740186be 100644 --- a/tests/integration/netapi/rest_cherrypy/test_app_pam.py +++ b/tests/integration/netapi/rest_cherrypy/test_app_pam.py @@ -13,7 +13,7 @@ from tests.support.helpers import destructiveTest # Import test support libs import tests.support.cherrypy_testclasses as cptc -from tests import integration +import tests.integration as integration # Import Salt Libs import salt.utils diff --git a/tests/integration/netapi/rest_tornado/test_app.py b/tests/integration/netapi/rest_tornado/test_app.py index ee9ec9f992..6a63dc7784 100644 --- a/tests/integration/netapi/rest_tornado/test_app.py +++ b/tests/integration/netapi/rest_tornado/test_app.py @@ -9,14 +9,12 @@ from distutils.version import StrictVersion # pylint: disable=import-error,no-n # Import Salt Libs from salt.netapi.rest_tornado import saltnado -from unit.netapi.rest_tornado.test_handlers import SaltnadoTestCase +from tests.unit.netapi.rest_tornado.test_handlers import SaltnadoTestCase # Import Salt Testing Libs from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../../') +# Import 3rd-party libs import salt.ext.six as six try: @@ -550,13 +548,3 @@ class TestWebhookSaltAPIHandler(SaltnadoTestCase): ) response_obj = json_loads(response.body) self.assertTrue(response_obj['success']) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(TestEventsSaltAPIHandler, - TestJobsSaltAPIHandler, - TestMinionSaltAPIHandler, - TestRunSaltAPIHandler, - TestSaltAPIHandler, - TestWebhookSaltAPIHandler, needs_daemon=True) diff --git a/tests/integration/netapi/test_client.py b/tests/integration/netapi/test_client.py index cb435721e7..48213a0e0a 100644 --- a/tests/integration/netapi/test_client.py +++ b/tests/integration/netapi/test_client.py @@ -5,8 +5,8 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from integration import TMP_CONF_DIR from tests.support.unit import TestCase +from tests.support.paths import TMP_CONF_DIR # Import Salt libs import salt.config @@ -93,8 +93,3 @@ class NetapiClientTest(TestCase): low.update(self.eauth_creds) ret = self.netapi.run(low) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetapiClientTest, needs_daemon=True) diff --git a/tests/integration/output/test_output.py b/tests/integration/output/test_output.py index c9bd9e1f78..c95cbe779c 100644 --- a/tests/integration/output/test_output.py +++ b/tests/integration/output/test_output.py @@ -9,16 +9,12 @@ import os import traceback # Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath +import tests.integration as integration from tests.support.mixins import RUNTIME_VARS -ensure_in_syspath('../../') - # Import Salt libs -import integration import salt.config from salt.output import display_output -import salt.config class OutputReturnTest(integration.ShellCase): @@ -115,8 +111,3 @@ class OutputReturnTest(integration.ShellCase): delattr(self, 'maxDiff') else: self.maxDiff = old_max_diff - - -if __name__ == '__main__': - from integration import run_tests - run_tests(OutputReturnTest) diff --git a/tests/integration/reactor/test_reactor.py b/tests/integration/reactor/test_reactor.py index 788740d174..c562bb074e 100644 --- a/tests/integration/reactor/test_reactor.py +++ b/tests/integration/reactor/test_reactor.py @@ -11,11 +11,7 @@ from __future__ import absolute_import # Import Salt testing libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') - -import integration +import tests.integration as integration # Import Salt libs import salt.utils.event @@ -37,7 +33,3 @@ class ReactorTest(integration.ModuleCase, integration.SaltMinionEventAssertsMixI e.fire_event({'a': 'b'}, '/test_event') self.assertMinionEventReceived({'a': 'b'}) - -if __name__ == '__main__': - from integration import run_tests - run_tests(ReactorTest) diff --git a/tests/integration/renderers/test_pydsl.py b/tests/integration/renderers/test_pydsl.py index 06d393832b..7fd96a33b5 100644 --- a/tests/integration/renderers/test_pydsl.py +++ b/tests/integration/renderers/test_pydsl.py @@ -6,12 +6,9 @@ import os import textwrap # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') +import tests.integration as integration # Import Salt libs -import integration import salt.utils @@ -43,8 +40,3 @@ class PyDSLRendererIncludeTestCase(integration.ModuleCase): finally: os.remove('/tmp/output') - -if __name__ == '__main__': - from integration import run_tests - tests = [PyDSLRendererIncludeTestCase] - run_tests(*tests, needs_daemon=True) diff --git a/tests/integration/returners/test_librato_return.py b/tests/integration/returners/test_librato_return.py index ff12409d8c..d9233d489e 100644 --- a/tests/integration/returners/test_librato_return.py +++ b/tests/integration/returners/test_librato_return.py @@ -7,11 +7,9 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration from salt.returners import librato_return log = logging.getLogger(__name__) @@ -62,7 +60,3 @@ class libratoTest(integration.ShellCase): self.assertEqual(results['num_failed_states'], 1) self.assertEqual(results['num_passed_states'], 1) self.assertEqual(results['runtime'], 7.29) - -if __name__ == '__main__': - from integration import run_tests - run_tests(libratoTest) diff --git a/tests/integration/returners/test_local_cache.py b/tests/integration/returners/test_local_cache.py index aa13d0dffa..05ce050c27 100644 --- a/tests/integration/returners/test_local_cache.py +++ b/tests/integration/returners/test_local_cache.py @@ -8,19 +8,16 @@ import logging import os # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration -from integration import TMP import salt.utils.job from salt.returners import local_cache log = logging.getLogger(__name__) # JOBS DIR and FILES -TMP_CACHE_DIR = os.path.join(TMP, 'rootdir', 'cache') +TMP_CACHE_DIR = os.path.join(integration.TMP, 'rootdir', 'cache') JOBS_DIR = os.path.join(TMP_CACHE_DIR, 'jobs') JID_DIR = os.path.join(JOBS_DIR, '31', 'c56eed380a4e899ae12bc42563cfdfc53066fb4a6b53e2378a08ac49064539') JID_FILE = os.path.join(JID_DIR, 'jid') @@ -122,8 +119,3 @@ class Local_CacheTest(integration.ShellCase): self._check_dir_files('new_jid_dir was not removed', EMPTY_JID_DIR, status='removed') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(Local_CacheTest) diff --git a/tests/integration/runners/test_fileserver.py b/tests/integration/runners/test_fileserver.py index 3b0ca952de..633f410c57 100644 --- a/tests/integration/runners/test_fileserver.py +++ b/tests/integration/runners/test_fileserver.py @@ -7,11 +7,7 @@ from __future__ import absolute_import import contextlib # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class FileserverTest(integration.ShellCase): @@ -193,7 +189,3 @@ class FileserverTest(integration.ShellCase): # Backend submitted as a list ret = self.run_run_plus(fun='fileserver.update', backend=['roots']) self.assertTrue(ret['return']) - -if __name__ == '__main__': - from integration import run_tests - run_tests(FileserverTest) diff --git a/tests/integration/runners/test_jobs.py b/tests/integration/runners/test_jobs.py index cc3f63f72e..41d2dac552 100644 --- a/tests/integration/runners/test_jobs.py +++ b/tests/integration/runners/test_jobs.py @@ -6,12 +6,8 @@ Tests for the salt-run command from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration class ManageTest(integration.ShellCase): @@ -41,8 +37,3 @@ class ManageTest(integration.ShellCase): ''' ret = self.run_run_plus('jobs.list_jobs') self.assertIsInstance(ret['return'], dict) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ManageTest) diff --git a/tests/integration/runners/test_manage.py b/tests/integration/runners/test_manage.py index b7d8b59a34..a31a542261 100644 --- a/tests/integration/runners/test_manage.py +++ b/tests/integration/runners/test_manage.py @@ -6,11 +6,7 @@ Tests for the salt-run command from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class ManageTest(integration.ShellCase): @@ -36,8 +32,3 @@ class ManageTest(integration.ShellCase): self.assertNotIn('sub_minion', ret['return']) self.assertNotIn('minion', ret['out']) self.assertNotIn('sub_minion', ret['out']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ManageTest) diff --git a/tests/integration/runners/test_runner_returns.py b/tests/integration/runners/test_runner_returns.py index 8b0c8e6b6a..09b6769bfe 100644 --- a/tests/integration/runners/test_runner_returns.py +++ b/tests/integration/runners/test_runner_returns.py @@ -10,11 +10,9 @@ import tempfile import yaml # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.payload import salt.utils import salt.utils.jid diff --git a/tests/integration/runners/test_salt.py b/tests/integration/runners/test_salt.py index 6b4ae620dc..7ca696bb53 100644 --- a/tests/integration/runners/test_salt.py +++ b/tests/integration/runners/test_salt.py @@ -8,11 +8,7 @@ Tests for the salt runner from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class SaltRunnerTest(integration.ShellCase): @@ -29,8 +25,3 @@ class SaltRunnerTest(integration.ShellCase): self.assertEqual(out_ret, 'True') self.assertTrue(return_ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SaltRunnerTest) diff --git a/tests/integration/runners/test_state.py b/tests/integration/runners/test_state.py index c999d2410d..118f5cdbb0 100644 --- a/tests/integration/runners/test_state.py +++ b/tests/integration/runners/test_state.py @@ -16,11 +16,8 @@ import threading from salt.ext.six.moves import queue # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -import integration # Import Salt Libs import salt.utils @@ -212,9 +209,3 @@ class OrchEventTest(integration.ShellCase): break finally: signal.alarm(0) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StateRunnerTest) - run_tests(OrchEventTest) diff --git a/tests/integration/runners/test_winrepo.py b/tests/integration/runners/test_winrepo.py index 72ddb35c0d..d029c3550f 100644 --- a/tests/integration/runners/test_winrepo.py +++ b/tests/integration/runners/test_winrepo.py @@ -7,15 +7,11 @@ import shutil import tempfile # Import Salt Testing Libs +import tests.integration as integration from salt.runners import winrepo from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../../') -# Import Salt Libs -import integration - _WINREPO_SLS = r''' winscp_x86: 5.7.5: @@ -107,8 +103,3 @@ class WinrepoTest(integration.ShellCase): 'winrepo_dir': self.winrepo_dir, 'extension_modules': self.extmods_dir}): self.assertEqual(winrepo.genrepo(), _WINREPO_GENREPO_DATA) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinrepoTest) diff --git a/tests/integration/sdb/test_env.py b/tests/integration/sdb/test_env.py index 65f2178c2f..b8fdaeb332 100644 --- a/tests/integration/sdb/test_env.py +++ b/tests/integration/sdb/test_env.py @@ -7,13 +7,11 @@ import os import textwrap # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration -import integration +# Import salt libs import salt.utils - STATE_DIR = os.path.join(integration.FILES, 'file', 'base') @@ -48,8 +46,3 @@ class EnvTestCase(integration.ModuleCase, state_key = 'test_|-always-changes-and-succeeds_|-foo_|-succeed_with_changes' ret = self.run_function('state.sls', [self.state_name]) self.assertTrue(ret[state_key]['result']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EnvTestCase) diff --git a/tests/integration/shell/test_arguments.py b/tests/integration/shell/test_arguments.py index f479e8d5fe..4293f0bd32 100644 --- a/tests/integration/shell/test_arguments.py +++ b/tests/integration/shell/test_arguments.py @@ -7,12 +7,10 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, requires_salt_modules - -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import requires_salt_modules # Import Salt libs -import integration import salt.utils.args @@ -56,8 +54,3 @@ class ArgumentTestCase(integration.ModuleCase): self.run_function('test.echo', [arg]), arg ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ArgumentTestCase) diff --git a/tests/integration/shell/test_auth.py b/tests/integration/shell/test_auth.py index b39b9db471..a33bb59782 100644 --- a/tests/integration/shell/test_auth.py +++ b/tests/integration/shell/test_auth.py @@ -12,16 +12,13 @@ import grp import random # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - ensure_in_syspath, - destructiveTest) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs import salt.utils from salt.utils.pycrypto import gen_hash -import integration # Import 3rd-party libs from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin @@ -137,8 +134,3 @@ class AuthTest(integration.ShellCase): self.run_call('user.delete {0}'.format(user)) if grp.getgrnam(self.group): self.run_call('group.delete {0}'.format(self.group)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AuthTest) diff --git a/tests/integration/shell/test_call.py b/tests/integration/shell/test_call.py index 572b8d6da0..c959e2b92f 100644 --- a/tests/integration/shell/test_call.py +++ b/tests/integration/shell/test_call.py @@ -19,15 +19,10 @@ from datetime import datetime import logging # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -from tests.support.helpers import ( - destructiveTest -) -ensure_in_syspath('../../') - -import integration -from integration.utils import testprogram +from tests.support.helpers import destructiveTest +from tests.integration.utils import testprogram # Import salt libs import salt.utils @@ -484,7 +479,3 @@ class CallTest(integration.ShellCase, testprogram.TestProgramCase, integration.S message='correct usage', stdout=stdout, stderr=stderr ) - - -if __name__ == '__main__': - integration.run_tests(CallTest) diff --git a/tests/integration/shell/test_cloud.py b/tests/integration/shell/test_cloud.py index b151323f62..e577cbb44b 100644 --- a/tests/integration/shell/test_cloud.py +++ b/tests/integration/shell/test_cloud.py @@ -13,11 +13,9 @@ from __future__ import absolute_import, print_function # Import salt testing libs from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../') # Import salt libs -import integration # pylint: disable=import-error +import tests.integration as integration # Import 3rd-party libs # pylint: disable=import-error @@ -96,8 +94,3 @@ class SaltCloudCliTest(integration.ShellCase, if len(test_options) <= 1: # Only one left? Stop iterating break - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(SaltCloudCliTest) diff --git a/tests/integration/shell/test_cp.py b/tests/integration/shell/test_cp.py index 1e5498435b..309e1d1010 100644 --- a/tests/integration/shell/test_cp.py +++ b/tests/integration/shell/test_cp.py @@ -15,11 +15,9 @@ import pipes import shutil # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils # Import 3rd-party libs @@ -160,8 +158,3 @@ class CopyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixin): self.chdir(old_cwd) if os.path.isdir(config_dir): shutil.rmtree(config_dir) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CopyTest) diff --git a/tests/integration/shell/test_enabled.py b/tests/integration/shell/test_enabled.py index cbbf792819..ca4d08744e 100644 --- a/tests/integration/shell/test_enabled.py +++ b/tests/integration/shell/test_enabled.py @@ -6,12 +6,9 @@ import os import textwrap # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') +import tests.integration as integration # Import Salt Libs -import integration import salt.utils @@ -102,8 +99,3 @@ class EnabledTest(integration.ModuleCase): self.assertEqual(ret[ret_key]['name'], disabled_ret) finally: os.remove(state_file) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EnabledTest) diff --git a/tests/integration/shell/test_key.py b/tests/integration/shell/test_key.py index 2392e1adc4..fc682e5ef5 100644 --- a/tests/integration/shell/test_key.py +++ b/tests/integration/shell/test_key.py @@ -8,11 +8,9 @@ import shutil import tempfile # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils USERA = 'saltdev' @@ -274,8 +272,3 @@ class KeyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixin): self.chdir(old_cwd) if os.path.isdir(config_dir): shutil.rmtree(config_dir) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeyTest) diff --git a/tests/integration/shell/test_master.py b/tests/integration/shell/test_master.py index 5d17d655e8..faf86f844b 100644 --- a/tests/integration/shell/test_master.py +++ b/tests/integration/shell/test_master.py @@ -14,16 +14,14 @@ import yaml import signal import shutil -# Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - # Import salt libs -import integration -import integration.utils -from integration.utils import testprogram import salt.utils +# Import salt test libs +import tests.integration as integration +import tests.integration.utils +from tests.integration.utils import testprogram + class MasterTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixin): @@ -97,7 +95,7 @@ class MasterTest(integration.ShellCase, testprogram.TestProgramCase, integration status, 'EX_NOUSER', message='unknown user not on system', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) # Although the start-up should fail, call shutdown() to set the internal # _shutdown flag and avoid the registered atexit calls to cause timeout @@ -125,7 +123,7 @@ class MasterTest(integration.ShellCase, testprogram.TestProgramCase, integration status, 'EX_USAGE', message='unknown argument', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) # Although the start-up should fail, call shutdown() to set the internal # _shutdown flag and avoid the registered atexit calls to cause timeout @@ -152,10 +150,6 @@ class MasterTest(integration.ShellCase, testprogram.TestProgramCase, integration status, 'EX_OK', message='correct usage', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) master.shutdown() - - -if __name__ == '__main__': - integration.run_tests(MasterTest) diff --git a/tests/integration/shell/test_master_tops.py b/tests/integration/shell/test_master_tops.py index 217eab23cd..32d0bc9d04 100644 --- a/tests/integration/shell/test_master_tops.py +++ b/tests/integration/shell/test_master_tops.py @@ -8,11 +8,7 @@ from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class MasterTopsTest(integration.ShellCase): @@ -26,7 +22,3 @@ class MasterTopsTest(integration.ShellCase): self.assertTrue( any('master_tops_test' in _x for _x in resp) ) - -if __name__ == '__main__': - from integration import run_tests - run_tests(MasterTopsTest) diff --git a/tests/integration/shell/test_matcher.py b/tests/integration/shell/test_matcher.py index 50831d024e..309741dcea 100644 --- a/tests/integration/shell/test_matcher.py +++ b/tests/integration/shell/test_matcher.py @@ -8,11 +8,9 @@ import shutil import time # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils @@ -372,8 +370,3 @@ class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixin): self.chdir(old_cwd) if os.path.isdir(config_dir): shutil.rmtree(config_dir) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MatchTest) diff --git a/tests/integration/shell/test_minion.py b/tests/integration/shell/test_minion.py index 7f1f88b8b1..8cea3697ca 100644 --- a/tests/integration/shell/test_minion.py +++ b/tests/integration/shell/test_minion.py @@ -19,16 +19,15 @@ import shutil import logging # Import Salt Testing libs +import tests.integration as integration +import tests.integration.utils +from tests.integration.utils import testprogram from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +# Import 3rd-party libs +import salt.ext.six as six # Import salt libs -import integration -import integration.utils -from integration.utils import testprogram -import salt.ext.six as six import salt.utils log = logging.getLogger(__name__) @@ -293,7 +292,7 @@ class MinionTest(integration.ShellCase, testprogram.TestProgramCase, integration status, 'EX_NOUSER', message='unknown user not on system', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) # Although the start-up should fail, call shutdown() to set the internal # _shutdown flag and avoid the registered atexit calls to cause timeout @@ -321,7 +320,7 @@ class MinionTest(integration.ShellCase, testprogram.TestProgramCase, integration status, 'EX_USAGE', message='unknown argument', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) # Although the start-up should fail, call shutdown() to set the internal # _shutdown flag and avoid the registered atexit calls to cause timeout @@ -350,7 +349,3 @@ class MinionTest(integration.ShellCase, testprogram.TestProgramCase, integration stdout=stdout, stderr=stderr ) minion.shutdown() - - -if __name__ == '__main__': - integration.run_tests(MinionTest) diff --git a/tests/integration/shell/test_proxy.py b/tests/integration/shell/test_proxy.py index 91b1fff34c..3dc03c9b06 100644 --- a/tests/integration/shell/test_proxy.py +++ b/tests/integration/shell/test_proxy.py @@ -10,14 +10,9 @@ from __future__ import absolute_import import logging -# Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration -import integration.utils -from integration.utils import testprogram +# Import salt tests libs +import tests.integration.utils +from tests.integration.utils import testprogram log = logging.getLogger(__name__) @@ -54,7 +49,7 @@ class ProxyTest(testprogram.TestProgramCase): status, 'EX_USAGE', message='no --proxyid specified', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) # proxy.shutdown() should be unnecessary since the start-up should fail @@ -79,7 +74,7 @@ class ProxyTest(testprogram.TestProgramCase): status, 'EX_NOUSER', message='unknown user not on system', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) # proxy.shutdown() should be unnecessary since the start-up should fail @@ -127,10 +122,6 @@ class ProxyTest(testprogram.TestProgramCase): status, 'EX_OK', message='correct usage', stdout=stdout, - stderr=integration.utils.decode_byte_list(stderr) + stderr=tests.integration.utils.decode_byte_list(stderr) ) proxy.shutdown() - - -if __name__ == '__main__': - integration.run_tests(ProxyTest) diff --git a/tests/integration/shell/test_runner.py b/tests/integration/shell/test_runner.py index f9906f1d40..3a8cfa34b4 100644 --- a/tests/integration/shell/test_runner.py +++ b/tests/integration/shell/test_runner.py @@ -11,13 +11,11 @@ import yaml import shutil # Import Salt Testing libs +import tests.integration as integration +from tests.integration.utils import testprogram from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration -from integration.utils import testprogram import salt.utils USERA = 'saltdev' @@ -211,7 +209,3 @@ class RunTest(integration.ShellCase, testprogram.TestProgramCase, integration.Sh test.arg arg kwarg=kwarg1'.format(USERA, USERA_PWD)) expect = ['The specified external authentication system "wrongeauth" is not available'] self.assertEqual(expect, run_cmd) - - -if __name__ == '__main__': - integration.run_tests(RunTest) diff --git a/tests/integration/shell/test_saltcli.py b/tests/integration/shell/test_saltcli.py index 2fbef8b3d4..2509e252a9 100644 --- a/tests/integration/shell/test_saltcli.py +++ b/tests/integration/shell/test_saltcli.py @@ -14,12 +14,7 @@ from __future__ import absolute_import import logging # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration -from integration.utils import testprogram +from tests.integration.utils import testprogram log = logging.getLogger(__name__) @@ -74,7 +69,3 @@ class SaltTest(testprogram.TestProgramCase): message='correct usage', stdout=stdout, stderr=stderr ) - - -if __name__ == '__main__': - integration.run_tests(SaltTest) diff --git a/tests/integration/shell/test_syndic.py b/tests/integration/shell/test_syndic.py index 453677a83d..9d50d4f720 100644 --- a/tests/integration/shell/test_syndic.py +++ b/tests/integration/shell/test_syndic.py @@ -16,12 +16,10 @@ import shutil import logging # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration +from tests.integration.utils import testprogram # Import salt libs -import integration -from integration.utils import testprogram import salt.utils @@ -159,7 +157,3 @@ class SyndicTest(integration.ShellCase, testprogram.TestProgramCase, integration stdout=stdout, stderr=stderr ) syndic.shutdown() - - -if __name__ == '__main__': - integration.run_tests(SyndicTest) diff --git a/tests/integration/ssh/test_deploy.py b/tests/integration/ssh/test_deploy.py index f2ac34e659..27b38327d5 100644 --- a/tests/integration/ssh/test_deploy.py +++ b/tests/integration/ssh/test_deploy.py @@ -5,13 +5,9 @@ salt-ssh testing # Import Python libs from __future__ import absolute_import -# Import salttesting libs +# Import salt testing libs from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import Salt libs -import integration +import tests.integration as integration @skipIf(True, 'Not ready for production') diff --git a/tests/integration/states/test_alternatives.py b/tests/integration/states/test_alternatives.py index e00363d0a6..94052d89ab 100644 --- a/tests/integration/states/test_alternatives.py +++ b/tests/integration/states/test_alternatives.py @@ -8,12 +8,9 @@ from __future__ import absolute_import import os # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import destructiveTest, ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +from tests.support.helpers import destructiveTest NO_ALTERNATIVES = False if not os.path.exists('/etc/alternatives'): diff --git a/tests/integration/states/test_archive.py b/tests/integration/states/test_archive.py index 5dd59f4b29..b6f55f8e6b 100644 --- a/tests/integration/states/test_archive.py +++ b/tests/integration/states/test_archive.py @@ -14,12 +14,10 @@ import tornado.ioloop import tornado.web # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils # Setup logging @@ -202,8 +200,3 @@ class ArchiveTest(integration.ModuleCase, self.assertSaltTrueReturn(ret) self._check_extracted(UNTAR_FILE) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ArchiveTest) diff --git a/tests/integration/states/test_boto_sns.py b/tests/integration/states/test_boto_sns.py index 9ab2b343b7..92fff7cd2a 100644 --- a/tests/integration/states/test_boto_sns.py +++ b/tests/integration/states/test_boto_sns.py @@ -8,12 +8,8 @@ from __future__ import absolute_import import re # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import Salt libs -import integration # Import 3rd-party libs NO_BOTO_MODULE = True diff --git a/tests/integration/states/test_bower.py b/tests/integration/states/test_bower.py index a8b8142b2c..bec140e208 100644 --- a/tests/integration/states/test_bower.py +++ b/tests/integration/states/test_bower.py @@ -7,12 +7,11 @@ from __future__ import absolute_import import json # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import destructiveTest, ensure_in_syspath -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils @@ -74,8 +73,3 @@ class BowerStateTest(integration.ModuleCase, self.assertSaltTrueReturn(ret) ret = self.run_state('file.absent', name='/salt_test_bower_3') self.assertSaltTrueReturn(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BowerStateTest) diff --git a/tests/integration/states/test_cmd.py b/tests/integration/states/test_cmd.py index d6c2130657..bf81a1626c 100644 --- a/tests/integration/states/test_cmd.py +++ b/tests/integration/states/test_cmd.py @@ -10,11 +10,9 @@ import textwrap import tempfile # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils IS_WINDOWS = salt.utils.is_windows() @@ -194,8 +192,3 @@ class CMDRunWatchTest(integration.ModuleCase, ret = self.run_function('state.sls', [self.state_name]) self.assertTrue(ret[saltines_key]['result']) self.assertTrue(ret[biscuits_key]['result']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests([CMDTest, CMDRunRedirectTest, CMDRunWatchTest]) diff --git a/tests/integration/states/test_compiler.py b/tests/integration/states/test_compiler.py index fe9047b228..6f5bf43efb 100644 --- a/tests/integration/states/test_compiler.py +++ b/tests/integration/states/test_compiler.py @@ -7,11 +7,7 @@ tests for host state from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class CompileTest(integration.ModuleCase): @@ -36,8 +32,3 @@ class CompileTest(integration.ModuleCase): ', in jinja_error' in ret[0].strip()) self.assertTrue( ret[0].strip().endswith('Exception: hehehe')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CompileTest) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index 6b856ccafd..b496e7e577 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -19,17 +19,14 @@ import textwrap import filecmp # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, with_system_user_and_group ) -ensure_in_syspath('../../') - # Import salt libs -import integration import salt.utils HAS_PWD = True @@ -2437,7 +2434,3 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): check_file = self.run_function('file.file_exists', [file]) if check_file: self.run_function('file.remove', [file]) - -if __name__ == '__main__': - from integration import run_tests - run_tests(FileTest) diff --git a/tests/integration/states/test_git.py b/tests/integration/states/test_git.py index 7de11b629e..d54fe81e4f 100644 --- a/tests/integration/states/test_git.py +++ b/tests/integration/states/test_git.py @@ -14,11 +14,10 @@ import subprocess import tempfile # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing -ensure_in_syspath('../../') +import tests.integration as integration +from tests.support.helpers import skip_if_binaries_missing # Import salt libs -import integration import salt.utils @@ -603,8 +602,3 @@ class LocalRepoGitTest(integration.ModuleCase, integration.SaltReturnAssertsMixI all([x in string.hexdigits for x in ret[next(iter(ret))]['changes']['revision']['new']]) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GitTest) diff --git a/tests/integration/states/test_handle_error.py b/tests/integration/states/test_handle_error.py index 713fdb2ddd..1d43860c49 100644 --- a/tests/integration/states/test_handle_error.py +++ b/tests/integration/states/test_handle_error.py @@ -7,11 +7,7 @@ tests for host state from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class HandleErrorTest(integration.ModuleCase): @@ -29,8 +25,3 @@ class HandleErrorTest(integration.ModuleCase): self.assertTrue( 'An exception occurred in this state: Traceback' in ret[[a for a in ret][0]]['comment']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HandleErrorTest) diff --git a/tests/integration/states/test_handle_iorder.py b/tests/integration/states/test_handle_iorder.py index 8abd515b9e..9df8d5ff61 100644 --- a/tests/integration/states/test_handle_iorder.py +++ b/tests/integration/states/test_handle_iorder.py @@ -7,11 +7,7 @@ tests for host state from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class HandleOrderTest(integration.ModuleCase): @@ -29,8 +25,3 @@ class HandleOrderTest(integration.ModuleCase): self.assertEqual(sorted_chunks[0]['name'], './configure') self.assertEqual(sorted_chunks[1]['name'], 'make') self.assertEqual(sorted_chunks[2]['name'], 'make install') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HandleOrderTest) diff --git a/tests/integration/states/test_host.py b/tests/integration/states/test_host.py index 9196d63c98..4ce2e9823a 100644 --- a/tests/integration/states/test_host.py +++ b/tests/integration/states/test_host.py @@ -9,11 +9,9 @@ import os import shutil # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +import tests.integration as integration # Import salt libs -import integration import salt.utils HFILE = os.path.join(integration.TMP, 'hosts') @@ -44,8 +42,3 @@ class HostTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): with salt.utils.fopen(HFILE) as fp_: output = fp_.read() self.assertIn('{0}\t\t{1}'.format(ip, name), output) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HostTest) diff --git a/tests/integration/states/test_keystone.py b/tests/integration/states/test_keystone.py index 73a2fe7efa..9615bad6b3 100644 --- a/tests/integration/states/test_keystone.py +++ b/tests/integration/states/test_keystone.py @@ -8,15 +8,10 @@ from __future__ import absolute_import import logging # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest -# Import salt libs -import integration log = logging.getLogger(__name__) NO_KEYSTONE = False @@ -209,8 +204,3 @@ class KeystoneStateTest(integration.ModuleCase, name='testv3', profile='adminv3') self.assertTrue(ret['keystone_|-testv3_|-testv3_|-service_absent']['result']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeystoneStateTest) diff --git a/tests/integration/states/test_match.py b/tests/integration/states/test_match.py index 4909a6dce3..b06c245ce1 100644 --- a/tests/integration/states/test_match.py +++ b/tests/integration/states/test_match.py @@ -12,12 +12,10 @@ from __future__ import absolute_import import os # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils STATE_DIR = os.path.join(integration.FILES, 'file', 'base') @@ -50,8 +48,3 @@ class StateMatchTest(integration.ModuleCase): ) finally: os.remove(top_file) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StateMatchTest) diff --git a/tests/integration/states/test_mysql.py b/tests/integration/states/test_mysql.py index 7b0198e9be..f9fe2abd93 100644 --- a/tests/integration/states/test_mysql.py +++ b/tests/integration/states/test_mysql.py @@ -8,15 +8,11 @@ from __future__ import absolute_import import logging # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils import salt.ext.six as six from salt.modules import mysql as mysqlmod @@ -502,8 +498,3 @@ class MysqlGrantsStateTest(integration.ModuleCase, connection_charset='utf8' ) self.assertSaltTrueReturn(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MysqlDatabaseStateTest, MysqlGrantsStateTest) diff --git a/tests/integration/states/test_network.py b/tests/integration/states/test_network.py index 7ed7d43b5d..abb06a75b0 100644 --- a/tests/integration/states/test_network.py +++ b/tests/integration/states/test_network.py @@ -8,13 +8,9 @@ # Python libs from __future__ import absolute_import -# Salt libs -import integration - -# Salttesting libs -from tests.support.helpers import destructiveTest, ensure_in_syspath - -ensure_in_syspath('../../') +# Import salt testing libs +import tests.integration as integration +from tests.support.helpers import destructiveTest @destructiveTest @@ -55,8 +51,3 @@ class NetworkTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): ret = self.run_function('state.sls', mods='network.system', test=True) self.assertIn('Global network settings are set to be updated:', ret[state_key]['comment']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetworkTest) diff --git a/tests/integration/states/test_npm.py b/tests/integration/states/test_npm.py index 289e5f58ba..ad33539f8b 100644 --- a/tests/integration/states/test_npm.py +++ b/tests/integration/states/test_npm.py @@ -8,12 +8,11 @@ from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import destructiveTest, ensure_in_syspath, requires_network -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest, requires_network # Import salt libs -import integration import salt.utils @@ -60,8 +59,3 @@ class NpmStateTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): ''' ret = self.run_state('npm.cache_cleaned', name=None) self.assertSaltTrueReturn(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NpmStateTest) diff --git a/tests/integration/states/test_pip.py b/tests/integration/states/test_pip.py index f94081e414..3623b674a2 100644 --- a/tests/integration/states/test_pip.py +++ b/tests/integration/states/test_pip.py @@ -23,7 +23,7 @@ from tests.support.helpers import ( with_system_user ) # Import salt libs -import integration +import tests.integration as integration import salt.utils from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES from salt.exceptions import CommandExecutionError diff --git a/tests/integration/states/test_pkg.py b/tests/integration/states/test_pkg.py index 098b67b592..26492e59af 100644 --- a/tests/integration/states/test_pkg.py +++ b/tests/integration/states/test_pkg.py @@ -10,17 +10,15 @@ import os import time # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains, requires_salt_modules ) -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils # Import 3rd-party libs @@ -697,7 +695,3 @@ class PkgTest(integration.ModuleCase, self.assertEqual(ret_comment, 'An error was encountered while installing/updating group ' '\'handle_missing_pkg_group\': Group \'handle_missing_pkg_group\' ' 'not found.') - -if __name__ == '__main__': - from integration import run_tests - run_tests(PkgTest) diff --git a/tests/integration/states/test_pkgrepo.py b/tests/integration/states/test_pkgrepo.py index f7dc893288..15be430668 100644 --- a/tests/integration/states/test_pkgrepo.py +++ b/tests/integration/states/test_pkgrepo.py @@ -7,16 +7,14 @@ tests for pkgrepo states from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, requires_system_grains ) -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils # Import 3rd-party libs @@ -80,8 +78,3 @@ class PkgrepoTest(integration.ModuleCase, self.assertReturnNonEmptySaltType(ret) for state_id, state_result in six.iteritems(ret): self.assertSaltTrueReturn(dict([(state_id, state_result)])) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PkgrepoTest) diff --git a/tests/integration/states/test_rabbitmq_user.py b/tests/integration/states/test_rabbitmq_user.py index bf67efdbd6..4e31c1f076 100644 --- a/tests/integration/states/test_rabbitmq_user.py +++ b/tests/integration/states/test_rabbitmq_user.py @@ -7,11 +7,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class RabbitUserTestCase(integration.ModuleCase, @@ -46,8 +42,3 @@ class RabbitUserTestCase(integration.ModuleCase, 'rabbitmq_user.absent', name='null_name', test=True ) self.assertSaltFalseReturn(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitUserTestCase) diff --git a/tests/integration/states/test_rabbitmq_vhost.py b/tests/integration/states/test_rabbitmq_vhost.py index 9c54899bb3..c05b15859b 100644 --- a/tests/integration/states/test_rabbitmq_vhost.py +++ b/tests/integration/states/test_rabbitmq_vhost.py @@ -8,11 +8,7 @@ from __future__ import absolute_import import os # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class RabbitVHostTestCase(integration.ModuleCase, @@ -46,8 +42,3 @@ class RabbitVHostTestCase(integration.ModuleCase, 'rabbitmq_vhost.absent', name='null_host', test=True ) self.assertSaltFalseReturn(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitVHostTestCase) diff --git a/tests/integration/states/test_renderers.py b/tests/integration/states/test_renderers.py index fcf89808a9..cacc4e0b24 100644 --- a/tests/integration/states/test_renderers.py +++ b/tests/integration/states/test_renderers.py @@ -7,11 +7,7 @@ Integration tests for renderer functions from __future__ import absolute_import # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import Salt Libs -import integration +import tests.integration as integration class TestJinjaRenderer(integration.ModuleCase): @@ -25,8 +21,3 @@ class TestJinjaRenderer(integration.ModuleCase): ret = self.run_function('state.sls', ['jinja_dot_notation']) for state_ret in ret.values(): self.assertTrue(state_ret['result']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestJinjaRenderer) diff --git a/tests/integration/states/test_service.py b/tests/integration/states/test_service.py index 3cddeed42b..b64a76b514 100644 --- a/tests/integration/states/test_service.py +++ b/tests/integration/states/test_service.py @@ -6,15 +6,11 @@ Tests for the service state from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - ensure_in_syspath, - destructiveTest -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils INIT_DELAY = 5 @@ -60,7 +56,3 @@ class ServiceTest(integration.ModuleCase, init_delay=INIT_DELAY) self.assertSaltTrueReturn(ret) self.check_service_status(False) - -if __name__ == '__main__': - from integration import run_tests - run_tests(ServiceTest) diff --git a/tests/integration/states/test_ssh.py b/tests/integration/states/test_ssh.py index 36c357bd21..ba2b29e7f8 100644 --- a/tests/integration/states/test_ssh.py +++ b/tests/integration/states/test_ssh.py @@ -9,17 +9,15 @@ import os import shutil # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import ( destructiveTest, - ensure_in_syspath, with_system_user, skip_if_binaries_missing ) -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils KNOWN_HOSTS = os.path.join(integration.TMP, 'known_hosts') @@ -251,8 +249,3 @@ class SSHAuthStateTests(integration.ModuleCase, fhr.read(), 'ssh-rsa AAAAB3NzaC1kcQ9J5bYTEyZ== {0}\n'.format(username) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests([SSHKnownHostsStateTest, SSHAuthStateTests]) diff --git a/tests/integration/states/test_supervisord.py b/tests/integration/states/test_supervisord.py index d48c943f45..7c19c7bfa8 100644 --- a/tests/integration/states/test_supervisord.py +++ b/tests/integration/states/test_supervisord.py @@ -11,12 +11,10 @@ import time import subprocess # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES @@ -255,8 +253,3 @@ class SupervisordTest(integration.ModuleCase, bin_env=self.venv_dir, conf_file=self.supervisor_conf ) self.assertSaltTrueReturn(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SupervisordTest) diff --git a/tests/integration/states/test_svn.py b/tests/integration/states/test_svn.py index 4fb9d28ce6..9cd702d095 100644 --- a/tests/integration/states/test_svn.py +++ b/tests/integration/states/test_svn.py @@ -11,11 +11,7 @@ import shutil import socket # Import Salt Testing libs -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - -# Import salt libs -import integration +import tests.integration as integration class SvnTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): @@ -142,8 +138,3 @@ class SvnTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): self.assertSaltTrueReturn(ret) self.assertSaltStateChangesEqual(ret, {}) self.assertTrue(os.path.isdir(os.path.join(self.target, '.svn'))) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SvnTest) diff --git a/tests/integration/states/test_user.py b/tests/integration/states/test_user.py index 28eca85c6a..1a3b48988b 100644 --- a/tests/integration/states/test_user.py +++ b/tests/integration/states/test_user.py @@ -15,17 +15,12 @@ from random import randint import grp # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - ensure_in_syspath, - requires_system_grains -) -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest, requires_system_grains # Import salt libs import salt.utils -import integration if salt.utils.is_darwin(): USER = 'macuser' @@ -263,7 +258,3 @@ class UserTest(integration.ModuleCase, check_user = self.run_function('user.list_users') if USER in check_user: del_user = self.run_function('user.delete', [USER], remove=True) - -if __name__ == '__main__': - from integration import run_tests - run_tests(UserTest) diff --git a/tests/integration/states/test_virtualenv.py b/tests/integration/states/test_virtualenv.py index 186b554c0b..8f00cafe1c 100644 --- a/tests/integration/states/test_virtualenv.py +++ b/tests/integration/states/test_virtualenv.py @@ -13,12 +13,11 @@ import os import shutil # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import destructiveTest, ensure_in_syspath -ensure_in_syspath('../../') +from tests.support.helpers import destructiveTest # Import salt libs -import integration import salt.utils from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES @@ -138,8 +137,3 @@ class VirtualenvTest(integration.ModuleCase, shutil.rmtree(venv_path) if os.path.exists(requirements_file_path): os.unlink(requirements_file_path) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VirtualenvTest) diff --git a/tests/integration/utils/test_reactor.py b/tests/integration/utils/test_reactor.py index ab3576055d..cb6a42597b 100644 --- a/tests/integration/utils/test_reactor.py +++ b/tests/integration/utils/test_reactor.py @@ -8,7 +8,7 @@ import os from contextlib import contextmanager -import integration +import tests.integration as integration from salt.utils.process import clean_proc from salt.utils import event diff --git a/tests/integration/utils/testprogram.py b/tests/integration/utils/testprogram.py index 48b4927750..a41feb0e5e 100644 --- a/tests/integration/utils/testprogram.py +++ b/tests/integration/utils/testprogram.py @@ -28,7 +28,8 @@ import salt.ext.six as six from tests.support.unit import TestCase -import integration +import tests.integration as integration +from tests.support.processes import terminate_process log = logging.getLogger(__name__) @@ -770,11 +771,11 @@ class TestDaemon(TestProgram): if not self._shutdown: try: pid = self.wait_for_daemon_pid(timeout) - integration.terminate_process_pid(pid) + terminate_process(pid=pid) except TimeoutError: pass if self.process: - integration.terminate_process_pid(self.process.pid) + terminate_process(pid=self.process.pid) self.process.wait() self.process = None self._shutdown = True diff --git a/tests/integration/wheel/test_client.py b/tests/integration/wheel/test_client.py index 7de272fa77..f405eb027f 100644 --- a/tests/integration/wheel/test_client.py +++ b/tests/integration/wheel/test_client.py @@ -4,7 +4,7 @@ from __future__ import absolute_import # Import Salt Testing libs -import integration +import tests.integration as integration from tests.support.unit import skipIf # Import Salt libs @@ -111,8 +111,3 @@ class WheelModuleTest(integration.TestCase, integration.AdaptedConfigurationTest } self.wheel.cmd_sync(low) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WheelModuleTest, needs_daemon=True) diff --git a/tests/integration/wheel/test_key.py b/tests/integration/wheel/test_key.py index 64185ca057..19939424dd 100644 --- a/tests/integration/wheel/test_key.py +++ b/tests/integration/wheel/test_key.py @@ -2,7 +2,7 @@ # Import Salt Testing libs from __future__ import absolute_import -import integration +import tests.integration as integration # Import Salt libs import salt.wheel @@ -26,7 +26,3 @@ class KeyWheelModuleTest(integration.TestCase, integration.AdaptedConfigurationT ret.get('pub', '').startswith('-----BEGIN PUBLIC KEY-----')) self.assertTrue( ret.get('priv', '').startswith('-----BEGIN RSA PRIVATE KEY-----')) - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeyWheelModuleTest, needs_daemon=True) diff --git a/tests/support/helpers.py b/tests/support/helpers.py index a67973f471..d1fa0a413f 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -362,52 +362,6 @@ def relative_import(import_name, relative_from='../'): return __import__(import_name) -def ensure_in_syspath(*ensure_paths): - ''' - Make sure that any path passed in `ensure_paths` exists in sys.path - ''' - - previous_frame = None - - for ensure_path in ensure_paths: - if ensure_path in sys.path: - # If it's already in sys.path, nothing to do - continue - - # We reached here? Then ensure_path is not present in sys.path - if os.path.isabs(ensure_path): - # It's an absolute path? Then include it in sys.path - sys.path.insert(0, ensure_path) - continue - - # If we reached here, it means it's a relative path. Lets compute the - # relation into a real path - if previous_frame is None: - previous_frame = inspect.getframeinfo( - inspect.currentframe().f_back - ) - - realpath = os.path.realpath( - os.path.join( - os.path.abspath( - os.path.dirname(previous_frame.filename) - ), - ensure_path - ) - ) - - if not os.path.exists(realpath): - # The path does not exist? Don't even inject it into sys.path - continue - - if realpath in sys.path: - # The path is already present in sys.path? Nothing else to do. - continue - - # Inject the computed path into sys.path - sys.path.insert(0, realpath) - - class ForceImportErrorOn(object): ''' This class is meant to be used in mock'ed test cases which require an diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index d6649135f6..e2516e06a4 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -8,22 +8,7 @@ from __future__ import absolute_import from tests.support.case import TestCase from tests.support.parser import SaltTestcaseParser -__all__ = ['run_tests', 'ModuleTestCase'] - - -def run_tests(*test_cases, **kwargs): - ''' - Run unit tests for the chosen test cases. - - :param test_cases: The list of test cases to execute - :type test_cases: ``list`` of :class:`TestCase` - ''' - parser = SaltTestcaseParser() - parser.parse_args() - for case in test_cases: - if parser.run_testcase(case) is False: - parser.finalize(1) - parser.finalize(0) +__all__ = ['ModuleTestCase'] def hasDependency(module, fake_module=None): diff --git a/tests/unit/beacons/test_adb_beacon.py b/tests/unit/beacons/test_adb_beacon.py index b41342a125..f22b19af72 100644 --- a/tests/unit/beacons/test_adb_beacon.py +++ b/tests/unit/beacons/test_adb_beacon.py @@ -3,20 +3,16 @@ # Python libs from __future__ import absolute_import +# Salt testing libs +from tests.support.unit import skipIf, TestCase +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock + # Salt libs from salt.beacons import adb -# Salt testing libs -from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath -from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, Mock - # Globals - adb.__salt__ = {} -ensure_in_syspath('../../') - @skipIf(NO_MOCK, NO_MOCK_REASON) class ADBBeaconTestCase(TestCase): diff --git a/tests/unit/beacons/test_inotify_beacon.py b/tests/unit/beacons/test_inotify_beacon.py index 4b0e560e1e..64473ffefc 100644 --- a/tests/unit/beacons/test_inotify_beacon.py +++ b/tests/unit/beacons/test_inotify_beacon.py @@ -11,7 +11,7 @@ from salt.beacons import inotify # Salt testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import destructiveTest, ensure_in_syspath +from tests.support.helpers import destructiveTest from tests.support.mock import NO_MOCK, NO_MOCK_REASON # Third-party libs @@ -22,9 +22,6 @@ except ImportError: HAS_PYINOTIFY = False -ensure_in_syspath('../../') - - @skipIf(not HAS_PYINOTIFY, 'pyinotify is not available') @skipIf(NO_MOCK, NO_MOCK_REASON) class INotifyBeaconTestCase(TestCase): @@ -168,8 +165,3 @@ class INotifyBeaconTestCase(TestCase): finally: if tmpdir: shutil.rmtree(tmpdir) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(INotifyBeaconTestCase, needs_daemon=False) diff --git a/tests/unit/cache/test_localfs.py b/tests/unit/cache/test_localfs.py index 87f203873d..82443b4825 100644 --- a/tests/unit/cache/test_localfs.py +++ b/tests/unit/cache/test_localfs.py @@ -9,7 +9,7 @@ import shutil import tempfile # Import Salt Testing libs -import integration +import tests.integration as integration from tests.support.unit import skipIf, TestCase from tests.support.mock import ( MagicMock, diff --git a/tests/unit/cloud/clouds/test_dimensiondata.py b/tests/unit/cloud/clouds/test_dimensiondata.py index 33525aa163..147d4f5afe 100644 --- a/tests/unit/cloud/clouds/test_dimensiondata.py +++ b/tests/unit/cloud/clouds/test_dimensiondata.py @@ -24,9 +24,6 @@ from salt.exceptions import SaltCloudSystemExit # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../../') # Global Variables dimensiondata.__active_provider_name__ = '' @@ -161,7 +158,3 @@ class DimensionDataTestCase(ExtendedTestCase): """ p = dimensiondata.get_configured_provider() self.assertNotEqual(p, None) - -if __name__ == '__main__': - from integration import run_tests - run_tests(DimensionDataTestCase, needs_daemon=False) diff --git a/tests/unit/cloud/clouds/test_gce.py b/tests/unit/cloud/clouds/test_gce.py index 5da051628f..933fdcf13b 100644 --- a/tests/unit/cloud/clouds/test_gce.py +++ b/tests/unit/cloud/clouds/test_gce.py @@ -24,9 +24,6 @@ from salt.exceptions import SaltCloudSystemExit # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../../') # Global Variables gce.__active_provider_name__ = '' @@ -106,7 +103,3 @@ class GCETestCase(TestCase): """ p = gce.get_configured_provider() self.assertNotEqual(p, None) - -if __name__ == '__main__': - from unit import run_tests - run_tests(GCETestCase, needs_daemon=False) diff --git a/tests/unit/cloud/clouds/test_joyent.py b/tests/unit/cloud/clouds/test_joyent.py index b2e17be994..abdd545cba 100644 --- a/tests/unit/cloud/clouds/test_joyent.py +++ b/tests/unit/cloud/clouds/test_joyent.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -19,8 +18,6 @@ from tests.support.mock import ( # Import Salt Libs from salt.cloud.clouds import joyent -ensure_in_syspath('../../../') - # Globals joyent.__utils__ = dict() joyent.__opts__ = dict() @@ -98,8 +95,3 @@ class JoyentTestCase(TestCase): result = joyent.query_instance(self.vm_) self.assertTrue(joyent.__utils__['cloud.fire_event'].called_once()) self.assertEqual(result, '1.1.1.1') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(JoyentTestCase, needs_daemon=False) diff --git a/tests/unit/cloud/clouds/test_linode.py b/tests/unit/cloud/clouds/test_linode.py index 6bc357eb13..4db4a94500 100644 --- a/tests/unit/cloud/clouds/test_linode.py +++ b/tests/unit/cloud/clouds/test_linode.py @@ -9,9 +9,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../../') # Import Salt Libs from salt.cloud.clouds import linode @@ -101,8 +98,3 @@ class LinodeTestCase(TestCase): # Test when name start and end with numbers self.assertTrue(linode._validate_name('1foo')) self.assertTrue(linode._validate_name('foo0')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LinodeTestCase, needs_daemon=False) diff --git a/tests/unit/cloud/clouds/test_opennebula.py b/tests/unit/cloud/clouds/test_opennebula.py index ab969c75d0..8d5da5b344 100644 --- a/tests/unit/cloud/clouds/test_opennebula.py +++ b/tests/unit/cloud/clouds/test_opennebula.py @@ -9,9 +9,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../../') # Import Salt Libs from salt.cloud.clouds import opennebula @@ -1645,8 +1642,3 @@ class OpenNebulaTestCase(TestCase): opennebula._get_xml, "[VirtualMachinePoolInfo] User couldn't be" " authenticated, aborting call.") - - -if __name__ == '__main__': - from integration import run_tests - run_tests(OpenNebulaTestCase, needs_daemon=False) diff --git a/tests/unit/cloud/clouds/test_saltify.py b/tests/unit/cloud/clouds/test_saltify.py index 7c8069c435..dd5b3497a4 100644 --- a/tests/unit/cloud/clouds/test_saltify.py +++ b/tests/unit/cloud/clouds/test_saltify.py @@ -35,8 +35,3 @@ class SaltifyTestCase(TestCase): 'name': 'dummy' } self.assertTrue(saltify.create(vm)['Error']['No Deploy']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SaltifyTestCase, needs_daemon=False) diff --git a/tests/unit/cloud/clouds/test_vmware.py b/tests/unit/cloud/clouds/test_vmware.py index 781e31bbd3..2b38359031 100644 --- a/tests/unit/cloud/clouds/test_vmware.py +++ b/tests/unit/cloud/clouds/test_vmware.py @@ -13,12 +13,9 @@ from copy import deepcopy # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath -from salt import config - -ensure_in_syspath('../../../') # Import Salt Libs +from salt import config from salt.cloud.clouds import vmware from salt.exceptions import SaltCloudSystemExit @@ -1274,8 +1271,3 @@ class CloneFromSnapshotTest(TestCase): 'disk_move_type': clone_type}}) self.assertEqual(clone_spec2.location.diskMoveType, clone_type) - -if __name__ == '__main__': - from integration import run_tests - run_tests(VMwareTestCase, needs_daemon=False) - run_tests(CloneFromSnapshotTest, needs_daemon=False) diff --git a/tests/unit/cloud/test_libcloud.py b/tests/unit/cloud/test_libcloud.py index 143c0f9f03..d3f1250a9b 100644 --- a/tests/unit/cloud/test_libcloud.py +++ b/tests/unit/cloud/test_libcloud.py @@ -15,11 +15,6 @@ from tests.support.unit import TestCase # Import Salt Libs import salt.cloud.libcloudfuncs as libcloud -# Import Salt Testing Libs -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - class LibcloudTestCase(TestCase): def test_node_state_libcloud_020(self): @@ -29,8 +24,3 @@ class LibcloudTestCase(TestCase): def test_node_state_libcloud_100(self): state = libcloud.node_state('terminated') self.assertEqual('TERMINATED', state) - - -if __name__ == '__main__': - from unit import run_tests - run_tests(LibcloudTestCase, needs_daemon=False) diff --git a/tests/unit/config/schemas/test_ssh.py b/tests/unit/config/schemas/test_ssh.py index ee6990a797..91cd1d05c2 100644 --- a/tests/unit/config/schemas/test_ssh.py +++ b/tests/unit/config/schemas/test_ssh.py @@ -11,9 +11,6 @@ from distutils.version import LooseVersion as _LooseVersion # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.config.schemas import ssh as ssh_schemas diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index 19700c4d88..74223e9e16 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -22,7 +22,7 @@ from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch import salt.minion import salt.utils import salt.utils.network -import integration +import tests.integration as integration from salt.syspaths import CONFIG_DIR from salt import config as sconfig from salt.exceptions import ( diff --git a/tests/unit/engines/test_sqs_events.py b/tests/unit/engines/test_sqs_events.py index fb2a61aec4..d293a863e9 100644 --- a/tests/unit/engines/test_sqs_events.py +++ b/tests/unit/engines/test_sqs_events.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.engines import sqs_events @@ -77,8 +73,3 @@ class EngineSqsEventTestCase(TestCase): sqs_events._process_queue(q, q_name, mock_fire) self.assertTrue(mock_sqs.queue.Queue().get_messages.called, len(msgs)) self.assertTrue(mock_fire.called, len(msgs)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EngineSqsEventTestCase, needs_daemon=False) diff --git a/tests/unit/fileserver/test_gitfs.py b/tests/unit/fileserver/test_gitfs.py index 26c83d8e74..c29dfef0de 100644 --- a/tests/unit/fileserver/test_gitfs.py +++ b/tests/unit/fileserver/test_gitfs.py @@ -19,7 +19,7 @@ except ImportError: # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -import integration +import tests.integration as integration # Import salt libs import salt.utils.gitfs diff --git a/tests/unit/modules/test_aliases.py b/tests/unit/modules/test_aliases.py index 1e0d7dde20..b1d7befd22 100644 --- a/tests/unit/modules/test_aliases.py +++ b/tests/unit/modules/test_aliases.py @@ -13,9 +13,6 @@ from salt.exceptions import SaltInvocationError # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -166,8 +163,3 @@ class AliasesTestCase(TestCase): ''' ret = aliases.rm_alias('foo') self.assertTrue(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AliasesTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_alternatives.py b/tests/unit/modules/test_alternatives.py index 31a4c892a0..17e9d9cab5 100644 --- a/tests/unit/modules/test_alternatives.py +++ b/tests/unit/modules/test_alternatives.py @@ -12,11 +12,9 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath, TestsLoggingHandler +from tests.support.helpers import TestsLoggingHandler from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') - # Import salt libs from salt.modules import alternatives @@ -196,8 +194,3 @@ class AlternativesTestCase(TestCase): ['alternatives', '--remove', 'better-world', '/usr/bin/better-world'], python_shell=False ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AlternativesTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_apache.py b/tests/unit/modules/test_apache.py index 1ab8afb05b..e297d4fc3e 100644 --- a/tests/unit/modules/test_apache.py +++ b/tests/unit/modules/test_apache.py @@ -204,8 +204,3 @@ class ApacheTestCase(TestCase): with patch('salt.utils.fopen', mock_open()): self.assertEqual(apache.config('/ports.conf', [{'Listen': '22'}]), 'Listen 22') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ApacheTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_aptpkg.py b/tests/unit/modules/test_aptpkg.py index 4b82685e7a..902bb9dcf1 100644 --- a/tests/unit/modules/test_aptpkg.py +++ b/tests/unit/modules/test_aptpkg.py @@ -16,7 +16,6 @@ from salt.modules import aptpkg # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -24,8 +23,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Globals aptpkg.__salt__ = {} aptpkg.__context__ = {} @@ -344,8 +341,3 @@ class AptPkgTestCase(TestCase): } with patch.multiple(aptpkg, **patch_kwargs): self.assertEqual(aptpkg.upgrade(), dict()) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(AptPkgTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_archive.py b/tests/unit/modules/test_archive.py index 98915fbdb7..2eaaf29d65 100644 --- a/tests/unit/modules/test_archive.py +++ b/tests/unit/modules/test_archive.py @@ -12,16 +12,16 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from salt.ext.six.moves import zip -ensure_in_syspath('../../') # Import salt libs from salt.modules import archive from salt.exceptions import CommandNotFoundError from salt.utils import which_bin +# Import 3rd-party libs +from salt.ext.six.moves import zip + class ZipFileMock(MagicMock): def __init__(self, files=None, **kwargs): # pylint: disable=W0231 @@ -443,8 +443,3 @@ class ArchiveTestCase(TestCase): with patch.dict(archive.__salt__, {'cmd.run': MagicMock(return_value=test_files)}): ret = archive.unrar(source, tmp_dir, trim_output=test_trim_opts) self.assertEqual(ret, test_expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ArchiveTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_artifactory.py b/tests/unit/modules/test_artifactory.py index b92c7043c2..6440ba15a9 100644 --- a/tests/unit/modules/test_artifactory.py +++ b/tests/unit/modules/test_artifactory.py @@ -6,8 +6,6 @@ from __future__ import absolute_import # Import Salt testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import Salt libs from salt.modules import artifactory diff --git a/tests/unit/modules/test_at.py b/tests/unit/modules/test_at.py index bbe3c60e4f..e388d327b4 100644 --- a/tests/unit/modules/test_at.py +++ b/tests/unit/modules/test_at.py @@ -199,7 +199,3 @@ class AtTestCase(TestCase): with patch.object(at, '_cmd', return_value='101\tThu Dec 11 19:48:47 2014 A B'): self.assertEqual(at.atc(101), '101\tThu Dec 11 19:48:47 2014 A B') - -if __name__ == '__main__': - from integration import run_tests - run_tests(AtTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_augeas_cfg.py b/tests/unit/modules/test_augeas_cfg.py index 705c1a0b7e..5316c3067c 100644 --- a/tests/unit/modules/test_augeas_cfg.py +++ b/tests/unit/modules/test_augeas_cfg.py @@ -148,8 +148,3 @@ class AugeasCfgTestCase(TestCase): Test if it returns recursively the complete tree of a node ''' self.assertEqual(augeas_cfg.tree('/etc/'), {'/etc': None}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AugeasCfgTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_bluez.py b/tests/unit/modules/test_bluez.py index 4f6fa18ce9..9f124e01c1 100644 --- a/tests/unit/modules/test_bluez.py +++ b/tests/unit/modules/test_bluez.py @@ -208,7 +208,3 @@ class BluezTestCase(TestCase): mock = MagicMock(return_value="Ok") with patch.dict(bluez.__salt__, {'service.stop': mock}): self.assertEqual(bluez.stop(), "Ok") - -if __name__ == '__main__': - from integration import run_tests - run_tests(BluezTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_apigateway.py b/tests/unit/modules/test_boto_apigateway.py index e26134b320..acb3919958 100644 --- a/tests/unit/modules/test_boto_apigateway.py +++ b/tests/unit/modules/test_boto_apigateway.py @@ -11,9 +11,6 @@ import string # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.loader @@ -1645,7 +1642,3 @@ class BotoApiGatewayTestCase(BotoApiGatewayTestCaseBase, BotoApiGatewayTestCaseM result = boto_apigateway.detach_usage_plan_from_apis(plan_id='plan1_id', apis=[api], **conn_parameters) self.assertEqual(result.get('success'), True) self.assertEqual(result.get('result'), detach_ret) - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoApiGatewayTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_cloudtrail.py b/tests/unit/modules/test_boto_cloudtrail.py index b971c68b58..2ddb787259 100644 --- a/tests/unit/modules/test_boto_cloudtrail.py +++ b/tests/unit/modules/test_boto_cloudtrail.py @@ -5,6 +5,7 @@ from __future__ import absolute_import from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module import random import string +import logging # Import Salt Testing libs from tests.support.unit import skipIf, TestCase @@ -14,9 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -24,9 +22,6 @@ import salt.loader from salt.modules import boto_cloudtrail from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin -# Import 3rd-party libs -import logging - # pylint: disable=import-error,no-name-in-module,unused-import try: import boto @@ -391,8 +386,3 @@ class BotoCloudTrailTestCase(BotoCloudTrailTestCaseBase, BotoCloudTrailTestCaseM with patch.dict(boto_cloudtrail.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}): result = boto_cloudtrail.list_tags(Name=trail_ret['Name'], **conn_parameters) self.assertTrue(result['error']) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoCloudTrailTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_cloudwatch_event.py b/tests/unit/modules/test_boto_cloudwatch_event.py index 1069cbe047..2bf8177e3a 100644 --- a/tests/unit/modules/test_boto_cloudwatch_event.py +++ b/tests/unit/modules/test_boto_cloudwatch_event.py @@ -13,9 +13,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -277,8 +274,3 @@ class BotoCloudWatchEventTestCase(BotoCloudWatchEventTestCaseBase, BotoCloudWatc self.conn.remove_targets.side_effect = ClientError(error_content, 'remove_targets') result = boto_cloudwatch_event.remove_targets(Rule=rule_name, Ids=[], **conn_parameters) self.assertEqual(result.get('error', {}).get('message'), error_message.format('remove_targets')) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoCloudWatchEventTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_cognitoidentity.py b/tests/unit/modules/test_boto_cognitoidentity.py index b8b668c115..edb4c947e3 100644 --- a/tests/unit/modules/test_boto_cognitoidentity.py +++ b/tests/unit/modules/test_boto_cognitoidentity.py @@ -10,9 +10,6 @@ import string # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -516,7 +513,3 @@ class BotoCognitoIdentityTestCase(BotoCognitoIdentityTestCaseBase, BotoCognitoId result = boto_cognitoidentity.update_identity_pool(IdentityPoolId=second_pool_id, DeveloperProviderName='added_developer_provider', **conn_parameters) self.assertIs(result.get('updated'), False) self.assertEqual(result.get('error', {}).get('message'), error_message.format('update_identity_pool')) - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoCognitoIdentityTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_elasticsearch_domain.py b/tests/unit/modules/test_boto_elasticsearch_domain.py index 4039da6e22..4d57e52e7c 100644 --- a/tests/unit/modules/test_boto_elasticsearch_domain.py +++ b/tests/unit/modules/test_boto_elasticsearch_domain.py @@ -16,9 +16,6 @@ from tests.support.mock import ( MagicMock, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.ext.six as six @@ -312,8 +309,3 @@ class BotoElasticsearchDomainTestCase(BotoElasticsearchDomainTestCaseBase, BotoE self.conn.describe_elasticsearch_domain.return_value = {'DomainStatus': domain_ret} result = boto_elasticsearch_domain.list_tags(DomainName=domain_ret['DomainName'], **conn_parameters) self.assertTrue(result['error']) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoElasticsearchDomainTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_elb.py b/tests/unit/modules/test_boto_elb.py index e526eb68f5..4d9a96ef2c 100644 --- a/tests/unit/modules/test_boto_elb.py +++ b/tests/unit/modules/test_boto_elb.py @@ -52,9 +52,6 @@ from salt.modules import boto_elb # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') log = logging.getLogger(__name__) @@ -200,7 +197,3 @@ class BotoElbTestCase(TestCase): actual_instances = [instance.id for instance in load_balancer_refreshed.instances] self.assertEqual(actual_instances, expected_instances) - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoElbTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_iot.py b/tests/unit/modules/test_boto_iot.py index 051ec43f41..f5bd725fcb 100644 --- a/tests/unit/modules/test_boto_iot.py +++ b/tests/unit/modules/test_boto_iot.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -771,9 +768,3 @@ class BotoIoTTopicRuleTestCase(BotoIoTTestCaseBase, BotoIoTTestCaseMixin): self.conn.list_topic_rules.side_effect = ClientError(error_content, 'list_topic_rules') result = boto_iot.list_topic_rules(**conn_parameters) self.assertEqual(result.get('error', {}).get('message'), error_message.format('list_topic_rules')) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoIoTPolicyTestCase, needs_daemon=False) - run_tests(BotoIoTTopicRuleTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_lambda.py b/tests/unit/modules/test_boto_lambda.py index f44a3b1186..daed613a43 100644 --- a/tests/unit/modules/test_boto_lambda.py +++ b/tests/unit/modules/test_boto_lambda.py @@ -15,9 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -817,8 +814,3 @@ class BotoLambdaEventSourceMappingTestCase(BotoLambdaTestCaseBase, BotoLambdaTes **conn_parameters) self.assertEqual(result.get('error', {}).get('message'), error_message.format('update_event_source_mapping')) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoLambdaFunctionTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_s3_bucket.py b/tests/unit/modules/test_boto_s3_bucket.py index e153ecdc35..a41a1ab7fc 100644 --- a/tests/unit/modules/test_boto_s3_bucket.py +++ b/tests/unit/modules/test_boto_s3_bucket.py @@ -15,9 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.ext.six as six @@ -719,8 +716,3 @@ class BotoS3BucketTestCase(BotoS3BucketTestCaseBase, BotoS3BucketTestCaseMixin): **conn_parameters) self.assertEqual(result.get('error', {}).get('message'), error_message.format('delete_bucket_website')) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoS3BucketTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_secgroup.py b/tests/unit/modules/test_boto_secgroup.py index 9a79b29efe..3ee0dad868 100644 --- a/tests/unit/modules/test_boto_secgroup.py +++ b/tests/unit/modules/test_boto_secgroup.py @@ -10,9 +10,6 @@ from distutils.version import LooseVersion # pylint: disable=import-error,no-na # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -312,8 +309,3 @@ class BotoSecgroupTestCase(TestCase): conn = boto.ec2.connect_to_region(region, **boto_conn_parameters) salt_conn = boto_secgroup._get_conn(**conn_parameters) self.assertEqual(conn.__class__, salt_conn.__class__) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoSecgroupTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_boto_vpc.py b/tests/unit/modules/test_boto_vpc.py index 2c9f93b475..ca47895e56 100644 --- a/tests/unit/modules/test_boto_vpc.py +++ b/tests/unit/modules/test_boto_vpc.py @@ -14,9 +14,6 @@ import string # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -1816,7 +1813,3 @@ class BotoVpcPeeringConnectionsTest(BotoVpcTestCaseBase, BotoVpcTestCaseMixin): requester_vpc_name='my_peering', peer_vpc_id=other_vpc.id, **conn_parameters) - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(BotoVpcTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_bower.py b/tests/unit/modules/test_bower.py index d190ca773c..9185b78d49 100644 --- a/tests/unit/modules/test_bower.py +++ b/tests/unit/modules/test_bower.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import bower from salt.exceptions import CommandExecutionError @@ -129,8 +125,3 @@ class BowerTestCase(TestCase): with patch.dict(bower.__salt__, {'cmd.run_all': mock}): self.assertEqual(bower.list_('/path/to/project'), {'underscore': {}, 'jquery': {}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BowerTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_bridge.py b/tests/unit/modules/test_bridge.py index a904bc1092..813ae32501 100644 --- a/tests/unit/modules/test_bridge.py +++ b/tests/unit/modules/test_bridge.py @@ -118,8 +118,3 @@ class BridgeTestCase(TestCase): with patch.dict(bridge.__grains__, {'kernel': None}): self.assertFalse(bridge.stp()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BridgeTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_btrfs.py b/tests/unit/modules/test_btrfs.py index 85d5353c93..362d5768a2 100644 --- a/tests/unit/modules/test_btrfs.py +++ b/tests/unit/modules/test_btrfs.py @@ -14,10 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs import salt import salt.utils.fsutils @@ -368,8 +364,3 @@ class BtrfsTestCase(TestCase): ''' self.assertRaises(CommandExecutionError, btrfs.properties, '/dev/sda1', 'subvol', True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BtrfsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_cassandra.py b/tests/unit/modules/test_cassandra.py index 713affab2f..276fddf829 100644 --- a/tests/unit/modules/test_cassandra.py +++ b/tests/unit/modules/test_cassandra.py @@ -142,8 +142,3 @@ class CassandraTestCase(TestCase): with patch.object(cassandra, '_sys_mgr', mock_sys_mgr): self.assertEqual(cassandra.column_family_definition('A', 'a'), vars(object)) self.assertEqual(cassandra.column_family_definition('B', 'a'), None) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CassandraTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_cassandra_cql.py b/tests/unit/modules/test_cassandra_cql.py index e5cd5b5888..88166ed8dd 100644 --- a/tests/unit/modules/test_cassandra_cql.py +++ b/tests/unit/modules/test_cassandra_cql.py @@ -10,9 +10,6 @@ import ssl # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import salt libs from salt.modules import cassandra_cql @@ -80,8 +77,3 @@ class CassandraCQLReturnerTestCase(TestCase): self.assertEqual(cassandra_cql._get_ssl_opts(), # pylint: disable=protected-access None) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CassandraCQLReturnerTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_chef.py b/tests/unit/modules/test_chef.py index 28822a0e20..d20e5a16c7 100644 --- a/tests/unit/modules/test_chef.py +++ b/tests/unit/modules/test_chef.py @@ -47,8 +47,3 @@ class ChefTestCase(TestCase): Test if it execute a chef solo run and return a dict ''' self.assertDictEqual(chef.solo('/dev/sda1'), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ChefTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_cmdmod.py b/tests/unit/modules/test_cmdmod.py index b4b1df0382..c972d78659 100644 --- a/tests/unit/modules/test_cmdmod.py +++ b/tests/unit/modules/test_cmdmod.py @@ -21,9 +21,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') cmdmod.__grains__ = {} @@ -253,8 +250,3 @@ class CMDMODTestCase(TestCase): ''' with patch('salt.utils.fopen', mock_open(read_data=MOCK_SHELL_FILE)): self.assertFalse(cmdmod._is_valid_shell('foo')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CMDMODTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_composer.py b/tests/unit/modules/test_composer.py index a87ea9847e..940bf40292 100644 --- a/tests/unit/modules/test_composer.py +++ b/tests/unit/modules/test_composer.py @@ -165,8 +165,3 @@ class ComposerTestCase(TestCase): mock = MagicMock(return_value=rval) with patch.dict(composer.__salt__, {'cmd.run_all': mock}): self.assertEqual(composer.selfupdate(), rval) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ComposerTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_config.py b/tests/unit/modules/test_config.py index 8c01e51d4c..c51dac36d0 100644 --- a/tests/unit/modules/test_config.py +++ b/tests/unit/modules/test_config.py @@ -5,11 +5,8 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -ensure_in_syspath('../../') - # Import Salt libs from salt.modules import config @@ -65,8 +62,3 @@ class TestModulesConfig(TestCase): self.assertEqual( opt, config.__pillar__['master'][opt_name]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestModulesConfig, needs_daemon=False) diff --git a/tests/unit/modules/test_cp.py b/tests/unit/modules/test_cp.py index b7c84db343..fa4bc4ad93 100644 --- a/tests/unit/modules/test_cp.py +++ b/tests/unit/modules/test_cp.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( Mock, MagicMock, @@ -18,8 +17,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import cp from salt.utils import templates @@ -159,8 +156,3 @@ class CpTestCase(TestCase): id='abc' ) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CpTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_cpan.py b/tests/unit/modules/test_cpan.py index af8845b7f5..655f164058 100644 --- a/tests/unit/modules/test_cpan.py +++ b/tests/unit/modules/test_cpan.py @@ -136,8 +136,3 @@ class CpanTestCase(TestCase): mock = MagicMock(return_value='') with patch.dict(cpan.__salt__, {'cmd.run': mock}): self.assertDictEqual(cpan.show_config(), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CpanTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_cron.py b/tests/unit/modules/test_cron.py index 075037d664..140c627ff8 100644 --- a/tests/unit/modules/test_cron.py +++ b/tests/unit/modules/test_cron.py @@ -8,11 +8,8 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call -ensure_in_syspath('../../') - # Import Salt libs from salt.modules import cron from salt.ext.six.moves import builtins, StringIO @@ -948,11 +945,3 @@ class PsTestCase(TestCase): with patch.dict(cron.__grains__, {'os': None}): ret = cron.rm_job('DUMMY_USER', '/bin/echo NOT A DROID', 1, 2, 3, 4, 5) self.assertEqual('absent', ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests([ - PsTestCase, - CronTestCase - ], needs_daemon=False) diff --git a/tests/unit/modules/test_cyg.py b/tests/unit/modules/test_cyg.py index 40e662385d..07eecb1fbb 100644 --- a/tests/unit/modules/test_cyg.py +++ b/tests/unit/modules/test_cyg.py @@ -5,9 +5,7 @@ # # Import Salt Testing libs # from tests.support.unit import skipIf, TestCase -# from tests.support.helpers import ensure_in_syspath # from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -# ensure_in_syspath('../../') # # Import salt libs # import salt.modules.cyg as cyg @@ -94,8 +92,3 @@ # with patch.object(cyg, '_cyg', new=mock): # self.assertEqual( # ['http://rubycygs.org/'], cyg.sources_list()) - - -# if __name__ == '__main__': -# from integration import run_tests -# run_tests(TestcygModule, needs_daemon=False) diff --git a/tests/unit/modules/test_daemontools.py b/tests/unit/modules/test_daemontools.py index 07ce91441f..8ecfa29734 100644 --- a/tests/unit/modules/test_daemontools.py +++ b/tests/unit/modules/test_daemontools.py @@ -130,8 +130,3 @@ class DaemontoolsTestCase(TestCase): mock = MagicMock(return_value='A') with patch.object(os, 'listdir', mock): self.assertEqual(daemontools.get_all(), ['A']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DaemontoolsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_data.py b/tests/unit/modules/test_data.py index a46ac81e9c..d09e589f65 100644 --- a/tests/unit/modules/test_data.py +++ b/tests/unit/modules/test_data.py @@ -134,8 +134,3 @@ class DataTestCase(TestCase): Test if it check and set a value in the minion datastore ''' self.assertTrue(data.cas('salt', 'SALTSTACK', 'SALT')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DataTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ddns.py b/tests/unit/modules/test_ddns.py index 419bc227cc..57f313f136 100644 --- a/tests/unit/modules/test_ddns.py +++ b/tests/unit/modules/test_ddns.py @@ -126,8 +126,3 @@ class DDNSTestCase(TestCase): with patch.object(ddns, '_get_keyring', return_value=None): with patch.object(ddns, '_config', return_value=None): self.assertTrue(ddns.delete(zone='A', name='B')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DDNSTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_deb_apache.py b/tests/unit/modules/test_deb_apache.py index 849c0a46cb..fad40a27d8 100644 --- a/tests/unit/modules/test_deb_apache.py +++ b/tests/unit/modules/test_deb_apache.py @@ -354,7 +354,3 @@ class DebApacheTestCase(TestCase): with patch.dict(deb_apache.__salt__, {'cmd.retcode': mock}): self.assertEqual(str(deb_apache.a2disconf('security')), 'error') - -if __name__ == '__main__': - from integration import run_tests - run_tests(DebApacheTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_deb_postgres.py b/tests/unit/modules/test_deb_postgres.py index e5652504e8..d618898db1 100644 --- a/tests/unit/modules/test_deb_postgres.py +++ b/tests/unit/modules/test_deb_postgres.py @@ -2,16 +2,10 @@ # Import python libs from __future__ import absolute_import, print_function -import os # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch -ensure_in_syspath( - os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../../')) -ensure_in_syspath( - os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../')) # Import salt libs import salt.ext.six as six @@ -129,8 +123,3 @@ class PostgresDeleteClusterTestCase(TestCase): cmd = SALT_STUB['cmd.run_all'] self.assertEqual('/usr/bin/pg_dropcluster --stop 9.3 main', cmd.call_args[0][0]) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresClusterTestCase, PostgresLsClusterTestCase, - PostgresDeleteClusterTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_debconfmod.py b/tests/unit/modules/test_debconfmod.py index 04e23c84a7..b5dfa47ac2 100644 --- a/tests/unit/modules/test_debconfmod.py +++ b/tests/unit/modules/test_debconfmod.py @@ -89,8 +89,3 @@ class DebconfmodTestCase(TestCase): mock = MagicMock(return_value=None) with patch.object(debconfmod, '_set_file', mock): self.assertFalse(debconfmod.set_file('path')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DebconfmodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_debian_ip.py b/tests/unit/modules/test_debian_ip.py index fd845ee6c9..fda4b59254 100644 --- a/tests/unit/modules/test_debian_ip.py +++ b/tests/unit/modules/test_debian_ip.py @@ -274,8 +274,3 @@ class DebianIpTestCase(TestCase): MagicMock(return_value=True)): self.assertTrue(debian_ip.build_network_settings (test='True')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DebianIpTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_debian_service.py b/tests/unit/modules/test_debian_service.py index 4b6808cd98..4252c2c93c 100644 --- a/tests/unit/modules/test_debian_service.py +++ b/tests/unit/modules/test_debian_service.py @@ -175,8 +175,3 @@ class DebianServicesTestCase(TestCase): mock = MagicMock(return_value=['A']) with patch.object(debian_service, 'get_enabled', mock): self.assertFalse(debian_service.disabled('name')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DebianServicesTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_defaults.py b/tests/unit/modules/test_defaults.py index 5ad293e791..3395ae1194 100644 --- a/tests/unit/modules/test_defaults.py +++ b/tests/unit/modules/test_defaults.py @@ -39,8 +39,3 @@ class DefaultsTestCase(TestCase): with patch.object(inspect, 'stack', MagicMock(return_value=[])): self.assertEqual(defaults.get('core:users:root'), {'users': {'root': [0]}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DefaultsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_devmap.py b/tests/unit/modules/test_devmap.py index 0e1209fb38..7e916c1291 100644 --- a/tests/unit/modules/test_devmap.py +++ b/tests/unit/modules/test_devmap.py @@ -54,8 +54,3 @@ class DevMapTestCase(TestCase): mock = MagicMock(return_value='A') with patch.dict(devmap.__salt__, {'cmd.run': mock}): self.assertEqual(devmap.multipath_flush('device'), ['A']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DevMapTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_dig.py b/tests/unit/modules/test_dig.py index c229282fbe..41b4f5f4b0 100644 --- a/tests/unit/modules/test_dig.py +++ b/tests/unit/modules/test_dig.py @@ -9,8 +9,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.modules import dig @@ -193,8 +191,3 @@ class DigTestCase(TestCase): ['50', 'alt4.aspmx.l.google.com.'], ['30', 'alt2.aspmx.l.google.com.']] ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DigTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_disk.py b/tests/unit/modules/test_disk.py index d82c2c1bb3..3b38c2159e 100644 --- a/tests/unit/modules/test_disk.py +++ b/tests/unit/modules/test_disk.py @@ -8,9 +8,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch -ensure_in_syspath('../../') # Import Salt libs from salt.modules import disk @@ -162,8 +160,3 @@ class DiskTestCase(TestCase): with patch.dict(disk.__salt__, {'cmd.run_all': mock}): disk.resize2fs(device) mock.assert_called_once_with('resize2fs {0}'.format(device), python_shell=False) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DiskTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_djangomod.py b/tests/unit/modules/test_djangomod.py index fb4067076e..28ab046830 100644 --- a/tests/unit/modules/test_djangomod.py +++ b/tests/unit/modules/test_djangomod.py @@ -92,8 +92,3 @@ class DjangomodTestCase(TestCase): mock = MagicMock(return_value=True) with patch.dict(djangomod.__salt__, {'cmd.run': mock}): self.assertTrue(djangomod.collectstatic('DJANGO_SETTINGS_MODULE')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DjangomodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_dnsmasq.py b/tests/unit/modules/test_dnsmasq.py index e04c42963c..3ea71d8b8d 100644 --- a/tests/unit/modules/test_dnsmasq.py +++ b/tests/unit/modules/test_dnsmasq.py @@ -107,8 +107,3 @@ class DnsmasqTestCase(TestCase): {'A': 'B', 'unparsed': ['line here', 'second line']}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DnsmasqTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_dnsutil.py b/tests/unit/modules/test_dnsutil.py index 0754c83978..6a89db59ca 100644 --- a/tests/unit/modules/test_dnsutil.py +++ b/tests/unit/modules/test_dnsutil.py @@ -9,7 +9,6 @@ import logging # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -19,8 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import dnsutil @@ -117,8 +114,3 @@ class DNSUtilTestCase(TestCase): def test_to_seconds_large(self): self.assertEqual(dnsutil._to_seconds('604801'), 604800, msg='Did not set time greater than one week to one week') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DNSUtilTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_docker.py b/tests/unit/modules/test_docker.py index b36b707948..29a9795923 100644 --- a/tests/unit/modules/test_docker.py +++ b/tests/unit/modules/test_docker.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, Mock, @@ -17,8 +16,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.ext.six.moves import range from salt.modules import docker as docker_mod @@ -842,8 +839,3 @@ class DockerTestCase(TestCase): result = docker_mod.images() self.assertEqual(result, {'sha256:abcdefg': {'RepoTags': ['image:latest']}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DockerTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_dpkg.py b/tests/unit/modules/test_dpkg.py index a789344d12..36d816405b 100644 --- a/tests/unit/modules/test_dpkg.py +++ b/tests/unit/modules/test_dpkg.py @@ -103,8 +103,3 @@ class DpkgTestCase(TestCase): 'stdout': 'Salt'}) with patch.dict(dpkg.__salt__, {'cmd.run_all': mock}): self.assertEqual(dpkg.file_dict('httpd'), 'Error: error') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DpkgTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_drac.py b/tests/unit/modules/test_drac.py index 108b1146d0..cedf398dcd 100644 --- a/tests/unit/modules/test_drac.py +++ b/tests/unit/modules/test_drac.py @@ -261,8 +261,3 @@ class DracTestCase(TestCase): mock = MagicMock(return_value=False) with patch.object(drac, '__execute_cmd', mock): self.assertFalse(drac.server_pxe()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DracTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_drbd.py b/tests/unit/modules/test_drbd.py index 34c9b19f84..6d1c7cdc9a 100644 --- a/tests/unit/modules/test_drbd.py +++ b/tests/unit/modules/test_drbd.py @@ -66,8 +66,3 @@ class DrbdTestCase(TestCase): UpToDate/partner syncbar None 50 50') with patch.dict(drbd.__salt__, {'cmd.run': mock}): self.assertDictEqual(drbd.overview(), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DrbdTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_environ.py b/tests/unit/modules/test_environ.py index 2c61fc11d1..bcd211a9d6 100644 --- a/tests/unit/modules/test_environ.py +++ b/tests/unit/modules/test_environ.py @@ -129,8 +129,3 @@ class EnvironTestCase(TestCase): Return a dict of the entire environment set for the salt process ''' self.assertNotEqual(list(environ.items()), []) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EnvironTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_etcd_mod.py b/tests/unit/modules/test_etcd_mod.py index f7220db8b8..bd772fba7d 100644 --- a/tests/unit/modules/test_etcd_mod.py +++ b/tests/unit/modules/test_etcd_mod.py @@ -15,9 +15,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import etcd_mod @@ -193,8 +190,3 @@ class EtcdModTestCase(TestCase): self.assertEqual(etcd_mod.watch('/some-dir', True, None, 5, 10), self.instance.watch.return_value) self.instance.watch.assert_called_with('/some-dir', recurse=True, timeout=5, index=10) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EtcdModTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_event.py b/tests/unit/modules/test_event.py index 687c16600b..159aba35cd 100644 --- a/tests/unit/modules/test_event.py +++ b/tests/unit/modules/test_event.py @@ -85,7 +85,3 @@ class EventTestCase(TestCase): ''' with patch.object(event, 'fire_master', return_value='B'): self.assertEqual(event.send('tag'), 'B') - -if __name__ == '__main__': - from integration import run_tests - run_tests(EventTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_extfs.py b/tests/unit/modules/test_extfs.py index 2a4c7ebbeb..5a78799ac0 100644 --- a/tests/unit/modules/test_extfs.py +++ b/tests/unit/modules/test_extfs.py @@ -72,7 +72,3 @@ class ExtfsTestCase(TestCase): Tests if specified group was added ''' self.assertEqual({}, extfs.blocks('/dev/sda1')) - -if __name__ == '__main__': - from integration import run_tests - run_tests(ExtfsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_file.py b/tests/unit/modules/test_file.py index 1085dbf3b2..6a7cb539a1 100644 --- a/tests/unit/modules/test_file.py +++ b/tests/unit/modules/test_file.py @@ -8,11 +8,8 @@ import textwrap # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch -ensure_in_syspath('../../') - # Import Salt libs import salt.utils from salt.modules import file as filemod @@ -713,11 +710,3 @@ class FileBasicsTestCase(TestCase): os.symlink(self.tfile.name, self.directory + '/a_link') result = filemod.symlink(self.tfile.name, self.directory + '/a_link') self.assertTrue(result) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(FileModuleTestCase, - FileReplaceTestCase, - FileBlockReplaceTestCase, - needs_daemon=False) diff --git a/tests/unit/modules/test_firewalld.py b/tests/unit/modules/test_firewalld.py index 7f916f0fd1..5edf8ae0ef 100644 --- a/tests/unit/modules/test_firewalld.py +++ b/tests/unit/modules/test_firewalld.py @@ -288,7 +288,3 @@ class FirewalldTestCase(TestCase): ''' with patch.object(firewalld, '__firewall_cmd', return_value='success'): self.assertEqual(firewalld.remove_rich_rule('zone', 'rule family="ipv4" source address="1.2.3.4" accept'), 'success') - -if __name__ == '__main__': - from integration import run_tests - run_tests(FirewalldTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_gem.py b/tests/unit/modules/test_gem.py index 9701592e8e..6bf528b216 100644 --- a/tests/unit/modules/test_gem.py +++ b/tests/unit/modules/test_gem.py @@ -5,9 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs import salt.modules.gem as gem @@ -132,8 +130,3 @@ http://rubygems.org/ with patch.object(gem, '_gem', new=mock): self.assertEqual( ['http://rubygems.org/'], gem.sources_list()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestGemModule, needs_daemon=False) diff --git a/tests/unit/modules/test_genesis.py b/tests/unit/modules/test_genesis.py index 1beea11eaf..2174bd3ef5 100644 --- a/tests/unit/modules/test_genesis.py +++ b/tests/unit/modules/test_genesis.py @@ -84,8 +84,3 @@ class GenesisTestCase(TestCase): ''' with patch.object(genesis, '_untar', return_value='untar'): self.assertEqual(genesis.unpack('name', 'root'), None) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GenesisTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_gentoo_service.py b/tests/unit/modules/test_gentoo_service.py index 29bfd70ba5..b77da1fc1c 100644 --- a/tests/unit/modules/test_gentoo_service.py +++ b/tests/unit/modules/test_gentoo_service.py @@ -442,8 +442,3 @@ class GentooServicesTestCase(TestCase): def __services(self, services): return '\n'.join([' | '.join([svc, ' '.join(services[svc])]) for svc in services]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GentooServicesTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_git.py b/tests/unit/modules/test_git.py index bcdb438b1a..03ada463e7 100644 --- a/tests/unit/modules/test_git.py +++ b/tests/unit/modules/test_git.py @@ -163,8 +163,3 @@ class GitTestCase(TestCase): dict([(x, worktree_ret[x]) for x in WORKTREE_INFO if WORKTREE_INFO[x].get('stale', False)]) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GitTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_glusterfs.py b/tests/unit/modules/test_glusterfs.py index 20b6d4f4da..31ea67bab2 100644 --- a/tests/unit/modules/test_glusterfs.py +++ b/tests/unit/modules/test_glusterfs.py @@ -677,8 +677,3 @@ class GlusterfsTestCase(TestCase): mock_run.return_value = xml_command_fail self.assertFalse(glusterfs.add_volume_bricks('Newvolume1', ['new:/path'])) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GlusterfsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_gnomedesktop.py b/tests/unit/modules/test_gnomedesktop.py index 9a186c3138..83116b945c 100644 --- a/tests/unit/modules/test_gnomedesktop.py +++ b/tests/unit/modules/test_gnomedesktop.py @@ -119,8 +119,3 @@ class GnomedesktopTestCase(TestCase): ''' with patch.object(gsettings_mock, '_get', return_value=True): self.assertTrue(gnomedesktop.set_()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GnomedesktopTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_grains.py b/tests/unit/modules/test_grains.py index d9897a31a3..b348eedd5b 100644 --- a/tests/unit/modules/test_grains.py +++ b/tests/unit/modules/test_grains.py @@ -6,7 +6,6 @@ import copy # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -14,8 +13,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt libs from salt.exceptions import SaltException from salt.modules import grains as grainsmod @@ -607,8 +604,3 @@ class GrainsModuleTestCase(TestCase): OrderedDict([('l23', 'l23val')])]), ('z', 'zval'), ])) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GrainsModuleTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_groupadd.py b/tests/unit/modules/test_groupadd.py index 08d5540f7b..f7a6f15f96 100644 --- a/tests/unit/modules/test_groupadd.py +++ b/tests/unit/modules/test_groupadd.py @@ -204,8 +204,3 @@ class GroupAddTestCase(TestCase): 'cmd.run': mock}): self.assertFalse(groupadd.members('test', 'foo')) groupadd.__salt__['cmd.retcode'].assert_called_once_with(os_version['cmd'], python_shell=False) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GroupAddTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_grub_legacy.py b/tests/unit/modules/test_grub_legacy.py index db5b65f6d0..68eddcfe97 100644 --- a/tests/unit/modules/test_grub_legacy.py +++ b/tests/unit/modules/test_grub_legacy.py @@ -53,8 +53,3 @@ class GrublegacyTestCase(TestCase): with patch.object(grub_legacy, '_detect_conf', return_value='A'): self.assertEqual(grub_legacy.conf(), {'A': 'B C D,E,F G H', 'stanzas': []}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GrublegacyTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_guestfs.py b/tests/unit/modules/test_guestfs.py index 0bbd82d701..0051fcc3f1 100644 --- a/tests/unit/modules/test_guestfs.py +++ b/tests/unit/modules/test_guestfs.py @@ -39,8 +39,3 @@ class GuestfsTestCase(TestCase): mock = MagicMock(return_value='') with patch.dict(guestfs.__salt__, {'cmd.run': mock}): self.assertTrue(guestfs.mount('/srv/images/fedora.qcow')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GuestfsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_hadoop.py b/tests/unit/modules/test_hadoop.py index b2b0cfb597..03825761fa 100644 --- a/tests/unit/modules/test_hadoop.py +++ b/tests/unit/modules/test_hadoop.py @@ -68,8 +68,3 @@ class HadoopTestCase(TestCase): ''' with patch.object(hadoop, '_hadoop_cmd', return_value='A'): self.assertEqual(hadoop.namenode_format('force'), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HadoopTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_haproxyconn.py b/tests/unit/modules/test_haproxyconn.py index b032db1cf6..6eeddcb73a 100644 --- a/tests/unit/modules/test_haproxyconn.py +++ b/tests/unit/modules/test_haproxyconn.py @@ -14,10 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import haproxyconn @@ -169,8 +165,3 @@ class HaproxyConnTestCase(TestCase): Test if it get a value from etcd, by direct path ''' self.assertTrue(haproxyconn.show_backends()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HaproxyConnTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_hashutil.py b/tests/unit/modules/test_hashutil.py index a944cb87c3..a71170c019 100644 --- a/tests/unit/modules/test_hashutil.py +++ b/tests/unit/modules/test_hashutil.py @@ -59,9 +59,3 @@ class HashutilTestCase(ModuleCase): 'shared secret', self.the_string_github) self.assertTrue(ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HashutilTestCase, - needs_daemon=False) diff --git a/tests/unit/modules/test_hg.py b/tests/unit/modules/test_hg.py index 33546e2eff..4868a45f40 100644 --- a/tests/unit/modules/test_hg.py +++ b/tests/unit/modules/test_hg.py @@ -110,8 +110,3 @@ class HgTestCase(TestCase): 'dir 0': {'added': ['file 0']}, 'dir 1': {'modified': ['file 1']}, }) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HgTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_hipchat.py b/tests/unit/modules/test_hipchat.py index 987192ad75..a89d7d955e 100644 --- a/tests/unit/modules/test_hipchat.py +++ b/tests/unit/modules/test_hipchat.py @@ -90,8 +90,3 @@ class HipchatTestCase(TestCase): self.assertEqual(hipchat.send_message('Development Room', 'Build is done', 'Build Server'), False) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HipchatTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_hosts.py b/tests/unit/modules/test_hosts.py index 9a9b3a62eb..5cbbd9e441 100644 --- a/tests/unit/modules/test_hosts.py +++ b/tests/unit/modules/test_hosts.py @@ -207,7 +207,3 @@ class HostsTestCase(TestCase): mock_opt = MagicMock(return_value=None) with patch.dict(hosts.__salt__, {'config.option': mock_opt}): self.assertTrue(hosts.add_host('10.10.10.10', 'Salt1')) - -if __name__ == '__main__': - from integration import run_tests - run_tests(HostsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_htpasswd.py b/tests/unit/modules/test_htpasswd.py index 900cb097f1..df195d9403 100644 --- a/tests/unit/modules/test_htpasswd.py +++ b/tests/unit/modules/test_htpasswd.py @@ -60,7 +60,3 @@ class HtpasswdTestCase(TestCase): ''' self.assertEqual(htpasswd.userdel('/etc/httpd/htpasswd', 'larry'), 'Error: The specified htpasswd file does not exist') - -if __name__ == '__main__': - from integration import run_tests - run_tests(HtpasswdTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_http.py b/tests/unit/modules/test_http.py index bc98352b49..a4f41dcae9 100644 --- a/tests/unit/modules/test_http.py +++ b/tests/unit/modules/test_http.py @@ -32,7 +32,3 @@ class HttpTestCase(TestCase): ''' with patch.object(salt.utils.http, 'query', return_value='A'): self.assertEqual(http.query('url'), 'A') - -if __name__ == '__main__': - from integration import run_tests - run_tests(HttpTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ilo.py b/tests/unit/modules/test_ilo.py index 6c3c912f4a..2f2492b3f7 100644 --- a/tests/unit/modules/test_ilo.py +++ b/tests/unit/modules/test_ilo.py @@ -305,8 +305,3 @@ class IloTestCase(TestCase): Test if it configure SNMP ''' self.assertDictEqual(ilo.configure_snmp('Salt'), {'Configure SNMP': {}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IloTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_incron.py b/tests/unit/modules/test_incron.py index 7a39cd7ec3..214c5201ea 100644 --- a/tests/unit/modules/test_incron.py +++ b/tests/unit/modules/test_incron.py @@ -184,8 +184,3 @@ class IncronTestCase(TestCase): self.assertEqual(incron.rm_job('cybage', '/home/cybage', 'IN_MODIFY', 'echo "SALT"'), 'absent') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IncronTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_influx08.py b/tests/unit/modules/test_influx08.py index 819e0cc218..b4a5b84cfd 100644 --- a/tests/unit/modules/test_influx08.py +++ b/tests/unit/modules/test_influx08.py @@ -284,7 +284,3 @@ class InfluxTestCase(TestCase): )) client.alter_retention_policy.assert_called_once_with( 'name', 'db', '30d', 1, False) - -if __name__ == '__main__': - from integration import run_tests - run_tests(InfluxTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ini_manage.py b/tests/unit/modules/test_ini_manage.py index 75fd8ac9e4..eec6576026 100644 --- a/tests/unit/modules/test_ini_manage.py +++ b/tests/unit/modules/test_ini_manage.py @@ -7,9 +7,6 @@ import tempfile # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.utils @@ -164,8 +161,3 @@ empty_option = 'SectionB': {'test3': 'this value will be edited two times'}, }) self.test_empty_lines_preserved_after_edit() - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IniManageTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_inspect_collector.py b/tests/unit/modules/test_inspect_collector.py index fce1b5f930..e51a6b0545 100644 --- a/tests/unit/modules/test_inspect_collector.py +++ b/tests/unit/modules/test_inspect_collector.py @@ -29,10 +29,8 @@ from tests.support.mock import ( NO_MOCK_REASON ) +# Import salt libs from salt.modules.inspectlib.collector import Inspector -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') @skipIf(NO_MOCK, NO_MOCK_REASON) diff --git a/tests/unit/modules/test_inspect_fsdb.py b/tests/unit/modules/test_inspect_fsdb.py index a166655ab7..8158fb2c2d 100644 --- a/tests/unit/modules/test_inspect_fsdb.py +++ b/tests/unit/modules/test_inspect_fsdb.py @@ -25,15 +25,12 @@ from __future__ import absolute_import from tests.support.unit import TestCase from tests.support.mock import MagicMock, patch -from tests.support.helpers import ensure_in_syspath from salt.modules.inspectlib.fsdb import CsvDB from salt.modules.inspectlib.entities import CsvDBEntity from salt.utils.odict import OrderedDict from salt.ext.six.moves import StringIO -ensure_in_syspath('../../') - def mock_open(data=None): ''' diff --git a/tests/unit/modules/test_introspect.py b/tests/unit/modules/test_introspect.py index a1ed9a9ed2..6dced79c33 100644 --- a/tests/unit/modules/test_introspect.py +++ b/tests/unit/modules/test_introspect.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import introspect @@ -80,8 +77,3 @@ class IntrospectTestCase(TestCase): Test if it return running and enabled services in a highstate structure. ''' self.assertDictEqual(introspect.service_highstate(), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IntrospectTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ipset.py b/tests/unit/modules/test_ipset.py index 00c73c6aa8..d425e0c01b 100644 --- a/tests/unit/modules/test_ipset.py +++ b/tests/unit/modules/test_ipset.py @@ -247,8 +247,3 @@ comment support') with patch.dict(ipset.__salt__, {'cmd.run': mock}): self.assertTrue(ipset.flush('set')) self.assertFalse(ipset.flush('set')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IpsetTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_iptables.py b/tests/unit/modules/test_iptables.py index 0b0c26b4f8..5fb648f059 100644 --- a/tests/unit/modules/test_iptables.py +++ b/tests/unit/modules/test_iptables.py @@ -15,9 +15,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import iptables @@ -483,8 +480,3 @@ class IptablesTestCase(TestCase): self.assertTrue(iptables.flush(table='filter', chain='INPUT', family='ipv4')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IptablesTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_jboss7.py b/tests/unit/modules/test_jboss7.py index 4749900874..84101a07c0 100644 --- a/tests/unit/modules/test_jboss7.py +++ b/tests/unit/modules/test_jboss7.py @@ -6,8 +6,6 @@ from __future__ import absolute_import # Import salt testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils.odict import OrderedDict diff --git a/tests/unit/modules/test_jboss7_cli.py b/tests/unit/modules/test_jboss7_cli.py index f9ba34e4be..ad90e5cc66 100644 --- a/tests/unit/modules/test_jboss7_cli.py +++ b/tests/unit/modules/test_jboss7_cli.py @@ -6,9 +6,8 @@ import re # Import salt testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +# Import salt libs from salt.modules import jboss7_cli from salt.exceptions import CommandExecutionError diff --git a/tests/unit/modules/test_k8s.py b/tests/unit/modules/test_k8s.py index 33a924341a..2147994bb4 100644 --- a/tests/unit/modules/test_k8s.py +++ b/tests/unit/modules/test_k8s.py @@ -13,9 +13,7 @@ from subprocess import Popen, PIPE # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath, skip_if_binaries_missing - -ensure_in_syspath('../../') +from tests.support.helpers import skip_if_binaries_missing # Import Salt libs import salt.modules.k8s as k8s @@ -23,12 +21,12 @@ import salt.modules.k8s as k8s # Import 3rd-party libs from salt.ext.six.moves import range # pylint: disable=import-error -TestCase.maxDiff = None - @skip_if_binaries_missing(['kubectl']) class TestK8SNamespace(TestCase): + maxDiff = None + def test_get_namespaces(self): res = k8s.get_namespaces(apiserver_url="http://127.0.0.1:8080") a = len(res.get("items")) @@ -59,6 +57,8 @@ class TestK8SNamespace(TestCase): @skip_if_binaries_missing(['kubectl']) class TestK8SSecrets(TestCase): + maxDiff = None + def setUp(self): hash = hashlib.sha1() hash.update(str(time.time())) @@ -175,6 +175,8 @@ class TestK8SSecrets(TestCase): @skip_if_binaries_missing(['kubectl']) class TestK8SResourceQuotas(TestCase): + maxDiff = None + def setUp(self): hash = hashlib.sha1() hash.update(str(time.time())) @@ -303,6 +305,8 @@ spec: @skip_if_binaries_missing(['kubectl']) class TestK8SLimitRange(TestCase): + maxDiff = None + def setUp(self): hash = hashlib.sha1() hash.update(str(time.time())) @@ -397,12 +401,3 @@ spec: kubectl_out = json.loads(proc.communicate()[0]) b = kubectl_out.get("metadata", {}).get("name", "b") self.assertEqual(a, b) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestK8SNamespace, - TestK8SSecrets, - TestK8SResourceQuotas, - TestK8SLimitRange, - needs_daemon=False) diff --git a/tests/unit/modules/test_key.py b/tests/unit/modules/test_key.py index 850d776f4e..e893a2f797 100644 --- a/tests/unit/modules/test_key.py +++ b/tests/unit/modules/test_key.py @@ -50,8 +50,3 @@ class KeyTestCase(TestCase): with patch.dict(key.__opts__, {'pki_dir': 'A', 'hash_type': 'sha256'}): self.assertEqual(key.finger_master(), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeyTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_keyboard.py b/tests/unit/modules/test_keyboard.py index ce1113963d..2689a21555 100644 --- a/tests/unit/modules/test_keyboard.py +++ b/tests/unit/modules/test_keyboard.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import keyboard @@ -70,8 +67,3 @@ class KeyboardTestCase(TestCase): mock = MagicMock(return_value='us') with patch.dict(keyboard.__salt__, {'cmd.run': mock}): self.assertEqual(keyboard.set_x('us'), 'us') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeyboardTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_keystone.py b/tests/unit/modules/test_keystone.py index 46cc1915df..d974132e3e 100644 --- a/tests/unit/modules/test_keystone.py +++ b/tests/unit/modules/test_keystone.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import keystone @@ -895,8 +891,3 @@ class KeystoneTestCase(TestCase): tenant_name='nova'), {'nova': {'id': '113', 'name': 'nova', 'tenant_id': '446', 'user_id': '446'}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeystoneTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_kmod.py b/tests/unit/modules/test_kmod.py index e95908ca17..927f583219 100644 --- a/tests/unit/modules/test_kmod.py +++ b/tests/unit/modules/test_kmod.py @@ -132,8 +132,3 @@ class KmodTestCase(TestCase): with patch.dict(kmod.__salt__, {'cmd.run_all': mock_run_all_1}): self.assertEqual('Error removing module {0}: {1}'.format(mod, err_msg), kmod.remove(mod, True)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KmodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_launchctl.py b/tests/unit/modules/test_launchctl.py index fef3ce7ad8..50af67e83b 100644 --- a/tests/unit/modules/test_launchctl.py +++ b/tests/unit/modules/test_launchctl.py @@ -131,8 +131,3 @@ class LaunchctlTestCase(TestCase): with patch.object(launchctl, 'stop', return_value=None): with patch.object(launchctl, 'start', return_value=True): self.assertTrue(launchctl.restart('job_label')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LaunchctlTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ldapmod.py b/tests/unit/modules/test_ldapmod.py index 98b326a825..9d3d733bb4 100644 --- a/tests/unit/modules/test_ldapmod.py +++ b/tests/unit/modules/test_ldapmod.py @@ -15,9 +15,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import ldapmod @@ -66,8 +63,3 @@ class LdapmodTestCase(TestCase): {'count': 4, 'results': 'SALT', 'time': {'raw': '0.0', 'human': '0.0ms'}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LdapmodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_libcloud_dns.py b/tests/unit/modules/test_libcloud_dns.py index 26597cc976..cc1bea02f1 100644 --- a/tests/unit/modules/test_libcloud_dns.py +++ b/tests/unit/modules/test_libcloud_dns.py @@ -15,11 +15,8 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath from salt.modules import libcloud_dns -ensure_in_syspath('../../') - SERVICE_NAME = 'libcloud_dns' libcloud_dns.__salt__ = {} libcloud_dns.__utils__ = {} @@ -63,7 +60,3 @@ class LibcloudDnsModuleTestCase(ModuleTestCase): with patch('salt.utils.compat.pack_dunder', return_value=False) as dunder: libcloud_dns.__init__(None) dunder.assert_called_with('salt.modules.libcloud_dns') - -if __name__ == '__main__': - from unit import run_tests - run_tests(LibcloudDnsModuleTestCase) diff --git a/tests/unit/modules/test_linux_acl.py b/tests/unit/modules/test_linux_acl.py index adadadbbf0..aa11c632be 100644 --- a/tests/unit/modules/test_linux_acl.py +++ b/tests/unit/modules/test_linux_acl.py @@ -5,9 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -ensure_in_syspath('../../') # Import salt libs from salt.modules import linux_acl diff --git a/tests/unit/modules/test_linux_lvm.py b/tests/unit/modules/test_linux_lvm.py index a10e83ea7e..9b2d9e10e0 100644 --- a/tests/unit/modules/test_linux_lvm.py +++ b/tests/unit/modules/test_linux_lvm.py @@ -282,7 +282,3 @@ class LinuxLVMTestCase(TestCase): mock = MagicMock(return_value={'retcode': 0}) with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}): self.assertDictEqual(linux_lvm.lvresize(1, 'a'), {}) - -if __name__ == '__main__': - from integration import run_tests - run_tests(LinuxLVMTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_linux_sysctl.py b/tests/unit/modules/test_linux_sysctl.py index 1381f5fc20..aa331dbb36 100644 --- a/tests/unit/modules/test_linux_sysctl.py +++ b/tests/unit/modules/test_linux_sysctl.py @@ -13,7 +13,6 @@ from salt.exceptions import CommandExecutionError # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, mock_open, @@ -22,8 +21,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Globals linux_sysctl.__salt__ = {} linux_sysctl.__context__ = {} @@ -146,8 +143,3 @@ class LinuxSysctlTestCase(TestCase): {'salt.utils.systemd.booted': True}): self.assertEqual(linux_sysctl.persist( 'net.ipv4.ip_forward', 1), 'Updated') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LinuxSysctlTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_localemod.py b/tests/unit/modules/test_localemod.py index 60a51ae331..adb373ecc1 100644 --- a/tests/unit/modules/test_localemod.py +++ b/tests/unit/modules/test_localemod.py @@ -238,8 +238,3 @@ class LocalemodTestCase(TestCase): with patch.dict(localemod.__salt__, {'cmd.run': mock_cmd}): ret = localemod._parse_localectl() self.assertEqual({'LANG': 'en_US.UTF-8', 'LANGUAGE': 'en_US:en'}, ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LocalemodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_locate.py b/tests/unit/modules/test_locate.py index cd388f0984..89f40b7429 100644 --- a/tests/unit/modules/test_locate.py +++ b/tests/unit/modules/test_locate.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import locate @@ -81,8 +78,3 @@ class LocateTestCase(TestCase): mock = MagicMock(return_value='') with patch.dict(locate.__salt__, {'cmd.run': mock}): self.assertListEqual(locate.locate('wholename', database='myfile'), []) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LocateTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_logadm.py b/tests/unit/modules/test_logadm.py index d1297e5426..b6b731a5e1 100644 --- a/tests/unit/modules/test_logadm.py +++ b/tests/unit/modules/test_logadm.py @@ -70,8 +70,3 @@ class LogadmTestCase(TestCase): MagicMock(return_value={'retcode': 0, 'stderr': 'stderr'})}): self.assertEqual(logadm.remove('name'), {'Result': 'Success'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LogadmTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_logrotate.py b/tests/unit/modules/test_logrotate.py index 25a44b530d..29ecd07e8f 100644 --- a/tests/unit/modules/test_logrotate.py +++ b/tests/unit/modules/test_logrotate.py @@ -18,9 +18,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Globals logrotate.__salt__ = {} @@ -93,8 +90,3 @@ class LogrotateTestCase(TestCase): 'value': '/var/log/wtmp', 'setting': '2'} self.assertRaises(SaltInvocationError, logrotate.set_, **kwargs) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(LogrotateTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_lvs.py b/tests/unit/modules/test_lvs.py index 79283fe0fe..3de634ccec 100644 --- a/tests/unit/modules/test_lvs.py +++ b/tests/unit/modules/test_lvs.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import lvs @@ -197,8 +194,3 @@ class LvsTestCase(TestCase): with patch.object(lvs, 'get_rules', return_value='C'): self.assertEqual(lvs.check_server('p', 's'), 'Error: server not exists') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LvsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_assistive.py b/tests/unit/modules/test_mac_assistive.py index 7d7f4f184c..afd10326a4 100644 --- a/tests/unit/modules/test_mac_assistive.py +++ b/tests/unit/modules/test_mac_assistive.py @@ -5,14 +5,11 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.exceptions import CommandExecutionError from salt.modules import mac_assistive as assistive @@ -139,8 +136,3 @@ class AssistiveTestCase(TestCase): with patch.dict(assistive.__salt__, {'cmd.run_all': mock_ret}): self.assertRaises(CommandExecutionError, assistive._get_assistive_access) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AssistiveTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_brew.py b/tests/unit/modules/test_mac_brew.py index 88d630a29e..8ddd68fbc1 100644 --- a/tests/unit/modules/test_mac_brew.py +++ b/tests/unit/modules/test_mac_brew.py @@ -13,9 +13,6 @@ from salt.exceptions import CommandExecutionError # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Global Variables mac_brew.__context__ = {} @@ -182,8 +179,3 @@ class BrewTestCase(TestCase): with patch.dict(mac_brew.__salt__, {'pkg_resource.parse_targets': mock_params}): self.assertEqual(mac_brew.install('name=foo'), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BrewTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_defaults.py b/tests/unit/modules/test_mac_defaults.py index e4d1efafcf..462628bf5d 100644 --- a/tests/unit/modules/test_mac_defaults.py +++ b/tests/unit/modules/test_mac_defaults.py @@ -8,14 +8,11 @@ from salt.modules import mac_defaults as macdefaults # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - macdefaults.__salt__ = {} @@ -86,8 +83,3 @@ class MacDefaultsTestCase(TestCase): with patch.dict(macdefaults.__salt__, {'cmd.run_all': mock}): macdefaults.delete('com.apple.CrashReporter', 'Crash', user="frank") mock.assert_called_once_with('defaults delete "com.apple.CrashReporter" "Crash"', output_loglevel='debug', runas="frank") - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacDefaultsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_desktop.py b/tests/unit/modules/test_mac_desktop.py index 48fe9fe157..3bf14f491f 100644 --- a/tests/unit/modules/test_mac_desktop.py +++ b/tests/unit/modules/test_mac_desktop.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import mac_desktop @@ -128,8 +125,3 @@ class MacDesktopTestCase(TestCase): with patch.dict(mac_desktop.__salt__, {'cmd.run_all': mock}): self.assertRaises(CommandExecutionError, mac_desktop.say) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacDesktopTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_group.py b/tests/unit/modules/test_mac_group.py index dd3d54f0c1..cfbeff23d3 100644 --- a/tests/unit/modules/test_mac_group.py +++ b/tests/unit/modules/test_mac_group.py @@ -181,8 +181,3 @@ class MacGroupTestCase(TestCase): {'file.group_to_gid': mock_pre_gid}): with patch.dict(mac_group.__salt__, {'cmd.retcode': mock_ret}): self.assertTrue(mac_group.chgid('test', 500)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacGroupTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_keychain.py b/tests/unit/modules/test_mac_keychain.py index 75697a4032..5e8ebd022e 100644 --- a/tests/unit/modules/test_mac_keychain.py +++ b/tests/unit/modules/test_mac_keychain.py @@ -8,14 +8,11 @@ from salt.modules import mac_keychain as keychain # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - keychain.__salt__ = {} @@ -107,7 +104,3 @@ class KeychainTestCase(TestCase): with patch.dict(keychain.__salt__, {'cmd.run': mock}): keychain.unlock_keychain('/path/to/chain.keychain', 'passw0rd') mock.assert_called_once_with('security unlock-keychain -p passw0rd /path/to/chain.keychain') - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeychainTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_package.py b/tests/unit/modules/test_mac_package.py index da05fbd9ae..66881a840b 100644 --- a/tests/unit/modules/test_mac_package.py +++ b/tests/unit/modules/test_mac_package.py @@ -8,15 +8,12 @@ from salt.modules import mac_package as macpackage # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, call ) -ensure_in_syspath('../../') - macpackage.__salt__ = {} @@ -254,7 +251,3 @@ class MacPackageTestCase(TestCase): cmd = '/usr/libexec/PlistBuddy -c "print :CFBundleIdentifier" \'/tmp/dmg-X/*.pkg/Contents/Info.plist\'' mock.assert_called_once_with(cmd, python_shell=True) self.assertEqual(out, expected) - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacPackageTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_power.py b/tests/unit/modules/test_mac_power.py index 53ecd68e53..41f810c92b 100644 --- a/tests/unit/modules/test_mac_power.py +++ b/tests/unit/modules/test_mac_power.py @@ -8,11 +8,8 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import mac_power from salt.exceptions import SaltInvocationError @@ -77,8 +74,3 @@ class MacPowerTestCase(TestCase): self.assertRaises(SaltInvocationError, mac_power._validate_sleep, 172.7) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacPowerTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_sysctl.py b/tests/unit/modules/test_mac_sysctl.py index 6b8293f88a..98064295b0 100644 --- a/tests/unit/modules/test_mac_sysctl.py +++ b/tests/unit/modules/test_mac_sysctl.py @@ -12,7 +12,6 @@ from salt.exceptions import CommandExecutionError # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, mock_open, @@ -22,8 +21,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Globals mac_sysctl.__salt__ = {} @@ -101,8 +98,3 @@ class DarwinSysctlTestCase(TestCase): helper_open = m_open() calls_list = helper_open.method_calls self.assertEqual(calls_list, m_calls_list) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DarwinSysctlTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_user.py b/tests/unit/modules/test_mac_user.py index a5a6a0cf72..72ef416fe1 100644 --- a/tests/unit/modules/test_mac_user.py +++ b/tests/unit/modules/test_mac_user.py @@ -10,11 +10,8 @@ import pwd # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import mac_user from salt.exceptions import SaltInvocationError, CommandExecutionError @@ -314,8 +311,3 @@ class MacUserTestCase(TestCase): ''' ret = ['_amavisd', '_appleevents', '_appowner'] self.assertEqual(mac_user.list_users(), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacUserTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mac_xattr.py b/tests/unit/modules/test_mac_xattr.py index 3daa532734..7ef2569fc2 100644 --- a/tests/unit/modules/test_mac_xattr.py +++ b/tests/unit/modules/test_mac_xattr.py @@ -5,11 +5,8 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch -ensure_in_syspath('../../') - # Import Salt Libs from salt.exceptions import CommandExecutionError from salt.modules import mac_xattr as xattr @@ -135,8 +132,3 @@ class XAttrTestCase(TestCase): Test clearing all attributes on a file ''' self.assertRaises(CommandExecutionError, xattr.clear, '/path/to/file') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(XAttrTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mdadm.py b/tests/unit/modules/test_mdadm.py index e5a175c2eb..d63b5fbe2e 100644 --- a/tests/unit/modules/test_mdadm.py +++ b/tests/unit/modules/test_mdadm.py @@ -12,9 +12,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs from salt.modules import mdadm @@ -56,7 +54,3 @@ class MdadmTestCase(TestCase): '--force -l 5 -e default -n 3 ' '/dev/sdb1 /dev/sdc1 /dev/sdd1'.split()), sorted(ret.split())) assert not mock.called, 'test mode failed, cmd.run called' - -if __name__ == '__main__': - from integration import run_tests - run_tests(MdadmTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_memcached.py b/tests/unit/modules/test_memcached.py index f8c6e0890c..8d974baba6 100644 --- a/tests/unit/modules/test_memcached.py +++ b/tests/unit/modules/test_memcached.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import memcached @@ -468,8 +465,3 @@ class MemcachedTestCase(TestCase): MagicMock(return_value=MockMemcache())): self.assertRaises(CommandExecutionError, memcached.decrement, 'salt') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MemcachedTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mine.py b/tests/unit/modules/test_mine.py index 835cc171d9..b281422793 100644 --- a/tests/unit/modules/test_mine.py +++ b/tests/unit/modules/test_mine.py @@ -13,9 +13,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import mine @@ -126,8 +123,3 @@ class MineTestCase(TestCase): ('172.17.42.1:80', 'abcdefhjhi1234567899'), ('192.168.0.1:80', 'abcdefhjhi1234567899'), ])}}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MineTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mod_random.py b/tests/unit/modules/test_mod_random.py index f60b71bad3..cfb094439c 100644 --- a/tests/unit/modules/test_mod_random.py +++ b/tests/unit/modules/test_mod_random.py @@ -13,9 +13,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import mod_random @@ -84,8 +81,3 @@ class ModrandomTestCase(TestCase): with patch.object(salt.utils.pycrypto, 'gen_hash', return_value='A'): self.assertEqual(mod_random.shadow_hash(), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ModrandomTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_modjk.py b/tests/unit/modules/test_modjk.py index e6aa9d42fa..819de099a4 100644 --- a/tests/unit/modules/test_modjk.py +++ b/tests/unit/modules/test_modjk.py @@ -14,10 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import modjk @@ -230,8 +226,3 @@ class ModjkTestCase(TestCase): {'worker.result.type': 'OK'}): self.assertTrue(modjk.worker_edit('node1', 'loadbalancer1', {'vwf': 500, 'vwd': 60})) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ModjkTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_monit.py b/tests/unit/modules/test_monit.py index 7adfd79f31..b4bb1f8149 100644 --- a/tests/unit/modules/test_monit.py +++ b/tests/unit/modules/test_monit.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import monit @@ -150,7 +147,3 @@ class MonitTestCase(TestCase): mock = MagicMock(return_value=0) with patch.dict(monit.__salt__, {'cmd.retcode': mock}): self.assertTrue(monit.validate()) - -if __name__ == '__main__': - from integration import run_tests - run_tests(MonitTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_moosefs.py b/tests/unit/modules/test_moosefs.py index 61a75b659e..d038498f71 100644 --- a/tests/unit/modules/test_moosefs.py +++ b/tests/unit/modules/test_moosefs.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import moosefs @@ -69,8 +66,3 @@ class MoosefsTestCase(TestCase): mock = MagicMock(return_value={'stdout': 'Salt: salt'}) with patch.dict(moosefs.__salt__, {'cmd.run_all': mock}): self.assertDictEqual(moosefs.getgoal('/tmp/salt'), {'goal': 'salt'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MoosefsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mount.py b/tests/unit/modules/test_mount.py index ad5427c135..72e2af8c52 100644 --- a/tests/unit/modules/test_mount.py +++ b/tests/unit/modules/test_mount.py @@ -346,7 +346,3 @@ class MountTestCase(TestCase): mock = MagicMock(return_value={'name': 'name'}) with patch.object(mount, 'active', mock): self.assertTrue(mount.is_mounted('name')) - -if __name__ == '__main__': - from integration import run_tests - run_tests(MountTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_munin.py b/tests/unit/modules/test_munin.py index 55df2b481f..8e37939b39 100644 --- a/tests/unit/modules/test_munin.py +++ b/tests/unit/modules/test_munin.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../..') # Import Salt Libs from salt.modules import munin @@ -64,8 +61,3 @@ class MuninTestCase(TestCase): Test if it list all the munin plugins ''' self.assertListEqual(munin.list_plugins(), ['uptime']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MuninTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_mysql.py b/tests/unit/modules/test_mysql.py index 87f61241f6..63598b53a9 100644 --- a/tests/unit/modules/test_mysql.py +++ b/tests/unit/modules/test_mysql.py @@ -12,11 +12,8 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call -ensure_in_syspath('../../') - # Import salt libs from salt.modules import mysql @@ -297,8 +294,3 @@ class MySQLTestCase(TestCase): else: calls = call().cursor().execute('{0}'.format(expected_sql)) connect_mock.assert_has_calls((calls,), True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MySQLTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_nagios.py b/tests/unit/modules/test_nagios.py index 1c8bb27a5a..6f5f1f40ea 100644 --- a/tests/unit/modules/test_nagios.py +++ b/tests/unit/modules/test_nagios.py @@ -13,9 +13,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import nagios @@ -86,8 +83,3 @@ class NagiosTestCase(TestCase): ''' with patch.object(os, 'listdir', return_value=[]): self.assertEqual(nagios.list_plugins(), []) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NagiosTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_netscaler.py b/tests/unit/modules/test_netscaler.py index f891a7dbef..34ec8edf52 100644 --- a/tests/unit/modules/test_netscaler.py +++ b/tests/unit/modules/test_netscaler.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import netscaler @@ -1123,8 +1119,3 @@ class NetscalerTestCase(TestCase): MagicMock(return_value=None)): self.assertFalse(netscaler.vserver_sslcert_delete ('vserverName', 'serGroupName')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetscalerTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_network.py b/tests/unit/modules/test_network.py index 56738370a1..75f08c09e8 100644 --- a/tests/unit/modules/test_network.py +++ b/tests/unit/modules/test_network.py @@ -18,10 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs import salt.ext.six as six import salt.utils @@ -358,8 +354,3 @@ class NetworkTestCase(TestCase): with patch.dict(network.__grains__, {'kernel': 'Linux'}): self.assertListEqual(network.default_route('inet'), []) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetworkTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_network_utils.py b/tests/unit/modules/test_network_utils.py index c30f7c97e0..b5192e31b1 100644 --- a/tests/unit/modules/test_network_utils.py +++ b/tests/unit/modules/test_network_utils.py @@ -18,8 +18,3 @@ class NetworkUtilsTestCase(ModuleCase): def test_is_loopback(self): __salt__ = salt.loader.raw_mod(self.minion_opts, 'network', None) self.assertTrue(__salt__['network.is_loopback']('127.0.0.1'), True) - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetworkUtilsTestCase, - needs_daemon=False) diff --git a/tests/unit/modules/test_neutron.py b/tests/unit/modules/test_neutron.py index 87b48e1dd4..fa8f8d9c61 100644 --- a/tests/unit/modules/test_neutron.py +++ b/tests/unit/modules/test_neutron.py @@ -14,10 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import neutron @@ -1035,8 +1031,3 @@ class NeutronTestCase(TestCase): ''' self.assertTrue(neutron.delete_ipsecpolicy('SALT', profile='openstack1')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NeutronTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_nfs3.py b/tests/unit/modules/test_nfs3.py index 0628aac9e8..6871458bca 100644 --- a/tests/unit/modules/test_nfs3.py +++ b/tests/unit/modules/test_nfs3.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( mock_open, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import nfs3 @@ -55,8 +52,3 @@ class NfsTestCase(TestCase): ['B1'], 'options': ['23']}]}): with patch.object(nfs3, '_write_exports', return_value=None): self.assertDictEqual(nfs3.del_export(path='A'), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NfsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_nftables.py b/tests/unit/modules/test_nftables.py index b4eae6b430..efed13560c 100644 --- a/tests/unit/modules/test_nftables.py +++ b/tests/unit/modules/test_nftables.py @@ -16,10 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import nftables import salt.utils @@ -484,8 +480,3 @@ class NftablesTestCase(TestCase): with patch.dict(nftables.__salt__, {'cmd.run': mock}): self.assertFalse(nftables.flush(table='filter', chain='input')) self.assertTrue(nftables.flush(table='filter', chain='input')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NftablesTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_nginx.py b/tests/unit/modules/test_nginx.py index 8e310f58c2..50127767dc 100644 --- a/tests/unit/modules/test_nginx.py +++ b/tests/unit/modules/test_nginx.py @@ -5,9 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch -ensure_in_syspath('../../') # Import Salt Module from salt.modules import nginx @@ -50,8 +48,3 @@ class NginxTestCase(TestCase): other_path = 'http://localhost/path' result = nginx.status(other_path) nginx._urlopen.assert_called_once_with(other_path) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NginxTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_nova.py b/tests/unit/modules/test_nova.py index 9ce018261f..9338d0deb6 100644 --- a/tests/unit/modules/test_nova.py +++ b/tests/unit/modules/test_nova.py @@ -320,8 +320,3 @@ class NovaTestCase(TestCase): with patch.object(mock_auth, 'server_by_name', MagicMock(return_value='A')): self.assertTrue(nova.server_by_name('name')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NovaTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_npm.py b/tests/unit/modules/test_npm.py index 6dbbe26885..cb210d9d42 100644 --- a/tests/unit/modules/test_npm.py +++ b/tests/unit/modules/test_npm.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import npm from salt.exceptions import CommandExecutionError @@ -154,8 +150,3 @@ class NpmTestCase(TestCase): 'stdout': '/User/salt/.npm'}) with patch.dict(npm.__salt__, {'cmd.run_all': mock}): self.assertEqual(npm.cache_path(), '/User/salt/.npm') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NpmTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_openbsdpkg.py b/tests/unit/modules/test_openbsdpkg.py index fe8fd97e0d..1b77066204 100644 --- a/tests/unit/modules/test_openbsdpkg.py +++ b/tests/unit/modules/test_openbsdpkg.py @@ -111,8 +111,3 @@ class OpenbsdpkgTestCase(TestCase): ] run_all_mock.assert_has_calls(expected_calls, any_order=True) self.assertEqual(run_all_mock.call_count, 3) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(OpenbsdpkgTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_openstack_config.py b/tests/unit/modules/test_openstack_config.py index 9f8013986e..a4e1a1b65f 100644 --- a/tests/unit/modules/test_openstack_config.py +++ b/tests/unit/modules/test_openstack_config.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import openstack_config from salt.exceptions import CommandExecutionError @@ -91,8 +87,3 @@ class OpenstackConfigTestCase(TestCase): with patch.dict(openstack_config.__salt__, {'cmd.run_all': mock}): self.assertRaises(CommandExecutionError, openstack_config.delete, '/etc/key/keystone.conf', 'sql', 'connection') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(OpenstackConfigTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_oracle.py b/tests/unit/modules/test_oracle.py index 7d5df1a8ba..7b51a98cac 100644 --- a/tests/unit/modules/test_oracle.py +++ b/tests/unit/modules/test_oracle.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import oracle import os @@ -87,8 +84,3 @@ class OracleTestCase(TestCase): 'TNS_ADMIN': 'TNS_ADMIN', 'NLS_LANG': 'NLS_LANG'}): self.assertDictEqual(oracle.show_env(), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(OracleTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pacman.py b/tests/unit/modules/test_pacman.py index 7bbb07175d..d543fa4918 100644 --- a/tests/unit/modules/test_pacman.py +++ b/tests/unit/modules/test_pacman.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import pacman @@ -136,7 +132,3 @@ class PacmanTestCase(TestCase): }): results = pacman.group_diff('testgroup') self.assertEqual(results['default'], {'installed': ['A'], 'not installed': ['C']}) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PacmanTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pagerduty.py b/tests/unit/modules/test_pagerduty.py index 4fce593ff8..d63a7c9af6 100644 --- a/tests/unit/modules/test_pagerduty.py +++ b/tests/unit/modules/test_pagerduty.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( patch, MagicMock, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs import salt.utils from salt.modules import pagerduty @@ -91,8 +88,3 @@ class PagerdutyTestCase(TestCase): with patch.object(salt.utils.pagerduty, 'query', return_value='A'): self.assertListEqual(pagerduty.create_event(), ['A']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PagerdutyTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pam.py b/tests/unit/modules/test_pam.py index a12721827c..f6653da990 100644 --- a/tests/unit/modules/test_pam.py +++ b/tests/unit/modules/test_pam.py @@ -16,10 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import pam @@ -42,8 +38,3 @@ class PamTestCase(TestCase): self.assertListEqual(pam.read_file('/etc/pam.d/login'), [{'arguments': [], 'control_flag': 'ok', 'interface': 'ok', 'module': 'ignore'}]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PamTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_parallels.py b/tests/unit/modules/test_parallels.py index 6fe34ab19a..ce8d9fd5f0 100644 --- a/tests/unit/modules/test_parallels.py +++ b/tests/unit/modules/test_parallels.py @@ -11,12 +11,10 @@ from salt.exceptions import SaltInvocationError # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath # Import third party libs import salt.ext.six as six -ensure_in_syspath('../../') parallels.__salt__ = {} @@ -602,8 +600,3 @@ class ParallelsTestCase(TestCase): mock_delete.assert_called_once_with('snapshot-switch', [name, '--id', snap_id], runas=None) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ParallelsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_parted.py b/tests/unit/modules/test_parted.py index 131b27999e..3964b527a8 100644 --- a/tests/unit/modules/test_parted.py +++ b/tests/unit/modules/test_parted.py @@ -12,9 +12,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs from salt.exceptions import CommandExecutionError @@ -326,8 +324,3 @@ class PartedTestCase(TestCase): } } self.assertEqual(output, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PartedTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pecl.py b/tests/unit/modules/test_pecl.py index c3572b4353..03796db643 100644 --- a/tests/unit/modules/test_pecl.py +++ b/tests/unit/modules/test_pecl.py @@ -14,10 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import pecl @@ -59,8 +55,3 @@ class PeclTestCase(TestCase): ''' with patch.object(pecl, '_pecl', return_value='A\nB'): self.assertDictEqual(pecl.list_('channel'), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PeclTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pillar.py b/tests/unit/modules/test_pillar.py index e01b3f933d..7407ba88ef 100644 --- a/tests/unit/modules/test_pillar.py +++ b/tests/unit/modules/test_pillar.py @@ -5,7 +5,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -13,8 +12,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt libs import salt.ext.six as six from salt.utils.odict import OrderedDict @@ -107,9 +104,3 @@ class PillarModuleTestCase(TestCase): pillarmod.get(key='foo', default=None, merge=True), 'bar', ) - - -# gracinet: not sure this is really useful, but other test modules have this as well -if __name__ == '__main__': - from integration import run_tests - run_tests(PillarModuleTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pip.py b/tests/unit/modules/test_pip.py index d17b9362bc..4a9040b3bd 100644 --- a/tests/unit/modules/test_pip.py +++ b/tests/unit/modules/test_pip.py @@ -6,9 +6,7 @@ import os # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs from salt.modules import pip @@ -1117,8 +1115,3 @@ class PipTestCase(TestCase): use_vt=False, python_shell=False, ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PipTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pkg_resource.py b/tests/unit/modules/test_pkg_resource.py index 3862a1f0d5..ff2aecd7dc 100644 --- a/tests/unit/modules/test_pkg_resource.py +++ b/tests/unit/modules/test_pkg_resource.py @@ -157,8 +157,3 @@ class PkgresTestCase(TestCase): 'A') self.assertTrue(pkg_resource.check_extra_requirements('a', False)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PkgresTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pkgutil.py b/tests/unit/modules/test_pkgutil.py index 3d6842ae63..d90ee4d0ee 100644 --- a/tests/unit/modules/test_pkgutil.py +++ b/tests/unit/modules/test_pkgutil.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import pkgutil from salt.exceptions import CommandExecutionError, MinionError @@ -228,8 +224,3 @@ class PkgutilTestCase(TestCase): with patch.dict(pkgutil.__salt__, {'pkg_resource.parse_targets': mock_pkg}): self.assertRaises(CommandExecutionError, pkgutil.purge) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PkgutilTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_portage_config.py b/tests/unit/modules/test_portage_config.py index dca1bae480..195d6ddd46 100644 --- a/tests/unit/modules/test_portage_config.py +++ b/tests/unit/modules/test_portage_config.py @@ -10,9 +10,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -ensure_in_syspath('../../') # Import salt libs from salt.modules import portage_config @@ -39,7 +37,3 @@ class PortageConfigTestCase(TestCase): portage_config.portage.dep.Atom = MagicMock(return_value=dummy_atom) portage_config._p_to_cp = MagicMock(return_value=dummy_atom.cp) self.assertEqual(portage_config._get_config_file('mask', atom), expected) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PortageConfigTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_postfix.py b/tests/unit/modules/test_postfix.py index a963c4d910..474de3024f 100644 --- a/tests/unit/modules/test_postfix.py +++ b/tests/unit/modules/test_postfix.py @@ -14,10 +14,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import postfix @@ -135,8 +131,3 @@ class PostfixTestCase(TestCase): self.assertDictEqual(postfix.requeue('ALL'), {'result': True, 'message': 'Successfully requeued all messages'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostfixTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_postgres.py b/tests/unit/modules/test_postgres.py index b0ed2d7f65..0b095d8759 100644 --- a/tests/unit/modules/test_postgres.py +++ b/tests/unit/modules/test_postgres.py @@ -7,9 +7,7 @@ import re # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch -ensure_in_syspath('../../') # Import salt libs from salt.modules import postgres @@ -1480,7 +1478,3 @@ class PostgresTestCase(TestCase): name = '/var/lib/pgsql/data' ret = postgres.datadir_exists(name) self.assertTrue(ret) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_poudriere.py b/tests/unit/modules/test_poudriere.py index d88c88480d..541077e284 100644 --- a/tests/unit/modules/test_poudriere.py +++ b/tests/unit/modules/test_poudriere.py @@ -6,6 +6,8 @@ # Import Python Libs from __future__ import absolute_import +import os + # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import ( @@ -16,11 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath -import os - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import poudriere @@ -248,8 +245,3 @@ class PoudriereTestCase(TestCase): with patch.dict(poudriere.__salt__, {'cmd.run': mock}): self.assertEqual(poudriere.bulk_build('90amd64', '/root/pkg_list'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PoudriereTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_powerpath.py b/tests/unit/modules/test_powerpath.py index fd4277a59d..177baca6b3 100644 --- a/tests/unit/modules/test_powerpath.py +++ b/tests/unit/modules/test_powerpath.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import powerpath @@ -79,8 +75,3 @@ class PowerpathTestCase(TestCase): self.assertDictEqual(powerpath.remove_license('key'), {'output': 'stderr', 'result': False, 'retcode': 1}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PowerpathTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_proxy.py b/tests/unit/modules/test_proxy.py index 6273c9c90f..3eb601c10c 100644 --- a/tests/unit/modules/test_proxy.py +++ b/tests/unit/modules/test_proxy.py @@ -8,7 +8,6 @@ from salt.modules import proxy as proxy # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -17,8 +16,6 @@ from tests.support.mock import ( call ) -ensure_in_syspath('../../') - proxy.__salt__ = {} proxy.__grains__ = {'os': 'Darwin'} @@ -405,7 +402,3 @@ class ProxyTestCase(TestCase): mock_reg.assert_has_calls(calls) mock_cmd.assert_called_once_with('netsh winhttp import proxy source=ie') self.assertTrue(out) - -if __name__ == '__main__': - from integration import run_tests - run_tests(ProxyTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ps.py b/tests/unit/modules/test_ps.py index 9545e5edb8..ff530b2035 100644 --- a/tests/unit/modules/test_ps.py +++ b/tests/unit/modules/test_ps.py @@ -8,11 +8,8 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch, call, Mock -ensure_in_syspath('../../') - # Import Salt libs from salt.modules import ps import salt.ext.six as six @@ -184,8 +181,3 @@ class PsTestCase(TestCase): # @patch('salt.utils.psutil_compat.get_users', new=MagicMock(return_value=None)) # This will force the function to use utmp # def test_get_users_utmp(self): # pass - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(PsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_publish.py b/tests/unit/modules/test_publish.py index 2cb323a2a8..daea338299 100644 --- a/tests/unit/modules/test_publish.py +++ b/tests/unit/modules/test_publish.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import publish import salt.crypt @@ -116,8 +112,3 @@ class PublishTestCase(TestCase): Channel.flag = 1 self.assertEqual(publish.runner('manage.down'), "'manage.down' runner publish timed out") - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PublishTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_puppet.py b/tests/unit/modules/test_puppet.py index b71e5903b8..cb2974b1a3 100644 --- a/tests/unit/modules/test_puppet.py +++ b/tests/unit/modules/test_puppet.py @@ -9,7 +9,6 @@ import os # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( mock_open, MagicMock, @@ -18,8 +17,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs import salt.utils from salt.modules import puppet @@ -185,7 +182,3 @@ class PuppetTestCase(TestCase): self.assertEqual(puppet.fact("salt"), "") self.assertTrue(puppet.fact("salt")) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PuppetTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pw_group.py b/tests/unit/modules/test_pw_group.py index ad51429a77..fbb2f27132 100644 --- a/tests/unit/modules/test_pw_group.py +++ b/tests/unit/modules/test_pw_group.py @@ -94,8 +94,3 @@ class PwGroupTestCase(TestCase): mock = MagicMock(return_value=None) with patch.dict(pw_group.__salt__, {'cmd.run': mock}): self.assertFalse(pw_group.chgid('name', 0)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PwGroupTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pw_user.py b/tests/unit/modules/test_pw_user.py index b0643c066a..ead30bd8dc 100644 --- a/tests/unit/modules/test_pw_user.py +++ b/tests/unit/modules/test_pw_user.py @@ -358,7 +358,3 @@ class PwUserTestCase(TestCase): mock = MagicMock(side_effect=[{'name': ''}, False, {'name': ''}]) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.rename('name', 'name')) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PwUserTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_pyenv.py b/tests/unit/modules/test_pyenv.py index 0d60d4f257..7dea8252aa 100644 --- a/tests/unit/modules/test_pyenv.py +++ b/tests/unit/modules/test_pyenv.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import pyenv @@ -212,8 +208,3 @@ class PyenvTestCase(TestCase): 'cmd.run_all': mock_all}): self.assertFalse(pyenv.do_with_python('2.0.0-p0', 'gem list bundler')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PyenvTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_qemu_img.py b/tests/unit/modules/test_qemu_img.py index e6fd14e318..a6607fe4a3 100644 --- a/tests/unit/modules/test_qemu_img.py +++ b/tests/unit/modules/test_qemu_img.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import qemu_img import os @@ -54,8 +50,3 @@ class QemuimgTestCase(TestCase): self.assertEqual(qemu_img.make_image('location', 'size', 'fmt'), '') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(QemuimgTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_qemu_nbd.py b/tests/unit/modules/test_qemu_nbd.py index 0fc395ecf5..2b4f39f22d 100644 --- a/tests/unit/modules/test_qemu_nbd.py +++ b/tests/unit/modules/test_qemu_nbd.py @@ -18,10 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import qemu_nbd @@ -107,8 +103,3 @@ class QemuNbdTestCase(TestCase): {'/mnt/foo': '/dev/nbd0p1'}) self.assertDictEqual(qemu_nbd.clear({"/mnt/foo": "/dev/nbd0p1"}), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(QemuNbdTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rabbitmq.py b/tests/unit/modules/test_rabbitmq.py index ae4c639fee..0172bf0747 100644 --- a/tests/unit/modules/test_rabbitmq.py +++ b/tests/unit/modules/test_rabbitmq.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import rabbitmq from salt.exceptions import CommandExecutionError @@ -521,8 +517,3 @@ class RabbitmqTestCase(TestCase): 'pkg.version': mock_pkg}): self.assertDictEqual(rabbitmq.disable_plugin('salt'), {'Disabled': 'saltstack'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitmqTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_raet_publish.py b/tests/unit/modules/test_raet_publish.py index 883591df60..c4dd5e4cbb 100644 --- a/tests/unit/modules/test_raet_publish.py +++ b/tests/unit/modules/test_raet_publish.py @@ -14,10 +14,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import raet_publish import salt.transport @@ -74,8 +70,3 @@ class RaetPublishTestCase(TestCase): MagicMock(return_value=MockFactory())): self.assertEqual(raet_publish.runner(1), '\'1\' runner publish timed out') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RaetPublishTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rbenv.py b/tests/unit/modules/test_rbenv.py index ed0cbcc4f4..2b29bb963f 100644 --- a/tests/unit/modules/test_rbenv.py +++ b/tests/unit/modules/test_rbenv.py @@ -14,10 +14,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import rbenv import os @@ -129,8 +125,3 @@ class RbenvTestCase(TestCase): ''' with patch.object(rbenv, 'do', return_value='A'): self.assertEqual(rbenv.do_with_ruby('ruby', 'cmdline'), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RbenvTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rdp.py b/tests/unit/modules/test_rdp.py index 689e4fd1de..0c915db973 100644 --- a/tests/unit/modules/test_rdp.py +++ b/tests/unit/modules/test_rdp.py @@ -61,8 +61,3 @@ class RdpTestCase(TestCase): mock = MagicMock(return_value='1') with patch.dict(rdp.__salt__, {'cmd.run': mock}): self.assertTrue(rdp.status()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RdpTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_redismod.py b/tests/unit/modules/test_redismod.py index da44cad8fe..eae732a6b6 100644 --- a/tests/unit/modules/test_redismod.py +++ b/tests/unit/modules/test_redismod.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import redismod from datetime import datetime @@ -467,8 +463,3 @@ class RedismodTestCase(TestCase): Test to get a range of values from a sorted set in Redis by index ''' self.assertEqual(redismod.zrange('key', 'start', 'stop'), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RedismodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_reg_win.py b/tests/unit/modules/test_reg_win.py index 8a7bacc1db..5c66464d3c 100644 --- a/tests/unit/modules/test_reg_win.py +++ b/tests/unit/modules/test_reg_win.py @@ -300,7 +300,3 @@ class RegWinTestCase(TestCase): # pylint: disable=W0511 # TODO: Test other hives, other than HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=C0413 - run_tests(RegWinTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ret.py b/tests/unit/modules/test_ret.py index 3adc3aba86..4ac357bc47 100644 --- a/tests/unit/modules/test_ret.py +++ b/tests/unit/modules/test_ret.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import ret import salt.loader @@ -77,8 +73,3 @@ class RetTestCase(TestCase): MagicMock(return_value= {'mysql.get_minions': mock_ret})): self.assertEqual(ret.get_minions('mysql'), 'DB') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RetTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rh_ip.py b/tests/unit/modules/test_rh_ip.py index 971c537799..85f6dca130 100644 --- a/tests/unit/modules/test_rh_ip.py +++ b/tests/unit/modules/test_rh_ip.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import rh_ip import jinja2.exceptions @@ -208,8 +204,3 @@ class RhipTestCase(TestCase): return_value='A'): self.assertEqual(rh_ip.build_network_settings (test=None), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RhipTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rh_service.py b/tests/unit/modules/test_rh_service.py index 32b78c4f20..467d1c1518 100644 --- a/tests/unit/modules/test_rh_service.py +++ b/tests/unit/modules/test_rh_service.py @@ -16,10 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import rh_service @@ -352,8 +348,3 @@ class RhServiceTestCase(TestCase): with patch.object(rh_service, '_sysv_is_enabled', self._m_bool(False)): self.assertTrue(rh_service.disabled('salt-api')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RhServiceTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_riak.py b/tests/unit/modules/test_riak.py index ca86721204..24d06bf687 100644 --- a/tests/unit/modules/test_riak.py +++ b/tests/unit/modules/test_riak.py @@ -12,10 +12,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import riak @@ -118,7 +114,3 @@ class RiakTestCase(TestCase): ''' with patch.object(riak, '__execute_cmd', return_value={'stdout': '[a,b,c]'}): self.assertEqual(riak.services(), ['a', 'b', 'c']) - -if __name__ == '__main__': - from integration import run_tests - run_tests(RiakTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rpm.py b/tests/unit/modules/test_rpm.py index 5b587054c5..555a595dd2 100644 --- a/tests/unit/modules/test_rpm.py +++ b/tests/unit/modules/test_rpm.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import rpm @@ -135,7 +131,3 @@ class RpmTestCase(TestCase): rpm.rpm = MagicMock(return_value=MagicMock) with patch('salt.modules.rpm.rpm.labelCompare', MagicMock(return_value=0)): self.assertEqual(-1, rpm.version_cmp('1', '2')) # mock returns -1, a python implementation was called - -if __name__ == '__main__': - from integration import run_tests - run_tests(RpmTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rsync.py b/tests/unit/modules/test_rsync.py index 12a7a021f6..306a0282b7 100644 --- a/tests/unit/modules/test_rsync.py +++ b/tests/unit/modules/test_rsync.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import rsync from salt.exceptions import CommandExecutionError, SaltInvocationError @@ -56,8 +52,3 @@ class RsyncTestCase(TestCase): self.assertRaises(CommandExecutionError, rsync.version) self.assertEqual(rsync.version(), 'C') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RsyncTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_rvm.py b/tests/unit/modules/test_rvm.py index 9ab766c711..b51c129b17 100644 --- a/tests/unit/modules/test_rvm.py +++ b/tests/unit/modules/test_rvm.py @@ -5,10 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch, call -ensure_in_syspath('../../') - # Import salt libs import salt.modules.rvm as rvm @@ -148,8 +145,3 @@ gemsets for ruby-1.9.2-p180 (found in /usr/local/rvm/gems/ruby-1.9.2-p180) 'ruby-1.9.3-p125': ['9bar', '9foo', 'global'], 'ruby-head': ['global', 'headbar', 'headfoo']}, rvm.gemset_list_all()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestRvmModule, needs_daemon=False) diff --git a/tests/unit/modules/test_s3.py b/tests/unit/modules/test_s3.py index ef6f164518..27ace2c0fc 100644 --- a/tests/unit/modules/test_s3.py +++ b/tests/unit/modules/test_s3.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import s3 @@ -81,8 +77,3 @@ class S3TestCase(TestCase): 'verify_ssl', 'kms_keyid', 'location', 'role_arn', 'path_style', 'https_enable')): self.assertEqual(s3.put('bucket'), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(S3TestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_saltcloudmod.py b/tests/unit/modules/test_saltcloudmod.py index a06d53a1cd..2476895015 100644 --- a/tests/unit/modules/test_saltcloudmod.py +++ b/tests/unit/modules/test_saltcloudmod.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import saltcloudmod @@ -70,8 +67,3 @@ class SaltcloudmodTestCase(TestCase): ), {} ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SaltcloudmodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_schedule.py b/tests/unit/modules/test_schedule.py index 37c63ad840..ad88db9d2a 100644 --- a/tests/unit/modules/test_schedule.py +++ b/tests/unit/modules/test_schedule.py @@ -5,8 +5,10 @@ # Import Python Libs from __future__ import absolute_import +import os # Import Salt Testing Libs +import tests.integration as integration from tests.support.unit import TestCase, skipIf from tests.support.mock import ( MagicMock, @@ -15,14 +17,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -import os -import integration -SOCK_DIR = os.path.join(integration.TMP, 'test-socks') - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import schedule from salt.utils.event import SaltEvent @@ -32,6 +26,8 @@ schedule.__salt__ = {} schedule.__opts__ = {} schedule.__pillar__ = {} +SOCK_DIR = os.path.join(integration.TMP, 'test-socks') + JOB1 = {'function': 'test.ping', 'maxrunning': 1, 'name': 'job1', 'jid_include': True, 'enabled': True} @@ -354,8 +350,3 @@ class ScheduleTestCase(TestCase): {'comment': comm3, 'minions': ['minion1'], 'result': True}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ScheduleTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_scsi.py b/tests/unit/modules/test_scsi.py index 9670cc9002..98db9caebc 100644 --- a/tests/unit/modules/test_scsi.py +++ b/tests/unit/modules/test_scsi.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import scsi import os @@ -96,8 +92,3 @@ class ScsiTestCase(TestCase): with patch.dict(scsi.__salt__, {'cmd.run': MagicMock(return_value='A')}): self.assertListEqual(scsi.rescan_all('host'), ['A']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ScsiTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_sdb.py b/tests/unit/modules/test_sdb.py index c667bc5fa1..300afce3b9 100644 --- a/tests/unit/modules/test_sdb.py +++ b/tests/unit/modules/test_sdb.py @@ -13,10 +13,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import sdb @@ -47,8 +43,3 @@ class SdbTestCase(TestCase): sdb:/// ''' self.assertFalse(sdb.set_('sdb://mymemcached/foo', 'bar')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SdbTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_seed.py b/tests/unit/modules/test_seed.py index d3585cd3d9..72ba4c52e3 100644 --- a/tests/unit/modules/test_seed.py +++ b/tests/unit/modules/test_seed.py @@ -19,10 +19,6 @@ from tests.support.mock import ( # Import Salt Libs import salt.utils.odict from salt.modules import seed -from tests.support.helpers import ensure_in_syspath - - -ensure_in_syspath('../../') # Globals seed.__salt__ = {} @@ -91,8 +87,3 @@ class SeedTestCase(TestCase): return_value=None): self.assertFalse(seed.apply_('path', install=False)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SeedTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_sensors.py b/tests/unit/modules/test_sensors.py index 2351fb94b5..9368eaa283 100644 --- a/tests/unit/modules/test_sensors.py +++ b/tests/unit/modules/test_sensors.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import sensors @@ -36,8 +32,3 @@ class SensorTestCase(TestCase): with patch.dict(sensors.__salt__, {'cmd.run': MagicMock(return_value='A:a B:b C:c D:d')}): self.assertDictEqual(sensors.sense('chip'), {'A': 'a B'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SensorTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_serverdensity_device.py b/tests/unit/modules/test_serverdensity_device.py index 8a1d3e4a89..01648b053f 100644 --- a/tests/unit/modules/test_serverdensity_device.py +++ b/tests/unit/modules/test_serverdensity_device.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import serverdensity_device from salt.exceptions import CommandExecutionError @@ -242,8 +238,3 @@ class ServerdensityDeviceTestCase(TestCase): self.assertTrue( serverdensity_device.install_agent( '51f7e', agent_version=2)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ServerdensityDeviceTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_service.py b/tests/unit/modules/test_service.py index f821cb653e..e12ecdd1af 100644 --- a/tests/unit/modules/test_service.py +++ b/tests/unit/modules/test_service.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import service import os @@ -111,8 +107,3 @@ class ServiceTestCase(TestCase): with patch.object(os, 'listdir', return_value=['A', 'B']): self.assertListEqual(service.get_all(), ['A', 'B']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ServiceTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_servicenow.py b/tests/unit/modules/test_servicenow.py index 4339fa5387..de1be15e70 100644 --- a/tests/unit/modules/test_servicenow.py +++ b/tests/unit/modules/test_servicenow.py @@ -14,11 +14,8 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath from salt.modules import servicenow -ensure_in_syspath('../../') - SERVICE_NAME = 'servicenow' servicenow.__salt__ = {} @@ -73,7 +70,3 @@ class ServiceNowModuleTestCase(ModuleTestCase): type='computer') self.assertFalse(result is None) self.assertEqual(result[0]['query_size'], 22) - -if __name__ == '__main__': - from unit import run_tests - run_tests(ServiceNowModuleTestCase) diff --git a/tests/unit/modules/test_shadow.py b/tests/unit/modules/test_shadow.py index 12b5efe6b6..c11c9c728e 100644 --- a/tests/unit/modules/test_shadow.py +++ b/tests/unit/modules/test_shadow.py @@ -9,8 +9,6 @@ from __future__ import absolute_import # Import Salt Testing libs from salt.utils import is_linux from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs try: @@ -59,7 +57,3 @@ class LinuxShadowTest(TestCase): ), hash_info['pw_hash'] ) - -if __name__ == '__main__': - from integration import run_tests - run_tests(LinuxShadowTest, needs_daemon=False) diff --git a/tests/unit/modules/test_smf.py b/tests/unit/modules/test_smf.py index d26114747d..0a263facdc 100644 --- a/tests/unit/modules/test_smf.py +++ b/tests/unit/modules/test_smf.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import smf @@ -178,8 +174,3 @@ class SmfTestCase(TestCase): ''' with patch.object(smf, '_get_enabled_disabled', return_value=True): self.assertTrue(smf.get_disabled()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SmfTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_smtp.py b/tests/unit/modules/test_smtp.py index 0d214987ab..4bc3241b59 100644 --- a/tests/unit/modules/test_smtp.py +++ b/tests/unit/modules/test_smtp.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import smtp @@ -299,8 +295,3 @@ class SmtpTestCase(TestCase): self.assertFalse(smtp.send_msg('admin@example.com', 'This is a salt module test', profile='my-smtp-account')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SmtpTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_snapper.py b/tests/unit/modules/test_snapper.py index f550dd68b7..4e27190e87 100644 --- a/tests/unit/modules/test_snapper.py +++ b/tests/unit/modules/test_snapper.py @@ -19,9 +19,6 @@ from tests.support.mock import ( patch, mock_open, ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.ext.six as six @@ -396,8 +393,3 @@ class SnapperTestCase(TestCase): "/tmp/foo3": MODULE_RET['DIFF']["/tmp/foo3"], } self.assertEqual(snapper.diff(), module_ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SnapperTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_solr.py b/tests/unit/modules/test_solr.py index a81b27dc9a..b88840d9ae 100644 --- a/tests/unit/modules/test_solr.py +++ b/tests/unit/modules/test_solr.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import solr import os @@ -541,8 +537,3 @@ class SolrTestCase(TestCase): {'A': 'a'}) self.assertEqual(solr.import_status('h'), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SolrTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_sqlite3.py b/tests/unit/modules/test_sqlite3.py index a3cb7ef589..569bbfd6e0 100644 --- a/tests/unit/modules/test_sqlite3.py +++ b/tests/unit/modules/test_sqlite3.py @@ -13,10 +13,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import sqlite3 import salt @@ -139,8 +135,3 @@ class Sqlite3TestCase(TestCase): for people with poor spelling skills ''' self.assertTrue(sqlite3.indexes('/root/test.db')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(Sqlite3TestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_ssh.py b/tests/unit/modules/test_ssh.py index a063da6500..5e3621e9ab 100644 --- a/tests/unit/modules/test_ssh.py +++ b/tests/unit/modules/test_ssh.py @@ -5,14 +5,12 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) # Import Salt Libs -ensure_in_syspath('../../') from salt.modules import ssh from salt.exceptions import CommandExecutionError @@ -60,8 +58,3 @@ class SSHAuthKeyTestCase(TestCase): # Inserting invalid public key should be rejected invalid_key = 'AAAAB3NzaC1kc3MAAACBAL0sQ9fJ5bYTEyY' # missing padding self.assertEqual(ssh.set_auth_key('user', invalid_key), 'Invalid public key') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SSHAuthKeyTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_state.py b/tests/unit/modules/test_state.py index ecff57459c..c0c09bf726 100644 --- a/tests/unit/modules/test_state.py +++ b/tests/unit/modules/test_state.py @@ -10,7 +10,6 @@ import os # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from salt.exceptions import SaltInvocationError -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -19,8 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs import salt.utils from salt.modules import state @@ -976,7 +973,3 @@ class StateTestCase(TestCase): with patch('salt.utils.fopen', mock_open()): self.assertTrue(state.pkg("/tmp/state_pkg.tgz", 0, "md5")) - -if __name__ == '__main__': - from integration import run_tests - run_tests(StateTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_status.py b/tests/unit/modules/test_status.py index 5ebec273e4..35aaf2f5d1 100644 --- a/tests/unit/modules/test_status.py +++ b/tests/unit/modules/test_status.py @@ -9,15 +9,12 @@ from salt.exceptions import CommandExecutionError # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, mock_open, ) -ensure_in_syspath('../../') - # Globals status.__salt__ = {} status.__grains__ = {} @@ -149,8 +146,3 @@ class StatusTestCase(TestCase): with self.assertRaises(CommandExecutionError): with patch.dict(status.__salt__, {'cmd.run': exc_mock}): status.uptime() - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StatusTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_supervisord.py b/tests/unit/modules/test_supervisord.py index 94d6aec7f0..372fdbe441 100644 --- a/tests/unit/modules/test_supervisord.py +++ b/tests/unit/modules/test_supervisord.py @@ -15,13 +15,9 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath -from salt.exceptions import CommandExecutionError - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import supervisord +from salt.exceptions import CommandExecutionError supervisord.__salt__ = {} @@ -186,8 +182,3 @@ class SupervisordTestCase(TestCase): MockConfig.flag = 0 self.assertDictEqual(supervisord.options('salt'), {'salt': True}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SupervisordTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_svn.py b/tests/unit/modules/test_svn.py index 0b380f1f7d..126cff93ac 100644 --- a/tests/unit/modules/test_svn.py +++ b/tests/unit/modules/test_svn.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import svn @@ -120,8 +116,3 @@ class SvnTestCase(TestCase): mock = MagicMock(return_value={'retcode': 0, 'stdout': True}) with patch.dict(svn.__salt__, {'cmd.run_all': mock}): self.assertTrue(svn.export('cwd', 'remote')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SvnTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_swift.py b/tests/unit/modules/test_swift.py index a1157b00cf..91e38d425f 100644 --- a/tests/unit/modules/test_swift.py +++ b/tests/unit/modules/test_swift.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import swift @@ -72,8 +68,3 @@ class SwiftTestCase(TestCase): local_file='/tmp/myfile.png')) self.assertFalse(swift.put('mycontainer', path='myfile.png')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SwiftTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_sysbench.py b/tests/unit/modules/test_sysbench.py index ff156a8a8e..aa65ee2776 100644 --- a/tests/unit/modules/test_sysbench.py +++ b/tests/unit/modules/test_sysbench.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import sysbench @@ -120,8 +116,3 @@ class SysbenchTestCase(TestCase): Test to ping ''' self.assertTrue(sysbench.ping()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SysbenchTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_syslog_ng.py b/tests/unit/modules/test_syslog_ng.py index f1eb551018..a6495ac731 100644 --- a/tests/unit/modules/test_syslog_ng.py +++ b/tests/unit/modules/test_syslog_ng.py @@ -9,12 +9,8 @@ from textwrap import dedent # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch - -ensure_in_syspath('../../') - # Import Salt libs import salt from salt.modules import syslog_ng @@ -282,9 +278,3 @@ class SyslogNGTestCase(TestCase): self.assertEqual(len(mock_function.call_args), 2) mock_param = mock_function.call_args self.assertTrue(mock_param[0][0].endswith(mock_function_args)) - - -if __name__ == '__main__': - from integration import run_tests - - run_tests(SyslogNGTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_sysmod.py b/tests/unit/modules/test_sysmod.py index 8f12f5bf54..0b15ac58cc 100644 --- a/tests/unit/modules/test_sysmod.py +++ b/tests/unit/modules/test_sysmod.py @@ -14,10 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import sysmod @@ -373,8 +369,3 @@ class SysmodTestCase(TestCase): self.assertListEqual(sysmod.list_renderers('user.info'), ['user.info']) self.assertListEqual(sysmod.list_renderers('syst*'), ['system.halt', 'system.reboot']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SysmodTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_system.py b/tests/unit/modules/test_system.py index e9322536d6..5f8d55f85f 100644 --- a/tests/unit/modules/test_system.py +++ b/tests/unit/modules/test_system.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import system @@ -78,8 +74,3 @@ class SystemTestCase(TestCase): with patch.dict(system.__salt__, {'cmd.run': MagicMock(return_value='A')}): self.assertEqual(system.shutdown(), 'A') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SystemTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_systemd.py b/tests/unit/modules/test_systemd.py index f79e2d8e24..64adaafcfd 100644 --- a/tests/unit/modules/test_systemd.py +++ b/tests/unit/modules/test_systemd.py @@ -10,7 +10,6 @@ import os # Import Salt Testing Libs from salt.exceptions import CommandExecutionError from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -18,8 +17,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import systemd import salt.utils.systemd @@ -547,8 +544,3 @@ class SystemdScopeTestCase(TestCase): def test_unmask_runtime(self): self._mask_unmask('unmask', True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SystemdTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_timezone.py b/tests/unit/modules/test_timezone.py index 3a9f1eb0ef..7a85e45700 100644 --- a/tests/unit/modules/test_timezone.py +++ b/tests/unit/modules/test_timezone.py @@ -8,15 +8,12 @@ import os # Import Salt Testing Libs from salt.exceptions import CommandExecutionError, SaltInvocationError from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( patch, NO_MOCK, NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import timezone import salt.ext.six as six @@ -85,8 +82,3 @@ class TimezoneTestCase(TestCase): temp.close() self.tempfiles.append(temp) return temp - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TimezoneTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_tls.py b/tests/unit/modules/test_tls.py index fa50a55f1d..8e97dcb7ad 100644 --- a/tests/unit/modules/test_tls.py +++ b/tests/unit/modules/test_tls.py @@ -32,7 +32,7 @@ from tests.support.helpers import destructiveTest # Import Salt Libs from salt.modules import tls -import integration +import tests.integration as integration # Globals @@ -812,7 +812,3 @@ class TLSAddTestCase(TestCase): finally: if os.path.isdir(ca_path): shutil.rmtree(ca_path) - -if __name__ == '__main__': - from integration import run_tests - run_tests(TLSAddTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_twilio_notify.py b/tests/unit/modules/test_twilio_notify.py index 97426317f9..50a317371c 100644 --- a/tests/unit/modules/test_twilio_notify.py +++ b/tests/unit/modules/test_twilio_notify.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import twilio_notify @@ -117,8 +113,3 @@ class TwilioNotifyTestCase(TestCase): {'message': {'sid': None}, '_error': {'msg': 'Exception error', 'status': 'Not send', 'code': 'error code'}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TwilioNotifyTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_udev.py b/tests/unit/modules/test_udev.py index 955dcac5e7..ee2c0b2f31 100644 --- a/tests/unit/modules/test_udev.py +++ b/tests/unit/modules/test_udev.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import udev @@ -175,8 +171,3 @@ E: XKBMODEL=pc105 ''' data = {'key': ['value', 'here'], 'foo': ['bar'], 'some': 'data'} assert udev._normalize_info(data) == {'foo': 'bar', 'some': 'data', 'key': ['value', 'here']} - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UdevTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_uptime.py b/tests/unit/modules/test_uptime.py index 91e7b9a606..7dbbf8fb5d 100644 --- a/tests/unit/modules/test_uptime.py +++ b/tests/unit/modules/test_uptime.py @@ -5,10 +5,7 @@ from __future__ import absolute_import, print_function # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, patch -ensure_in_syspath('../../') -ensure_in_syspath('../../../') # Import salt libs from salt.exceptions import CommandExecutionError @@ -87,7 +84,3 @@ class UptimeTestCase(TestCase): self.assertTrue(uptime.delete('http://example.org') is True) self.assertEqual(('http://localhost:5000/api/checks/1234',), REQUEST_MOCK.args) - -if __name__ == '__main__': - from integration import run_tests - run_tests(UptimeTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_useradd.py b/tests/unit/modules/test_useradd.py index d48d16a2ce..aa48e53163 100644 --- a/tests/unit/modules/test_useradd.py +++ b/tests/unit/modules/test_useradd.py @@ -381,8 +381,3 @@ class UserAddTestCase(TestCase): mock = MagicMock(side_effect=[{'name': ''}, False, {'name': ''}]) with patch.object(useradd, 'info', mock): self.assertFalse(useradd.rename('salt', 'salt')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UserAddTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_uwsgi.py b/tests/unit/modules/test_uwsgi.py index 859197c812..503bc23688 100644 --- a/tests/unit/modules/test_uwsgi.py +++ b/tests/unit/modules/test_uwsgi.py @@ -5,13 +5,11 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, Mock, patch +# Import salt libs from salt.modules import uwsgi -ensure_in_syspath('../../') - uwsgi.__salt__ = {} @@ -28,8 +26,3 @@ class UwsgiTestCase(TestCase): ['uwsgi', '--connect-and-read', '{0}'.format(socket)], python_shell=False) self.assertEqual(result, {'a': 1, 'b': 2}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UwsgiTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_varnish.py b/tests/unit/modules/test_varnish.py index 1ac809bc15..78239f4155 100644 --- a/tests/unit/modules/test_varnish.py +++ b/tests/unit/modules/test_varnish.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import varnish @@ -86,8 +82,3 @@ class VarnishTestCase(TestCase): return_value={'retcode': False, 'stdout': 'A .1\nB .2\n'}): self.assertEqual(varnish.param_show('param'), {'A': '.1'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VarnishTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py index 2f613ed7aa..e5e24197e8 100644 --- a/tests/unit/modules/test_virt.py +++ b/tests/unit/modules/test_virt.py @@ -7,9 +7,7 @@ import re # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs from salt.modules import virt @@ -538,8 +536,3 @@ class VirtTestCase(TestCase): nic = nics[list(nics)[0]] self.assertEqual('bridge', nic['type']) self.assertEqual('ac:de:48:b6:8b:59', nic['mac']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VirtTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_virtualenv.py b/tests/unit/modules/test_virtualenv.py index ed006ad161..4385be9497 100644 --- a/tests/unit/modules/test_virtualenv.py +++ b/tests/unit/modules/test_virtualenv.py @@ -13,13 +13,8 @@ import sys # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ( - ensure_in_syspath, - TestsLoggingHandler, - ForceImportErrorOn -) +from tests.support.helpers import TestsLoggingHandler, ForceImportErrorOn from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs from salt.modules import virtualenv_mod @@ -357,8 +352,3 @@ class VirtualenvTestCase(TestCase): runas=None, python_shell=False ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VirtualenvTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_vsphere.py b/tests/unit/modules/test_vsphere.py index 998b057eec..4235aa4610 100644 --- a/tests/unit/modules/test_vsphere.py +++ b/tests/unit/modules/test_vsphere.py @@ -21,9 +21,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Globals HOST = '1.2.3.4' diff --git a/tests/unit/modules/test_win_autoruns.py b/tests/unit/modules/test_win_autoruns.py index c886325e53..8dc145becd 100644 --- a/tests/unit/modules/test_win_autoruns.py +++ b/tests/unit/modules/test_win_autoruns.py @@ -13,10 +13,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_autoruns @@ -50,8 +46,3 @@ class WinAutorunsTestCase(TestCase): mock = MagicMock(return_value='SALT') with patch.dict(win_autoruns.__salt__, {'cmd.run': mock}): self.assertDictEqual(win_autoruns.list_(), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinAutorunsTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_certutil.py b/tests/unit/modules/test_win_certutil.py index a343fe42d9..b33485f302 100644 --- a/tests/unit/modules/test_win_certutil.py +++ b/tests/unit/modules/test_win_certutil.py @@ -8,14 +8,11 @@ from salt.modules import win_certutil as certutil # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - certutil.__salt__ = {} @@ -68,8 +65,3 @@ class CertUtilTestCase(TestCase): certutil.del_store('salt://path/to/file', 'TrustedPublisher') cmd_mock.assert_called_once_with('certutil.exe -delstore TrustedPublisher ABCDEF') cache_mock.assert_called_once_with('salt://path/to/file', 'base') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CertUtilTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_disk.py b/tests/unit/modules/test_win_disk.py index e94be03d0a..293ed5a112 100644 --- a/tests/unit/modules/test_win_disk.py +++ b/tests/unit/modules/test_win_disk.py @@ -13,10 +13,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_disk @@ -71,8 +67,3 @@ class WinDiskTestCase(TestCase): 'used': None, 'capacity': None, 'filesystem': 'A:\\'}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinDiskTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_dism.py b/tests/unit/modules/test_win_dism.py index 95f83c49f8..50f58f6bbd 100644 --- a/tests/unit/modules/test_win_dism.py +++ b/tests/unit/modules/test_win_dism.py @@ -8,14 +8,11 @@ from salt.modules import win_dism as dism # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - dism.__salt__ = {} dism.__grains__ = {} @@ -234,7 +231,3 @@ class WinDismTestCase(TestCase): out = dism.installed_packages() mock.assert_called_once_with(['DISM', '/English', '/Online', '/Get-Packages']) self.assertEqual(out, ['Capa1', 'Capa2']) - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinDismTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_dns_client.py b/tests/unit/modules/test_win_dns_client.py index f997c5e2da..d9aa24d0fe 100644 --- a/tests/unit/modules/test_win_dns_client.py +++ b/tests/unit/modules/test_win_dns_client.py @@ -18,10 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # wmi and pythoncom modules are platform specific... wmi = types.ModuleType('wmi') sys.modules['wmi'] = wmi @@ -160,8 +156,3 @@ class WinDnsClientTestCase(TestCase): with patch.object(WMI, 'Win32_NetworkAdapterConfiguration', return_value=[Mockwmi()]): self.assertTrue(win_dns_client.get_dns_config()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinDnsClientTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_firewall.py b/tests/unit/modules/test_win_firewall.py index ce2672afec..431a8bcf65 100644 --- a/tests/unit/modules/test_win_firewall.py +++ b/tests/unit/modules/test_win_firewall.py @@ -14,10 +14,6 @@ from tests.support.mock import ( call ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_firewall import salt.utils @@ -206,8 +202,3 @@ class WinFirewallTestCase(TestCase): 'dir=in', 'remoteip=any'], python_shell=False) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinFirewallTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_groupadd.py b/tests/unit/modules/test_win_groupadd.py index 6c182014ed..e48bc743c2 100644 --- a/tests/unit/modules/test_win_groupadd.py +++ b/tests/unit/modules/test_win_groupadd.py @@ -14,10 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_groupadd @@ -146,8 +142,3 @@ class WinGroupTestCase(TestCase): comment = ['dc=foo membership is correct'] ret.update({'comment': comment, 'result': None}) self.assertDictEqual(win_groupadd.members('dc=foo', 'dc=\\user1'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinGroupTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_iis.py b/tests/unit/modules/test_win_iis.py index f525089daa..710d78664a 100644 --- a/tests/unit/modules/test_win_iis.py +++ b/tests/unit/modules/test_win_iis.py @@ -16,7 +16,6 @@ from salt.modules import win_iis # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -24,8 +23,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Globals win_iis.__salt__ = {} @@ -409,7 +406,3 @@ class WinIisTestCase(TestCase): 'settings': {'managedPipelineMode': 'Integrated'}} with patch.dict(win_iis.__salt__): self.assertTrue(win_iis.set_container_setting(**kwargs)) - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(WinIisTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_ip.py b/tests/unit/modules/test_win_ip.py index 5992e96d5d..9b1f910bd6 100644 --- a/tests/unit/modules/test_win_ip.py +++ b/tests/unit/modules/test_win_ip.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_ip from salt.exceptions import CommandExecutionError, SaltInvocationError @@ -248,8 +244,3 @@ class WinShadowTestCase(TestCase): mock_cmd = MagicMock(return_value=ETHERNET_CONFIG) with patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}): self.assertEqual(win_ip.get_default_gateway(), '1.2.3.1') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinShadowTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_license.py b/tests/unit/modules/test_win_license.py index c27a11af42..e67c89b0ce 100644 --- a/tests/unit/modules/test_win_license.py +++ b/tests/unit/modules/test_win_license.py @@ -8,14 +8,11 @@ from salt.modules import win_license as license # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - license.__salt__ = {} @@ -95,7 +92,3 @@ class LicenseTestCase(TestCase): out = license.info() mock.assert_called_once_with(r'cscript C:\Windows\System32\slmgr.vbs /dli') self.assertEqual(out, expected) - -if __name__ == '__main__': - from integration import run_tests - run_tests(LicenseTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_network.py b/tests/unit/modules/test_win_network.py index a73ab617a8..e38a544e9c 100644 --- a/tests/unit/modules/test_win_network.py +++ b/tests/unit/modules/test_win_network.py @@ -19,10 +19,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # wmi modules are platform specific... wmi = types.ModuleType('wmi') sys.modules['wmi'] = wmi @@ -212,8 +208,3 @@ class WinNetworkTestCase(TestCase): with patch.object(salt.utils.network, 'in_subnet', MagicMock(return_value=True)): self.assertTrue(win_network.in_subnet('10.1.1.0/16')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinNetworkTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_ntp.py b/tests/unit/modules/test_win_ntp.py index 4712cc0f49..b0cb6a9f84 100644 --- a/tests/unit/modules/test_win_ntp.py +++ b/tests/unit/modules/test_win_ntp.py @@ -13,10 +13,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_ntp @@ -72,8 +68,3 @@ class WinNtpTestCase(TestCase): self.assertListEqual(win_ntp.get_servers(), ['SALT']) self.assertFalse(win_ntp.get_servers()) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinNtpTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_path.py b/tests/unit/modules/test_win_path.py index b722c343d6..6b14125307 100644 --- a/tests/unit/modules/test_win_path.py +++ b/tests/unit/modules/test_win_path.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_path @@ -110,8 +107,3 @@ class WinPathTestCase(TestCase): self.assertEqual(win_path.remove("c:\\salt"), "Salt") self.assertFalse(win_path.remove("c:\\salt")) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinPathTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_pki.py b/tests/unit/modules/test_win_pki.py index d3d172be84..eb337d4c7a 100644 --- a/tests/unit/modules/test_win_pki.py +++ b/tests/unit/modules/test_win_pki.py @@ -14,7 +14,6 @@ from salt.modules import win_pki # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -22,8 +21,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Globals win_pki.__salt__ = {} @@ -185,8 +182,3 @@ class WinPkiTestCase(TestCase): ''' with patch.dict(win_pki.__salt__): self.assertTrue(win_pki.remove_cert(thumbprint=THUMBPRINT[::-1])) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(WinPkiTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_powercfg.py b/tests/unit/modules/test_win_powercfg.py index 1bbb1f39d7..b85f1b1acb 100644 --- a/tests/unit/modules/test_win_powercfg.py +++ b/tests/unit/modules/test_win_powercfg.py @@ -8,7 +8,6 @@ from salt.modules import win_powercfg as powercfg # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -17,8 +16,6 @@ from tests.support.mock import ( call ) -ensure_in_syspath('../../') - powercfg.__salt__ = {} powercfg.__grains__ = {'osrelease': 8} @@ -214,7 +211,3 @@ class PowerCfgTestCase(TestCase): mock.assert_has_calls(calls) self.assertEqual({'ac': 30, 'dc': 15}, ret) - -if __name__ == '__main__': - from integration import run_tests - run_tests(PowerCfgTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_service.py b/tests/unit/modules/test_win_service.py index f63f68cbb2..9a61cd9801 100644 --- a/tests/unit/modules/test_win_service.py +++ b/tests/unit/modules/test_win_service.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,7 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import win_service @@ -248,8 +246,3 @@ class WinServiceTestCase(TestCase): with patch.object(win_service, 'enabled', mock): self.assertTrue(win_service.disabled('spongebob')) self.assertFalse(win_service.disabled('squarepants')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinServiceTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_shadow.py b/tests/unit/modules/test_win_shadow.py index 74e60e994c..13ca98662f 100644 --- a/tests/unit/modules/test_win_shadow.py +++ b/tests/unit/modules/test_win_shadow.py @@ -13,10 +13,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_shadow import salt.utils @@ -54,8 +50,3 @@ class WinShadowTestCase(TestCase): mock_cmd = MagicMock(return_value={'retcode': False}) with patch.dict(win_shadow.__salt__, {'cmd.run_all': mock_cmd}): self.assertTrue(win_shadow.set_password('root', 'mysecretpassword')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinShadowTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_snmp.py b/tests/unit/modules/test_win_snmp.py index 89fe9913a8..7a35ea1182 100644 --- a/tests/unit/modules/test_win_snmp.py +++ b/tests/unit/modules/test_win_snmp.py @@ -14,7 +14,6 @@ from salt.modules import win_snmp # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -22,8 +21,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Globals win_snmp.__salt__ = {} @@ -93,8 +90,3 @@ class WinSnmpTestCase(TestCase): kwargs = {'communities': COMMUNITY_NAMES} with patch.dict(win_snmp.__salt__, {'reg.set_value': mock_value}): self.assertTrue(win_snmp.set_community_names(**kwargs)) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(WinSnmpTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_status.py b/tests/unit/modules/test_win_status.py index 61eb89e18d..3c072b63c0 100644 --- a/tests/unit/modules/test_win_status.py +++ b/tests/unit/modules/test_win_status.py @@ -10,8 +10,7 @@ import salt.ext.six as six # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +from tests.support.mock import NO_MOCK, Mock, patch, ANY # wmi and pythoncom modules are platform specific... wmi = types.ModuleType('wmi') @@ -20,8 +19,6 @@ sys.modules['wmi'] = wmi pythoncom = types.ModuleType('pythoncom') sys.modules['pythoncom'] = pythoncom -from tests.support.mock import NO_MOCK, Mock, patch, ANY - if NO_MOCK is False: WMI = Mock() wmi.WMI = Mock(return_value=WMI) @@ -183,17 +180,3 @@ class TestEmptyCommandLine(TestProcsBase): # def test_initialize_and_uninitialize_called(self): # pythoncom.CoInitialize.assert_has_calls(self.expected_calls) # pythoncom.CoUninitialize.assert_has_calls(self.expected_calls) - - -if __name__ == '__main__': - from integration import run_tests - run_tests( - [ - TestProcsCount, - TestProcsAttributes, - TestProcsUnicodeAttributes, - TestProcsWMIGetOwnerErrorsAreLogged, - TestProcsWMIGetOwnerAccessDeniedWorkaround, - ], - needs_daemon=False - ) diff --git a/tests/unit/modules/test_win_system.py b/tests/unit/modules/test_win_system.py index fcd5187f3e..5acb6992ff 100644 --- a/tests/unit/modules/test_win_system.py +++ b/tests/unit/modules/test_win_system.py @@ -9,7 +9,6 @@ from datetime import datetime # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -17,7 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import win_system @@ -296,8 +294,3 @@ class WinSystemTestCase(TestCase): ret = win_system.get_hostname() self.assertEqual(ret, "MINION") cmd_run_mock.assert_called_once_with(cmd="hostname") - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinSystemTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_win_timezone.py b/tests/unit/modules/test_win_timezone.py index ed756e4587..9fe2e37cd5 100644 --- a/tests/unit/modules/test_win_timezone.py +++ b/tests/unit/modules/test_win_timezone.py @@ -13,10 +13,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import win_timezone @@ -106,8 +102,3 @@ class WinTimezoneTestCase(TestCase): Test if it sets the hardware clock to be either UTC or localtime ''' self.assertFalse(win_timezone.set_hwclock('UTC')) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinTimezoneTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_xapi.py b/tests/unit/modules/test_xapi.py index bd69a51439..63f4700454 100644 --- a/tests/unit/modules/test_xapi.py +++ b/tests/unit/modules/test_xapi.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( mock_open, MagicMock, @@ -17,7 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') # Import Salt Libs from salt.modules import xapi @@ -412,8 +410,3 @@ class XapiTestCase(TestCase): ''' with patch.object(xapi, "_get_xapi_session", MagicMock()): self.assertDictEqual(xapi.vm_diskstats(""), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(XapiTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_zcbuildout.py b/tests/unit/modules/test_zcbuildout.py index e11bbf1a56..f4bc2b2af0 100644 --- a/tests/unit/modules/test_zcbuildout.py +++ b/tests/unit/modules/test_zcbuildout.py @@ -16,15 +16,10 @@ from salt.ext.six.moves.urllib.request import urlopen # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ( - ensure_in_syspath, - requires_network, - skip_if_binaries_missing -) -ensure_in_syspath('../..') +from tests.support.helpers import requires_network, skip_if_binaries_missing +import tests.integration as integration # Import Salt libs -import integration # pylint: disable=import-error import salt.utils from salt.modules import zcbuildout as buildout from salt.modules import cmdmod as cmd @@ -506,12 +501,3 @@ class BuildoutAPITestCase(TestCase): uret = buildout._set_status({}, out=u'éà') self.assertTrue(ret['outlog'] == uret['outlog']) self.assertTrue('àé' in uret['outlog_by_level']) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests( - BuildoutAPITestCase, - BuildoutTestCase, - BuildoutOnlineTestCase, - needs_daemon=False) diff --git a/tests/unit/modules/test_zfs.py b/tests/unit/modules/test_zfs.py index c31e9b7b8e..c93cb0cc5d 100644 --- a/tests/unit/modules/test_zfs.py +++ b/tests/unit/modules/test_zfs.py @@ -11,7 +11,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath # Import Mock libraries from tests.support.mock import ( @@ -21,8 +20,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Import Salt Execution module to test from salt.modules import zfs from salt.utils.odict import OrderedDict @@ -501,9 +498,3 @@ class ZfsTestCase(TestCase): mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}): self.assertEqual(zfs.get('myzpool', properties='compression', fields='value'), res) - -if __name__ == '__main__': - from integration import run_tests - run_tests(ZfsTestCase, needs_daemon=False) - -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/tests/unit/modules/test_znc.py b/tests/unit/modules/test_znc.py index 5919249f9c..1e34aac3f3 100644 --- a/tests/unit/modules/test_znc.py +++ b/tests/unit/modules/test_znc.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.modules import znc @@ -78,8 +74,3 @@ class ZncTestCase(TestCase): mock = MagicMock(return_value='ZNC 1.2 - http://znc.in') with patch.dict(znc.__salt__, {'cmd.run': mock}): self.assertEqual(znc.version(), 'ZNC 1.2') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ZncTestCase, needs_daemon=False) diff --git a/tests/unit/modules/test_zpool.py b/tests/unit/modules/test_zpool.py index c661f796c9..5ba77ca865 100644 --- a/tests/unit/modules/test_zpool.py +++ b/tests/unit/modules/test_zpool.py @@ -11,7 +11,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath # Import Mock libraries from tests.support.mock import ( @@ -21,8 +20,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Import Salt Execution module to test from salt.modules import zpool @@ -159,9 +156,3 @@ class ZpoolTestCase(TestCase): ret = zpool.get('mypool', 'readonly') res = OrderedDict([('mypool', OrderedDict([('readonly', 'off')]))]) self.assertEqual(res, ret) - -if __name__ == '__main__': - from integration import run_tests - run_tests(ZpoolTestCase, needs_daemon=False) - -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/tests/unit/modules/test_zypper.py b/tests/unit/modules/test_zypper.py index 146a7ca110..3522795501 100644 --- a/tests/unit/modules/test_zypper.py +++ b/tests/unit/modules/test_zypper.py @@ -9,7 +9,6 @@ import os # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( Mock, MagicMock, @@ -19,8 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt libs from salt.exceptions import CommandExecutionError from salt.ext.six.moves import configparser @@ -782,7 +779,3 @@ Repository 'DUMMY' not found by its alias, number, or URI. zypper.__zypper__.refreshable.xml.call.assert_called_once_with( '--gpg-auto-import-keys', 'mr', '--refresh', name ) - -if __name__ == '__main__': - from integration import run_tests - run_tests(ZypperTestCase, needs_daemon=False) diff --git a/tests/unit/netapi/rest_tornado/test_handlers.py b/tests/unit/netapi/rest_tornado/test_handlers.py index b23b91772e..da1f360989 100644 --- a/tests/unit/netapi/rest_tornado/test_handlers.py +++ b/tests/unit/netapi/rest_tornado/test_handlers.py @@ -10,9 +10,7 @@ import hashlib # Import Salt Testing Libs from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../..') -import integration # pylint: disable=import-error +import tests.integration as integration # Import Salt libs try: @@ -698,8 +696,3 @@ class TestWebsocketSaltAPIHandler(SaltnadoTestCase): ws = yield websocket_connect(request) ws.write_message('websocket client ready') ws.close() - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(TestBaseSaltAPIHandler, TestSaltAuthHandler, needs_daemon=False) diff --git a/tests/unit/netapi/rest_tornado/test_utils.py b/tests/unit/netapi/rest_tornado/test_utils.py index db512fcc0d..76b5d66076 100644 --- a/tests/unit/netapi/rest_tornado/test_utils.py +++ b/tests/unit/netapi/rest_tornado/test_utils.py @@ -6,8 +6,6 @@ import os # Import Salt Testing Libs from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../..') # Import 3rd-party libs # pylint: disable=import-error @@ -33,7 +31,7 @@ except ImportError: HAS_TORNADO = False # Import utility lib from tests -from unit.utils.test_event import eventpublisher_process, event, SOCK_DIR # pylint: disable=import-error +from tests.unit.utils.test_event import eventpublisher_process, event, SOCK_DIR # pylint: disable=import-error @skipIf(HAS_TORNADO is False, 'The tornado package needs to be installed') diff --git a/tests/unit/output/test_json_out.py b/tests/unit/output/test_json_out.py index 931be7a091..7e85a8de85 100644 --- a/tests/unit/output/test_json_out.py +++ b/tests/unit/output/test_json_out.py @@ -9,9 +9,6 @@ import json # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.output import json_out @@ -67,8 +64,3 @@ class JsonTestCase(TestCase): self.assertEqual(expect, ret) else: self.assertEqual(json.loads(ret), data) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(JsonTestCase, needs_daemon=False) diff --git a/tests/unit/output/test_yaml_out.py b/tests/unit/output/test_yaml_out.py index 14a484675e..6e603f41f3 100644 --- a/tests/unit/output/test_yaml_out.py +++ b/tests/unit/output/test_yaml_out.py @@ -8,9 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.output import yaml_out as yaml @@ -35,8 +32,3 @@ class YamlTestCase(TestCase): ret = yaml.output(self.data) expect = '{example: one, test: two}\n' self.assertEqual(expect, ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(YamlTestCase, needs_daemon=False) diff --git a/tests/unit/pillar/test_consul.py b/tests/unit/pillar/test_consul.py index 9cce5b1a3e..b4c67805fa 100644 --- a/tests/unit/pillar/test_consul.py +++ b/tests/unit/pillar/test_consul.py @@ -6,9 +6,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.pillar import consul_pillar @@ -81,8 +78,3 @@ class ConsulPillarTestCase(TestCase): with patch.dict(test_dict, {'key1': {'key3': {'key4': 'value'}}}): self.assertDictEqual(pillar.dict_merge(test_dict, SIMPLE_DICT), {'key1': {'key2': 'val1', 'key3': {'key4': 'value'}}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ConsulPillarTestCase, needs_daemon=False) diff --git a/tests/unit/pillar/test_git.py b/tests/unit/pillar/test_git.py index 926c217b86..cc6990c631 100644 --- a/tests/unit/pillar/test_git.py +++ b/tests/unit/pillar/test_git.py @@ -21,7 +21,7 @@ import yaml from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -import integration +import tests.integration as integration COMMIT_USER_NAME = 'test_user' COMMIT_USER_EMAIL = 'someone@git.test' @@ -181,8 +181,3 @@ class GitPillarTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn) self.assertTrue(orig_ext_pillar.count < 7) finally: LazyLoader.__getitem__ = orig_getitem - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GitPillarTestCase, needs_daemon=False) diff --git a/tests/unit/pillar/test_hg.py b/tests/unit/pillar/test_hg.py index 648a32ecf5..748276ef41 100644 --- a/tests/unit/pillar/test_hg.py +++ b/tests/unit/pillar/test_hg.py @@ -14,7 +14,7 @@ import yaml from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -import integration +import tests.integration as integration COMMIT_USER_NAME = 'test_user' # file contents diff --git a/tests/unit/pillar/test_mysql.py b/tests/unit/pillar/test_mysql.py index 35597b0286..f18d65240c 100644 --- a/tests/unit/pillar/test_mysql.py +++ b/tests/unit/pillar/test_mysql.py @@ -6,9 +6,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.pillar import mysql @@ -572,8 +569,3 @@ class MysqlPillarTestCase(TestCase): ]}, return_data.result ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MysqlPillarTestCase, needs_daemon=False) diff --git a/tests/unit/pillar/test_nodegroups.py b/tests/unit/pillar/test_nodegroups.py index 17c73bbf6d..163b15e028 100644 --- a/tests/unit/pillar/test_nodegroups.py +++ b/tests/unit/pillar/test_nodegroups.py @@ -5,11 +5,8 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, MagicMock -ensure_in_syspath('../../') - # Import Salt Libs from salt.pillar import nodegroups diff --git a/tests/unit/pillar/test_sqlcipher.py b/tests/unit/pillar/test_sqlcipher.py index c609e06c74..339d31e8d5 100644 --- a/tests/unit/pillar/test_sqlcipher.py +++ b/tests/unit/pillar/test_sqlcipher.py @@ -6,9 +6,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.pillar import sqlcipher @@ -561,8 +558,3 @@ class SQLCipherPillarTestCase(TestCase): ]}), sorted(return_data.result) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SQLCipherPillarTestCase, needs_daemon=False) diff --git a/tests/unit/pillar/test_sqlite3.py b/tests/unit/pillar/test_sqlite3.py index 928bc63c5a..4c97ddd854 100644 --- a/tests/unit/pillar/test_sqlite3.py +++ b/tests/unit/pillar/test_sqlite3.py @@ -6,9 +6,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.pillar import sqlite3 @@ -561,8 +558,3 @@ class SQLite3PillarTestCase(TestCase): ]}), sorted(return_data.result) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SQLite3PillarTestCase, needs_daemon=False) diff --git a/tests/unit/renderers/test_gpg.py b/tests/unit/renderers/test_gpg.py index 6cf22eba7f..91b5aca989 100644 --- a/tests/unit/renderers/test_gpg.py +++ b/tests/unit/renderers/test_gpg.py @@ -5,7 +5,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -13,8 +12,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - # Import Salt libs from salt.renderers import gpg from salt.exceptions import SaltRenderError @@ -96,8 +93,3 @@ class GPGTestCase(TestCase): with patch('salt.renderers.gpg._get_key_dir', MagicMock(return_value=key_dir)): with patch('salt.renderers.gpg._decrypt_object', MagicMock(return_value=secret)): self.assertEqual(gpg.render(crypted), secret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GPGTestCase, needs_daemon=False) diff --git a/tests/unit/renderers/test_yaml.py b/tests/unit/renderers/test_yaml.py index cb2f531548..7e2a69ddd1 100644 --- a/tests/unit/renderers/test_yaml.py +++ b/tests/unit/renderers/test_yaml.py @@ -5,9 +5,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs from salt.renderers import yaml diff --git a/tests/unit/renderers/test_yamlex.py b/tests/unit/renderers/test_yamlex.py index fdf805c181..5814cd4806 100644 --- a/tests/unit/renderers/test_yamlex.py +++ b/tests/unit/renderers/test_yamlex.py @@ -5,9 +5,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../..') # Import Salt libs import salt.state @@ -61,7 +58,3 @@ class RendererTests(TestCase, RendererMixin): } } }, sls_obj - -if __name__ == '__main__': - from integration import run_tests - run_tests(RendererTests, needs_daemon=False) diff --git a/tests/unit/returners/test_local_cache.py b/tests/unit/returners/test_local_cache.py index fa9375492c..45b5c4eca3 100644 --- a/tests/unit/returners/test_local_cache.py +++ b/tests/unit/returners/test_local_cache.py @@ -14,7 +14,7 @@ import tempfile # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import destructiveTest, ensure_in_syspath +from tests.support.helpers import destructiveTest from tests.support.mock import ( MagicMock, NO_MOCK, @@ -22,8 +22,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - # Import Salt libs import salt.utils from salt.returners import local_cache @@ -161,8 +159,3 @@ class LocalCacheCleanOldJobsTestCase(TestCase): jid_file.write('this is a jid file') return temp_dir, jid_file_path - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LocalCacheCleanOldJobsTestCase, needs_daemon=False) diff --git a/tests/unit/returners/test_smtp_return.py b/tests/unit/returners/test_smtp_return.py index 22107046a0..fcdb289415 100644 --- a/tests/unit/returners/test_smtp_return.py +++ b/tests/unit/returners/test_smtp_return.py @@ -12,11 +12,8 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') - # Import salt libs from salt.returners import smtp_return as smtp @@ -86,6 +83,3 @@ else: self._test_returner(mocked_smtplib, *args) SMTPReturnerTestCase.test_returner = test_returner -if __name__ == '__main__': - from integration import run_tests - run_tests(SMTPReturnerTestCase, needs_daemon=False) diff --git a/tests/unit/runners/test_cache.py b/tests/unit/runners/test_cache.py index 3f2a15d261..00a8ff92da 100644 --- a/tests/unit/runners/test_cache.py +++ b/tests/unit/runners/test_cache.py @@ -8,15 +8,12 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.runners import cache import salt.utils @@ -49,8 +46,3 @@ class CacheTest(TestCase): with patch.object(salt.utils.master, 'MasterPillarUtil', MockMaster): self.assertEqual(cache.grains(), mock_data) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CacheTest, needs_daemon=False) diff --git a/tests/unit/runners/test_jobs.py b/tests/unit/runners/test_jobs.py index c6224b6efe..2887ae9fa6 100644 --- a/tests/unit/runners/test_jobs.py +++ b/tests/unit/runners/test_jobs.py @@ -8,15 +8,12 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.runners import jobs import salt.minion @@ -80,8 +77,3 @@ class JobsTest(TestCase): self.assertEqual(jobs.list_jobs(search_target='non-existant'), returns['non-existant']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(JobsTest, needs_daemon=False) diff --git a/tests/unit/runners/test_queue.py b/tests/unit/runners/test_queue.py index bab3e3dd22..2e22560f91 100644 --- a/tests/unit/runners/test_queue.py +++ b/tests/unit/runners/test_queue.py @@ -7,17 +7,14 @@ unit tests for the cache runner from __future__ import absolute_import # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, MagicMock, patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.runners import queue as queue_mod @@ -61,8 +58,3 @@ class QueueTest(TestCase): queue_pop.assert_called_once_with(queue='salt', quantity=1, backend='pgjsonb') test_stdout_print.assert_called_once_with() queue_pop.assert_called_once_with(queue='salt', quantity=1, backend='pgjsonb') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(QueueTest, needs_daemon=False) diff --git a/tests/unit/runners/test_vault.py b/tests/unit/runners/test_vault.py index d219c8ab3d..f367f7bbca 100644 --- a/tests/unit/runners/test_vault.py +++ b/tests/unit/runners/test_vault.py @@ -6,22 +6,21 @@ Unit tests for the Vault runner # Import Python Libs from __future__ import absolute_import import logging -from salt.ext import six -from salt.runners import vault # Import Salt Testing Libs -from salttesting import skipIf, TestCase -from salttesting.helpers import ensure_in_syspath -from salttesting.mock import ( +from tests.support.unit import skipIf, TestCase +from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) +# Import salt libs +import salt.ext.six as six +from salt.runners import vault log = logging.getLogger(__name__) -ensure_in_syspath('../../') vault.__opts__ = {} @@ -126,8 +125,3 @@ class VaultTest(TestCase): log.debug('Expected:\n\t{0}\nGot\n\t{1}'.format(output, correct_output)) log.debug('Difference:\n\t{0}'.format(diff)) self.assertEqual(output, correct_output) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(VaultTest, needs_daemon=False) diff --git a/tests/unit/serializers/test_serializers.py b/tests/unit/serializers/test_serializers.py index 8899402150..d310695bb5 100644 --- a/tests/unit/serializers/test_serializers.py +++ b/tests/unit/serializers/test_serializers.py @@ -2,15 +2,10 @@ # Import python libs from __future__ import absolute_import +from textwrap import dedent # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') - - -# Import Python libs -from textwrap import dedent # Import 3rd party libs import jinja2 @@ -346,7 +341,3 @@ class TestSerializers(TestCase): deserialized = configparser.deserialize(serialized) assert deserialized == data, deserialized - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestSerializers, needs_daemon=False) diff --git a/tests/unit/ssh/test_ssh_single.py b/tests/unit/ssh/test_ssh_single.py index c32bece7f1..25d89f6eca 100644 --- a/tests/unit/ssh/test_ssh_single.py +++ b/tests/unit/ssh/test_ssh_single.py @@ -10,13 +10,10 @@ import os.path # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../') - # Import Salt libs -import integration +import tests.integration as integration from salt.client import ssh from salt.utils import thin @@ -66,7 +63,3 @@ class SSHSingleTests(TestCase): 'PasswordAuthentication=yes -o ConnectTimeout=65 -o Port=22 ' '-o IdentityFile=/etc/salt/pki/master/ssh/salt-ssh.rsa ' '-o User=root date +%s') - -if __name__ == '__main__': - from integration import run_tests - run_tests(SSHSingleTests, needs_daemon=False) diff --git a/tests/unit/states/test_alias.py b/tests/unit/states/test_alias.py index 9da97de8d8..273d5a781b 100644 --- a/tests/unit/states/test_alias.py +++ b/tests/unit/states/test_alias.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -16,8 +15,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import alias @@ -163,8 +160,3 @@ class AliasTest(TestCase): with patch.dict(alias.__opts__, {'test': False}): with patch.dict(alias.__salt__, {'aliases.rm_alias': rm_alias}): self.assertEqual(alias.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AliasTest, needs_daemon=False) diff --git a/tests/unit/states/test_alternatives.py b/tests/unit/states/test_alternatives.py index 2c418f321b..736251659b 100644 --- a/tests/unit/states/test_alternatives.py +++ b/tests/unit/states/test_alternatives.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import alternatives @@ -213,8 +209,3 @@ class AlternativesTestCase(TestCase): comt = ('Alternative {0} for {1} doesn\'t exist').format(path, name) ret.update({'comment': comt, 'result': False}) self.assertDictEqual(alternatives.set_(name, path), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AlternativesTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_apache.py b/tests/unit/states/test_apache.py index c134f2d561..30cfd8ec14 100644 --- a/tests/unit/states/test_apache.py +++ b/tests/unit/states/test_apache.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch, mock_open) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import apache import salt.utils @@ -71,8 +67,3 @@ class ApacheTestCase(TestCase): 'result': True}) with patch.dict(apache.__opts__, {'test': False}): self.assertDictEqual(apache.configfile(name, config), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ApacheTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_apache_conf.py b/tests/unit/states/test_apache_conf.py index 787506fdb4..a548205d1c 100644 --- a/tests/unit/states/test_apache_conf.py +++ b/tests/unit/states/test_apache_conf.py @@ -11,10 +11,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import apache_conf @@ -92,8 +88,3 @@ class ApacheConfTestCase(TestCase): comt = ('{0} already disabled.'.format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(apache_conf.disabled(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ApacheConfTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_apache_module.py b/tests/unit/states/test_apache_module.py index 4601fd94fc..fce3d6d17d 100644 --- a/tests/unit/states/test_apache_module.py +++ b/tests/unit/states/test_apache_module.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import apache_module @@ -95,8 +91,3 @@ class ApacheModuleTestCase(TestCase): comt = ('{0} already disabled.'.format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(apache_module.disabled(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ApacheModuleTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_apache_site.py b/tests/unit/states/test_apache_site.py index 2cd059bcbb..90f94df207 100644 --- a/tests/unit/states/test_apache_site.py +++ b/tests/unit/states/test_apache_site.py @@ -11,10 +11,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import apache_site @@ -92,8 +88,3 @@ class ApacheSiteTestCase(TestCase): comt = ('{0} already disabled.'.format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(apache_site.disabled(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ApacheSiteTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_apt.py b/tests/unit/states/test_apt.py index cf9f128157..2232e93e5a 100644 --- a/tests/unit/states/test_apt.py +++ b/tests/unit/states/test_apt.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import aptpkg @@ -45,8 +41,3 @@ class AptTestCase(TestCase): mock = MagicMock(return_value=False) with patch.dict(aptpkg.__salt__, {'pkg.get_selections': mock}): self.assertDictEqual(aptpkg.held(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AptTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_archive.py b/tests/unit/states/test_archive.py index 149cee4bc8..218941ced8 100644 --- a/tests/unit/states/test_archive.py +++ b/tests/unit/states/test_archive.py @@ -9,7 +9,6 @@ import os # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -17,8 +16,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import archive as archive from salt.ext.six.moves import zip # pylint: disable=import-error,redefined-builtin @@ -188,7 +185,3 @@ class ArchiveTestCase(TestCase): enforce_toplevel=False, keep=True) self.assertEqual(ret['changes']['extracted_files'], 'stderr') - -if __name__ == '__main__': - from integration import run_tests - run_tests(ArchiveTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_artifactory.py b/tests/unit/states/test_artifactory.py index bf56a03a74..0570b39562 100644 --- a/tests/unit/states/test_artifactory.py +++ b/tests/unit/states/test_artifactory.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import artifactory @@ -57,8 +53,3 @@ class ArtifactoryTestCase(TestCase): ret = artifactory.downloaded(name, artifact) self.assertEqual(ret['result'], False) self.assertEqual(repr(ret['comment']), repr(Exception('error'))) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ArtifactoryTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_at.py b/tests/unit/states/test_at.py index 52a6a0b207..9fe64a19ac 100644 --- a/tests/unit/states/test_at.py +++ b/tests/unit/states/test_at.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import at @@ -216,8 +212,3 @@ class AtTestCase(TestCase): 'comment': ret['comment'].replace('2', '1'), }) self.assertDictEqual(at.absent(name, tag=tag), ret_tag) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AtTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_augeas.py b/tests/unit/states/test_augeas.py index 509ed9ece8..57f76e351d 100644 --- a/tests/unit/states/test_augeas.py +++ b/tests/unit/states/test_augeas.py @@ -18,10 +18,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import augeas @@ -240,8 +236,3 @@ class AugeasTestCase(TestCase): context=self.context, changes=self.changes), self.ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AugeasTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_aws_sqs.py b/tests/unit/states/test_aws_sqs.py index df9974b3e9..c762f22f48 100644 --- a/tests/unit/states/test_aws_sqs.py +++ b/tests/unit/states/test_aws_sqs.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import aws_sqs @@ -78,8 +74,3 @@ class AwsSqsTestCase(TestCase): comt = u'{0} does not exist in {1}'.format(name, region) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(aws_sqs.absent(name, region), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AwsSqsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_blockdev.py b/tests/unit/states/test_blockdev.py index ca8f56df8d..450955cdc7 100644 --- a/tests/unit/states/test_blockdev.py +++ b/tests/unit/states/test_blockdev.py @@ -14,10 +14,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import blockdev import salt.utils @@ -110,8 +106,3 @@ class BlockdevTestCase(TestCase): MagicMock(return_value=True)): with patch.dict(blockdev.__opts__, {'test': False}): self.assertDictEqual(blockdev.formatted(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BlockdevTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_apigateway.py b/tests/unit/states/test_boto_apigateway.py index 4b8d4e0c6a..65abbdf782 100644 --- a/tests/unit/states/test_boto_apigateway.py +++ b/tests/unit/states/test_boto_apigateway.py @@ -12,9 +12,6 @@ import string # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -24,7 +21,7 @@ import salt.loader import yaml # pylint: disable=import-error,no-name-in-module -from unit.modules.test_boto_apigateway import BotoApiGatewayTestCaseMixin +from tests.unit.modules.test_boto_apigateway import BotoApiGatewayTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_asg.py b/tests/unit/states/test_boto_asg.py index c0a3dbd307..4f53b915d0 100644 --- a/tests/unit/states/test_boto_asg.py +++ b/tests/unit/states/test_boto_asg.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_asg @@ -117,8 +113,3 @@ class BotoAsgTestCase(TestCase): comt = ('Autoscale group does not exist.') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(boto_asg.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoAsgTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_cloudtrail.py b/tests/unit/states/test_boto_cloudtrail.py index 38d27ad625..9495793e27 100644 --- a/tests/unit/states/test_boto_cloudtrail.py +++ b/tests/unit/states/test_boto_cloudtrail.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -27,7 +24,7 @@ from salt.ext.six.moves import range # pylint: disable=import-error,redefined-b import logging # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.test_boto_cloudtrail import BotoCloudTrailTestCaseMixin +from tests.unit.modules.test_boto_cloudtrail import BotoCloudTrailTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_cloudwatch_alarm.py b/tests/unit/states/test_boto_cloudwatch_alarm.py index e97b43ecd4..03bf3713cf 100644 --- a/tests/unit/states/test_boto_cloudwatch_alarm.py +++ b/tests/unit/states/test_boto_cloudwatch_alarm.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_cloudwatch_alarm @@ -96,8 +92,3 @@ class BotoCloudwatchAlarmTestCase(TestCase): comt = ('my test alarm does not exist in None.') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(boto_cloudwatch_alarm.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoCloudwatchAlarmTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_cloudwatch_event.py b/tests/unit/states/test_boto_cloudwatch_event.py index 917d95f3da..29077cc319 100644 --- a/tests/unit/states/test_boto_cloudwatch_event.py +++ b/tests/unit/states/test_boto_cloudwatch_event.py @@ -8,9 +8,6 @@ import string # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -23,7 +20,7 @@ import logging from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # pylint: disable=import-error,no-name-in-module -from unit.modules.test_boto_cloudwatch_event import BotoCloudWatchEventTestCaseMixin +from tests.unit.modules.test_boto_cloudwatch_event import BotoCloudWatchEventTestCaseMixin # pylint: disable=unused-import # Import 3rd-party libs diff --git a/tests/unit/states/test_boto_cognitoidentity.py b/tests/unit/states/test_boto_cognitoidentity.py index d79ff0eb73..425ef150ad 100644 --- a/tests/unit/states/test_boto_cognitoidentity.py +++ b/tests/unit/states/test_boto_cognitoidentity.py @@ -9,9 +9,6 @@ import string # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -24,7 +21,7 @@ import logging from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch # pylint: disable=import-error,no-name-in-module -from unit.modules.test_boto_cognitoidentity import BotoCognitoIdentityTestCaseMixin +from tests.unit.modules.test_boto_cognitoidentity import BotoCognitoIdentityTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_dynamodb.py b/tests/unit/states/test_boto_dynamodb.py index 2d0e1bf2a2..be0ec2249f 100644 --- a/tests/unit/states/test_boto_dynamodb.py +++ b/tests/unit/states/test_boto_dynamodb.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_dynamodb @@ -119,8 +115,3 @@ class BotoDynamodbTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': changes}) self.assertDictEqual(boto_dynamodb.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoDynamodbTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_ec2.py b/tests/unit/states/test_boto_ec2.py index 272d5c7c94..6441d32624 100644 --- a/tests/unit/states/test_boto_ec2.py +++ b/tests/unit/states/test_boto_ec2.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_ec2 @@ -86,8 +82,3 @@ class BotoEc2TestCase(TestCase): comt = ('The key {0} is set to be deleted.'.format(name)) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_ec2.key_absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoEc2TestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_elasticache.py b/tests/unit/states/test_boto_elasticache.py index 4e67a5f6c8..155ab360d2 100644 --- a/tests/unit/states/test_boto_elasticache.py +++ b/tests/unit/states/test_boto_elasticache.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_elasticache @@ -122,8 +118,3 @@ class BotoElasticacheTestCase(TestCase): self.assertDictEqual(boto_elasticache.creategroup (name, primary_cluster_id, replication_group_description), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoElasticacheTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_elasticsearch_domain.py b/tests/unit/states/test_boto_elasticsearch_domain.py index d0c1956964..ca12bfa9e4 100644 --- a/tests/unit/states/test_boto_elasticsearch_domain.py +++ b/tests/unit/states/test_boto_elasticsearch_domain.py @@ -15,9 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.ext.six as six @@ -25,7 +22,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.test_boto_elasticsearch_domain import BotoElasticsearchDomainTestCaseMixin +from tests.unit.modules.test_boto_elasticsearch_domain import BotoElasticsearchDomainTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_elb.py b/tests/unit/states/test_boto_elb.py index 05364863aa..b3a780835d 100644 --- a/tests/unit/states/test_boto_elb.py +++ b/tests/unit/states/test_boto_elb.py @@ -14,10 +14,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_elb @@ -180,8 +176,3 @@ class BotoElbTestCase(TestCase): comt = ('ELB {0} is set to be removed.'.format(name)) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_elb.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoElbTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_iam_role.py b/tests/unit/states/test_boto_iam_role.py index ae95056d58..7ba7121785 100644 --- a/tests/unit/states/test_boto_iam_role.py +++ b/tests/unit/states/test_boto_iam_role.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_iam_role @@ -178,8 +174,3 @@ class BotoIAMRoleTestCase(TestCase): 'does not exist. Failed to delete myrole iam role.') ret.update({'comment': comt, 'changes': {}}) self.assertDictEqual(boto_iam_role.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoIAMRoleTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_iot.py b/tests/unit/states/test_boto_iot.py index 4719a2ee19..306e25999b 100644 --- a/tests/unit/states/test_boto_iot.py +++ b/tests/unit/states/test_boto_iot.py @@ -15,9 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -25,7 +22,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.test_boto_iot import BotoIoTTestCaseMixin +from tests.unit.modules.test_boto_iot import BotoIoTTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_kinesis.py b/tests/unit/states/test_boto_kinesis.py index 7f692d0c55..8f02dc5d99 100644 --- a/tests/unit/states/test_boto_kinesis.py +++ b/tests/unit/states/test_boto_kinesis.py @@ -10,10 +10,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_kinesis @@ -144,8 +140,3 @@ class BotoKinesisTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': changes}) self.assertDictEqual(boto_kinesis.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoKinesisTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_lambda.py b/tests/unit/states/test_boto_lambda.py index 81b28a5661..31e554e2c9 100644 --- a/tests/unit/states/test_boto_lambda.py +++ b/tests/unit/states/test_boto_lambda.py @@ -16,9 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -26,7 +23,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module -from unit.modules.test_boto_lambda import BotoLambdaTestCaseMixin, TempZipFile +from tests.unit.modules.test_boto_lambda import BotoLambdaTestCaseMixin, TempZipFile # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_lc.py b/tests/unit/states/test_boto_lc.py index cf77d269ad..2503782754 100644 --- a/tests/unit/states/test_boto_lc.py +++ b/tests/unit/states/test_boto_lc.py @@ -13,11 +13,8 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import SaltInvocationError -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_lc @@ -83,8 +80,3 @@ class BotoLcTestCase(TestCase): comt = ('Launch configuration set to be deleted.') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_lc.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoLcTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_route53.py b/tests/unit/states/test_boto_route53.py index 54ac114f8f..ce410927af 100644 --- a/tests/unit/states/test_boto_route53.py +++ b/tests/unit/states/test_boto_route53.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_route53 @@ -99,8 +95,3 @@ class BotoRoute53TestCase(TestCase): ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_route53.absent(name, zone, record_type), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoRoute53TestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_s3_bucket.py b/tests/unit/states/test_boto_s3_bucket.py index bf3619605a..8e25772066 100644 --- a/tests/unit/states/test_boto_s3_bucket.py +++ b/tests/unit/states/test_boto_s3_bucket.py @@ -16,9 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.ext.six as six @@ -26,7 +23,7 @@ import salt.loader from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,no-name-in-module,unused-import -from unit.modules.test_boto_s3_bucket import BotoS3BucketTestCaseMixin +from tests.unit.modules.test_boto_s3_bucket import BotoS3BucketTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_boto_secgroup.py b/tests/unit/states/test_boto_secgroup.py index d78052b7f3..ecec353ebf 100644 --- a/tests/unit/states/test_boto_secgroup.py +++ b/tests/unit/states/test_boto_secgroup.py @@ -5,9 +5,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.case import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.states import boto_secgroup @@ -47,7 +44,3 @@ class Boto_SecgroupTestCase(TestCase): # can also use: rules_to_delete = [rule for rule in present_rules if rule not in desired_rules] rules_to_delete = [OrderedDict([('ip_protocol', 'tcp'), ('from_port', 80), ('to_port', 80), ('cidr_ip', '0.0.0.0/0')])] self.assertEqual(boto_secgroup._get_rule_changes(desired_rules, present_rules), (rules_to_delete, [])) - -if __name__ == '__main__': - from integration import run_tests - run_tests(Boto_SecgroupTestCase) diff --git a/tests/unit/states/test_boto_sns.py b/tests/unit/states/test_boto_sns.py index d50d51cbe2..d20424669b 100644 --- a/tests/unit/states/test_boto_sns.py +++ b/tests/unit/states/test_boto_sns.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_sns @@ -149,8 +145,3 @@ class BotoSnsTestCase(TestCase): 'result': False, 'comment': comt}) self.assertDictEqual(boto_sns.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoSnsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_sqs.py b/tests/unit/states/test_boto_sqs.py index b8c587c3fd..b01c50a431 100644 --- a/tests/unit/states/test_boto_sqs.py +++ b/tests/unit/states/test_boto_sqs.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import boto_sqs @@ -93,8 +89,3 @@ class BotoSqsTestCase(TestCase): comt = ('AWS SQS queue {0} is set to be removed.'.format(name)) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(boto_sqs.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoSqsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_boto_vpc.py b/tests/unit/states/test_boto_vpc.py index 7b16fafb1c..896dd42758 100644 --- a/tests/unit/states/test_boto_vpc.py +++ b/tests/unit/states/test_boto_vpc.py @@ -10,9 +10,6 @@ import string # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs import salt.config @@ -21,7 +18,7 @@ import salt.utils.boto from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin # pylint: disable=import-error,unused-import -from unit.modules.test_boto_vpc import BotoVpcTestCaseMixin +from tests.unit.modules.test_boto_vpc import BotoVpcTestCaseMixin # Import 3rd-party libs try: diff --git a/tests/unit/states/test_bower.py b/tests/unit/states/test_bower.py index d01e58595b..51614065f7 100644 --- a/tests/unit/states/test_bower.py +++ b/tests/unit/states/test_bower.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import bower from salt.exceptions import CommandExecutionError @@ -239,8 +235,3 @@ class BowerTestCase(TestCase): 'Package(s) \'underscore\' successfully installed', 'changes': {'new': ['underscore'], 'old': []}} self.assertEqual(ret, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BowerTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_chef.py b/tests/unit/states/test_chef.py index a133a3f09c..39e8529003 100644 --- a/tests/unit/states/test_chef.py +++ b/tests/unit/states/test_chef.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import chef @@ -70,8 +66,3 @@ class ChefTestCase(TestCase): comt = ('\nerror') ret.update({'comment': comt}) self.assertDictEqual(chef.solo(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ChefTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_cloud.py b/tests/unit/states/test_cloud.py index 100af324fb..71143213f4 100644 --- a/tests/unit/states/test_cloud.py +++ b/tests/unit/states/test_cloud.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import cloud import salt.utils.cloud @@ -393,8 +389,3 @@ class CloudTestCase(TestCase): self.assertDictEqual(cloud.volume_detached(name, server_name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CloudTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_cmd.py b/tests/unit/states/test_cmd.py index dcd706b9f2..74ebfec435 100644 --- a/tests/unit/states/test_cmd.py +++ b/tests/unit/states/test_cmd.py @@ -14,11 +14,8 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import cmd @@ -309,8 +306,3 @@ class CmdTestCase(TestCase): ' please use cmd.wait or cmd.wait_script') ret.update({'comment': comt}) self.assertDictEqual(cmd.mod_watch(name, sfun='salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CmdTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_composer.py b/tests/unit/states/test_composer.py index 5036419bf6..4464d1ed4d 100644 --- a/tests/unit/states/test_composer.py +++ b/tests/unit/states/test_composer.py @@ -13,11 +13,8 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import SaltException -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import composer @@ -109,8 +106,3 @@ class ComposerTestCase(TestCase): ret.update({'comment': comt, 'result': True}) self.assertDictEqual(composer.update(name, quiet=True), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ComposerTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_cron.py b/tests/unit/states/test_cron.py index 2d52a43af2..e22bd491bc 100644 --- a/tests/unit/states/test_cron.py +++ b/tests/unit/states/test_cron.py @@ -8,11 +8,8 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') - from salt.ext.six.moves import StringIO from salt.modules import cron as cronmod from salt.states import cron as cron @@ -349,7 +346,3 @@ class CronTestCase(TestCase): ret = cron.present('foo', 'root', minute='0', hour='2') self.assertEqual(ret['changes'], {}) self.assertEqual(ret['comment'], 'Cron foo already present') - -if __name__ == '__main__': - from integration import run_tests - run_tests(CronTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_cyg.py b/tests/unit/states/test_cyg.py index b1bd3e65b7..1a667cf817 100644 --- a/tests/unit/states/test_cyg.py +++ b/tests/unit/states/test_cyg.py @@ -2,9 +2,7 @@ # # Import Salt Testing libs # from tests.support.unit import skipIf, TestCase -# from tests.support.helpers import ensure_in_syspath # from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -# ensure_in_syspath('../../') # # Late import so mock can do its job # import salt.states.cyg as cyg @@ -63,8 +61,3 @@ # self.assertEqual(False, ret['result']) # gem_uninstall_fails.assert_called_once_with( # 'bar', None, runas=None) - - -# if __name__ == '__main__': -# from integration import run_tests -# run_tests(TestGemState, needs_daemon=False) diff --git a/tests/unit/states/test_ddns.py b/tests/unit/states/test_ddns.py index 6f9711fc38..d8a7afd0c3 100644 --- a/tests/unit/states/test_ddns.py +++ b/tests/unit/states/test_ddns.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ddns @@ -79,8 +75,3 @@ class DdnsTestCase(TestCase): comt = ('No matching DNS record(s) present') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(ddns.absent(name, zone, data), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DdnsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_debconfmod.py b/tests/unit/states/test_debconfmod.py index c1bd91bcdd..511055c315 100644 --- a/tests/unit/states/test_debconfmod.py +++ b/tests/unit/states/test_debconfmod.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import debconfmod @@ -86,8 +82,3 @@ class DebconfmodTestCase(TestCase): with patch.dict(debconfmod.__opts__, {'test': True}): ret.update({'changes': changes}) self.assertDictEqual(debconfmod.set(name, data), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DebconfmodTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_disk.py b/tests/unit/states/test_disk.py index ea7ca2ca87..96a5e9d4dd 100644 --- a/tests/unit/states/test_disk.py +++ b/tests/unit/states/test_disk.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import disk @@ -247,8 +243,3 @@ class DiskTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'data': {'capacity': '15 %', 'used': '15'}}) self.assertDictEqual(disk.status(mock_fs, '20', '10', absolute=True), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DiskTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_docker.py b/tests/unit/states/test_docker.py index 64d975fb07..ccd4c4d4de 100644 --- a/tests/unit/states/test_docker.py +++ b/tests/unit/states/test_docker.py @@ -9,7 +9,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase from salt.exceptions import SaltInvocationError -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, Mock, @@ -18,8 +17,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.exceptions import CommandExecutionError from salt.modules import docker as docker_mod @@ -1198,8 +1195,3 @@ class DockerTestCase(TestCase): 'changes': {}, 'result': True, }) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DockerTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_drac.py b/tests/unit/states/test_drac.py index 5a84573cb4..0225698f3e 100644 --- a/tests/unit/states/test_drac.py +++ b/tests/unit/states/test_drac.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import drac @@ -116,8 +112,3 @@ class DracTestCase(TestCase): comt = ('unable to configure network') ret.update({'comment': comt, 'result': False}) self.assertDictEqual(drac.network(ip_, netmask, gateway), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DracTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_environ.py b/tests/unit/states/test_environ.py index 6e66bb4d5d..2e6b85601d 100644 --- a/tests/unit/states/test_environ.py +++ b/tests/unit/states/test_environ.py @@ -6,13 +6,10 @@ import os # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - # Import salt libs import salt.states.environ as envstate import salt.modules.environ as envmodule @@ -120,7 +117,3 @@ class TestEnvironState(TestCase): self.assertEqual(ret['changes'], {'test': 'value'}) ret = envstate.setenv('INITIAL', 'initial') self.assertEqual(ret['changes'], {}) - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestEnvironState, needs_daemon=False) diff --git a/tests/unit/states/test_eselect.py b/tests/unit/states/test_eselect.py index 2bfe3a5d14..794d8ff1f6 100644 --- a/tests/unit/states/test_eselect.py +++ b/tests/unit/states/test_eselect.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import eselect @@ -48,8 +44,3 @@ class EselectTestCase(TestCase): .format(target, name)) ret.update({'comment': comt}) self.assertDictEqual(eselect.set_(name, target), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EselectTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_event.py b/tests/unit/states/test_event.py index f58f6d5b49..48a66e32fd 100644 --- a/tests/unit/states/test_event.py +++ b/tests/unit/states/test_event.py @@ -10,7 +10,6 @@ from salt.states import event # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -18,8 +17,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - event.__opts__ = {} event.__salt__ = {} @@ -62,8 +59,3 @@ class EventTestCase(TestCase): 'name': 'salt', 'result': True} ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EventTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_file.py b/tests/unit/states/test_file.py index d44946a1c7..b0ddd155bb 100644 --- a/tests/unit/states/test_file.py +++ b/tests/unit/states/test_file.py @@ -16,7 +16,7 @@ NO_DATEUTIL_REASON = 'python-dateutil is not installed' # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import destructiveTest, ensure_in_syspath +from tests.support.helpers import destructiveTest from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -25,8 +25,6 @@ from tests.support.mock import ( mock_open, patch) -ensure_in_syspath('../../') - # Import third party libs import yaml @@ -1808,9 +1806,3 @@ class FileTestCase(TestCase): run_checks(test=True) run_checks(strptime_format=fake_strptime_format) run_checks(strptime_format=fake_strptime_format, test=True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(FileTestCase, needs_daemon=False) - run_tests(TestFileState, needs_daemon=False) diff --git a/tests/unit/states/test_gem.py b/tests/unit/states/test_gem.py index 872ad3d8b4..adc20296c2 100644 --- a/tests/unit/states/test_gem.py +++ b/tests/unit/states/test_gem.py @@ -5,9 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Late import so mock can do its job import salt.states.gem as gem @@ -106,7 +104,3 @@ class TestGemState(TestCase): self.assertEqual(False, ret['result']) gem_sources_remove_fails.assert_called_once_with( source_uri='http://bar', ruby=None, runas=None) - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestGemState, needs_daemon=False) diff --git a/tests/unit/states/test_glusterfs.py b/tests/unit/states/test_glusterfs.py index 611d97f956..26d32d4223 100644 --- a/tests/unit/states/test_glusterfs.py +++ b/tests/unit/states/test_glusterfs.py @@ -14,10 +14,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import glusterfs import salt.utils.cloud @@ -297,8 +293,3 @@ class GlusterfsTestCase(TestCase): 'changes': {'new': bricks + old_bricks, 'old': old_bricks}}) self.assertDictEqual(glusterfs.add_volume_bricks(name, bricks), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GlusterfsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_gnomedesktop.py b/tests/unit/states/test_gnomedesktop.py index 8b1a49e8f0..1ed730d865 100644 --- a/tests/unit/states/test_gnomedesktop.py +++ b/tests/unit/states/test_gnomedesktop.py @@ -11,10 +11,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import gnomedesktop @@ -68,8 +64,3 @@ class GnomedesktopTestCase(TestCase): 'changes': {}} self.assertDictEqual(gnomedesktop.desktop_interface(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GnomedesktopTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_grafana.py b/tests/unit/states/test_grafana.py index 7c402c44af..749ba199f5 100644 --- a/tests/unit/states/test_grafana.py +++ b/tests/unit/states/test_grafana.py @@ -4,6 +4,7 @@ ''' # Import Python libs from __future__ import absolute_import +import json # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase @@ -14,14 +15,9 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath -from salt.exceptions import SaltInvocationError -import json - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import grafana +from salt.exceptions import SaltInvocationError grafana.__opts__ = {} grafana.__salt__ = {} @@ -142,8 +138,3 @@ class GrafanaTestCase(TestCase): comt = ('Dashboard myservice does not exist.') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(grafana.dashboard_absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GrafanaTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_grafana_datasource.py b/tests/unit/states/test_grafana_datasource.py index 9f282945f1..1d666dd6a9 100644 --- a/tests/unit/states/test_grafana_datasource.py +++ b/tests/unit/states/test_grafana_datasource.py @@ -12,10 +12,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import grafana_datasource diff --git a/tests/unit/states/test_grains.py b/tests/unit/states/test_grains.py index 5a1a2ef097..2e26c9cd67 100644 --- a/tests/unit/states/test_grains.py +++ b/tests/unit/states/test_grains.py @@ -11,15 +11,12 @@ import yaml # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') - from salt.modules import grains as grainsmod from salt.states import grains as grains -import integration +import tests.integration as integration @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -1077,8 +1074,3 @@ class GrainsTestCase(TestCase): + "foo:\n" + "- bar\n" ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GrainsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_group.py b/tests/unit/states/test_group.py index dcada1f72c..4fe395b49b 100644 --- a/tests/unit/states/test_group.py +++ b/tests/unit/states/test_group.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import group from salt.utils.odict import OrderedDict @@ -112,8 +109,3 @@ class GroupTestCase(TestCase): ret.update({'result': True, 'comment': 'Group not present'}) self.assertDictEqual(group.absent('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GroupTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_hg.py b/tests/unit/states/test_hg.py index 24520a5570..4b56e98bbf 100644 --- a/tests/unit/states/test_hg.py +++ b/tests/unit/states/test_hg.py @@ -11,7 +11,6 @@ from salt.states import hg # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -19,8 +18,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - hg.__opts__ = {} hg.__salt__ = {} @@ -120,8 +117,3 @@ class HgTestCase(TestCase): with patch.object(hg, '_clone_repo', mock): self.assertDictEqual(hg.latest("salt", target="c:\\salt", update_head=False), ret) assert not update_mock.called - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HgTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_hipchat.py b/tests/unit/states/test_hipchat.py index 31e4e70d58..60200f5ed1 100644 --- a/tests/unit/states/test_hipchat.py +++ b/tests/unit/states/test_hipchat.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import hipchat @@ -75,8 +71,3 @@ class HipchatTestCase(TestCase): self.assertDictEqual(hipchat.send_message(name, room_id, from_name, message), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HipchatTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_host.py b/tests/unit/states/test_host.py index ab523eba74..c29fc3879b 100644 --- a/tests/unit/states/test_host.py +++ b/tests/unit/states/test_host.py @@ -10,7 +10,6 @@ from salt.states import host # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -18,8 +17,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - host.__salt__ = {} host.__opts__ = {} @@ -126,8 +123,3 @@ class HostTestCase(TestCase): self.assertDictEqual( expected, host.only("127.0.1.1", ['foo.bar', 'foo'])) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HostTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_htpasswd.py b/tests/unit/states/test_htpasswd.py index 63f8ad0f04..f7efe098e1 100644 --- a/tests/unit/states/test_htpasswd.py +++ b/tests/unit/states/test_htpasswd.py @@ -15,10 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import htpasswd @@ -88,8 +84,3 @@ class HtpasswdTestCase(TestCase): 'comment': 'Error', 'changes': {}} self.assertEqual(ret, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HtpasswdTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_http.py b/tests/unit/states/test_http.py index 2bb84028da..501cba7eae 100644 --- a/tests/unit/states/test_http.py +++ b/tests/unit/states/test_http.py @@ -10,7 +10,6 @@ from salt.states import http # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -18,8 +17,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - http.__salt__ = {} http.__opts__ = {} @@ -46,8 +43,3 @@ class HttpTestCase(TestCase): with patch.dict(http.__salt__, {'http.query': mock}): self.assertDictEqual(http.query("salt", "Dude", "stack"), ret[1]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HttpTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_incron.py b/tests/unit/states/test_incron.py index 5b7fe1b40b..cd843d86f4 100644 --- a/tests/unit/states/test_incron.py +++ b/tests/unit/states/test_incron.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import incron @@ -114,8 +110,3 @@ class IncronTestCase(TestCase): ret.update({'comment': comt4, 'result': False, 'changes': {}}) self.assertDictEqual(incron.absent(name, path, mask, cmd), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IncronTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_influxdb08_database.py b/tests/unit/states/test_influxdb08_database.py index 1d0463a05f..2255129071 100644 --- a/tests/unit/states/test_influxdb08_database.py +++ b/tests/unit/states/test_influxdb08_database.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import influxdb08_database @@ -106,8 +102,3 @@ class InfluxdbDatabaseTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(influxdb08_database.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(InfluxdbDatabaseTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_influxdb08_user.py b/tests/unit/states/test_influxdb08_user.py index 67c16da15c..e1b3dce8cf 100644 --- a/tests/unit/states/test_influxdb08_user.py +++ b/tests/unit/states/test_influxdb08_user.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import influxdb08_user @@ -113,8 +109,3 @@ class InfluxdbUserTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(influxdb08_user.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(InfluxdbUserTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ini_manage.py b/tests/unit/states/test_ini_manage.py index 12832c9f7d..78affdc388 100644 --- a/tests/unit/states/test_ini_manage.py +++ b/tests/unit/states/test_ini_manage.py @@ -13,10 +13,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ini_manage @@ -145,8 +141,3 @@ class IniManageTestCase(TestCase): comt = ('No anomaly detected') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(ini_manage.sections_absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IniManageTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ipmi.py b/tests/unit/states/test_ipmi.py index f415dd07de..8eb34ccd6c 100644 --- a/tests/unit/states/test_ipmi.py +++ b/tests/unit/states/test_ipmi.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ipmi @@ -158,8 +154,3 @@ class IpmiTestCase(TestCase): ret.update({'comment': comt, 'result': False, 'changes': {'new': 'None', 'old': [5]}}) self.assertDictEqual(ipmi.user_absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IpmiTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ipset.py b/tests/unit/states/test_ipset.py index 865df3875b..c74aac5c68 100644 --- a/tests/unit/states/test_ipset.py +++ b/tests/unit/states/test_ipset.py @@ -14,10 +14,6 @@ from tests.support.mock import ( call, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ipset diff --git a/tests/unit/states/test_iptables.py b/tests/unit/states/test_iptables.py index 16405783c3..cc38b73d72 100644 --- a/tests/unit/states/test_iptables.py +++ b/tests/unit/states/test_iptables.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import iptables @@ -376,8 +373,3 @@ class IptablesTestCase(TestCase): self.assertDictEqual(iptables.mod_aggregate({'fun': 'append'}, [], []), {'fun': 'append'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IptablesTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_jboss7.py b/tests/unit/states/test_jboss7.py index e4cd8444f6..38b0254d96 100644 --- a/tests/unit/states/test_jboss7.py +++ b/tests/unit/states/test_jboss7.py @@ -6,8 +6,6 @@ from __future__ import absolute_import # Import Salt testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import Salt libs from salt.states import jboss7 diff --git a/tests/unit/states/test_keyboard.py b/tests/unit/states/test_keyboard.py index 3b8f862d63..19e47f9061 100644 --- a/tests/unit/states/test_keyboard.py +++ b/tests/unit/states/test_keyboard.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import keyboard @@ -100,8 +96,3 @@ class KeyboardTestCase(TestCase): comt = ('Failed to set XOrg keyboard layout') ret.update({'comment': comt, 'result': False, 'changes': {}}) self.assertDictEqual(keyboard.xorg(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeyboardTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_keystone.py b/tests/unit/states/test_keystone.py index 3fce2faba2..4f051a63bf 100644 --- a/tests/unit/states/test_keystone.py +++ b/tests/unit/states/test_keystone.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import keystone @@ -359,8 +355,3 @@ class KeystoneTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(keystone.endpoint_absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeystoneTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_kmod.py b/tests/unit/states/test_kmod.py index fb76adbb4d..8b788c847a 100644 --- a/tests/unit/states/test_kmod.py +++ b/tests/unit/states/test_kmod.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import kmod @@ -217,8 +213,3 @@ class KmodTestCase(TestCase): 'result': True, 'changes': {}}) self.assertDictEqual(kmod.absent(name, mods=mods), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KmodTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_layman.py b/tests/unit/states/test_layman.py index c6d2cafa21..d6dca91ce4 100644 --- a/tests/unit/states/test_layman.py +++ b/tests/unit/states/test_layman.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import layman @@ -76,8 +72,3 @@ class LaymanTestCase(TestCase): comt = ('Overlay {0} is set to be deleted'.format(name)) ret.update({'comment': comt, 'result': None}) self.assertDictEqual(layman.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LaymanTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ldap.py b/tests/unit/states/test_ldap.py index a6d9c8fc1c..d0e068cc82 100644 --- a/tests/unit/states/test_ldap.py +++ b/tests/unit/states/test_ldap.py @@ -16,16 +16,12 @@ import salt.ext.six as six import salt.states.ldap from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, patch, ) -ensure_in_syspath('../../') - - # emulates the LDAP database. each key is the DN of an entry and it # maps to a dict which maps attribute names to sets of values. db = {} @@ -327,8 +323,3 @@ class LDAPTestCase(TestCase): self._test_helper_success( {}, {'dummydn': {'dummyattr': ['dummyval', 'dummyval']}}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LDAPTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_libcloud_dns.py b/tests/unit/states/test_libcloud_dns.py index 9fb7f70cba..11dd3c7811 100644 --- a/tests/unit/states/test_libcloud_dns.py +++ b/tests/unit/states/test_libcloud_dns.py @@ -15,11 +15,8 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath from salt.states import libcloud_dns -ensure_in_syspath('../../') - SERVICE_NAME = 'libcloud_dns' libcloud_dns.__salt__ = {} libcloud_dns.__utils__ = {} @@ -192,7 +189,3 @@ class LibcloudDnsModuleTestCase(ModuleTestCase): result = libcloud_dns.zone_absent('testing.com', 'test1') self.assertTrue(result) self.assertFalse(create_patch.called) - -if __name__ == '__main__': - from unit import run_tests - run_tests(LibcloudDnsModuleTestCase) diff --git a/tests/unit/states/test_libvirt.py b/tests/unit/states/test_libvirt.py index 00ea8bc6db..debb97acc1 100644 --- a/tests/unit/states/test_libvirt.py +++ b/tests/unit/states/test_libvirt.py @@ -15,10 +15,6 @@ from tests.support.mock import ( mock_open, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import virt import salt.utils @@ -65,8 +61,3 @@ class LibvirtTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': {'servercert': 'new'}}) self.assertDictEqual(virt.keys(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LibvirtTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_linux_acl.py b/tests/unit/states/test_linux_acl.py index bbdd6f8ae9..7d8f9a69dc 100644 --- a/tests/unit/states/test_linux_acl.py +++ b/tests/unit/states/test_linux_acl.py @@ -14,10 +14,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import linux_acl @@ -98,8 +94,3 @@ class LinuxAclTestCase(TestCase): ret.update({'comment': comt, 'result': False}) self.assertDictEqual(linux_acl.absent(name, acl_type, acl_name, perms), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LinuxAclTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_locale.py b/tests/unit/states/test_locale.py index d2ab1526a7..5dac0d81dd 100644 --- a/tests/unit/states/test_locale.py +++ b/tests/unit/states/test_locale.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import locale @@ -90,8 +87,3 @@ class LocaleTestCase(TestCase): self.assertDictEqual(locale.present("salt"), ret[2]) self.assertDictEqual(locale.present("salt"), ret[3]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LocaleTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_lvm.py b/tests/unit/states/test_lvm.py index 597175c3fe..f01c55d00a 100644 --- a/tests/unit/states/test_lvm.py +++ b/tests/unit/states/test_lvm.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import lvm @@ -176,8 +172,3 @@ class LvmTestCase(TestCase): ret.update({'comment': comt, 'result': None}) with patch.dict(lvm.__opts__, {'test': True}): self.assertDictEqual(lvm.lv_absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LvmTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_lvs_server.py b/tests/unit/states/test_lvs_server.py index 448a96f712..760dbc9c19 100644 --- a/tests/unit/states/test_lvs_server.py +++ b/tests/unit/states/test_lvs_server.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import lvs_server @@ -129,8 +125,3 @@ class LvsServerTestCase(TestCase): ' so it cannot be removed') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(lvs_server.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LvsServerTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_lvs_service.py b/tests/unit/states/test_lvs_service.py index 82a6411464..8a25f43544 100644 --- a/tests/unit/states/test_lvs_service.py +++ b/tests/unit/states/test_lvs_service.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import lvs_service @@ -122,8 +118,3 @@ class LvsServiceTestCase(TestCase): comt = ('LVS Service lvsrs is not present, so it cannot be removed') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(lvs_service.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LvsServiceTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_lxc.py b/tests/unit/states/test_lxc.py index 26be980fde..f5d6dbf342 100644 --- a/tests/unit/states/test_lxc.py +++ b/tests/unit/states/test_lxc.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import lxc import salt.utils @@ -258,8 +254,3 @@ class LxcTestCase(TestCase): with patch.dict(lxc.__salt__, {'lxc.update_lxc_conf': mock}): self.assertDictEqual(lxc.edited_conf(name), {'name': 'web01'}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LxcTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mac_assistive.py b/tests/unit/states/test_mac_assistive.py index f51a2aa0d3..0c1a39f99b 100644 --- a/tests/unit/states/test_mac_assistive.py +++ b/tests/unit/states/test_mac_assistive.py @@ -8,14 +8,11 @@ from salt.states import mac_assistive as assistive # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - assistive.__salt__ = {} @@ -119,8 +116,3 @@ class AssistiveTestCase(TestCase): enable_mock.assert_called_once_with('com.apple.Chess', False) assert not install_mock.called self.assertEqual(out, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(AssistiveTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mac_defaults.py b/tests/unit/states/test_mac_defaults.py index d77f55450f..63e0a3f039 100644 --- a/tests/unit/states/test_mac_defaults.py +++ b/tests/unit/states/test_mac_defaults.py @@ -8,14 +8,11 @@ from salt.states import mac_defaults as macdefaults # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - macdefaults.__salt__ = {} @@ -174,8 +171,3 @@ class MacDefaultsTestCase(TestCase): out = macdefaults.absent('Key', 'com.apple.something') mock.assert_called_once_with('com.apple.something', 'Key', None) self.assertEqual(out, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacDefaultsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mac_keychain.py b/tests/unit/states/test_mac_keychain.py index 28d285f23f..317876603e 100644 --- a/tests/unit/states/test_mac_keychain.py +++ b/tests/unit/states/test_mac_keychain.py @@ -8,15 +8,12 @@ from salt.states import mac_keychain as keychain # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, call ) -ensure_in_syspath('../../') - keychain.__salt__ = {} @@ -235,8 +232,3 @@ class KeychainTestCase(TestCase): uninstall_mock.assert_called_once_with('Friendly Name', '/Library/Keychains/System.keychain', keychain_password=None) self.assertEqual(out, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KeychainTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mac_package.py b/tests/unit/states/test_mac_package.py index 3adb8088a0..3d4dce22bc 100644 --- a/tests/unit/states/test_mac_package.py +++ b/tests/unit/states/test_mac_package.py @@ -8,14 +8,11 @@ from salt.states import mac_package as macpackage # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - macpackage.__salt__ = {} macpackage.__grains__ = {} @@ -367,7 +364,3 @@ class MacPackageTestCase(TestCase): with patch.dict(macpackage.__salt__, {'cmd.retcode': mock}): out = macpackage.installed('/path/to/file.pkg', unless='some command') self.assertEqual(out, expected) - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacPackageTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mac_xattr.py b/tests/unit/states/test_mac_xattr.py index 56a0e0f15c..cb088ee7af 100644 --- a/tests/unit/states/test_mac_xattr.py +++ b/tests/unit/states/test_mac_xattr.py @@ -8,14 +8,11 @@ from salt.states import mac_xattr as xattr # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - xattr.__salt__ = {} @@ -140,8 +137,3 @@ class XAttrTestCase(TestCase): list_mock.assert_called_once_with('/path/to/file') assert not delete_mock.called self.assertEqual(out, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(XAttrTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_makeconf.py b/tests/unit/states/test_makeconf.py index 8966c02ce3..5c68761cf7 100644 --- a/tests/unit/states/test_makeconf.py +++ b/tests/unit/states/test_makeconf.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import makeconf @@ -67,8 +63,3 @@ class MakeconfTestCase(TestCase): .format(name)) ret.update({'comment': comt}) self.assertDictEqual(makeconf.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MakeconfTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mdadm.py b/tests/unit/states/test_mdadm.py index 81e1b4d508..865c22d5d5 100644 --- a/tests/unit/states/test_mdadm.py +++ b/tests/unit/states/test_mdadm.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import mdadm @@ -94,8 +91,3 @@ class MdadmTestCase(TestCase): mock = MagicMock(return_value=True) with patch.dict(mdadm.__salt__, {'raid.destroy': mock}): self.assertDictEqual(mdadm.absent("saltstack"), ret[2]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MdadmTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_memcached.py b/tests/unit/states/test_memcached.py index 17d5db1dbf..9b67e709d3 100644 --- a/tests/unit/states/test_memcached.py +++ b/tests/unit/states/test_memcached.py @@ -13,11 +13,8 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import memcached @@ -101,8 +98,3 @@ class MemcachedTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': {'key deleted': 'foo', 'value': True}}) self.assertDictEqual(memcached.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MemcachedTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_modjk.py b/tests/unit/states/test_modjk.py index a5bbaa6990..bf1270f2fb 100644 --- a/tests/unit/states/test_modjk.py +++ b/tests/unit/states/test_modjk.py @@ -11,10 +11,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import modjk import salt.ext.six as six @@ -94,8 +90,3 @@ class ModjkTestCase(TestCase): ret.update({'comment': LIST_NOT_STR}) self.assertDictEqual(modjk.worker_recover(name, 'app1'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ModjkTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_modjk_worker.py b/tests/unit/states/test_modjk_worker.py index 43b40085d6..71fc5adb39 100644 --- a/tests/unit/states/test_modjk_worker.py +++ b/tests/unit/states/test_modjk_worker.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import modjk_worker @@ -93,8 +89,3 @@ class ModjkWorkerTestCase(TestCase): with patch.dict(modjk_worker.__salt__, {'publish.publish': mock}): ret.update({'comment': comt}) self.assertDictEqual(modjk_worker.disable(name, lbn, target), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ModjkWorkerTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_module.py b/tests/unit/states/test_module.py index 5c932a126c..d148ad4f60 100644 --- a/tests/unit/states/test_module.py +++ b/tests/unit/states/test_module.py @@ -12,7 +12,6 @@ from salt.states import module # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -20,8 +19,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - CMD = 'foo.bar' MOCK = MagicMock() module.__salt__ = {CMD: MOCK} @@ -70,8 +67,3 @@ class ModuleStateTest(TestCase): self.assertIn(comment, ret['comment']) self.assertIn('world', ret['comment']) self.assertIn('hello', ret['comment']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ModuleStateTest, needs_daemon=False) diff --git a/tests/unit/states/test_mongodb_database.py b/tests/unit/states/test_mongodb_database.py index e488f5af5e..02e7f34a5c 100644 --- a/tests/unit/states/test_mongodb_database.py +++ b/tests/unit/states/test_mongodb_database.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import mongodb_database @@ -63,8 +59,3 @@ class MongodbDatabaseTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'changes': {}}) self.assertDictEqual(mongodb_database.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MongodbDatabaseTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mongodb_user.py b/tests/unit/states/test_mongodb_user.py index 3de6191a0c..c755119ba4 100644 --- a/tests/unit/states/test_mongodb_user.py +++ b/tests/unit/states/test_mongodb_user.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import mongodb_user @@ -102,8 +98,3 @@ class MongodbUserTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(mongodb_user.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MongodbUserTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mount.py b/tests/unit/states/test_mount.py index 81570be5fd..f6177d3c43 100644 --- a/tests/unit/states/test_mount.py +++ b/tests/unit/states/test_mount.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import mount import os @@ -301,8 +297,3 @@ class MountTestCase(TestCase): comt = ('Watch not supported in unmount at this time') ret.update({'comment': comt}) self.assertDictEqual(mount.mod_watch(name, sfun='unmount'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MountTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mysql_grants.py b/tests/unit/states/test_mysql_grants.py index 646dbece9a..91ed7c969b 100644 --- a/tests/unit/states/test_mysql_grants.py +++ b/tests/unit/states/test_mysql_grants.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import mysql_grants @@ -117,8 +113,3 @@ class MysqlGrantsTestCase(TestCase): ' so it cannot be revoked') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(mysql_grants.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MysqlGrantsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mysql_query.py b/tests/unit/states/test_mysql_query.py index 86015a89cf..8047bc3cb6 100644 --- a/tests/unit/states/test_mysql_query.py +++ b/tests/unit/states/test_mysql_query.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import mysql_query import os @@ -124,8 +120,3 @@ class MysqlQueryTestCase(TestCase): 'changes': {'query': 'Executed'}}) self.assertDictEqual(mysql_query.run(name, database, query), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MysqlQueryTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_mysql_user.py b/tests/unit/states/test_mysql_user.py index 7329af2640..97652e1de6 100644 --- a/tests/unit/states/test_mysql_user.py +++ b/tests/unit/states/test_mysql_user.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import mysql_user import salt @@ -157,8 +153,3 @@ class MysqlUserTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(mysql_user.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MysqlUserTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_network.py b/tests/unit/states/test_network.py index c2ce0b8375..711e34e6f8 100644 --- a/tests/unit/states/test_network.py +++ b/tests/unit/states/test_network.py @@ -9,7 +9,6 @@ import sys # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -17,8 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import network @@ -231,8 +228,3 @@ class NetworkTestCase(TestCase): ' are up to date.', 'result': True}) self.assertDictEqual(network.system('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetworkTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_nftables.py b/tests/unit/states/test_nftables.py index 61575c01ab..df6a1fd249 100644 --- a/tests/unit/states/test_nftables.py +++ b/tests/unit/states/test_nftables.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import nftables @@ -275,8 +272,3 @@ class NftablesTestCase(TestCase): 'result': False}) self.assertDictEqual(nftables.flush('salt', table='', chain=''), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NftablesTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_npm.py b/tests/unit/states/test_npm.py index 7b2c370b00..e0ac66ea37 100644 --- a/tests/unit/states/test_npm.py +++ b/tests/unit/states/test_npm.py @@ -13,11 +13,8 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import npm @@ -220,8 +217,3 @@ class NpmTestCase(TestCase): pkg_ret.update({'result': False, 'comment': comt}) pkg_ret['changes'] = {} self.assertDictEqual(npm.cache_cleaned(name), pkg_ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NpmTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ntp.py b/tests/unit/states/test_ntp.py index 4f8bb9dc55..bd46fdfef1 100644 --- a/tests/unit/states/test_ntp.py +++ b/tests/unit/states/test_ntp.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ntp @@ -58,8 +54,3 @@ class NtpTestCase(TestCase): comt = ('Failed to update NTP servers') ret.update({'comment': comt, 'result': False}) self.assertDictEqual(ntp.managed(name, [name]), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NtpTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_openstack_config.py b/tests/unit/states/test_openstack_config.py index ec001bc4f8..1bf4885ad2 100644 --- a/tests/unit/states/test_openstack_config.py +++ b/tests/unit/states/test_openstack_config.py @@ -13,11 +13,8 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import openstack_config @@ -98,8 +95,3 @@ class OpenstackConfigTestCase(TestCase): ret.update({'comment': comt, 'changes': {'Value': 'Deleted'}}) self.assertDictEqual(openstack_config.absent(name, filename, section), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(OpenstackConfigTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_openvswitch_port.py b/tests/unit/states/test_openvswitch_port.py index daa2656cbf..16a034172e 100644 --- a/tests/unit/states/test_openvswitch_port.py +++ b/tests/unit/states/test_openvswitch_port.py @@ -10,10 +10,6 @@ from tests.support.mock import ( NO_MOCK_REASON, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import openvswitch_port @@ -86,9 +82,3 @@ class OpenvswitchPortTestCase(TestCase): } }) self.assertDictEqual(openvswitch_port.present(name, bridge, tunnel_type="gre", id=1, remote="10.0.0.1"), ret) - - -if __name__ == '__main__': - from integration import run_tests - - run_tests(OpenvswitchPortTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_pagerduty.py b/tests/unit/states/test_pagerduty.py index c7eba0f747..9c2be5cf46 100644 --- a/tests/unit/states/test_pagerduty.py +++ b/tests/unit/states/test_pagerduty.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import pagerduty @@ -61,8 +57,3 @@ class PagerdutyTestCase(TestCase): self.assertDictEqual(pagerduty.create_event(name, details, service_key, profile), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PagerdutyTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_pecl.py b/tests/unit/states/test_pecl.py index c364732c90..6fdd91b96b 100644 --- a/tests/unit/states/test_pecl.py +++ b/tests/unit/states/test_pecl.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import pecl @@ -94,8 +90,3 @@ class PeclTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': {name: 'Removed'}}) self.assertDictEqual(pecl.removed(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PeclTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_pip.py b/tests/unit/states/test_pip.py index 1c1d078fe7..d37f064b6d 100644 --- a/tests/unit/states/test_pip.py +++ b/tests/unit/states/test_pip.py @@ -11,13 +11,11 @@ from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs -import integration from salt.states import pip_state # Import 3rd-party libs @@ -302,8 +300,3 @@ class PipStateTest(TestCase, integration.SaltReturnAssertsMixIn): 'successfully installed', {'test': ret} ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PipStateTest, needs_daemon=False) diff --git a/tests/unit/states/test_pkgng.py b/tests/unit/states/test_pkgng.py index 3fad7036ad..d050d77437 100644 --- a/tests/unit/states/test_pkgng.py +++ b/tests/unit/states/test_pkgng.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import pkgng @@ -44,8 +40,3 @@ class PkgngTestCase(TestCase): mock_t = MagicMock(return_value=True) with patch.dict(pkgng.__salt__, {'pkgng.update_package_site': mock_t}): self.assertDictEqual(pkgng.update_packaging_site(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PkgngTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_portage_config.py b/tests/unit/states/test_portage_config.py index 5d309f70e8..7bd6101fce 100644 --- a/tests/unit/states/test_portage_config.py +++ b/tests/unit/states/test_portage_config.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import portage_config @@ -80,8 +76,3 @@ class PortageConfigTestCase(TestCase): ret.update({'comment': '', 'result': True}) self.assertDictEqual(portage_config.flags(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PortageConfigTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ports.py b/tests/unit/states/test_ports.py index ca978d3d09..1d7eb7e952 100644 --- a/tests/unit/states/test_ports.py +++ b/tests/unit/states/test_ports.py @@ -13,11 +13,8 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import SaltInvocationError -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ports import os @@ -139,8 +136,3 @@ class PortsTestCase(TestCase): self.assertDictEqual(ports.installed(name, [{'salt': 'salt'}]), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PortsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_postgres.py b/tests/unit/states/test_postgres.py index e323e5a78f..39e5ec6a5a 100644 --- a/tests/unit/states/test_postgres.py +++ b/tests/unit/states/test_postgres.py @@ -5,15 +5,10 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, Mock, MagicMock, patch -ensure_in_syspath('../../') - # Import salt libs - from salt.modules import postgres as postgresmod - from salt.states import ( postgres_database, postgres_user, @@ -568,8 +563,3 @@ class PostgresSchemaTestCase(TestCase): 'result': True} ) self.assertEqual(SALT_STUB['postgres.schema_remove'].call_count, 0) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresExtensionTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_postgres_cluster.py b/tests/unit/states/test_postgres_cluster.py index 9e18689021..1cad5dbdc1 100644 --- a/tests/unit/states/test_postgres_cluster.py +++ b/tests/unit/states/test_postgres_cluster.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import postgres_cluster @@ -129,8 +125,3 @@ class PostgresClusterTestCase(TestCase): .format(version, name)) ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(postgres_cluster.absent(version, name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresClusterTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_postgres_database.py b/tests/unit/states/test_postgres_database.py index bc3d1d0966..9d75841eea 100644 --- a/tests/unit/states/test_postgres_database.py +++ b/tests/unit/states/test_postgres_database.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import postgres_database @@ -109,8 +105,3 @@ class PostgresDatabaseTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(postgres_database.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresDatabaseTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_postgres_extension.py b/tests/unit/states/test_postgres_extension.py index b4f38b70de..96e9ce6acd 100644 --- a/tests/unit/states/test_postgres_extension.py +++ b/tests/unit/states/test_postgres_extension.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import postgres_extension @@ -94,8 +90,3 @@ class PostgresExtensionTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(postgres_extension.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresExtensionTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_postgres_group.py b/tests/unit/states/test_postgres_group.py index d53d755fa5..bdf9c88335 100644 --- a/tests/unit/states/test_postgres_group.py +++ b/tests/unit/states/test_postgres_group.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import postgres_group @@ -92,8 +88,3 @@ class PostgresGroupTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(postgres_group.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresGroupTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_postgres_initdb.py b/tests/unit/states/test_postgres_initdb.py index f0889d4691..9a156d0438 100644 --- a/tests/unit/states/test_postgres_initdb.py +++ b/tests/unit/states/test_postgres_initdb.py @@ -12,10 +12,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - from salt.states import postgres_initdb diff --git a/tests/unit/states/test_postgres_language.py b/tests/unit/states/test_postgres_language.py index 0799eecab5..53c51ffe07 100644 --- a/tests/unit/states/test_postgres_language.py +++ b/tests/unit/states/test_postgres_language.py @@ -12,10 +12,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - from salt.states import postgres_language diff --git a/tests/unit/states/test_postgres_privileges.py b/tests/unit/states/test_postgres_privileges.py index ee390c2124..4ce1ac66d7 100644 --- a/tests/unit/states/test_postgres_privileges.py +++ b/tests/unit/states/test_postgres_privileges.py @@ -12,10 +12,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - from salt.states import postgres_privileges diff --git a/tests/unit/states/test_postgres_schema.py b/tests/unit/states/test_postgres_schema.py index f3e43dc727..c160b8e596 100644 --- a/tests/unit/states/test_postgres_schema.py +++ b/tests/unit/states/test_postgres_schema.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import postgres_schema @@ -87,8 +83,3 @@ class PostgresSchemaTestCase(TestCase): ' so it cannot be removed'.format(name, dbname)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(postgres_schema.absent(dbname, name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresSchemaTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_postgres_user.py b/tests/unit/states/test_postgres_user.py index f78670d3dd..cd813f84a7 100644 --- a/tests/unit/states/test_postgres_user.py +++ b/tests/unit/states/test_postgres_user.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import postgres_user @@ -93,8 +89,3 @@ class PostgresUserTestCase(TestCase): .format(name)) ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(postgres_user.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PostgresUserTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_powerpath.py b/tests/unit/states/test_powerpath.py index 610334c2c2..456c448c58 100644 --- a/tests/unit/states/test_powerpath.py +++ b/tests/unit/states/test_powerpath.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import powerpath @@ -115,8 +111,3 @@ class PowerpathTestCase(TestCase): ret.update({'result': False, 'changes': {}}) self.assertDictEqual(powerpath.license_absent('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PowerpathTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_process.py b/tests/unit/states/test_process.py index 5afe077a47..e1eb63ec01 100644 --- a/tests/unit/states/test_process.py +++ b/tests/unit/states/test_process.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import process @@ -54,8 +50,3 @@ class ProcessTestCase(TestCase): with patch.dict(process.__opts__, {'test': False}): ret.update({'result': True}) self.assertDictEqual(process.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ProcessTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_proxy.py b/tests/unit/states/test_proxy.py index d6392f78ff..c466415988 100644 --- a/tests/unit/states/test_proxy.py +++ b/tests/unit/states/test_proxy.py @@ -5,7 +5,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -17,8 +16,6 @@ from tests.support.mock import ( # Import 3rd-party libs import salt.ext.six as six -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import proxy as proxy @@ -195,8 +192,3 @@ class ProxyTestCase(TestCase): assert not set_proxy_mock.called self.assertEqual(out, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ProxyTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_pyenv.py b/tests/unit/states/test_pyenv.py index 0b1f6001ed..2cf87498ef 100644 --- a/tests/unit/states/test_pyenv.py +++ b/tests/unit/states/test_pyenv.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import pyenv @@ -132,8 +128,3 @@ class PyenvTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'default': False, 'changes': {None: 'Installed'}}) self.assertDictEqual(pyenv.install_pyenv(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PyenvTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_pyrax_queues.py b/tests/unit/states/test_pyrax_queues.py index 621d9c8e1b..e7bdd2870f 100644 --- a/tests/unit/states/test_pyrax_queues.py +++ b/tests/unit/states/test_pyrax_queues.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import pyrax_queues @@ -87,8 +83,3 @@ class PyraxQueuesTestCase(TestCase): comt = ('Rackspace queue myqueue is set to be removed.') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(pyrax_queues.absent(name, provider), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PyraxQueuesTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_quota.py b/tests/unit/states/test_quota.py index d7b879b80f..5edf06f0c4 100644 --- a/tests/unit/states/test_quota.py +++ b/tests/unit/states/test_quota.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import quota @@ -69,8 +65,3 @@ class QuotaTestCase(TestCase): comt = ('Failed to set quota for / to on') ret.update({'comment': comt, 'result': False, 'changes': {}}) self.assertDictEqual(quota.mode(name, mode, quotatype), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(QuotaTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_rabbitmq_cluster.py b/tests/unit/states/test_rabbitmq_cluster.py index e838c36dd0..ef80a3ecf1 100644 --- a/tests/unit/states/test_rabbitmq_cluster.py +++ b/tests/unit/states/test_rabbitmq_cluster.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import rabbitmq_cluster @@ -67,8 +64,3 @@ class RabbitmqClusterTestCase(TestCase): 'salt', 'rahulha'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitmqClusterTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_rabbitmq_plugin.py b/tests/unit/states/test_rabbitmq_plugin.py index 761a0960ac..bdeaf1592f 100644 --- a/tests/unit/states/test_rabbitmq_plugin.py +++ b/tests/unit/states/test_rabbitmq_plugin.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import rabbitmq_plugin @@ -81,8 +77,3 @@ class RabbitmqPluginTestCase(TestCase): changes = {'new': '', 'old': 'some_plugin'} ret.update({'comment': comment, 'result': None, 'changes': changes}) self.assertDictEqual(rabbitmq_plugin.disabled(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitmqPluginTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_rabbitmq_policy.py b/tests/unit/states/test_rabbitmq_policy.py index 0c5c8b6cc4..3bb47a91ae 100644 --- a/tests/unit/states/test_rabbitmq_policy.py +++ b/tests/unit/states/test_rabbitmq_policy.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import rabbitmq_policy @@ -87,8 +83,3 @@ class RabbitmqPolicyTestCase(TestCase): changes = {'new': '', 'old': 'HA'} ret.update({'comment': comment, 'result': None, 'changes': changes}) self.assertDictEqual(rabbitmq_policy.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitmqPolicyTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_rabbitmq_vhost.py b/tests/unit/states/test_rabbitmq_vhost.py index 9ceac0f2ac..0db5feba42 100644 --- a/tests/unit/states/test_rabbitmq_vhost.py +++ b/tests/unit/states/test_rabbitmq_vhost.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import rabbitmq_vhost @@ -66,8 +62,3 @@ class RabbitmqVhostTestCase(TestCase): with patch.dict(rabbitmq_vhost.__salt__, {'rabbitmq.vhost_exists': mock}): self.assertDictEqual(rabbitmq_vhost.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RabbitmqVhostTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_rbenv.py b/tests/unit/states/test_rbenv.py index 766deda257..c4cd910f71 100644 --- a/tests/unit/states/test_rbenv.py +++ b/tests/unit/states/test_rbenv.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import rbenv @@ -128,8 +124,3 @@ class RbenvTestCase(TestCase): comt = ('Rbenv installed') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(rbenv.install_rbenv(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RbenvTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_rdp.py b/tests/unit/states/test_rdp.py index d2981174bc..2eb552d1d3 100644 --- a/tests/unit/states/test_rdp.py +++ b/tests/unit/states/test_rdp.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import rdp @@ -95,8 +91,3 @@ class RdpTestCase(TestCase): comt = ('RDP is disabled') ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(rdp.disabled(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RdpTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_redismod.py b/tests/unit/states/test_redismod.py index 79ce98157a..9872d40fc4 100644 --- a/tests/unit/states/test_redismod.py +++ b/tests/unit/states/test_redismod.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import redismod @@ -81,8 +77,3 @@ class RedismodTestCase(TestCase): ret.update({'comment': comt, 'changes': {'deleted': ['key_in_redis']}}) self.assertDictEqual(redismod.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RedismodTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_reg.py b/tests/unit/states/test_reg.py index 26ae16c55e..7d2d69f18a 100644 --- a/tests/unit/states/test_reg.py +++ b/tests/unit/states/test_reg.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import reg @@ -112,8 +108,3 @@ class RegTestCase(TestCase): 'changes': {'reg': {'Removed': {'Entry': vname, 'Key': name}}}, 'comment': 'Removed {0} from {1}'.format(key, hive)}) self.assertDictEqual(reg.absent(name, vname), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RegTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_rvm.py b/tests/unit/states/test_rvm.py index 6b21201d13..2cdead4d75 100644 --- a/tests/unit/states/test_rvm.py +++ b/tests/unit/states/test_rvm.py @@ -5,9 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') # Import salt libs import salt.modules.rvm @@ -97,8 +95,3 @@ class TestRvmState(TestCase): rvm.installed('1.9.3', default=True) mock.assert_called_once_with( {'result': True}, '1.9.3', True, user=None) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestRvmState, needs_daemon=False) diff --git a/tests/unit/states/test_saltmod.py b/tests/unit/states/test_saltmod.py index f1a6d547c6..3fa7f50c84 100644 --- a/tests/unit/states/test_saltmod.py +++ b/tests/unit/states/test_saltmod.py @@ -4,6 +4,7 @@ ''' # Import Python libs from __future__ import absolute_import +import time # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase @@ -14,13 +15,8 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath -import salt.utils.event -import time - -ensure_in_syspath('../../') - # Import Salt Libs +import salt.utils.event from salt.states import saltmod saltmod.__opts__ = {'__role': 'master', 'file_client': 'remote'} @@ -193,8 +189,3 @@ class SaltmodTestCase(TestCase): with patch.dict(saltmod.__salt__, {'saltutil.wheel': wheel_mock}): self.assertDictEqual(saltmod.wheel(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SaltmodTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_schedule.py b/tests/unit/states/test_schedule.py index 557caeda72..a09e56f7d5 100644 --- a/tests/unit/states/test_schedule.py +++ b/tests/unit/states/test_schedule.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import schedule @@ -87,8 +83,3 @@ class ScheduleTestCase(TestCase): comt = ('Job job1 not present in schedule') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(schedule.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ScheduleTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_selinux.py b/tests/unit/states/test_selinux.py index aa45bfaa63..610b894fec 100644 --- a/tests/unit/states/test_selinux.py +++ b/tests/unit/states/test_selinux.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import selinux @@ -127,8 +123,3 @@ class SelinuxTestCase(TestCase): 'samba_create_home_dirs to on') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(selinux.boolean(name, value), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SelinuxTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_serverdensity_device.py b/tests/unit/states/test_serverdensity_device.py index 2792a58dfb..657ca51f7c 100644 --- a/tests/unit/states/test_serverdensity_device.py +++ b/tests/unit/states/test_serverdensity_device.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import serverdensity_device @@ -63,8 +59,3 @@ class ServerdensityDeviceTestCase(TestCase): {'agentKey': True}, 'installed_agent': True}}) self.assertDictEqual(serverdensity_device.monitored(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ServerdensityDeviceTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_service.py b/tests/unit/states/test_service.py index e622e07cf6..c481048b22 100644 --- a/tests/unit/states/test_service.py +++ b/tests/unit/states/test_service.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import service @@ -241,8 +238,3 @@ class ServiceTestCase(TestCase): ret[3]) self.assertDictEqual(service.mod_watch("salt", "stack"), ret[1]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ServiceTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_slack.py b/tests/unit/states/test_slack.py index 56ba96fdd8..edf83dc9ca 100644 --- a/tests/unit/states/test_slack.py +++ b/tests/unit/states/test_slack.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import slack @@ -76,8 +72,3 @@ class SlackTestCase(TestCase): self.assertDictEqual(slack.post_message(name, channel, from_name, message), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SlackTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_smtp.py b/tests/unit/states/test_smtp.py index 80e927d0fd..5847cf83f8 100644 --- a/tests/unit/states/test_smtp.py +++ b/tests/unit/states/test_smtp.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import smtp @@ -66,8 +62,3 @@ class SmtpTestCase(TestCase): 'Message from Salt', 'admin@example.com', 'my-smtp-account'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SmtpTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_splunk_search.py b/tests/unit/states/test_splunk_search.py index 610368948f..cf214ff571 100644 --- a/tests/unit/states/test_splunk_search.py +++ b/tests/unit/states/test_splunk_search.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import splunk_search @@ -83,8 +79,3 @@ class SplunkSearchTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(splunk_search.absent(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SplunkSearchTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ssh_auth.py b/tests/unit/states/test_ssh_auth.py index 96b3d99017..0c8e1ee73b 100644 --- a/tests/unit/states/test_ssh_auth.py +++ b/tests/unit/states/test_ssh_auth.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ssh_auth @@ -105,8 +101,3 @@ class SshAuthTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'changes': {name: 'Removed'}}) self.assertDictEqual(ssh_auth.absent(name, user, source), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SshAuthTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_ssh_known_hosts.py b/tests/unit/states/test_ssh_known_hosts.py index 3e4103ce71..389bfc1154 100644 --- a/tests/unit/states/test_ssh_known_hosts.py +++ b/tests/unit/states/test_ssh_known_hosts.py @@ -4,6 +4,7 @@ ''' # Import Python libs from __future__ import absolute_import +import os # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase @@ -14,10 +15,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath -import os -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import ssh_known_hosts @@ -170,8 +167,3 @@ class SshKnownHostsTestCase(TestCase): 'changes': {'new': None, 'old': True}}) self.assertDictEqual(ssh_known_hosts.absent(name, user), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SshKnownHostsTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_status.py b/tests/unit/states/test_status.py index edd31212e0..bc3b62779e 100644 --- a/tests/unit/states/test_status.py +++ b/tests/unit/states/test_status.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import status @@ -92,8 +88,3 @@ class StatusTestCase(TestCase): ret.update({'comment': comt, 'result': True, 'data': {name: 1}}) self.assertDictEqual(status.process(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StatusTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_supervisord.py b/tests/unit/states/test_supervisord.py index 4a985647e0..011addbe02 100644 --- a/tests/unit/states/test_supervisord.py +++ b/tests/unit/states/test_supervisord.py @@ -14,10 +14,6 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import supervisord @@ -95,8 +91,3 @@ class SupervisordTestCase(TestCase): ' Do you need to install supervisord?') ret.update({'comment': comt, 'result': False}) self.assertDictEqual(supervisord.mod_watch(name), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SupervisordTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_svn.py b/tests/unit/states/test_svn.py index 9b2dc203be..c6525221a3 100644 --- a/tests/unit/states/test_svn.py +++ b/tests/unit/states/test_svn.py @@ -11,7 +11,6 @@ from salt.states import svn # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -19,8 +18,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - svn.__opts__ = {} svn.__salt__ = {} @@ -120,8 +117,3 @@ class SvnTestCase(TestCase): mock = MagicMock(return_value=True) with patch.object(svn, '_fail', mock): self.assertTrue(svn.dirty("salt", "c://salt")) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SvnTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_sysctl.py b/tests/unit/states/test_sysctl.py index a3f9777fc3..9f0c19c08d 100644 --- a/tests/unit/states/test_sysctl.py +++ b/tests/unit/states/test_sysctl.py @@ -14,11 +14,8 @@ from tests.support.mock import ( patch ) -from tests.support.helpers import ensure_in_syspath from salt.exceptions import CommandExecutionError -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import sysctl @@ -129,8 +126,3 @@ class SysctlTestCase(TestCase): with patch.dict(sysctl.__salt__, {'sysctl.persist': mock}): ret.update({'comment': comt7, 'result': True}) self.assertDictEqual(sysctl.present(name, value), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SysctlTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_syslog_ng.py b/tests/unit/states/test_syslog_ng.py index 9b0d062070..2476dbb13c 100644 --- a/tests/unit/states/test_syslog_ng.py +++ b/tests/unit/states/test_syslog_ng.py @@ -11,11 +11,8 @@ import tempfile import os from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../../') - import salt.utils from salt.states import syslog_ng from salt.modules import syslog_ng as syslog_ng_module @@ -383,9 +380,3 @@ class SyslogNGTestCase(TestCase): command = got["changes"]["new"] self.assertTrue( command.endswith("syslog-ng --user=joe --group=users --enable-core --cfgfile=/etc/syslog-ng.conf")) - - -if __name__ == '__main__': - from integration import run_tests - - run_tests(SyslogNGTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_sysrc.py b/tests/unit/states/test_sysrc.py index 7306804d4f..569050363e 100644 --- a/tests/unit/states/test_sysrc.py +++ b/tests/unit/states/test_sysrc.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import sysrc @@ -86,8 +83,3 @@ class SysrcTestCase(TestCase): 'comment': '"salt" was removed!', 'result': True}) self.assertDictEqual(sysrc.absent('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SysrcTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_test.py b/tests/unit/states/test_test.py index a5bf73ff25..faac6fe3b9 100644 --- a/tests/unit/states/test_test.py +++ b/tests/unit/states/test_test.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( patch, MagicMock, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.exceptions import SaltInvocationError from salt.states import test @@ -330,7 +327,3 @@ class TestTestCase(TestCase): pillar_mock = MagicMock(return_value=pillar_return) with patch.dict(test.__salt__, {'pillar.get': pillar_mock}): self.assertEqual(test.check_pillar('salt', dictionary='my_pillar'), ret) - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_timezone.py b/tests/unit/states/test_timezone.py index d75717ea90..b5a313081c 100644 --- a/tests/unit/states/test_timezone.py +++ b/tests/unit/states/test_timezone.py @@ -9,7 +9,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from salt.exceptions import CommandExecutionError from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -17,8 +16,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import timezone @@ -63,8 +60,3 @@ class TimezoneTestCase(TestCase): ret.update({'comment': 'Failed to set UTC to True', 'result': False}) self.assertDictEqual(timezone.system('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TimezoneTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_tomcat.py b/tests/unit/states/test_tomcat.py index 698a667d23..dfd70bfbd1 100644 --- a/tests/unit/states/test_tomcat.py +++ b/tests/unit/states/test_tomcat.py @@ -11,7 +11,6 @@ from salt.states import tomcat # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -19,8 +18,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Globals tomcat.__salt__ = {} tomcat.__opts__ = {} @@ -220,9 +217,3 @@ class TomcatTestCase(TestCase): ret.update({'changes': {'undeploy': 1}, 'comment': '', 'result': True}) self.assertDictEqual(tomcat.undeployed('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - - run_tests(TomcatTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_user.py b/tests/unit/states/test_user.py index 9bc26d2b18..b65299f8fc 100644 --- a/tests/unit/states/test_user.py +++ b/tests/unit/states/test_user.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import user @@ -102,8 +99,3 @@ class UserTestCase(TestCase): ret.update({'comment': 'User salt is not present', 'result': True}) self.assertDictEqual(user.absent('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UserTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_vbox_guest.py b/tests/unit/states/test_vbox_guest.py index 144bfe795f..95b61fe901 100644 --- a/tests/unit/states/test_vbox_guest.py +++ b/tests/unit/states/test_vbox_guest.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import vbox_guest @@ -124,8 +121,3 @@ class VboxGuestTestCase(TestCase): ''' self.assertDictEqual(vbox_guest.grant_access_to_shared_folders_to('AB'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VboxGuestTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_virtualenv_mod.py b/tests/unit/states/test_virtualenv_mod.py index 10ac633ab2..406b1b9181 100644 --- a/tests/unit/states/test_virtualenv_mod.py +++ b/tests/unit/states/test_virtualenv_mod.py @@ -5,19 +5,16 @@ # Import Python Libs from __future__ import absolute_import +import os # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -import os - -ensure_in_syspath('../../') # Import Salt Libs from salt.states import virtualenv_mod @@ -92,8 +89,3 @@ class VirtualenvModTestCase(TestCase): ret.update({'comment': 'virtualenv exists', 'result': True}) self.assertDictEqual(virtualenv_mod.managed('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VirtualenvModTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_certutil.py b/tests/unit/states/test_win_certutil.py index b0f0efb581..645fe36007 100644 --- a/tests/unit/states/test_win_certutil.py +++ b/tests/unit/states/test_win_certutil.py @@ -8,14 +8,11 @@ from salt.states import win_certutil as certutil # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - certutil.__salt__ = {} @@ -228,8 +225,3 @@ class CertUtilTestCase(TestCase): get_store_serials_mock.assert_called_once_with('TrustedPublisher') del_mock.assert_called_once_with('/tmp/cert.cer', 'TrustedPublisher') self.assertEqual(expected, out) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CertUtilTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_dism.py b/tests/unit/states/test_win_dism.py index 09979057e2..7fa679906b 100644 --- a/tests/unit/states/test_win_dism.py +++ b/tests/unit/states/test_win_dism.py @@ -8,14 +8,11 @@ from salt.states import win_dism as dism # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - dism.__salt__ = {} dism.__opts__ = {} @@ -521,8 +518,3 @@ class WinDismTestCase(TestCase): mock_removed.assert_called_once_with() assert not mock_remove.called self.assertEqual(out, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinDismTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_dns_client.py b/tests/unit/states/test_win_dns_client.py index f15f5d428d..fd00a5c8d9 100644 --- a/tests/unit/states/test_win_dns_client.py +++ b/tests/unit/states/test_win_dns_client.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import win_dns_client @@ -135,8 +132,3 @@ class WinDnsClientTestCase(TestCase): 'comment': 'Updated primary DNS suffix (a)'}) self.assertDictEqual(win_dns_client.primary_suffix('salt', 'a'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinDnsClientTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_firewall.py b/tests/unit/states/test_win_firewall.py index 8115c4410a..07159e1591 100644 --- a/tests/unit/states/test_win_firewall.py +++ b/tests/unit/states/test_win_firewall.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import win_firewall import salt.utils @@ -77,8 +74,3 @@ class WinFirewallTestCase(TestCase): ' exists', 'result': True, 'changes': {}}) self.assertDictEqual(win_firewall.add_rule('salt', 'stack'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinFirewallTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_license.py b/tests/unit/states/test_win_license.py index 88358ba606..09e067f05c 100644 --- a/tests/unit/states/test_win_license.py +++ b/tests/unit/states/test_win_license.py @@ -8,14 +8,11 @@ from salt.states import win_license as license # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch ) -ensure_in_syspath('../../') - license.__salt__ = {} @@ -170,7 +167,3 @@ class LicenseTestCase(TestCase): assert not install_mock.called activate_mock.assert_called_once_with() self.assertEqual(out, expected) - -if __name__ == '__main__': - from integration import run_tests - run_tests(LicenseTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_network.py b/tests/unit/states/test_win_network.py index 1e0115b590..aa101cae23 100644 --- a/tests/unit/states/test_win_network.py +++ b/tests/unit/states/test_win_network.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import win_network @@ -118,8 +115,3 @@ class WinNetworkTestCase(TestCase): 'cp', ip_proto='dhcp' ), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinNetworkTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_path.py b/tests/unit/states/test_win_path.py index d96b1142ef..a088cb3965 100644 --- a/tests/unit/states/test_win_path.py +++ b/tests/unit/states/test_win_path.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import win_path @@ -83,8 +80,3 @@ class WinPathTestCase(TestCase): ' PATH at the right location', 'result': True, 'changes': {}}) self.assertDictEqual(win_path.exists('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinPathTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_pki.py b/tests/unit/states/test_win_pki.py index 166582d4ee..a6dd50d82b 100644 --- a/tests/unit/states/test_win_pki.py +++ b/tests/unit/states/test_win_pki.py @@ -14,7 +14,6 @@ from salt.states import win_pki # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -22,8 +21,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Globals win_pki.__salt__ = {} win_pki.__opts__ = {} @@ -104,8 +101,3 @@ class WinPkiTestCase(TestCase): " {1}").format(kwargs['thumbprint'], STORE_PATH) ret['result'] = None self.assertEqual(win_pki.remove_cert(**kwargs), ret) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(WinPkiTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_powercfg.py b/tests/unit/states/test_win_powercfg.py index 638028f72c..6551990a07 100644 --- a/tests/unit/states/test_win_powercfg.py +++ b/tests/unit/states/test_win_powercfg.py @@ -8,7 +8,6 @@ from salt.states import win_powercfg as powercfg # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, @@ -16,8 +15,6 @@ from tests.support.mock import ( patch ) -ensure_in_syspath('../../') - powercfg.__salt__ = {} @@ -61,8 +58,3 @@ class PowerCfgTestCase(TestCase): ''' ret = {'changes': {}, 'comment': 'fakepower is not a power type', 'name': 'monitor', 'result': False} self.assertEqual(powercfg.set_timeout("monitor", 0, power="fakepower"), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PowerCfgTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_servermanager.py b/tests/unit/states/test_win_servermanager.py index c158d71c4e..ad524362ed 100644 --- a/tests/unit/states/test_win_servermanager.py +++ b/tests/unit/states/test_win_servermanager.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import win_servermanager @@ -121,8 +118,3 @@ class WinServermanagerTestCase(TestCase): 'old': 'patrick'}}}} self.assertDictEqual( win_servermanager.removed('squidward'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinServermanagerTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_snmp.py b/tests/unit/states/test_win_snmp.py index a47eb30179..0f04ef2b9c 100644 --- a/tests/unit/states/test_win_snmp.py +++ b/tests/unit/states/test_win_snmp.py @@ -15,7 +15,6 @@ import salt.ext.six as six # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -23,8 +22,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../../') - # Globals win_snmp.__salt__ = {} win_snmp.__opts__ = {} @@ -99,8 +96,3 @@ class WinSnmpTestCase(TestCase): 'win_snmp.set_community_names': mock_value_set}): with patch.dict(win_snmp.__opts__, {'test': False}): self.assertEqual(win_snmp.community_names(**kwargs), ret) - - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error - run_tests(WinSnmpTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_system.py b/tests/unit/states/test_win_system.py index 2acb60168a..6400fac1d9 100644 --- a/tests/unit/states/test_win_system.py +++ b/tests/unit/states/test_win_system.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import win_system @@ -135,8 +132,3 @@ class WinSystemTestCase(TestCase): 'result': True}) self.assertDictEqual(win_system.hostname('SALT'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinSystemTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_win_update.py b/tests/unit/states/test_win_update.py index 37c8c462cb..d37a32ba4b 100644 --- a/tests/unit/states/test_win_update.py +++ b/tests/unit/states/test_win_update.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import win_update @@ -125,8 +122,3 @@ class WinUpdateTestCase(TestCase): ret.update({'changes': True, 'result': True}) self.assertDictEqual(win_update.downloaded('salt'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinUpdateTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_winrepo.py b/tests/unit/states/test_winrepo.py index e5ecb6df31..b0dbfb89a0 100644 --- a/tests/unit/states/test_winrepo.py +++ b/tests/unit/states/test_winrepo.py @@ -5,21 +5,18 @@ # Import Python Libs from __future__ import absolute_import +import os # Import Salt Testing Libs import salt.config from salt.syspaths import BASE_FILE_ROOTS_DIR from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, NO_MOCK, NO_MOCK_REASON ) -import os - -ensure_in_syspath('../../') # Import Salt Libs from salt.states import winrepo @@ -91,8 +88,3 @@ class WinrepoTestCase(TestCase): ret.update({'changes': {'winrepo': []}}) self.assertDictEqual(winrepo.genrepo('salt', True), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WinrepoTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_xmpp.py b/tests/unit/states/test_xmpp.py index 1107c93ff4..0d0cb1a16a 100644 --- a/tests/unit/states/test_xmpp.py +++ b/tests/unit/states/test_xmpp.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import xmpp @@ -52,8 +49,3 @@ class XmppTestCase(TestCase): 'comment': 'Sent message to myaccount: salt'}) self.assertDictEqual(xmpp.send_msg('salt', 'myaccount', 'salt@saltstack.com'), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(XmppTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_zcbuildout.py b/tests/unit/states/test_zcbuildout.py index e6aca373d5..c2ae6ac78a 100644 --- a/tests/unit/states/test_zcbuildout.py +++ b/tests/unit/states/test_zcbuildout.py @@ -6,17 +6,12 @@ import os # Import Salt Testing libs from tests.support.unit import skipIf -from tests.support.helpers import ( - ensure_in_syspath, - requires_network, -) - -ensure_in_syspath('../../') -import integration +from tests.support.helpers import requires_network +import tests.integration as integration # Import Salt libs import salt.utils -from unit.modules.test_zcbuildout import Base, KNOWN_VIRTUALENV_BINARY_NAMES +from tests.unit.modules.test_zcbuildout import Base, KNOWN_VIRTUALENV_BINARY_NAMES from salt.modules import zcbuildout as modbuildout from salt.states import zcbuildout as buildout from salt.modules import cmdmod as cmd @@ -89,8 +84,3 @@ class BuildoutTestCase(Base): self.assertEqual(ret['result'], True) self.assertTrue('OUTPUT:' in ret['comment']) self.assertTrue('Log summary:' in ret['comment']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BuildoutTestCase, needs_daemon=False) diff --git a/tests/unit/states/test_zk_concurrency.py b/tests/unit/states/test_zk_concurrency.py index 8e7a35ec54..9221484e73 100644 --- a/tests/unit/states/test_zk_concurrency.py +++ b/tests/unit/states/test_zk_concurrency.py @@ -13,10 +13,6 @@ from tests.support.mock import ( MagicMock, patch) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - # Import Salt Libs from salt.states import zk_concurrency @@ -98,8 +94,3 @@ class ZkConcurrencyTestCase(TestCase): self.assertDictEqual(zk_concurrency.min_party('salt', 'dude', 2, True), ret) ret.update({'comment': 'Currently 3 nodes, which is < 4', 'result': False}) self.assertDictEqual(zk_concurrency.min_party('salt', 'dude', 4), ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ZkConcurrencyTestCase, needs_daemon=False) diff --git a/tests/unit/templates/test_jinja.py b/tests/unit/templates/test_jinja.py index d633e09325..d1360a737a 100644 --- a/tests/unit/templates/test_jinja.py +++ b/tests/unit/templates/test_jinja.py @@ -14,8 +14,7 @@ import re # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.case import ModuleCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +from tests.support.paths import TMP_CONF_DIR # Import salt libs import salt.config @@ -32,7 +31,6 @@ from salt.utils.jinja import ( ) from salt.utils.templates import JINJA, render_jinja_tmpl from salt.utils.odict import OrderedDict -from integration import TMP_CONF_DIR # Import 3rd party libs import yaml @@ -1084,9 +1082,3 @@ class TestDotNotationLookup(ModuleCase): ret = self.render(tmpl_str) self.assertEqual(ret, 'Hello, jerry.') - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestSaltCacheLoader, TestGetTemplate, TestCustomExtensions, - TestDotNotationLookup, - needs_daemon=False) diff --git a/tests/unit/test_auth.py b/tests/unit/test_auth.py index a671957e6d..67c47ca78e 100644 --- a/tests/unit/test_auth.py +++ b/tests/unit/test_auth.py @@ -8,14 +8,11 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, call, NO_MOCK, NO_MOCK_REASON, MagicMock -ensure_in_syspath('../') - # Import Salt libraries import salt.master -import integration +import tests.integration as integration from salt import auth @@ -549,8 +546,3 @@ class AuthACLTestCase(integration.ModuleCase): self.clear.publish(self.valid_clear_load) self.assertEqual(auth_check_mock.call_args[0][0], [{'beta_minion': ['test.ping']}]) - -if __name__ == '__main__': - from integration import run_tests - tests = [LoadAuthTestCase, MasterACLTestCase] - run_tests(*tests, needs_daemon=False) diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 7d4ce63c7d..b469388270 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -7,13 +7,11 @@ from __future__ import absolute_import # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../') # Import Salt libs -import integration from salt import client from salt.exceptions import EauthAuthenticationError, SaltInvocationError, SaltClientError @@ -89,8 +87,3 @@ class LocalClientTestCase(TestCase, self.assertRaises(SaltInvocationError, self.client.pub, 'non_existent_group', 'test.ping', tgt_type='nodegroup') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(LocalClientTestCase, needs_daemon=False) diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 72189579bf..6ca085ef86 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -9,14 +9,11 @@ import os # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON, ) -ensure_in_syspath('../') - # Import Salt libs import salt.config @@ -187,8 +184,3 @@ class ConfTest(TestCase): conf_file ) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ConfTest, needs_daemon=False) diff --git a/tests/unit/test_context.py b/tests/unit/test_context.py index 1b1808b357..843c4ecb8c 100644 --- a/tests/unit/test_context.py +++ b/tests/unit/test_context.py @@ -15,8 +15,6 @@ import time # Import Salt Testing libs from tests.support.unit import TestCase from salt.ext.six.moves import range -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import Salt libs from salt.utils.context import ContextDict, NamespacedDictWrapper diff --git a/tests/unit/test_crypt.py b/tests/unit/test_crypt.py index 40d879697f..52f5df4860 100644 --- a/tests/unit/test_crypt.py +++ b/tests/unit/test_crypt.py @@ -5,11 +5,8 @@ from __future__ import absolute_import # salt testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, call, mock_open, NO_MOCK, NO_MOCK_REASON, MagicMock -ensure_in_syspath('../') - # salt libs import salt.utils from salt import crypt @@ -107,8 +104,3 @@ class CryptTestCase(TestCase): def test_verify_signature(self): with patch('salt.utils.fopen', mock_open(read_data=PUBKEY_DATA)): self.assertTrue(crypt.verify_signature('/keydir/keyname.pub', MSG, SIG)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CryptTestCase, needs_daemon=False) diff --git a/tests/unit/test_daemons.py b/tests/unit/test_daemons.py index c99a963861..dc8473461d 100644 --- a/tests/unit/test_daemons.py +++ b/tests/unit/test_daemons.py @@ -8,13 +8,10 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, MagicMock, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../') - # Import Salt libs -import integration +import tests.integration as integration import multiprocessing from salt.cli import daemons @@ -248,7 +245,3 @@ class DaemonsStarterTestCase(TestCase, integration.SaltClientTestCaseMixIn): child_pipe.close() self._multiproc_exec_test(exec_test) - -if __name__ == '__main__': - from integration import run_tests - run_tests(DaemonsStarterTestCase, needs_daemon=False) diff --git a/tests/unit/test_doc.py b/tests/unit/test_doc.py index b3af08c003..336833a46c 100644 --- a/tests/unit/test_doc.py +++ b/tests/unit/test_doc.py @@ -9,12 +9,9 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') # Import Salt libs -import integration +import tests.integration as integration import salt.modules.cmdmod @@ -71,8 +68,3 @@ class DocTestCase(TestCase): # test_ret should be empty, otherwise there are :doc: references present self.assertEqual(test_ret, {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DocTestCase, needs_daemon=False) diff --git a/tests/unit/test_files.py b/tests/unit/test_files.py index d333ab56a6..d3816084d4 100644 --- a/tests/unit/test_files.py +++ b/tests/unit/test_files.py @@ -12,8 +12,6 @@ import tempfile # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import Salt libs import salt.utils diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py index 7bd4d2e174..aeef062b1c 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_log.py @@ -16,9 +16,7 @@ from salt.ext.six.moves import StringIO # Import Salt Testing libs from tests.support.case import TestCase -from tests.support.helpers import ensure_in_syspath, TestsLoggingHandler - -ensure_in_syspath('../') +from tests.support.helpers import TestsLoggingHandler # Import Salt libs from salt.log import setup as saltlog @@ -177,8 +175,3 @@ class TestLog(TestCase): finally: log.removeHandler(handler1) log.removeHandler(handler2) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestLog, needs_daemon=False) diff --git a/tests/unit/test_map_conf.py b/tests/unit/test_map_conf.py index 06854049dd..11594e4a69 100644 --- a/tests/unit/test_map_conf.py +++ b/tests/unit/test_map_conf.py @@ -8,7 +8,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON, ) -ensure_in_syspath('../') - # Import Salt libs import salt.cloud @@ -116,8 +113,3 @@ class MapConfTest(TestCase): 'user': 'root'}} } self.assertEqual(cloud_map.map_data(), merged_profile) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MapConfTest, needs_daemon=False) diff --git a/tests/unit/test_minion.py b/tests/unit/test_minion.py index f905b01f0e..113f6daa6e 100644 --- a/tests/unit/test_minion.py +++ b/tests/unit/test_minion.py @@ -10,7 +10,6 @@ import os # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock # Import salt libs @@ -20,8 +19,6 @@ from salt.exceptions import SaltSystemExit import salt.syspaths import tornado -ensure_in_syspath('../') - __opts__ = {} @@ -138,8 +135,3 @@ class MinionTestCase(TestCase): self.assertEqual(minion.jid_queue, [456, 789]) finally: minion.destroy() - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MinionTestCase, needs_daemon=False) diff --git a/tests/unit/test_payload.py b/tests/unit/test_payload.py index e222c90bf0..d41b62695f 100644 --- a/tests/unit/test_payload.py +++ b/tests/unit/test_payload.py @@ -15,9 +15,8 @@ import threading # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath, MockWraps +from tests.support.helpers import MockWraps from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -ensure_in_syspath('../') # Import salt libs import salt.payload @@ -170,9 +169,3 @@ class SREQTestCase(TestCase): # ensure no exceptions when we go to destroy the sreq, since __del__ # swallows exceptions, we have to call destroy directly sreq.destroy() - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PayloadTestCase, needs_daemon=False) - run_tests(SREQTestCase, needs_daemon=False) diff --git a/tests/unit/test_pillar.py b/tests/unit/test_pillar.py index 5dd067e5a6..18bd7f615a 100644 --- a/tests/unit/test_pillar.py +++ b/tests/unit/test_pillar.py @@ -13,9 +13,7 @@ import tempfile # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch -ensure_in_syspath('../') # Import salt libs import salt.pillar @@ -275,8 +273,3 @@ p2: }[sls] client.get_state.side_effect = get_state - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PillarTestCase, needs_daemon=False) diff --git a/tests/unit/test_pydsl.py b/tests/unit/test_pydsl.py index 6a09a7577c..50b865babc 100644 --- a/tests/unit/test_pydsl.py +++ b/tests/unit/test_pydsl.py @@ -11,12 +11,9 @@ import copy # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') # Import Salt libs -import integration +import tests.integration as integration import salt.loader import salt.config import salt.utils @@ -457,9 +454,3 @@ class PyDSLRendererTestCase(CommonTestCaseBoilerplate): def write_to(fpath, content): with salt.utils.fopen(fpath, 'w') as f: f.write(content) - - -if __name__ == '__main__': - from integration import run_tests - tests = [PyDSLRendererTestCase] - run_tests(*tests, needs_daemon=False) diff --git a/tests/unit/test_pyobjects.py b/tests/unit/test_pyobjects.py index a4283ecc2f..f8d37c486c 100644 --- a/tests/unit/test_pyobjects.py +++ b/tests/unit/test_pyobjects.py @@ -9,12 +9,9 @@ import uuid # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') # Import Salt libs -import integration +import tests.integration as integration import salt.config import salt.state import salt.utils @@ -448,8 +445,3 @@ class SaltObjectTests(TestCase): self.assertRaises(AttributeError, attr_fail) self.assertEqual(Salt.math.times2, times2) self.assertEqual(Salt.math.times2(2), 4) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StateTests, RendererTests, MapTests, SaltObjectTests, needs_daemon=False) diff --git a/tests/unit/test_simple.py b/tests/unit/test_simple.py index 2fb8451d67..58a53cee3f 100644 --- a/tests/unit/test_simple.py +++ b/tests/unit/test_simple.py @@ -5,9 +5,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, expectedFailure -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') class SimpleTest(TestCase): @@ -17,7 +14,3 @@ class SimpleTest(TestCase): @expectedFailure def test_fail(self): assert False - -if __name__ == '__main__': - from integration import run_tests - run_tests(SimpleTest, needs_daemon=False) diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index 2f8a9190a4..294e62025e 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -8,14 +8,11 @@ import tempfile # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import destructiveTest import salt.config import salt.spm -ensure_in_syspath('../') - - _TMP_SPM = tempfile.mkdtemp() config = salt.config.minion_config(None) @@ -173,8 +170,3 @@ class SPMTest(TestCase): self.ui._error = [] self.client.run(args) assert len(self.ui._error) > 0 - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SPMTest, needs_daemon=False) diff --git a/tests/unit/test_state.py b/tests/unit/test_state.py index 6d0c0d1751..b6c9a92cab 100644 --- a/tests/unit/test_state.py +++ b/tests/unit/test_state.py @@ -11,13 +11,10 @@ import sys import tempfile # Import Salt Testing libs -import integration +import tests.integration as integration from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -ensure_in_syspath('../') - # Import Salt libs import salt.state import salt.config @@ -468,8 +465,3 @@ class TopFileMergeTestCase(TestCase): expected_merge = DefaultOrderedDict(OrderedDict) self.assertEqual(merged_tops, expected_merge) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StateCompilerTestCase, needs_daemon=False) diff --git a/tests/unit/test_stateconf.py b/tests/unit/test_stateconf.py index 2d8fa96d4c..6f739e3231 100644 --- a/tests/unit/test_stateconf.py +++ b/tests/unit/test_stateconf.py @@ -8,14 +8,11 @@ import tempfile # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') # Import Salt libs import salt.loader import salt.config -import integration +import tests.integration as integration from salt.exceptions import SaltRenderError from salt.ext.six.moves import StringIO @@ -337,8 +334,3 @@ formula/woot.sls: r = result['formula/woot.sls']['cmd.run'][0]['name'] self.assertEqual(r, 'echo formula/woot') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StateConfigRendererTestCase, needs_daemon=False) diff --git a/tests/unit/test_statemod.py b/tests/unit/test_statemod.py index 4e1d985885..9b6767595b 100644 --- a/tests/unit/test_statemod.py +++ b/tests/unit/test_statemod.py @@ -10,13 +10,10 @@ import os.path # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -ensure_in_syspath('../') - # Import Salt libs -import integration +import tests.integration as integration from salt.states import saltmod @@ -67,8 +64,3 @@ class StatemodTests(TestCase): 'result': True } self.assertEqual(ret, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(StatemodTests, needs_daemon=False) diff --git a/tests/unit/test_template.py b/tests/unit/test_template.py index 5585de0e8a..fb09c96341 100644 --- a/tests/unit/test_template.py +++ b/tests/unit/test_template.py @@ -8,9 +8,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') # Import Salt libs from salt import template @@ -50,7 +47,3 @@ class TemplateTestCase(TestCase): self.assertListEqual([], ret) ret = template.check_render_pipe_str('jinja|json', self.render_dict, ['jinja'], ['jinja', 'json']) self.assertListEqual([('fake_json_func', '')], ret) - -if __name__ == '__main__': - from integration import run_tests - run_tests(TemplateTestCase, needs_daemon=False) diff --git a/tests/unit/test_test_module_names.py b/tests/unit/test_test_module_names.py index a7c632963a..c13884b3de 100644 --- a/tests/unit/test_test_module_names.py +++ b/tests/unit/test_test_module_names.py @@ -13,7 +13,7 @@ from tests.support.unit import TestCase # Import Salt libs -import integration +import tests.integration as integration EXCLUDED_DIRS = [ 'tests/pkg', diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py index b70b503ea2..89c0886ee1 100644 --- a/tests/unit/test_version.py +++ b/tests/unit/test_version.py @@ -15,9 +15,6 @@ import re # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../') # Import Salt libs from salt.version import SaltStackVersion @@ -74,8 +71,3 @@ class VersionTestCase(TestCase): with self.assertRaises(ValueError): SaltStackVersion.parse('Drunk') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VersionTestCase, needs_daemon=False) diff --git a/tests/unit/transport/test_ipc.py b/tests/unit/transport/test_ipc.py index 7ae724ec4b..d188b1912a 100644 --- a/tests/unit/transport/test_ipc.py +++ b/tests/unit/transport/test_ipc.py @@ -23,14 +23,11 @@ import salt.ext.six as six from salt.ext.six.moves import range # Import Salt Testing libs -import integration +import tests.integration as integration from tests.support.mock import MagicMock -from tests.support.helpers import ensure_in_syspath log = logging.getLogger(__name__) -ensure_in_syspath('../') - class BaseIPCReqCase(tornado.testing.AsyncTestCase): ''' @@ -139,8 +136,3 @@ class IPCMessageClient(BaseIPCReqCase): self.channel.send({'stop': True}) self.wait() self.assertEqual(self.payloads[:-1], [None, None, 'foo', 'foo']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(IPCMessageClient, needs_daemon=False) diff --git a/tests/unit/transport/test_tcp.py b/tests/unit/transport/test_tcp.py index 2baf7cc173..66e31923e1 100644 --- a/tests/unit/transport/test_tcp.py +++ b/tests/unit/transport/test_tcp.py @@ -21,13 +21,11 @@ import salt.exceptions # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../') -import integration +import tests.integration as integration # Import Salt libs -from unit.transport.test_req import ReqChannelMixin -from unit.transport.test_pub import PubChannelMixin +from tests.unit.transport.test_req import ReqChannelMixin +from tests.unit.transport.test_pub import PubChannelMixin # TODO: move to a library? @@ -198,8 +196,3 @@ class AsyncPubChannelTest(BaseTCPPubCase, PubChannelMixin): ''' Tests around the publish system ''' - -if __name__ == '__main__': - from integration import run_tests - run_tests(ClearReqTestCases, needs_daemon=False) - run_tests(AESReqTestCases, needs_daemon=False) diff --git a/tests/unit/utils/test_aggregation.py b/tests/unit/utils/test_aggregation.py index 0c7104a72e..a97b56e7ab 100644 --- a/tests/unit/utils/test_aggregation.py +++ b/tests/unit/utils/test_aggregation.py @@ -5,8 +5,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils.aggregation import aggregate, Map, Scalar @@ -139,8 +137,3 @@ class TestAggregation(TestCase): 'another': 'value' } }, result - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestAggregation, needs_daemon=False) diff --git a/tests/unit/utils/test_args.py b/tests/unit/utils/test_args.py index eda348ef28..928a9f60cd 100644 --- a/tests/unit/utils/test_args.py +++ b/tests/unit/utils/test_args.py @@ -9,9 +9,6 @@ from salt.utils import args # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -26,8 +23,3 @@ class ArgsTestCase(TestCase): ''' cmd = args.condition_input(['*', 'foo.bar', 20141020201325675584], None) self.assertIsInstance(cmd[2], str) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ArgsTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_boto.py b/tests/unit/utils/test_boto.py index b4ec3f4b69..6c7d842c36 100644 --- a/tests/unit/utils/test_boto.py +++ b/tests/unit/utils/test_boto.py @@ -7,8 +7,6 @@ from distutils.version import LooseVersion # pylint: disable=import-error,no-na # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import Salt libs from salt.exceptions import SaltInvocationError @@ -271,8 +269,3 @@ class BotoBoto3CacheContextCollisionTest(BotoUtilsTestCaseBase): # These should *not* be the same object! self.assertNotEqual(id(boto_ec2_conn), id(boto3_ec2_conn)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(BotoUtilsGetConnTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_cache.py b/tests/unit/utils/test_cache.py index 288ebb57b7..88b9d07ac9 100644 --- a/tests/unit/utils/test_cache.py +++ b/tests/unit/utils/test_cache.py @@ -15,8 +15,6 @@ import shutil # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs import salt.config @@ -95,8 +93,3 @@ class CacheContextTestCase(TestCase): self.assertEqual(cache_test_func()['called'], 0) self.assertEqual(cache_test_func()['called'], 1) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CacheDictTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_cloud.py b/tests/unit/utils/test_cloud.py index b0e517093d..f8cb0217f7 100644 --- a/tests/unit/utils/test_cloud.py +++ b/tests/unit/utils/test_cloud.py @@ -16,12 +16,10 @@ import tempfile # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') +from tests.support.paths import TMP, CODE_DIR # Import salt libs from salt.utils import cloud -from integration import TMP, CODE_DIR GPG_KEYDIR = os.path.join(TMP, 'gpg-keydir') @@ -138,7 +136,3 @@ class CloudUtilsTestCase(TestCase): # tmp file removed self.assertFalse(cloud.check_key_path_and_mode('foo', key_file)) - -if __name__ == '__main__': - from integration import run_tests - run_tests(CloudUtilsTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_configcomparer.py b/tests/unit/utils/test_configcomparer.py index 9ec5136446..2cc17e38d2 100644 --- a/tests/unit/utils/test_configcomparer.py +++ b/tests/unit/utils/test_configcomparer.py @@ -6,9 +6,6 @@ import copy # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs from salt.utils import configcomparer @@ -314,8 +311,3 @@ class UtilConfigcomparerTestCase(TestCase): }, to_update, ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UtilConfigcomparerTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_decorators.py b/tests/unit/utils/test_decorators.py index f5eead3fac..09cc375f4b 100644 --- a/tests/unit/utils/test_decorators.py +++ b/tests/unit/utils/test_decorators.py @@ -9,13 +9,10 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from salt.utils import decorators from salt.version import SaltStackVersion from salt.exceptions import CommandExecutionError -ensure_in_syspath('../../') - class DummyLogger(object): ''' @@ -225,8 +222,3 @@ class DecoratorsTest(TestCase): 'an alias "old_function" is configured as its deprecated version. ' 'The lifetime of the function "old_function" expired. ' 'Please use its successor "new_function" instead.']) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(DecoratorsTest, needs_daemon=False) diff --git a/tests/unit/utils/test_dictupdate.py b/tests/unit/utils/test_dictupdate.py index 5893d514f4..be138f5b4c 100644 --- a/tests/unit/utils/test_dictupdate.py +++ b/tests/unit/utils/test_dictupdate.py @@ -6,9 +6,6 @@ import copy # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs from salt.utils import dictupdate @@ -173,8 +170,3 @@ class UtilDictMergeTestCase(TestCase): mdict1['A'] = ['B'] ret = dictupdate.merge_list(mdict1, {'A': ['b', 'c']}) self.assertEqual({'A': [['B'], ['b', 'c']], 'C': {'D': 'E', 'F': {'I': 'J', 'G': 'H'}}}, ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UtilDictupdateTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_disk_cache.py b/tests/unit/utils/test_disk_cache.py index 6be7b32031..2d37afc98b 100644 --- a/tests/unit/utils/test_disk_cache.py +++ b/tests/unit/utils/test_disk_cache.py @@ -15,8 +15,6 @@ import time # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils import cache @@ -57,8 +55,3 @@ class CacheDiskTestCase(TestCase): finally: shutil.rmtree(tmpdir, ignore_errors=True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(CacheDiskTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_etcd_util.py b/tests/unit/utils/test_etcd_util.py index 5320a339c2..7b2680d09c 100644 --- a/tests/unit/utils/test_etcd_util.py +++ b/tests/unit/utils/test_etcd_util.py @@ -14,9 +14,6 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.utils import etcd_util @@ -339,8 +336,3 @@ class EtcdUtilTestCase(TestCase): mock.return_value = None self.assertEqual(client.watch('/some-key'), {}) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(EtcdUtilTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_event.py b/tests/unit/utils/test_event.py index ce381c47ba..c65b397d27 100644 --- a/tests/unit/utils/test_event.py +++ b/tests/unit/utils/test_event.py @@ -25,7 +25,7 @@ from multiprocessing import Process from tests.support.unit import expectedFailure, skipIf, TestCase # Import salt libs -import integration +import tests.integration as integration from salt.utils.process import clean_proc from salt.utils import event, to_bytes diff --git a/tests/unit/utils/test_extend.py b/tests/unit/utils/test_extend.py index 28f9a88d86..308876fda6 100644 --- a/tests/unit/utils/test_extend.py +++ b/tests/unit/utils/test_extend.py @@ -15,14 +15,11 @@ from datetime import date # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch -ensure_in_syspath('../../') - # Import salt libs import salt.utils.extend -import integration +import tests.integration as integration import salt.utils @@ -49,7 +46,3 @@ class ExtendTestCase(TestCase): self.assertTrue(os.path.exists(os.path.join(out, 'directory', 'test.py'))) with salt.utils.fopen(os.path.join(out, 'directory', 'test.py'), 'r') as test_f: self.assertEqual(test_f.read(), year) - -if __name__ == '__main__': - from unit import run_tests - run_tests(ExtendTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_filebuffer.py b/tests/unit/utils/test_filebuffer.py index e5f81a2bfd..9eb5ad9228 100644 --- a/tests/unit/utils/test_filebuffer.py +++ b/tests/unit/utils/test_filebuffer.py @@ -12,8 +12,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils.filebuffer import BufferedReader, InvalidFileMode @@ -32,8 +30,3 @@ class TestFileBuffer(TestCase): with self.assertRaises(InvalidFileMode): BufferedReader('/tmp/foo', mode='wb') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestFileBuffer, needs_daemon=False) diff --git a/tests/unit/utils/test_find.py b/tests/unit/utils/test_find.py index 08e21babec..4dd53d5d54 100644 --- a/tests/unit/utils/test_find.py +++ b/tests/unit/utils/test_find.py @@ -10,11 +10,9 @@ import stat # Import Salt Testing libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration +import tests.integration as integration import salt.ext.six as six import salt.utils import salt.utils.find @@ -593,11 +591,3 @@ class TestFinder(TestCase): finder = salt.utils.find.Finder({'name': 'test_name'}) self.assertEqual(list(finder.find('')), []) - - -if __name__ == '__main__': - from integration import run_tests - run_tests( - [TestFind, TestGrepOption, TestPrintOption, TestFinder], - needs_daemon=False - ) diff --git a/tests/unit/utils/test_format_call.py b/tests/unit/utils/test_format_call.py index 28bff8f6cd..073066caeb 100644 --- a/tests/unit/utils/test_format_call.py +++ b/tests/unit/utils/test_format_call.py @@ -14,8 +14,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils import format_call @@ -56,8 +54,3 @@ class TestFormatCall(TestCase): TypeError, r'foo2 takes at least 2 arguments \(1 given\)'): format_call(foo2, dict(one=1)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestFormatCall, needs_daemon=False) diff --git a/tests/unit/utils/test_gitfs.py b/tests/unit/utils/test_gitfs.py index a5f9799864..c8942e4695 100644 --- a/tests/unit/utils/test_gitfs.py +++ b/tests/unit/utils/test_gitfs.py @@ -10,8 +10,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs import salt.utils.gitfs @@ -90,8 +88,3 @@ class TestGitFSProvider(TestCase): role_class, *args ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestGitFSProvider, needs_daemon=False) diff --git a/tests/unit/utils/test_http.py b/tests/unit/utils/test_http.py index 014e3c77b0..993e7975e8 100644 --- a/tests/unit/utils/test_http.py +++ b/tests/unit/utils/test_http.py @@ -9,9 +9,6 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.utils import http @@ -93,8 +90,3 @@ class HTTPTestCase(TestCase): mock_ret = 'foo=XXXXXXXXXX&foo=XXXXXXXXXX&api_key=testing&' ret = http._sanitize_url_components(mock_component_list, 'foo') self.assertEqual(ret, mock_ret) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(HTTPTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_immutabletypes.py b/tests/unit/utils/test_immutabletypes.py index 76ecf43c71..4626866b13 100644 --- a/tests/unit/utils/test_immutabletypes.py +++ b/tests/unit/utils/test_immutabletypes.py @@ -14,8 +14,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils import immutabletypes @@ -83,8 +81,3 @@ class ImmutableTypesTestCase(TestCase): with self.assertRaises(TypeError): flist = frozen[4] flist[0] = 5 - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ImmutableTypesTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_kwarg_regex.py b/tests/unit/utils/test_kwarg_regex.py index b87b05a385..5b2ba201a3 100644 --- a/tests/unit/utils/test_kwarg_regex.py +++ b/tests/unit/utils/test_kwarg_regex.py @@ -12,9 +12,6 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt libs from salt.utils.args import KWARG_REGEX @@ -34,8 +31,3 @@ class KwargRegexTest(TestCase): self.assertEqual( KWARG_REGEX.match(argument).groups(), match ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(KwargRegexTest, needs_daemon=False) diff --git a/tests/unit/utils/test_locales.py b/tests/unit/utils/test_locales.py index 77d0e00edb..45232544ce 100644 --- a/tests/unit/utils/test_locales.py +++ b/tests/unit/utils/test_locales.py @@ -5,11 +5,9 @@ from __future__ import absolute_import # salt testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON # salt libs -ensure_in_syspath('../../') import salt.ext.six as six from salt.ext.six.moves import reload_module from salt.utils import locales @@ -64,8 +62,3 @@ class TestLocales(TestCase): self.assertEqual( locales.normalize_locale('ca_es.UTF-8@valencia utf-8'), 'ca_ES.utf8@valencia') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestLocales, needs_daemon=False) diff --git a/tests/unit/utils/test_mac_utils.py b/tests/unit/utils/test_mac_utils.py index 597ca9d871..3b7bc32d33 100644 --- a/tests/unit/utils/test_mac_utils.py +++ b/tests/unit/utils/test_mac_utils.py @@ -8,12 +8,9 @@ from __future__ import absolute_import # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON from salt.ext.six.moves import range -ensure_in_syspath('../../') - # Import Salt Libs from salt.utils import mac_utils from salt.exceptions import SaltInvocationError, CommandExecutionError @@ -166,8 +163,3 @@ class MacUtilsTestCase(TestCase): ''' self.assertEqual(mac_utils.validate_enabled(False), 'off') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MacUtilsTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_minions.py b/tests/unit/utils/test_minions.py index 4360e551cc..3a025960cc 100644 --- a/tests/unit/utils/test_minions.py +++ b/tests/unit/utils/test_minions.py @@ -8,9 +8,6 @@ from salt.utils import minions # Import Salt Testing Libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') NODEGROUPS = { 'group1': 'L@host1,host2,host3', @@ -39,8 +36,3 @@ class MinionsTestCase(TestCase): expected = EXPECTED[nodegroup] ret = minions.nodegroup_comp(nodegroup, NODEGROUPS) self.assertEqual(ret, expected) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(MinionsTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_network.py b/tests/unit/utils/test_network.py index 1f7ad1b040..df6adff5e4 100644 --- a/tests/unit/utils/test_network.py +++ b/tests/unit/utils/test_network.py @@ -5,9 +5,7 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import skipIf from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock -ensure_in_syspath('../../') # Import salt libs from salt.utils import network @@ -386,8 +384,3 @@ class NetworkTestCase(TestCase): :return: ''' self.assertEqual(network.generate_minion_id(), '1.2.3.4') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(NetworkTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_parsers.py b/tests/unit/utils/test_parsers.py index af592c357d..fb56294dec 100644 --- a/tests/unit/utils/test_parsers.py +++ b/tests/unit/utils/test_parsers.py @@ -9,7 +9,7 @@ import os # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase -from tests.support.helpers import ensure_in_syspath, destructiveTest +from tests.support.helpers import destructiveTest from tests.support.mock import ( MagicMock, patch, @@ -23,8 +23,6 @@ import salt.log.setup as log import salt.config import salt.syspaths -ensure_in_syspath('../../') - class ErrorMock(object): # pylint: disable=too-few-public-methods ''' @@ -933,20 +931,3 @@ class SaltAPIParserTestCase(LogSettingsParserTests): # Hide the class from unittest framework when it searches for TestCase classes in the module del LogSettingsParserTests - -if __name__ == '__main__': - from integration import run_tests # pylint: disable=import-error,wrong-import-position - run_tests(MasterOptionParserTestCase, - MinionOptionParserTestCase, - ProxyMinionOptionParserTestCase, - SyndicOptionParserTestCase, - SaltCMDOptionParserTestCase, - SaltCPOptionParserTestCase, - SaltKeyOptionParserTestCase, - SaltCallOptionParserTestCase, - SaltRunOptionParserTestCase, - SaltSSHOptionParserTestCase, - SaltCloudParserTestCase, - SPMParserTestCase, - SaltAPIParserTestCase, - needs_daemon=False) diff --git a/tests/unit/utils/test_path_join.py b/tests/unit/utils/test_path_join.py index 80286486fb..8f5a060a39 100644 --- a/tests/unit/utils/test_path_join.py +++ b/tests/unit/utils/test_path_join.py @@ -19,8 +19,6 @@ import tempfile # Import Salt Testing libs import salt.utils from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils import path_join @@ -139,8 +137,3 @@ class PathJoinTestCase(TestCase): for module in (posixpath, os, os.path, tempfile, platform): reload(module) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(PathJoinTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_process.py b/tests/unit/utils/test_process.py index 44776bbc69..72215cd98a 100644 --- a/tests/unit/utils/test_process.py +++ b/tests/unit/utils/test_process.py @@ -10,8 +10,6 @@ import multiprocessing # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs import salt.utils @@ -164,11 +162,3 @@ class TestThreadPool(TestCase): self.assertEqual(counter.value, 0) # make sure the queue is still full self.assertEqual(pool._job_queue.qsize(), 1) - - -if __name__ == '__main__': - from integration import run_tests - run_tests( - [TestProcessManager, TestThreadPool], - needs_daemon=False - ) diff --git a/tests/unit/utils/test_rsax931.py b/tests/unit/utils/test_rsax931.py index aca7a27cb5..2544bbe174 100644 --- a/tests/unit/utils/test_rsax931.py +++ b/tests/unit/utils/test_rsax931.py @@ -8,9 +8,6 @@ from __future__ import absolute_import # salt testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # salt libs from salt.utils.rsax931 import RSAX931Signer, RSAX931Verifier @@ -108,8 +105,3 @@ class RSAX931Test(TestCase): msg = verifier.verify(RSAX931Test.hello_world_sig) self.assertEqual(RSAX931Test.hello_world, msg) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(RSAX931Test, needs_daemon=False) diff --git a/tests/unit/utils/test_runtime_whitespace_regex.py b/tests/unit/utils/test_runtime_whitespace_regex.py index 83684c9227..d582ab744e 100644 --- a/tests/unit/utils/test_runtime_whitespace_regex.py +++ b/tests/unit/utils/test_runtime_whitespace_regex.py @@ -13,8 +13,6 @@ import re # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils import build_whitespace_split_regex @@ -101,8 +99,3 @@ class TestRuntimeWhitespaceRegex(TestCase): def test_issue_2227(self): regex = build_whitespace_split_regex(SINGLE_DOUBLE_SAME_LINE_TXT) self.assertTrue(re.search(regex, MATCH)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestRuntimeWhitespaceRegex, needs_daemon=False) diff --git a/tests/unit/utils/test_safe_walk.py b/tests/unit/utils/test_safe_walk.py index 76105e65a2..08877a85a1 100644 --- a/tests/unit/utils/test_safe_walk.py +++ b/tests/unit/utils/test_safe_walk.py @@ -9,11 +9,9 @@ from tempfile import mkdtemp # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs -import integration +import tests.integration as integration import salt.utils import salt.utils.find @@ -47,8 +45,3 @@ class TestUtils(TestCase): ) finally: rmtree(tmp) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestUtils, needs_daemon=False) diff --git a/tests/unit/utils/test_sanitizers.py b/tests/unit/utils/test_sanitizers.py index c53600017b..abc790d2f7 100644 --- a/tests/unit/utils/test_sanitizers.py +++ b/tests/unit/utils/test_sanitizers.py @@ -10,9 +10,6 @@ from salt.utils.sanitizers import clean # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -50,8 +47,3 @@ class SanitizersTestCase(TestCase): assert response == 'somedubioushostname' test_sanitized_id = test_sanitized_hostname - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SanitizersTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_schedule.py b/tests/unit/utils/test_schedule.py index 0cbaa577cc..0a4a965e96 100644 --- a/tests/unit/utils/test_schedule.py +++ b/tests/unit/utils/test_schedule.py @@ -11,11 +11,7 @@ import copy # Import Salt Testing Libs from tests.support.unit import skipIf, TestCase from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') - -import integration +import tests.integration as integration # Import Salt Libs import salt.config @@ -263,8 +259,3 @@ class ScheduleTestCase(TestCase): ''' self.schedule.opts.update({'schedule': ''}) self.assertRaises(ValueError, Schedule.eval, self.schedule) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ScheduleTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_schema.py b/tests/unit/utils/test_schema.py index eee89720a6..e4c67b6774 100644 --- a/tests/unit/utils/test_schema.py +++ b/tests/unit/utils/test_schema.py @@ -13,9 +13,6 @@ from distutils.version import LooseVersion as _LooseVersion # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') # Import Salt Libs from salt.utils import schema @@ -2328,9 +2325,3 @@ class ComplexSchemaTestCase(TestCase): serialized) self.assertIn('\'hungry\' is a required property', excinfo.exception.message) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ConfigTestCase, needs_daemon=False) - run_tests(ComplexSchemaTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_systemd.py b/tests/unit/utils/test_systemd.py index d32c403f88..b444ea2d48 100644 --- a/tests/unit/utils/test_systemd.py +++ b/tests/unit/utils/test_systemd.py @@ -280,8 +280,3 @@ class SystemdTestCase(TestCase): # Test with invalid context data with self.assertRaises(SaltInvocationError): _systemd.has_scope(99999) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(SystemdTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_url.py b/tests/unit/utils/test_url.py index 8bb6e8ac1a..5705e588da 100644 --- a/tests/unit/utils/test_url.py +++ b/tests/unit/utils/test_url.py @@ -8,7 +8,6 @@ import salt.utils.url # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( MagicMock, patch, @@ -16,8 +15,6 @@ from tests.support.mock import ( NO_MOCK_REASON ) -ensure_in_syspath('../../') - @patch('salt.utils.is_windows', MagicMock(return_value=False)) @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -376,8 +373,3 @@ class UrlTestCase(TestCase): non_auth_output, salt.utils.url.redact_http_basic_auth(non_auth_output) ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UrlTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 372b4bccc2..df68422e2e 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -8,14 +8,12 @@ from __future__ import absolute_import # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import ( patch, DEFAULT, create_autospec, NO_MOCK, NO_MOCK_REASON ) -ensure_in_syspath('../../') # Import Salt libs from salt.utils import args @@ -811,8 +809,3 @@ class UtilsTestCase(TestCase): ut = '\xe4\xb8\xad\xe5\x9b\xbd\xe8\xaa\x9e (\xe7\xb9\x81\xe4\xbd\x93)' un = u'\u4e2d\u56fd\u8a9e (\u7e41\u4f53)' self.assertEqual(utils.to_unicode(ut, 'utf-8'), un) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(UtilsTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_validate_net.py b/tests/unit/utils/test_validate_net.py index e019b7b848..c370b6e00d 100644 --- a/tests/unit/utils/test_validate_net.py +++ b/tests/unit/utils/test_validate_net.py @@ -9,9 +9,6 @@ from salt.utils.validate import net # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf from tests.support.mock import NO_MOCK, NO_MOCK_REASON -from tests.support.helpers import ensure_in_syspath - -ensure_in_syspath('../../') @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -72,8 +69,3 @@ class ValidateNetTestCase(TestCase): for addr in false_addrs: self.assertFalse(net.ipv6_addr(addr)) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(ValidateNetTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_verify.py b/tests/unit/utils/test_verify.py index d8b80b4e60..52bab189ec 100644 --- a/tests/unit/utils/test_verify.py +++ b/tests/unit/utils/test_verify.py @@ -17,7 +17,6 @@ import socket # Import Salt Testing libs from tests.support.unit import skipIf, TestCase from tests.support.helpers import ( - ensure_in_syspath, requires_network, TestsLoggingHandler ) @@ -27,11 +26,10 @@ from tests.support.mock import ( NO_MOCK, NO_MOCK_REASON ) -ensure_in_syspath('../../') # Import salt libs import salt.utils -import integration +import tests.integration as integration from salt.utils.verify import ( check_user, verify_env, @@ -248,8 +246,3 @@ class TestVerify(TestCase): with patch.object(log, 'warning', mock_info): verify_log({'log_level': 'info'}) self.assertTrue(mock_info.call_count == 0) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestVerify, needs_daemon=False) diff --git a/tests/unit/utils/test_vt.py b/tests/unit/utils/test_vt.py index c753ab12f5..7ba4282a19 100644 --- a/tests/unit/utils/test_vt.py +++ b/tests/unit/utils/test_vt.py @@ -19,8 +19,6 @@ import time # Import Salt Testing libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs import salt.utils @@ -213,8 +211,3 @@ class VTTestCase(TestCase): self.assertIsNone(stdout) finally: term.close(terminate=True, kill=True) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(VTTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_warnings.py b/tests/unit/utils/test_warnings.py index 533c84c889..0db74caa82 100644 --- a/tests/unit/utils/test_warnings.py +++ b/tests/unit/utils/test_warnings.py @@ -16,8 +16,6 @@ import warnings # Import Salt Testing libs from tests.support.unit import TestCase -from tests.support.helpers import ensure_in_syspath -ensure_in_syspath('../../') # Import salt libs from salt.utils import warn_until, kwargs_warn_until @@ -165,8 +163,3 @@ class WarnUntilTestCase(TestCase): r'0.17.0 is released. Current version is now 0.17.0. ' r'Please remove the warning.'): raise_warning(bar='baz', qux='quux', _version_info_=(0, 17)) # some kwargs - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WarnUntilTestCase, needs_daemon=False) diff --git a/tests/unit/utils/test_which.py b/tests/unit/utils/test_which.py index 31cc1ac38f..952b3641a5 100644 --- a/tests/unit/utils/test_which.py +++ b/tests/unit/utils/test_which.py @@ -5,13 +5,11 @@ from __future__ import absolute_import import os # Import Salt Testing libs +import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch -ensure_in_syspath('../../') # Import salt libs -import integration import salt.utils @@ -118,8 +116,3 @@ class TestWhich(integration.TestCase): # The returned path should return the .exe suffix '/bin/this-binary-exists-under-windows.CMD' ) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(TestWhich, needs_daemon=False) diff --git a/tests/unit/utils/test_yamlloader.py b/tests/unit/utils/test_yamlloader.py index 9386d23b9e..69a2724f5d 100644 --- a/tests/unit/utils/test_yamlloader.py +++ b/tests/unit/utils/test_yamlloader.py @@ -13,13 +13,9 @@ import salt.utils # Import Salt Testing Libs from tests.support.unit import TestCase, skipIf -from tests.support.helpers import ensure_in_syspath from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON, mock_open -ensure_in_syspath('../../') - - @skipIf(NO_MOCK, NO_MOCK_REASON) class YamlLoaderTestCase(TestCase): ''' @@ -105,8 +101,3 @@ p2: <<: *p1 v2: beta v2: betabeta''') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(YamlLoaderTestCase, needs_daemon=False) diff --git a/tests/unit/utils/vmware_test/test_cluster.py b/tests/unit/utils/vmware_test/test_cluster.py index c4584379ed..205c4f077b 100644 --- a/tests/unit/utils/vmware_test/test_cluster.py +++ b/tests/unit/utils/vmware_test/test_cluster.py @@ -240,10 +240,3 @@ class UpdateClusterTestCase(TestCase): self.mock_cluster_spec) mock_wait_for_task.assert_called_once_with( self.mock_task, 'fake_cluster', 'ClusterUpdateTask') - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GetClusterTestCase, needs_daemon=False) - run_tests(CreateClusterTestCase, needs_daemon=False) - run_tests(UpdateClusterTestCase, needs_daemon=False) diff --git a/tests/unit/utils/vmware_test/test_common.py b/tests/unit/utils/vmware_test/test_common.py index 7acc92a41b..157fe69b5e 100644 --- a/tests/unit/utils/vmware_test/test_common.py +++ b/tests/unit/utils/vmware_test/test_common.py @@ -789,13 +789,3 @@ class GetRootFolderTestCase(TestCase): def test_return(self): ret = salt.utils.vmware.get_root_folder(self.mock_si) self.assertEqual(ret, self.mock_root_folder) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(WaitForTaskTestCase, needs_daemon=False) - run_tests(GetMorsWithPropertiesTestCase, needs_daemon=False) - run_tests(GetPropertiesOfManagedObjectTestCase, needs_daemon=False) - run_tests(GetManagedObjectName, needs_daemon=False) - run_tests(GetContentTestCase, needs_daemon=False) - run_tests(GetRootFolderTestCase, needs_daemon=False) diff --git a/tests/unit/utils/vmware_test/test_connection.py b/tests/unit/utils/vmware_test/test_connection.py index b18be0fb85..bb003930cd 100644 --- a/tests/unit/utils/vmware_test/test_connection.py +++ b/tests/unit/utils/vmware_test/test_connection.py @@ -826,12 +826,3 @@ class GetServiceInstanceFromManagedObjectTestCase(TestCase): self.mock_mo_ref) self.assertEqual(ret, self.mock_si) self.assertEqual(ret._stub, self.mock_stub) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GssapiTokenTest, needs_daemon=False) - run_tests(PrivateGetServiceInstanceTestCase, needs_daemon=False) - run_tests(GetServiceInstanceTestCase, needs_daemon=False) - run_tests(IsConnectionToAVCenterTestCase, needs_daemon=False) - run_tests(GetServiceInstanceFromManagedObjectTestCase, needs_daemon=False) diff --git a/tests/unit/utils/vmware_test/test_datacenter.py b/tests/unit/utils/vmware_test/test_datacenter.py index b3f09d1c7f..abd675ba5a 100644 --- a/tests/unit/utils/vmware_test/test_datacenter.py +++ b/tests/unit/utils/vmware_test/test_datacenter.py @@ -174,8 +174,3 @@ class CreateDatacenterTestCase(TestCase): MagicMock(return_value=self.mock_root_folder)): res = vmware.create_datacenter(self.mock_si, 'fake_dc') self.assertEqual(res, self.mock_dc) - -if __name__ == '__main__': - from integration import run_tests - run_tests(GetDatacenterTestCase, needs_daemon=False) - run_tests(CreateDatacenterTestCase, needs_daemon=False) diff --git a/tests/unit/utils/vmware_test/test_host.py b/tests/unit/utils/vmware_test/test_host.py index b4042adf50..6f0276d849 100644 --- a/tests/unit/utils/vmware_test/test_host.py +++ b/tests/unit/utils/vmware_test/test_host.py @@ -150,8 +150,3 @@ class GetHostsTestCase(TestCase): MagicMock(return_value=[self.mock_prop_host1])): res = salt.utils.vmware.get_hosts(self.mock_si, get_all_hosts=True) self.assertEqual(res, [self.mock_host1]) - - -if __name__ == '__main__': - from integration import run_tests - run_tests(GetHostsTestCase, needs_daemon=False) From ab83cced63dbe891af223dda6edc351eb32e0a2e Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 27 Feb 2017 19:42:43 +0000 Subject: [PATCH 281/370] Child processes termination cleanup --- tests/runtests.py | 9 --------- tests/support/helpers.py | 5 ++++- tests/support/parser/__init__.py | 27 ++++++++++++++++++--------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/tests/runtests.py b/tests/runtests.py index ddf8104941..dfad3049f7 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -51,7 +51,6 @@ except ImportError as exc: except ImportError: print('Unable to import salt test module') print('PYTHONPATH:', os.environ.get('PYTHONPATH')) - pass print('Current sys.path:') import pprint pprint.pprint(sys.path) @@ -67,9 +66,6 @@ if not salt.utils.is_windows(): from tests.support.parser import PNUM, print_header from tests.support.parser.cover import SaltCoverageTestingParser -# Import test support libs -from tests.support.processes import collect_child_processes, terminate_process - XML_OUTPUT_DIR = os.environ.get( 'SALT_XML_TEST_REPORTS_DIR', os.path.join(TMP, 'xml-test-reports') @@ -649,11 +645,6 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): status.append(results) return status - def print_overall_testsuite_report(self): - children = collect_child_processes(os.getpid()) - SaltCoverageTestingParser.print_overall_testsuite_report(self) - terminate_process(children=children) - def main(): ''' diff --git a/tests/support/helpers.py b/tests/support/helpers.py index d1fa0a413f..f61e88ae81 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -1163,7 +1163,10 @@ def terminate_process(pid=None, process=None, children=None, kill_children=False process_list = [] def on_process_terminated(proc): - log.info('Process %s terminated with exit code: %s', getattr(proc, '_cmdline', proc), proc.returncode) + if proc.returncode: + log.info('Process %s terminated with exit code: %s', getattr(proc, '_cmdline', proc), proc.returncode) + else: + log.info('Process %s terminated', getattr(proc, '_cmdline', proc)) if pid and not process: try: diff --git a/tests/support/parser/__init__.py b/tests/support/parser/__init__.py index e0116770b9..8c2b359b29 100644 --- a/tests/support/parser/__init__.py +++ b/tests/support/parser/__init__.py @@ -27,10 +27,12 @@ import warnings from functools import partial from contextlib import closing -import six from tests.support import helpers from tests.support.unit import TestLoader, TextTestRunner from tests.support.xmlunit import HAS_XMLRUNNER, XMLTestRunner + +# Import 3rd-party libs +import salt.ext.six as six try: from tests.support.ext import console WIDTH, HEIGHT = console.getTerminalSize() @@ -38,6 +40,8 @@ try: except Exception: # pylint: disable=broad-except PNUM = 70 +log = logging.getLogger(__name__) + # This is a completely random and meaningful number intended to identify our # own signal triggering. WEIRD_SIGNAL_NUM = -45654 @@ -436,7 +440,7 @@ class SaltTestingParser(optparse.OptionParser): logging_level = logging.ERROR consolehandler.setLevel(logging_level) logging.root.addHandler(consolehandler) - logging.getLogger(__name__).info('Runtests logging has been setup') + log.info('Runtests logging has been setup') def pre_execution_cleanup(self): ''' @@ -607,15 +611,20 @@ class SaltTestingParser(optparse.OptionParser): ''' Run the finalization procedures. Show report, clean-up file-system, etc ''' + # Collect any child processes still laying around + children = helpers.collect_child_processes(os.getpid()) if self.options.no_report is False: self.print_overall_testsuite_report() self.post_execution_cleanup() - # Brute force approach to terminate this process and it's children - logging.getLogger(__name__).info('Terminating test suite child processes.') - helpers.terminate_process_pid(os.getpid(), only_children=True) - logging.getLogger(__name__).info('Terminating test suite child processes if any are still found running.') - helpers.terminate_process_pid(os.getpid(), only_children=True) - logging.getLogger(__name__).info( + # Brute force approach to terminate this process and its children + if children: + log.info('Terminating test suite child processes: %s', children) + helpers.terminate_process(children=children, kill_children=True) + children = helpers.collect_child_processes(os.getpid()) + if children: + log.info('Second run at terminating test suite child processes: %s', children) + helpers.terminate_process(children=children, kill_children=True) + log.info( 'Test suite execution finalized with exit code: {0}'.format( exit_code ) @@ -742,7 +751,7 @@ class SaltTestingParser(optparse.OptionParser): calling_args.append(option.get_opt_string()) elif option.action == 'append': - for val in (value is not None and value or default): + for val in value is not None and value or default: calling_args.extend([option.get_opt_string(), str(val)]) elif option.action == 'count': calling_args.extend([option.get_opt_string()] * value) From bb60e5010ca2879f5479a36cd03ae5bb98c8c0a9 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 28 Feb 2017 00:49:26 +0000 Subject: [PATCH 282/370] Redundant --- tests/integration/output/test_output.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/output/test_output.py b/tests/integration/output/test_output.py index c95cbe779c..6d7ac74dcd 100644 --- a/tests/integration/output/test_output.py +++ b/tests/integration/output/test_output.py @@ -97,7 +97,6 @@ class OutputReturnTest(integration.ShellCase): try: # this should not raises UnicodeEncodeError display_output(data, opts=opts) - self.assertTrue(True) except Exception: # display trace in error message for debugging on jenkins trace = traceback.format_exc() From 4f425e596bbfe2bb1152668b52d184f2a5aa3489 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 28 Feb 2017 01:06:24 +0000 Subject: [PATCH 283/370] Don't assert, just fail --- tests/integration/states/test_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/states/test_service.py b/tests/integration/states/test_service.py index b64a76b514..491ada74f7 100644 --- a/tests/integration/states/test_service.py +++ b/tests/integration/states/test_service.py @@ -30,7 +30,7 @@ class ServiceTest(integration.ModuleCase, ''' check_status = self.run_function('service.status', name=SERVICE_NAME) if check_status is not exp_return: - self.assertFalse('status of service is not returning correctly') + self.fail('status of service is not returning correctly') def test_service_dead(self): ''' From a78c037a5fbf807dc7b111b9247a82e850f76773 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 28 Feb 2017 12:07:21 +0000 Subject: [PATCH 284/370] PyLint, no its not a repeated keyword! --- tests/integration/states/test_ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/states/test_ssh.py b/tests/integration/states/test_ssh.py index ba2b29e7f8..f667a9ccd8 100644 --- a/tests/integration/states/test_ssh.py +++ b/tests/integration/states/test_ssh.py @@ -76,7 +76,7 @@ class SSHKnownHostsStateTest(integration.ModuleCase, self.assertSaltTrueReturn(ret) # then add a record for IP address - ret = self.run_state('ssh_known_hosts.present', + ret = self.run_state('ssh_known_hosts.present', # pylint: disable=repeated-keyword **dict(kwargs, name=GITHUB_IP)) try: self.assertSaltStateChangesEqual( From 251c4c20ab4424bc541175c378012b51788b3e56 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 28 Feb 2017 19:11:34 +0000 Subject: [PATCH 285/370] Add PyLint checker to make sure salttesting is not being used on develop --- .pylintrc | 3 ++- .testing.pylintrc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 6fa3db810f..ce0667593e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -24,7 +24,8 @@ load-plugins=saltpylint.pep8, saltpylint.fileperms, saltpylint.py3modernize, saltpylint.smartup, - saltpylint.minpyver + saltpylint.minpyver, + saltpylint.salttesting # Use multiple processes to speed up Pylint. # Don't bump this values on PyLint 1.4.0 - Know bug that ignores the passed --rcfile diff --git a/.testing.pylintrc b/.testing.pylintrc index ee106b8b8e..c4d4465378 100644 --- a/.testing.pylintrc +++ b/.testing.pylintrc @@ -21,7 +21,8 @@ load-plugins=saltpylint.pep8, saltpylint.fileperms, saltpylint.py3modernize, saltpylint.smartup, - saltpylint.minpyver + saltpylint.minpyver, + saltpylint.salttesting # Use multiple processes to speed up Pylint. # Don't bump this values on PyLint 1.4.0 - Know bug that ignores the passed --rcfile From 959033e39bb748530d8f36f3a10d82d66c19f6b4 Mon Sep 17 00:00:00 2001 From: Tom Williams Date: Tue, 28 Feb 2017 11:41:54 -0500 Subject: [PATCH 286/370] INFRA-4487 - 'test=True' should return True rather than None if no changes are scheduled. --- salt/states/boto_elb.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/salt/states/boto_elb.py b/salt/states/boto_elb.py index 1b0be55565..a8eace6769 100644 --- a/salt/states/boto_elb.py +++ b/salt/states/boto_elb.py @@ -506,7 +506,6 @@ def present( if __salt__['boto_elb.set_instances'](name, instance_ids, True, region, key, keyid, profile): ret['comment'] += ' ELB {0} instances would be updated.'.format(name) - ret['result'] = None return ret _ret = __salt__['boto_elb.set_instances'](name, instance_ids, False, region, key, keyid, profile) @@ -565,7 +564,6 @@ def register_instances(name, instances, region=None, key=None, keyid=None, else: if __opts__['test']: ret['comment'] = 'ELB {0} is set to register : {1}.'.format(name, new) - ret['result'] = None return ret state = __salt__['boto_elb.register_instances'](name, instances, @@ -677,7 +675,6 @@ def _elb_present( if not exists: if __opts__['test']: ret['comment'] = 'ELB {0} is set to be created.'.format(name) - ret['result'] = None return ret created = __salt__['boto_elb.create'](name=name, availability_zones=availability_zones, @@ -780,7 +777,6 @@ def _listeners_present( else: msg.append('Listeners already set on ELB {0}.'.format(name)) ret['comment'] = ' '.join(msg) - ret['result'] = None return ret if to_delete: @@ -843,7 +839,6 @@ def _security_groups_present( if __opts__['test']: msg = 'ELB {0} set to have security groups modified.'.format(name) ret['comment'] = msg - ret['result'] = None return ret changed = __salt__['boto_elb.apply_security_groups']( name, security_groups, region, key, keyid, profile @@ -907,7 +902,6 @@ def _attributes_present( if attrs_to_set: if __opts__['test']: ret['comment'] = 'ELB {0} set to have attributes set.'.format(name) - ret['result'] = None return ret was_set = __salt__['boto_elb.set_attributes'](name, attributes, region, key, keyid, @@ -950,7 +944,6 @@ def _health_check_present( if need_to_set: if __opts__['test']: msg = 'ELB {0} set to have health check set.'.format(name) - ret['result'] = True ret['comment'] = msg return ret was_set = __salt__['boto_elb.set_health_check'](name, health_check, @@ -1000,7 +993,6 @@ def _zones_present( if __opts__['test']: msg = 'ELB {0} to have availability zones set.'.format(name) ret['comment'] = msg - ret['result'] = None return ret if to_enable: enabled = __salt__['boto_elb.enable_availability_zones'](name, @@ -1072,7 +1064,6 @@ def _subnets_present( if __opts__['test']: msg = 'ELB {0} to have subnets set.'.format(name) ret['comment'] = msg - ret['result'] = None return ret if to_enable: attached = __salt__['boto_elb.attach_subnets'](name, to_enable, @@ -1286,15 +1277,12 @@ def _policies_present( msg.append('Policy {0} added.'.format(policy)) for policy in to_delete: msg.append('Policy {0} deleted.'.format(policy)) - ret['result'] = None else: msg.append('Policies already set on ELB {0}.'.format(name)) for listener in listeners_to_update: msg.append('Listener {0} policies updated.'.format(listener)) - ret['result'] = None for backend in backends_to_update: msg.append('Backend {0} policies updated.'.format(backend)) - ret['result'] = None ret['comment'] = ' '.join(msg) return ret @@ -1415,7 +1403,6 @@ def absent( if exists: if __opts__['test']: ret['comment'] = 'ELB {0} is set to be removed.'.format(name) - ret['result'] = None return ret deleted = __salt__['boto_elb.delete'](name, region, key, keyid, profile) @@ -1461,7 +1448,6 @@ def _tags_present(name, msg = 'The following tag{0} set to be removed: {1}.'.format( ('s are' if len(tags_to_remove) > 1 else ' is'), ', '.join(tags_to_remove)) ret['comment'] = ' '.join([ret['comment'], msg]) - ret['result'] = None else: _ret = __salt__['boto_elb.delete_tags']( name, @@ -1486,13 +1472,11 @@ def _tags_present(name, ('s are' if len(tags_to_add.keys()) > 1 else ' is'), ', '.join(tags_to_add.keys())) ret['comment'] = ' '. join([ret['comment'], msg]) - ret['result'] = None if tags_to_update: msg = 'The following tag {0} set to be updated: {1}.'.format( ('values are' if len(tags_to_update.keys()) > 1 else 'value is'), ', '.join(tags_to_update.keys())) ret['comment'] = ' '.join([ret['comment'], msg]) - ret['result'] = None else: all_tag_changes = dictupdate.update(tags_to_add, tags_to_update) _ret = __salt__['boto_elb.set_tags']( From aa8d822e780039ee2f9f526bdc238d5a4cbd42ba Mon Sep 17 00:00:00 2001 From: Tom Williams Date: Tue, 28 Feb 2017 16:08:03 -0500 Subject: [PATCH 287/370] INFRA-4487 - fix unit test to match corrected return value --- tests/unit/states/test_boto_elb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/states/test_boto_elb.py b/tests/unit/states/test_boto_elb.py index 47030435cc..9486abc86f 100644 --- a/tests/unit/states/test_boto_elb.py +++ b/tests/unit/states/test_boto_elb.py @@ -178,7 +178,7 @@ class BotoElbTestCase(TestCase): with patch.dict(boto_elb.__opts__, {'test': True}): comt = ('ELB {0} is set to be removed.'.format(name)) - ret.update({'comment': comt, 'result': None}) + ret.update({'comment': comt, 'result': True}) self.assertDictEqual(boto_elb.absent(name), ret) From a8ced5a5e117239243138b8de09c7f74f2308f96 Mon Sep 17 00:00:00 2001 From: pengyao Date: Wed, 1 Mar 2017 10:56:08 +0800 Subject: [PATCH 288/370] Fix #39350 If use "--askpass" option by salt-ssh, ssh_passwd option explicit set to True, to avoid overwrite by MergeConfig --- salt/utils/parsers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/salt/utils/parsers.py b/salt/utils/parsers.py index 23ad7853b7..c96007cc34 100644 --- a/salt/utils/parsers.py +++ b/salt/utils/parsers.py @@ -2992,6 +2992,11 @@ class SaltSSHOptionParser(six.with_metaclass(OptionParserMeta, if self.options.ssh_askpass: self.options.ssh_passwd = getpass.getpass('Password: ') + for group in self.option_groups: + for option in group.option_list: + if option.dest == 'ssh_passwd': + option.explicit = True + break def setup_config(self): return config.master_config(self.get_config_file_path()) From 474dc619ba20150aa3ef25d70d7ad1c609b66b92 Mon Sep 17 00:00:00 2001 From: Tom Williams Date: Tue, 28 Feb 2017 23:54:41 -0500 Subject: [PATCH 289/370] INFRA-4445 - sort policy docs so they compare equal when they in fact are --- salt/states/boto_iam_role.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/salt/states/boto_iam_role.py b/salt/states/boto_iam_role.py index 97cde4faf3..aaff877547 100644 --- a/salt/states/boto_iam_role.py +++ b/salt/states/boto_iam_role.py @@ -269,11 +269,11 @@ def _role_present( if not policy_document: policy = __salt__['boto_iam.build_policy'](region, key, keyid, profile) - if role['assume_role_policy_document'] != policy: + if _sort_policy(role['assume_role_policy_document']) != _sort_policy(policy): update_needed = True _policy_document = policy else: - if role['assume_role_policy_document'] != policy_document: + if _sort_policy(role['assume_role_policy_document']) != _sort_policy(policy_document): update_needed = True _policy_document = policy_document if update_needed: @@ -357,6 +357,19 @@ def _instance_profile_associated( return ret +def _sort_policy(doc): + # List-type sub-items in policies don't happen to be order-sensitive, but + # compare operations will render them unequal, leading to non-idempotent + # state runs. We'll sort any list-type subitems before comparison to reduce + # the likelihood of false negatives. + if isinstance(doc, list): + return sorted([_sort_policy(i) for i in doc]) + elif isinstance(doc, dict): + return dict([(k, _sort_policy(v)) for k, v in doc.items()]) + else: + return doc + + def _policies_present( name, policies=None, From d5d99d6399cc622f2a1b38c2ceafe0981864ef90 Mon Sep 17 00:00:00 2001 From: Kadlec Jan Date: Wed, 1 Mar 2017 07:13:28 +0100 Subject: [PATCH 290/370] recteate unit tests --- salt/states/mongodb_user.py | 4 ++-- tests/unit/states/test_mongodb_user.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/salt/states/mongodb_user.py b/salt/states/mongodb_user.py index c9a53b979b..4c3c68b7f8 100644 --- a/salt/states/mongodb_user.py +++ b/salt/states/mongodb_user.py @@ -118,8 +118,8 @@ def present(name, # if the check does not return a boolean, return an error # this may be the case if there is a database connection error - if not isinstance(user_exists, bool): - ret['comment'] = user_exists + if not isinstance(users, list): + ret['comment'] = users ret['result'] = False return ret diff --git a/tests/unit/states/test_mongodb_user.py b/tests/unit/states/test_mongodb_user.py index 31e1f03295..82478ee2be 100644 --- a/tests/unit/states/test_mongodb_user.py +++ b/tests/unit/states/test_mongodb_user.py @@ -47,13 +47,16 @@ class MongodbUserTestCase(TestCase): ret.update({'comment': comt}) self.assertDictEqual(mongodb_user.present(name, passwd, port={}), ret) - mock = MagicMock(side_effect=[True, False, False]) mock_t = MagicMock(return_value=True) + mock_f = MagicMock(return_value=[]) with patch.dict(mongodb_user.__salt__, - {'mongodb.user_exists': mock, - 'mongodb.user_create': mock_t}): - comt = ('User {0} is already present'.format(name)) - ret.update({'comment': comt, 'result': True}) + { + 'mongodb.user_create': mock_t, + 'mongodb.user_find': mock_f + }): + comt = ('User {0} is not present and needs to be created' + ).format(name) + ret.update({'comment': comt, 'result': None}) self.assertDictEqual(mongodb_user.present(name, passwd), ret) with patch.dict(mongodb_user.__opts__, {'test': True}): @@ -66,6 +69,7 @@ class MongodbUserTestCase(TestCase): comt = ('User {0} has been created'.format(name)) ret.update({'comment': comt, 'result': True, 'changes': {name: 'Present'}}) + print ret self.assertDictEqual(mongodb_user.present(name, passwd), ret) # 'absent' function tests: 1 From e550aeca64709cb19fa1d66f7a774c75d9e6a5af Mon Sep 17 00:00:00 2001 From: Jacek Tomasiak Date: Wed, 1 Mar 2017 10:31:46 +0100 Subject: [PATCH 291/370] Added credstore option to esxi proxy config Credential store can be used to store server thumbprints where untrusted SSL certs are used. It needs to be passed to esxcli as an additional argument. With this change, it's possible to set path to the credential store in the proxy config pillar. --- salt/modules/vsphere.py | 157 ++++++++++++++++++++++-------- salt/proxy/esxi.py | 15 +++ salt/utils/decorators/__init__.py | 18 ++++ salt/utils/vmware.py | 7 +- 4 files changed, 158 insertions(+), 39 deletions(-) diff --git a/salt/modules/vsphere.py b/salt/modules/vsphere.py index 8d9de8b74b..2f0062572b 100644 --- a/salt/modules/vsphere.py +++ b/salt/modules/vsphere.py @@ -175,7 +175,7 @@ import salt.utils.vmware import salt.utils.http from salt.utils import dictupdate from salt.exceptions import CommandExecutionError, VMwareSaltError -from salt.utils.decorators import depends +from salt.utils.decorators import depends, ignores_kwargs from salt.utils import clean_kwargs # Import Third Party Libs @@ -377,7 +377,7 @@ def disconnect(service_instance): @depends(HAS_ESX_CLI) -def esxcli_cmd(cmd_str, host=None, username=None, password=None, protocol=None, port=None, esxi_hosts=None): +def esxcli_cmd(cmd_str, host=None, username=None, password=None, protocol=None, port=None, esxi_hosts=None, credstore=None): ''' Run an ESXCLI command directly on the host or list of hosts. @@ -408,6 +408,9 @@ def esxcli_cmd(cmd_str, host=None, username=None, password=None, protocol=None, If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + CLI Example: .. code-block:: bash @@ -428,7 +431,7 @@ def esxcli_cmd(cmd_str, host=None, username=None, password=None, protocol=None, for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd_str, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) if response['retcode'] != 0: ret.update({esxi_host: {'Error': response.get('stdout')}}) else: @@ -436,7 +439,8 @@ def esxcli_cmd(cmd_str, host=None, username=None, password=None, protocol=None, else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd_str, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) if response['retcode'] != 0: ret.update({host: {'Error': response.get('stdout')}}) else: @@ -446,7 +450,7 @@ def esxcli_cmd(cmd_str, host=None, username=None, password=None, protocol=None, @depends(HAS_ESX_CLI) -def get_coredump_network_config(host, username, password, protocol=None, port=None, esxi_hosts=None): +def get_coredump_network_config(host, username, password, protocol=None, port=None, esxi_hosts=None, credstore=None): ''' Retrieve information on ESXi or vCenter network dump collection and format it into a dictionary. @@ -472,6 +476,9 @@ def get_coredump_network_config(host, username, password, protocol=None, port=No If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + :return: A dictionary with the network configuration, or, if getting the network config failed, a an error message retrieved from the standard cmd.run_all dictionary, per host. @@ -497,7 +504,7 @@ def get_coredump_network_config(host, username, password, protocol=None, port=No for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) if response['retcode'] != 0: ret.update({esxi_host: {'Error': response.get('stdout')}}) else: @@ -506,7 +513,8 @@ def get_coredump_network_config(host, username, password, protocol=None, port=No else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) if response['retcode'] != 0: ret.update({host: {'Error': response.get('stdout')}}) else: @@ -518,7 +526,7 @@ def get_coredump_network_config(host, username, password, protocol=None, port=No @depends(HAS_ESX_CLI) -def coredump_network_enable(host, username, password, enabled, protocol=None, port=None, esxi_hosts=None): +def coredump_network_enable(host, username, password, enabled, protocol=None, port=None, esxi_hosts=None, credstore=None): ''' Enable or disable ESXi core dump collection. Returns ``True`` if coredump is enabled and returns ``False`` if core dump is not enabled. If there was an error, the error @@ -548,6 +556,9 @@ def coredump_network_enable(host, username, password, enabled, protocol=None, po If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + CLI Example: .. code-block:: bash @@ -573,7 +584,7 @@ def coredump_network_enable(host, username, password, enabled, protocol=None, po for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) if response['retcode'] != 0: ret.update({esxi_host: {'Error': response.get('stdout')}}) else: @@ -582,7 +593,8 @@ def coredump_network_enable(host, username, password, enabled, protocol=None, po else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) if response['retcode'] != 0: ret.update({host: {'Error': response.get('stdout')}}) else: @@ -600,7 +612,8 @@ def set_coredump_network_config(host, port=None, host_vnic='vmk0', dump_port=6500, - esxi_hosts=None): + esxi_hosts=None, + credstore=None): ''' Set the network parameters for a network coredump collection. @@ -637,6 +650,9 @@ def set_coredump_network_config(host, dump_port TCP port to use for the dump, defaults to ``6500``. + credstore + Optionally set to path to the credential store file. + :return: A standard cmd.run_all dictionary with a `success` key added, per host. `success` will be True if the set succeeded, False otherwise. @@ -662,7 +678,7 @@ def set_coredump_network_config(host, for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) if response['retcode'] != 0: response['success'] = False else: @@ -673,7 +689,8 @@ def set_coredump_network_config(host, else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) if response['retcode'] != 0: response['success'] = False else: @@ -684,7 +701,7 @@ def set_coredump_network_config(host, @depends(HAS_ESX_CLI) -def get_firewall_status(host, username, password, protocol=None, port=None, esxi_hosts=None): +def get_firewall_status(host, username, password, protocol=None, port=None, esxi_hosts=None, credstore=None): ''' Show status of all firewall rule sets. @@ -709,6 +726,9 @@ def get_firewall_status(host, username, password, protocol=None, port=None, esxi If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + :return: Nested dictionary with two toplevel keys ``rulesets`` and ``success`` ``success`` will be True or False depending on query success ``rulesets`` will list the rulesets and their statuses if ``success`` @@ -735,7 +755,7 @@ def get_firewall_status(host, username, password, protocol=None, port=None, esxi for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) if response['retcode'] != 0: ret.update({esxi_host: {'Error': response['stdout'], 'success': False, @@ -746,7 +766,8 @@ def get_firewall_status(host, username, password, protocol=None, port=None, esxi else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) if response['retcode'] != 0: ret.update({host: {'Error': response['stdout'], 'success': False, @@ -766,7 +787,8 @@ def enable_firewall_ruleset(host, ruleset_name, protocol=None, port=None, - esxi_hosts=None): + esxi_hosts=None, + credstore=None): ''' Enable or disable an ESXi firewall rule set. @@ -797,6 +819,9 @@ def enable_firewall_ruleset(host, If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + :return: A standard cmd.run_all dictionary, per host. CLI Example: @@ -822,19 +847,20 @@ def enable_firewall_ruleset(host, for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) ret.update({esxi_host: response}) else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) ret.update({host: response}) return ret @depends(HAS_ESX_CLI) -def syslog_service_reload(host, username, password, protocol=None, port=None, esxi_hosts=None): +def syslog_service_reload(host, username, password, protocol=None, port=None, esxi_hosts=None, credstore=None): ''' Reload the syslog service so it will pick up any changes. @@ -859,6 +885,9 @@ def syslog_service_reload(host, username, password, protocol=None, port=None, es If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + :return: A standard cmd.run_all dictionary. This dictionary will at least have a `retcode` key. If `retcode` is 0 the command was successful. @@ -883,12 +912,13 @@ def syslog_service_reload(host, username, password, protocol=None, port=None, es for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) ret.update({esxi_host: response}) else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) ret.update({host: response}) return ret @@ -904,7 +934,8 @@ def set_syslog_config(host, port=None, firewall=True, reset_service=True, - esxi_hosts=None): + esxi_hosts=None, + credstore=None): ''' Set the specified syslog configuration parameter. By default, this function will reset the syslog service after the configuration is set. @@ -950,6 +981,9 @@ def set_syslog_config(host, If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + :return: Dictionary with a top-level key of 'success' which indicates if all the parameters were reset, and individual keys for each parameter indicating which succeeded or failed, per host. @@ -980,7 +1014,7 @@ def set_syslog_config(host, response = enable_firewall_ruleset(host, username, password, ruleset_enable=True, ruleset_name='syslog', protocol=protocol, port=port, - esxi_hosts=[esxi_host]).get(esxi_host) + esxi_hosts=[esxi_host], credstore=credstore).get(esxi_host) if response['retcode'] != 0: ret.update({esxi_host: {'enable_firewall': {'message': response['stdout'], 'success': False}}}) @@ -990,7 +1024,8 @@ def set_syslog_config(host, # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = enable_firewall_ruleset(host, username, password, ruleset_enable=True, ruleset_name='syslog', - protocol=protocol, port=port).get(host) + protocol=protocol, port=port, + credstore=credstore).get(host) if response['retcode'] != 0: ret.update({host: {'enable_firewall': {'message': response['stdout'], 'success': False}}}) @@ -1005,7 +1040,8 @@ def set_syslog_config(host, for esxi_host in esxi_hosts: response = _set_syslog_config_helper(host, username, password, syslog_config, config_value, protocol=protocol, port=port, - reset_service=reset_service, esxi_host=esxi_host) + reset_service=reset_service, esxi_host=esxi_host, + credstore=credstore) # Ensure we don't overwrite any dictionary data already set # By updating the esxi_host directly. if ret.get(esxi_host) is None: @@ -1016,7 +1052,7 @@ def set_syslog_config(host, # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = _set_syslog_config_helper(host, username, password, syslog_config, config_value, protocol=protocol, port=port, - reset_service=reset_service) + reset_service=reset_service, credstore=credstore) # Ensure we don't overwrite any dictionary data already set # By updating the host directly. if ret.get(host) is None: @@ -1027,7 +1063,7 @@ def set_syslog_config(host, @depends(HAS_ESX_CLI) -def get_syslog_config(host, username, password, protocol=None, port=None, esxi_hosts=None): +def get_syslog_config(host, username, password, protocol=None, port=None, esxi_hosts=None, credstore=None): ''' Retrieve the syslog configuration. @@ -1052,6 +1088,9 @@ def get_syslog_config(host, username, password, protocol=None, port=None, esxi_h If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + :return: Dictionary with keys and values corresponding to the syslog configuration, per host. @@ -1076,13 +1115,14 @@ def get_syslog_config(host, username, password, protocol=None, port=None, esxi_h for esxi_host in esxi_hosts: response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) # format the response stdout into something useful ret.update({esxi_host: _format_syslog_config(response)}) else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response = salt.utils.vmware.esxcli(host, username, password, cmd, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) # format the response stdout into something useful ret.update({host: _format_syslog_config(response)}) @@ -1096,7 +1136,8 @@ def reset_syslog_config(host, protocol=None, port=None, syslog_config=None, - esxi_hosts=None): + esxi_hosts=None, + credstore=None): ''' Reset the syslog service to its default settings. @@ -1129,6 +1170,9 @@ def reset_syslog_config(host, If ``host`` is a vCenter host, then use esxi_hosts to execute this function on a list of one or more ESXi machines. + credstore + Optionally set to path to the credential store file. + :return: Dictionary with a top-level key of 'success' which indicates if all the parameters were reset, and individual keys for each parameter indicating which succeeded or failed, per host. @@ -1170,18 +1214,20 @@ def reset_syslog_config(host, response_dict = _reset_syslog_config_params(host, username, password, cmd, resets, valid_resets, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) ret.update({esxi_host: response_dict}) else: # Handles a single host or a vCenter connection when no esxi_hosts are provided. response_dict = _reset_syslog_config_params(host, username, password, cmd, resets, valid_resets, - protocol=protocol, port=port) + protocol=protocol, port=port, + credstore=credstore) ret.update({host: response_dict}) return ret +@ignores_kwargs('credstore') def upload_ssh_key(host, username, password, ssh_key=None, ssh_key_file=None, protocol=None, port=None, certificate_verify=False): ''' @@ -1253,6 +1299,7 @@ def upload_ssh_key(host, username, password, ssh_key=None, ssh_key_file=None, return ret +@ignores_kwargs('credstore') def get_ssh_key(host, username, password, @@ -1310,6 +1357,7 @@ def get_ssh_key(host, @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def get_host_datetime(host, username, password, protocol=None, port=None, host_names=None): ''' Get the date/time information for a given host or list of host_names. @@ -1368,6 +1416,7 @@ def get_host_datetime(host, username, password, protocol=None, port=None, host_n @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def get_ntp_config(host, username, password, protocol=None, port=None, host_names=None): ''' Get the NTP configuration information for a given host or list of host_names. @@ -1425,6 +1474,7 @@ def get_ntp_config(host, username, password, protocol=None, port=None, host_name @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def get_service_policy(host, username, password, service_name, protocol=None, port=None, host_names=None): ''' Get the service name's policy for a given host or list of hosts. @@ -1531,6 +1581,7 @@ def get_service_policy(host, username, password, service_name, protocol=None, po @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def get_service_running(host, username, password, service_name, protocol=None, port=None, host_names=None): ''' Get the service name's running state for a given host or list of hosts. @@ -1637,6 +1688,7 @@ def get_service_running(host, username, password, service_name, protocol=None, p @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def get_vmotion_enabled(host, username, password, protocol=None, port=None, host_names=None): ''' Get the VMotion enabled status for a given host or a list of host_names. Returns ``True`` @@ -1698,6 +1750,7 @@ def get_vmotion_enabled(host, username, password, protocol=None, port=None, host @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def get_vsan_enabled(host, username, password, protocol=None, port=None, host_names=None): ''' Get the VSAN enabled status for a given host or a list of host_names. Returns ``True`` @@ -1764,6 +1817,7 @@ def get_vsan_enabled(host, username, password, protocol=None, port=None, host_na @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def get_vsan_eligible_disks(host, username, password, protocol=None, port=None, host_names=None): ''' Returns a list of VSAN-eligible disks for a given host or list of host_names. @@ -1859,6 +1913,7 @@ def test_vcenter_connection(service_instance=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def system_info(host, username, password, protocol=None, port=None): ''' Return system information about a VMware environment. @@ -1899,6 +1954,7 @@ def system_info(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_datacenters(host, username, password, protocol=None, port=None): ''' Returns a list of datacenters for the the specified host. @@ -1936,6 +1992,7 @@ def list_datacenters(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_clusters(host, username, password, protocol=None, port=None): ''' Returns a list of clusters for the the specified host. @@ -1973,6 +2030,7 @@ def list_clusters(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_datastore_clusters(host, username, password, protocol=None, port=None): ''' Returns a list of datastore clusters for the the specified host. @@ -2009,6 +2067,7 @@ def list_datastore_clusters(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_datastores(host, username, password, protocol=None, port=None): ''' Returns a list of datastores for the the specified host. @@ -2045,6 +2104,7 @@ def list_datastores(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_hosts(host, username, password, protocol=None, port=None): ''' Returns a list of hosts for the the specified VMware environment. @@ -2081,6 +2141,7 @@ def list_hosts(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_resourcepools(host, username, password, protocol=None, port=None): ''' Returns a list of resource pools for the the specified host. @@ -2117,6 +2178,7 @@ def list_resourcepools(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_networks(host, username, password, protocol=None, port=None): ''' Returns a list of networks for the the specified host. @@ -2153,6 +2215,7 @@ def list_networks(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_vms(host, username, password, protocol=None, port=None): ''' Returns a list of VMs for the the specified host. @@ -2189,6 +2252,7 @@ def list_vms(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_folders(host, username, password, protocol=None, port=None): ''' Returns a list of folders for the the specified host. @@ -2225,6 +2289,7 @@ def list_folders(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_dvs(host, username, password, protocol=None, port=None): ''' Returns a list of distributed virtual switches for the the specified host. @@ -2261,6 +2326,7 @@ def list_dvs(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_vapps(host, username, password, protocol=None, port=None): ''' Returns a list of vApps for the the specified host. @@ -2298,6 +2364,7 @@ def list_vapps(host, username, password, protocol=None, port=None): @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_ssds(host, username, password, protocol=None, port=None, host_names=None): ''' Returns a list of SSDs for the given host or list of host_names. @@ -2358,6 +2425,7 @@ def list_ssds(host, username, password, protocol=None, port=None, host_names=Non @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def list_non_ssds(host, username, password, protocol=None, port=None, host_names=None): ''' Returns a list of Non-SSD disks for the given host or list of host_names. @@ -2425,6 +2493,7 @@ def list_non_ssds(host, username, password, protocol=None, port=None, host_names @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def set_ntp_config(host, username, password, ntp_servers, protocol=None, port=None, host_names=None): ''' Set NTP configuration for a given host of list of host_names. @@ -2504,6 +2573,7 @@ def set_ntp_config(host, username, password, ntp_servers, protocol=None, port=No @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def service_start(host, username, password, @@ -2614,6 +2684,7 @@ def service_start(host, @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def service_stop(host, username, password, @@ -2724,6 +2795,7 @@ def service_stop(host, @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def service_restart(host, username, password, @@ -2834,6 +2906,7 @@ def service_restart(host, @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def set_service_policy(host, username, password, @@ -2962,6 +3035,7 @@ def set_service_policy(host, @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def update_host_datetime(host, username, password, protocol=None, port=None, host_names=None): ''' Update the date/time on the given host or list of host_names. This function should be @@ -3028,6 +3102,7 @@ def update_host_datetime(host, username, password, protocol=None, port=None, hos @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def update_host_password(host, username, password, new_password, protocol=None, port=None): ''' Update the password for a given host. @@ -3090,6 +3165,7 @@ def update_host_password(host, username, password, new_password, protocol=None, @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def vmotion_disable(host, username, password, protocol=None, port=None, host_names=None): ''' Disable vMotion for a given host or list of host_names. @@ -3158,6 +3234,7 @@ def vmotion_disable(host, username, password, protocol=None, port=None, host_nam @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def vmotion_enable(host, username, password, protocol=None, port=None, host_names=None, device='vmk0'): ''' Enable vMotion for a given host or list of host_names. @@ -3230,6 +3307,7 @@ def vmotion_enable(host, username, password, protocol=None, port=None, host_name @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def vsan_add_disks(host, username, password, protocol=None, port=None, host_names=None): ''' Add any VSAN-eligible disks to the VSAN System for the given host or list of host_names. @@ -3333,6 +3411,7 @@ def vsan_add_disks(host, username, password, protocol=None, port=None, host_name @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def vsan_disable(host, username, password, protocol=None, port=None, host_names=None): ''' Disable VSAN for a given host or list of host_names. @@ -3417,6 +3496,7 @@ def vsan_disable(host, username, password, protocol=None, port=None, host_names= @depends(HAS_PYVMOMI) +@ignores_kwargs('credstore') def vsan_enable(host, username, password, protocol=None, port=None, host_names=None): ''' Enable VSAN for a given host or list of host_names. @@ -3724,7 +3804,7 @@ def _get_vsan_eligible_disks(service_instance, host, host_names): def _reset_syslog_config_params(host, username, password, cmd, resets, valid_resets, - protocol=None, port=None, esxi_host=None): + protocol=None, port=None, esxi_host=None, credstore=None): ''' Helper function for reset_syslog_config that resets the config and populates the return dictionary. ''' @@ -3738,7 +3818,7 @@ def _reset_syslog_config_params(host, username, password, cmd, resets, valid_res if reset_param in valid_resets: ret = salt.utils.vmware.esxcli(host, username, password, cmd + reset_param, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) ret_dict[reset_param] = {} ret_dict[reset_param]['success'] = ret['retcode'] == 0 if ret['retcode'] != 0: @@ -3757,7 +3837,7 @@ def _reset_syslog_config_params(host, username, password, cmd, resets, valid_res def _set_syslog_config_helper(host, username, password, syslog_config, config_value, - protocol=None, port=None, reset_service=None, esxi_host=None): + protocol=None, port=None, reset_service=None, esxi_host=None, credstore=None): ''' Helper function for set_syslog_config that sets the config and populates the return dictionary. ''' @@ -3773,7 +3853,7 @@ def _set_syslog_config_helper(host, username, password, syslog_config, config_va response = salt.utils.vmware.esxcli(host, username, password, cmd, protocol=protocol, port=port, - esxi_host=esxi_host) + esxi_host=esxi_host, credstore=credstore) # Update the return dictionary for success or error messages. if response['retcode'] != 0: @@ -3791,12 +3871,13 @@ def _set_syslog_config_helper(host, username, password, syslog_config, config_va host_name = host response = syslog_service_reload(host, username, password, protocol=protocol, port=port, - esxi_hosts=esxi_host).get(host_name) + esxi_hosts=esxi_host, credstore=credstore).get(host_name) ret_dict.update({'syslog_restart': {'success': response['retcode'] == 0}}) return ret_dict +@ignores_kwargs('credstore') def add_host_to_dvs(host, username, password, vmknic_name, vmnic_name, dvs_name, target_portgroup_name, uplink_portgroup_name, protocol=None, port=None, host_names=None): diff --git a/salt/proxy/esxi.py b/salt/proxy/esxi.py index b01daf34a6..151286d82d 100644 --- a/salt/proxy/esxi.py +++ b/salt/proxy/esxi.py @@ -105,6 +105,7 @@ look like this: - first_password - second_password - third_password + credstore: proxytype ^^^^^^^^^ @@ -168,6 +169,18 @@ port If the ESXi host is not using the default port, set this value to an alternate port. Default is ``443``. +credstore +^^^^^^^^^ +If the ESXi host is using an untrusted SSL certificate, set this value to +the file path where the credential store is located. This file is passed to +``esxcli``. Default is ``/.vmware/credstore/vicredentials.xml`` on Linux +and ``/VMware/credstore/vicredentials.xml`` on Windows. + +.. note:: + + ``HOME`` variable is sometimes not set for processes running as system + services. If you want to rely on the default credential store location, + make sure ``HOME`` is set for the proxy process. Salt Proxy ---------- @@ -321,6 +334,7 @@ def init(opts): DETAILS['password'] = password DETAILS['protocol'] = opts['proxy'].get('protocol', 'https') DETAILS['port'] = opts['proxy'].get('port', '443') + DETAILS['credstore'] = opts['proxy'].get('credstore') def grains(): @@ -401,6 +415,7 @@ def ch_config(cmd, *args, **kwargs): kwargs['password'] = DETAILS['password'] kwargs['port'] = DETAILS['port'] kwargs['protocol'] = DETAILS['protocol'] + kwargs['credstore'] = DETAILS['credstore'] if 'vsphere.' + cmd not in __salt__: return {'retcode': -1, 'message': 'vsphere.' + cmd + ' is not available.'} diff --git a/salt/utils/decorators/__init__.py b/salt/utils/decorators/__init__.py index 7ef3f82d8c..e1110afc6b 100644 --- a/salt/utils/decorators/__init__.py +++ b/salt/utils/decorators/__init__.py @@ -588,3 +588,21 @@ class _WithDeprecated(_DeprecationDecorator): with_deprecated = _WithDeprecated + + +def ignores_kwargs(*kwarg_names): + ''' + Decorator to filter out unexpected keyword arguments from the call + + kwarg_names: + List of argument names to ignore + ''' + def _ignores_kwargs(fn): + def __ignores_kwargs(*args, **kwargs): + kwargs_filtered = kwargs.copy() + for name in kwarg_names: + if name in kwargs_filtered: + del kwargs_filtered[name] + return fn(*args, **kwargs_filtered) + return __ignores_kwargs + return _ignores_kwargs diff --git a/salt/utils/vmware.py b/salt/utils/vmware.py index 543f1b6509..9353779395 100644 --- a/salt/utils/vmware.py +++ b/salt/utils/vmware.py @@ -116,7 +116,7 @@ def __virtual__(): return False, 'Missing dependency: The salt.utils.vmware module requires pyVmomi.' -def esxcli(host, user, pwd, cmd, protocol=None, port=None, esxi_host=None): +def esxcli(host, user, pwd, cmd, protocol=None, port=None, esxi_host=None, credstore=None): ''' Shell out and call the specified esxcli commmand, parse the result and return something sane. @@ -128,6 +128,8 @@ def esxcli(host, user, pwd, cmd, protocol=None, port=None, esxi_host=None): :param cmd: esxcli command and arguments :param esxi_host: If `host` is a vCenter host, then esxi_host is the ESXi machine on which to execute this command + :param credstore: Optional path to the credential store file + :return: Dictionary ''' @@ -142,6 +144,9 @@ def esxcli(host, user, pwd, cmd, protocol=None, port=None, esxi_host=None): if protocol is None: protocol = 'https' + if credstore: + esx_cmd += ' --credstore \'{0}\''.format(credstore) + if not esxi_host: # Then we are connecting directly to an ESXi server, # 'host' points at that server, and esxi_host is a reference to the From 74971d1b05a85fb236b9e3edf4d208d3bc48f17a Mon Sep 17 00:00:00 2001 From: Zhi Han Date: Wed, 1 Mar 2017 10:10:59 -0500 Subject: [PATCH 292/370] Handle special cases in exit_success Make sure the logic in exit_success is equivalent to that of lookup_jid: - Have default values for 'Minions' and 'Result' in the data - If a job has return but is not listed in minions, consider it a success. Handles the case where lookup_jid find the job but does not know the minions: $ salt-run jobs.lookup_jid .... StartTime: 2017, Mar 01 03:50:59.396278 Target: unknown-target Target-type: User: root jid: 20170301035059396278 $ salt-run jobs.exit_success Exception occurred in runner jobs.exit_success: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/salt/client/mixins.py", line 395, in _low data['return'] = self.functions[fun](*args, **kwargs) File "/usr/lib/python2.7/dist-packages/salt/runners/jobs.py", line 478, in exit_success minions = data['Minions'] KeyError: 'Minions' --- salt/runners/jobs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/salt/runners/jobs.py b/salt/runners/jobs.py index f0e8902d70..912868511d 100644 --- a/salt/runners/jobs.py +++ b/salt/runners/jobs.py @@ -475,8 +475,8 @@ def exit_success(jid, ext_source=None): ext_source=ext_source ) - minions = data['Minions'] - result = data['Result'] + minions = data.get('Minions', []) + result = data.get('Result', {}) for minion in minions: if minion in result and 'return' in result[minion]: @@ -484,6 +484,9 @@ def exit_success(jid, ext_source=None): else: ret[minion] = False + for minion in result: + if 'return' in result[minion] and result[minion]['return']: + ret[minion] = True return ret From 33e40c94e410183acdacc4e61f9f70131c6be0bb Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 1 Mar 2017 09:06:17 -0700 Subject: [PATCH 293/370] Fix docs test for #39753 --- tests/integration/files/file/base/_modules/runtests_helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/files/file/base/_modules/runtests_helpers.py b/tests/integration/files/file/base/_modules/runtests_helpers.py index 5968aab7c7..54624aa796 100644 --- a/tests/integration/files/file/base/_modules/runtests_helpers.py +++ b/tests/integration/files/file/base/_modules/runtests_helpers.py @@ -83,6 +83,7 @@ def get_invalid_docs(): ) allow_failure_glob = ( 'runtests_helpers.*', + 'vsphere.*', ) nodoc = set() noexample = set() From f377a253946af3594ac90d5b9aab187c7f45c448 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 1 Mar 2017 16:14:23 +0000 Subject: [PATCH 294/370] Update development requirements file --- requirements/dev_python27.txt | 5 +++-- requirements/dev_python34.txt | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/requirements/dev_python27.txt b/requirements/dev_python27.txt index 59bffbc8e0..3a2148e09f 100644 --- a/requirements/dev_python27.txt +++ b/requirements/dev_python27.txt @@ -5,6 +5,7 @@ apache-libcloud>=0.14.0 boto>=2.32.1 boto3>=1.2.1 moto>=0.3.6 -SaltTesting -SaltPyLint>=v2017.2.22 +SaltPyLint>=v2017.2.29 GitPython>=0.3 +pytest +git+https://github.com/saltstack/pytest-salt.git@master#egg=pytest-salt diff --git a/requirements/dev_python34.txt b/requirements/dev_python34.txt index 2a7221dbb5..3a2148e09f 100644 --- a/requirements/dev_python34.txt +++ b/requirements/dev_python34.txt @@ -5,5 +5,7 @@ apache-libcloud>=0.14.0 boto>=2.32.1 boto3>=1.2.1 moto>=0.3.6 -SaltTesting -SaltPyLint>=v2017.2.22 +SaltPyLint>=v2017.2.29 +GitPython>=0.3 +pytest +git+https://github.com/saltstack/pytest-salt.git@master#egg=pytest-salt From 25655278ae7aacb713a455643dc81b99eadff6bf Mon Sep 17 00:00:00 2001 From: Luke Hollins Date: Wed, 1 Mar 2017 11:23:25 -0500 Subject: [PATCH 295/370] Fixed whitespace error --- salt/modules/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/docker.py b/salt/modules/docker.py index 9769b30dc2..5bbec5e9ca 100644 --- a/salt/modules/docker.py +++ b/salt/modules/docker.py @@ -1979,7 +1979,7 @@ def _validate_input(kwargs, raise SaltInvocationError( 'Invalid sysctls configuration.' ) - + def _valid_ulimits(): # pylint: disable=unused-variable ''' Must be a string or list of strings with bind mount information From 6a9fbd314cb780aeccb539ab4366deb0baa78659 Mon Sep 17 00:00:00 2001 From: rallytime Date: Wed, 1 Mar 2017 09:25:35 -0700 Subject: [PATCH 296/370] Remove duplicate test --- tests/unit/modules/test_systemd.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/unit/modules/test_systemd.py b/tests/unit/modules/test_systemd.py index 3a579717d0..59cb247320 100644 --- a/tests/unit/modules/test_systemd.py +++ b/tests/unit/modules/test_systemd.py @@ -536,9 +536,6 @@ class SystemdScopeTestCase(TestCase): self._change_state('disable', no_block=False) self._change_state('disable', no_block=True) - def test_disable(self): - self._change_state('disable') - def test_mask(self): self._mask_unmask('mask', False) From 9087bfd44cef9b2ea7cc4db70818e511559ec756 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 1 Mar 2017 10:15:17 -0700 Subject: [PATCH 297/370] Single quotes --- salt/modules/cron.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/cron.py b/salt/modules/cron.py index f67fb19217..d2e9ca9f3a 100644 --- a/salt/modules/cron.py +++ b/salt/modules/cron.py @@ -408,7 +408,7 @@ def _get_cron_date_time(**kwargs): value = str(kwargs.get(param, '1')).lower() if value == 'random': ret[param] = str(random.sample(range_max[param], 1)[0]) - elif len(value.split(":")) == 2: + elif len(value.split(':')) == 2: cron_range = sorted(value.split(":")) start, end = int(cron_range[0]), int(cron_range[1]) ret[param] = str(random.randint(start, end)) From 539aad1e224cd4a8f126444598fa821e55a92836 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 1 Mar 2017 10:17:06 -0700 Subject: [PATCH 298/370] One more single quotes --- salt/modules/cron.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/cron.py b/salt/modules/cron.py index d2e9ca9f3a..ab8b0b2f8b 100644 --- a/salt/modules/cron.py +++ b/salt/modules/cron.py @@ -409,7 +409,7 @@ def _get_cron_date_time(**kwargs): if value == 'random': ret[param] = str(random.sample(range_max[param], 1)[0]) elif len(value.split(':')) == 2: - cron_range = sorted(value.split(":")) + cron_range = sorted(value.split(':')) start, end = int(cron_range[0]), int(cron_range[1]) ret[param] = str(random.randint(start, end)) else: From 255db60f5ab472de6fbe0ee595a588bb78b8ab79 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 13:21:25 -0700 Subject: [PATCH 299/370] Add pre and post states to SPM --- doc/topics/spm/spm_formula.rst | 99 ++++++++++++++++++++++++++++++++++ salt/spm/__init__.py | 58 ++++++++++++++++++++ 2 files changed, 157 insertions(+) diff --git a/doc/topics/spm/spm_formula.rst b/doc/topics/spm/spm_formula.rst index c840b57e9e..445ee204f7 100644 --- a/doc/topics/spm/spm_formula.rst +++ b/doc/topics/spm/spm_formula.rst @@ -146,6 +146,105 @@ The first 5 of these types (``c``, ``d``, ``g``, ``l``, ``r``) will be placed in The last two types (``s`` and ``m``) are currently ignored, but they are reserved for future use. +Pre and Post States +------------------- +It is possible to run Salt states before and after installing a package by +using pre and post states. The following sections may be declared in a +``FORMULA``: + +* ``pre_local_state`` +* ``pre_tgt_state`` +* ``post_local_state`` +* ``post_tgt_state`` + +Sections with ``pre`` in their name are evaluated before a package is installed +and sections with ``post`` are evaluated after a package is installed. ``local`` +states are evaluated before ``tgt`` states. + +Each of these sections needs to be evaluated as text, rather than as YAML. +Consider the following block: + +.. code-block:: + + pre_local_state: > + echo test > /tmp/spmtest: + cmd: + - run + +Note that this declaration uses ``>`` after ``pre_local_state``. This is a YAML +marker that marks the next multi-line block as text, including newlines. It is +important to use this marker whenever declaring ``pre`` or ``post`` states, so +that the text following it can be evaluated properly. + +local States +~~~~~~~~~~~~ +``local`` states are evaluated locally; this is analagous to issuing a state +run using a ``salt-call --local`` command. These commands will be issued on the +local machine running the ``spm`` command, whether that machine is a master or +a minion. + +``local`` states do not require any special arguments, but they must still use +the ``>`` marker to denote that the state is evaluated as text, not a data +structure. + +.. code-block:: + + pre_local_state: > + echo test > /tmp/spmtest: + cmd: + - run + +tgt States +~~~~~~~~~~ +``tgt`` states are issued against a remote target. This is analogous to issuing +a state using the ``salt`` command. As such it requires that the machine that +the ``spm`` command is running on is a master. + +Because ``tgt`` states require that a target be specified, their code blocks +are a little different. Consider the following state: + +.. code-block:: + + pre_tgt_state: + tgt: '*' + data: > + echo test > /tmp/spmtest: + cmd: + - run + +With ``tgt`` states, the state data is placed under a ``data`` section, inside +the ``*_tgt_state`` code block. The target is of course specified as a ``tgt`` +and you may also optionally specify a ``tgt_type`` (the default is ``glob``). + +You still need to use the ``>`` marker, but this time it follows the ``data`` +line, rather than the ``*_tgt_state`` line. + +Templating States +~~~~~~~~~~~~~~~~~ +The reason that state data must be evaluated as text rather than a data +structure is because that state data is first processed through the rendering +engine, as it would be with a standard state run. + +This means that you can use Jinja or any other supported renderer inside of +Salt. All formula variables are available to the renderer, so you can reference +``FORMULA`` data inside your state if you need to: + +.. code-block:: + + pre_tgt_state: + tgt: '*' + data: > + echo {{ name }} > /tmp/spmtest: + cmd: + - run + +You may also declare your own variables inside the ``FORMULA``. If SPM doesn't +recognize them then it will ignore them, so there are no restrictions on +variable names, outside of avoiding reserved words. + +By default the renderer is set to ``yaml_jinja``. You may change this by +changing the ``renderer`` setting in the ``FORMULA`` itself. + Building a Package ------------------ Once a ``FORMULA`` file has been created, it is placed into the root of the diff --git a/salt/spm/__init__.py b/salt/spm/__init__.py index ce4bebe6de..b5edc1a451 100644 --- a/salt/spm/__init__.py +++ b/salt/spm/__init__.py @@ -20,6 +20,7 @@ import grp import sys # Import Salt libs +import salt.client import salt.config import salt.loader import salt.cache @@ -31,6 +32,7 @@ from salt.ext.six import string_types from salt.ext.six.moves import input from salt.ext.six.moves import zip from salt.ext.six.moves import filter +from salt.template import compile_template # Get logging started log = logging.getLogger(__name__) @@ -229,6 +231,10 @@ class SPMClient(object): if len(args) < 2: raise SPMInvocationError('A package must be specified') + caller_opts = self.opts.copy() + caller_opts['file_client'] = 'local' + self.caller = salt.client.Caller(mopts=caller_opts) + self.client = salt.client.get_local_client(self.opts['conf_file']) cache = salt.cache.Cache(self.opts) packages = args[1:] @@ -468,6 +474,22 @@ class SPMClient(object): # We've decided to install self._pkgdb_fun('register_pkg', pkg_name, formula_def, self.db_conn) + # Run the pre_local_state script, if present + if 'pre_local_state' in formula_def: + high_data = self._render(formula_def['pre_local_state'], formula_def) + ret = self.caller.cmd('state.high', data=high_data) + if 'pre_tgt_state' in formula_def: + log.debug('Executing pre_tgt_state script') + high_data = self._render(formula_def['pre_tgt_state']['data'], formula_def) + tgt = formula_def['pre_tgt_state']['tgt'] + ret = client.run_job( + tgt=formula_def['pre_tgt_state']['tgt'], + 'state.high', + tgt_type=formula_def['pre_tgt_state'].get('tgt_type', 'glob'), + timout=self.opts['timeout'], + data=high_data, + ) + # No defaults for this in config.py; default to the current running # user and group uid = self.opts.get('spm_uid', os.getuid()) @@ -505,6 +527,23 @@ class SPMClient(object): digest, self.db_conn) + # Run the post_local_state script, if present + if 'post_local_state' in formula_def: + log.debug('Executing post_local_state script') + high_data = self._render(formula_def['post_local_state'], formula_def) + self.caller.cmd('state.high', data=high_data) + if 'post_tgt_state' in formula_def: + log.debug('Executing post_tgt_state script') + high_data = self._render(formula_def['post_tgt_state']['data'], formula_def) + tgt = formula_def['post_tgt_state']['tgt'] + ret = client.run_job( + tgt=formula_def['post_tgt_state']['tgt'], + 'state.high', + tgt_type=formula_def['post_tgt_state'].get('tgt_type', 'glob'), + timout=self.opts['timeout'], + data=high_data, + ) + formula_tar.close() def _resolve_deps(self, formula_def): @@ -998,6 +1037,25 @@ class SPMClient(object): return None return member + def _render(self, data, formula_def): + ''' + Render a [pre|post]_local_state or [pre|post]_tgt_state script + ''' + # FORMULA can contain a renderer option + renderer = formula_def.get('renderer', self.opts.get('renderer', 'yaml_jinja')) + rend = salt.loader.render(self.opts, {}) + blacklist = self.opts.get('renderer_blacklist') + whitelist = self.opts.get('renderer_whitelist') + return compile_template( + ':string:', + rend, + renderer, + blacklist, + whitelist, + input_data=data, + **formula_def + ) + class SPMUserInterface(object): ''' From 4f51c67bee86591847c0de40e3c8f46c6f9c75e0 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 13:37:09 -0700 Subject: [PATCH 300/370] Add opts to the template vars --- salt/spm/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/salt/spm/__init__.py b/salt/spm/__init__.py index b5edc1a451..0b05be5079 100644 --- a/salt/spm/__init__.py +++ b/salt/spm/__init__.py @@ -1046,6 +1046,8 @@ class SPMClient(object): rend = salt.loader.render(self.opts, {}) blacklist = self.opts.get('renderer_blacklist') whitelist = self.opts.get('renderer_whitelist') + template_vars = formula_def.copy() + template_vars['opts'] = self.opts.copy() return compile_template( ':string:', rend, @@ -1053,7 +1055,7 @@ class SPMClient(object): blacklist, whitelist, input_data=data, - **formula_def + **template_vars ) From 56b8d44c261ca69f0d8165abce319512d7051f7f Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 15:43:51 -0700 Subject: [PATCH 301/370] Forgot to name a kwarg --- salt/spm/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/spm/__init__.py b/salt/spm/__init__.py index 0b05be5079..3d90f51193 100644 --- a/salt/spm/__init__.py +++ b/salt/spm/__init__.py @@ -484,7 +484,7 @@ class SPMClient(object): tgt = formula_def['pre_tgt_state']['tgt'] ret = client.run_job( tgt=formula_def['pre_tgt_state']['tgt'], - 'state.high', + fun='state.high', tgt_type=formula_def['pre_tgt_state'].get('tgt_type', 'glob'), timout=self.opts['timeout'], data=high_data, @@ -538,7 +538,7 @@ class SPMClient(object): tgt = formula_def['post_tgt_state']['tgt'] ret = client.run_job( tgt=formula_def['post_tgt_state']['tgt'], - 'state.high', + fun='state.high', tgt_type=formula_def['post_tgt_state'].get('tgt_type', 'glob'), timout=self.opts['timeout'], data=high_data, From bd2e1427adf4c6b752592c31870a42df05b8362f Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 17:13:28 -0700 Subject: [PATCH 302/370] Add cachedir to test --- tests/unit/test_spm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index f3790231c0..5f1edcc612 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -37,6 +37,7 @@ __opts__ = { 'force': False, 'verbose': False, 'cache': 'localfs', + 'cachedir': os.path.join(_TMP_SPM, 'cache'), 'spm_repo_dups': 'ignore', 'spm_share_dir': os.path.join(_TMP_SPM, 'share'), } From 829b5b3ab35d0a6bb5f7872bba927b00a0c97c72 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 28 Feb 2017 18:08:53 -0700 Subject: [PATCH 303/370] It's self.client now, not client --- salt/spm/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/spm/__init__.py b/salt/spm/__init__.py index 3d90f51193..1abf6fa535 100644 --- a/salt/spm/__init__.py +++ b/salt/spm/__init__.py @@ -482,7 +482,7 @@ class SPMClient(object): log.debug('Executing pre_tgt_state script') high_data = self._render(formula_def['pre_tgt_state']['data'], formula_def) tgt = formula_def['pre_tgt_state']['tgt'] - ret = client.run_job( + ret = self.client.run_job( tgt=formula_def['pre_tgt_state']['tgt'], fun='state.high', tgt_type=formula_def['pre_tgt_state'].get('tgt_type', 'glob'), @@ -536,7 +536,7 @@ class SPMClient(object): log.debug('Executing post_tgt_state script') high_data = self._render(formula_def['post_tgt_state']['data'], formula_def) tgt = formula_def['post_tgt_state']['tgt'] - ret = client.run_job( + ret = self.client.run_job( tgt=formula_def['post_tgt_state']['tgt'], fun='state.high', tgt_type=formula_def['post_tgt_state'].get('tgt_type', 'glob'), From 8b8320d56d24495b05de03528a690be76925c038 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Wed, 1 Mar 2017 07:19:30 -0700 Subject: [PATCH 304/370] Add renderer variable to tests --- tests/unit/test_spm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index 5f1edcc612..fd6ed90460 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -40,6 +40,9 @@ __opts__ = { 'cachedir': os.path.join(_TMP_SPM, 'cache'), 'spm_repo_dups': 'ignore', 'spm_share_dir': os.path.join(_TMP_SPM, 'share'), + 'renderer': 'yaml_jinja', + 'renderer_blacklist': [], + 'renderer_whitelist': [], } _F1 = { From 88a38d5ee92ce41bebe4c6a00c5da5c5d7077d1c Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Wed, 1 Mar 2017 11:42:05 -0700 Subject: [PATCH 305/370] Add id to test --- tests/unit/test_spm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index fd6ed90460..12ff4956b2 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -43,6 +43,7 @@ __opts__ = { 'renderer': 'yaml_jinja', 'renderer_blacklist': [], 'renderer_whitelist': [], + 'id': 'test', } _F1 = { From 320b39bc1251a4c845ca48c7caef00818b831e34 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 1 Mar 2017 11:57:28 -0700 Subject: [PATCH 306/370] Fix broken test and lint issue --- tests/unit/states/test_mongodb_user.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/states/test_mongodb_user.py b/tests/unit/states/test_mongodb_user.py index 82478ee2be..392b26898d 100644 --- a/tests/unit/states/test_mongodb_user.py +++ b/tests/unit/states/test_mongodb_user.py @@ -21,7 +21,7 @@ ensure_in_syspath('../../') from salt.states import mongodb_user mongodb_user.__salt__ = {} -mongodb_user.__opts__ = {} +mongodb_user.__opts__ = {'test': True} @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -69,7 +69,6 @@ class MongodbUserTestCase(TestCase): comt = ('User {0} has been created'.format(name)) ret.update({'comment': comt, 'result': True, 'changes': {name: 'Present'}}) - print ret self.assertDictEqual(mongodb_user.present(name, passwd), ret) # 'absent' function tests: 1 From 925eb7ffea09ca37426002ed9256b35cd547bf90 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Wed, 1 Mar 2017 12:56:23 -0700 Subject: [PATCH 307/370] Add environment to test --- tests/unit/test_spm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index 12ff4956b2..7adf1b6ce7 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -44,6 +44,7 @@ __opts__ = { 'renderer_blacklist': [], 'renderer_whitelist': [], 'id': 'test', + 'environment': None, } _F1 = { From 8058bbe6ca9311723826d482b0b51e01da4ec74a Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Wed, 1 Mar 2017 13:12:18 -0700 Subject: [PATCH 308/370] Just set all the default minion opts and be done with it --- tests/unit/test_spm.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index 7adf1b6ce7..58d9787aec 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -19,7 +19,9 @@ config = salt.config.minion_config(None) config['file_roots'] = {'base': [os.path.join(_TMP_SPM, 'salt')]} config['pillar_roots'] = {'base': [os.path.join(_TMP_SPM, 'pillar')]} -__opts__ = { +__opts__ = salt.config.DEFAULT_MINION_OPTS + +__opts__.update({ 'spm_logfile': os.path.join(_TMP_SPM, 'log'), 'spm_repos_config': os.path.join(_TMP_SPM, 'etc', 'spm.repos'), 'spm_cache_dir': os.path.join(_TMP_SPM, 'cache'), @@ -40,12 +42,7 @@ __opts__ = { 'cachedir': os.path.join(_TMP_SPM, 'cache'), 'spm_repo_dups': 'ignore', 'spm_share_dir': os.path.join(_TMP_SPM, 'share'), - 'renderer': 'yaml_jinja', - 'renderer_blacklist': [], - 'renderer_whitelist': [], - 'id': 'test', - 'environment': None, -} +}) _F1 = { 'definition': { From c557d76fe7641a0ccd3af0a6d783b6a8cd8031ad Mon Sep 17 00:00:00 2001 From: David Boucha Date: Wed, 1 Mar 2017 13:12:48 -0700 Subject: [PATCH 309/370] Add another example for a module.run state. ZD#1162 --- salt/states/module.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/salt/states/module.py b/salt/states/module.py index 686546832f..ee42a211a8 100644 --- a/salt/states/module.py +++ b/salt/states/module.py @@ -91,6 +91,23 @@ arguments. For example: delvol_on_destroy: 'True' } +Another example that creates a recurring task that runs a batch on a Windows +system: + +.. code-block:: yaml + + eventsviewer: + module.run: + - name: task.create_task + - m_name: 'events-viewer' + - user_name: System + - kwargs: { + action_type: 'Execute', + cmd: 'c:\netops\scripts\events_viewer.bat', + trigger_type: 'Daily', + start_date: '2017-1-20', + start_time: '11:59PM' + } ''' from __future__ import absolute_import From 560883c1097e42267f08ea7c96ee7b8637c9dc86 Mon Sep 17 00:00:00 2001 From: David Boucha Date: Wed, 1 Mar 2017 13:14:55 -0700 Subject: [PATCH 310/370] fix wording --- salt/states/module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/states/module.py b/salt/states/module.py index ee42a211a8..6f03851d19 100644 --- a/salt/states/module.py +++ b/salt/states/module.py @@ -91,8 +91,8 @@ arguments. For example: delvol_on_destroy: 'True' } -Another example that creates a recurring task that runs a batch on a Windows -system: +Another example that creates a recurring task that runs a batch file on a +Windows system: .. code-block:: yaml From 25b6d221c4cf897b27effc4b0fee589ff6e644cc Mon Sep 17 00:00:00 2001 From: twangboy Date: Fri, 24 Feb 2017 11:47:39 -0700 Subject: [PATCH 311/370] Fix ext_grains and ext_modules tests for Windows --- salt/loader.py | 17 +++-- tests/integration/loader/test_ext_grains.py | 15 ++++- tests/integration/loader/test_ext_modules.py | 15 +++++ tests/whitelist.txt | 66 ++++++++++---------- 4 files changed, 71 insertions(+), 42 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index 5eb5e8cb0f..c19e5881cf 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -653,17 +653,16 @@ def grains(opts, force_refresh=False, proxy=None): except (IOError, OSError): pass else: - if force_refresh: - log.debug('Grains refresh requested. Refreshing grains.') - else: - log.debug('Grains cache last modified {0} seconds ago and ' - 'cache expiration is set to {1}. ' - 'Grains cache expired. Refreshing.'.format( - grains_cache_age, - opts.get('grains_cache_expiration', 300) - )) + log.debug('Grains cache last modified {0} seconds ago and ' + 'cache expiration is set to {1}. ' + 'Grains cache expired. Refreshing.'.format( + grains_cache_age, + opts.get('grains_cache_expiration', 300) + )) else: log.debug('Grains cache file does not exist.') + else: + log.debug('Grains refresh requested. Refreshing grains.') if opts.get('skip_grains', False): return {} diff --git a/tests/integration/loader/test_ext_grains.py b/tests/integration/loader/test_ext_grains.py index 54b680b932..2868e2cec0 100644 --- a/tests/integration/loader/test_ext_grains.py +++ b/tests/integration/loader/test_ext_grains.py @@ -8,6 +8,8 @@ # Import Python libs from __future__ import absolute_import +import os +import time # Import Salt Testing libs from tests.support.unit import skipIf @@ -15,7 +17,6 @@ from tests.support.unit import skipIf # Import salt libs import tests.integration as integration from salt.config import minion_config - from salt.loader import grains @@ -30,6 +31,18 @@ class LoaderGrainsTest(integration.ModuleCase): # self.opts['grains'] = grains(self.opts) def test_grains_overwrite(self): + # To avoid a race condition on Windows, we need to make sure the + # `test_custom_grain2.py` file is present in the _grains directory + # before trying to get the grains. For some reason, the files aren't + # available immediately. + module = os.path.join(integration.TMP, 'rootdir', 'cache', 'files', + 'base', '_grains', 'test_custom_grain2.py') + tries = 0 + while not os.path.exists(module): + tries += 1 + if tries > 60: + break + time.sleep(1) grains = self.run_function('grains.items') # Check that custom grains are overwritten diff --git a/tests/integration/loader/test_ext_modules.py b/tests/integration/loader/test_ext_modules.py index 2f2854f2ad..763bc336ba 100644 --- a/tests/integration/loader/test_ext_modules.py +++ b/tests/integration/loader/test_ext_modules.py @@ -11,6 +11,8 @@ # Import Python libs from __future__ import absolute_import +import os +import time # Import Salt Testing libs import tests.integration as integration @@ -19,6 +21,19 @@ import tests.integration as integration class LoaderOverridesTest(integration.ModuleCase): def test_overridden_internal(self): + # To avoid a race condition on Windows, we need to make sure the + # `override_test.py` file is present in the _modules directory before + # trying to list all functions. For some reason, the files aren't copied + # over immediately. + module = os.path.join(integration.TMP, 'rootdir', 'cache', 'files', + 'base', '_modules', 'override_test.py') + tries = 0 + while not os.path.exists(module): + tries += 1 + if tries > 60: + break + time.sleep(1) + funcs = self.run_function('sys.list_functions') # We placed a test module under _modules. diff --git a/tests/whitelist.txt b/tests/whitelist.txt index 46e1373b7f..deaba55a07 100644 --- a/tests/whitelist.txt +++ b/tests/whitelist.txt @@ -1,35 +1,37 @@ -integration.client.runner -integration.client.standard -integration.fileserver.fileclient_test -integration.fileserver.roots_test -integration.loader.globals -integration.loader.interfaces -integration.loader.loader -integration.modules.aliases -integration.modules.beacons -integration.modules.config -integration.modules.cp -integration.modules.data -integration.modules.disk -integration.modules.git -integration.modules.grains -integration.modules.hosts -integration.modules.mine -integration.modules.pillar -integration.modules.pkg -integration.modules.publish -integration.modules.state -integration.modules.sysmod -integration.modules.test -integration.modules.useradd +integration.client.test_runner +integration.client.test_standard +integration.fileserver.test_fileclient +integration.fileserver.test_roots +integration.loader.test_ext_grains +integration.loader.test_ext_modules +integration.loader.test_globals +integration.loader.test_interfaces +integration.loader.test_loader +integration.modules.test_aliases +integration.modules.test_beacons +integration.modules.test_config +integration.modules.test_cp +integration.modules.test_data +integration.modules.test_disk +integration.modules.test_git +integration.modules.test_grains +integration.modules.test_hosts +integration.modules.test_mine +integration.modules.test_pillar +integration.modules.test_pkg +integration.modules.test_publish +integration.modules.test_state +integration.modules.test_sysmod +integration.modules.test_test +integration.modules.test_useradd integration.returners.test_librato_return integration.returners.test_local_cache -integration.runners.jobs -integration.runners.salt -integration.runners.winrepo +integration.runners.test_jobs +integration.runners.test_salt +integration.runners.test_winrepo integration.sdb.test_env -integration.states.host -integration.states.renderers -integration.utils.testprogram -integration.wheel.client -integration.wheel.key +integration.states.test_host +integration.states.test_renderers +integration.utils.test_testprogram +integration.wheel.test_client +integration.wheel.test_key From ad654abc202a4246d0df7396d11d2cbb251bacfb Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 1 Mar 2017 13:53:32 -0700 Subject: [PATCH 312/370] Clarify the reason for the while loop --- tests/integration/loader/test_ext_grains.py | 4 ++-- tests/integration/loader/test_ext_modules.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/loader/test_ext_grains.py b/tests/integration/loader/test_ext_grains.py index 2868e2cec0..89898759a2 100644 --- a/tests/integration/loader/test_ext_grains.py +++ b/tests/integration/loader/test_ext_grains.py @@ -33,8 +33,8 @@ class LoaderGrainsTest(integration.ModuleCase): def test_grains_overwrite(self): # To avoid a race condition on Windows, we need to make sure the # `test_custom_grain2.py` file is present in the _grains directory - # before trying to get the grains. For some reason, the files aren't - # available immediately. + # before trying to get the grains. This test may execute before the + # minion has finished syncing down the files it needs. module = os.path.join(integration.TMP, 'rootdir', 'cache', 'files', 'base', '_grains', 'test_custom_grain2.py') tries = 0 diff --git a/tests/integration/loader/test_ext_modules.py b/tests/integration/loader/test_ext_modules.py index 763bc336ba..2d1ded9b0e 100644 --- a/tests/integration/loader/test_ext_modules.py +++ b/tests/integration/loader/test_ext_modules.py @@ -23,8 +23,8 @@ class LoaderOverridesTest(integration.ModuleCase): def test_overridden_internal(self): # To avoid a race condition on Windows, we need to make sure the # `override_test.py` file is present in the _modules directory before - # trying to list all functions. For some reason, the files aren't copied - # over immediately. + # trying to list all functions. This test may execute before the + # minion has finished syncing down the files it needs. module = os.path.join(integration.TMP, 'rootdir', 'cache', 'files', 'base', '_modules', 'override_test.py') tries = 0 From bdb26ddf83ef226cef06995b6b9360e39ae570db Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Wed, 1 Mar 2017 16:09:13 -0700 Subject: [PATCH 313/370] Create master cache dir --- tests/unit/test_spm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/test_spm.py b/tests/unit/test_spm.py index 58d9787aec..86673d3d67 100644 --- a/tests/unit/test_spm.py +++ b/tests/unit/test_spm.py @@ -93,6 +93,9 @@ class SPMTest(TestCase): os.mkdir(_TMP_SPM) self.ui = SPMTestUserInterface() self.client = salt.spm.SPMClient(self.ui, __opts__) + master_cache = salt.config.DEFAULT_MASTER_OPTS['cachedir'] + if not os.path.exists(master_cache): + os.makedirs(master_cache) def tearDown(self): shutil.rmtree(_TMP_SPM, ignore_errors=True) From 7ef41155c0cca6e18486752969bb7ff52a6b3d0c Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 1 Mar 2017 17:57:23 -0700 Subject: [PATCH 314/370] Make win_file use the win_dacl salt util --- .../windows/windows-specific-behavior.rst | 6 - salt/modules/win_file.py | 606 +++++++++--------- salt/utils/win_dacl.py | 139 +++- 3 files changed, 424 insertions(+), 327 deletions(-) diff --git a/doc/topics/windows/windows-specific-behavior.rst b/doc/topics/windows/windows-specific-behavior.rst index 3fc429977c..ed4f712ecb 100644 --- a/doc/topics/windows/windows-specific-behavior.rst +++ b/doc/topics/windows/windows-specific-behavior.rst @@ -81,9 +81,3 @@ levels of symlinks (defaults to 64), an error is always raised. For some functions, this behavior is different to the behavior on Unix platforms. In general, avoid symlink loops on either platform. - - -Modifying security properties (ACLs) on files -============================================= -There is no support in Salt for modifying ACLs, and therefore no support for -changing file permissions, besides modifying the owner/user. diff --git a/salt/modules/win_file.py b/salt/modules/win_file.py index 84f9f46eaa..ead8a4fa3e 100644 --- a/salt/modules/win_file.py +++ b/salt/modules/win_file.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- ''' Manage information about files on the minion, set/read user, group -data +data, modify the ACL of files/directories :depends: - win32api - win32file - - win32security + - win32con + - salt.utils.win_dacl ''' from __future__ import absolute_import @@ -40,17 +41,6 @@ import salt.utils.atomicfile # do not remove, used in imported file.py function from salt.exceptions import CommandExecutionError, SaltInvocationError # pylint: enable=W0611 -# Import third party libs -try: - import win32api - import win32file - import win32security - import win32con - from pywintypes import error as pywinerror - HAS_WINDOWS_MODULES = True -except ImportError: - HAS_WINDOWS_MODULES = False - # Import salt libs import salt.utils from salt.modules.file import (check_hash, # pylint: disable=W0611 @@ -68,6 +58,14 @@ from salt.modules.file import (check_hash, # pylint: disable=W0611 from salt.utils import namespaced_function as _namespaced_function +HAS_WINDOWS_MODULES = False +if salt.utils.is_windows(): + import win32api + import win32file + import win32con + from pywintypes import error as pywinerror + HAS_WINDOWS_MODULES = True + HAS_WIN_DACL = False if salt.utils.is_windows(): import salt.utils.win_dacl @@ -195,92 +193,6 @@ def _resolve_symlink(path, max_depth=64): return path -def _change_privilege_state(privilege_name, enable): - ''' - Change the state, either enable or disable, of the named privilege for this - process. - - If the change fails, an exception will be raised. If successful, it returns - True. - ''' - log.debug( - '{0} the privilege {1} for this process.'.format( - 'Enabling' if enable else 'Disabling', - privilege_name - ) - ) - # this is a pseudo-handle that doesn't need to be closed - hProc = win32api.GetCurrentProcess() - hToken = None - try: - hToken = win32security.OpenProcessToken( - hProc, - win32security.TOKEN_QUERY | win32security.TOKEN_ADJUST_PRIVILEGES - ) - privilege = win32security.LookupPrivilegeValue(None, privilege_name) - if enable: - privilege_attrs = win32security.SE_PRIVILEGE_ENABLED - else: - # a value of 0 disables a privilege (there's no constant for it) - privilege_attrs = 0 - - # check that the handle has the requested privilege - token_privileges = dict(win32security.GetTokenInformation( - hToken, win32security.TokenPrivileges)) - if privilege not in token_privileges: - if enable: - raise SaltInvocationError( - 'The requested privilege {0} is not available for this ' - 'process (check Salt user privileges).'.format(privilege_name)) - else: # disable a privilege this process does not have - log.debug( - 'Cannot disable privilege {0} because this process ' - 'does not have that privilege.'.format(privilege_name) - ) - return True - else: - # check if the privilege is already in the requested state - if token_privileges[privilege] == privilege_attrs: - log.debug( - 'The requested privilege {0} is already in the ' - 'requested state.'.format(privilege_name) - ) - return True - - changes = win32security.AdjustTokenPrivileges( - hToken, - False, - [(privilege, privilege_attrs)] - ) - finally: - if hToken: - win32api.CloseHandle(hToken) - - if not bool(changes): - raise SaltInvocationError( - 'Could not {0} the {1} privilege for this process'.format( - 'enable' if enable else 'remove', - privilege_name - ) - ) - else: - return True - - -def _enable_privilege(privilege_name): - ''' - Enables the named privilege for this process. - ''' - return _change_privilege_state(privilege_name, True) - - -def _disable_privilege(privilege_name): - ''' - Disables the named privilege for this process. - ''' - return _change_privilege_state(privilege_name, False) - - def gid_to_group(gid): ''' Convert the group id to the group name on this system @@ -293,6 +205,12 @@ def gid_to_group(gid): instead; an info level log entry will be generated if this function is used directly. + Args: + gid (str): The gid of the group + + Returns: + str: The name of the group + CLI Example: .. code-block:: bash @@ -319,6 +237,12 @@ def group_to_gid(group): instead; an info level log entry will be generated if this function is used directly. + Args: + group (str): The name of the group + + Returns: + str: The gid of the group + CLI Example: .. code-block:: bash @@ -330,7 +254,10 @@ def group_to_gid(group): log.info('The function {0} should not be used on Windows systems; ' 'see function docs for details.'.format(func_name)) - return _user_to_uid(group) + if group is None: + return '' + + return salt.utils.win_dacl.get_sid_string(group) def get_pgid(path, follow_symlinks=True): @@ -344,6 +271,16 @@ def get_pgid(path, follow_symlinks=True): Ensure you know what you are doing before using this function. + Args: + path (str): The path to the file or directory + + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + str: The gid of the primary group + CLI Example: .. code-block:: bash @@ -351,7 +288,7 @@ def get_pgid(path, follow_symlinks=True): salt '*' file.get_pgid c:\\temp\\test.txt ''' if not os.path.exists(path): - return False + raise CommandExecutionError('Path not found: {0}'.format(path)) # Under Windows, if the path is a symlink, the user that owns the symlink is # returned, not the user that owns the file/directory the symlink is @@ -361,25 +298,8 @@ def get_pgid(path, follow_symlinks=True): if follow_symlinks and sys.getwindowsversion().major >= 6: path = _resolve_symlink(path) - try: - secdesc = win32security.GetFileSecurity( - path, win32security.GROUP_SECURITY_INFORMATION - ) - # Not all filesystems mountable within windows - # have SecurityDescriptor's. For instance, some mounted - # SAMBA shares, or VirtualBox's shared folders. If we - # can't load a file descriptor for the file, we default - # to "Everyone" - http://support.microsoft.com/kb/243330 - except MemoryError: - # generic memory error (win2k3+) - return 'S-1-1-0' - except pywinerror as exc: - # Incorrect function error (win2k8+) - if exc.winerror == 1 or exc.winerror == 50: - return 'S-1-1-0' - raise - group_sid = secdesc.GetSecurityDescriptorGroup() - return win32security.ConvertSidToStringSid(group_sid) + group_name = salt.utils.win_dacl.get_primary_group(path) + return salt.utils.win_dacl.get_sid_string(group_name) def get_pgroup(path, follow_symlinks=True): @@ -398,6 +318,16 @@ def get_pgroup(path, follow_symlinks=True): means no value was returned. To be certain, use the `get_pgid` function which will return the SID, including for the system 'None' group. + Args: + path (str): The path to the file or directory + + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + str: The name of the primary group + CLI Example: .. code-block:: bash @@ -426,6 +356,16 @@ def get_gid(path, follow_symlinks=True): If you do actually want to access the 'primary group' of a file, use `file.get_pgid`. + Args: + path (str): The path to the file or directory + + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + str: The gid of the owner + CLI Example: .. code-block:: bash @@ -460,6 +400,16 @@ def get_group(path, follow_symlinks=True): If you do actually want to access the 'primary group' of a file, use `file.get_pgroup`. + Args: + path (str): The path to the file or directory + + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + str: The name of the owner + CLI Example: .. code-block:: bash @@ -479,6 +429,12 @@ def uid_to_user(uid): ''' Convert a uid to a user name + Args: + uid (str): The user id to lookup + + Returns: + str: The name of the user + CLI Example: .. code-block:: bash @@ -488,24 +444,19 @@ def uid_to_user(uid): if uid is None or uid == '': return '' - sid = win32security.GetBinarySid(uid) - try: - name, domain, account_type = win32security.LookupAccountSid(None, sid) - return name - except pywinerror as exc: - # if user does not exist... - # 1332 = No mapping between account names and security IDs was carried - # out. - if exc.winerror == 1332: - return '' - else: - raise + return salt.utils.win_dacl.get_name(uid) def user_to_uid(user): ''' Convert user name to a uid + Args: + user (str): The user to lookup + + Returns: + str: The user id of the user + CLI Example: .. code-block:: bash @@ -514,28 +465,8 @@ def user_to_uid(user): ''' if user is None: user = salt.utils.get_user() - return _user_to_uid(user) - -def _user_to_uid(user): - ''' - Convert user name to a uid - ''' - if user is None or user == '': - return '' - - try: - sid, domain, account_type = win32security.LookupAccountName(None, user) - except pywinerror as exc: - # if user does not exist... - # 1332 = No mapping between account names and security IDs was carried - # out. - if exc.winerror == 1332: - return '' - else: - raise - - return win32security.ConvertSidToStringSid(sid) + return salt.utils.win_dacl.get_sid_string(user) def get_uid(path, follow_symlinks=True): @@ -545,6 +476,17 @@ def get_uid(path, follow_symlinks=True): Symlinks are followed by default to mimic Unix behavior. Specify `follow_symlinks=False` to turn off this behavior. + Args: + path (str): The path to the file or directory + + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + str: The uid of the owner + + CLI Example: .. code-block:: bash @@ -553,7 +495,7 @@ def get_uid(path, follow_symlinks=True): salt '*' file.get_uid c:\\temp\\test.txt follow_symlinks=False ''' if not os.path.exists(path): - return False + raise CommandExecutionError('Path not found: {0}'.format(path)) # Under Windows, if the path is a symlink, the user that owns the symlink is # returned, not the user that owns the file/directory the symlink is @@ -562,20 +504,9 @@ def get_uid(path, follow_symlinks=True): # supported on Windows Vista or later. if follow_symlinks and sys.getwindowsversion().major >= 6: path = _resolve_symlink(path) - try: - secdesc = win32security.GetFileSecurity( - path, win32security.OWNER_SECURITY_INFORMATION - ) - except MemoryError: - # generic memory error (win2k3+) - return 'S-1-1-0' - except pywinerror as exc: - # Incorrect function error (win2k8+) - if exc.winerror == 1 or exc.winerror == 50: - return 'S-1-1-0' - raise - owner_sid = secdesc.GetSecurityDescriptorOwner() - return win32security.ConvertSidToStringSid(owner_sid) + + owner_sid = salt.utils.win_dacl.get_owner(path) + return salt.utils.win_dacl.get_sid_string(owner_sid) def get_user(path, follow_symlinks=True): @@ -585,6 +516,17 @@ def get_user(path, follow_symlinks=True): Symlinks are followed by default to mimic Unix behavior. Specify `follow_symlinks=False` to turn off this behavior. + Args: + path (str): The path to the file or directory + + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + str: The name of the owner + + CLI Example: .. code-block:: bash @@ -592,7 +534,18 @@ def get_user(path, follow_symlinks=True): salt '*' file.get_user c:\\temp\\test.txt salt '*' file.get_user c:\\temp\\test.txt follow_symlinks=False ''' - return uid_to_user(get_uid(path, follow_symlinks)) + if not os.path.exists(path): + raise CommandExecutionError('Path not found: {0}'.format(path)) + + # Under Windows, if the path is a symlink, the user that owns the symlink is + # returned, not the user that owns the file/directory the symlink is + # pointing to. This behavior is *different* to *nix, therefore the symlink + # is first resolved manually if necessary. Remember symlinks are only + # supported on Windows Vista or later. + if follow_symlinks and sys.getwindowsversion().major >= 6: + path = _resolve_symlink(path) + + return salt.utils.win_dacl.get_owner(path) def get_mode(path): @@ -602,6 +555,12 @@ def get_mode(path): Right now we're just returning None because Windows' doesn't have a mode like Linux + Args: + path (str): The path to the file or directory + + Returns: + None + CLI Example: .. code-block:: bash @@ -609,7 +568,7 @@ def get_mode(path): salt '*' file.get_mode /etc/passwd ''' if not os.path.exists(path): - return '' + raise CommandExecutionError('Path not found: {0}'.format(path)) func_name = '{0}.get_mode'.format(__virtualname__) if __opts__.get('fun', '') == func_name: @@ -639,6 +598,15 @@ def lchown(path, user, group=None, pgroup=None): Otherwise Salt will interpret it as the Python value of None and no primary group changes will occur. See the example below. + Args: + path (str): The path to the file or directory + user (str): The name of the user to own the file + group (str): The group (not used) + pgroup (str): The primary group to assign + + Returns: + bool: True if successful, otherwise error + CLI Example: .. code-block:: bash @@ -650,13 +618,11 @@ def lchown(path, user, group=None, pgroup=None): if group: func_name = '{0}.lchown'.format(__virtualname__) if __opts__.get('fun', '') == func_name: - log.info('The group parameter has no effect when using {0} on Windows ' - 'systems; see function docs for details.'.format(func_name)) - log.debug( - 'win_file.py {0} Ignoring the group parameter for {1}'.format( - func_name, path - ) - ) + log.info('The group parameter has no effect when using {0} on ' + 'Windows systems; see function docs for details.' + ''.format(func_name)) + log.debug('win_file.py {0} Ignoring the group parameter for {1}' + ''.format(func_name, path)) group = None return chown(path, user, group, pgroup, follow_symlinks=False) @@ -676,9 +642,17 @@ def chown(path, user, group=None, pgroup=None, follow_symlinks=True): If you do want to change the 'primary group' property and understand the implications, pass the Windows only parameter, pgroup, instead. - To set the primary group to 'None', it must be specified in quotes. - Otherwise Salt will interpret it as the Python value of None and no primary - group changes will occur. See the example below. + Args: + path (str): The path to the file or directory + user (str): The name of the user to own the file + group (str): The group (not used) + pgroup (str): The primary group to assign + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + bool: True if successful, otherwise error CLI Example: @@ -689,72 +663,26 @@ def chown(path, user, group=None, pgroup=None, follow_symlinks=True): salt '*' file.chown c:\\temp\\test.txt myusername "pgroup='None'" ''' # the group parameter is not used; only provided for API compatibility - if group: + if group is not None: func_name = '{0}.chown'.format(__virtualname__) if __opts__.get('fun', '') == func_name: - log.info('The group parameter has no effect when using {0} on Windows ' - 'systems; see function docs for details.'.format(func_name)) - log.debug( - 'win_file.py {0} Ignoring the group parameter for {1}'.format( - func_name, path - ) - ) - group = None - - err = '' - # get SID object for user - try: - userSID, domainName, objectType = win32security.LookupAccountName(None, user) - except pywinerror: - err += 'User does not exist\n' - - if pgroup: - # get SID object for group - try: - groupSID, domainName, objectType = win32security.LookupAccountName(None, pgroup) - except pywinerror: - err += 'Group does not exist\n' - else: - groupSID = None - - if not os.path.exists(path): - err += 'File not found' - if err: - return err + log.info('The group parameter has no effect when using {0} on ' + 'Windows systems; see function docs for details.' + ''.format(func_name)) + log.debug('win_file.py {0} Ignoring the group parameter for {1}' + ''.format(func_name, path)) if follow_symlinks and sys.getwindowsversion().major >= 6: path = _resolve_symlink(path) - privilege_enabled = False - try: - privilege_enabled = _enable_privilege(win32security.SE_RESTORE_NAME) - if pgroup: - # set owner and group - win32security.SetNamedSecurityInfo( - path, - win32security.SE_FILE_OBJECT, - win32security.OWNER_SECURITY_INFORMATION + win32security.GROUP_SECURITY_INFORMATION, - userSID, - groupSID, - None, - None - ) - else: - # set owner only - win32security.SetNamedSecurityInfo( - path, - win32security.SE_FILE_OBJECT, - win32security.OWNER_SECURITY_INFORMATION, - userSID, - None, - None, - None - ) - finally: - if privilege_enabled: - _disable_privilege(win32security.SE_RESTORE_NAME) + if not os.path.exists(path): + raise CommandExecutionError('Path not found: {0}'.format(path)) - return None + salt.utils.win_dacl.set_owner(path, user) + if pgroup: + salt.utils.win_dacl.set_primary_group(path, pgroup) + + return True def chpgrp(path, group): @@ -768,9 +696,12 @@ def chpgrp(path, group): Ensure you know what you are doing before using this function. - To set the primary group to 'None', it must be specified in quotes. - Otherwise Salt will interpret it as the Python value of None and no primary - group changes will occur. See the example below. + Args: + path (str): The path to the file or directory + pgroup (str): The primary group to assign + + Returns: + bool: True if successful, otherwise error CLI Example: @@ -779,42 +710,7 @@ def chpgrp(path, group): salt '*' file.chpgrp c:\\temp\\test.txt Administrators salt '*' file.chpgrp c:\\temp\\test.txt "'None'" ''' - if group is None: - raise SaltInvocationError("The group value was specified as None and " - "is invalid. If you mean the built-in None " - "group, specify the group in lowercase, e.g. " - "'none'.") - - err = '' - # get SID object for group - try: - groupSID, domainName, objectType = win32security.LookupAccountName(None, group) - except pywinerror: - err += 'Group does not exist\n' - - if not os.path.exists(path): - err += 'File not found\n' - if err: - return err - - # set group - privilege_enabled = False - try: - privilege_enabled = _enable_privilege(win32security.SE_RESTORE_NAME) - win32security.SetNamedSecurityInfo( - path, - win32security.SE_FILE_OBJECT, - win32security.GROUP_SECURITY_INFORMATION, - None, - groupSID, - None, - None - ) - finally: - if privilege_enabled: - _disable_privilege(win32security.SE_RESTORE_NAME) - - return None + return salt.utils.win_dacl.set_primary_group(path, group) def chgrp(path, group): @@ -833,8 +729,17 @@ def chgrp(path, group): this function is superfluous and will generate an info level log entry if used directly. - If you do actually want to set the 'primary group' of a file, use `file - .chpgrp`. + If you do actually want to set the 'primary group' of a file, use ``file + .chpgrp``. + + To set group permissions use ``file.set_perms`` + + Args: + path (str): The path to the file or directory + group (str): The group (unused) + + Returns: + None CLI Example: @@ -866,18 +771,31 @@ def stats(path, hash_type='sha256', follow_symlinks=True): compatibility with Unix behavior. If the 'primary group' is required, it can be accessed in the `pgroup` and `pgid` properties. + Args: + path (str): The path to the file or directory + hash_type (str): The type of hash to return + follow_symlinks (bool): + If the object specified by ``path`` is a symlink, get attributes of + the linked file instead of the symlink itself. Default is True + + Returns: + dict: A dictionary of file/directory stats + CLI Example: .. code-block:: bash salt '*' file.stats /etc/passwd ''' - ret = {} if not os.path.exists(path): - return ret + raise CommandExecutionError('Path not found: {0}'.format(path)) + if follow_symlinks and sys.getwindowsversion().major >= 6: path = _resolve_symlink(path) + pstat = os.stat(path) + + ret = {} ret['inode'] = pstat.st_ino # don't need to resolve symlinks again because we've already done that ret['uid'] = get_uid(path, follow_symlinks=False) @@ -918,17 +836,20 @@ def get_attributes(path): Return a dictionary object with the Windows file attributes for a file. + Args: + path (str): The path to the file or directory + + Returns: + dict: A dictionary of file attributes + CLI Example: .. code-block:: bash salt '*' file.get_attributes c:\\temp\\a.txt ''' - err = '' if not os.path.exists(path): - err += 'File not found\n' - if err: - return err + raise CommandExecutionError('Path not found: {0}'.format(path)) # set up dictionary for attribute values attributes = {} @@ -979,6 +900,21 @@ def set_attributes(path, archive=None, hidden=None, normal=None, Set file attributes for a file. Note that the normal attribute means that all others are false. So setting it will clear all others. + Args: + path (str): The path to the file or directory + archive (bool): Sets the archive attribute. Default is None + hidden (bool): Sets the hidden attribute. Default is None + normal (bool): + Resets the file attributes. Cannot be used in conjunction with any + other attribute. Default is None + notIndexed (bool): Sets the indexed attribute. Default is None + readonly (bool): Sets the readonly attribute. Default is None + system (bool): Sets the system attribute. Default is None + temporary (bool): Sets the temporary attribute. Default is None + + Returns: + bool: True if successful, otherwise False + CLI Example: .. code-block:: bash @@ -986,18 +922,19 @@ def set_attributes(path, archive=None, hidden=None, normal=None, salt '*' file.set_attributes c:\\temp\\a.txt normal=True salt '*' file.set_attributes c:\\temp\\a.txt readonly=True hidden=True ''' - err = '' if not os.path.exists(path): - err += 'File not found\n' + raise CommandExecutionError('Path not found: {0}'.format(path)) + if normal: if archive or hidden or notIndexed or readonly or system or temporary: - err += 'Normal attribute may not be used with any other attributes\n' - else: - return win32file.SetFileAttributes(path, 128) - if err: - return err + raise CommandExecutionError( + 'Normal attribute may not be used with any other attributes') + ret = win32file.SetFileAttributes(path, 128) + return True if ret is None else False + # Get current attributes intAttributes = win32file.GetFileAttributes(path) + # individually set or clear bits for appropriate attributes if archive is not None: if archive: @@ -1029,7 +966,9 @@ def set_attributes(path, archive=None, hidden=None, normal=None, intAttributes |= 0x100 else: intAttributes &= 0xFEFF - return win32file.SetFileAttributes(path, intAttributes) + + ret = win32file.SetFileAttributes(path, intAttributes) + return True if ret is None else False def set_mode(path, mode): @@ -1039,6 +978,13 @@ def set_mode(path, mode): This just calls get_mode, which returns None because we don't use mode on Windows + Args: + path: The path to the file or directory + mode: The mode (not used) + + Returns: + None + CLI Example: .. code-block:: bash @@ -1058,12 +1004,12 @@ def remove(path, force=False): ''' Remove the named file or directory - :param str path: The path to the file or directory to remove. + Args: + path (str): The path to the file or directory to remove. + force (bool): Remove even if marked Read-Only. Default is False - :param bool force: Remove even if marked Read-Only - - :return: True if successful, False if unsuccessful - :rtype: bool + Returns: + bool: True if successful, False if unsuccessful CLI Example: @@ -1079,7 +1025,7 @@ def remove(path, force=False): # Does the file/folder exists if not os.path.exists(path): - return 'File/Folder not found: {0}'.format(path) + raise CommandExecutionError('Path not found: {0}'.format(path)) if not os.path.isabs(path): raise SaltInvocationError('File path must be absolute.') @@ -1127,6 +1073,13 @@ def symlink(src, link): exception - invalid symlinks cannot be created. The source path must exist. If it doesn't, an error will be raised. + Args: + src (str): The path to a file or directory + link (str): The path to the link + + Returns: + bool: True if successful, otherwise False + CLI Example: .. code-block:: bash @@ -1191,6 +1144,12 @@ def is_link(path): is not a symlink, however, the error raised will be a SaltInvocationError, not an OSError. + Args: + path (str): The path to a file or directory + + Returns: + bool: True if path is a symlink, otherwise False + CLI Example: .. code-block:: bash @@ -1281,6 +1240,12 @@ def readlink(path): not a symlink, however, the error raised will be a SaltInvocationError, not an OSError. + Args: + path (str): The path to the symlink + + Returns: + str: The path that the symlink points to + CLI Example: .. code-block:: bash @@ -1954,30 +1919,37 @@ def set_perms(path, grant_perms=None, deny_perms=None, inheritance=True): path (str): The full path to the directory. - grant_perms (dict): A dictionary containing the user/group and the basic - permissions to grant, ie: ``{'user': {'perms': 'basic_permission'}}``. - You can also set the ``applies_to`` setting here. The default is - ``this_folder_subfolders_files``. Specify another ``applies_to`` setting - like this: + grant_perms (dict): + A dictionary containing the user/group and the basic permissions to + grant, ie: ``{'user': {'perms': 'basic_permission'}}``. You can also + set the ``applies_to`` setting here. The default is + ``this_folder_subfolders_files``. Specify another ``applies_to`` + setting like this: - .. code-block:: yaml + .. code-block:: yaml - {'user': {'perms': 'full_control', 'applies_to': 'this_folder'}} + {'user': {'perms': 'full_control', 'applies_to': 'this_folder'}} - To set advanced permissions use a list for the ``perms`` parameter, ie: + To set advanced permissions use a list for the ``perms`` parameter, + ie: - .. code-block:: yaml + .. code-block:: yaml - {'user': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder'}} + {'user': {'perms': ['read_attributes', 'read_ea'], 'applies_to': 'this_folder'}} - deny_perms (dict): A dictionary containing the user/group and - permissions to deny along with the ``applies_to`` setting. Use the same - format used for the ``grant_perms`` parameter. Remember, deny - permissions supersede grant permissions. + To see a list of available attributes and applies to settings see + the documentation for salt.utils.win_dacl - inheritance (bool): If True the object will inherit permissions from the - parent, if False, inheritance will be disabled. Inheritance setting will - not apply to parent directories if they must be created + deny_perms (dict): + A dictionary containing the user/group and permissions to deny along + with the ``applies_to`` setting. Use the same format used for the + ``grant_perms`` parameter. Remember, deny permissions supersede + grant permissions. + + inheritance (bool): + If True the object will inherit permissions from the parent, if + False, inheritance will be disabled. Inheritance setting will not + apply to parent directories if they must be created Returns: bool: True if successful, otherwise raise an error diff --git a/salt/utils/win_dacl.py b/salt/utils/win_dacl.py index 02b1c6892e..ccee233a01 100644 --- a/salt/utils/win_dacl.py +++ b/salt/utils/win_dacl.py @@ -1142,14 +1142,70 @@ def get_owner(obj_name): salt.utils.win_dacl.get_owner('c:\\file') ''' - # Return owner - security_descriptor = win32security.GetFileSecurity( - obj_name, win32security.OWNER_SECURITY_INFORMATION) - owner_sid = security_descriptor.GetSecurityDescriptorOwner() + # Not all filesystems mountable within windows have SecurityDescriptors. + # For instance, some mounted SAMBA shares, or VirtualBox shared folders. If + # we can't load a file descriptor for the file, we default to "None" + # http://support.microsoft.com/kb/243330 + try: + security_descriptor = win32security.GetFileSecurity( + obj_name, win32security.OWNER_SECURITY_INFORMATION) + owner_sid = security_descriptor.GetSecurityDescriptorOwner() + + except MemoryError: + # Generic Memory Error (Windows Server 2003+) + owner_sid = 'S-1-1-0' + + except pywintypes.error as exc: + # Incorrect function error (Windows Server 2008+) + if exc.winerror == 1 or exc.winerror == 50: + owner_sid = 'S-1-1-0' + else: + raise CommandExecutionError( + 'Failed to set permissions: {0}'.format(exc[2])) return get_name(win32security.ConvertSidToStringSid(owner_sid)) +def get_primary_group(obj_name): + ''' + Gets the primary group of the passed object + + Args: + obj_name (str): The path for which to obtain primary group information + + Returns: + str: The primary group for the object + + Usage: + + .. code-block:: python + + salt.utils.win_dacl.get_primary_group('c:\\file') + ''' + # Not all filesystems mountable within windows have SecurityDescriptors. + # For instance, some mounted SAMBA shares, or VirtualBox shared folders. If + # we can't load a file descriptor for the file, we default to "Everyone" + # http://support.microsoft.com/kb/243330 + try: + security_descriptor = win32security.GetFileSecurity( + obj_name, win32security.GROUP_SECURITY_INFORMATION) + primary_group_gid = security_descriptor.GetSecurityDescriptorGroup() + + except MemoryError: + # Generic Memory Error (Windows Server 2003+) + primary_group_gid = 'S-1-1-0' + + except pywintypes.error as exc: + # Incorrect function error (Windows Server 2008+) + if exc.winerror == 1 or exc.winerror == 50: + primary_group_gid = 'S-1-1-0' + else: + raise CommandExecutionError( + 'Failed to set permissions: {0}'.format(exc[2])) + + return get_name(win32security.ConvertSidToStringSid(primary_group_gid)) + + def set_owner(obj_name, principal, obj_type='file'): ''' Set the owner of an object. This can be a file, folder, registry key, @@ -1216,6 +1272,81 @@ def set_owner(obj_name, principal, obj_type='file'): return True +def set_primary_group(obj_name, principal, obj_type='file'): + ''' + Set the primary group of an object. This can be a file, folder, registry + key, printer, service, etc... + + Args: + + obj_name (str): + The object for which to set primary group. This can be the path to a + file or folder, a registry key, printer, etc. For more information + about how to format the name see: + + https://msdn.microsoft.com/en-us/library/windows/desktop/aa379593(v=vs.85).aspx + + principal (str): + The name of the group to make primary for the object. Can also pass + a SID. + + obj_type (Optional[str]): + The type of object for which to set the primary group. + + Returns: + bool: True if successful, raises an error otherwise + + Usage: + + .. code-block:: python + + salt.utils.win_dacl.set_primary_group('C:\\MyDirectory', 'Administrators', 'file') + ''' + # Windows has the concept of a group called 'None'. It is the default group + # for all Objects. If the user passes None, assume 'None' + if principal is None: + principal = 'None' + + gid = get_sid(principal) + + obj_flags = flags() + + # To set the owner to something other than the logged in user requires + # SE_TAKE_OWNERSHIP_NAME and SE_RESTORE_NAME privileges + # Enable them for the logged in user + # Setup the privilege set + new_privs = set() + luid = win32security.LookupPrivilegeValue('', 'SeTakeOwnershipPrivilege') + new_privs.add((luid, win32con.SE_PRIVILEGE_ENABLED)) + luid = win32security.LookupPrivilegeValue('', 'SeRestorePrivilege') + new_privs.add((luid, win32con.SE_PRIVILEGE_ENABLED)) + + # Get the current token + p_handle = win32api.GetCurrentProcess() + t_handle = win32security.OpenProcessToken( + p_handle, + win32security.TOKEN_ALL_ACCESS | win32con.TOKEN_ADJUST_PRIVILEGES) + + # Enable the privileges + win32security.AdjustTokenPrivileges(t_handle, 0, new_privs) + + # Set the user + try: + win32security.SetNamedSecurityInfo( + obj_name, + obj_flags.obj_type[obj_type], + obj_flags.element['group'], + None, gid, None, None) + except pywintypes.error as exc: + log.debug( + 'Failed to make {0} the primary group: {1}' + ''.format(principal, exc[2])) + raise CommandExecutionError( + 'Failed to set primary group: {0}'.format(exc[2])) + + return True + + def set_permissions(obj_name, principal, permissions, From 7992df44b6a6907b77d79011f04d89dcfaefef07 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 1 Mar 2017 19:57:13 -0700 Subject: [PATCH 315/370] Repr comment --- salt/states/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/module.py b/salt/states/module.py index 6f03851d19..04c6d7fd1c 100644 --- a/salt/states/module.py +++ b/salt/states/module.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -''' +r''' Execution of Salt modules from within states ============================================ From 7ebf1cf10416a9e9a2813aa366c82c758a1237b1 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Thu, 2 Mar 2017 05:17:42 -0700 Subject: [PATCH 316/370] Fix paths from SPM files PR --- salt/syspaths.py | 1 + setup.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/salt/syspaths.py b/salt/syspaths.py index bebc2eab9d..9145fff260 100644 --- a/salt/syspaths.py +++ b/salt/syspaths.py @@ -139,6 +139,7 @@ if SPM_REACTOR_PATH is None: __all__ = [ 'ROOT_DIR', + 'SHARE_DIR', 'CONFIG_DIR', 'CACHE_DIR', 'SOCK_DIR', diff --git a/setup.py b/setup.py index 202ae02cc0..467d50aa34 100755 --- a/setup.py +++ b/setup.py @@ -215,6 +215,7 @@ class GenerateSaltSyspaths(Command): INSTALL_SYSPATHS_TEMPLATE.format( date=DATE, root_dir=self.distribution.salt_root_dir, + share_dir=self.distribution.salt_share_dir, config_dir=self.distribution.salt_config_dir, cache_dir=self.distribution.salt_cache_dir, sock_dir=self.distribution.salt_sock_dir, @@ -703,6 +704,7 @@ INSTALL_SYSPATHS_TEMPLATE = '''\ {date:%A, %d %B %Y @ %H:%m:%S UTC}. ROOT_DIR = {root_dir!r} +SHARE_DIR = {share_dir!r} CONFIG_DIR = {config_dir!r} CACHE_DIR = {cache_dir!r} SOCK_DIR = {sock_dir!r} @@ -864,6 +866,7 @@ class SaltDistribution(distutils.dist.Distribution): # Salt Paths Configuration Settings self.salt_root_dir = None + self.salt_share_dir = None self.salt_config_dir = None self.salt_cache_dir = None self.salt_sock_dir = None From 829f7008f187aecf3be29c91d5fa4b775bf3107c Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Thu, 2 Mar 2017 05:27:20 -0700 Subject: [PATCH 317/370] Fill in a couple more spots --- pkg/smartos/esky/_syspaths.py | 1 + setup.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pkg/smartos/esky/_syspaths.py b/pkg/smartos/esky/_syspaths.py index 3eb52474a2..365229690b 100644 --- a/pkg/smartos/esky/_syspaths.py +++ b/pkg/smartos/esky/_syspaths.py @@ -11,6 +11,7 @@ elif __file__: ROOT_DIR=application_path.split("bin/appdata")[0] # Copied from syspaths.py +SHARE_DIR = os.path.join(ROOT_DIR, 'usr', 'share', 'salt') CONFIG_DIR = os.path.join(ROOT_DIR, 'etc') CACHE_DIR = os.path.join(ROOT_DIR, 'var', 'cache', 'salt') SOCK_DIR = os.path.join(ROOT_DIR, 'var', 'run', 'salt') diff --git a/setup.py b/setup.py index 467d50aa34..bd00e9697a 100755 --- a/setup.py +++ b/setup.py @@ -832,6 +832,8 @@ class SaltDistribution(distutils.dist.Distribution): # Salt's Paths Configuration Settings ('salt-root-dir=', None, 'Salt\'s pre-configured root directory'), + ('salt-share-dir=', None, + 'Salt\'s pre-configured share directory'), ('salt-config-dir=', None, 'Salt\'s pre-configured configuration directory'), ('salt-cache-dir=', None, From 9711f65d7034f7da0263ffc8f9fae98d465ff1d5 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 15:23:35 +0000 Subject: [PATCH 318/370] Try to reduce memory consumption during full test runs --- tests/support/parser/__init__.py | 58 +++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/tests/support/parser/__init__.py b/tests/support/parser/__init__.py index 8c2b359b29..8f68263f8d 100644 --- a/tests/support/parser/__init__.py +++ b/tests/support/parser/__init__.py @@ -26,6 +26,7 @@ import subprocess import warnings from functools import partial from contextlib import closing +from collections import namedtuple from tests.support import helpers from tests.support.unit import TestLoader, TextTestRunner @@ -74,6 +75,9 @@ def __global_logging_exception_handler(exc_type, exc_value, exc_traceback): # Set our own exception handler as the one to use sys.excepthook = __global_logging_exception_handler +TestsuiteResult = namedtuple('TestsuiteResult', ['header', 'errors', 'skipped', 'failures', 'passed']) +TestResult = namedtuple('TestResult', ['id', 'reason']) + def print_header(header, sep='~', top=True, bottom=True, inline=False, centered=False, width=PNUM): @@ -490,13 +494,31 @@ class SaltTestingParser(optparse.OptionParser): output=self.xml_output_dir, verbosity=self.options.verbosity ).run(tests) - self.testsuite_results.append((header, runner)) else: runner = TextTestRunner( stream=sys.stdout, verbosity=self.options.verbosity).run(tests) - self.testsuite_results.append((header, runner)) - return runner.wasSuccessful() + + errors = [] + skipped = [] + failures = [] + for testcase, reason in runner.errors: + errors.append(TestResult(testcase.id(), reason)) + for testcase, reason in runner.skipped: + skipped.append(TestResult(testcase.id(), reason)) + for testcase, reason in runner.failures: + failures.append(TestResult(testcase.id(), reason)) + self.testsuite_results.append( + TestsuiteResult(header, + errors, + skipped, + failures, + runner.testsRun - len(errors + skipped + failures)) + ) + success = runner.wasSuccessful() + del loader + del runner + return success def print_overall_testsuite_report(self): ''' @@ -510,22 +532,19 @@ class SaltTestingParser(optparse.OptionParser): failures = errors = skipped = passed = 0 no_problems_found = True - for (name, results) in self.testsuite_results: + for results in self.testsuite_results: failures += len(results.failures) errors += len(results.errors) skipped += len(results.skipped) - passed += results.testsRun - len( - results.failures + results.errors + results.skipped - ) + passed += results.passed - if not results.failures and not results.errors and \ - not results.skipped: + if not results.failures and not results.errors and not results.skipped: continue no_problems_found = False print_header( - u'*** {0} '.format(name), sep=u'*', inline=True, + u'*** {0} '.format(results.header), sep=u'*', inline=True, width=self.options.output_columns ) if results.skipped: @@ -534,12 +553,11 @@ class SaltTestingParser(optparse.OptionParser): width=self.options.output_columns ) maxlen = len( - max([testcase.id() for (testcase, reason) in - results.skipped], key=len) + max([testcase.id for testcase in results.skipped], key=len) ) fmt = u' -> {0: <{maxlen}} -> {1}' - for testcase, reason in results.skipped: - print(fmt.format(testcase.id(), reason, maxlen=maxlen)) + for testcase in results.skipped: + print(fmt.format(testcase.id, testcase.reason, maxlen=maxlen)) print_header(u' ', sep='-', inline=True, width=self.options.output_columns) @@ -548,13 +566,13 @@ class SaltTestingParser(optparse.OptionParser): u' -------- Tests with Errors ', sep='-', inline=True, width=self.options.output_columns ) - for testcase, reason in results.errors: + for testcase in results.errors: print_header( - u' -> {0} '.format(testcase.id()), + u' -> {0} '.format(testcase.id), sep=u'.', inline=True, width=self.options.output_columns ) - for line in reason.rstrip().splitlines(): + for line in testcase.reason.rstrip().splitlines(): print(' {0}'.format(line.rstrip())) print_header(u' ', sep=u'.', inline=True, width=self.options.output_columns) @@ -566,13 +584,13 @@ class SaltTestingParser(optparse.OptionParser): u' -------- Failed Tests ', sep='-', inline=True, width=self.options.output_columns ) - for testcase, reason in results.failures: + for testcase in results.failures: print_header( - u' -> {0} '.format(testcase.id()), + u' -> {0} '.format(testcase.id), sep=u'.', inline=True, width=self.options.output_columns ) - for line in reason.rstrip().splitlines(): + for line in testcase.reason.rstrip().splitlines(): print(' {0}'.format(line.rstrip())) print_header(u' ', sep=u'.', inline=True, width=self.options.output_columns) From 816cfe862aeb4964eea2653a0a8b080f7bade44c Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 2 Mar 2017 10:21:24 -0600 Subject: [PATCH 319/370] add get_or_set_hash to sdb --- salt/modules/sdb.py | 36 ++++++++++++++++++++++++++++++++++++ salt/runners/sdb.py | 26 ++++++++++++++++++++++++++ salt/utils/sdb.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/salt/modules/sdb.py b/salt/modules/sdb.py index cca5477539..b5a73149f0 100644 --- a/salt/modules/sdb.py +++ b/salt/modules/sdb.py @@ -56,3 +56,39 @@ def delete(uri): salt '*' sdb.delete sdb://mymemcached/foo ''' return salt.utils.sdb.sdb_delete(uri, __opts__, __utils__) + + +def get_or_set_hash(uri, + length=8, + chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'): + ''' + Perform a one-time generation of a hash and write it to sdb. + If that value has already been set return the value instead. + + This is useful for generating passwords or keys that are specific to + multiple minions that need to be stored somewhere centrally. + + State Example: + + .. code-block:: yaml + + some_mysql_user: + mysql_user: + - present + - host: localhost + - password: '{{ salt['sdb.get_or_set_hash']('some_mysql_user_pass') }}' + + CLI Example: + + .. code-block:: bash + + salt '*' sdb.get_or_set_hash 'SECRET_KEY' 50 + + .. warning:: + + This function could return strings which may contain characters which are reserved + as directives by the YAML parser, such as strings beginning with ``%``. To avoid + issues when using the output of this function in an SLS file containing YAML+Jinja, + surround the call with single quotes. + ''' + return salt.utils.sdb.sdb_get_or_set_hash(uri, __opts__, length, chars, __utils__) diff --git a/salt/runners/sdb.py b/salt/runners/sdb.py index 9b6bd2daba..e70f621c00 100644 --- a/salt/runners/sdb.py +++ b/salt/runners/sdb.py @@ -55,3 +55,29 @@ def delete(uri): salt '*' sdb.delete sdb://mymemcached/foo ''' return salt.utils.sdb.sdb_delete(uri, __opts__, __utils__) + + +def get_or_set_hash(uri, + length=8, + chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'): + ''' + Perform a one-time generation of a hash and write it to sdb. + If that value has already been set return the value instead. + + This is useful for generating passwords or keys that are specific to + multiple minions that need to be stored somewhere centrally. + + CLI Example: + + .. code-block:: bash + + salt-run sdb.get_or_set_hash 'SECRET_KEY' 50 + + .. warning:: + + This function could return strings which may contain characters which are reserved + as directives by the YAML parser, such as strings beginning with ``%``. To avoid + issues when using the output of this function in an SLS file containing YAML+Jinja, + surround the call with single quotes. + ''' + return salt.utils.sdb.sdb_get_or_set_hash(uri, __opts__, length, chars, __utils__) diff --git a/salt/utils/sdb.py b/salt/utils/sdb.py index b9b7e3d82e..441b129add 100644 --- a/salt/utils/sdb.py +++ b/salt/utils/sdb.py @@ -6,6 +6,11 @@ For configuration options, see the docs for specific sdb modules. ''' from __future__ import absolute_import + +# Import python libs +import random + +# Import salt libs import salt.loader from salt.ext.six import string_types @@ -109,3 +114,31 @@ def sdb_delete(uri, opts, utils=None): loaded_db = salt.loader.sdb(opts, fun, utils=utils) return loaded_db[fun](query, profile=profile) + + +def sdb_get_or_set_hash(uri, + opts, + length=8, + chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)', + utils=None): + ''' + Check if value exists in sdb. If it does, return, otherwise generate a + random string and store it. This can be used for storing secrets in a + centralized place. + ''' + if not isinstance(uri, string_types): + return False + + if not uri.startswith('sdb://'): + return False + + if utils is None: + utils = {} + + ret = sdb_get(uri, opts, utils=utils) + + if ret is None: + val = ''.join([random.SystemRandom().choice(chars) for _ in range(length)]) + sdb_set(uri, val, opts, utils) + + return ret or val From 5c978722d3dc37c74f516fdb6a4d8510e4593351 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 2 Mar 2017 12:26:28 -0600 Subject: [PATCH 320/370] consolidate test of valid sdb uri --- salt/utils/sdb.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/salt/utils/sdb.py b/salt/utils/sdb.py index 441b129add..83431c9954 100644 --- a/salt/utils/sdb.py +++ b/salt/utils/sdb.py @@ -20,10 +20,7 @@ def sdb_get(uri, opts, utils=None): Get a value from a db, using a uri in the form of ``sdb:///``. If the uri provided does not start with ``sdb://``, then it will be returned as-is. ''' - if not isinstance(uri, string_types): - return uri - - if not uri.startswith('sdb://'): + if not isinstance(uri, string_types) or not uri.startswith('sdb://'): return uri if utils is None: @@ -54,10 +51,7 @@ def sdb_set(uri, value, opts, utils=None): If the uri provided does not start with ``sdb://`` or the value is not successfully set, return ``False``. ''' - if not isinstance(uri, string_types): - return False - - if not uri.startswith('sdb://'): + if not isinstance(uri, string_types) or not uri.startswith('sdb://'): return False if utils is None: @@ -88,10 +82,7 @@ def sdb_delete(uri, opts, utils=None): the uri provided does not start with ``sdb://`` or the value is not successfully deleted, return ``False``. ''' - if not isinstance(uri, string_types): - return False - - if not uri.startswith('sdb://'): + if not isinstance(uri, string_types) or not uri.startswith('sdb://'): return False if utils is None: @@ -126,10 +117,7 @@ def sdb_get_or_set_hash(uri, random string and store it. This can be used for storing secrets in a centralized place. ''' - if not isinstance(uri, string_types): - return False - - if not uri.startswith('sdb://'): + if not isinstance(uri, string_types) or not uri.startswith('sdb://'): return False if utils is None: From e444e7da62bcc0a32fe4c6ed7ea01c2d2a7ecd34 Mon Sep 17 00:00:00 2001 From: Seth House Date: Fri, 17 Feb 2017 18:57:43 -0700 Subject: [PATCH 321/370] Add full_return argument to LocalClient.cmd to expose exit code --- salt/client/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/salt/client/__init__.py b/salt/client/__init__.py index 3afb85c9f4..57382d2954 100644 --- a/salt/client/__init__.py +++ b/salt/client/__init__.py @@ -576,6 +576,7 @@ class LocalClient(object): tgt_type='glob', ret='', jid='', + full_return=False, kwarg=None, **kwargs): ''' @@ -664,6 +665,9 @@ class LocalClient(object): :param kwarg: A dictionary with keyword arguments for the function. + :param full_return: Output the job return only (default) or the full + return including exit code and other job metadata. + :param kwargs: Optional keyword arguments. Authentication credentials may be passed when using :conf_master:`external_auth`. @@ -714,7 +718,8 @@ class LocalClient(object): if fn_ret: for mid, data in six.iteritems(fn_ret): - ret[mid] = data.get('ret', {}) + ret[mid] = (data if full_return + else data.get('ret', {})) for failed in list(set(pub_data['minions']) ^ set(ret.keys())): ret[failed] = False From 065e24d10145cf5abe6712708014c970485b68f9 Mon Sep 17 00:00:00 2001 From: Seth House Date: Fri, 17 Feb 2017 19:03:09 -0700 Subject: [PATCH 322/370] Add full_return support to RunnerClient.cmd_sync to expose exit code --- salt/client/mixins.py | 4 ++-- salt/netapi/__init__.py | 4 ++-- salt/runner.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/salt/client/mixins.py b/salt/client/mixins.py index 13041c4e03..7e815ce8b1 100644 --- a/salt/client/mixins.py +++ b/salt/client/mixins.py @@ -138,7 +138,7 @@ class SyncClientMixin(object): salt.utils.error.raise_error(**ret['error']) return ret - def cmd_sync(self, low, timeout=None): + def cmd_sync(self, low, timeout=None, full_return=False): ''' Execute a runner function synchronously; eauth is respected @@ -166,7 +166,7 @@ class SyncClientMixin(object): "RunnerClient job '{0}' timed out".format(job['jid']), jid=job['jid']) - return ret['data']['return'] + return ret if full_return else ret['data']['return'] def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False): ''' diff --git a/salt/netapi/__init__.py b/salt/netapi/__init__.py index 49cab3c439..830f287e05 100644 --- a/salt/netapi/__init__.py +++ b/salt/netapi/__init__.py @@ -125,7 +125,7 @@ class NetapiClient(object): disable_custom_roster=True) return ssh_client.cmd_sync(kwargs) - def runner(self, fun, timeout=None, **kwargs): + def runner(self, fun, timeout=None, full_return=False, **kwargs): ''' Run `runner modules ` synchronously @@ -138,7 +138,7 @@ class NetapiClient(object): ''' kwargs['fun'] = fun runner = salt.runner.RunnerClient(self.opts) - return runner.cmd_sync(kwargs, timeout=timeout) + return runner.cmd_sync(kwargs, timeout=timeout, full_return=full_return) def runner_async(self, fun, **kwargs): ''' diff --git a/salt/runner.py b/salt/runner.py index fd16f21aba..f0f9b919c8 100644 --- a/salt/runner.py +++ b/salt/runner.py @@ -113,7 +113,7 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object): return mixins.AsyncClientMixin.cmd_async(self, reformatted_low) - def cmd_sync(self, low, timeout=None): + def cmd_sync(self, low, timeout=None, full_return=False): ''' Execute a runner function synchronously; eauth is respected @@ -130,7 +130,7 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object): }) ''' reformatted_low = self._reformat_low(low) - return mixins.SyncClientMixin.cmd_sync(self, reformatted_low, timeout) + return mixins.SyncClientMixin.cmd_sync(self, reformatted_low, timeout, full_return) def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False): ''' From c25ffd5d2e825bba4335866e2c5c4182d25eedef Mon Sep 17 00:00:00 2001 From: Seth House Date: Fri, 17 Feb 2017 19:31:57 -0700 Subject: [PATCH 323/370] Add LocalClient and RunnerClient full_return tests --- tests/integration/client/test_kwarg.py | 5 +++++ tests/integration/client/test_runner.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/tests/integration/client/test_kwarg.py b/tests/integration/client/test_kwarg.py index 9a957f6502..883c0da520 100644 --- a/tests/integration/client/test_kwarg.py +++ b/tests/integration/client/test_kwarg.py @@ -89,3 +89,8 @@ class StdTest(integration.ModuleCase): self.assertIn('int', data['args'][1]) self.assertIn('dict', data['kwargs']['outer']) self.assertIn('str', data['kwargs']['inner']) + + def test_full_return_kwarg(self): + ret = self.client.cmd('minion', 'test.ping', full_return=True) + for mid, data in ret.items(): + self.assertIn('retcode', data) diff --git a/tests/integration/client/test_runner.py b/tests/integration/client/test_runner.py index 3f26cbf122..8b5bf18236 100644 --- a/tests/integration/client/test_runner.py +++ b/tests/integration/client/test_runner.py @@ -100,3 +100,9 @@ class RunnerModuleTest(integration.TestCase, integration.AdaptedConfigurationTes 'bar': 'Bar!', } self.runner.cmd_sync(low) + + def test_full_return_kwarg(self): + low = {'fun': 'test.arg'} + low.update(self.eauth_creds) + ret = self.runner.cmd_sync(low, full_return=True) + self.assertIn('success', ret['data']) From 661b6416b7f88991f87143b2758d0154b5c6fc02 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 19:11:37 +0000 Subject: [PATCH 324/370] Allow passing a test module path to runtests.py to run its tests Example: ``` python tests/runtests.py -v tests/integration/states/test_alternatives.py ``` --- tests/runtests.py | 11 +++++++++++ tests/support/parser/__init__.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/runtests.py b/tests/runtests.py index dfad3049f7..b056267035 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -600,6 +600,17 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): with TestDaemon(self): if self.options.name: for name in self.options.name: + if os.path.isfile(name): + if not name.endswith('.py'): + continue + if name.startswith(os.path.join('tests', 'unit')): + continue + results = self.run_suite(os.path.dirname(name), + name, + suffix=os.path.basename(name), + load_from_name=False) + status.append(results) + continue if name.startswith('unit.'): continue results = self.run_suite('', name, suffix='test_*.py', load_from_name=True) diff --git a/tests/support/parser/__init__.py b/tests/support/parser/__init__.py index 8f68263f8d..d1882f999c 100644 --- a/tests/support/parser/__init__.py +++ b/tests/support/parser/__init__.py @@ -311,6 +311,17 @@ class SaltTestingParser(optparse.OptionParser): self.options.name.extend(lines) else: self.options.name = lines + if self.args: + if not self.options.name: + self.options.name = [] + for fpath in self.args: + if not os.path.isfile(fpath): + continue + if not fpath.endswith('.py'): + continue + if not os.path.basename(fpath).startswith('test_'): + continue + self.options.name.append(fpath) print_header(u'', inline=True, width=self.options.output_columns) self.pre_execution_cleanup() From 00b8b167162e634ab11ea00759fc0dbcf9bd0f44 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 2 Mar 2017 13:24:05 -0600 Subject: [PATCH 325/370] fix pylint --- salt/utils/sdb.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/utils/sdb.py b/salt/utils/sdb.py index 83431c9954..f6470193e7 100644 --- a/salt/utils/sdb.py +++ b/salt/utils/sdb.py @@ -13,6 +13,7 @@ import random # Import salt libs import salt.loader from salt.ext.six import string_types +from salt.ext.six.moves import range def sdb_get(uri, opts, utils=None): From c545990d07d33f6bbadd8f687c9e913059d4b058 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 11:30:42 +0000 Subject: [PATCH 326/370] We get bytes under Py3 --- salt/fileclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index c55716bced..4f801ef62e 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -630,7 +630,7 @@ class Client(object): if 'handle' not in query: raise MinionError('Error: {0} reading {1}'.format(query['error'], url)) if no_cache: - return ''.join(result) + return six.b('').join(result) else: destfp.close() destfp = None From f98ae604458715dddefc0ec3cb362d95cbfbe1bc Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 11:45:24 +0000 Subject: [PATCH 327/370] We need bytes to gzip under Py3 --- salt/utils/gzip_util.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/utils/gzip_util.py b/salt/utils/gzip_util.py index 1a6fb9aeb9..5092500909 100644 --- a/salt/utils/gzip_util.py +++ b/salt/utils/gzip_util.py @@ -11,6 +11,7 @@ from __future__ import absolute_import import gzip # Import 3rd-party libs +import salt.ext.six as six from salt.ext.six import BytesIO @@ -53,6 +54,8 @@ def compress(data, compresslevel=9): ''' buf = BytesIO() with open_fileobj(buf, 'wb', compresslevel) as ogz: + if six.PY3 and not isinstance(data, bytes): + data = data.encode(__salt_system_encoding__) ogz.write(data) compressed = buf.getvalue() return compressed From 979090d2257a77d1bd8997862b55e634a1cf1ba9 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 11:46:26 +0000 Subject: [PATCH 328/370] We need bytes under Py3 to compute the hash --- tests/integration/modules/test_cp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/modules/test_cp.py b/tests/integration/modules/test_cp.py index f358773be1..4da6a3247e 100644 --- a/tests/integration/modules/test_cp.py +++ b/tests/integration/modules/test_cp.py @@ -77,6 +77,8 @@ class CPModuleTest(integration.ModuleCase): data = scene.read() self.assertIn('KNIGHT: They\'re nervous, sire.', data) self.assertNotIn('bacon', data) + if six.PY3: + data = salt.utils.to_bytes(data) self.assertEqual(hash_str, hashlib.md5(data).hexdigest()) def test_get_file_makedirs(self): From 01d6ee176d347fd341e7d45236cc62871a6dda21 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 17:19:41 +0000 Subject: [PATCH 329/370] Try to parse the content-type headers in order to get the encoding for text files --- salt/fileclient.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/salt/fileclient.py b/salt/fileclient.py index 4f801ef62e..3a16650a19 100644 --- a/salt/fileclient.py +++ b/salt/fileclient.py @@ -11,7 +11,7 @@ import os import string import shutil import ftplib -from tornado.httputil import parse_response_start_line, HTTPInputError +from tornado.httputil import parse_response_start_line, HTTPHeaders, HTTPInputError # Import salt libs from salt.exceptions import ( @@ -591,21 +591,45 @@ class Client(object): # Use list here to make it writable inside the on_header callback. Simple bool doesn't # work here: on_header creates a new local variable instead. This could be avoided in # Py3 with 'nonlocal' statement. There is no Py2 alternative for this. - write_body = [False] + write_body = [None, False, None] def on_header(hdr): + if write_body[1] is not False and write_body[2] is None: + # Try to find out what content type encoding is used if this is a text file + write_body[1].parse_line(hdr) # pylint: disable=no-member + if 'Content-Type' in write_body[1]: + content_type = write_body[1].get('Content-Type') # pylint: disable=no-member + if not content_type.startswith('text'): + write_body[1] = write_body[2] = False + else: + encoding = 'utf-8' + fields = content_type.split(';') + for field in fields: + if 'encoding' in field: + encoding = field.split('encoding=')[-1] + write_body[2] = encoding + # We have found our encoding. Stop processing headers. + write_body[1] = False + + if write_body[0] is not None: + # We already parsed the first line. No need to run the code below again + return + try: hdr = parse_response_start_line(hdr) except HTTPInputError: # Not the first line, do nothing return write_body[0] = hdr.code not in [301, 302, 303, 307] + write_body[1] = HTTPHeaders() if no_cache: result = [] def on_chunk(chunk): if write_body[0]: + if write_body[2]: + chunk = chunk.decode(write_body[2]) result.append(chunk) else: dest_tmp = "{0}.part".format(dest) @@ -630,6 +654,8 @@ class Client(object): if 'handle' not in query: raise MinionError('Error: {0} reading {1}'.format(query['error'], url)) if no_cache: + if write_body[2]: + return six.u('').join(result) return six.b('').join(result) else: destfp.close() From 8d6d67de924eefdde210833a79685b72ff112367 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 17:20:58 +0000 Subject: [PATCH 330/370] Try to decode bytes to string under Py3. If it fails, its a binary file. --- salt/utils/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index ead6252c30..a8c2f0bb90 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -2625,12 +2625,18 @@ def is_bin_file(path): a bin, False if the file is not and None if the file is not available. ''' if not os.path.isfile(path): - return None + return False try: - with fopen(path, 'r') as fp_: - return is_bin_str(fp_.read(2048)) + with fopen(path, 'rb') as fp_: + try: + data = fp_.read(2048) + if six.PY3: + data = data.decode(__salt_system_encoding__) + return is_bin_str(data) + except UnicodeDecodeError: + return True except os.error: - return None + return False def is_bin_str(data): From 8e3acf5ba53fa9946379d760f3f4f948152723e0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 17:34:47 +0000 Subject: [PATCH 331/370] `to_unicode` should also handle `bytearray` --- salt/utils/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index a8c2f0bb90..54175f7c86 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -3038,10 +3038,10 @@ def to_unicode(s, encoding=None): ''' Given str or unicode, return unicode (str for python 3) ''' - if not isinstance(s, (bytes, six.string_types)): + if not isinstance(s, (bytes, bytearray, six.string_types)): return s if six.PY3: - if isinstance(s, bytes): + if isinstance(s, (bytes, bytearray)): return to_str(s, encoding) else: if isinstance(s, str): From 7b4d849540bd658afea0972579c22380e0999544 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 18:06:53 +0000 Subject: [PATCH 332/370] Moved some test supporting modules to tests/support Previously they were in tests/utils which also had test case modules. --- tests/integration/netapi/rest_cherrypy/test_app_pam.py | 6 ++---- tests/support/cherrypy_testclasses.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/integration/netapi/rest_cherrypy/test_app_pam.py b/tests/integration/netapi/rest_cherrypy/test_app_pam.py index 37740186be..466dc3c807 100644 --- a/tests/integration/netapi/rest_cherrypy/test_app_pam.py +++ b/tests/integration/netapi/rest_cherrypy/test_app_pam.py @@ -7,13 +7,11 @@ Integration Tests for restcherry salt-api with pam eauth from __future__ import absolute_import import os -# Import salttesting libs +# Import test support libs +import tests.integration as integration from tests.support.unit import skipIf from tests.support.helpers import destructiveTest - -# Import test support libs import tests.support.cherrypy_testclasses as cptc -import tests.integration as integration # Import Salt Libs import salt.utils diff --git a/tests/support/cherrypy_testclasses.py b/tests/support/cherrypy_testclasses.py index 2b89c13307..4fc8dc8088 100644 --- a/tests/support/cherrypy_testclasses.py +++ b/tests/support/cherrypy_testclasses.py @@ -11,7 +11,7 @@ except ImportError: import os import salt.config -from tests.integration import TMP_CONF_DIR +from tests.support.paths import TMP_CONF_DIR if HAS_CHERRYPY: from tests.support.cptestcase import BaseCherryPyTestCase From 96bcaf536566c248b64b8e7ffeac8a8d4e195fe6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 19:02:08 +0000 Subject: [PATCH 333/370] The order is shady under Py3 /cc @cachedout @rallytime --- tests/support/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/support/helpers.py b/tests/support/helpers.py index f61e88ae81..f57e699bec 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- ''' - :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` :copyright: © 2013-2017 by the SaltStack Team, see AUTHORS for more details. :license: Apache 2.0, see LICENSE for more details. @@ -8,7 +7,7 @@ tests.support.helpers ~~~~~~~~~~~~~~~~~~~~~ - Unit testing helpers + Test support helpers ''' # pylint: disable=repr-flag-used-in-string @@ -36,6 +35,7 @@ else: # Import Salt Tests Support libs from tests.support.unit import skip, _id +from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin log = logging.getLogger(__name__) From cbef6c044f49fbab403b559d9eac1513dfd7e12e Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 24 Feb 2017 19:39:06 +0000 Subject: [PATCH 334/370] Re-enable the test since we now have the flaky decorator --- tests/unit/transport/test_zeromq.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/unit/transport/test_zeromq.py b/tests/unit/transport/test_zeromq.py index 75404055d0..eaa8db1d76 100644 --- a/tests/unit/transport/test_zeromq.py +++ b/tests/unit/transport/test_zeromq.py @@ -26,13 +26,10 @@ import salt.transport.server import salt.transport.client import salt.exceptions - -# Import Salt Testing libs -from tests.support.unit import TestCase, skipIf - # Import test support libs import tests.integration as integration from tests.support.helpers import flaky +from tests.support.unit import TestCase, skipIf from tests.unit.transport.test_req import ReqChannelMixin from tests.unit.transport.test_pub import PubChannelMixin From fc501e93aca23a1ac78b7a9aae80cde17f402ce7 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 25 Feb 2017 17:49:00 +0000 Subject: [PATCH 335/370] Remove deprecated options --- tests/integration/files/conf/_ssh/sshd_config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/files/conf/_ssh/sshd_config b/tests/integration/files/conf/_ssh/sshd_config index 7b42eac4df..3c6cb93f62 100644 --- a/tests/integration/files/conf/_ssh/sshd_config +++ b/tests/integration/files/conf/_ssh/sshd_config @@ -9,8 +9,8 @@ UsePrivilegeSeparation yes StrictModes no # Lifetime and size of ephemeral version 1 server key -KeyRegenerationInterval 3600 -ServerKeyBits 1024 +#KeyRegenerationInterval 3600 +#ServerKeyBits 1024 # Logging SyslogFacility AUTH @@ -21,7 +21,7 @@ LoginGraceTime 120 PermitRootLogin without-password StrictModes yes -RSAAuthentication yes +#RSAAuthentication yes PubkeyAuthentication yes #AuthorizedKeysFile %h/.ssh/authorized_keys #AuthorizedKeysFile key_test.pub @@ -29,7 +29,7 @@ PubkeyAuthentication yes # Don't read the user's ~/.rhosts and ~/.shosts files IgnoreRhosts yes # For this to work you will also need host keys in /etc/ssh_known_hosts -RhostsRSAAuthentication no +#RhostsRSAAuthentication no # similar for protocol version 2 HostbasedAuthentication no #IgnoreUserKnownHosts yes From 560edcf6f683e12dac4902684db4c89cf90044cf Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 25 Feb 2017 17:49:36 +0000 Subject: [PATCH 336/370] The ssh_log_file setting should also have the root_dir prefixed --- salt/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 5242d5479e..faed486a4a 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -3389,7 +3389,7 @@ def apply_master_config(overrides=None, defaults=None): ] # These can be set to syslog, so, not actual paths on the system - for config_key in ('log_file', 'key_logfile'): + for config_key in ('log_file', 'key_logfile', 'ssh_log_file'): log_setting = opts.get(config_key, '') if log_setting is None: continue From 31df825a1c2d4495a4319e02f9a8a561e3d4a558 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 25 Feb 2017 17:50:00 +0000 Subject: [PATCH 337/370] Set the ssh_log_file relative --- tests/integration/files/conf/master | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/files/conf/master b/tests/integration/files/conf/master index 2d76e9e131..54270ee72f 100644 --- a/tests/integration/files/conf/master +++ b/tests/integration/files/conf/master @@ -17,6 +17,7 @@ log_file: master.log log_fmt: '[%(asctime)s.%(msecs)s] %(colorlevel)s%(colorname)s%(colorprocess)s %(funcName)s() L%(lineno)s %(processName)s %(message)s' log_level_logfile: debug key_logfile: key.log +ssh_log_file: ssh.log token_file: /tmp/ksfjhdgiuebfgnkefvsikhfjdgvkjahcsidk # These settings needed for tests on Windows which defaults From 519a3f689eb90e71b729d7f8469a292cf1bda03b Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 14:13:44 +0000 Subject: [PATCH 338/370] These tests are not destructive --- tests/integration/fileserver/test_fileclient.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/integration/fileserver/test_fileclient.py b/tests/integration/fileserver/test_fileclient.py index 1d96f7d26c..15175fa07d 100644 --- a/tests/integration/fileserver/test_fileclient.py +++ b/tests/integration/fileserver/test_fileclient.py @@ -9,22 +9,22 @@ import logging import os import shutil -log = logging.getLogger(__name__) - # Import Salt Testing libs import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import destructiveTest from tests.support.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON +from tests.support.paths import TMP # Import salt libs import salt.utils from salt import fileclient import salt.ext.six as six +log = logging.getLogger(__name__) + SALTENVS = ('base', 'dev') -FS_ROOT = os.path.join(integration.TMP, 'fileclient_fs_root') -CACHE_ROOT = os.path.join(integration.TMP, 'fileclient_cache_root') +FS_ROOT = os.path.join(TMP, 'fileclient_fs_root') +CACHE_ROOT = os.path.join(TMP, 'fileclient_cache_root') SUBDIR = 'subdir' SUBDIR_FILES = ('foo.txt', 'bar.txt', 'baz.txt') @@ -72,7 +72,6 @@ class FileClientTest(integration.ModuleCase): @skipIf(NO_MOCK, NO_MOCK_REASON) -@destructiveTest class FileclientCacheTest(integration.ModuleCase): ''' Tests for the fileclient caching. The LocalClient is the only thing we can From 80002276c2740ac2dac52684e02f17a41ffac496 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 19:24:03 +0000 Subject: [PATCH 339/370] These tests are not destructive --- tests/integration/states/test_archive.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/integration/states/test_archive.py b/tests/integration/states/test_archive.py index b6f55f8e6b..d6d2e40479 100644 --- a/tests/integration/states/test_archive.py +++ b/tests/integration/states/test_archive.py @@ -23,9 +23,8 @@ import salt.utils # Setup logging log = logging.getLogger(__name__) -STATE_DIR = os.path.join(integration.FILES, 'file', 'base') if salt.utils.is_windows(): - ARCHIVE_DIR = os.path.join("c:/", "tmp") + ARCHIVE_DIR = os.path.join('c:/', 'tmp') else: ARCHIVE_DIR = '/tmp/archive' @@ -151,7 +150,6 @@ class ArchiveTest(integration.ModuleCase, self._check_extracted(UNTAR_FILE) - @skipIf(os.geteuid() != 0, 'you must be root to run this test') def test_archive_extracted_with_strip_in_options(self): ''' test archive.extracted with --strip in options @@ -169,7 +167,6 @@ class ArchiveTest(integration.ModuleCase, self._check_extracted(os.path.join(ARCHIVE_DIR, 'README')) - @skipIf(os.geteuid() != 0, 'you must be root to run this test') def test_archive_extracted_with_strip_components_in_options(self): ''' test archive.extracted with --strip-components in options From 2f3d0b0b81d8bd014eb7aa4473af6a8a0d9eddd8 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 19:33:14 +0000 Subject: [PATCH 340/370] These are not destructive tests --- tests/integration/states/test_file.py | 45 +++++++++++---------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index b496e7e577..68b56f63e3 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -21,10 +21,7 @@ import filecmp # Import Salt Testing libs import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import ( - destructiveTest, - with_system_user_and_group -) +from tests.support.helpers import with_system_user_and_group # Import salt libs import salt.utils @@ -348,7 +345,6 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): self.assertEqual(oct(desired_mode), oct(resulting_mode)) self.assertSaltTrueReturn(ret) - @destructiveTest def test_managed_file_with_grains_data(self): ''' Test to ensure we can render grains data into a managed @@ -366,7 +362,6 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): self.assertTrue(re.match('^minion$', file_contents[0])) - @destructiveTest def test_managed_file_with_pillar_sls(self): ''' Test to ensure pillar data in sls file @@ -381,7 +376,6 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): check_file = self.run_function('file.file_exists', [FILEPILLAR]) self.assertTrue(check_file) - @destructiveTest def test_managed_file_with_pillardefault_sls(self): ''' Test to ensure when pillar data is not available @@ -398,7 +392,6 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): self.assertTrue(check_file) @skipIf(not HAS_GIT_PYTHON, "GitFS could not be loaded. Skipping test") - @destructiveTest def test_managed_file_with_gitpillar_sls(self): ''' Test to ensure git pillar data in sls @@ -574,27 +567,28 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): for typ in managed_files: os.remove(managed_files[typ]) - @destructiveTest @skipIf(salt.utils.is_windows(), 'Windows does not support "mode" kwarg. Skipping.') def test_managed_check_cmd(self): ''' Test file.managed passing a basic check_cmd kwarg. See Issue #38111. ''' - ret = self.run_state( - 'file.managed', - name='/tmp/sudoers', - user='root', - group='root', - mode=440, - check_cmd='visudo -c -s -f' - ) - self.assertSaltTrueReturn(ret) - self.assertInSaltComment('Empty file', ret) - self.assertEqual(ret['file_|-/tmp/sudoers_|-/tmp/sudoers_|-managed']['changes'], - {'new': 'file /tmp/sudoers created', 'mode': '0440'}) - - # Clean Up File - os.remove('/tmp/sudoers') + try: + ret = self.run_state( + 'file.managed', + name='/tmp/sudoers', + user='root', + group='root', + mode=440, + check_cmd='visudo -c -s -f' + ) + self.assertSaltTrueReturn(ret) + self.assertInSaltComment('Empty file', ret) + self.assertEqual(ret['file_|-/tmp/sudoers_|-/tmp/sudoers_|-managed']['changes'], + {'new': 'file /tmp/sudoers created', 'mode': '0440'}) + finally: + # Clean Up File + if os.path.exists('/tmp/sudoers'): + os.remove('/tmp/sudoers') def test_directory(self): ''' @@ -2237,7 +2231,6 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): os.unlink(test_file) os.unlink(template_path) - @destructiveTest @skipIf(not IS_ADMIN, 'you must be root to run this test') @skipIf(not HAS_PWD, "pwd not available. Skipping test") @skipIf(not HAS_GRP, "grp not available. Skipping test") @@ -2285,7 +2278,6 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): if os.path.isdir(tmp_dir): shutil.rmtree(tmp_dir) - @destructiveTest @skipIf(not IS_ADMIN, 'you must be root to run this test') @skipIf(not HAS_PWD, "pwd not available. Skipping test") @skipIf(not HAS_GRP, "grp not available. Skipping test") @@ -2414,7 +2406,6 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): os.remove(source) os.remove(dest) - @destructiveTest def test_contents_pillar_with_pillar_list(self): ''' This tests for any regressions for this issue: From 5e3309d5f829a5d7a9b41b719392a616f23d2461 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 19:41:11 +0000 Subject: [PATCH 341/370] Let's use the skip_if_not_root decorator instead --- tests/integration/states/test_file.py | 21 +++++---------------- tests/support/helpers.py | 14 +++++++++++--- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index 68b56f63e3..9fbfd250d5 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -21,7 +21,7 @@ import filecmp # Import Salt Testing libs import tests.integration as integration from tests.support.unit import skipIf -from tests.support.helpers import with_system_user_and_group +from tests.support.helpers import skip_if_not_root, with_system_user_and_group # Import salt libs import salt.utils @@ -38,18 +38,7 @@ try: except ImportError: HAS_GRP = False -IS_ADMIN = False -IS_WINDOWS = False -if salt.utils.is_windows(): - IS_WINDOWS = True - import salt.utils.win_functions - current_user = salt.utils.win_functions.get_current_user() - if current_user == 'SYSTEM': - IS_ADMIN = True - else: - IS_ADMIN = salt.utils.win_functions.is_admin(current_user) -else: - IS_ADMIN = os.geteuid() == 0 +IS_WINDOWS = salt.utils.is_windows() # Import 3rd-party libs import salt.ext.six as six @@ -406,7 +395,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): check_file = self.run_function('file.file_exists', [FILEPILLARGIT]) self.assertTrue(check_file) - @skipIf(not IS_ADMIN, 'you must be root to run this test') + @skip_if_not_root def test_managed_dir_mode(self): ''' Tests to ensure that file.managed creates directories with the @@ -2231,7 +2220,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): os.unlink(test_file) os.unlink(template_path) - @skipIf(not IS_ADMIN, 'you must be root to run this test') + @skip_if_not_root @skipIf(not HAS_PWD, "pwd not available. Skipping test") @skipIf(not HAS_GRP, "grp not available. Skipping test") @with_system_user_and_group('user12209', 'group12209', @@ -2278,7 +2267,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): if os.path.isdir(tmp_dir): shutil.rmtree(tmp_dir) - @skipIf(not IS_ADMIN, 'you must be root to run this test') + @skip_if_not_root @skipIf(not HAS_PWD, "pwd not available. Skipping test") @skipIf(not HAS_GRP, "grp not available. Skipping test") @with_system_user_and_group('user12209', 'group12209', diff --git a/tests/support/helpers.py b/tests/support/helpers.py index f57e699bec..226cfc3b25 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -1042,9 +1042,17 @@ def skip_if_binaries_missing(*binaries, **kwargs): def skip_if_not_root(func): - if os.getuid() != 0: - func.__unittest_skip__ = True - func.__unittest_skip_why__ = 'You must be logged in as root to run this test' + if not sys.platform.startswith('win'): + if os.getuid() != 0: + func.__unittest_skip__ = True + func.__unittest_skip_why__ = 'You must be logged in as root to run this test' + else: + import salt.utils.win_functions + current_user = salt.utils.win_functions.get_current_user() + if current_user != 'SYSTEM': + if not salt.utils.win_functions.is_admin(current_user): + func.__unittest_skip__ = True + func.__unittest_skip_why__ = 'You must be logged in as an Administrator to run this test' return func From 5b5a6ebbe88ccb5857d7119c796fcb6723aeca3d Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 19:54:10 +0000 Subject: [PATCH 342/370] Minor code cleanup --- tests/integration/states/test_file.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index 9fbfd250d5..801b0b4126 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -38,12 +38,11 @@ try: except ImportError: HAS_GRP = False -IS_WINDOWS = salt.utils.is_windows() - # Import 3rd-party libs import salt.ext.six as six from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin +IS_WINDOWS = salt.utils.is_windows() GIT_PYTHON = '0.3.2' HAS_GIT_PYTHON = False @@ -144,11 +143,11 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): tgt = os.path.join(integration.TMP, 'target') # Windows must have a source directory to link to - if salt.utils.is_windows() and not os.path.isdir(tgt): + if IS_WINDOWS and not os.path.isdir(tgt): os.mkdir(tgt) # Windows cannot create a symlink if it already exists - if salt.utils.is_windows() and self.run_function('file.is_link', [name]): + if IS_WINDOWS and self.run_function('file.is_link', [name]): self.run_function('file.remove', [name]) ret = self.run_state('file.symlink', name=name, target=tgt) @@ -194,7 +193,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): tgt = '{0}.tgt'.format(name) # Windows must have a source directory to link to - if salt.utils.is_windows() and not os.path.isdir(tgt): + if IS_WINDOWS and not os.path.isdir(tgt): os.mkdir(tgt) if not self.run_function('file.is_link', [name]): @@ -556,7 +555,8 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): for typ in managed_files: os.remove(managed_files[typ]) - @skipIf(salt.utils.is_windows(), 'Windows does not support "mode" kwarg. Skipping.') + @skip_if_not_root + @skipIf(IS_WINDOWS, 'Windows does not support "mode" kwarg. Skipping.') def test_managed_check_cmd(self): ''' Test file.managed passing a basic check_cmd kwarg. See Issue #38111. @@ -715,7 +715,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): pass exclude_pat = 'E@^straydir(|/keepfile)$' - if salt.utils.is_windows(): + if IS_WINDOWS: exclude_pat = 'E@^straydir(|\\\\keepfile)$' ret = self.run_state('file.directory', @@ -756,7 +756,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): pass exclude_pat = 'E@^straydir(|/keepfile)$' - if salt.utils.is_windows(): + if IS_WINDOWS: exclude_pat = 'E@^straydir(|\\\\keepfile)$' ret = self.run_state('file.directory', From 1f364fa9d43cdcd43c243bc01ec7ec8b2d63ef22 Mon Sep 17 00:00:00 2001 From: Christian McHugh Date: Thu, 2 Mar 2017 20:13:45 +0000 Subject: [PATCH 343/370] Correct lack of kwargs --- salt/states/zabbix_host.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/zabbix_host.py b/salt/states/zabbix_host.py index c03aacf3d9..8088a5d651 100644 --- a/salt/states/zabbix_host.py +++ b/salt/states/zabbix_host.py @@ -256,7 +256,7 @@ def present(host, groups, interfaces, **kwargs): return ret -def absent(name): +def absent(name, **kwargs): """ Ensures that the host does not exists, eventually deletes host. From eb0b7227e9cc3332a4bc13f99d453999f70dd4fc Mon Sep 17 00:00:00 2001 From: twangboy Date: Thu, 2 Mar 2017 13:31:52 -0700 Subject: [PATCH 344/370] Fix incorrect test name --- tests/whitelist.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/whitelist.txt b/tests/whitelist.txt index 7a43c1e72f..2ff2a25c46 100644 --- a/tests/whitelist.txt +++ b/tests/whitelist.txt @@ -33,6 +33,6 @@ integration.runners.test_winrepo integration.sdb.test_env integration.states.test_host integration.states.test_renderers -integration.utils.test_testprogram +integration.utils.testprogram integration.wheel.test_client integration.wheel.test_key From ef53ec7efebcb2a86a744d06f004c433823853ee Mon Sep 17 00:00:00 2001 From: twangboy Date: Thu, 2 Mar 2017 14:37:53 -0700 Subject: [PATCH 345/370] Fix test_worktree_add_rm test for Windows --- tests/integration/modules/test_git.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/integration/modules/test_git.py b/tests/integration/modules/test_git.py index dd2df171cc..0d80ff2e7e 100644 --- a/tests/integration/modules/test_git.py +++ b/tests/integration/modules/test_git.py @@ -56,7 +56,7 @@ def _worktrees_supported(): Check if the git version is 2.5.0 or later ''' try: - return _git_version() >= LooseVersion('2.5.0').encode() + return _git_version() >= LooseVersion('2.5.0') except AttributeError: return False @@ -931,10 +931,16 @@ class GitModuleTest(integration.ModuleCase): worktree_add_prefix = 'Preparing ' else: worktree_add_prefix = 'Enter ' + worktree_path = tempfile.mkdtemp(dir=integration.TMP) worktree_basename = os.path.basename(worktree_path) worktree_path2 = tempfile.mkdtemp(dir=integration.TMP) - worktree_basename2 = os.path.basename(worktree_path2) + + # Even though this is Windows, git commands return a unix style path + if salt.utils.is_windows(): + worktree_path = worktree_path.replace('\\', '/') + worktree_path = worktree_path.replace('\\', '/') + # Add the worktrees ret = self.run_function( 'git.worktree_add', [self.repo, worktree_path], From 25938ebc8e03beb0bc5a182f9a0a3a3246aa2ebb Mon Sep 17 00:00:00 2001 From: twangboy Date: Thu, 2 Mar 2017 15:40:22 -0700 Subject: [PATCH 346/370] Fix test_add_user_to_group for Windows --- tests/integration/modules/test_useradd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/modules/test_useradd.py b/tests/integration/modules/test_useradd.py index 645f9c2b0f..739b3fb91e 100644 --- a/tests/integration/modules/test_useradd.py +++ b/tests/integration/modules/test_useradd.py @@ -183,8 +183,7 @@ class UseraddModuleTestWindows(integration.ModuleCase): # And create the user as a member of that group if self.run_function( - 'user.add', - [user_name, 'groups={0}'.format(group_name)]) is False: + 'user.add', [user_name], groups=group_name) is False: self.run_function('user.delete', [user_name, True, True]) self.skipTest('Failed to create user') From 861d0838455bb0e8dee4d1f2e13d0dcb1a4d85b9 Mon Sep 17 00:00:00 2001 From: Tom Williams Date: Thu, 2 Mar 2017 18:16:54 -0500 Subject: [PATCH 347/370] INFRA-4579 - fix some deref errors I introduced awhile back, a small docstring fix, and increase default timeouts for cache subnet group and replication group creations --- salt/states/boto3_elasticache.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/salt/states/boto3_elasticache.py b/salt/states/boto3_elasticache.py index 93d33cb6e9..2ab15e7cb0 100644 --- a/salt/states/boto3_elasticache.py +++ b/salt/states/boto3_elasticache.py @@ -160,7 +160,7 @@ def _diff_cache_cluster(current, desired): return need_update -def cache_cluster_present(name, wait=600, security_groups=None, region=None, key=None, +def cache_cluster_present(name, wait=900, security_groups=None, region=None, key=None, keyid=None, profile=None, **args): ''' Ensure a given cache cluster exists. @@ -398,7 +398,7 @@ def cache_cluster_present(name, wait=600, security_groups=None, region=None, key keyid=keyid, profile=profile) ret['comment'] = 'Cache cluster {0} was created.'.format(name) ret['changes']['old'] = None - ret['changes']['new'] = new['CacheClusters'][0] + ret['changes']['new'] = new[0] else: ret['result'] = False ret['comment'] = 'Failed to create {0} cache cluster.'.format(name) @@ -428,7 +428,7 @@ def cache_cluster_present(name, wait=600, security_groups=None, region=None, key else: ret['comment'] = 'Cache cluster {0} was modified.'.format(name) ret['changes']['old'] = current - ret['changes']['new'] = new['CacheClusters'][0] + ret['changes']['new'] = new[0] else: ret['result'] = False ret['comment'] = 'Failed to modify cache cluster {0}.'.format(name) @@ -551,7 +551,7 @@ def _diff_replication_group(current, desired): return need_update -def replication_group_present(name, wait=600, security_groups=None, region=None, key=None, +def replication_group_present(name, wait=900, security_groups=None, region=None, key=None, keyid=None, profile=None, **args): ''' Ensure a replication group exists and is in the given state. @@ -788,7 +788,7 @@ def replication_group_present(name, wait=600, security_groups=None, region=None, keyid=keyid, profile=profile) ret['comment'] = 'Replication group {0} was created.'.format(name) ret['changes']['old'] = None - ret['changes']['new'] = new['ReplicationGroups'][0] + ret['changes']['new'] = new[0] else: ret['result'] = False ret['comment'] = 'Failed to create {0} replication group.'.format(name) @@ -830,10 +830,10 @@ def replication_group_present(name, wait=600, security_groups=None, region=None, def replication_group_absent(name, wait=600, region=None, key=None, keyid=None, profile=None, **args): ''' - Ensure a given cache cluster is deleted. + Ensure a given replication group is deleted. name - Name of the cache cluster. + Name of the replication group. wait Integer describing how long, in seconds, to wait for confirmation from AWS that the @@ -850,9 +850,10 @@ def replication_group_absent(name, wait=600, region=None, key=None, keyid=None, If set to true, all of the read replicas are deleted, but the primary node is retained. FinalSnapshotIdentifier - The user-supplied name of a final cache cluster snapshot. This is the unique name - that identifies the snapshot. ElastiCache creates the snapshot, and then deletes the - cache cluster immediately afterward. + The name of a final node group (shard) snapshot. ElastiCache creates the snapshot from + the primary node in the cluster, rather than one of the replicas; this is to ensure that + it captures the freshest data. After the final snapshot is taken, the replication group is + immediately deleted. region Region to connect to. @@ -983,7 +984,7 @@ def cache_subnet_group_present(name, subnets=None, region=None, key=None, keyid= keyid=keyid, profile=profile) ret['comment'] = 'Cache subnet group {0} was created.'.format(name) ret['changes']['old'] = None - ret['changes']['new'] = new['CacheSubnetGroups'][0] + ret['changes']['new'] = new[0] else: ret['result'] = False ret['comment'] = 'Failed to create {0} cache subnet group.'.format(name) @@ -1005,7 +1006,7 @@ def cache_subnet_group_present(name, subnets=None, region=None, key=None, keyid= keyid=keyid, profile=profile) ret['comment'] = 'Cache subnet group {0} was modified.'.format(name) ret['changes']['old'] = current['CacheSubetGroups'][0] - ret['changes']['new'] = new['CacheSubnetGroups'][0] + ret['changes']['new'] = new[0] else: ret['result'] = False ret['comment'] = 'Failed to modify cache subnet group {0}.'.format(name) From cc4ead3eba1b4fe4467afb4b39e69e83e1944847 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 2 Mar 2017 23:22:42 +0000 Subject: [PATCH 348/370] Stop returning `None` Prevents: ``` 23:21:32,673 [salt.loader :1634][WARNING ] salt.loaded.int.engines.stalekey.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'stalekey', please fix this. ``` --- salt/engines/stalekey.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/engines/stalekey.py b/salt/engines/stalekey.py index 3e142a1f79..1fdcff940e 100644 --- a/salt/engines/stalekey.py +++ b/salt/engines/stalekey.py @@ -40,6 +40,7 @@ log = logging.getLogger(__name__) def __virtual__(): if not __opts__.get('minion_data_cache'): return (False, 'stalekey engine requires minion_data_cache to be enabled') + return True def _get_keys(): From e556be369aa2d68181af2618d0272c11636d0642 Mon Sep 17 00:00:00 2001 From: Kade Date: Fri, 3 Mar 2017 15:58:53 +0800 Subject: [PATCH 349/370] Fix salt-ssh cp.get_url wapper bug In fileclient.get_url function, the 2nd arg is "dest", not "saltenv". --- salt/client/ssh/wrapper/cp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/client/ssh/wrapper/cp.py b/salt/client/ssh/wrapper/cp.py index ae1c2acbcb..bfe3a3acf0 100644 --- a/salt/client/ssh/wrapper/cp.py +++ b/salt/client/ssh/wrapper/cp.py @@ -68,7 +68,7 @@ def get_url(path, dest, saltenv='base'): ''' retrieve a URL ''' - src = __context__['fileclient'].get_url( + src = __context__['fileclient'].cache_file( path, saltenv, cachedir=os.path.join('salt-ssh', __salt__.kwargs['id_'])) From c745415b8b2b88c8fe51c59d2abc0f67ec4b71e7 Mon Sep 17 00:00:00 2001 From: Calle Pettersson Date: Fri, 3 Mar 2017 09:05:27 +0100 Subject: [PATCH 350/370] Vault: Always lowercase policies --- salt/runners/vault.py | 5 ++++- tests/unit/runners/test_vault.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/salt/runners/vault.py b/salt/runners/vault.py index 6495220f44..af19d26b86 100644 --- a/salt/runners/vault.py +++ b/salt/runners/vault.py @@ -120,7 +120,10 @@ def _get_policies(minion_id, config): for pattern in policy_patterns: try: for expanded_pattern in _expand_pattern_lists(pattern, **mappings): - policies.append(expanded_pattern.format(**mappings)) + policies.append( + expanded_pattern.format(**mappings) + .lower() # Vault requirement + ) except KeyError: log.warning('Could not resolve policy pattern {0}'.format(pattern)) diff --git a/tests/unit/runners/test_vault.py b/tests/unit/runners/test_vault.py index f367f7bbca..b9fe1adc83 100644 --- a/tests/unit/runners/test_vault.py +++ b/tests/unit/runners/test_vault.py @@ -45,6 +45,7 @@ class VaultTest(TestCase): } } }, + 'mixedcase': 'UP-low-UP', 'dictlist': [ {'foo': 'bar'}, {'baz': 'qux'} @@ -111,7 +112,10 @@ class VaultTest(TestCase): 'deeply-nested-list:hello', 'deeply-nested-list:world' ], - 'should-not-cause-an-exception,but-result-empty:{foo}': [] + 'should-not-cause-an-exception,but-result-empty:{foo}': [], + 'Case-Should-Be-Lowered:{grains[mixedcase]}': [ + 'case-should-be-lowered:up-low-up' + ] } with patch('salt.utils.minions.get_minion_data', From 04f097b59c72829fb895f173dc7aeb2ff85bf5a3 Mon Sep 17 00:00:00 2001 From: Marno van der Molen Date: Fri, 3 Mar 2017 09:59:50 +0100 Subject: [PATCH 351/370] Minor typo fix --- salt/cloud/clouds/digital_ocean.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/cloud/clouds/digital_ocean.py b/salt/cloud/clouds/digital_ocean.py index 7686898b8d..b227da247e 100644 --- a/salt/cloud/clouds/digital_ocean.py +++ b/salt/cloud/clouds/digital_ocean.py @@ -342,7 +342,7 @@ def create(vm_): ) if ssh_interface == 'private': - log.info("ssh_interafce: Setting interface for ssh to 'private'.") + log.info("ssh_interface: Setting interface for ssh to 'private'.") kwargs['ssh_interface'] = ssh_interface else: if ssh_interface != 'public': @@ -350,7 +350,7 @@ def create(vm_): "The DigitalOcean driver requires ssh_interface to be defined as 'public' or 'private'." ) else: - log.info("ssh_interafce: Setting interface for ssh to 'public'.") + log.info("ssh_interface: Setting interface for ssh to 'public'.") kwargs['ssh_interface'] = ssh_interface private_networking = config.get_cloud_config_value( From 0021b65ec22bb9fbb7e5f0ab3dfdefecb684a94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCttler?= Date: Fri, 3 Mar 2017 13:20:13 +0100 Subject: [PATCH 352/370] Changed "Template is an empty file" to debug. --- salt/template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/template.py b/salt/template.py index efff27eba7..ac097ae300 100644 --- a/salt/template.py +++ b/salt/template.py @@ -68,7 +68,7 @@ def compile_template(template, return ret # Template is an empty file if salt.utils.is_empty(template): - log.warning('Template is an empty file: {0}'.format(template)) + log.debug('Template is an empty file: {0}'.format(template)) return ret with codecs.open(template, encoding=SLS_ENCODING) as ifile: From c687b6112a14a8ae23060fcc3f202523cf42ce61 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 12:38:00 +0000 Subject: [PATCH 353/370] Account for test module names prefixed with `tests.` --- tests/runtests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/runtests.py b/tests/runtests.py index b056267035..58c3425718 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -569,7 +569,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): if self.options.name: for test in self.options.name: - if test.startswith('unit.'): + if test.startswith(('tests.unit.', 'unit.')): named_unit_test.append(test) continue named_tests.append(test) @@ -611,7 +611,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): load_from_name=False) status.append(results) continue - if name.startswith('unit.'): + if name.startswith(('tests.unit.', 'unit.')): continue results = self.run_suite('', name, suffix='test_*.py', load_from_name=True) status.append(results) @@ -627,7 +627,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser): named_unit_test = [] if self.options.name: for test in self.options.name: - if not test.startswith('unit.'): + if not test.startswith(('tests.unit.', 'unit.')): continue named_unit_test.append(test) From 3b0b60dd9f8ae76a8c13b261adab037ef3dbb011 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 12:39:20 +0000 Subject: [PATCH 354/370] Error out when the path passed is not valid tests module --- tests/support/parser/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/support/parser/__init__.py b/tests/support/parser/__init__.py index d1882f999c..c7d5979d54 100644 --- a/tests/support/parser/__init__.py +++ b/tests/support/parser/__init__.py @@ -315,13 +315,12 @@ class SaltTestingParser(optparse.OptionParser): if not self.options.name: self.options.name = [] for fpath in self.args: - if not os.path.isfile(fpath): + if os.path.isfile(fpath) and \ + fpath.endswith('.py') and \ + os.path.basename(fpath).startswith('test_'): + self.options.name.append(fpath) continue - if not fpath.endswith('.py'): - continue - if not os.path.basename(fpath).startswith('test_'): - continue - self.options.name.append(fpath) + self.exit(status=1, msg='\'{}\' is not a valid test module'.format(fpath)) print_header(u'', inline=True, width=self.options.output_columns) self.pre_execution_cleanup() From e180f1e913592850eb9231c52802a68f6c16ee91 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 00:29:43 +0000 Subject: [PATCH 355/370] Normalize the mode --- salt/modules/file.py | 3 +++ tests/integration/states/test_file.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index e3bfedb97e..c4e0431481 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -5051,6 +5051,9 @@ def makedirs_(path, ''' path = os.path.expanduser(path) + if mode: + mode = salt.utils.normalize_mode(mode) + # walk up the directory structure until we find the first existing # directory dirname = os.path.normpath(os.path.dirname(path)) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index 801b0b4126..4070880730 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -360,7 +360,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): ret = self.run_function('state.sls', [state_name]) self.assertSaltTrueReturn(ret) - #Check to make sure the file was created + # Check to make sure the file was created check_file = self.run_function('file.file_exists', [FILEPILLAR]) self.assertTrue(check_file) @@ -375,7 +375,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): ret = self.run_function('state.sls', [state_name]) self.assertSaltTrueReturn(ret) - #Check to make sure the file was created + # Check to make sure the file was created check_file = self.run_function('file.file_exists', [FILEPILLARDEF]) self.assertTrue(check_file) @@ -390,7 +390,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): ret = self.run_function('state.sls', [state_name]) self.assertSaltTrueReturn(ret) - #Check to make sure the file was created + # Check to make sure the file was created check_file = self.run_function('file.file_exists', [FILEPILLARGIT]) self.assertTrue(check_file) @@ -610,7 +610,7 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): if os.path.islink(sym_dir): os.unlink(sym_dir) - @skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test') + @skip_if_not_root @skipIf(IS_WINDOWS, 'Mode not available in Windows') def test_directory_max_depth(self): ''' From d3bfaac650dfdb23598abdc9ae749b0797290ec1 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 15:18:15 +0000 Subject: [PATCH 356/370] Gate 3rd party import --- salt/cloud/clouds/packet.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/salt/cloud/clouds/packet.py b/salt/cloud/clouds/packet.py index 182f1c2d34..827215f919 100644 --- a/salt/cloud/clouds/packet.py +++ b/salt/cloud/clouds/packet.py @@ -53,7 +53,13 @@ from __future__ import absolute_import import logging import pprint import time -import packet + +# Import 3rd-party libs +try: + import packet + HAS_PACKET = True +except ImportError: + HAS_PACKET = False # Import Salt Libs import salt.config as config @@ -89,6 +95,8 @@ def __virtual__(): ''' Check for Packet configs. ''' + if HAS_PACKET is False: + return False, 'The packet python library is not installed' if get_configured_provider() is False: return False From 43dcc01275cfd40a6aaee4c6a64587239302968b Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 15:18:42 +0000 Subject: [PATCH 357/370] Separate the error --- salt/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/loader.py b/salt/loader.py index c19e5881cf..575e31dc03 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -1611,7 +1611,7 @@ class LazyLoader(salt.utils.lazy.LazyDict): except Exception as exc: error_reason = ( 'Exception raised when processing __virtual__ function' - ' for {0}. Module will not be loaded {1}'.format( + ' for {0}. Module will not be loaded: {1}'.format( module_name, exc)) log.error(error_reason, exc_info_on_loglevel=logging.DEBUG) virtual = None From 5f388e7ea2df758fb65bd54738d29d14370a53a5 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 15:19:24 +0000 Subject: [PATCH 358/370] Minor fixes --- tests/unit/test_test_module_names.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/unit/test_test_module_names.py b/tests/unit/test_test_module_names.py index c13884b3de..899fddfa24 100644 --- a/tests/unit/test_test_module_names.py +++ b/tests/unit/test_test_module_names.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ''' - tests.unit.doc_test - ~~~~~~~~~~~~~~~~~~~~ + tests.unit.test_test_module_name + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' # Import Python libs @@ -10,10 +10,7 @@ import os # Import Salt Testing libs from tests.support.unit import TestCase - - -# Import Salt libs -import tests.integration as integration +from tests.support.paths import CODE_DIR EXCLUDED_DIRS = [ 'tests/pkg', @@ -56,11 +53,10 @@ class BadTestModuleNamesTestCase(TestCase): Make sure all test modules conform to the test_*.py naming scheme ''' excluded_dirs = tuple(EXCLUDED_DIRS) - code_dir = integration.CODE_DIR - tests_dir = os.path.join(code_dir, 'tests') + tests_dir = os.path.join(CODE_DIR, 'tests') bad_names = [] for root, dirs, files in os.walk(tests_dir): - reldir = os.path.relpath(root, code_dir) + reldir = os.path.relpath(root, CODE_DIR) if reldir.startswith(excluded_dirs) or reldir.endswith('__pycache__'): continue for fname in files: From f5de085ac4694db47d2d6e3c888f357a8c336e49 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 15:19:34 +0000 Subject: [PATCH 359/370] Add test case which will catch SOME problems with __virtual__ calls. And also 3rd-party import errors. --- tests/unit/test_module_virtual_returns.py | 237 ++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 tests/unit/test_module_virtual_returns.py diff --git a/tests/unit/test_module_virtual_returns.py b/tests/unit/test_module_virtual_returns.py new file mode 100644 index 0000000000..a319e7e637 --- /dev/null +++ b/tests/unit/test_module_virtual_returns.py @@ -0,0 +1,237 @@ +# -*- coding: utf-8 -*- +''' + tests.unit.test_module_virtual_returns + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +''' + +# Import Python libs +from __future__ import absolute_import +import os +import imp +import sys +import copy +import types +from contextlib import contextmanager + +# Import 3rd-party libs +import salt.ext.six as six + +# Import Salt Testing libs +from tests.support.unit import TestCase, skipIf +from tests.support.paths import CODE_DIR +from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch + +# Import salt libs +import salt.utils +import salt.config +import salt.loader + +SUFFIXES_MAP = {} +for (suffix, mode, kind) in salt.loader.SUFFIXES: + SUFFIXES_MAP[suffix] = (suffix, mode, kind) + + +@skipIf(NO_MOCK, NO_MOCK_REASON) +class BadLoaderModuleVirtualFunctionReturnsTestCase(TestCase): + ''' + Unit test case for testing bad returns on loader modules + ''' + maxDiff = None + + @classmethod + def setUpClass(cls): + ctx = {} + opts = salt.config.DEFAULT_MINION_OPTS + opts['ext_pillar'] = [] + opts['master_tops'] = {} + grains = salt.loader.grains(opts) + utils = salt.loader.utils(opts, context=ctx) + funcs = salt.loader.minion_mods(opts, context=ctx, utils=utils) + cls.loader_module_globals = { + '__opts__': opts, + '__salt__': funcs, + '__utils__': utils, + '__grains__': grains, + '__active_provider_name__': None + } + + @classmethod + def tearDownClass(cls): + del cls.loader_module_globals + + @contextmanager + def patch_module(self, loader_module): + loader_module_name = loader_module.__name__ + loader_module_globals = getattr(self, 'loader_module_globals', None) + loader_module_blacklisted_dunders = getattr(self, 'loader_module_blacklisted_dunders', ()) + #if loader_module_globals is None: + # loader_module_globals = {} + #elif callable(loader_module_globals): + # loader_module_globals = loader_module_globals() + #else: + # loader_module_globals = copy.deepcopy(loader_module_globals) + + salt_dunders = ( + '__opts__', '__salt__', '__runner__', '__context__', '__utils__', + '__ext_pillar__', '__thorium__', '__states__', '__serializers__', '__ret__', + '__grains__', '__pillar__', '__sdb__', + # Proxy is commented out on purpose since some code in salt expects a NameError + # and is most of the time not a required dunder + '__proxy__' + ) + for dunder_name in salt_dunders: + if dunder_name not in loader_module_globals: + if dunder_name in loader_module_blacklisted_dunders: + continue + loader_module_globals[dunder_name] = {} + + for key in loader_module_globals: + if not hasattr(loader_module, key): + if key in salt_dunders: + setattr(loader_module, key, {}) + else: + setattr(loader_module, key, None) + + if loader_module_globals: + patcher = patch.multiple(loader_module, **loader_module_globals) + patcher.start() + + yield loader_module + + if loader_module_globals: + patcher.stop() + del loader_module_globals + + def get_loader_modules_for_path(self, path): + for fname in os.listdir(path): + if not fname.endswith('.py'): + continue + if fname == '__init__.py': + continue + with salt.utils.fopen(os.path.join(path, fname)) as rfh: + if 'def __virtual__():' not in rfh.read(): + continue + yield os.path.join(path, fname) + + @contextmanager + def load_module(self, modpath): + relmodpath = os.path.relpath(modpath, CODE_DIR) + no_ext, ext = os.path.splitext(relmodpath) + modnamespace = no_ext.replace(os.sep, '.') + with salt.utils.fopen(modpath) as rfh: + mod = imp.load_module(modnamespace, rfh, modpath, SUFFIXES_MAP[ext]) + with self.patch_module(mod): + yield mod + sys.modules.pop(modnamespace, None) + del mod + + def run_test_for_path(self, path): + failures = [] + import_errors = [] + for modpath in self.get_loader_modules_for_path(path): + try: + with self.load_module(modpath) as mod: + virtual_return = mod.__virtual__() + if isinstance(virtual_return, (tuple, bool, six.string_types)): + continue + failures.append((os.path.relpath(modpath, CODE_DIR), virtual_return)) + except ImportError as exc: + import_errors.append((os.path.relpath(modpath, CODE_DIR), str(exc))) + + if failures: + errmsg = '\n\nThe following modules \'__virtual__()\' call returns are invalid:\n\n' + for modpath, returned in failures: + errmsg += ' {}.__virtual__() returned {}\n'.format(modpath, returned) + self.assertEqual(failures, [], errmsg) + if import_errors: + errmsg = '\n\nThe following modules are not gatting external library imports:\n\n' + for modpath, exc in import_errors: + errmsg += ' {} raised an import error when loading: {}\n'.format(modpath, exc) + self.assertEqual(import_errors, [], errmsg) + + def test_minion_mods(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'modules')) + + def test_engines(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'engines')) + + def test_proxy(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'proxy')) + + def test_returners(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'returners')) + + #def test_utils(self): + # self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'utils')) + + def test_pillars(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'pillar')) + + def test_tops(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'tops')) + + def test_wheels(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'wheel')) + + def test_outputters(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'output')) + + def test_serializers(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'serializers')) + + def test_auth(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'auth')) + + def test_fileserver(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'fileserver')) + + def test_roster(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'roster')) + + def test_thorium(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'thorium')) + + def test_states(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'states')) + + def test_beacons(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'beacons')) + + def test_search(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'search')) + + def test_log_handlers(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'log', 'handlers')) + + def test_renderers(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'renderers')) + + def test_grains(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'grains')) + + def test_runners(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'runners')) + + def test_queues(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'queues')) + + def test_sdb(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'sdb')) + + def test_spm_pkgdb(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'spm', 'pkgdb')) + + def test_spm_pkgfiles(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'spm', 'pkgfiles')) + + def test_clouds(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'cloud', 'clouds')) + + def test_netapi(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'netapi')) + + def test_executors(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'executors')) + + def test_cache(self): + self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'cache')) From 2633f70c3ae214656298846da27f6d3868153afe Mon Sep 17 00:00:00 2001 From: Seth House Date: Fri, 3 Mar 2017 10:13:59 -0700 Subject: [PATCH 360/370] Add dummy kwarg to WheelClient().cmd_sync() to match mixin At some point these two kwargs should be wired up to match RunnerClient. --- salt/wheel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/wheel/__init__.py b/salt/wheel/__init__.py index dc6ee5010a..ef1b55fbba 100644 --- a/salt/wheel/__init__.py +++ b/salt/wheel/__init__.py @@ -75,7 +75,7 @@ class WheelClient(salt.client.mixins.SyncClientMixin, salt.utils.error.raise_error(**ret['error']) return ret - def cmd_sync(self, low, timeout=None): + def cmd_sync(self, low, timeout=None, full_return=False): ''' Execute a wheel function synchronously; eauth is respected From 54891a57b17380baa9b71be158ed7bcc2d3cf1c9 Mon Sep 17 00:00:00 2001 From: twangboy Date: Fri, 3 Mar 2017 10:24:28 -0700 Subject: [PATCH 361/370] Fix type in second worktree_path --- tests/integration/modules/test_git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/modules/test_git.py b/tests/integration/modules/test_git.py index 0d80ff2e7e..7e8b1d75b1 100644 --- a/tests/integration/modules/test_git.py +++ b/tests/integration/modules/test_git.py @@ -939,7 +939,7 @@ class GitModuleTest(integration.ModuleCase): # Even though this is Windows, git commands return a unix style path if salt.utils.is_windows(): worktree_path = worktree_path.replace('\\', '/') - worktree_path = worktree_path.replace('\\', '/') + worktree_path2 = worktree_path2.replace('\\', '/') # Add the worktrees ret = self.run_function( From 4b616714604e8aa29235fab2387c7d20037bbcf1 Mon Sep 17 00:00:00 2001 From: Tobias Macey Date: Fri, 3 Mar 2017 12:13:57 -0500 Subject: [PATCH 362/370] Added fix for empty overrides value in apply config methods In `apply_minion_config` and `apply_master_config` there is a call to `overrides.get` while the `overrides` value still has the potential of being `None`. Updated the call to be `(overrides or {}).get` to prevent unwarranted exceptions. --- salt/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index faed486a4a..49e005764a 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -3278,7 +3278,7 @@ def apply_minion_config(overrides=None, if 'beacons' not in opts: opts['beacons'] = {} - if overrides.get('ipc_write_buffer', '') == 'dynamic': + if (overrides or {}).get('ipc_write_buffer', '') == 'dynamic': opts['ipc_write_buffer'] = _DFLT_IPC_WBUFFER if 'ipc_write_buffer' not in overrides: opts['ipc_write_buffer'] = 0 @@ -3363,7 +3363,7 @@ def apply_master_config(overrides=None, defaults=None): ) opts['token_dir'] = os.path.join(opts['cachedir'], 'tokens') opts['syndic_dir'] = os.path.join(opts['cachedir'], 'syndics') - if overrides.get('ipc_write_buffer', '') == 'dynamic': + if (overrides or {}).get('ipc_write_buffer', '') == 'dynamic': opts['ipc_write_buffer'] = _DFLT_IPC_WBUFFER if 'ipc_write_buffer' not in overrides: opts['ipc_write_buffer'] = 0 From 08eba84cfb842412c57b81d0ad02afd35f79c79b Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 17:42:36 +0000 Subject: [PATCH 363/370] Upgrade the six library 1.10.0 ------ - Issue benjaminp/six#122: Improve the performance of `six.int2byte` on Python 3. - Pull request benjaminp/six#55 and issue benjaminp/six#99: Don't add the `winreg` module to `six.moves` on non-Windows platforms. - Pull request benjaminp/six#60 and issue benjaminp/six#108: Add `six.moves.getcwd` and `six.moves.getcwdu`. - Pull request benjaminp/six#64: Add `create_unbound_method` to create unbound methods. --- salt/ext/six.py | 74 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/salt/ext/six.py b/salt/ext/six.py index ffee22b6e9..b7ffcc8e8c 100644 --- a/salt/ext/six.py +++ b/salt/ext/six.py @@ -36,12 +36,13 @@ import sys import types __author__ = "Benjamin Peterson " -__version__ = "1.9.0" +__version__ = "1.10.0" # Useful for very coarse version differentiation. PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 +PY34 = sys.version_info[0:2] >= (3, 4) if PY3: string_types = str, @@ -64,6 +65,7 @@ else: else: # It's possible to have sizeof(long) != sizeof(Py_ssize_t). class X(object): + def __len__(self): return 1 << 31 try: @@ -95,7 +97,7 @@ class _LazyDescr(object): def __get__(self, obj, tp): result = self._resolve() - setattr(obj, self.name, result) # Invokes __set__. + setattr(obj, self.name, result) # Invokes __set__. try: # This is a bit ugly, but it avoids running this again by # removing this descriptor. @@ -167,12 +169,14 @@ class MovedAttribute(_LazyDescr): class _SixMetaPathImporter(object): + """ A meta path importer to import six.moves and its submodules. This class implements a PEP302 finder and loader. It should be compatible with Python 2.5 and all existing versions of Python3 """ + def __init__(self, six_module_name): self.name = six_module_name self.known_modules = {} @@ -230,6 +234,7 @@ _importer = _SixMetaPathImporter(__name__) class _MovedItems(_LazyModule): + """Lazy loading of moved objects""" __path__ = [] # mark as package @@ -241,8 +246,10 @@ _moved_attributes = [ MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), MovedAttribute("intern", "__builtin__", "sys"), MovedAttribute("map", "itertools", "builtins", "imap", "map"), + MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"), + MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"), MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), - MovedAttribute("reload_module", "__builtin__", "imp", "reload"), + MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"), MovedAttribute("reduce", "__builtin__", "functools"), MovedAttribute("shlex_quote", "pipes", "shlex", "quote"), MovedAttribute("StringIO", "StringIO", "io"), @@ -252,7 +259,6 @@ _moved_attributes = [ MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), - MovedModule("builtins", "__builtin__"), MovedModule("configparser", "ConfigParser"), MovedModule("copyreg", "copy_reg"), @@ -299,8 +305,13 @@ _moved_attributes = [ MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"), - MovedModule("winreg", "_winreg"), ] +# Add windows specific modules. +if sys.platform == "win32": + _moved_attributes += [ + MovedModule("winreg", "_winreg"), + ] + for attr in _moved_attributes: setattr(_MovedItems, attr.name, attr) if isinstance(attr, MovedModule): @@ -314,6 +325,7 @@ _importer._add_module(moves, "moves") class Module_six_moves_urllib_parse(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_parse""" @@ -353,6 +365,7 @@ _importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_pa class Module_six_moves_urllib_error(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_error""" @@ -372,6 +385,7 @@ _importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.er class Module_six_moves_urllib_request(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_request""" @@ -421,6 +435,7 @@ _importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib. class Module_six_moves_urllib_response(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_response""" @@ -441,6 +456,7 @@ _importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib class Module_six_moves_urllib_robotparser(_LazyModule): + """Lazy loading of moved objects in six.moves.urllib_robotparser""" @@ -458,6 +474,7 @@ _importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.url class Module_six_moves_urllib(types.ModuleType): + """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" __path__ = [] # mark as package parse = _importer._get_module("moves.urllib_parse") @@ -528,6 +545,9 @@ if PY3: create_bound_method = types.MethodType + def create_unbound_method(func, cls): + return func + Iterator = object else: def get_unbound_function(unbound): @@ -536,6 +556,9 @@ else: def create_bound_method(func, obj): return types.MethodType(func, obj, obj.__class__) + def create_unbound_method(func, cls): + return types.MethodType(func, None, cls) + class Iterator(object): def next(self): @@ -574,16 +597,16 @@ if PY3: viewitems = operator.methodcaller("items") else: def iterkeys(d, **kw): - return iter(d.iterkeys(**kw)) + return d.iterkeys(**kw) def itervalues(d, **kw): - return iter(d.itervalues(**kw)) + return d.itervalues(**kw) def iteritems(d, **kw): - return iter(d.iteritems(**kw)) + return d.iteritems(**kw) def iterlists(d, **kw): - return iter(d.iterlists(**kw)) + return d.iterlists(**kw) viewkeys = operator.methodcaller("viewkeys") @@ -602,15 +625,13 @@ _add_doc(iterlists, if PY3: def b(s): return s.encode("latin-1") + def u(s): return s unichr = chr - if sys.version_info[1] <= 1: - def int2byte(i): - return bytes((i,)) - else: - # This is about 2x faster than the implementation above on 3.2+ - int2byte = operator.methodcaller("to_bytes", 1, "big") + import struct + int2byte = struct.Struct(">B").pack + del struct byte2int = operator.itemgetter(0) indexbytes = operator.getitem iterbytes = iter @@ -618,18 +639,25 @@ if PY3: StringIO = io.StringIO BytesIO = io.BytesIO _assertCountEqual = "assertCountEqual" - _assertRaisesRegex = "assertRaisesRegex" - _assertRegex = "assertRegex" + if sys.version_info[1] <= 1: + _assertRaisesRegex = "assertRaisesRegexp" + _assertRegex = "assertRegexpMatches" + else: + _assertRaisesRegex = "assertRaisesRegex" + _assertRegex = "assertRegex" else: def b(s): return s # Workaround for standalone backslash + def u(s): return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") unichr = unichr int2byte = chr + def byte2int(bs): return ord(bs[0]) + def indexbytes(buf, i): return ord(buf[i]) iterbytes = functools.partial(itertools.imap, ord) @@ -657,7 +685,6 @@ def assertRegex(self, *args, **kwargs): if PY3: exec_ = getattr(moves.builtins, "exec") - def reraise(tp, value, tb=None): if value is None: value = tp() @@ -678,7 +705,6 @@ else: _locs_ = _globs_ exec("""exec _code_ in _globs_, _locs_""") - exec_("""def reraise(tp, value, tb=None): raise tp, value, tb """) @@ -706,13 +732,14 @@ if print_ is None: fp = kwargs.pop("file", sys.stdout) if fp is None: return + def write(data): if not isinstance(data, basestring): data = str(data) # If the file has an encoding, encode unicode with it. if (isinstance(fp, file) and - isinstance(data, unicode) and - fp.encoding is not None): + isinstance(data, unicode) and + fp.encoding is not None): errors = getattr(fp, "errors", None) if errors is None: errors = "strict" @@ -755,6 +782,7 @@ if print_ is None: write(end) if sys.version_info[:2] < (3, 3): _print = print_ + def print_(*args, **kwargs): fp = kwargs.get("file", sys.stdout) flush = kwargs.pop("flush", False) @@ -775,12 +803,14 @@ if sys.version_info[0:2] < (3, 4): else: wraps = functools.wraps + def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. class metaclass(meta): + def __new__(cls, name, this_bases, d): return meta(name, bases, d) return type.__new__(metaclass, 'temporary_class', (), {}) @@ -837,7 +867,7 @@ if sys.meta_path: # the six meta path importer, since the other six instance will have # inserted an importer with different class. if (type(importer).__name__ == "_SixMetaPathImporter" and - importer.name == __name__): + importer.name == __name__): del sys.meta_path[i] break del i, importer From 2a6e61a42e0720392501021e4a959f0b88b9bebe Mon Sep 17 00:00:00 2001 From: twangboy Date: Fri, 3 Mar 2017 10:53:12 -0700 Subject: [PATCH 364/370] Add encode for Py3 compatability --- tests/integration/modules/test_git.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/modules/test_git.py b/tests/integration/modules/test_git.py index 7e8b1d75b1..00562ed998 100644 --- a/tests/integration/modules/test_git.py +++ b/tests/integration/modules/test_git.py @@ -48,7 +48,7 @@ def _git_version(): log.debug('Git not installed') return False log.debug('Detected git version %s', git_version) - return LooseVersion(str(git_version.split()[-1])) + return LooseVersion(str(git_version.split()[-1]).encode()) def _worktrees_supported(): @@ -56,7 +56,7 @@ def _worktrees_supported(): Check if the git version is 2.5.0 or later ''' try: - return _git_version() >= LooseVersion('2.5.0') + return _git_version() >= LooseVersion('2.5.0'.encode()) except AttributeError: return False From adacf4cc289614f75a9ae7789b4b70c4b15b5b18 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 18:24:44 +0000 Subject: [PATCH 365/370] Don't expect any ordering from sets!!!!! --- salt/state.py | 12 ++++++++---- .../files/file/base/issue-7649-handle-iorder.sls | 12 ++++++------ tests/integration/states/test_handle_iorder.py | 7 +++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/salt/state.py b/salt/state.py index be2652d951..5bca61aa46 100644 --- a/salt/state.py +++ b/salt/state.py @@ -566,7 +566,7 @@ class Compiler(object): continue for state, run in six.iteritems(body): funcs = set() - names = set() + names = [] if state.startswith('__'): continue chunk = {'state': state, @@ -583,7 +583,9 @@ class Compiler(object): if isinstance(arg, dict): for key, val in six.iteritems(arg): if key == 'names': - names.update(val) + for _name in val: + if _name not in names: + names.append(_name) continue else: chunk.update(arg) @@ -1266,7 +1268,7 @@ class State(object): continue for state, run in six.iteritems(body): funcs = set() - names = set() + names = [] if state.startswith('__'): continue chunk = {'state': state, @@ -1285,7 +1287,9 @@ class State(object): if isinstance(arg, dict): for key, val in six.iteritems(arg): if key == 'names': - names.update(val) + for _name in val: + if _name not in names: + names.append(_name) elif key == 'state': # Don't pass down a state override continue diff --git a/tests/integration/files/file/base/issue-7649-handle-iorder.sls b/tests/integration/files/file/base/issue-7649-handle-iorder.sls index 4cfcdd11a0..49e6dfe900 100644 --- a/tests/integration/files/file/base/issue-7649-handle-iorder.sls +++ b/tests/integration/files/file/base/issue-7649-handle-iorder.sls @@ -1,9 +1,9 @@ handle-iorder: cmd: - - cwd: /tmp/ruby-1.9.2-p320 - - names: - - ./configure - - make - - make install - - run + - cwd: /tmp/ruby-1.9.2-p320 + - names: + - ./configure + - make + - make install + - run diff --git a/tests/integration/states/test_handle_iorder.py b/tests/integration/states/test_handle_iorder.py index 9df8d5ff61..b1fc1a0196 100644 --- a/tests/integration/states/test_handle_iorder.py +++ b/tests/integration/states/test_handle_iorder.py @@ -20,8 +20,7 @@ class HandleOrderTest(integration.ModuleCase): ''' ret = self.run_function('state.show_low_sls', mods='issue-7649-handle-iorder') - sorted_chunks = sorted(ret, key=lambda c: c.get('order')) + sorted_chunks = [chunk['name'] for chunk in sorted(ret, key=lambda c: c.get('order'))] - self.assertEqual(sorted_chunks[0]['name'], './configure') - self.assertEqual(sorted_chunks[1]['name'], 'make') - self.assertEqual(sorted_chunks[2]['name'], 'make install') + expected = ['./configure', 'make', 'make install'] + self.assertEqual(expected, sorted_chunks) From f4732d54333c2670b9388c6bd5da37a794e708c1 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 19:28:34 +0000 Subject: [PATCH 366/370] Lint fixes --- tests/unit/test_module_virtual_returns.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/test_module_virtual_returns.py b/tests/unit/test_module_virtual_returns.py index a319e7e637..de7bceaf03 100644 --- a/tests/unit/test_module_virtual_returns.py +++ b/tests/unit/test_module_virtual_returns.py @@ -9,8 +9,6 @@ from __future__ import absolute_import import os import imp import sys -import copy -import types from contextlib import contextmanager # Import 3rd-party libs From 44ba96613b8ca96bde8386d9782a2112c07ece18 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2017 20:35:17 +0000 Subject: [PATCH 367/370] This needs to be done as a PyLint plugin not as this kind of test. It's the only way we can check all code paths of the __virtual__ function. Regarding the 3rd-party modules gating, we also need to create a pylint plugin which known what are the hard deps of Salt and will complain on all other 3rd-party imports. --- tests/unit/test_module_virtual_returns.py | 235 ---------------------- 1 file changed, 235 deletions(-) delete mode 100644 tests/unit/test_module_virtual_returns.py diff --git a/tests/unit/test_module_virtual_returns.py b/tests/unit/test_module_virtual_returns.py deleted file mode 100644 index de7bceaf03..0000000000 --- a/tests/unit/test_module_virtual_returns.py +++ /dev/null @@ -1,235 +0,0 @@ -# -*- coding: utf-8 -*- -''' - tests.unit.test_module_virtual_returns - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -''' - -# Import Python libs -from __future__ import absolute_import -import os -import imp -import sys -from contextlib import contextmanager - -# Import 3rd-party libs -import salt.ext.six as six - -# Import Salt Testing libs -from tests.support.unit import TestCase, skipIf -from tests.support.paths import CODE_DIR -from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch - -# Import salt libs -import salt.utils -import salt.config -import salt.loader - -SUFFIXES_MAP = {} -for (suffix, mode, kind) in salt.loader.SUFFIXES: - SUFFIXES_MAP[suffix] = (suffix, mode, kind) - - -@skipIf(NO_MOCK, NO_MOCK_REASON) -class BadLoaderModuleVirtualFunctionReturnsTestCase(TestCase): - ''' - Unit test case for testing bad returns on loader modules - ''' - maxDiff = None - - @classmethod - def setUpClass(cls): - ctx = {} - opts = salt.config.DEFAULT_MINION_OPTS - opts['ext_pillar'] = [] - opts['master_tops'] = {} - grains = salt.loader.grains(opts) - utils = salt.loader.utils(opts, context=ctx) - funcs = salt.loader.minion_mods(opts, context=ctx, utils=utils) - cls.loader_module_globals = { - '__opts__': opts, - '__salt__': funcs, - '__utils__': utils, - '__grains__': grains, - '__active_provider_name__': None - } - - @classmethod - def tearDownClass(cls): - del cls.loader_module_globals - - @contextmanager - def patch_module(self, loader_module): - loader_module_name = loader_module.__name__ - loader_module_globals = getattr(self, 'loader_module_globals', None) - loader_module_blacklisted_dunders = getattr(self, 'loader_module_blacklisted_dunders', ()) - #if loader_module_globals is None: - # loader_module_globals = {} - #elif callable(loader_module_globals): - # loader_module_globals = loader_module_globals() - #else: - # loader_module_globals = copy.deepcopy(loader_module_globals) - - salt_dunders = ( - '__opts__', '__salt__', '__runner__', '__context__', '__utils__', - '__ext_pillar__', '__thorium__', '__states__', '__serializers__', '__ret__', - '__grains__', '__pillar__', '__sdb__', - # Proxy is commented out on purpose since some code in salt expects a NameError - # and is most of the time not a required dunder - '__proxy__' - ) - for dunder_name in salt_dunders: - if dunder_name not in loader_module_globals: - if dunder_name in loader_module_blacklisted_dunders: - continue - loader_module_globals[dunder_name] = {} - - for key in loader_module_globals: - if not hasattr(loader_module, key): - if key in salt_dunders: - setattr(loader_module, key, {}) - else: - setattr(loader_module, key, None) - - if loader_module_globals: - patcher = patch.multiple(loader_module, **loader_module_globals) - patcher.start() - - yield loader_module - - if loader_module_globals: - patcher.stop() - del loader_module_globals - - def get_loader_modules_for_path(self, path): - for fname in os.listdir(path): - if not fname.endswith('.py'): - continue - if fname == '__init__.py': - continue - with salt.utils.fopen(os.path.join(path, fname)) as rfh: - if 'def __virtual__():' not in rfh.read(): - continue - yield os.path.join(path, fname) - - @contextmanager - def load_module(self, modpath): - relmodpath = os.path.relpath(modpath, CODE_DIR) - no_ext, ext = os.path.splitext(relmodpath) - modnamespace = no_ext.replace(os.sep, '.') - with salt.utils.fopen(modpath) as rfh: - mod = imp.load_module(modnamespace, rfh, modpath, SUFFIXES_MAP[ext]) - with self.patch_module(mod): - yield mod - sys.modules.pop(modnamespace, None) - del mod - - def run_test_for_path(self, path): - failures = [] - import_errors = [] - for modpath in self.get_loader_modules_for_path(path): - try: - with self.load_module(modpath) as mod: - virtual_return = mod.__virtual__() - if isinstance(virtual_return, (tuple, bool, six.string_types)): - continue - failures.append((os.path.relpath(modpath, CODE_DIR), virtual_return)) - except ImportError as exc: - import_errors.append((os.path.relpath(modpath, CODE_DIR), str(exc))) - - if failures: - errmsg = '\n\nThe following modules \'__virtual__()\' call returns are invalid:\n\n' - for modpath, returned in failures: - errmsg += ' {}.__virtual__() returned {}\n'.format(modpath, returned) - self.assertEqual(failures, [], errmsg) - if import_errors: - errmsg = '\n\nThe following modules are not gatting external library imports:\n\n' - for modpath, exc in import_errors: - errmsg += ' {} raised an import error when loading: {}\n'.format(modpath, exc) - self.assertEqual(import_errors, [], errmsg) - - def test_minion_mods(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'modules')) - - def test_engines(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'engines')) - - def test_proxy(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'proxy')) - - def test_returners(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'returners')) - - #def test_utils(self): - # self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'utils')) - - def test_pillars(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'pillar')) - - def test_tops(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'tops')) - - def test_wheels(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'wheel')) - - def test_outputters(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'output')) - - def test_serializers(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'serializers')) - - def test_auth(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'auth')) - - def test_fileserver(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'fileserver')) - - def test_roster(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'roster')) - - def test_thorium(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'thorium')) - - def test_states(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'states')) - - def test_beacons(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'beacons')) - - def test_search(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'search')) - - def test_log_handlers(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'log', 'handlers')) - - def test_renderers(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'renderers')) - - def test_grains(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'grains')) - - def test_runners(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'runners')) - - def test_queues(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'queues')) - - def test_sdb(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'sdb')) - - def test_spm_pkgdb(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'spm', 'pkgdb')) - - def test_spm_pkgfiles(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'spm', 'pkgfiles')) - - def test_clouds(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'cloud', 'clouds')) - - def test_netapi(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'netapi')) - - def test_executors(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'executors')) - - def test_cache(self): - self.run_test_for_path(os.path.join(CODE_DIR, 'salt', 'cache')) From 830c4b89148a37648dfb493e4ae763151e48ed07 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 3 Mar 2017 16:19:08 -0600 Subject: [PATCH 368/370] Fix regression in docker module when client is spawned PR #39597 broke this module by introducing an UnboundLocalError. This fixes that error. --- salt/modules/docker.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/salt/modules/docker.py b/salt/modules/docker.py index 5bbec5e9ca..6fc100c655 100644 --- a/salt/modules/docker.py +++ b/salt/modules/docker.py @@ -807,9 +807,8 @@ def _get_client(timeout=None): - docker.version: API version to use (default: "auto") ''' if 'docker.client' not in __context__: - if timeout is None: - client_kwargs = {} - else: + client_kwargs = {} + if timeout is not None: client_kwargs['timeout'] = timeout for key, val in (('base_url', 'docker.url'), ('version', 'docker.version')): From 573d6e9dfb851827655789e220a45ce7501494e0 Mon Sep 17 00:00:00 2001 From: Silvio Moioli Date: Sat, 4 Mar 2017 14:48:05 +0100 Subject: [PATCH 369/370] minionswarm.py: add flag to delay starts --- tests/minionswarm.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/minionswarm.py b/tests/minionswarm.py index 4e0de30fa8..cfb0192450 100644 --- a/tests/minionswarm.py +++ b/tests/minionswarm.py @@ -130,6 +130,12 @@ def parse(): dest='transport', default='zeromq', help='Declare which transport to use, default is zeromq') + parser.add_option( + '--start-delay', + dest='start_delay', + default=0.0, + type='float', + help='Seconds to wait between minion starts') parser.add_option( '-c', '--config-dir', default='', help=('Pass in a configuration directory containing base configuration.') @@ -276,6 +282,7 @@ class MinionSwarm(Swarm): else: cmd += ' -d &' subprocess.call(cmd, shell=True) + time.sleep(self.opts['start_delay']) def mkconf(self, idx): ''' From faffb834a6526b58d2905000931f32aeabb9dead Mon Sep 17 00:00:00 2001 From: Mike Place Date: Thu, 2 Mar 2017 20:52:59 -0700 Subject: [PATCH 370/370] Support the creation of .zip thin file --- salt/runners/thin.py | 6 ++++-- salt/utils/thin.py | 43 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/salt/runners/thin.py b/salt/runners/thin.py index 42cbd03f09..c1172965a6 100644 --- a/salt/runners/thin.py +++ b/salt/runners/thin.py @@ -16,7 +16,8 @@ import salt.utils.thin def generate(extra_mods='', overwrite=False, so_mods='', - python2_bin='python2', python3_bin='python3', absonly=True): + python2_bin='python2', python3_bin='python3', absonly=True, + compress='gzip'): ''' Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma @@ -41,7 +42,8 @@ def generate(extra_mods='', overwrite=False, so_mods='', so_mods, python2_bin, python3_bin, - absonly) + absonly, + compress) def generate_min(extra_mods='', overwrite=False, so_mods='', diff --git a/salt/utils/thin.py b/salt/utils/thin.py index 17b9237c0a..f18704aa62 100644 --- a/salt/utils/thin.py +++ b/salt/utils/thin.py @@ -154,7 +154,8 @@ def get_tops(extra_mods='', so_mods=''): def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='', - python2_bin='python2', python3_bin='python3', absonly=True): + python2_bin='python2', python3_bin='python3', absonly=True, + compress='gzip'): ''' Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma @@ -172,7 +173,11 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='', thindir = os.path.join(cachedir, 'thin') if not os.path.isdir(thindir): os.makedirs(thindir) - thintar = os.path.join(thindir, 'thin.tgz') + if compress == 'gzip': + thin_ext = 'tgz' + elif compress == 'zip': + thin_ext = 'zip' + thintar = os.path.join(thindir, 'thin.' + thin_ext) thinver = os.path.join(thindir, 'version') pythinver = os.path.join(thindir, '.thin-gen-py-version') salt_call = os.path.join(thindir, 'salt-call') @@ -261,7 +266,10 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='', except ValueError: pass - tfp = tarfile.open(thintar, 'w:gz', dereference=True) + if compress == 'gzip': + tfp = tarfile.open(thintar, 'w:gz', dereference=True) + elif compress == 'zip': + tfp = zipfile.ZipFile(thintar, 'w') try: # cwd may not exist if it was removed but salt was run from it start_dir = os.getcwd() except OSError: @@ -285,25 +293,42 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='', if not os.path.isdir(top): # top is a single file module if os.path.exists(os.path.join(top_dirname, base)): - tfp.add(base, arcname=os.path.join('py{0}'.format(py_ver), base)) + if compress == 'gzip': + tfp.add(base, arcname=os.path.join('py{0}'.format(py_ver), base)) + elif compress == 'zip': + tfp.write(base, arcname=os.path.join('py{0}'.format(py_ver), base)) continue for root, dirs, files in os.walk(base, followlinks=True): for name in files: if not name.endswith(('.pyc', '.pyo')): - tfp.add(os.path.join(root, name), - arcname=os.path.join('py{0}'.format(py_ver), root, name)) + if compress == 'gzip': + tfp.add(os.path.join(root, name), + arcname=os.path.join('py{0}'.format(py_ver), root, name)) + elif compress == 'zip': + try: + # This is a little slow but there's no clear way to detect duplicates + tfp.getinfo(os.path.join('py{0}'.format(py_ver), root, name)) + except KeyError: + tfp.write(os.path.join(root, name), arcname=os.path.join('py{0}'.format(py_ver), root, name)) if tempdir is not None: shutil.rmtree(tempdir) tempdir = None os.chdir(thindir) - tfp.add('salt-call') + if compress == 'gzip': + tfp.add('salt-call') + elif compress == 'zip': + tfp.write('salt-call') with salt.utils.fopen(thinver, 'w+') as fp_: fp_.write(salt.version.__version__) with salt.utils.fopen(pythinver, 'w+') as fp_: fp_.write(str(sys.version_info[0])) os.chdir(os.path.dirname(thinver)) - tfp.add('version') - tfp.add('.thin-gen-py-version') + if compress == 'gzip': + tfp.add('version') + tfp.add('.thin-gen-py-version') + elif compress == 'zip': + tfp.write('version') + tfp.write('.thin-gen-py-version') if start_dir: os.chdir(start_dir) tfp.close()