当前位置: 首页>>代码示例>>Python>>正文


Python teal.Teal类代码示例

本文整理汇总了Python中ibm.teal.Teal的典型用法代码示例。如果您正苦于以下问题:Python Teal类的具体用法?Python Teal怎么用?Python Teal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Teal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: JournalTest

class JournalTest(TealTestCase):


    def setUp(self):        
        self.teal = Teal('data/common/configurationtest.conf', 'stderr', msgLevel=self.msglevel, commit_alerts=False, commit_checkpoints=False)

    def tearDown(self):
        self.teal.shutdown()

    def testJournalLoadSave(self):
        ''' Test loading and saving a json file ''' 
        Journal('test journal', file='data/journal_test/data_sample_001_NEW.json')
        # TODO: Clean up the file after it gets created
        #j.save('data/journal_test/data_sample_001_NEW_AUTO_OUT.json')
        return
    
    def testJournalQueue(self):
        ''' Test injecting the Journal through a queue'''
        lq = ListenableQueue('test journal queue')
        j = Journal('test journal -- input', file='data/journal_test/data_sample_001_NEW.json')
        j_rec = Journal('j_rec -- output')
        lq.register_listener(j_rec)
        j.inject_queue(lq)
        while len(j) != len(j_rec):
            # p rint ('waiting for queue to process %s of %s' % (str(len(j_rec)), str(len(j))))
            sleep(1.0)
        #p rint j
        #p rint j_rec
        self.assertTrue(j.deep_match(j))
        self.assertTrue(j.deep_match(j_rec, ignore_delay=True))
        return
开发者ID:ppjsand,项目名称:pyteal,代码行数:31,代码来源:journal_test.py

示例2: AlertTestDuplicateSupport

class AlertTestDuplicateSupport(TealTestCase):
    
    def testDisableDup(self):
        ''' Test That disable dup works'''
        self.teal = Teal('data/common/configurationtest.conf', 'stderr', msgLevel=self.msglevel, commit_alerts=False, commit_checkpoints=False)
        am = get_service(SERVICE_ALERT_MGR)
        self.assertEqual(len(am.in_mem_alerts), 0)
        self.assertEqual(len(am.in_mem_alerts_duplicate), 0)
        self.assertEqual(len(am.active_alerts_open), 0)
        create_teal_alert('XXXXXXXX', 'no reason at all', 'medium well', loc_instance="YYY")
        self.assertEqual(len(am.in_mem_alerts), 1)
        self.assertEqual(len(am.in_mem_alerts_duplicate), 0)
        self.assertEqual(len(am.active_alerts_open), 1)
        create_teal_alert('XXXXXXXX', 'no reason at all', 'medium well', loc_instance="YYY")
        self.assertEqual(len(am.in_mem_alerts), 2)
        self.assertEqual(len(am.in_mem_alerts_duplicate), 1)
        self.assertEqual(len(am.active_alerts_open), 1)
        create_teal_alert('XXXXXXXX', 'no reason at all', 'medium well', loc_instance="YYY", disable_dup=True)
        self.assertEqual(len(am.in_mem_alerts), 3)
        self.assertEqual(len(am.in_mem_alerts_duplicate), 1)
        self.assertEqual(len(am.active_alerts_open), 2)
        create_teal_alert('XXXXXXXX', 'no reason at all', 'medium well', loc_instance="YYY", disable_dup=True)
        self.assertEqual(len(am.in_mem_alerts), 4)
        self.assertEqual(len(am.in_mem_alerts_duplicate), 1)
        self.assertEqual(len(am.active_alerts_open), 3)
        create_teal_alert('XXXXXXXX', 'no reason at all', 'medium well', loc_instance="YYY")
        self.assertEqual(len(am.in_mem_alerts), 5)
        self.assertEqual(len(am.in_mem_alerts_duplicate), 2)
        self.assertEqual(len(am.active_alerts_open), 3)
        self.teal.shutdown()
        return
