def test_queue_queue(self): """ Test queue 2 queue. """ print("checking queue 2 queue use case") mq1_path = self.path + "/mq1" mq2_path = self.path + "/mq2" mq1 = DQS(path=mq1_path) count = 10 bodies = list() for i in range(count): body = "hello world %s" % (i, ) bodies.append(body) mq1.add_message(Message(body=body)) self.assertEqual(count, mq1.count()) cmd = "python bin/amqpclt --incoming-queue path=%s" \ " --outgoing-queue path=%s --remove --loglevel debug" \ % (mq1_path, mq2_path) (ret, out, err) = proc.timed_process(cmd.split()) self.assertEqual(0, ret, "out: %s\nerr: %s" % (out, err)) mq2 = DQS(path=mq2_path) for i in mq2: if mq2.lock(i): bodies.remove(mq2.get_message(i).body) self.assertEqual(count, mq2.count()) self.assertEqual(0, len(bodies)) print("checking queue 2 queue use case OK")
def test_full_chain(self): """ Test kombu full chain. """ print("checking kombu full chain") try: import kombu except ImportError: print("kombu is not available, skipping it") return mq1_path = self.path + "/mq1" mq2_path = self.path + "/mq2" mq1 = DQS(path=mq1_path) count = 10 dest = "/queue/test%s" % (rndstr(10), ) bodies = list() for i in range(count): body = "hello world %s" % (i, ) bodies.append(body) msg = Message(body=body) msg.header = {"destination": dest} mq1.add_message(msg) self.assertEqual(count, mq1.count()) cmd1 = "python bin/amqpclt --incoming-queue path=%s" \ " --outgoing-broker-uri %s " \ " --outgoing-broker-module kombu " \ " --outgoing-broker-auth plain,name=guest,pass=guest" \ " --remove --loglevel debug" \ % (mq1_path, self.broker) (ret, out, err) = proc.timed_process(cmd1.split()) self.assertEqual(0, ret, "out: %s\nerr: %s" % (out, err)) cmd2 = "python bin/amqpclt --incoming-broker-uri %s" \ " --incoming-broker-module kombu" \ " --incoming-broker-auth plain,name=guest,pass=guest" \ " --subscribe destination=%s" \ " --outgoing-queue path=%s --count %d --reliable " \ "--loglevel debug" \ % (self.broker, dest, mq2_path, count) (ret, out, err) = proc.timed_process(cmd2.split()) self.assertEqual(0, ret, "out: %s\nerr: %s" % (out, err)) mq2 = DQS(path=mq2_path) for i in mq2: if mq2.lock(i): bodies.remove(mq2.get_message(i).body) self.assertEqual(count, mq2.count()) self.assertEqual(0, len(bodies)) self.assertEqual(0, mq1.count()) print("checking kombu fullchain OK")