mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #36680 from rallytime/merge-2016.3
[2016.3] Merge forward from 2015.8 to 2016.3
This commit is contained in:
commit
f95dd696e5
@ -70,7 +70,7 @@ class GrainsTargetingTest(integration.ShellCase):
|
||||
# ping disconnected minion and ensure it times out and returns with correct message
|
||||
try:
|
||||
ret = ''
|
||||
for item in self.run_salt('-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()
|
||||
self.assertEqual(ret, test_ret)
|
||||
|
@ -1,13 +1,9 @@
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}:
|
||||
virtualenv:
|
||||
- managed
|
||||
- system_site_packages: False
|
||||
- distribute: True
|
||||
required_state:
|
||||
test:
|
||||
- succeed_without_changes
|
||||
|
||||
pep8-pip:
|
||||
pip:
|
||||
- installed
|
||||
- name: pep8
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
requiring_state:
|
||||
test:
|
||||
- succeed_without_changes
|
||||
- require:
|
||||
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
- test: required_state
|
||||
|
@ -1,11 +1,6 @@
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}:
|
||||
virtualenv.managed:
|
||||
- system_site_packages: False
|
||||
- distribute: True
|
||||
required_state: test.succeed_without_changes
|
||||
|
||||
pep8-pip:
|
||||
pip.installed:
|
||||
- name: pep8
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
requiring_state:
|
||||
test.succeed_without_changes:
|
||||
- require:
|
||||
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
- test: required_state
|
||||
|
@ -41,6 +41,12 @@ class PipModuleTest(integration.ModuleCase):
|
||||
os.makedirs(self.pip_temp)
|
||||
os.environ['PIP_SOURCE_DIR'] = os.environ['PIP_BUILD_DIR'] = ''
|
||||
|
||||
def _check_download_error(self, ret):
|
||||
'''
|
||||
Checks to see if a download error looks transitory
|
||||
'''
|
||||
return any(w in ret for w in ['URLError'])
|
||||
|
||||
def pip_successful_install(self, target, expect=('flake8', 'pep8',)):
|
||||
'''
|
||||
isolate regex for extracting `successful install` message from pip
|
||||
@ -301,6 +307,8 @@ class PipModuleTest(integration.ModuleCase):
|
||||
'pip.install', requirements=req1_filename, user=this_user,
|
||||
no_chown=True, bin_env=self.venv_dir
|
||||
)
|
||||
if self._check_download_error(ret['stdout']):
|
||||
self.skipTest('Test skipped due to pip download error')
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
self.assertIn('installed pep8', ret['stdout'])
|
||||
@ -313,6 +321,8 @@ class PipModuleTest(integration.ModuleCase):
|
||||
# Let's create the testing virtualenv
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
ret = self.run_function('pip.install', ['pep8'], bin_env=self.venv_dir)
|
||||
if self._check_download_error(ret['stdout']):
|
||||
self.skipTest('Test skipped due to pip download error')
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
self.assertIn('installed pep8', ret['stdout'])
|
||||
ret = self.run_function(
|
||||
@ -332,6 +342,8 @@ class PipModuleTest(integration.ModuleCase):
|
||||
ret = self.run_function(
|
||||
'pip.install', ['pep8==1.3.4'], bin_env=self.venv_dir
|
||||
)
|
||||
if self._check_download_error(ret['stdout']):
|
||||
self.skipTest('Test skipped due to pip download error')
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
self.assertIn('installed pep8', ret['stdout'])
|
||||
@ -346,7 +358,8 @@ class PipModuleTest(integration.ModuleCase):
|
||||
bin_env=self.venv_dir,
|
||||
upgrade=True
|
||||
)
|
||||
|
||||
if self._check_download_error(ret['stdout']):
|
||||
self.skipTest('Test skipped due to pip download error')
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
self.assertIn('installed pep8', ret['stdout'])
|
||||
@ -380,6 +393,8 @@ class PipModuleTest(integration.ModuleCase):
|
||||
editable='{0}'.format(','.join(editables)),
|
||||
bin_env=self.venv_dir
|
||||
)
|
||||
if self._check_download_error(ret['stdout']):
|
||||
self.skipTest('Test skipped due to pip download error')
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
self.assertIn(
|
||||
@ -403,6 +418,8 @@ class PipModuleTest(integration.ModuleCase):
|
||||
editable='{0}'.format(','.join(editables)),
|
||||
bin_env=self.venv_dir
|
||||
)
|
||||
if self._check_download_error(ret['stdout']):
|
||||
self.skipTest('Test skipped due to pip download error')
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
for package in ('Blinker', 'SaltTesting', 'pep8'):
|
||||
|
@ -326,38 +326,22 @@ class StateModuleTest(integration.ModuleCase,
|
||||
|
||||
with salt.utils.fopen(template_path, 'r') as fp_:
|
||||
template = fp_.read()
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.template_str', [template], timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
self.assertTrue(
|
||||
os.path.isfile(os.path.join(venv_dir, 'bin', 'pep8'))
|
||||
)
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
|
||||
# Now using state.template
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.template', [template_path], timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
ret = self.run_function(
|
||||
'state.template', [template_path], timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
# Now the problematic #2068 including dot's
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.sls', mods='issue-2068-template-str', timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
ret = self.run_function(
|
||||
'state.sls', mods='issue-2068-template-str', timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
# Let's load the template from the filesystem. If running this state
|
||||
# with state.sls works, so should using state.template_str
|
||||
@ -368,28 +352,16 @@ class StateModuleTest(integration.ModuleCase,
|
||||
|
||||
with salt.utils.fopen(template_path, 'r') as fp_:
|
||||
template = fp_.read()
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.template_str', [template], timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
self.assertTrue(
|
||||
os.path.isfile(os.path.join(venv_dir, 'bin', 'pep8'))
|
||||
)
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
ret = self.run_function(
|
||||
'state.template_str', [template], timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
# Now using state.template
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.template', [template_path], timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
ret = self.run_function(
|
||||
'state.template', [template_path], timeout=120
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
def test_template_invalid_items(self):
|
||||
TEMPLATE = textwrap.dedent('''\
|
||||
|
@ -417,8 +417,6 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
||||
stat3 = os.stat(output_file)
|
||||
# Mode must have changed since we're creating a new log file
|
||||
self.assertNotEqual(stat1.st_mode, stat3.st_mode)
|
||||
# Data was appended to file
|
||||
self.assertEqual(stat1.st_size, stat3.st_size)
|
||||
finally:
|
||||
if os.path.exists(output_file):
|
||||
os.unlink(output_file)
|
||||
|
Loading…
Reference in New Issue
Block a user