开发者ID:ppjsand,项目名称:pyteal,代码行数:31,代码来源:alert_test.py

示例3: JournalTestWithOptionalData

class JournalTestWithOptionalData(TealTestCase):


    def setUp(self):
        self.teal = Teal('data/common/configurationtest.conf', 'stderr', msgLevel=self.msglevel, commit_alerts=False, commit_checkpoints=False)

    def tearDown(self):
        self.teal.shutdown()

#    def testJournalLoadSave(self):
#        ''' Test loading and saving a json file with optional fields. ''' 
#        j = Journal('test journal', file='data/journal_test/data_sample_002_NEW.json')
#        j.save('data/journal_test/data_sample_002_NEW_AUTO_OUT.json')
#        return
    
    def testJournalQueue(self):
        ''' Test injecting a Journal containing optional fields through a queue'''
        lq = ListenableQueue('test journal queue')
        j = Journal('test journal', file='data/journal_test/data_sample_002_NEW.json')
        j_rec = Journal('j_rec')
        lq.register_listener(j_rec)
        j.inject_queue(lq)
        while len(j) != len(j_rec):
            # p rint ('waiting for queue to process %s of %s' % (str(len(j_rec)), str(len(j))))
            sleep(1.0)
        #p rint j
        #p rint j_rec
        self.assertTrue(j.deep_match(j))
        self.assertTrue(j.deep_match(j_rec, ignore_delay=True))
        return
开发者ID:ppjsand,项目名称:pyteal,代码行数:30,代码来源:journal_test.py

示例4: TealTestDemoEventQ

class TealTestDemoEventQ(TealTestCase):
    '''Test the demo configuration ''' 
        
    def testDemo1EventQ(self):
        '''Test that the first demo flow works -- Inject Event Q'''
        self.teal = Teal('data/teal_test/configurationtest_05_auto.conf', 'stderr', msgLevel=self.msglevel, 
                         commit_alerts=False, commit_checkpoints=False, run_mode=TEAL_RUN_MODE_HISTORIC)
        j_in = Journal('j_in', file='data/demo/data_sample_demo_NEW_001.json')
        j_out_aaq = Journal('j_out_aaq')
        j_out_dq = Journal('j_out_dq')
        j_out_lis = Journal('j_out_lis')
        q_in = registry.get_service(SERVICE_EVENT_Q)
        q_out_aaq = registry.get_service(SERVICE_ALERT_ANALYZER_Q)
        q_out_dq = registry.get_service(SERVICE_ALERT_DELIVERY_Q)
        q_out_dq.register_listener(j_out_dq)
        q_out_aaq.register_listener(j_out_aaq)
        listeners = get_service(SERVICE_ALERT_DELIVERY).listeners
        for listener in listeners:
            if listener.get_name() == 'outputJournal':
                j_out_lis = listener.journal
        j_in.inject_queue(q_in)
        self.assertTrue(j_out_lis.wait_for_entries(3))
        j_exp_aaq = Journal('j_exp_aaq', 'data/teal_test/data_sample_demo_NEW_001_AAQ_Result.json')
        self.assertTrue(j_out_aaq.deep_match(j_exp_aaq, ignore_delay=True, ignore_times=True))
        j_exp_dq = Journal('j_exp_dq', 'data/teal_test/data_sample_demo_NEW_001_DQ_Result.json')
        self.assertTrue(j_out_dq.deep_match(j_exp_dq, ignore_delay=True, ignore_times=True))
        j_exp_lis = Journal('j_exp_lis', 'data/teal_test/data_sample_demo_NEW_001_LIS_Result.json')
        self.assertTrue(j_out_lis.deep_match(j_exp_lis, ignore_delay=True, ignore_times=True))
        
        q_out_aaq.unregister_listener(j_out_aaq)        
        q_out_dq.unregister_listener(j_out_dq)
        self.teal.shutdown()
开发者ID:ppjsand,项目名称:pyteal,代码行数:32,代码来源:teal_test.py

