diff --git a/src/powerapi/processor/pre/k8s/k8s_pre_processor_actor.py b/src/powerapi/processor/pre/k8s/k8s_pre_processor_actor.py index 841907fc..c5baecb4 100644 --- a/src/powerapi/processor/pre/k8s/k8s_pre_processor_actor.py +++ b/src/powerapi/processor/pre/k8s/k8s_pre_processor_actor.py @@ -42,7 +42,7 @@ from powerapi.processor.pre.k8s.k8s_pre_processor_handlers import K8sPreProcessorActorHWPCReportHandler, \ K8sPreProcessorActorStartMessageHandler, K8sPreProcessorActorPoisonPillMessageHandler from powerapi.processor.processor_actor import ProcessorState, ProcessorActor -from powerapi.report import HWPCReport +from powerapi.report.report import Report ADDED_EVENT = 'ADDED' DELETED_EVENT = 'DELETED' @@ -211,6 +211,6 @@ def setup(self): """ ProcessorActor.setup(self) self.add_handler(message_type=StartMessage, handler=K8sPreProcessorActorStartMessageHandler(state=self.state)) - self.add_handler(message_type=HWPCReport, handler=K8sPreProcessorActorHWPCReportHandler(state=self.state)) + self.add_handler(message_type=Report, handler=K8sPreProcessorActorHWPCReportHandler(state=self.state)) self.add_handler(message_type=PoisonPillMessage, handler=K8sPreProcessorActorPoisonPillMessageHandler(state=self.state)) diff --git a/tests/unit/actor/abstract_test_actor.py b/tests/unit/actor/abstract_test_actor.py index e34db9a3..a8525be5 100644 --- a/tests/unit/actor/abstract_test_actor.py +++ b/tests/unit/actor/abstract_test_actor.py @@ -261,7 +261,9 @@ def init_actor(self, actor): def started_actor(self, init_actor): init_actor.send_control(StartMessage('test_case')) _ = init_actor.receive_control(2000) - return init_actor + yield init_actor + + init_actor.send_control(PoisonPillMessage()) @pytest.fixture def started_fake_pusher_power_report(self, dummy_pipe_in): diff --git a/tests/unit/dispatcher/test_dispatcher_actor.py b/tests/unit/dispatcher/test_dispatcher_actor.py index 9272da4b..d53be6b4 100644 --- a/tests/unit/dispatcher/test_dispatcher_actor.py +++ b/tests/unit/dispatcher/test_dispatcher_actor.py @@ -331,23 +331,23 @@ def test_send_Report1_without_dispatch_rule_for_Report1_dont_create_formula(self @define_dispatch_rules([(Report1, DispatchRule1AB(primary=True))]) def test_send_Report1_with_dispatch_rule_for_Report1_and_no_formula_created_must_create_a_new_formula(self, started_actor, - dummy_pipe_out, - shutdown_system): + dummy_pipe_out): """ Check that a formula is created when a report is received """ started_actor.send_data(REPORT_1) - _, power_report = recv_from_pipe(dummy_pipe_out, 2) + _, power_report = recv_from_pipe(dummy_pipe_out, 0.2) assert isinstance(power_report, PowerReport) assert power_report.power == 42 + # started_actor.send_control(PoisonPillMessage()) + @pytest.mark.usefixtures("shutdown_system") @define_dispatch_rules([(Report1, DispatchRule1AB(primary=True))]) def test_send_Report1_with_dispatch_rule_for_Report1_and_one_formula_send_report_to_formula(self, dispatcher_with_formula, - dummy_pipe_out, - shutdown_system): + dummy_pipe_out): """ Check that DispatcherActor with a created formula sent a report to it """ @@ -367,8 +367,7 @@ def test_send_Report1_with_dispatch_rule_for_Report1_and_one_formula_send_report (Report2, DispatchRule2A())]) def test_send_Report2_with_dispatch_rule_for_Report1_Primary_and_two_formula_send_report_to_all_formula(self, dispatcher_with_two_formula, - dummy_pipe_out, - shutdown_system): + dummy_pipe_out): """ Check that DispatcherActor sent a report to all existing formulas @@ -394,7 +393,7 @@ def test_send_Report2_with_dispatch_rule_for_Report1_Primary_and_two_formula_sen @define_dispatch_rules([(Report1, DispatchRule1AB(primary=True))]) def test_send_REPORT1_B2_with_dispatch_rule_1AB_must_create_two_formula(self, started_actor, - dummy_pipe_out, shutdown_system): + dummy_pipe_out): """ Check that two formulas are created by DispatcherActor """ @@ -411,8 +410,7 @@ def test_send_REPORT1_B2_with_dispatch_rule_1AB_must_create_two_formula(self, st (Report3, DispatchRule3())]) def test_send_REPORT3_on_dispatcher_with_two_formula_and_dispatch_rule_1AB_send_report_to_one_formula(self, dispatcher_with_two_formula, - dummy_pipe_out, - shutdown_system): + dummy_pipe_out): """ Check that 3 reports are produced by formulas when DispatcherActor receives @@ -431,8 +429,7 @@ def test_send_REPORT3_on_dispatcher_with_two_formula_and_dispatch_rule_1AB_send_ assert recv_from_pipe(dummy_pipe_out, 0.5) == (None, None) @define_dispatch_rules([(Report1, DispatchRule1AB(primary=True))]) - def test_send_PoisonPillMessage_make_dispatcher_forward_it_to_formula(self, dispatcher_with_two_formula, - shutdown_system): + def test_send_PoisonPillMessage_make_dispatcher_forward_it_to_formula(self, dispatcher_with_two_formula): """ Check that a PoissonPillMessage stops the DispatcherActor as well as their formulas """