def test_browsing(self): priorities = [4,5,3,6,0,1,2,8,2,0,2,1,6,0,1,3,3,3,8,1,3,0,3,7,9,0,1,9,0,2,3] msgs = [Message(content=str(uuid4()), priority = p) for p in priorities] snd = self.ssn.sender("priority-queue; {create: sender, node: {x-declare:{arguments:{x-qpid-priorities:10}}}}", durable=self.durable()) for m in msgs: snd.send(m) rcv = self.ssn.receiver("priority-queue; {mode: browse, delete: receiver}") received = [] try: while True: received.append(rcv.fetch(0)) except Empty: None #check all messages on the queue were received by the browser; don't relay on any specific ordering at present assert set([m.content for m in msgs]) == set([m.content for m in received])
def test_recover(self): """ Test basic recover behaviour """ session = self.session session.dtx_select() session.queue_declare(queue="dummy", exclusive=True, auto_delete=True) prepared = [] for i in range(1, 10): tx = self.xid("tx%s" % (i)) session.dtx_start(xid=tx) session.message_transfer( self.createMessage(session, "dummy", "message%s" % (i), "message%s" % (i))) session.dtx_end(xid=tx) if i in [2, 5, 6, 8]: session.dtx_prepare(xid=tx) prepared.append(tx) else: session.dtx_rollback(xid=tx) xids = session.dtx_recover().in_doubt #rollback the prepared transactions returned by recover for x in xids: session.dtx_rollback(xid=x) #validate against the expected list of prepared transactions actual = set([x.global_id for x in xids ]) #TODO: come up with nicer way to test these expected = set([x.global_id for x in prepared]) intersection = actual.intersection(expected) if intersection != expected: missing = expected.difference(actual) extra = actual.difference(expected) self.fail( "Recovered xids not as expected. missing: %s; extra: %s" % (missing, extra))
def test_browsing(self): priorities = [ 4, 5, 3, 6, 0, 1, 2, 8, 2, 0, 2, 1, 6, 0, 1, 3, 3, 3, 8, 1, 3, 0, 3, 7, 9, 0, 1, 9, 0, 2, 3 ] msgs = [Message(content=str(uuid4()), priority=p) for p in priorities] snd = self.ssn.sender( "priority-queue; {create: sender, node: {x-declare:{arguments:{x-qpid-priorities:10}}}}", durable=self.durable()) for m in msgs: snd.send(m) rcv = self.ssn.receiver( "priority-queue; {mode: browse, delete: receiver}") received = [] try: while True: received.append(rcv.fetch(0)) except Empty: None #check all messages on the queue were received by the browser; don't relay on any specific ordering at present assert set([m.content for m in msgs]) == set([m.content for m in received])
def test_recover(self): """ Test basic recover behaviour """ session = self.session session.dtx_select() session.queue_declare(queue="dummy", exclusive=True, auto_delete=True) prepared = [] for i in range(1, 10): tx = self.xid("tx%s" % (i)) session.dtx_start(xid=tx) session.message_transfer(self.createMessage(session, "dummy", "message%s" % (i), "message%s" % (i))) session.dtx_end(xid=tx) if i in [2, 5, 6, 8]: session.dtx_prepare(xid=tx) prepared.append(tx) else: session.dtx_rollback(xid=tx) xids = session.dtx_recover().in_doubt #rollback the prepared transactions returned by recover for x in xids: session.dtx_rollback(xid=x) #validate against the expected list of prepared transactions actual = set([x.global_id for x in xids]) #TODO: come up with nicer way to test these expected = set([x.global_id for x in prepared]) intersection = actual.intersection(expected) if intersection != expected: missing = expected.difference(actual) extra = actual.difference(expected) self.fail("Recovered xids not as expected. missing: %s; extra: %s" % (missing, extra))