@@ -762,6 +762,34 @@ def fake_soi(context, instance, **kwargs):
762
762
self .assertTrue (soi .called )
763
763
self .assertEqual ([instance2 .uuid ], data )
764
764
765
+ @mock .patch ('nova.accelerator.cyborg._CyborgClient.'
766
+ 'get_arq_uuids_for_instance' )
767
+ @mock .patch ('oslo_utils.timeutils.is_older_than' )
768
+ @mock .patch ('oslo_utils.timeutils.parse_strtime' )
769
+ def test_shelved_poll_with_accel_uuids (self , mock_parse , mock_older ,
770
+ mock_get_arq_uuids ):
771
+ self .flags (shelved_offload_time = 1 )
772
+ mock_older .return_value = True
773
+ instance = self ._create_fake_instance_obj ()
774
+ instance .task_state = None
775
+ instance .vm_state = vm_states .SHELVED
776
+ instance .host = self .compute .host
777
+ instance .system_metadata = {'shelved_at' : '' }
778
+ instance .flavor .extra_specs ['accel:device_profile' ] = 'dp_test'
779
+ mock_get_arq_uuids .return_value = [uuids .fake ]
780
+ instance .save ()
781
+
782
+ data = []
783
+
784
+ def fake_soi (context , instance , ** kwargs ):
785
+ data .append (instance .uuid )
786
+
787
+ with mock .patch .object (self .compute , 'shelve_offload_instance' ) as soi :
788
+ soi .side_effect = fake_soi
789
+ self .compute ._poll_shelved_instances (self .context )
790
+ self .assertTrue (soi .called )
791
+ self .assertEqual ([instance .uuid ], data )
792
+
765
793
@mock .patch ('oslo_utils.timeutils.is_older_than' )
766
794
@mock .patch ('oslo_utils.timeutils.parse_strtime' )
767
795
def test_shelved_poll_checks_task_state_on_save (self , mock_parse ,
0 commit comments