Skip to content

Commit

Permalink
fix pipeline_manager call order
Browse files Browse the repository at this point in the history
  • Loading branch information
ekneg54 committed Sep 13, 2024
1 parent 61d35e9 commit 9534a4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions logprep/framework/pipeline_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,10 @@ def stop(self):

def restart(self, daemon=True):
"""Restarts all pipelines"""
if self.prometheus_exporter:
self.prometheus_exporter.run(daemon=daemon)
self.set_count(0)
self.set_count(self._configuration.process_count)
if not self.prometheus_exporter:
return
self.prometheus_exporter.run(daemon=daemon)

def _create_pipeline(self, index) -> multiprocessing.Process:
pipeline = Pipeline(pipeline_index=index, config=self._configuration)
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/framework/test_pipeline_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ def test_restart_injects_healthcheck_functions(self):
pipeline_manager.restart()
pipeline_manager.prometheus_exporter.update_healthchecks.assert_called()

def test_restart_ensures_prometheus_exporter_is_running(self):
config = deepcopy(self.config)
config.metrics = MetricsConfig(enabled=True, port=666)
pipeline_manager = PipelineManager(config)
pipeline_manager.prometheus_exporter._prepare_multiprocessing = mock.MagicMock()
with mock.patch("logprep.util.http.ThreadingHTTPServer"):
pipeline_manager.restart()
pipeline_manager.prometheus_exporter.server.start.assert_called()


class TestThrottlingQueue:

Expand Down

0 comments on commit 9534a4c

Please sign in to comment.