示例5: testHistoricOnlyHistoric

 def testHistoricOnlyHistoric(self):
     ''' Verify that the historic monitor can only be run in historic mode '''
     self.assertRaisesTealError(TealError, "Historic monitor can only enabled for historic use.  Unsupported value specified: realtime", Teal, 'data/teal_test/bad_hist_mon_01.conf', 'stderr', self.msglevel, 'now', 'realtime')
     self.assertRaisesTealError(TealError, "Historic monitor can only enabled for historic use.  Unsupported value specified: all", Teal, 'data/teal_test/bad_hist_mon_02.conf', 'stderr', self.msglevel, 'now', 'historic')
     # Should run ... clear the DB and run it with no events, so nothing will happen
     self.prepare_db()
     teal = Teal('data/teal_test/bad_hist_mon_03.conf', 'stderr', self.msglevel, 'now', 'historic')
     teal.shutdown()
开发者ID:ppjsand,项目名称:pyteal,代码行数:8,代码来源:teal_test.py

示例6: setUp

 def setUp(self):
     global VFYRULE
     t = Teal('data/tlcommands_test/test.conf',data_only=True)
     teal_path = registry.get_service(registry.TEAL_ROOT_DIR)
     VFYRULE = os.path.join(teal_path,'bin/tlvfyrule')
     t.shutdown()
     
     tmp_data_dir = os.path.join(os.environ.get('TEAL_ROOT_DIR','/opt/teal'),'data')
     self.teal_data_dir = self.force_env('TEAL_DATA_DIR', tmp_data_dir)
     return
开发者ID:ppjsand,项目名称:pyteal,代码行数:10,代码来源:tlvfyrule_test.py

示例7: testEnabledHistoric

 def testEnabledHistoric(self):
     ''' Verify that historic indicator on enabled plug-in control works '''
     teal = Teal('data/teal_test/good_01.conf', 'stderr', msgLevel=self.msglevel, run_mode='historic', commit_alerts=False, commit_checkpoints=False)
     event_q_lsrs = registry.get_service(SERVICE_EVENT_Q).listener_methods
     self.assertEquals(len(event_q_lsrs), 1)
     names = []
     for lsr_m in event_q_lsrs:
         names.append(lsr_m.__self__.get_name())
     self.assertTrue('AnalyzerTest055a' in names)
     teal.shutdown()
开发者ID:ppjsand,项目名称:pyteal,代码行数:10,代码来源:teal_test.py

示例8: TealTestDemoDB

