def test_send_reliableFirst(self):
     """
     Test that messages are prioritized to reliable subscribers.
     
     This is actually a test of the underlying scheduler more than it is a test
     of the send message, per se.
     """
     
     dest = '/queue/dest'
     conn1 = MockConnection()
     conn1.reliable_subscriber = True
     
     self.qm.subscribe(conn1, dest)
     
     conn2 = MockConnection()
     conn2.reliable_subscriber = False
     self.qm.subscribe(conn2, dest)
     
     f = StompFrame('MESSAGE', headers={'destination': dest, 'message-id': uuid.uuid4()}, body='Empty')
     self.qm.send(f)
         
     print conn1.frames
     print conn2.frames
     assert len(conn1.frames) == 1
     assert len(conn2.frames) == 0
Exemple #2
0
    def test_send_reliableFirst(self):
        """
        Test that messages are prioritized to reliable subscribers.
        
        This is actually a test of the underlying scheduler more than it is a test
        of the send message, per se.
        """

        dest = '/queue/dest'
        conn1 = MockConnection()
        conn1.reliable_subscriber = True

        self.qm.subscribe(conn1, dest)

        conn2 = MockConnection()
        conn2.reliable_subscriber = False
        self.qm.subscribe(conn2, dest)

        f = StompFrame('MESSAGE',
                       headers={
                           'destination': dest,
                           'message-id': uuid.uuid4()
                       },
                       body='Empty')
        self.qm.send(f)

        print conn1.frames
        print conn2.frames
        assert len(conn1.frames) == 1
        assert len(conn2.frames) == 0
 def test_favorReliable(self):
     """ Test the favor reliable delivery scheduler. """
     
     sched = FavorReliableSubscriberScheduler()
     
     conn1 = MockConnection()
     conn1.reliable_subscriber = True
     
     conn2 = MockConnection()
     conn2.reliable_subscriber = False
     
     choice = sched.choice((conn1, conn2), None)
     
     assert choice is conn1, "Expected reliable connection to be selected."
    def test_favorReliable(self):
        """ Test the favor reliable delivery scheduler. """

        sched = FavorReliableSubscriberScheduler()

        conn1 = MockConnection()
        conn1.reliable_subscriber = True

        conn2 = MockConnection()
        conn2.reliable_subscriber = False

        choice = sched.choice((conn1, conn2), None)

        assert choice is conn1, "Expected reliable connection to be selected."
Exemple #5
0
    def test_ack_basic(self):
        """ Test reliable client (ACK) behavior. """

        dest = '/queue/dest'
        conn1 = MockConnection()
        conn1.reliable_subscriber = True

        self.qm.subscribe(conn1, dest)

        m1 = StompFrame('MESSAGE',
                        headers={'destination': dest},
                        body='Message body (1)')
        self.qm.send(m1)

        assert conn1.frames[0] == m1

        m2 = StompFrame('MESSAGE',
                        headers={'destination': dest},
                        body='Message body (2)')
        self.qm.send(m2)

        assert len(conn1.frames
                   ) == 1, "Expected connection to still only have 1 frame."
        assert conn1.frames[0] == m1

        ack = StompFrame('ACK',
                         headers={
                             'destination': dest,
                             'message-id': m1.message_id
                         })
        self.qm.ack(conn1, ack)

        print conn1.frames
        assert len(conn1.frames) == 2, "Expected 2 frames now, after ACK."
        assert conn1.frames[1] == m2
 def test_ack_transaction(self):
     """ Test the reliable client (ACK) behavior with transactions. """
             
     dest = '/queue/dest'
     conn1 = MockConnection()
     conn1.reliable_subscriber = True
     
     self.qm.subscribe(conn1, dest)
     
     m1 = StompFrame('MESSAGE', headers={'destination': dest, }, body='Message body (1)')
     self.qm.send(m1)
     
     assert conn1.frames[0] == m1
     
     m2 = StompFrame('MESSAGE', headers={'destination': dest}, body='Message body (2)')
     self.qm.send(m2)
     
     assert len(conn1.frames) == 1, "Expected connection to still only have 1 frame."
     assert conn1.frames[0] == m1
     
     ack = StompFrame('ACK', headers={'destination': dest, 'transaction': 'abc', 'message-id': m1.message_id})
     self.qm.ack(conn1, ack, transaction='abc')
     
     ack = StompFrame('ACK', headers={'destination': dest, 'transaction': 'abc', 'message-id': m2.message_id})
     self.qm.ack(conn1, ack, transaction='abc')
     
     assert len(conn1.frames) == 2, "Expected 2 frames now, after ACK."
     assert conn1.frames[1] == m2
     
     self.qm.resend_transaction_frames(conn1, transaction='abc')
     
     assert len(conn1.frames) == 3, "Expected 3 frames after re-transmit."
     assert bool(self.qm._pending[conn1]) == True, "Expected 1 pending (waiting on ACK) frame.""" 
     
 def test_ack_basic(self):
     """ Test reliable client (ACK) behavior. """
     
     dest = '/queue/dest'
     conn1 = MockConnection()
     conn1.reliable_subscriber = True
     
     self.qm.subscribe(conn1, dest)
     
     m1 = StompFrame('MESSAGE', headers={'destination': dest}, body='Message body (1)')
     self.qm.send(m1)
     
     assert conn1.frames[0] == m1
     
     m2 = StompFrame('MESSAGE', headers={'destination': dest}, body='Message body (2)')
     self.qm.send(m2)
     
     assert len(conn1.frames) == 1, "Expected connection to still only have 1 frame."
     assert conn1.frames[0] == m1
     
     ack = StompFrame('ACK', headers={'destination': dest, 'message-id': m1.message_id})
     self.qm.ack(conn1, ack)
     
     print conn1.frames
     assert len(conn1.frames) == 2, "Expected 2 frames now, after ACK."
     assert conn1.frames[1] == m2
