diff --git a/doc/topics/releases/2019.2.0.rst b/doc/topics/releases/2019.2.0.rst index 6de65ed381..fe0af4e7bc 100644 --- a/doc/topics/releases/2019.2.0.rst +++ b/doc/topics/releases/2019.2.0.rst @@ -289,7 +289,7 @@ a BGP policy referenced in many places, you can do so by running: .. code-block:: bash - salt '*' net.replae_pattern OLD-POLICY-CONFIG new-policy-config + salt '*' net.replace_pattern OLD-POLICY-CONFIG new-policy-config Similarly, you can also replace entire configuration blocks using the :mod:`net.blockreplace ` function. diff --git a/salt/grains/core.py b/salt/grains/core.py index 7acf07692d..25cd650c7e 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -2141,6 +2141,12 @@ def locale_info(): def hostname(): ''' Return fqdn, hostname, domainname + + .. note:: + On Windows the ``domain`` grain may refer to the dns entry for the host + instead of the Windows domain to which the host is joined. It may also + be empty if not a part of any domain. Refer to the ``windowsdomain`` + grain instead ''' # This is going to need some work # Provides: diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py index 77e172f1ae..28f65e4816 100644 --- a/tests/unit/grains/test_core.py +++ b/tests/unit/grains/test_core.py @@ -136,6 +136,28 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin): os_release = core._parse_os_release('/etc/os-release', '/usr/lib/os-release') self.assertEqual(os_release, {}) + @skipIf(not salt.utils.platform.is_windows(), 'System is not Windows') + def test__windows_platform_data(self): + grains = core._windows_platform_data() + keys = ['biosversion', + 'osrelease', + 'domain', + 'kernelrelease', + 'motherboard', + 'serialnumber', + 'timezone', + 'manufacturer', + 'kernelversion', + 'osservicepack', + 'virtual', + 'productname', + 'osfullname', + 'osmanufacturer', + 'osversion', + 'windowsdomain'] + for key in keys: + self.assertIn(key, grains) + @skipIf(not salt.utils.platform.is_linux(), 'System is not Linux') def test_gnu_slash_linux_in_os_name(self): ''' diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 70def09940..fd82238e8b 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -197,9 +197,12 @@ class SampleConfTest(TestCase): commented out. This test loops through all of the files in that directory to check for any lines that are not commented or blank. ''' - cloud_sample_files = os.listdir(SAMPLE_CONF_DIR + 'cloud.profiles.d/') + cloud_sample_dir = SAMPLE_CONF_DIR + 'cloud.profiles.d/' + if not os.path.exists(cloud_sample_dir): + self.skipTest("Sample config directory '{}' is missing.".format(cloud_sample_dir)) + cloud_sample_files = os.listdir(cloud_sample_dir) for conf_file in cloud_sample_files: - profile_conf = SAMPLE_CONF_DIR + 'cloud.profiles.d/' + conf_file + profile_conf = cloud_sample_dir + conf_file ret = salt.config._read_conf_file(profile_conf) self.assertEqual( ret, @@ -215,9 +218,12 @@ class SampleConfTest(TestCase): commented out. This test loops through all of the files in that directory to check for any lines that are not commented or blank. ''' - cloud_sample_files = os.listdir(SAMPLE_CONF_DIR + 'cloud.providers.d/') + cloud_sample_dir = SAMPLE_CONF_DIR + 'cloud.providers.d/' + if not os.path.exists(cloud_sample_dir): + self.skipTest("Sample config directory '{}' is missing.".format(cloud_sample_dir)) + cloud_sample_files = os.listdir(cloud_sample_dir) for conf_file in cloud_sample_files: - provider_conf = SAMPLE_CONF_DIR + 'cloud.providers.d/' + conf_file + provider_conf = cloud_sample_dir + conf_file ret = salt.config._read_conf_file(provider_conf) self.assertEqual( ret, @@ -233,9 +239,12 @@ class SampleConfTest(TestCase): commented out. This test loops through all of the files in that directory to check for any lines that are not commented or blank. ''' - cloud_sample_files = os.listdir(SAMPLE_CONF_DIR + 'cloud.maps.d/') + cloud_sample_dir = SAMPLE_CONF_DIR + 'cloud.maps.d/' + if not os.path.exists(cloud_sample_dir): + self.skipTest("Sample config directory '{}' is missing.".format(cloud_sample_dir)) + cloud_sample_files = os.listdir(cloud_sample_dir) for conf_file in cloud_sample_files: - map_conf = SAMPLE_CONF_DIR + 'cloud.maps.d/' + conf_file + map_conf = cloud_sample_dir + conf_file ret = salt.config._read_conf_file(map_conf) self.assertEqual( ret, diff --git a/tests/unit/utils/test_extend.py b/tests/unit/utils/test_extend.py index 2cf90fcaaf..9cbb767ca5 100644 --- a/tests/unit/utils/test_extend.py +++ b/tests/unit/utils/test_extend.py @@ -14,7 +14,7 @@ import shutil from datetime import date # Import Salt Testing libs -from tests.support.unit import TestCase +from tests.support.unit import TestCase, skipIf from tests.support.mock import MagicMock, patch # Import salt libs @@ -35,6 +35,8 @@ class ExtendTestCase(TestCase): shutil.rmtree(self.out, True) os.chdir(self.starting_dir) + @skipIf(not os.path.exists(os.path.join(integration.CODE_DIR, 'templates')), + "Test template directory 'templates/' missing.") def test_run(self): with patch('sys.exit', MagicMock): out = salt.utils.extend.run('test', 'test', 'this description', integration.CODE_DIR, False)