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