def testWorkerPdshBuffers(self): """test buffers at pdsh worker level""" task = task_self() self.assert_(task != None) worker = WorkerPdsh("localhost", command="printf 'foo\nbar\nxxx\n'", handler=None, timeout=None) task.schedule(worker) task.resume() cnt = 2 for buf, nodes in worker.iter_buffers(): cnt -= 1 if buf == "foo\nbar\nxxx\n": self.assertEqual(len(nodes), 1) self.assertEqual(str(nodes), "localhost") self.assertEqual(cnt, 1) # new check in 1.7 to ensure match_keys is not a string testgen = worker.iter_buffers("localhost") # cast to list to effectively iterate self.assertRaises(TypeError, list, testgen) # and also fixed an issue when match_keys was an empty list for buf, nodes in worker.iter_buffers([]): self.assertFalse("Found buffer with empty match_keys?!") for buf, nodes in worker.iter_buffers(["localhost"]): cnt -= 1 if buf == "foo\nbar\nxxx\n": self.assertEqual(len(nodes), 1) self.assertEqual(str(nodes), "localhost") self.assertEqual(cnt, 0)
def testWorkerPdshBuffers(self): """test buffers at pdsh worker level""" task = task_self() self.assert_(task != None) worker = WorkerPdsh("localhost", command="printf 'foo\nbar\nxxx\n'", handler=None, timeout=None) task.schedule(worker) task.resume() cnt = 2 for buf, nodes in worker.iter_buffers(): cnt -= 1 if buf == "foo\nbar\nxxx\n": self.assertEqual(len(nodes), 1) self.assertEqual(str(nodes), "localhost") self.assertEqual(cnt, 1) for buf, nodes in worker.iter_buffers("localhost"): cnt -= 1 if buf == "foo\nbar\nxxx\n": self.assertEqual(len(nodes), 1) self.assertEqual(str(nodes), "localhost") self.assertEqual(cnt, 0)
def testWorkerPdshBuffers(self): # test buffers at pdsh worker level worker = WorkerPdsh(HOSTNAME, command="printf 'foo\nbar\nxxx\n'", handler=None, timeout=None) self._task.schedule(worker) self._task.resume() cnt = 2 for buf, nodes in worker.iter_buffers(): cnt -= 1 if buf == "foo\nbar\nxxx\n": self.assertEqual(len(nodes), 1) self.assertEqual(str(nodes), HOSTNAME) self.assertEqual(cnt, 1) # new check in 1.7 to ensure match_keys is not a string testgen = worker.iter_buffers(HOSTNAME) # cast to list to effectively iterate self.assertRaises(TypeError, list, testgen) # and also fixed an issue when match_keys was an empty list for buf, nodes in worker.iter_buffers([]): self.assertFalse("Found buffer with empty match_keys?!") for buf, nodes in worker.iter_buffers([HOSTNAME]): cnt -= 1 if buf == "foo\nbar\nxxx\n": self.assertEqual(len(nodes), 1) self.assertEqual(str(nodes), HOSTNAME) self.assertEqual(cnt, 0)