@@ -387,57 +387,6 @@ def test_enable_sbd_service(self, mock_list_cluster_nodes, mock_ServiceManager,
387387 call ("Enable %s on node %s" , constants .SBD_SERVICE , 'node2' )
388388 ])
389389
390- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
391- @patch ('crmsh.sbd.ServiceManager' )
392- def test_restart_cluster_if_possible_return (self , mock_ServiceManager , mock_CrmMonXmlParser ):
393- mock_ServiceManager .return_value .service_is_active .return_value = False
394- SBDManager .restart_cluster_if_possible ()
395- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
396- mock_CrmMonXmlParser .assert_not_called ()
397-
398- @patch ('logging.Logger.warning' )
399- @patch ('crmsh.utils.is_dlm_running' )
400- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
401- @patch ('crmsh.sbd.ServiceManager' )
402- def test_restart_cluster_if_possible_manually (
403- self , mock_ServiceManager , mock_CrmMonXmlParser , mock_is_dlm_running , mock_logger_warning ,
404- ):
405- mock_ServiceManager .return_value .service_is_active .return_value = True
406- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = True
407- mock_is_dlm_running .return_value = False
408- SBDManager .restart_cluster_if_possible ()
409- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
410- mock_logger_warning .assert_has_calls ([
411- call ("Resource is running, need to restart cluster service manually on each node" ),
412- call ("Or, run with `crm -F` or `--force` option, the `sbd` subcommand will leverage maintenance mode for any changes that require restarting sbd.service" ),
413- call ("Understand risks that running RA has no cluster protection while the cluster is in maintenance mode and restarting" )
414- ])
415-
416- @patch ('logging.Logger.warning' )
417- @patch ('crmsh.utils.is_dlm_running' )
418- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
419- @patch ('crmsh.sbd.ServiceManager' )
420- def test_restart_cluster_if_possible_dlm_running (
421- self , mock_ServiceManager , mock_CrmMonXmlParser , mock_is_dlm_running , mock_logger_warning ,
422- ):
423- mock_ServiceManager .return_value .service_is_active .return_value = True
424- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = True
425- mock_is_dlm_running .return_value = True
426- SBDManager .restart_cluster_if_possible (with_maintenance_mode = True )
427- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
428- mock_logger_warning .assert_called_once_with ("Resource is running, need to restart cluster service manually on each node" )
429-
430- @patch ('crmsh.bootstrap.restart_cluster' )
431- @patch ('logging.Logger.warning' )
432- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
433- @patch ('crmsh.sbd.ServiceManager' )
434- def test_restart_cluster_if_possible (self , mock_ServiceManager , mock_CrmMonXmlParser , mock_logger_warning , mock_restart_cluster ):
435- mock_ServiceManager .return_value .service_is_active .return_value = True
436- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = False
437- SBDManager .restart_cluster_if_possible ()
438- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
439- mock_restart_cluster .assert_called_once ()
440-
441390 @patch ('crmsh.bootstrap.prompt_for_string' )
442391 def test_prompt_for_sbd_device_diskless (self , mock_prompt_for_string ):
443392 mock_prompt_for_string .return_value = "none"
@@ -625,10 +574,10 @@ def test_init_and_deploy_sbd_not_config_sbd(self, mock_ServiceManager):
625574 sbdmanager_instance ._load_attributes_from_bootstrap .assert_not_called ()
626575
627576 @patch ('crmsh.bootstrap.adjust_properties' )
628- @patch ('crmsh.sbd.SBDManager.restart_cluster_if_possible ' )
577+ @patch ('crmsh.bootstrap.restart_cluster ' )
629578 @patch ('crmsh.sbd.SBDManager.enable_sbd_service' )
630579 @patch ('crmsh.sbd.ServiceManager' )
631- def test_init_and_deploy_sbd (self , mock_ServiceManager , mock_enable_sbd_service , mock_restart_cluster_if_possible , mock_adjust_properties ):
580+ def test_init_and_deploy_sbd (self , mock_ServiceManager , mock_enable_sbd_service , mock_restart_cluster , mock_adjust_properties ):
632581 mock_bootstrap_ctx = Mock (cluster_is_running = True )
633582 sbdmanager_instance = SBDManager (bootstrap_context = mock_bootstrap_ctx )
634583 sbdmanager_instance .get_sbd_device_from_bootstrap = Mock ()
0 commit comments