Example #1
0
    def test_sample(self):
        result = yield self.driver_client.initialize('some arg')

        dpsc = DataPubsubClient(self.sup)
        topicname = 'SBE49 Topic'
        topic = PubSubTopicResource.create(topicname,"")

        # Use the service to create a queue and register the topic
        topic = yield dpsc.define_topic(topic)

        subscription = SubscriptionResource()
        subscription.topic1 = PubSubTopicResource.create(topicname,'')

        subscription.workflow = {
            'consumer1':
                {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                 'consumerclass':'LoggingConsumer',\
                 'attach':'topic1'}
                }

        subscription = yield dpsc.define_subscription(subscription)

        logging.info('Defined subscription: '+str(subscription))

        params = {}
        params['publish-to'] = topic.RegistryIdentity
        yield self.driver_client.configure_driver(params)

        cmd1 = [['ds', 'now']]
        result = yield self.driver_client.execute(cmd1)
        self.assertEqual(result['status'], 'OK')

        yield pu.asleep(1)

        result = yield self.driver_client.disconnect(['some arg'])
Example #2
0
    def test_create_consumer_args1(self):
        '''
        @Brief Test business logic to create consumer args from a workflow
        Make sure teh basics of the workflow processing work to create consumer
        args.
        '''
        
        # Create and Register a topic
        topic = PubSubTopicResource.create('Davids Topic',"oceans, oil spill, fun things to do")        
        # Use the service to create a queue and register the topic
        topic = yield self.pubsub.create_and_register_topic(topic)


        # A condition to search for the topic
        t_search = PubSubTopicResource.create('Davids Topic','')
        
        subscription = SubscriptionResource()
        subscription.topic1 = t_search
        
        subscription.workflow = {'consumer1':{'module':'path.to.module','consumerclass':'<ConsumerClassName>',\
            'attach':'topic1',\
            'process parameters':{'param1':'my parameter'}}}

        subscription = yield self.pubsub.create_consumer_args(subscription)

        logging.debug('Defined subscription consumers: '+str(subscription.consumer_args))
        self.assertEqual({'consumer1':
            {'procclass': '<ConsumerClassName>',
             'name': 'consumer1',
             'module': 'path.to.module',
             'spawnargs': {
                'attach': [topic.queue.name],
                'delivery interval': None,
                'delivery queues': {},
                'process parameters': {'param1': 'my parameter'}}}}, subscription.consumer_args)
Example #3
0
    def test_sample(self):
        result = yield self.driver_client.initialize('some arg')

        dpsc = DataPubsubClient(self.sup)
        topicname = 'SBE49 Topic'
        topic = PubSubTopicResource.create(topicname, "")

        # Use the service to create a queue and register the topic
        topic = yield dpsc.define_topic(topic)

        subscription = SubscriptionResource()
        subscription.topic1 = PubSubTopicResource.create(topicname, '')

        subscription.workflow = {
            'consumer1':
                {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                 'consumerclass':'LoggingConsumer',\
                 'attach':'topic1'}
                }

        subscription = yield dpsc.define_subscription(subscription)

        logging.info('Defined subscription: ' + str(subscription))

        params = {}
        params['publish-to'] = topic.RegistryIdentity
        yield self.driver_client.configure_driver(params)

        cmd1 = [['ds', 'now']]
        result = yield self.driver_client.execute(cmd1)
        self.assertEqual(result['status'], 'OK')

        yield pu.asleep(1)

        result = yield self.driver_client.disconnect(['some arg'])
Example #4
0
    def test_create_consumer_args3(self):
        '''
        @Brief Test business logic to create consumer args from a workflow
        In this test two consumers attach to the same queue created by the workflow
        '''
        
        # Create and Register a topic
        topic = PubSubTopicResource.create('Davids Topic',"oceans, oil spill, fun things to do")        
        # Use the service to create a queue and register the topic
        topic = yield self.pubsub.create_and_register_topic(topic)


        # A condition to search for the topic
        t_search = PubSubTopicResource.create('Davids Topic','')
        
        subscription = SubscriptionResource()
        subscription.topic1 = t_search
        
        subscription.workflow = {
            'consumer1':{'module':'path.to.module','consumerclass':'<ConsumerClassName>',\
            'attach':'topic1',\
            'process parameters':{'param1':'my parameter1'}},
                
            'consumer2':{'module':'path.to.module2','consumerclass':'<ConsumerClassName2>',\
            'attach':[['consumer1','deliver_to']],\
            'Process Parameters':{'param2':'my parameter2'}},
            
            'consumer3':{'module':'path.to.module3','consumerclass':'<ConsumerClassName3>',\
            'attach':[['consumer1','deliver_to'],'topic1']}
                }

        subscription = yield self.pubsub.create_consumer_args(subscription)

        logging.debug('Defined subscription consumers: '+str(subscription.consumer_args))
        
        consume2_attach = subscription.consumer_args['consumer2']['spawnargs']['attach']
        self.assertEqual({'module': 'path.to.module',
               'name': 'consumer1',
               'procclass': '<ConsumerClassName>',
               'spawnargs': {'attach': [topic.queue.name],
                             'delivery interval': None,
                             'delivery queues': {'deliver_to': consume2_attach[0]},
                             'process parameters': {'param1': 'my parameter1'}}},
            subscription.consumer_args['consumer1'])
        
        self.assertEqual({'procclass': '<ConsumerClassName3>',
         'name': 'consumer3',
         'module': 'path.to.module3',
         'spawnargs': {
            'attach': [consume2_attach[0], topic.queue.name],
            'delivery interval': None,
            'delivery queues': {},
            'process parameters': {}}},
            subscription.consumer_args['consumer3'])
