diff options
author | armando-migliaccio <armamig@gmail.com> | 2015-04-07 15:37:59 -0700 |
---|---|---|
committer | armando-migliaccio <armamig@gmail.com> | 2015-04-07 16:40:47 -0700 |
commit | 31631e82bbf974c50fb913dafe0ad86e2c0e6a8b (patch) | |
tree | 02de5812cd674a61944359c54f9ea2b24d954377 | |
parent | 7f143e75ee84514aeb01acced927aa5ead7f8d42 (diff) | |
download | neutron-31631e82bbf974c50fb913dafe0ad86e2c0e6a8b.tar.gz |
Fix intermittent UT failures in test_utils
Change eba4c2941ee introduced these tests. However they are not that useful as they
simply mimick the code, without really ensuring that the behavior is expected, so
they provide negative value ([1]), plus, they fail randomly.
This patch removes them in favor of a more useful functional check.
[1] http://googletesting.blogspot.com/2015/01/testing-on-toilet-change-detector-tests.html
Closes-bug: #1441347
Change-Id: I8a321995295deef7f6d30be303486be491e2771f
-rw-r--r-- | neutron/tests/functional/agent/linux/test_process_monitor.py | 6 | ||||
-rw-r--r-- | neutron/tests/unit/agent/linux/test_utils.py | 16 |
2 files changed, 6 insertions, 16 deletions
diff --git a/neutron/tests/functional/agent/linux/test_process_monitor.py b/neutron/tests/functional/agent/linux/test_process_monitor.py index 1bf50803fc..51bf796682 100644 --- a/neutron/tests/functional/agent/linux/test_process_monitor.py +++ b/neutron/tests/functional/agent/linux/test_process_monitor.py @@ -12,6 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +import os + from oslo_config import cfg from six import moves @@ -78,6 +80,10 @@ class BaseTestProcessMonitor(base.BaseTestCase): def all_children_active(): return all(pm.active for pm in self._child_processes) + for pm in self._child_processes: + directory = os.path.dirname(pm.get_pid_file_name()) + self.assertEqual(0o755, os.stat(directory).st_mode & 0o777) + # we need to allow extra_time for the check process to happen # and properly execute action over the gone processes under # high load conditions diff --git a/neutron/tests/unit/agent/linux/test_utils.py b/neutron/tests/unit/agent/linux/test_utils.py index a1e1b85f2e..512f1bd778 100644 --- a/neutron/tests/unit/agent/linux/test_utils.py +++ b/neutron/tests/unit/agent/linux/test_utils.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import os - import mock import socket import testtools @@ -227,20 +225,6 @@ class TestBaseOSUtils(base.BaseTestCase): EGID = 456 EGNAME = 'group' - @mock.patch.object(os.path, 'isdir', return_value=False) - @mock.patch.object(os, 'makedirs') - def test_ensure_dir_not_exist(self, makedirs, isdir): - utils.ensure_dir('/the') - isdir.assert_called_once_with('/the') - makedirs.assert_called_once_with('/the', 0o755) - - @mock.patch.object(os.path, 'isdir', return_value=True) - @mock.patch.object(os, 'makedirs') - def test_ensure_dir_exist(self, makedirs, isdir): - utils.ensure_dir('/the') - isdir.assert_called_once_with('/the') - self.assertFalse(makedirs.called) - @mock.patch('os.geteuid', return_value=EUID) @mock.patch('pwd.getpwuid', return_value=FakeUser(EUNAME)) def test_is_effective_user_id(self, getpwuid, geteuid): |