Merge branch '2017.7' into windows_pr_builds

This commit is contained in:
Daniel Wozniak 2018-08-27 18:51:28 -07:00 committed by GitHub
commit b9fa7db67e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 77 additions and 42 deletions

View File

@ -37,7 +37,10 @@ def inet_pton(address_family, ip_string):
# This will catch IP Addresses such as 10.1.2
if address_family == socket.AF_INET:
try:
ipaddress.ip_address(six.u(ip_string))
if isinstance(ip_string, six.binary_type):
ipaddress.ip_address(six.u(ip_string))
else:
ipaddress.ip_address(ip_string)
except ValueError:
raise socket.error('illegal IP address string passed to inet_pton')
return socket.inet_aton(ip_string)

View File

@ -19,7 +19,7 @@ class BatchTest(ShellCase):
Tests executing a simple batch command to help catch regressions
'''
ret = 'Executing run on [\'sub_minion\']'
cmd = self.run_salt('\'*\' test.echo \'batch testing\' -b 50%')
cmd = self.run_salt('"*minion" test.echo "batch testing" -b 50%')
self.assertIn(ret, cmd)
def test_batch_run_number(self):
@ -28,7 +28,7 @@ class BatchTest(ShellCase):
a percentage with full batch CLI call.
'''
ret = "Executing run on ['minion', 'sub_minion']"
cmd = self.run_salt('\'*\' test.ping --batch-size 2')
cmd = self.run_salt('"*minion" test.ping --batch-size 2')
self.assertIn(ret, cmd)
def test_batch_run_grains_targeting(self):
@ -45,7 +45,7 @@ class BatchTest(ShellCase):
os_grain = item
os_grain = os_grain.strip()
cmd = self.run_salt('-G \'os:{0}\' -b 25% test.ping'.format(os_grain))
cmd = self.run_salt('-C "G@os:{0} and not localhost" -b 25% test.ping'.format(os_grain))
self.assertIn(sub_min_ret, cmd)
self.assertIn(min_ret, cmd)

View File

@ -40,17 +40,17 @@ class GrainsTargetingTest(ShellCase):
if item != 'minion:':
os_grain = item.strip()
ret = self.run_salt('-G \'os:{0}\' test.ping'.format(os_grain))
ret = self.run_salt('-G "os:{0}" test.ping'.format(os_grain))
self.assertEqual(sorted(ret), sorted(test_ret))
def test_grains_targeting_minion_id_running(self):
'''
Tests return of each running test minion targeting with minion id grain
'''
minion = self.run_salt('-G \'id:minion\' test.ping')
minion = self.run_salt('-G "id:minion" test.ping')
self.assertEqual(sorted(minion), sorted(['minion:', ' True']))
sub_minion = self.run_salt('-G \'id:sub_minion\' test.ping')
sub_minion = self.run_salt('-G "id:sub_minion" test.ping')
self.assertEqual(sorted(sub_minion), sorted(['sub_minion:', ' True']))
@flaky
@ -69,7 +69,7 @@ class GrainsTargetingTest(ShellCase):
# ping disconnected minion and ensure it times out and returns with correct message
try:
ret = ''
for item in self.run_salt('-t 1 -G \'id:disconnected\' test.ping', timeout=40):
for item in self.run_salt('-t 1 -G "id:disconnected" test.ping', timeout=40):
if item != 'disconnected:':
ret = item.strip()
assert ret == test_ret

View File

