@@ -401,57 +401,6 @@ def test_enable_sbd_service(self, mock_list_cluster_nodes, mock_ServiceManager,
401401 call ("Enable %s on node %s" , constants .SBD_SERVICE , 'node2' )
402402 ])
403403
404- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
405- @patch ('crmsh.sbd.ServiceManager' )
406- def test_restart_cluster_if_possible_return (self , mock_ServiceManager , mock_CrmMonXmlParser ):
407- mock_ServiceManager .return_value .service_is_active .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_CrmMonXmlParser .assert_not_called ()
411-
412- @patch ('logging.Logger.warning' )
413- @patch ('crmsh.utils.is_dlm_running' )
414- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
415- @patch ('crmsh.sbd.ServiceManager' )
416- def test_restart_cluster_if_possible_manually (
417- self , mock_ServiceManager , mock_CrmMonXmlParser , mock_is_dlm_running , mock_logger_warning ,
418- ):
419- mock_ServiceManager .return_value .service_is_active .return_value = True
420- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = True
421- mock_is_dlm_running .return_value = False
422- SBDManager .restart_cluster_if_possible ()
423- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
424- mock_logger_warning .assert_has_calls ([
425- call ("Resource is running, need to restart cluster service manually on each node" ),
426- call ("Or, run with `crm -F` or `--force` option, the `sbd` subcommand will leverage maintenance mode for any changes that require restarting sbd.service" ),
427- call ("Understand risks that running RA has no cluster protection while the cluster is in maintenance mode and restarting" )
428- ])
429-
430- @patch ('logging.Logger.warning' )
431- @patch ('crmsh.utils.is_dlm_running' )
432- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
433- @patch ('crmsh.sbd.ServiceManager' )
434- def test_restart_cluster_if_possible_dlm_running (
435- self , mock_ServiceManager , mock_CrmMonXmlParser , mock_is_dlm_running , mock_logger_warning ,
436- ):
437- mock_ServiceManager .return_value .service_is_active .return_value = True
438- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = True
439- mock_is_dlm_running .return_value = True
440- SBDManager .restart_cluster_if_possible (with_maintenance_mode = True )
441- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
442- mock_logger_warning .assert_called_once_with ("Resource is running, need to restart cluster service manually on each node" )
443-
444- @patch ('crmsh.bootstrap.restart_cluster' )
445- @patch ('logging.Logger.warning' )
446- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
447- @patch ('crmsh.sbd.ServiceManager' )
448- def test_restart_cluster_if_possible (self , mock_ServiceManager , mock_CrmMonXmlParser , mock_logger_warning , mock_restart_cluster ):
449- mock_ServiceManager .return_value .service_is_active .return_value = True
450- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = False
451- SBDManager .restart_cluster_if_possible ()
452- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
453- mock_restart_cluster .assert_called_once ()
454-
455404 @patch ('crmsh.bootstrap.prompt_for_string' )
456405 def test_prompt_for_sbd_device_diskless (self , mock_prompt_for_string ):
457406 mock_prompt_for_string .return_value = "none"
@@ -639,10 +588,10 @@ def test_init_and_deploy_sbd_not_config_sbd(self, mock_ServiceManager):
639588 sbdmanager_instance ._load_attributes_from_bootstrap .assert_not_called ()
640589
641590 @patch ('crmsh.bootstrap.adjust_properties' )
642- @patch ('crmsh.sbd.SBDManager.restart_cluster_if_possible ' )
591+ @patch ('crmsh.bootstrap.restart_cluster ' )
643592 @patch ('crmsh.sbd.SBDManager.enable_sbd_service' )
644593 @patch ('crmsh.sbd.ServiceManager' )
645- def test_init_and_deploy_sbd (self , mock_ServiceManager , mock_enable_sbd_service , mock_restart_cluster_if_possible , mock_adjust_properties ):
594+ def test_init_and_deploy_sbd (self , mock_ServiceManager , mock_enable_sbd_service , mock_restart_cluster , mock_adjust_properties ):
646595 mock_bootstrap_ctx = Mock (cluster_is_running = True )
647596 sbdmanager_instance = SBDManager (bootstrap_context = mock_bootstrap_ctx )
648597 sbdmanager_instance .get_sbd_device_from_bootstrap = Mock ()
0 commit comments