summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/process_unittest.py44
1 files changed, 25 insertions, 19 deletions
diff --git a/nova/tests/process_unittest.py b/nova/tests/process_unittest.py
index 01648961f..1c15b69a0 100644
--- a/nova/tests/process_unittest.py
+++ b/nova/tests/process_unittest.py
@@ -37,7 +37,7 @@ class ProcessTestCase(test.TrialTestCase):
def test_execute_stdout(self):
pool = process.ProcessPool(2)
- d = pool.simpleExecute('echo test')
+ d = pool.simple_execute('echo test')
def _check(rv):
self.assertEqual(rv[0], 'test\n')
self.assertEqual(rv[1], '')
@@ -48,38 +48,38 @@ class ProcessTestCase(test.TrialTestCase):
def test_execute_stderr(self):
pool = process.ProcessPool(2)
- d = pool.simpleExecute('cat BAD_FILE', error_ok=1)
+ d = pool.simple_execute('cat BAD_FILE', error_ok=1)
def _check(rv):
self.assertEqual(rv[0], '')
self.assert_('No such file' in rv[1])
-
+
d.addCallback(_check)
d.addErrback(self.fail)
return d
def test_execute_unexpected_stderr(self):
pool = process.ProcessPool(2)
- d = pool.simpleExecute('cat BAD_FILE')
+ d = pool.simple_execute('cat BAD_FILE')
d.addCallback(lambda x: self.fail('should have raised an error'))
d.addErrback(lambda failure: failure.trap(IOError))
return d
-
+
def test_max_processes(self):
pool = process.ProcessPool(2)
- d1 = pool.simpleExecute('sleep 0.01')
- d2 = pool.simpleExecute('sleep 0.01')
- d3 = pool.simpleExecute('sleep 0.005')
- d4 = pool.simpleExecute('sleep 0.005')
+ d1 = pool.simple_execute('sleep 0.01')
+ d2 = pool.simple_execute('sleep 0.01')
+ d3 = pool.simple_execute('sleep 0.005')
+ d4 = pool.simple_execute('sleep 0.005')
called = []
def _called(rv, name):
called.append(name)
-
+
d1.addCallback(_called, 'd1')
d2.addCallback(_called, 'd2')
d3.addCallback(_called, 'd3')
d4.addCallback(_called, 'd4')
-
+
# Make sure that d3 and d4 had to wait on the other two and were called
# in order
# NOTE(termie): there may be a race condition in this test if for some
@@ -92,25 +92,31 @@ class ProcessTestCase(test.TrialTestCase):
def test_kill_long_process(self):
pool = process.ProcessPool(2)
-
- d1 = pool.simpleExecute('sleep 1')
- d2 = pool.simpleExecute('sleep 0.005')
+
+ d1 = pool.simple_execute('sleep 1')
+ d2 = pool.simple_execute('sleep 0.005')
timeout = reactor.callLater(0.1, self.fail, 'should have been killed')
-
+
# kill d1 and wait on it to end then cancel the timeout
d2.addCallback(lambda _: d1.process.signalProcess('KILL'))
d2.addCallback(lambda _: d1)
d2.addBoth(lambda _: timeout.active() and timeout.cancel())
d2.addErrback(self.fail)
return d2
-
+
def test_process_exit_is_contained(self):
pool = process.ProcessPool(2)
-
- d1 = pool.simpleExecute('sleep 1')
+
+ d1 = pool.simple_execute('sleep 1')
d1.addCallback(lambda x: self.fail('should have errbacked'))
d1.addErrback(lambda fail: fail.trap(IOError))
reactor.callLater(0.05, d1.process.signalProcess, 'KILL')
-
+
return d1
+
+ def test_shared_pool_is_singleton(self):
+ pool1 = process.SharedPool()
+ pool2 = process.SharedPool()
+ self.assert_(id(pool1) == id(pool2))
+