19
19
import textwrap
20
20
import warnings
21
21
22
- from cinderclient import exceptions as cinder_exception
23
22
import ddt
24
23
import fixtures
25
24
import mock
@@ -3247,6 +3246,10 @@ def test_show_unknown_failure(self, mock_get_context):
3247
3246
"""Test the 'show' command with an unknown failure"""
3248
3247
mock_get_context .side_effect = test .TestingException ('oops' )
3249
3248
ret = self .commands .show (uuidsentinel .instance , uuidsentinel .volume )
3249
+ output = self .output .getvalue ().strip ()
3250
+ self .assertIn (
3251
+ 'Unexpected error, see nova-manage.log for the full trace: oops' ,
3252
+ output )
3250
3253
self .assertEqual (1 , ret )
3251
3254
3252
3255
@mock .patch (
@@ -3350,6 +3353,10 @@ def test_get_connector_unknown_failure(
3350
3353
mock_get_connector .side_effect = test .TestingException ('oops' )
3351
3354
ret = self .commands .get_connector ()
3352
3355
3356
+ output = self .output .getvalue ().strip ()
3357
+ self .assertIn (
3358
+ 'Unexpected error, see nova-manage.log for the full trace: oops' ,
3359
+ output )
3353
3360
self .assertEqual (1 , ret )
3354
3361
mock_get_root .assert_called_once_with ()
3355
3362
mock_get_connector .assert_called_once_with (
@@ -3491,7 +3498,7 @@ def test_refresh_invalid_volume_id(self, mock_get_instance, mock_get_bdm):
3491
3498
objects .BlockDeviceMapping , 'get_by_volume_and_instance' )
3492
3499
@mock .patch .object (objects .Instance , 'get_by_uuid' )
3493
3500
@mock .patch .object (objects .InstanceAction , 'action_start' )
3494
- def test_refresh_attachment_create_failure (
3501
+ def test_refresh_attachment_unknown_failure (
3495
3502
self , mock_action_start , mock_get_instance , mock_get_bdm , mock_lock ,
3496
3503
mock_unlock , mock_attachment_create , mock_attachment_delete ,
3497
3504
mock_attachment_get
@@ -3505,14 +3512,16 @@ def test_refresh_attachment_create_failure(
3505
3512
mock_get_bdm .return_value = objects .BlockDeviceMapping (
3506
3513
uuid = uuidsentinel .bdm , volume_id = uuidsentinel .volume ,
3507
3514
attachment_id = uuidsentinel .attachment )
3508
- mock_attachment_create .side_effect = \
3509
- cinder_exception .ClientException (400 , '400' )
3515
+ mock_attachment_create .side_effect = Exception ('oops' )
3510
3516
mock_action = mock .Mock (spec = objects .InstanceAction )
3511
3517
mock_action_start .return_value = mock_action
3512
3518
3513
3519
ret = self ._test_refresh ()
3514
3520
self .assertEqual (1 , ret )
3515
-
3521
+ output = self .output .getvalue ().strip ()
3522
+ self .assertIn (
3523
+ 'Unexpected error, see nova-manage.log for the full trace: oops' ,
3524
+ output )
3516
3525
mock_attachment_create .assert_called_once_with (
3517
3526
mock .ANY , uuidsentinel .volume , uuidsentinel .instance )
3518
3527
mock_attachment_delete .assert_not_called ()
@@ -3640,10 +3649,14 @@ def test_get(self, mock_get_context, mock_get_machine_type):
3640
3649
def test_get_unknown_failure (
3641
3650
self , mock_get_context , mock_get_machine_type
3642
3651
):
3643
- mock_get_machine_type .side_effect = Exception ()
3652
+ mock_get_machine_type .side_effect = Exception ('oops' )
3644
3653
ret = self .commands .get_machine_type (
3645
3654
instance_uuid = uuidsentinel .instance
3646
3655
)
3656
+ output = self .output .getvalue ().strip ()
3657
+ self .assertIn (
3658
+ 'Unexpected error, see nova-manage.log for the full trace: oops' ,
3659
+ output )
3647
3660
self .assertEqual (1 , ret )
3648
3661
3649
3662
@mock .patch ('nova.virt.libvirt.machine_type_utils.get_machine_type' )
@@ -3735,11 +3748,15 @@ def test_update_force(self, mock_get_context, mock_update):
3735
3748
@mock .patch ('nova.virt.libvirt.machine_type_utils.update_machine_type' )
3736
3749
@mock .patch ('nova.context.get_admin_context' , new = mock .Mock ())
3737
3750
def test_update_unknown_failure (self , mock_update ):
3738
- mock_update .side_effect = Exception ()
3751
+ mock_update .side_effect = Exception ('oops' )
3739
3752
ret = self .commands .update_machine_type (
3740
3753
instance_uuid = uuidsentinel .instance ,
3741
3754
machine_type = mock .sentinel .machine_type
3742
3755
)
3756
+ output = self .output .getvalue ().strip ()
3757
+ self .assertIn (
3758
+ 'Unexpected error, see nova-manage.log for the full trace: oops' ,
3759
+ output )
3743
3760
self .assertEqual (1 , ret )
3744
3761
3745
3762
@mock .patch ('nova.virt.libvirt.machine_type_utils.update_machine_type' )
@@ -3859,9 +3876,13 @@ def test_list_unset_machine_type_none_found(
3859
3876
def test_list_unset_machine_type_unknown_failure (
3860
3877
self , mock_get_context , mock_get_instances
3861
3878
):
3862
- mock_get_instances .side_effect = Exception ()
3879
+ mock_get_instances .side_effect = Exception ('oops' )
3863
3880
ret = self .commands .list_unset_machine_type (
3864
3881
cell_uuid = uuidsentinel .cell_uuid )
3882
+ output = self .output .getvalue ().strip ()
3883
+ self .assertIn (
3884
+ 'Unexpected error, see nova-manage.log for the full trace: oops' ,
3885
+ output )
3865
3886
self .assertEqual (1 , ret )
3866
3887
3867
3888
@mock .patch (
0 commit comments