Exemple #8
0
 def test_ack_transaction(self):
     """ Test the reliable client (ACK) behavior with transactions. """
             
     dest = '/queue/ack-transaction'
     conn1 = MockConnection()
     conn1.reliable_subscriber = True
     
     self.qm.subscribe(conn1, dest)
     
     m1 = Frame('MESSAGE', headers={'destination': dest, }, body='Message body (1)')
     self.qm.send(m1)
     
     assert conn1.frames[0] == m1
     
     m2 = Frame('MESSAGE', headers={'destination': dest}, body='Message body (2)')
     self.qm.send(m2)
     
     assert len(conn1.frames) == 1, "Expected connection to still only have 1 frame."
     assert conn1.frames[0] == m1
     
     ack = Frame('ACK', headers={'destination': dest, 'transaction': 'abc', 'message-id': m1.message_id})
     self.qm.ack(conn1, ack, transaction='abc')
     
     ack = Frame('ACK', headers={'destination': dest, 'transaction': 'abc', 'message-id': m2.message_id})
     self.qm.ack(conn1, ack, transaction='abc')
     
     assert len(conn1.frames) == 2, "Expected 2 frames now, after ACK."
     assert conn1.frames[1] == m2
     
     self.qm.resend_transaction_frames(conn1, transaction='abc')
     
     assert len(conn1.frames) == 3, "Expected 3 frames after re-transmit."
     assert bool(self.qm._pending[conn1]) == True, "Expected 1 pending (waiting on ACK) frame.""" 
Exemple #9
0
 def test_clear_transaction_frames(self):
     """ Test the clearing of transaction ACK frames. """
     dest = '/queue/tx'
     
     f = Frame('SEND', headers={'destination': dest, 'transaction': '1'}, body='Body-A')
     self.qm.send(f)
     
     print self.store.destinations()
     assert dest in self.store.destinations()
     
     conn1 = MockConnection()
     conn1.reliable_subscriber = True
     self.qm.subscribe(conn1, dest)
     
     assert len(conn1.frames) == 1
     
     self.qm.clear_transaction_frames(conn1, '1')
Exemple #10
0
 def test_disconnect_pending_frames(self):
     """ Test a queue disconnect when there are pending frames. """
     
     dest = '/queue/disconnect-pending-frames'
     conn1 = MockConnection()
     conn1.reliable_subscriber = True
     
     self.qm.subscribe(conn1, dest)
     
     m1 = Frame('MESSAGE', headers={'destination': dest}, body='Message body (1)')
     self.qm.send(m1)
     
     assert conn1.frames[0] == m1
     
     self.qm.disconnect(conn1)
     
     # Now we need to ensure that the frame we sent is re-queued.
     assert len(self.store.frames(dest)) == 1