Mock out poller in ovsdb unittests
The second thread running in ovsdb connection crashed due to not passing file descriptor to poller. This patch mocks out the poller as it's not used in the tests to avoid false tracebacks in the logs. Change-Id: I62e87e3248d176e5db7fe57bfb4467176ba05392 Closes-Bug: 1583069
This commit is contained in:
parent
0eed94a777
commit
99f2224e6b
|
@ -12,11 +12,13 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import eventlet
|
||||||
import mock
|
import mock
|
||||||
import unittest2
|
import unittest2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ovs.db import idl
|
from ovs.db import idl
|
||||||
|
from ovs import poller
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise unittest2.SkipTest(
|
raise unittest2.SkipTest(
|
||||||
"Skip test since ovs requirement for PY3 doesn't support yet.")
|
"Skip test since ovs requirement for PY3 doesn't support yet.")
|
||||||
|
@ -40,7 +42,9 @@ class TestOVSNativeConnection(base.BaseTestCase):
|
||||||
gsh.return_value = helper = mock.Mock()
|
gsh.return_value = helper = mock.Mock()
|
||||||
self.connection = connection.Connection(
|
self.connection = connection.Connection(
|
||||||
mock.Mock(), mock.Mock(), mock.Mock())
|
mock.Mock(), mock.Mock(), mock.Mock())
|
||||||
self.connection.start(table_name_list=table_name_list)
|
with mock.patch.object(poller, 'Poller') as poller_mock:
|
||||||
|
poller_mock.return_value.block.side_effect = eventlet.sleep
|
||||||
|
self.connection.start(table_name_list=table_name_list)
|
||||||
reg_all_called = table_name_list is None
|
reg_all_called = table_name_list is None
|
||||||
reg_table_called = table_name_list is not None
|
reg_table_called = table_name_list is not None
|
||||||
self.assertEqual(reg_all_called, helper.register_all.called)
|
self.assertEqual(reg_all_called, helper.register_all.called)
|
||||||
|
|
Loading…
Reference in New Issue