class TealTestDemoDB(TealTestCase):
    '''Test the demo configuration '''
    
    def testDemo1DB(self):
        '''Test demo flow by injecting into DB'''
        self.prepare_db()
        keep_var = self.force_env('TEAL_TEST_POOL_TIMERS_OFF', 'YES')
        self.teal = Teal('data/teal_test/configurationtest_05_semaphore_auto.conf', 'stderr', 
                         msgLevel=self.msglevel)

        j_in = Journal('j_in', file='data/demo/data_sample_demo_NEW_001.json')
        j_out_eq = Journal('j_out_eq')
        j_out_aaq = Journal('j_out_aaq')
        j_out_dq = Journal('j_out_dq')
        j_out_lis = Journal('j_out_lis')
        q_out_eq = registry.get_service(SERVICE_EVENT_Q)
        q_out_aaq = registry.get_service(SERVICE_ALERT_ANALYZER_Q)
        q_out_dq = registry.get_service(SERVICE_ALERT_DELIVERY_Q)
        q_out_eq.register_listener(j_out_eq)
        q_out_dq.register_listener(j_out_dq)
        q_out_aaq.register_listener(j_out_aaq)
        listeners = get_service(SERVICE_ALERT_DELIVERY).listeners
        for listener in listeners:
            if listener.get_name() == 'outputJournal':
                j_out_lis = listener.journal
        try:
            j_in.insert_in_db(progress_cb=None, truncate=False, use_rec_ids=True, no_delay=False, post=True)
        except:
            print 'INSERTION FAILED'
            q_out_eq.unregister_listener(j_out_eq)
            q_out_dq.unregister_listener(j_out_dq)
            q_out_aaq.unregister_listener(j_out_aaq)
            raise
       
        # Yes, only 2: Flush can't be injected to connector, so pool does not get closed, so last event
        # Does not get turned into an alert!
        self.assertTrue(j_out_lis.wait_for_entries(2))

        # Note these connector ('C') versions have one less alert
        #     The analyzer is being run in historic mode (see configuration) if that was 
        #     changed to runtime then the pool would time out and the last alert would be journaled
        j_exp_aaq = Journal('j_exp_aaq', 'data/teal_test/data_sample_demo_NEW_001_AAQ_Result_C.json')
        self.assertTrue(j_out_aaq.deep_match(j_exp_aaq, ignore_delay=True, ignore_times=True))
        j_exp_dq = Journal('j_exp_dq', 'data/teal_test/data_sample_demo_NEW_001_DQ_Result_C.json')
        self.assertTrue(j_out_dq.deep_match(j_exp_dq, ignore_delay=True, ignore_times=True))
        j_exp_lis = Journal('j_exp_lis', 'data/teal_test/data_sample_demo_NEW_001_LIS_Result_C.json')
        self.assertTrue(j_out_lis.deep_match(j_exp_lis, ignore_delay=True, ignore_times=True))

        q_out_eq.unregister_listener(j_out_eq)
        q_out_dq.unregister_listener(j_out_dq)
        q_out_aaq.unregister_listener(j_out_aaq)
        
        self.teal.shutdown()
        self.restore_env('TEAL_TEST_POOL_TIMERS_OFF', keep_var)
开发者ID:ppjsand,项目名称:pyteal,代码行数:54,代码来源:teal_test.py

示例9: AlertListenerFailureTest

class AlertListenerFailureTest(TealTestCase):
    """Test the alert delivery (filters and listeners)"""

    def setUp(self):
        """Setup Teal"""
        # Not testing duplicates, so OK to turn off
        self.keep_ADC = self.force_env("TEAL_ALERT_DUPLICATE_CHECK", "No")
        self.teal = Teal(
            "data/alert_delivery_test/listener_failure/test.conf",
            "stderr",
            msgLevel=self.msglevel,
            commit_alerts=False,
            commit_checkpoints=False,
        )
        return

    def tearDown(self):
        """Teardown teal"""
        self.teal.shutdown()
        self.restore_env("TEAL_ALERT_DUPLICATE_CHECK", self.keep_ADC)
        return

    def testGeneralFilters(self):
        """test alert delivery with global and local filtering"""
        j_in_dq = Journal("j_in_DQ", "data/alert_delivery_test/listener_failure/inject_DQ_alerts.json")
        dq_q = get_service(SERVICE_ALERT_DELIVERY_Q)
        # Get the AlertListenerJournal journals
        listeners = get_service(SERVICE_ALERT_DELIVERY).listeners
        for listener in listeners:
            name = listener.get_name()
            if name == "AllAlerts":
                j_out_all = listener.journal
            if name == "OnlyAnalyzer1":
                j_out_analyzer1 = listener.journal
        # inject
        j_in_dq.inject_queue(dq_q)
        # Create a TEAL alert
        create_teal_alert("XXXXXXXX", "no reason at all", "medium well", loc_instance="YYY")

        # Get expected values
        j_out_all_exp = Journal("all_exp", "data/alert_delivery_test/analyzer_filter/alerts_out_all.json")
        j_out_analyzer1_exp = Journal("analyzer1", "data/alert_delivery_test/analyzer_filter/alerts_out_analyzer1.json")
        # wait for stuff to come out
        self.assertTrue(j_out_all.wait_for_entries(len(j_out_all_exp) + 3))
        self.assertTrue(j_out_analyzer1.wait_for_entries(len(j_out_analyzer1_exp)))
        # Check that it was what was expected

        # Can't really check this because the location is unique for each machine and run
        #  Make sure only 3 extra
        self.assertEqual(len(j_out_all) - len(j_out_all_exp), 3)
        # self.assertTrue(j_out_all.deep_match(j_out_all_exp, ignore_delay=True, ignore_times=True))
        self.assertTrue(j_out_analyzer1.deep_match(j_out_analyzer1_exp, ignore_delay=True, ignore_times=True))
        return