@ -18,6 +18,7 @@ from tests.support.helpers import destructiveTest
import salt.utils
# Import 3rd party libs
from salt.ext import six
try:
import zipfile # pylint: disable=W0611
HAS_ZIPFILE = True
@ -44,40 +45,44 @@ class ArchiveTest(ModuleCase):
self.arch = os.path.join(self.base_path, 'archive.{0}'.format(arch_fmt))
self.dst = os.path.join(self.base_path, '{0}_dst_dir'.format(arch_fmt))
def _set_up(self, arch_fmt):
def _set_up(self, arch_fmt, unicode_filename=False):
'''
Create source file tree and destination directory
:param str arch_fmt: The archive format used in the test
'''
# Setup artifact paths
self._set_artifact_paths(arch_fmt)
# Remove the artifacts if any present
if any([os.path.exists(f) for f in (self.src, self.arch, self.dst)]):
self._tear_down()
self._set_artifact_paths(arch_fmt)
# Create source
os.makedirs(self.src)
with salt.utils.fopen(os.path.join(self.src, 'file'), 'w') as theorem:
theorem.write(textwrap.dedent(r'''\
if unicode_filename:
filename = 'file®'
else:
filename = 'file'
with salt.utils.fopen(os.path.join(self.src, filename), 'wb') as theorem:
theorem.write(salt.utils.to_bytes(textwrap.dedent('''\
Compression theorem of computational complexity theory:
Given a Gödel numbering $φ$ of the computable functions and a
Blum complexity measure $Φ$ where a complexity class for a
boundary function $f$ is defined as
$\mathrm C(f) := \{φ_i \mathbb R^{(1)} | (^ x) Φ_i(x) f(x)\}$.
$\\mathrm C(f) := \\{φ_i \\mathbb R^{(1)} | (^ x) Φ_i(x) f(x)\\}$.
Then there exists a total computable function $f$ so that for
all $i$
$\mathrm{Dom}(φ_i) = \mathrm{Dom}(φ_{f(i)})$
$\\mathrm{Dom}(φ_i) = \\mathrm{Dom}(φ_{f(i)})$
and
$\mathrm C(φ_i) \mathrm{C}(φ_{f(i)})$.
'''))
$\\mathrm C(φ_i) \\mathrm{C}(φ_{f(i)})$.
''')))
# Create destination
os.makedirs(self.dst)
@ -97,19 +102,32 @@ class ArchiveTest(ModuleCase):
del self.arch
del self.src_file
def _assert_artifacts_in_ret(self, ret, file_only=False):
def _assert_artifacts_in_ret(self, ret, file_only=False, unix_sep=False):
'''
Assert that the artifact source files are printed in the source command
output
'''
def normdir(path):
normdir = os.path.normcase(os.path.abspath(path))
if salt.utils.is_windows():
# Remove the drive portion of path
if len(normdir) >= 2 and normdir[1] == ':':
normdir = normdir.split(':', 1)[1]
normdir = normdir.lstrip(os.path.sep)
# Unzipped paths might have unix line endings
if unix_sep:
normdir = normdir.replace(os.path.sep, '/')
return normdir
# Try to find source directory and file in output lines
dir_in_ret = None
file_in_ret = None
for line in ret:
if self.src.lstrip('/') in line \
and not self.src_file.lstrip('/') in line:
if normdir(self.src) in line \
and not normdir(self.src_file) in line:
dir_in_ret = True
if self.src_file.lstrip('/') in line:
if normdir(self.src_file) in line:
file_in_ret = True
# Assert number of lines, reporting of source directory and file
@ -231,8 +249,8 @@ class ArchiveTest(ModuleCase):
# Test create archive
ret = self.run_function('archive.unzip', [self.arch, self.dst])
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self.assertTrue(isinstance(ret, list), six.text_type(ret))
self._assert_artifacts_in_ret(ret, unix_sep=True if six.PY2 else False)
self._tear_down()

View File

@ -318,6 +318,7 @@ class MatchTest(ShellCase, ShellCaseCommonTestsMixin):
data = '\n'.join(data)
self.assertIn('minion', data)
@flaky
def test_salt_documentation(self):
'''
Test to see if we're supporting --doc

View File

@ -38,7 +38,6 @@ from tests.support.mixins import AdaptedConfigurationTestCaseMixin, SaltClientTe
from tests.support.paths import ScriptPathMixin, INTEGRATION_TEST_DIR, CODE_DIR, PYEXEC, SCRIPT_DIR
# Import 3rd-party libs
import salt.utils
import salt.ext.six as six
from salt.ext.six.moves import cStringIO # pylint: disable=import-error
@ -237,25 +236,26 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
'''
Execute a script with the given argument string
'''
import salt.utils
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='
if salt.utils.is_windows():
cmd = 'python '
else:
cmd = 'PYTHONPATH='
python_path = os.environ.get('PYTHONPATH', None)
if python_path is not None:
cmd += '{0}:'.format(python_path)
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)
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)
@ -264,7 +264,7 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
popen_kwargs = {
'shell': True,
'stdout': tmp_file,
'universal_newlines': True
'universal_newlines': True,
}
if catch_stderr is True:

View File

@ -1,14 +1,26 @@
integration.cli.test_batch
integration.cli.test_custom_module
integration.cli.test_grains
integration.client.test_kwarg
integration.client.test_runner
integration.client.test_standard
integration.client.test_syndic
integration.doc.test_man
integration.grains.test_core
integration.grains.test_custom
integration.loader.test_ext_grains
integration.loader.test_ext_modules
integration.logging.test_jid_logging
integration.minion.test_blackout
integration.minion.test_pillar
integration.minion.test_timeout
integration.modules.test_aliases
integration.modules.test_autoruns
integration.modules.test_archive
integration.modules.test_beacons
integration.modules.test_cmdmod
integration.modules.test_config
integration.modules.test_cp
integration.modules.test_cmdmod
integration.modules.test_data
integration.modules.test_disk
integration.modules.test_firewall
@ -30,6 +42,7 @@ integration.modules.test_sysmod
integration.modules.test_system
integration.modules.test_test
integration.modules.test_useradd
integration.modules.test_win_autoruns
integration.modules.test_win_dns_client
integration.modules.test_win_pkg
integration.reactor.test_reactor