Exemplo n.º 1
0
    def test_multiprocess_collate(self):
        try:
            log_processor.LogProcessor._internal_proxy = DumbInternalProxy()

            def get_object_data(*a, **kw):
                return [self.access_test_line]

            orig_get_object_data = log_processor.LogProcessor.get_object_data
            log_processor.LogProcessor.get_object_data = get_object_data
            proxy_config = self.proxy_config.copy()
            proxy_config.update({
                'log-processor-access': {
                    'source_filename_format': '%Y%m%d%H*',
                    'class_path':
                    'slogging.access_processor.AccessLogProcessor'
                }
            })
            processor_args = (proxy_config, DumbLogger())
            item = ('access', 'a', 'c', 'o')
            logs_to_process = [item]
            processor_klass = log_processor.LogProcessor
            results = log_processor.multiprocess_collate(
                processor_klass, processor_args, 'process_one_file',
                logs_to_process, 1, DumbLogger())
            results = list(results)
            expected = [(item, {
                ('acct', '2010', '07', '09', '04'): {
                    ('public', 'object', 'GET', '2xx'): 1,
                    ('public', 'bytes_out'): 95,
                    'marker_query': 0,
                    'format_query': 1,
                    'delimiter_query': 0,
                    'path_query': 0,
                    ('public', 'bytes_in'): 6,
                    'prefix_query': 0
                }
            })]
            self.assertEquals(results, expected)
        finally:
            log_processor.LogProcessor._internal_proxy = None
            log_processor.LogProcessor.get_object_data = orig_get_object_data
Exemplo n.º 2
0
    def test_multiprocess_collate(self):
        try:
            log_processor.LogProcessor._internal_proxy = DumbInternalProxy()

            def get_object_data(*a, **kw):
                return [self.access_test_line]
            orig_get_object_data = log_processor.LogProcessor.get_object_data
            log_processor.LogProcessor.get_object_data = get_object_data
            proxy_config = self.proxy_config.copy()
            proxy_config.update({
                    'log-processor-access': {
                        'source_filename_format': '%Y%m%d%H*',
                        'class_path':
                            'slogging.access_processor.AccessLogProcessor'
                    }})
            processor_args = (proxy_config, DumbLogger())
            item = ('access', 'a', 'c', 'o')
            logs_to_process = [item]
            processor_klass = log_processor.LogProcessor
            results = log_processor.multiprocess_collate(processor_klass,
                                                         processor_args,
                                                         'process_one_file',
                                                         logs_to_process,
                                                         1,
                                                         DumbLogger())
            results = list(results)
            expected = [(item, {('acct', '2010', '07', '09', '04'):
                        {('public', 'object', 'GET', '2xx'): 1,
                        ('public', 'bytes_out'): 95,
                        'marker_query': 0,
                        'format_query': 1,
                        'delimiter_query': 0,
                        'path_query': 0,
                        ('public', 'bytes_in'): 6,
                        'prefix_query': 0}})]
            self.assertEquals(results, expected)
        finally:
            log_processor.LogProcessor._internal_proxy = None
            log_processor.LogProcessor.get_object_data = orig_get_object_data