Example #5
0
def start():
    """
    Main function of bootstrap. Starts DM pubsub...
    """
    logging.info("ION DM PubSub bootstrapping now...")
    startsvcs = []
    #startsvcs.extend(dm_services)
    sup = yield bootstrap.bootstrap(ion_messaging, startsvcs)
        
    print 'STARTSVCS',startsvcs
    print 'ION_MESSAGING',ion_messaging
    print 'CONT_ARGS',ioninit.cont_args
    
    #yield create_producer(sup)
        
    dpsc = pubsub_service.DataPubsubClient(proc=sup)
    
    subscription = SubscriptionResource()
    subscription.topic1 = PubSubTopicResource.create('Inst/RAW','')
    
    # Use the example consumer to create events... graph the number of events
    '''
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                'consumerclass':'LoggingConsumer',\
                'attach':'topic1'}
        }
    
    
    
    '''
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.instrument_timeseries_consumer',
                'consumerclass':'InstrumentTimeseriesConsumer',\
                'attach':'topic1'},
        'consumer3':
            {'module':'ion.services.dm.presentation.web_viz_consumer',
                'consumerclass':'WebVizConsumer',\
                'attach':[['consumer1','queue']],
                'process parameters':{'port':8180}
            }
                
        }
    
    
    subscription = yield dpsc.define_subscription(subscription)
    linfo = '\n================================================\n'
    linfo+= 'Open your web browser and look at: http://127.0.0.1:8180/ \n'
    linfo+= '================================================\n'
    logging.info(linfo)    
Example #6
0
def start():
    """
    Main function of bootstrap. Starts DM pubsub...
    """
    logging.info("ION DM PubSub bootstrapping now...")
    startsvcs = []
    #startsvcs.extend(dm_services)
    sup = yield bootstrap.bootstrap(ion_messaging, startsvcs)

    print 'STARTSVCS', startsvcs
    print 'ION_MESSAGING', ion_messaging
    print 'CONT_ARGS', ioninit.cont_args

    #yield create_producer(sup)

    dpsc = pubsub_service.DataPubsubClient(proc=sup)

    subscription = SubscriptionResource()
    subscription.topic1 = PubSubTopicResource.create('Inst/RAW', '')

    # Use the example consumer to create events... graph the number of events
    '''
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                'consumerclass':'LoggingConsumer',\
                'attach':'topic1'}
        }
    
    
    
    '''
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.instrument_timeseries_consumer',
                'consumerclass':'InstrumentTimeseriesConsumer',\
                'attach':'topic1'},
        'consumer3':
            {'module':'ion.services.dm.presentation.web_viz_consumer',
                'consumerclass':'WebVizConsumer',\
                'attach':[['consumer1','queue']],
                'process parameters':{'port':8180}
            }

        }

    subscription = yield dpsc.define_subscription(subscription)
    linfo = '\n================================================\n'
    linfo += 'Open your web browser and look at: http://127.0.0.1:8180/ \n'
    linfo += '================================================\n'
    logging.info(linfo)