开发者ID:ppjsand,项目名称:pyteal,代码行数:53,代码来源:alert_delivery_test.py

示例10: TEALShutdownModeTest3b

class TEALShutdownModeTest3b(TealTestCase):
    ''' Test setting of shutdown mode works '''
    
    def setUp(self):
        self.t = Teal('data/checkpoint_test/shutdown_immediate.conf', 'stderr', msgLevel=self.msglevel, data_only=True)  
          
    def tearDown(self):
        self.t.shutdown()
    
    def testSettingImmediateShutdownMode(self):
        ''' Test that the shutdown mode to immediate works config '''  
        self.assertEqual(SHUTDOWN_MODE_IMMEDIATE, registry.get_service(registry.SERVICE_SHUTDOWN_MODE))
开发者ID:ppjsand,项目名称:pyteal,代码行数:12,代码来源:checkpoint_shutdown_test.py

示例11: TEALShutdownModeTest1

class TEALShutdownModeTest1(TealTestCase):
    ''' Test setting of shutdown mode works '''
    
    def setUp(self):
        self.t = Teal('data/tlcommands_test/test.conf', 'stderr', msgLevel=self.msglevel, data_only=True)  
          
    def tearDown(self):
        self.t.shutdown()
    
    def testDefaultShutdownMode(self):
        ''' Test that the shutdown mode correctly defaults '''  
        self.assertEqual(SHUTDOWN_MODE_DEFERRED, registry.get_service(registry.SERVICE_SHUTDOWN_MODE))
开发者ID:ppjsand,项目名称:pyteal,代码行数:12,代码来源:checkpoint_shutdown_test.py

示例12: AlertDeliveryTest

class AlertDeliveryTest(TealTestCase):
    """Test the alert delivery (filters and listeners)"""

    def setUp(self):
        """Setup Teal"""
        self.keep_ADC = self.force_env("TEAL_ALERT_DUPLICATE_CHECK", "No")
        self.teal = Teal(
            "data/alert_delivery_test/test_local_filters.conf",
            "stderr",
            msgLevel=self.msglevel,
            commit_alerts=False,
            commit_checkpoints=False,
        )
        return

    def tearDown(self):
        """Teardown teal"""
        self.teal.shutdown()
        self.restore_env("TEAL_ALERT_DUPLICATE_CHECK", self.keep_ADC)
        return

    def testGeneralFilters(self):
        """test alert delivery with global and local filtering"""
        j_in_dq = Journal("j_in_DQ", "data/alert_delivery_test/data_sample_inject_DQ.json")
        # p rint str(j_in_dq)
        dq_q = get_service(SERVICE_ALERT_DELIVERY_Q)
        # Get the AlertListenerJournal journals
        listeners = get_service(SERVICE_ALERT_DELIVERY).listeners
        for listener in listeners:
            name = listener.get_name()
            # p rint name
            if name == "AllAlerts":
                j_out_all = listener.journal
            if name == "OnlyAlertId":
                j_out_alert_id = listener.journal
            if name == "OnlyAlertIdUrgent":
                j_out_ai_urgent = listener.journal
        # inject
        j_in_dq.inject_queue(dq_q)
        # wait for stuff to come out
        self.assertTrue(j_out_all.wait_for_entries(5))
        self.assertTrue(j_out_alert_id.wait_for_entries(3))
        self.assertTrue(j_out_ai_urgent.wait_for_entries(2))
        #
        j_out_all_exp = Journal("j_out_all_exp", "data/alert_delivery_test/data_sample_out_all_alerts.json")
        self.assertTrue(j_out_all.deep_match(j_out_all_exp, ignore_delay=True, ignore_times=True))
        j_out_alert_id_exp = Journal("j_out_alert_id_exp", "data/alert_delivery_test/data_sample_out_alert_id.json")
        self.assertTrue(j_out_alert_id.deep_match(j_out_alert_id_exp, ignore_delay=True, ignore_times=True))
        j_out_ai_urgent_exp = Journal("j_out_ai_urgent_exp", "data/alert_delivery_test/data_sample_out_ai_urgent.json")
        self.assertTrue(j_out_ai_urgent.deep_match(j_out_ai_urgent_exp, ignore_delay=True, ignore_times=True))
        return
