Fix intermittent UT failures in test_utils
Change eba4c2941e
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
This commit is contained in:
parent
7f143e75ee
commit
31631e82bb
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue