本文整理汇总了Python中socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage.save_raw_and_processed方法的典型用法代码示例。如果您正苦于以下问题:Python ElasticSearchCrashStorage.save_raw_and_processed方法的具体用法?Python ElasticSearchCrashStorage.save_raw_and_processed怎么用?Python ElasticSearchCrashStorage.save_raw_and_processed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage
的用法示例。
在下文中一共展示了ElasticSearchCrashStorage.save_raw_and_processed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_success
# 需要导入模块: from socorro.external.elasticsearch.crashstorage import ElasticSearchCrashStorage [as 别名]
# 或者: from socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage import save_raw_and_processed [as 别名]
def test_success(self, pyes_mock):
mock_logging = mock.Mock()
mock_es = mock.Mock()
pyes_mock.ElasticSearch.return_value = mock_es
required_config = ElasticSearchCrashStorage.get_required_config()
required_config.add_option('logger', default=mock_logging)
config_manager = ConfigurationManager(
[required_config],
app_name='testapp',
app_version='1.0',
app_description='app description',
values_source_list=[{
'logger': mock_logging,
'elasticsearch_urls': 'http://elasticsearch_host:9200',
}],
argv_source=[]
)
with config_manager.context() as config:
crash_id = a_processed_crash['uuid']
es_storage = ElasticSearchCrashStorage(config)
es_storage.save_raw_and_processed(
a_raw_crash,
None,
a_processed_crash.copy(),
crash_id,
)
expected_crash = {
'crash_id': crash_id,
'processed_crash': a_processed_crash.copy(),
'raw_crash': a_raw_crash
}
expected_request_args = (
'socorro201214',
'crash_reports',
expected_crash
)
expected_request_kwargs = {
'id': crash_id,
'replication': 'async',
}
mock_es.index.assert_called_with(
*expected_request_args,
**expected_request_kwargs
)
示例2: test_success_after_limited_retry
# 需要导入模块: from socorro.external.elasticsearch.crashstorage import ElasticSearchCrashStorage [as 别名]
# 或者: from socorro.external.elasticsearch.crashstorage.ElasticSearchCrashStorage import save_raw_and_processed [as 别名]
def test_success_after_limited_retry(self, pyes_mock):
mock_logging = mock.Mock()
mock_es = mock.Mock()
pyes_mock.ElasticSearch.return_value = mock_es
required_config = ElasticSearchCrashStorage.get_required_config()
required_config.add_option('logger', default=mock_logging)
config_manager = ConfigurationManager(
[required_config],
app_name='testapp',
app_version='1.0',
app_description='app description',
values_source_list=[{
'logger': mock_logging,
'elasticsearch_urls': 'http://elasticsearch_host:9200',
'timeout': 0,
'backoff_delays': [0, 0, 0],
'transaction_executor_class':
TransactionExecutorWithLimitedBackoff
}],
argv_source=[]
)
with config_manager.context() as config:
es_storage = ElasticSearchCrashStorage(config)
esindex_results = [pyelasticsearch.exceptions.Timeout,
pyelasticsearch.exceptions.Timeout]
def esindex_fn(*args, **kwargs):
try:
r = esindex_results.pop(0)
raise r
except IndexError:
return mock_es.index
mock_es.index.side_effect = esindex_fn
crash_id = a_processed_crash['uuid']
es_storage.save_raw_and_processed(
a_raw_crash,
None,
a_processed_crash.copy(),
crash_id,
)
expected_crash = {
'crash_id': crash_id,
'processed_crash': a_processed_crash.copy(),
'raw_crash': a_raw_crash
}
expected_request_args = (
'socorro201214',
'crash_reports',
expected_crash
)
expected_request_kwargs = {
'id': crash_id,
}
mock_es.index.assert_called_with(
*expected_request_args,
**expected_request_kwargs
)