开发者ID:ppjsand,项目名称:pyteal,代码行数:51,代码来源:alert_delivery_test.py

示例13: TEALShutdownModeTest2

class TEALShutdownModeTest2(TealTestCase):
    ''' Test setting of shutdown mode works '''
    
    def setUp(self):
        self.keep_mode = self.force_env(TEAL_SHUTDOWN_MODE, SHUTDOWN_MODE_DEFERRED)
        self.t = Teal('data/tlcommands_test/test.conf', 'stderr', msgLevel=self.msglevel, data_only=True)  
          
    def tearDown(self):
        self.t.shutdown()
        self.restore_env(TEAL_SHUTDOWN_MODE, self.keep_mode)
    
    def testSettingDeferredShutdownMode(self):
        ''' Test that the shutdown mode being set to deferred works '''  
        self.assertEqual(SHUTDOWN_MODE_DEFERRED, registry.get_service(registry.SERVICE_SHUTDOWN_MODE))
开发者ID:ppjsand,项目名称:pyteal,代码行数:14,代码来源:checkpoint_shutdown_test.py

示例14: TEALShutdownModeTest4

class TEALShutdownModeTest4(TealTestCase):
    ''' Test setting of shutdown mode ignored '''
    
    def setUp(self):
        self.keep_mode = self.force_env(TEAL_SHUTDOWN_MODE, SHUTDOWN_MODE_IMMEDIATE)
        self.t = Teal('data/tlcommands_test/test.conf', 'stderr', msgLevel=self.msglevel, data_only=True, run_mode=TEAL_RUN_MODE_HISTORIC, commit_alerts=False)  
          
    def tearDown(self):
        self.t.shutdown()
        self.restore_env(TEAL_SHUTDOWN_MODE, self.keep_mode)
    
    def testSettingImmediateShutdownMode(self):
        ''' Test that the shutdown mode to immediate ignored if HISTORIC '''  
        self.assertEqual(SHUTDOWN_MODE_DEFERRED, registry.get_service(registry.SERVICE_SHUTDOWN_MODE))
开发者ID:ppjsand,项目名称:pyteal,代码行数:14,代码来源:checkpoint_shutdown_test.py

示例15: TEALShutdownModeTest3a

class TEALShutdownModeTest3a(TealTestCase):
    ''' Test setting of shutdown mode works '''
    
    def setUp(self):
        self.keep_mode = self.force_env(TEAL_SHUTDOWN_MODE, SHUTDOWN_MODE_IMMEDIATE)
        self.t = Teal('data/tlcommands_test/test.conf', 'stderr', msgLevel=self.msglevel, data_only=True)  
          
    def tearDown(self):
        self.t.shutdown()
        self.restore_env(TEAL_SHUTDOWN_MODE, self.keep_mode)
    
    def testSettingImmediateShutdownMode(self):
        ''' Test that the shutdown mode to immediate works ENV '''  
        self.assertEqual(SHUTDOWN_MODE_IMMEDIATE, registry.get_service(registry.SERVICE_SHUTDOWN_MODE))
开发者ID:ppjsand,项目名称:pyteal,代码行数:14,代码来源:checkpoint_shutdown_test.py


注:本文中的ibm.teal.Teal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。