From f84bee7faaded8609981dc8e9039a121fb2f3a50 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Tue, 16 May 2017 15:59:52 -0700 Subject: [PATCH] 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 --- ironic/tests/unit/common/test_utils.py | 91 -------------------------- 1 file changed, 91 deletions(-) diff --git a/ironic/tests/unit/common/test_utils.py b/ironic/tests/unit/common/test_utils.py index cfb5e91c3f..ef040b9143 100644 --- a/ironic/tests/unit/common/test_utils.py +++ b/ironic/tests/unit/common/test_utils.py @@ -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,