Show More
@@ -65,7 +65,7 b' def setup():' | |||||
65 | if cp.poll() is not None: |
|
65 | if cp.poll() is not None: | |
66 | print cp.poll() |
|
66 | print cp.poll() | |
67 | raise RuntimeError("The test controller failed to start.") |
|
67 | raise RuntimeError("The test controller failed to start.") | |
68 |
elif time.time()-tic > 1 |
|
68 | elif time.time()-tic > 15: | |
69 | raise RuntimeError("Timeout waiting for the test controller to start.") |
|
69 | raise RuntimeError("Timeout waiting for the test controller to start.") | |
70 | time.sleep(0.1) |
|
70 | time.sleep(0.1) | |
71 | add_engines(1) |
|
71 | add_engines(1) | |
@@ -93,7 +93,7 b" def add_engines(n=1, profile='iptest', total=False):" | |||||
93 | while len(rc) < base+n: |
|
93 | while len(rc) < base+n: | |
94 | if any([ ep.poll() is not None for ep in eps ]): |
|
94 | if any([ ep.poll() is not None for ep in eps ]): | |
95 | raise RuntimeError("A test engine failed to start.") |
|
95 | raise RuntimeError("A test engine failed to start.") | |
96 |
elif time.time()-tic > 1 |
|
96 | elif time.time()-tic > 15: | |
97 | raise RuntimeError("Timeout waiting for engines to connect.") |
|
97 | raise RuntimeError("Timeout waiting for engines to connect.") | |
98 | time.sleep(.1) |
|
98 | time.sleep(.1) | |
99 | rc.spin() |
|
99 | rc.spin() |
@@ -154,7 +154,7 b' class AsyncResultTest(ClusterTestCase):' | |||||
154 | ar = v.apply_async(time.sleep, 0.25) |
|
154 | ar = v.apply_async(time.sleep, 0.25) | |
155 | self.assertRaises(TimeoutError, getattr, ar, 'serial_time') |
|
155 | self.assertRaises(TimeoutError, getattr, ar, 'serial_time') | |
156 | ar.get(2) |
|
156 | ar.get(2) | |
157 |
self.assertTrue(ar.serial_time < |
|
157 | self.assertTrue(ar.serial_time < 1.) | |
158 | self.assertTrue(ar.serial_time > 0.2) |
|
158 | self.assertTrue(ar.serial_time > 0.2) | |
159 |
|
159 | |||
160 | def test_serial_time_multi(self): |
|
160 | def test_serial_time_multi(self): | |
@@ -171,8 +171,8 b' class AsyncResultTest(ClusterTestCase):' | |||||
171 | ar = v.apply_async(time.sleep, 0.25) |
|
171 | ar = v.apply_async(time.sleep, 0.25) | |
172 | while not ar.ready(): |
|
172 | while not ar.ready(): | |
173 | time.sleep(0.01) |
|
173 | time.sleep(0.01) | |
174 |
self.assertTrue(ar.elapsed < |
|
174 | self.assertTrue(ar.elapsed < 1) | |
175 |
self.assertTrue(ar.elapsed < |
|
175 | self.assertTrue(ar.elapsed < 1) | |
176 | ar.get(2) |
|
176 | ar.get(2) | |
177 |
|
177 | |||
178 | def test_elapsed_multi(self): |
|
178 | def test_elapsed_multi(self): | |
@@ -180,8 +180,8 b' class AsyncResultTest(ClusterTestCase):' | |||||
180 | ar = v.apply_async(time.sleep, 0.25) |
|
180 | ar = v.apply_async(time.sleep, 0.25) | |
181 | while not ar.ready(): |
|
181 | while not ar.ready(): | |
182 | time.sleep(0.01) |
|
182 | time.sleep(0.01) | |
183 |
self.assertTrue(ar.elapsed < |
|
183 | self.assertTrue(ar.elapsed < 1) | |
184 |
self.assertTrue(ar.elapsed < |
|
184 | self.assertTrue(ar.elapsed < 1) | |
185 | ar.get(2) |
|
185 | ar.get(2) | |
186 |
|
186 | |||
187 | def test_hubresult_timestamps(self): |
|
187 | def test_hubresult_timestamps(self): |
@@ -575,13 +575,23 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
575 |
|
575 | |||
576 |
|
576 | |||
577 | # begin execute tests |
|
577 | # begin execute tests | |
|
578 | def _wait_for(self, f, timeout=10): | |||
|
579 | tic = time.time() | |||
|
580 | while time.time() <= tic + timeout: | |||
|
581 | if f(): | |||
|
582 | return | |||
|
583 | time.sleep(0.1) | |||
|
584 | self.client.spin() | |||
|
585 | if not f(): | |||
|
586 | print "Warning: Awaited condition never arrived" | |||
|
587 | ||||
578 |
|
588 | |||
579 | def test_execute_reply(self): |
|
589 | def test_execute_reply(self): | |
580 | e0 = self.client[self.client.ids[0]] |
|
590 | e0 = self.client[self.client.ids[0]] | |
581 | e0.block = True |
|
591 | e0.block = True | |
582 | ar = e0.execute("5", silent=False) |
|
592 | ar = e0.execute("5", silent=False) | |
583 | er = ar.get() |
|
593 | er = ar.get() | |
584 | time.sleep(0.2) |
|
594 | self._wait_for(lambda : bool(er.pyout)) | |
585 | self.assertEquals(str(er), "<ExecuteReply[%i]: 5>" % er.execution_count) |
|
595 | self.assertEquals(str(er), "<ExecuteReply[%i]: 5>" % er.execution_count) | |
586 | self.assertEquals(er.pyout['text/plain'], '5') |
|
596 | self.assertEquals(er.pyout['text/plain'], '5') | |
587 |
|
597 | |||
@@ -590,14 +600,15 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
590 | e0.block = True |
|
600 | e0.block = True | |
591 | ar = e0.execute("print (5)", silent=False) |
|
601 | ar = e0.execute("print (5)", silent=False) | |
592 | er = ar.get() |
|
602 | er = ar.get() | |
593 | time.sleep(0.2) |
|
603 | self._wait_for(lambda : bool(er.stdout)) | |
594 | self.assertEquals(er.stdout.strip(), '5') |
|
604 | self.assertEquals(er.stdout.strip(), '5') | |
595 |
|
605 | |||
596 | def test_execute_pyout(self): |
|
606 | def test_execute_pyout(self): | |
597 | """execute triggers pyout with silent=False""" |
|
607 | """execute triggers pyout with silent=False""" | |
598 | view = self.client[:] |
|
608 | view = self.client[:] | |
599 | ar = view.execute("5", silent=False, block=True) |
|
609 | ar = view.execute("5", silent=False, block=True) | |
600 | time.sleep(0.2) |
|
610 | self._wait_for(lambda : all(ar.pyout)) | |
|
611 | ||||
601 | expected = [{'text/plain' : '5'}] * len(view) |
|
612 | expected = [{'text/plain' : '5'}] * len(view) | |
602 | self.assertEquals(ar.pyout, expected) |
|
613 | self.assertEquals(ar.pyout, expected) | |
603 |
|
614 | |||
@@ -615,7 +626,7 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
615 | ar = view.execute("%whos", block=True) |
|
626 | ar = view.execute("%whos", block=True) | |
616 | # this will raise, if that failed |
|
627 | # this will raise, if that failed | |
617 | ar.get(5) |
|
628 | ar.get(5) | |
618 | time.sleep(0.2) |
|
629 | self._wait_for(lambda : all(ar.stdout)) | |
619 | for stdout in ar.stdout: |
|
630 | for stdout in ar.stdout: | |
620 | lines = stdout.splitlines() |
|
631 | lines = stdout.splitlines() | |
621 | self.assertEquals(lines[0].split(), ['Variable', 'Type', 'Data/Info']) |
|
632 | self.assertEquals(lines[0].split(), ['Variable', 'Type', 'Data/Info']) | |
@@ -632,7 +643,8 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
632 | view = self.client[:] |
|
643 | view = self.client[:] | |
633 | view.execute("from IPython.core.display import *") |
|
644 | view.execute("from IPython.core.display import *") | |
634 | ar = view.execute("[ display(i) for i in range(5) ]", block=True) |
|
645 | ar = view.execute("[ display(i) for i in range(5) ]", block=True) | |
635 | time.sleep(0.2) |
|
646 | ||
|
647 | self._wait_for(lambda : all(len(er.outputs) >= 5 for er in ar)) | |||
636 | outs = [ {u'text/plain' : unicode(i)} for i in range(5) ] |
|
648 | outs = [ {u'text/plain' : unicode(i)} for i in range(5) ] | |
637 | expected = [outs] * len(view) |
|
649 | expected = [outs] * len(view) | |
638 | self.assertEquals(ar.outputs, expected) |
|
650 | self.assertEquals(ar.outputs, expected) | |
@@ -648,7 +660,7 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
648 |
|
660 | |||
649 | ar = view.apply_async(publish) |
|
661 | ar = view.apply_async(publish) | |
650 | ar.get(5) |
|
662 | ar.get(5) | |
651 | time.sleep(0.2) |
|
663 | self._wait_for(lambda : all(len(out) >= 5 for out in ar.outputs)) | |
652 | outs = [ {u'text/plain' : unicode(j)} for j in range(5) ] |
|
664 | outs = [ {u'text/plain' : unicode(j)} for j in range(5) ] | |
653 | expected = [outs] * len(view) |
|
665 | expected = [outs] * len(view) | |
654 | self.assertEquals(ar.outputs, expected) |
|
666 | self.assertEquals(ar.outputs, expected) | |
@@ -669,6 +681,7 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
669 | # include imports, in case user config |
|
681 | # include imports, in case user config | |
670 | ar = view.execute("plot(rand(100))", silent=False) |
|
682 | ar = view.execute("plot(rand(100))", silent=False) | |
671 | reply = ar.get(5) |
|
683 | reply = ar.get(5) | |
|
684 | self._wait_for(lambda : all(ar.outputs)) | |||
672 | self.assertEquals(len(reply.outputs), 1) |
|
685 | self.assertEquals(len(reply.outputs), 1) | |
673 | output = reply.outputs[0] |
|
686 | output = reply.outputs[0] | |
674 | self.assertTrue("image/png" in output) |
|
687 | self.assertTrue("image/png" in output) |
General Comments 0
You need to be logged in to leave comments.
Login now