def setUp(self): super(TestExtARQJobMixin, self).setUp() self.fake_db_extarqs = fake_extarq.get_fake_db_extarqs() self.fake_obj_extarqs = fake_extarq.get_fake_extarq_objs() self.fake_obj_fpga_extarqs = fake_extarq.get_fake_fpga_extarq_objs() self.deployable_uuids = [ '0acbf8d6-e02a-4394-aae3-57557d209498', '0acbf8d6-e02a-4394-aae3-57557d209666' ] self.classes = [ "gpu", "no_program", "bitstream_program", "function_program", "bad_program", "mlu" ] self.class_objects = dict(zip(self.classes, self.fake_obj_extarqs)) self.class_dbs = dict(zip(self.classes, self.fake_db_extarqs)) self.fpga_classes = [ "no_program", "bitstream_program", "function_program", "bad_program" ] self.fpga_class_objects = dict( zip(self.fpga_classes, self.fake_obj_fpga_extarqs)) self.bitstream_id = self.class_objects["bitstream_program"][ "device_profile_group"][constants.ACCEL_BITSTREAM_ID] self.function_id = self.class_objects["function_program"][ "device_profile_group"][constants.ACCEL_FUNCTION_ID]
def _test_get_arq_bind_statuses_exception(self): extarqs = fake_extarq.get_fake_extarq_objs() arq_list = [extarq.arq for extarq in extarqs] for arq in arq_list: arq['state'] = constants.ARQ_INITIAL self.assertRaises(exception.ARQBadState, objects.ExtARQ.get_arq_bind_statuses, arq_list)
def setUp(self): super(TestARQsController, self).setUp() self.headers = self.gen_headers(self.context) self.fake_extarqs = fake_extarq.get_fake_extarq_objs() self.fake_bind_extarqs = fake_extarq.get_fake_extarq_bind_objs() self.fake_resolved_extarqs = ( fake_extarq.get_fake_extarq_resolved_objs()) self.arqs_controller = arqs.ARQsController()
def test_check_if_bound(self, mock_extarq_list): """Test the happy path.""" extarqs = fake_extarq.get_fake_extarq_objs() mock_extarq_list.return_value = extarqs # Not the instance UUID in extarqs above instance_uuid = 'ffbb66f6-99f6-4a85-a90c-fd8e8fb35f16' valid_fields = { extarq.arq['uuid']: { 'hostname': 'myhost', 'device_rp_uuid': 'fb16c293-5739-4c84-8590-926f9ab16669', 'instance_uuid': instance_uuid } for extarq in extarqs } self.arqs_controller._check_if_already_bound(self.context, valid_fields) mock_extarq_list.assert_called_once_with(self.context)
def test_check_if_bound_exception(self, mock_extarq_list): """Test that an exception is raised if binding request specifies an instance that already has ARQs. """ extarqs = fake_extarq.get_fake_extarq_objs() mock_extarq_list.return_value = extarqs # Same instance UUID as in extarqs above, thus triggering exception instance_uuid = extarqs[0].arq['instance_uuid'] valid_fields = { extarq.arq['uuid']: { 'hostname': 'myhost', 'device_rp_uuid': 'fb16c293-5739-4c84-8590-926f9ab16669', 'instance_uuid': instance_uuid } for extarq in extarqs } expected_err = ('Instance %s already has accelerator requests. ' 'Cannot bind additional ARQs.') % instance_uuid self.assertRaisesRegex(exception.PatchError, expected_err, self.arqs_controller._check_if_already_bound, self.context, valid_fields)
def setUp(self): super(TestExtARQObject, self).setUp() self.fake_db_extarqs = fake_extarq.get_fake_db_extarqs() self.fake_obj_extarqs = fake_extarq.get_fake_extarq_objs() self.fake_obj_fpga_extarqs = fake_extarq.get_fake_fpga_extarq_objs() self.deployable_uuids = ['0acbf8d6-e02a-4394-aae3-57557d209498']
def setUp(self): super(TestARQsController, self).setUp() self.headers = self.gen_headers(self.context) self.fake_extarqs = fake_extarq.get_fake_extarq_objs()