Exemplo n.º 1
0
   def test_link_down(self):
      # Create a echo stub process
      self.stub = EchoStub(self.url, "my_echo_proc")

      # Hunt the stub  process
      gw = ogre.create(self.url, "testprocess")
      gw.hunt("my_echo_proc")
      pid = gw.receive().sender()

      # Test if working
      sig = ogre_sig.ogre_sync_req()
      sig.t1 = 47
      gw.send(sig, pid)
      rsp = gw.receive()
      self.assertEqual(47, rsp.t1)

      # Kill the node
      gw.send(ogre.UnknownSignal(1), pid)
      print 'Stop the node:'
      print '  telnet %s' % (os.environ['OGRE_NODE'])
      print '  reload'

      # All connection methods shall raise exception now
      self.assertRaises(ogre.ConnectionLostError, gw.receive)
      self.assertRaises(ogre.ConnectionLostError, gw.send, sig, pid)
      self.assertRaises(ogre.ConnectionLostError, gw.hunt, 'kalle')
      gw.close()
Exemplo n.º 2
0
 def test_echo(self):
    proc = ogre.DspProcess(self.url, 'ogre_dsp1', self.dedicated_server)
    sig = ogre_sig.ogre_sync_req()
    sig.t1 = 47
    proc.send(sig)
    rsp = proc.receive()
    self.assertEqual(47, rsp.t1)
    proc.close()
Exemplo n.º 3
0
   def _send_receive_small_signal(self, p):
      sig = ogre_sig.ogre_sync_req()
      sig.t1 = 101
      sig.t2 = 102
      sig.t3 = 103
      sig.t4 = 104

      # Send and wait for a reply
      p.send(sig)
      reply = p.receive()

      # Verify the reply
      self.assertEqual(101, reply.t1)
      self.assertEqual(102, reply.t2)
      self.assertEqual(103, reply.t3)
      self.assertEqual(104, reply.t4)
Exemplo n.º 4
0
   def test_multiple(self):
      proc1 = ogre.DspProcess(self.url, 'ogre_dsp1', self.dedicated_server)
      proc2 = ogre.DspProcess(self.url, 'ogre_dsp2', self.dedicated_server)

      sig = ogre_sig.ogre_sync_req()
      sig.t1 = 37
      proc2.send(sig)
      proc2.send(sig)

      count = 0
      for proc,sig in ogre.DspProcess.receive_any([proc1, proc2], timeout=1):
         print proc,sig
         self.assertEqual(37, sig.t1)
         count += 1
      self.assertEqual(2, count)
      
      proc1.close()
      proc2.close()
Exemplo n.º 5
0
   def test_link_down_process(self):
      # Create a echo stub process
      self.stub = EchoStub(self.url, "my_echo_proc")

      # Hunt the stub  process
      proc = ogre.Process(self.url, 'my_echo_proc', supervise=False)

      # Test if working
      sig = ogre_sig.ogre_sync_req()
      sig.t1 = 47
      proc.send(sig)
      rsp = proc.receive()
      self.assertEqual(47, rsp.t1)

      # Kill the node
      proc.send(ogre.UnknownSignal(1))
      print 'Stop the node:'
      print '  telnet %s' % (os.environ['OGRE_NODE'])
      print '  reload'

      # All process methods shall raise exception
      self.assertRaises(ogre.ConnectionLostError, proc.receive)
      self.assertRaises(ogre.ConnectionLostError, proc.send, sig)
      proc.close()