Example #7
0
    def test_create_subscription2(self):
        '''
        @Brief Create a subscription!
        '''

        # Create and Register a topic
        topic1 = PubSubTopicResource.create('Davids Topic',"oceans, oil spill, fun things to do")        
        # Use the service to create a queue and register the topic
        topic1 = yield self.pubsub.create_and_register_topic(topic1)
        
        topic2 = PubSubTopicResource.create('Johns Topic',"oceans, mbari, working really hard")        
        # Use the service to create a queue and register the topic
        topic2 = yield self.pubsub.create_and_register_topic(topic2)
        
        subscription = SubscriptionResource()
        subscription.topic1 = PubSubTopicResource.create('Davids Topic','')
        subscription.topic2 = PubSubTopicResource.create('','oceans')
        
        subscription.workflow = {
            'consumer1':
                {'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'consumerclass':'ForwardingConsumer',\
                 'attach':'topic1'},
            'consumer2':
                {'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'consumerclass':'ForwardingConsumer',\
                 'attach':[['consumer1','queues']]}
                }

        subscription = yield self.pubsub.create_subscription(subscription)

        logging.info('Defined subscription: '+str(subscription))

        msg=DataMessageObject()
        self.sup.send(topic1.queue.name,'data',msg.encode())
        
        # Wait for message to be received
        yield pu.asleep(1)
        child1_id = self.pubsub.get_child_id('consumer1')
        dc1 = self._get_procinstance(child1_id)
        rec = dc1.receive_cnt[topic1.queue.name]
        self.assertEqual(rec,1)
                
        child2_id = self.pubsub.get_child_id('consumer2')
        dc2 = self._get_procinstance(child2_id)
        
        q = subscription.consumer_args['consumer2']['spawnargs']['attach']
        rec = dc2.receive_cnt[q[0]]
        self.assertEqual(rec,1)
Example #8
0
    def test_execute(self):
        """
        Test the execute command to the Instrument Driver
        """
        result = yield self.driver_client.initialize('some arg')

        dpsc = DataPubsubClient(self.sup)

        subscription = SubscriptionResource()
        subscription.topic1 = PubSubTopicResource.create('SBE49 Topic','')
        #subscription.topic2 = PubSubTopicResource.create('','oceans')

        subscription.workflow = {
            'consumer1':
                {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                 'consumerclass':'LoggingConsumer',\
                 'attach':'topic1'}
                }

        subscription = yield dpsc.define_subscription(subscription)

        logging.info('Defined subscription: '+str(subscription))

        cmd1 = [['ds', 'now']]
        #cmd1 = [['start', 'now']]
        #cmd2 = [['stop', 'now']]
        #cmd2 = [['pumpoff', '3600', '1']]
        result = yield self.driver_client.execute(cmd1)
        self.assertEqual(result['status'], 'OK')
        # DHE: wait a while...
        yield pu.asleep(1)
        #result = yield self.driver_client.execute(cmd2)
        #self.assertEqual(result['status'], 'OK')


        # DHE: disconnecting; a connect would probably be good.
        result = yield self.driver_client.disconnect(['some arg'])
Example #9
0
    def test_create_subscription1(self):
        '''
        @Brief Create a subscription!
        '''

        # Create and Register a topic
        topic = PubSubTopicResource.create('Davids Topic',"oceans, oil spill, fun things to do")        
        # Use the service to create a queue and register the topic
        topic = yield self.pubsub.create_and_register_topic(topic)


        # A condition to search for the topic
        t_search = PubSubTopicResource.create('Davids Topic','')
        
        subscription = SubscriptionResource()
        subscription.topic1 = t_search
        
        subscription.workflow = {
            'consumer1':
                {'module':'ion.services.dm.distribution.consumers.forwarding_consumer',
                 'consumerclass':'ForwardingConsumer',\
                 'attach':'topic1'}}

        subscription = yield self.pubsub.create_subscription(subscription)

        logging.info('Defined subscription: '+str(subscription))

        msg=DataMessageObject()
        self.sup.send(topic.queue.name,'data',msg.encode())
        
        # Wait for message to be received
        yield pu.asleep(1)
        child_id = self.pubsub.get_child_id('consumer1')
        dc1 = self._get_procinstance(child_id)
        rec = dc1.receive_cnt[topic.queue.name]
        self.assertEqual(rec,1)
Example #10
0
    def test_execute(self):
        """
        Test the execute command to the Instrument Driver
        """
        result = yield self.driver_client.initialize('some arg')

        dpsc = DataPubsubClient(self.sup)

        subscription = SubscriptionResource()
        subscription.topic1 = PubSubTopicResource.create('SBE49 Topic', '')
        #subscription.topic2 = PubSubTopicResource.create('','oceans')

        subscription.workflow = {
            'consumer1':
                {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                 'consumerclass':'LoggingConsumer',\
                 'attach':'topic1'}
                }

        subscription = yield dpsc.define_subscription(subscription)

        logging.info('Defined subscription: ' + str(subscription))

        cmd1 = [['ds', 'now']]
        #cmd1 = [['start', 'now']]
        #cmd2 = [['stop', 'now']]
        #cmd2 = [['pumpoff', '3600', '1']]
        result = yield self.driver_client.execute(cmd1)
        self.assertEqual(result['status'], 'OK')
        # DHE: wait a while...
        yield pu.asleep(1)
        #result = yield self.driver_client.execute(cmd2)
        #self.assertEqual(result['status'], 'OK')

        # DHE: disconnecting; a connect would probably be good.
        result = yield self.driver_client.disconnect(['some arg'])
Example #11
0
def start():
    """
    Main function of bootstrap. Starts DM pubsub...
    """
    logging.info("ION DM PubSub bootstrapping now...")
    startsvcs = []
    startsvcs.extend(dm_services)
    sup = yield bootstrap.bootstrap(ion_messaging, startsvcs)
        
    print 'STARTSVCS',startsvcs
    print 'ION_MESSAGING',ion_messaging
    print 'CONT_ARGS',ioninit.cont_args
    
    nproducers = int(ioninit.cont_args.get('nproducers',5))
    print 'NPRODUCERS',nproducers
    yield create_producers(sup, nproducers)
        
    dpsc = pubsub_service.DataPubsubClient(proc=sup)
    
        
    subscription = SubscriptionResource()
    subscription.topic1 = PubSubTopicResource.create('topic','')
    
    """

    # Use the example consumer to create events... log the events
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.example_consumer',
                'consumerclass':'ExampleConsumer',\
                'attach':'topic1'},
        'consumer2':
            {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                'consumerclass':'LoggingConsumer',\
                'attach':[['consumer1','event_queue']]}
            }
    
    # Log all the messages created
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                'consumerclass':'LoggingConsumer',\
                'attach':'topic1'}
            }
    
    """
    # Use the example consumer to create events... graph the number of events
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.example_consumer',
                'consumerclass':'ExampleConsumer',\
                'attach':'topic1'},
        'consumer2':
            {'module':'ion.services.dm.distribution.consumers.message_count_consumer',
                'consumerclass':'MessageCountConsumer',\
                'attach':[['consumer1','event_queue']],\
                'delivery interval':5,
                'process parameters':{'max_points':5}
                },
        'consumer3':
            {'module':'ion.services.dm.presentation.web_viz_consumer',
                'consumerclass':'WebVizConsumer',\
                'attach':[['consumer2','queue']],
                'process parameters':{'port':8180}
            }
                
        }
    
    
    subscription = yield dpsc.define_subscription(subscription)
    linfo = '\n================================================\n'
    linfo+= 'Open your web browser and look at: http://127.0.0.1:8180/ \n'
    linfo+= '================================================\n'
    logging.info(linfo)    
