@@ -1172,8 +1172,9 @@ def _test_init_instance_reverts_crashed_migrations(self,
1172
1172
mock_finish .assert_called_once_with (self .context , instance ,
1173
1173
[], [], power_on )
1174
1174
mock_save .assert_called_once_with ()
1175
- mock_get_info .assert_has_calls ([mock .call (instance ),
1176
- mock .call (instance )])
1175
+ mock_get_info .assert_has_calls (
1176
+ [mock .call (instance , use_cache = False ),
1177
+ mock .call (instance , use_cache = False )])
1177
1178
self .assertIsNone (instance .task_state )
1178
1179
1179
1180
def test_init_instance_reverts_crashed_migration_from_active (self ):
@@ -1645,6 +1646,20 @@ def test_init_instance_retries_power_off_silent_exception(self):
1645
1646
self .compute .stop_instance .assert_has_calls ([call ])
1646
1647
self .assertIsNone (init_return )
1647
1648
1649
+ def test_get_power_state (self ):
1650
+ instance = objects .Instance (self .context )
1651
+ instance .uuid = uuids .instance
1652
+ instance .id = 1
1653
+ instance .vm_state = vm_states .STOPPED
1654
+ instance .task_state = None
1655
+ instance .host = self .compute .host
1656
+ with mock .patch .object (self .compute .driver , 'get_info' ) as mock_info :
1657
+ mock_info .return_value = hardware .InstanceInfo (
1658
+ state = power_state .SHUTDOWN )
1659
+ res = self .compute ._get_power_state (self .context , instance )
1660
+ mock_info .assert_called_once_with (instance , use_cache = False )
1661
+ self .assertEqual (res , power_state .SHUTDOWN )
1662
+
1648
1663
@mock .patch ('nova.objects.InstanceList.get_by_filters' )
1649
1664
def test_get_instances_on_driver (self , mock_instance_list ):
1650
1665
driver_instances = []
0 commit comments