Esempio n. 1
0
    def test_send(self):
        pd1={'name':'consumer_number_1',
                 'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'procclass':'ForwardingConsumer',
                 'spawnargs':{'attach':self.queue1,\
                              'process parameters':{},
                              'delivery queues':{'queues':[self.queue2]}}\
                    }
        child1 = base_consumer.ConsumerDesc(**pd1)

        child1_id = yield self.test_sup.spawn_child(child1)

        dmsg = DataMessageObject()
        dmsg.notifcation = 'Junk'
        dmsg.timestamp = pu.currenttime()
        dmsg = dmsg.encode()

        yield self.test_sup.send(self.queue1, 'data', dmsg)

        yield pu.asleep(1)
        msg_cnt = yield child1.get_msg_count()
        received = msg_cnt.get('received', {})
        sent = msg_cnt.get('sent', {})
        self.assertEqual(sent.get(self.queue2), 1)
        self.assertEqual(received.get(self.queue1), 1)
    def test_send(self):
        pd1={'name':'consumer_number_1',
                 'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'procclass':'ForwardingConsumer',
                 'spawnargs':{'attach':self.queue1,\
                              'process parameters':{},
                              'delivery queues':{'queues':[self.queue2]}}\
                    }
        child1 = base_consumer.ConsumerDesc(**pd1)

        child1_id = yield self.test_sup.spawn_child(child1)

        dmsg = DataMessageObject()
        dmsg.notifcation = 'Junk'
        dmsg.timestamp = pu.currenttime()
        dmsg = dmsg.encode()
        
        yield self.test_sup.send(self.queue1, 'data', dmsg)
        
        yield pu.asleep(1)
        msg_cnt = yield child1.get_msg_count()
        received = msg_cnt.get('received',{})
        sent = msg_cnt.get('sent',{})
        self.assertEqual(sent.get(self.queue2),1)
        self.assertEqual(received.get(self.queue1),1)
Esempio n. 3
0
    def test_send_chain(self):
        pd1={'name':'consumer_number_1',
                 'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'procclass':'ForwardingConsumer',
                 'spawnargs':{'attach':self.queue1,\
                              'process parameters':{},\
                              'delivery queues':{'queues':[self.queue2]}}\
                    }
        child1 = base_consumer.ConsumerDesc(**pd1)

        child1_id = yield self.test_sup.spawn_child(child1)

        dmsg = DataMessageObject()
        dmsg.notifcation = 'Junk'
        dmsg.timestamp = pu.currenttime()
        dmsg = dmsg.encode()

        yield self.test_sup.send(self.queue1, 'data', dmsg)

        yield pu.asleep(1)

        msg_cnt = yield child1.get_msg_count()
        received = msg_cnt.get('received', {})
        sent = msg_cnt.get('sent', {})
        self.assertEqual(sent.get(self.queue2), 1)
        self.assertEqual(received.get(self.queue1), 1)

        #Spawn another process to listen to queue 2
        pd2={'name':'consumer_number_2', \
                 'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'procclass':'ForwardingConsumer',\
                 'spawnargs':{'attach':self.queue2}}

        child2 = base_consumer.ConsumerDesc(**pd2)

        child2_id = yield self.test_sup.spawn_child(child2)

        # Tell the first consumer to pass results to the second!
        #res = yield child1.set_params({'queues':[self.queue2]})

        yield self.test_sup.send(self.queue1, 'data', dmsg)

        yield pu.asleep(1)

        msg_cnt = yield child1.get_msg_count()
        received = msg_cnt.get('received', {})
        sent = msg_cnt.get('sent', {})
        self.assertEqual(sent.get(self.queue2), 2)
        self.assertEqual(received.get(self.queue1), 2)

        msg_cnt = yield child2.get_msg_count()
        received = msg_cnt.get('received', {})
        sent = msg_cnt.get('sent')
        self.assertEqual(sent, {})
        self.assertEqual(received.get(self.queue2), 1)

        yield child1.shutdown()
        yield child2.shutdown()
    def test_send_chain(self):
        pd1={'name':'consumer_number_1',
                 'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'procclass':'ForwardingConsumer',
                 'spawnargs':{'attach':self.queue1,\
                              'process parameters':{},\
                              'delivery queues':{'queues':[self.queue2]}}\
                    }
        child1 = base_consumer.ConsumerDesc(**pd1)

        child1_id = yield self.test_sup.spawn_child(child1)

        dmsg = DataMessageObject()
        dmsg.notifcation = 'Junk'
        dmsg.timestamp = pu.currenttime()
        dmsg = dmsg.encode()
        
        yield self.test_sup.send(self.queue1, 'data', dmsg)
        
        yield pu.asleep(1)
        
        msg_cnt = yield child1.get_msg_count()
        received = msg_cnt.get('received',{})
        sent = msg_cnt.get('sent',{})
        self.assertEqual(sent.get(self.queue2),1)
        self.assertEqual(received.get(self.queue1),1)
        
        
        #Spawn another process to listen to queue 2  
        pd2={'name':'consumer_number_2', \
                 'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'procclass':'ForwardingConsumer',\
                 'spawnargs':{'attach':self.queue2}}
        
        child2 = base_consumer.ConsumerDesc(**pd2)
                
        child2_id = yield self.test_sup.spawn_child(child2)
       
        # Tell the first consumer to pass results to the second!
        #res = yield child1.set_params({'queues':[self.queue2]})
        
        yield self.test_sup.send(self.queue1, 'data', dmsg)
        
        yield pu.asleep(1)

        msg_cnt = yield child1.get_msg_count()
        received = msg_cnt.get('received',{})
        sent = msg_cnt.get('sent',{})
        self.assertEqual(sent.get(self.queue2),2)
        self.assertEqual(received.get(self.queue1),2)
        
        
        msg_cnt = yield child2.get_msg_count()
        received = msg_cnt.get('received',{})
        sent = msg_cnt.get('sent')
        self.assertEqual(sent,{})
        self.assertEqual(received.get(self.queue2),1)
        
        
        yield child1.shutdown()
        yield child2.shutdown()