|
|
|
@ -23,6 +23,8 @@ import testlib
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MuxProcessMixin(object):
|
|
|
|
|
no_zombie_check = True
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def setUpClass(cls):
|
|
|
|
|
#mitogen.utils.log_to_file()
|
|
|
|
@ -61,7 +63,23 @@ class ConnectionMixin(MuxProcessMixin):
|
|
|
|
|
super(ConnectionMixin, self).tearDown()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OptionalIntTest(unittest2.TestCase):
|
|
|
|
|
class MuxShutdownTest(ConnectionMixin, testlib.TestCase):
|
|
|
|
|
def test_connection_failure_raised(self):
|
|
|
|
|
# ensure if a WorkerProcess tries to connect to a MuxProcess that has
|
|
|
|
|
# already shut down, it fails with a graceful error.
|
|
|
|
|
path = self.model._muxes[0].path
|
|
|
|
|
os.rename(path, path + '.tmp')
|
|
|
|
|
try:
|
|
|
|
|
#e = self.assertRaises(ansible.errors.AnsibleError,
|
|
|
|
|
#lambda: self.conn._connect()
|
|
|
|
|
#)
|
|
|
|
|
e = 1
|
|
|
|
|
print(e)
|
|
|
|
|
finally:
|
|
|
|
|
os.rename(path + '.tmp', path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OptionalIntTest(testlib.TestCase):
|
|
|
|
|
func = staticmethod(ansible_mitogen.connection.optional_int)
|
|
|
|
|
|
|
|
|
|
def test_already_int(self):
|
|
|
|
@ -81,7 +99,7 @@ class OptionalIntTest(unittest2.TestCase):
|
|
|
|
|
self.assertEquals(None, self.func({1:2}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PutDataTest(ConnectionMixin, unittest2.TestCase):
|
|
|
|
|
class PutDataTest(ConnectionMixin, testlib.TestCase):
|
|
|
|
|
def test_out_path(self):
|
|
|
|
|
path = tempfile.mktemp(prefix='mitotest')
|
|
|
|
|
contents = mitogen.core.b('contents')
|
|
|
|
@ -102,7 +120,7 @@ class PutDataTest(ConnectionMixin, unittest2.TestCase):
|
|
|
|
|
os.unlink(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PutFileTest(ConnectionMixin, unittest2.TestCase):
|
|
|
|
|
class PutFileTest(ConnectionMixin, testlib.TestCase):
|
|
|
|
|
@classmethod
|
|
|
|
|
def setUpClass(cls):
|
|
|
|
|
super(PutFileTest, cls).setUpClass()
|
|
|
|
|