Remove unit tests that test oslo_concurrency.processutils.execute
Remove the unit tests that were testing the functionality of oslo_concurrency.processutils.execute. It is not our job to unit test 3rd party libraries. Change-Id: I6a55f572e2e0c648326006c394ea909649a8e72c
This commit is contained in:
parent
20dba3fb88
commit
f84bee7faa
@ -52,97 +52,6 @@ class BareMetalUtilsTestCase(base.TestCase):
|
||||
|
||||
class ExecuteTestCase(base.TestCase):
|
||||
|
||||
def test_retry_on_failure(self):
|
||||
fd, tmpfilename = tempfile.mkstemp()
|
||||
_, tmpfilename2 = tempfile.mkstemp()
|
||||
try:
|
||||
with os.fdopen(fd, 'w+') as fp:
|
||||
fp.write('''#!/bin/sh
|
||||
# If stdin fails to get passed during one of the runs, make a note.
|
||||
if ! grep -q foo
|
||||
then
|
||||
echo 'failure' > "$1"
|
||||
fi
|
||||
# If stdin has failed to get passed during this or a previous run, exit early.
|
||||
if grep failure "$1"
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
runs="$(cat $1)"
|
||||
if [ -z "$runs" ]
|
||||
then
|
||||
runs=0
|
||||
fi
|
||||
runs=$(($runs + 1))
|
||||
echo $runs > "$1"
|
||||
exit 1
|
||||
''')
|
||||
os.chmod(tmpfilename, 0o755)
|
||||
try:
|
||||
self.assertRaises(processutils.ProcessExecutionError,
|
||||
utils.execute,
|
||||
tmpfilename, tmpfilename2, attempts=10,
|
||||
process_input=b'foo',
|
||||
delay_on_retry=False)
|
||||
except OSError as e:
|
||||
if e.errno == errno.EACCES:
|
||||
self.skipTest("Permissions error detected. "
|
||||
"Are you running with a noexec /tmp?")
|
||||
else:
|
||||
raise
|
||||
with open(tmpfilename2, 'r') as fp:
|
||||
runs = fp.read()
|
||||
self.assertNotEqual(runs.strip(), 'failure', 'stdin did not '
|
||||
'always get passed '
|
||||
'correctly')
|
||||
runs = int(runs.strip())
|
||||
self.assertEqual(10, runs,
|
||||
'Ran %d times instead of 10.' % (runs,))
|
||||
finally:
|
||||
os.unlink(tmpfilename)
|
||||
os.unlink(tmpfilename2)
|
||||
|
||||
def test_unknown_kwargs_raises_error(self):
|
||||
self.assertRaises(processutils.UnknownArgumentError,
|
||||
utils.execute,
|
||||
'/usr/bin/env', 'true',
|
||||
this_is_not_a_valid_kwarg=True)
|
||||
|
||||
def test_check_exit_code_boolean(self):
|
||||
utils.execute('/usr/bin/env', 'false', check_exit_code=False)
|
||||
self.assertRaises(processutils.ProcessExecutionError,
|
||||
utils.execute,
|
||||
'/usr/bin/env', 'false', check_exit_code=True)
|
||||
|
||||
def test_no_retry_on_success(self):
|
||||
fd, tmpfilename = tempfile.mkstemp()
|
||||
_, tmpfilename2 = tempfile.mkstemp()
|
||||
try:
|
||||
with os.fdopen(fd, 'w+') as fp:
|
||||
fp.write('''#!/bin/sh
|
||||
# If we've already run, bail out.
|
||||
grep -q foo "$1" && exit 1
|
||||
# Mark that we've run before.
|
||||
echo foo > "$1"
|
||||
# Check that stdin gets passed correctly.
|
||||
grep foo
|
||||
''')
|
||||
os.chmod(tmpfilename, 0o755)
|
||||
try:
|
||||
utils.execute(tmpfilename,
|
||||
tmpfilename2,
|
||||
process_input=b'foo',
|
||||
attempts=2)
|
||||
except OSError as e:
|
||||
if e.errno == errno.EACCES:
|
||||
self.skipTest("Permissions error detected. "
|
||||
"Are you running with a noexec /tmp?")
|
||||
else:
|
||||
raise
|
||||
finally:
|
||||
os.unlink(tmpfilename)
|
||||
os.unlink(tmpfilename2)
|
||||
|
||||
@mock.patch.object(processutils, 'execute', autospec=True)
|
||||
@mock.patch.object(os.environ, 'copy', return_value={}, autospec=True)
|
||||
def test_execute_use_standard_locale_no_env_variables(self, env_mock,
|
||||
|
Loading…
Reference in New Issue
Block a user