示例#1
0
 def _node_test_simple(self):
     cpg = LoggingCPG('test.group', stop='stop')
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     dispatcher.wait()
     return cpg.messages()
示例#2
0
 def _node_test_simple(self):
     cpg = LoggingCPG("test.group", stop="stop")
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     dispatcher.wait()
     return cpg.messages()
示例#3
0
 def _node_test_ordering(self):
     cpg = LoggingCPG('test.ordering', stop='stop')
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     while not cpg.messages():
         time.sleep(0.5)  # wait for 'start' message'
     for i in range(1000):
         cpg.send_message('test-%d' % random.randint(0, 100000))
     dispatcher.wait()
     return cpg.messages()
示例#4
0
 def _node_test_ordering(self):
     cpg = LoggingCPG("test.ordering", stop="stop")
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     while not cpg.messages():
         time.sleep(0.5)  # wait for 'start' message'
     for i in range(1000):
         cpg.send_message("test-%d" % random.randint(0, 100000))
     dispatcher.wait()
     return cpg.messages()
示例#5
0
 def test_simple(self):
     self.require(cluster=True, nodes=3)
     cpg = LoggingCPG('test.group', stop='stop')
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     self.start_on_cluster_nodes(self._node_test_simple)
     nodes = len(self.cluster_nodes())
     while len(cpg.members()) != nodes + 1:
         time.sleep(0.5)  # wait until everybody has joined
     cpg.send_message('ping')
     cpg.send_message('stop')
     dispatcher.wait()
     assert len(cpg.messages()) == 1
     assert cpg.messages()[0][1] == 'ping'
     result = self.remote_results()
     for res in result:
         assert len(res) == 1
         assert res[0][1] == 'ping'
示例#6
0
 def test_simple(self):
     self.require(cluster=True, nodes=3)
     cpg = LoggingCPG("test.group", stop="stop")
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     self.start_on_cluster_nodes(self._node_test_simple)
     nodes = len(self.cluster_nodes())
     while len(cpg.members()) != nodes + 1:
         time.sleep(0.5)  # wait until everybody has joined
     cpg.send_message("ping")
     cpg.send_message("stop")
     dispatcher.wait()
     assert len(cpg.messages()) == 1
     assert cpg.messages()[0][1] == "ping"
     result = self.remote_results()
     for res in result:
         assert len(res) == 1
         assert res[0][1] == "ping"
示例#7
0
 def test_ordering(self):
     self.require(cluster=True, nodes=3)
     cpg = LoggingCPG('test.ordering', stop='stop')
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     self.start_on_cluster_nodes(self._node_test_ordering)
     nodes = len(self.cluster_nodes())
     while len(cpg.members()) != nodes + 1:
         time.sleep(0.5)  # wait until everybody has joined
     cpg.send_message('start')
     while len(cpg.messages()) != nodes * 1000 + 1:
         time.sleep(0.5)
     cpg.send_message('stop')
     dispatcher.wait()
     assert len(cpg.messages()) == nodes * 1000 + 1
     result = self.remote_results()
     assert len(result) == nodes
     for res in result:
         assert len(res) == nodes * 1000 + 1
     reference = [msg for (addr, msg) in cpg.messages()]
     for res in result:
         messages = [msg for (addr, msg) in res]
         assert messages == reference
示例#8
0
 def test_ordering(self):
     self.require(cluster=True, nodes=3)
     cpg = LoggingCPG("test.ordering", stop="stop")
     dispatcher = ThreadedDispatcher()
     dispatcher.add_service(cpg)
     dispatcher.start()
     self.start_on_cluster_nodes(self._node_test_ordering)
     nodes = len(self.cluster_nodes())
     while len(cpg.members()) != nodes + 1:
         time.sleep(0.5)  # wait until everybody has joined
     cpg.send_message("start")
     while len(cpg.messages()) != nodes * 1000 + 1:
         time.sleep(0.5)
     cpg.send_message("stop")
     dispatcher.wait()
     assert len(cpg.messages()) == nodes * 1000 + 1
     result = self.remote_results()
     assert len(result) == nodes
     for res in result:
         assert len(res) == nodes * 1000 + 1
     reference = [msg for (addr, msg) in cpg.messages()]
     for res in result:
         messages = [msg for (addr, msg) in res]
         assert messages == reference