Merge pull request #36680 from rallytime/merge-2016.3

[2016.3] Merge forward from 2015.8 to 2016.3
This commit is contained in:
Nicole Thomas 2016-09-29 10:49:16 -06:00 committed by GitHub
commit f95dd696e5
6 changed files with 46 additions and 68 deletions

View File

@ -70,7 +70,7 @@ class GrainsTargetingTest(integration.ShellCase):
# ping disconnected minion and ensure it times out and returns with correct message # ping disconnected minion and ensure it times out and returns with correct message
try: try:
ret = '' 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:': if item != 'disconnected:':
ret = item.strip() ret = item.strip()
self.assertEqual(ret, test_ret) self.assertEqual(ret, test_ret)

View File

@ -1,13 +1,9 @@
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}: required_state:
virtualenv: test:
- managed - succeed_without_changes
- system_site_packages: False
- distribute: True
pep8-pip: requiring_state:
pip: test:
- installed - succeed_without_changes
- name: pep8
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
- require: - require:
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }} - test: required_state

View File

@ -1,11 +1,6 @@
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}: required_state: test.succeed_without_changes
virtualenv.managed:
- system_site_packages: False
- distribute: True
pep8-pip: requiring_state:
pip.installed: test.succeed_without_changes:
- name: pep8
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
- require: - require:
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }} - test: required_state

View File

@ -41,6 +41,12 @@ class PipModuleTest(integration.ModuleCase):
os.makedirs(self.pip_temp) os.makedirs(self.pip_temp)
os.environ['PIP_SOURCE_DIR'] = os.environ['PIP_BUILD_DIR'] = '' 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',)): def pip_successful_install(self, target, expect=('flake8', 'pep8',)):
''' '''
isolate regex for extracting `successful install` message from pip 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, 'pip.install', requirements=req1_filename, user=this_user,
no_chown=True, bin_env=self.venv_dir 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: try:
self.assertEqual(ret['retcode'], 0) self.assertEqual(ret['retcode'], 0)
self.assertIn('installed pep8', ret['stdout']) self.assertIn('installed pep8', ret['stdout'])
@ -313,6 +321,8 @@ class PipModuleTest(integration.ModuleCase):
# Let's create the testing virtualenv # Let's create the testing virtualenv
self.run_function('virtualenv.create', [self.venv_dir]) self.run_function('virtualenv.create', [self.venv_dir])
ret = self.run_function('pip.install', ['pep8'], bin_env=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.assertEqual(ret['retcode'], 0)
self.assertIn('installed pep8', ret['stdout']) self.assertIn('installed pep8', ret['stdout'])
ret = self.run_function( ret = self.run_function(
@ -332,6 +342,8 @@ class PipModuleTest(integration.ModuleCase):
ret = self.run_function( ret = self.run_function(
'pip.install', ['pep8==1.3.4'], bin_env=self.venv_dir '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: try:
self.assertEqual(ret['retcode'], 0) self.assertEqual(ret['retcode'], 0)
self.assertIn('installed pep8', ret['stdout']) self.assertIn('installed pep8', ret['stdout'])
@ -346,7 +358,8 @@ class PipModuleTest(integration.ModuleCase):
bin_env=self.venv_dir, bin_env=self.venv_dir,
upgrade=True upgrade=True
) )
if self._check_download_error(ret['stdout']):
self.skipTest('Test skipped due to pip download error')
try: try:
self.assertEqual(ret['retcode'], 0) self.assertEqual(ret['retcode'], 0)
self.assertIn('installed pep8', ret['stdout']) self.assertIn('installed pep8', ret['stdout'])
@ -380,6 +393,8 @@ class PipModuleTest(integration.ModuleCase):
editable='{0}'.format(','.join(editables)), editable='{0}'.format(','.join(editables)),
bin_env=self.venv_dir bin_env=self.venv_dir
) )
if self._check_download_error(ret['stdout']):
self.skipTest('Test skipped due to pip download error')
try: try:
self.assertEqual(ret['retcode'], 0) self.assertEqual(ret['retcode'], 0)
self.assertIn( self.assertIn(
@ -403,6 +418,8 @@ class PipModuleTest(integration.ModuleCase):
editable='{0}'.format(','.join(editables)), editable='{0}'.format(','.join(editables)),
bin_env=self.venv_dir bin_env=self.venv_dir
) )
if self._check_download_error(ret['stdout']):
self.skipTest('Test skipped due to pip download error')
try: try:
self.assertEqual(ret['retcode'], 0) self.assertEqual(ret['retcode'], 0)
for package in ('Blinker', 'SaltTesting', 'pep8'): for package in ('Blinker', 'SaltTesting', 'pep8'):

View File

@ -326,38 +326,22 @@ class StateModuleTest(integration.ModuleCase,
with salt.utils.fopen(template_path, 'r') as fp_: with salt.utils.fopen(template_path, 'r') as fp_:
template = fp_.read() template = fp_.read()
try:
ret = self.run_function( ret = self.run_function(
'state.template_str', [template], timeout=120 'state.template_str', [template], timeout=120
) )
self.assertSaltTrueReturn(ret) 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 # Now using state.template
try:
ret = self.run_function( ret = self.run_function(
'state.template', [template_path], timeout=120 'state.template', [template_path], timeout=120
) )
self.assertSaltTrueReturn(ret) self.assertSaltTrueReturn(ret)
finally:
if os.path.isdir(venv_dir):
shutil.rmtree(venv_dir)
# Now the problematic #2068 including dot's # Now the problematic #2068 including dot's
try:
ret = self.run_function( ret = self.run_function(
'state.sls', mods='issue-2068-template-str', timeout=120 'state.sls', mods='issue-2068-template-str', timeout=120
) )
self.assertSaltTrueReturn(ret) self.assertSaltTrueReturn(ret)
finally:
if os.path.isdir(venv_dir):
shutil.rmtree(venv_dir)
# Let's load the template from the filesystem. If running this state # Let's load the template from the filesystem. If running this state
# with state.sls works, so should using state.template_str # 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_: with salt.utils.fopen(template_path, 'r') as fp_:
template = fp_.read() template = fp_.read()
try:
ret = self.run_function( ret = self.run_function(
'state.template_str', [template], timeout=120 'state.template_str', [template], timeout=120
) )
self.assertSaltTrueReturn(ret) 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 # Now using state.template
try:
ret = self.run_function( ret = self.run_function(
'state.template', [template_path], timeout=120 'state.template', [template_path], timeout=120
) )
self.assertSaltTrueReturn(ret) self.assertSaltTrueReturn(ret)
finally:
if os.path.isdir(venv_dir):
shutil.rmtree(venv_dir)
def test_template_invalid_items(self): def test_template_invalid_items(self):
TEMPLATE = textwrap.dedent('''\ TEMPLATE = textwrap.dedent('''\

View File

@ -417,8 +417,6 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
stat3 = os.stat(output_file) stat3 = os.stat(output_file)
# Mode must have changed since we're creating a new log file # Mode must have changed since we're creating a new log file
self.assertNotEqual(stat1.st_mode, stat3.st_mode) self.assertNotEqual(stat1.st_mode, stat3.st_mode)
# Data was appended to file
self.assertEqual(stat1.st_size, stat3.st_size)
finally: finally:
if os.path.exists(output_file): if os.path.exists(output_file):
os.unlink(output_file) os.unlink(output_file)