Exemple #1
0
def test_kafka_queue():
    kafka = KafkaClient("kafka01", 9092)
    q = KafkaQueue(kafka, "queue", [0])
    q.put("first")
    q.put("second")
    assert q.get() == "first"
    assert q.get() == "second"
    q.close()
    kafka.close()
Exemple #2
0
    def test_queue(self):
        # Send 1000 messages
        q = KafkaQueue(self.kafka, "test-queue", [0, 1])
        t1 = time.time()
        for i in range(1000):
            q.put("test %d" % i)
        t2 = time.time()

        # Wait for the producer to fully flush
        time.sleep(2)

        # Copy all the messages into a list
        t1 = time.time()
        consumed = []
        for i in range(1000):
            consumed.append(q.get())
        t2 = time.time()

        # Verify everything is there
        for i in range(1000):
            self.assertTrue("test %d" % i in consumed)

        # Shutdown the queue
        q.close()
    def test_queue(self):
        # Send 1000 messages
        q = KafkaQueue(self.kafka, "test-queue", [0,1])
        t1 = time.time()
        for i in range(1000):
            q.put("test %d" % i)
        t2 = time.time()

        # Wait for the producer to fully flush
        time.sleep(2)

        # Copy all the messages into a list
        t1 = time.time()
        consumed = []
        for i in range(1000):
            consumed.append(q.get())
        t2 = time.time()

        # Verify everything is there
        for i in range(1000):
            self.assertTrue("test %d" % i in consumed)

        # Shutdown the queue
        q.close()