Example #12
0
def start():
    """
    Main function of bootstrap. Starts DM pubsub...
    """
    logging.info("ION DM PubSub bootstrapping now...")
    startsvcs = []
    startsvcs.extend(dm_services)
    sup = yield bootstrap.bootstrap(ion_messaging, startsvcs)

    print 'STARTSVCS', startsvcs
    print 'ION_MESSAGING', ion_messaging
    print 'CONT_ARGS', ioninit.cont_args

    nproducers = int(ioninit.cont_args.get('nproducers', 5))
    print 'NPRODUCERS', nproducers
    yield create_producers(sup, nproducers)

    dpsc = pubsub_service.DataPubsubClient(proc=sup)

    subscription = SubscriptionResource()
    subscription.topic1 = PubSubTopicResource.create('topic', '')
    """

    # Use the example consumer to create events... log the events
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.example_consumer',
                'consumerclass':'ExampleConsumer',\
                'attach':'topic1'},
        'consumer2':
            {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                'consumerclass':'LoggingConsumer',\
                'attach':[['consumer1','event_queue']]}
            }
    
    # Log all the messages created
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.logging_consumer',
                'consumerclass':'LoggingConsumer',\
                'attach':'topic1'}
            }
    
    """
    # Use the example consumer to create events... graph the number of events
    subscription.workflow = {
        'consumer1':
            {'module':'ion.services.dm.distribution.consumers.example_consumer',
                'consumerclass':'ExampleConsumer',\
                'attach':'topic1'},
        'consumer2':
            {'module':'ion.services.dm.distribution.consumers.message_count_consumer',
                'consumerclass':'MessageCountConsumer',\
                'attach':[['consumer1','event_queue']],\
                'delivery interval':5,
                'process parameters':{'max_points':5}
                },
        'consumer3':
            {'module':'ion.services.dm.presentation.web_viz_consumer',
                'consumerclass':'WebVizConsumer',\
                'attach':[['consumer2','queue']],
                'process parameters':{'port':8180}
            }

        }

    subscription = yield dpsc.define_subscription(subscription)
    linfo = '\n================================================\n'
    linfo += 'Open your web browser and look at: http://127.0.0.1:8180/ \n'
    linfo += '================================================\n'
    logging.info(linfo)