File tree Expand file tree Collapse file tree
elasticsearch_metrics/imps Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -473,17 +473,24 @@ def each_timeseries_index(
473473 yield _index_name , _index_info
474474
475475 @classmethod
476- def do_teardown (cls , es8_client : Elastic8Client ) -> None :
476+ def do_teardown (
477+ cls ,
478+ using : str | Elastic8Client | None = None ,
479+ * ,
480+ keep_templates : bool = False ,
481+ ) -> None :
477482 assert not cls .is_abstract
483+ _client = cls ._get_connection (using )
478484 _indexname_wildcard = cls .format_timeseries_index_pattern ()
479- _indices = es8_client .indices .get (index = _indexname_wildcard , features = "," )
485+ _indices = _client .indices .get (index = _indexname_wildcard , features = "," )
480486 for _index_name in _indices .keys ():
481- es8_client .indices .delete (index = _index_name )
482- _templatename = cls .get_timeseries_template_name ()
483- try :
484- es8_client .indices .delete_index_template (name = _templatename )
485- except NotFoundError :
486- pass
487+ _client .indices .delete (index = _index_name )
488+ if not keep_templates :
489+ _templatename = cls .get_timeseries_template_name ()
490+ try :
491+ _client .indices .delete_index_template (name = _templatename )
492+ except NotFoundError :
493+ pass
487494
488495 @classmethod
489496 def get_timeseries_template (cls ) -> esdsl .ComposableIndexTemplate :
You can’t perform that action at this time.
0 commit comments