@@ -1068,8 +1068,8 @@ def test_interrupt_applies_all_commands(self, run_mock, datetime_mock):
10681068 "package_version" : "version"
10691069 }
10701070 run_mock .assert_has_calls ([
1071- mock .call (["systemctl" , "daemon-reload" ], controller .get_log_file ("interrupts/service_restart_0" , copy_dir , config_data , root_dir ), write_cmds = True , no_chmod = True ),
1072- mock .call (["systemctl" , "restart" , "containerd" ], controller .get_log_file ("interrupts/service_restart_1" , copy_dir , config_data , root_dir ), write_cmds = True , no_chmod = True )
1071+ mock .call (root_dir , ["systemctl" , "daemon-reload" ], controller .get_log_file ("interrupts/service_restart_0" , copy_dir , config_data , root_dir ), write_cmds = True , no_chmod = True ),
1072+ mock .call (root_dir , ["systemctl" , "restart" , "containerd" ], controller .get_log_file ("interrupts/service_restart_1" , copy_dir , config_data , root_dir ), write_cmds = True , no_chmod = True )
10731073 ])
10741074
10751075 @mock .patch ("skyhook_agent.controller._run" )
@@ -1112,6 +1112,26 @@ def test_interrupt_failures_remove_flag(self, run_mock):
11121112 self .assertFalse (os .path .exists (f"{ interrupt_dir } /{ interrupt ._type ()} _1.complete" ))
11131113 self .assertFalse (os .path .exists (f"{ interrupt_dir } /{ interrupt ._type ()} _1.complete" ))
11141114
1115+ @mock .patch ("skyhook_agent.controller._run" )
1116+ def test_interrupt_calls_run_with_correct_parameters (self , run_mock ):
1117+ run_mock .return_value = 0
1118+ SKYHOOK_RESOURCE_ID = "scr-id-1_package_version"
1119+
1120+ with (self ._setup_for_main () as (container_root_dir , config_data , root_dir , copy_dir ),
1121+ set_env (SKYHOOK_RESOURCE_ID = SKYHOOK_RESOURCE_ID )):
1122+
1123+ interrupt = interrupts .ServiceRestart (["foo" , "bar" ])
1124+ result = controller .do_interrupt (interrupt .make_controller_input (), root_dir , copy_dir )
1125+
1126+ self .assertEqual (result , False )
1127+ expected_calls = [
1128+ mock .call (root_dir , ["systemctl" , "daemon-reload" ], mock .ANY , write_cmds = True , no_chmod = True ),
1129+ mock .call (root_dir , ["systemctl" , "restart" , "foo" ], mock .ANY , write_cmds = True , no_chmod = True ),
1130+ mock .call (root_dir , ["systemctl" , "restart" , "bar" ], mock .ANY , write_cmds = True , no_chmod = True )
1131+ ]
1132+ run_mock .assert_has_calls (expected_calls )
1133+ self .assertEqual (run_mock .call_count , 3 )
1134+
11151135 @mock .patch ("skyhook_agent.controller.datetime" )
11161136 @mock .patch ("skyhook_agent.controller._run" )
11171137 def test_interrupt_failure_fails_controller (self , run_mock , datetime_mock ):
@@ -1140,7 +1160,7 @@ def test_interrupt_failure_fails_controller(self, run_mock, datetime_mock):
11401160 "package_version" : "version"
11411161 }
11421162 run_mock .assert_has_calls ([
1143- mock .call (["systemctl" , "daemon-reload" ], controller .get_log_file ("interrupts/service_restart_0" , "copy_dir" , config_data , root_dir ), write_cmds = True , no_chmod = True )
1163+ mock .call (root_dir , ["systemctl" , "daemon-reload" ], controller .get_log_file ("interrupts/service_restart_0" , "copy_dir" , config_data , root_dir ), write_cmds = True , no_chmod = True )
11441164 ])
11451165
11461166 self .assertEqual (result , True )
@@ -1173,7 +1193,7 @@ def test_interrupt_makes_config_from_skyhook_resource_id(self, run_mock, datetim
11731193 "package_version" : "version"
11741194 }
11751195 run_mock .assert_has_calls ([
1176- mock .call (["systemctl" , "daemon-reload" ], controller .get_log_file ("interrupts/service_restart_0" , "copy_dir" , config_data , root_dir ), write_cmds = True , no_chmod = True )
1196+ mock .call (root_dir , ["systemctl" , "daemon-reload" ], controller .get_log_file ("interrupts/service_restart_0" , "copy_dir" , config_data , root_dir ), write_cmds = True , no_chmod = True )
11771197 ])
11781198
11791199 def test_interrupt_noop_makes_the_flag_file (self ):
0 commit comments