@@ -403,57 +403,6 @@ def test_enable_sbd_service(self, mock_list_cluster_nodes, mock_ServiceManager,
403403 call ("Enable %s on node %s" , constants .SBD_SERVICE , 'node2' )
404404 ])
405405
406- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
407- @patch ('crmsh.sbd.ServiceManager' )
408- def test_restart_cluster_if_possible_return (self , mock_ServiceManager , mock_CrmMonXmlParser ):
409- mock_ServiceManager .return_value .service_is_active .return_value = False
410- SBDManager .restart_cluster_if_possible ()
411- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
412- mock_CrmMonXmlParser .assert_not_called ()
413-
414- @patch ('logging.Logger.warning' )
415- @patch ('crmsh.utils.is_dlm_running' )
416- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
417- @patch ('crmsh.sbd.ServiceManager' )
418- def test_restart_cluster_if_possible_manually (
419- self , mock_ServiceManager , mock_CrmMonXmlParser , mock_is_dlm_running , mock_logger_warning ,
420- ):
421- mock_ServiceManager .return_value .service_is_active .return_value = True
422- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = True
423- mock_is_dlm_running .return_value = False
424- SBDManager .restart_cluster_if_possible ()
425- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
426- mock_logger_warning .assert_has_calls ([
427- call ("Resource is running, need to restart cluster service manually on each node" ),
428- call ("Or, run with `crm -F` or `--force` option, the `sbd` subcommand will leverage maintenance mode for any changes that require restarting sbd.service" ),
429- call ("Understand risks that running RA has no cluster protection while the cluster is in maintenance mode and restarting" )
430- ])
431-
432- @patch ('logging.Logger.warning' )
433- @patch ('crmsh.utils.is_dlm_running' )
434- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
435- @patch ('crmsh.sbd.ServiceManager' )
436- def test_restart_cluster_if_possible_dlm_running (
437- self , mock_ServiceManager , mock_CrmMonXmlParser , mock_is_dlm_running , mock_logger_warning ,
438- ):
439- mock_ServiceManager .return_value .service_is_active .return_value = True
440- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = True
441- mock_is_dlm_running .return_value = True
442- SBDManager .restart_cluster_if_possible (with_maintenance_mode = True )
443- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
444- mock_logger_warning .assert_called_once_with ("Resource is running, need to restart cluster service manually on each node" )
445-
446- @patch ('crmsh.bootstrap.restart_cluster' )
447- @patch ('logging.Logger.warning' )
448- @patch ('crmsh.xmlutil.CrmMonXmlParser' )
449- @patch ('crmsh.sbd.ServiceManager' )
450- def test_restart_cluster_if_possible (self , mock_ServiceManager , mock_CrmMonXmlParser , mock_logger_warning , mock_restart_cluster ):
451- mock_ServiceManager .return_value .service_is_active .return_value = True
452- mock_CrmMonXmlParser .return_value .is_non_stonith_resource_running .return_value = False
453- SBDManager .restart_cluster_if_possible ()
454- mock_ServiceManager .return_value .service_is_active .assert_called_once_with (constants .PCMK_SERVICE )
455- mock_restart_cluster .assert_called_once ()
456-
457406 @patch ('crmsh.bootstrap.prompt_for_string' )
458407 def test_prompt_for_sbd_device_diskless (self , mock_prompt_for_string ):
459408 mock_prompt_for_string .return_value = "none"
@@ -641,10 +590,10 @@ def test_init_and_deploy_sbd_not_config_sbd(self, mock_ServiceManager):
641590 sbdmanager_instance ._load_attributes_from_bootstrap .assert_not_called ()
642591
643592 @patch ('crmsh.bootstrap.adjust_properties' )
644- @patch ('crmsh.sbd.SBDManager.restart_cluster_if_possible ' )
593+ @patch ('crmsh.bootstrap.restart_cluster ' )
645594 @patch ('crmsh.sbd.SBDManager.enable_sbd_service' )
646595 @patch ('crmsh.sbd.ServiceManager' )
647- def test_init_and_deploy_sbd (self , mock_ServiceManager , mock_enable_sbd_service , mock_restart_cluster_if_possible , mock_adjust_properties ):
596+ def test_init_and_deploy_sbd (self , mock_ServiceManager , mock_enable_sbd_service , mock_restart_cluster , mock_adjust_properties ):
648597 mock_bootstrap_ctx = Mock (cluster_is_running = True )
649598 sbdmanager_instance = SBDManager (bootstrap_context = mock_bootstrap_ctx )
650599 sbdmanager_instance .get_sbd_device_from_bootstrap = Mock ()
0 commit comments