def test_create_plugin_labels_on_unsupported_node(self): dbutils.create_test_pci_device( host_id=self.worker.id, pclass='VGA compatible controller', driver='', ) test_plugin_label = { 'intelgpu': 'enabled', } self.assign_labels_failure(self.worker.uuid, test_plugin_label)
def test_device_list_all(self): dbutils.create_test_pci_device(host_id=self.worker.id, pclass_id='030000', pvendor_id='80ee', pdevice_id='beef', sriov_totalvfs=64) data = self.get_json(self._get_path()) self.assertEqual(1, len(data['pci_devices'])) self.assertEqual(data['pci_devices'][0]['pclass_id'], '030000') self.assertEqual(data['pci_devices'][0]['pvendor_id'], '80ee') self.assertEqual(data['pci_devices'][0]['pdevice_id'], 'beef') self.assertEqual(data['pci_devices'][0]['sriov_totalvfs'], 64)
def test_create_plugin_labels_on_supported_node(self): dbutils.create_test_pci_device( host_id=self.worker.id, pclass='VGA compatible controller', driver='i915', ) test_plugin_label = { 'intelgpu': 'enabled', } self.assign_labels(self.worker.uuid, test_plugin_label) response_data = self.get_host_labels(self.worker.uuid) self.validate_labels(test_plugin_label, response_data)
def setUp(self): super(TestPatch, self).setUp() self.controller = dbutils.create_test_ihost( id='1', uuid=None, forisystemid=self.system.id, hostname='controller-0', personality=constants.CONTROLLER, subfunctions=constants.CONTROLLER, invprovision=constants.PROVISIONED ) # Create a pci_device and fpga_device object self.pci_device = dbutils.create_test_pci_device( host_id=self.controller.id, pclass='Processing accelerators', pclass_id='120000',) self.fpga_device = dbutils.create_test_fpga_device( host_id=self.controller.id, pci_id=self.pci_device.id) # Create a device image self.device_image = dbutils.create_test_device_image( bitstream_type=dconstants.BITSTREAM_TYPE_FUNCTIONAL, pci_vendor='80ee', pci_device='beef', bitstream_id='12345') self.device_image2 = dbutils.create_test_device_image( bitstream_type=dconstants.BITSTREAM_TYPE_FUNCTIONAL, pci_vendor='80ee', pci_device='beef', bitstream_id='6789')
def _setup_fpga_configuration(self): # Setup a single FPGA FEC device self.device = dbutils.create_test_pci_device(host_id=self.host.id, pclass_id='030000', pvendor_id='80ee', pdevice_id='beef', sriov_totalvfs=64)
def test_device_modify_name(self): self.pci_device = dbutils.create_test_pci_device( host_id=self.worker.id, pdevice_id='FFFF') response = self.patch_dict_json( '%s' % self._get_path(self.pci_device['uuid']), name='new_name', expect_errors=False) self.assertEqual('application/json', response.content_type) self.assertEqual(http_client.OK, response.status_code) self.assertEqual('new_name', response.json['name'])
def test_device_modify_sriov_vf_driver_unsupported_device(self): self.pci_device = dbutils.create_test_pci_device( host_id=self.worker.id, device_id="FFFF") response = self.patch_dict_json( '%s' % self._get_path(self.pci_device['uuid']), sriov_vf_driver='igb_uio', expect_errors=True) self.assertEqual(http_client.BAD_REQUEST, response.status_int) self.assertEqual('application/json', response.content_type) self.assertTrue(response.json['error_message']) self.assertIn('device is not supported for SR-IOV', response.json['error_message'])
def test_device_list_one(self): device = dbutils.create_test_pci_device(host_id=self.worker.id, pclass_id='030000', pvendor_id='80ee', pdevice_id='beef', sriov_totalvfs=64) result = self.get_json(self._get_path(device['uuid'])) self.assertEqual(result['pclass_id'], '030000') self.assertEqual(result['pvendor_id'], '80ee') self.assertEqual(result['pdevice_id'], 'beef') self.assertEqual(result['sriov_totalvfs'], 64)
def test_device_modify_sriov_vf_driver_vfio(self): self.pci_device = dbutils.create_test_pci_device( host_id=self.worker.id, pclass_id=dconstants.PCI_DEVICE_CLASS_FPGA, pdevice_id=dconstants.PCI_DEVICE_ID_FPGA_INTEL_5GNR_FEC_PF, sriov_totalvfs=8, sriov_numvfs=2) response = self.patch_dict_json( '%s' % self._get_path(self.pci_device['uuid']), sriov_vf_driver='vfio', expect_errors=False) self.assertEqual('application/json', response.content_type) self.assertEqual(http_client.OK, response.status_code) self.assertEqual('vfio', response.json['sriov_vf_driver'])
def test_device_modify_sriov_numvfs_unsupported_hw_device(self): self.pci_device = dbutils.create_test_pci_device( host_id=self.worker.id, pclass_id=dconstants.PCI_DEVICE_CLASS_FPGA, pdevice_id=dconstants.PCI_DEVICE_ID_FPGA_INTEL_5GNR_FEC_PF, sriov_totalvfs=None) response = self.patch_dict_json( '%s' % self._get_path(self.pci_device['uuid']), sriov_numvfs=2, expect_errors=True) self.assertEqual(http_client.BAD_REQUEST, response.status_int) self.assertEqual('application/json', response.content_type) self.assertTrue(response.json['error_message']) self.assertIn('SR-IOV cannot be configured on this interface', response.json['error_message'])
def setUp(self): super(DeviceLabelTestCase, self).setUp() self.dbapi = dbapi.get_instance() # Create a pci_device and fpga_device object self.pci_device = dbutils.create_test_pci_device( host_id=self.host.id, pclass='Processing accelerators', pclass_id='120000',) self.fpga_device = dbutils.create_test_fpga_device( host_id=self.host.id, pci_id=self.pci_device.id) self.generic_labels = [ {'pcidevice_uuid': self.pci_device.uuid}, {'key1': 'value1'}, # {'key1': 'value2'}, {'key2': 'value2'} ]
def setUp(self, pclass_id=dconstants.PCI_DEVICE_CLASS_FPGA.__str__().split(' '), pdev_id='0d8f'): super(TestPatchDevice, self).setUp() # PCI_DEVICE_CLASS_FPGA is now a class that overloads euqality conditional. # This was needed to account for PCI devices with ProgIF other than 0x0. # First element in pclass_id is the default 0x120000 Classid + ProgIF. self.pclass_id = pclass_id[0] self.pdevice = 'Device [' + pdev_id + ']' # Create a pci_device self.pci_device = dbutils.create_test_pci_device( host_id=self.worker.id, pciaddr='0000:b7:00.0', name='pci_0000_b7_00_0', pclass='Processing accelerators', pclass_id=self.pclass_id, pvendor='Intel Corporation', pvendor_id='8086', pdevice='Device [0d8f]', pdevice_id=dconstants.PCI_DEVICE_ID_FPGA_INTEL_5GNR_FEC_PF, driver=None, enabled=False, sriov_totalvfs=8, sriov_numvfs=None, sriov_vf_driver=None) time.sleep(2) response = self.get_json(self._get_path(self.pci_device['uuid'])) self.assertEqual('0000:b7:00.0', response['pciaddr']) self.assertEqual('pci_0000_b7_00_0', response['name']) self.assertEqual('Processing accelerators', response['pclass']) self.assertEqual(self.pclass_id, response['pclass_id']) self.assertEqual('Intel Corporation', response['pvendor']) self.assertEqual('8086', response['pvendor_id']) self.assertEqual(self.pdevice, response['pdevice']) self.assertEqual(dconstants.PCI_DEVICE_ID_FPGA_INTEL_5GNR_FEC_PF, response['pdevice_id']) self.assertEqual(None, response['driver']) self.assertEqual(False, response['enabled']) self.assertEqual(8, response['sriov_totalvfs']) self.assertEqual(None, response['sriov_numvfs']) self.assertEqual(None, response['sriov_vf_driver'])
def test_device_modify_fec_device_unprovisioned(self): host = self._create_host(constants.CONTROLLER, subfunction=constants.WORKER, admin=constants.ADMIN_LOCKED, invprovision="provisioning") self.pci_device = dbutils.create_test_pci_device( host_id=host.id, pclass_id=dconstants.PCI_DEVICE_CLASS_FPGA, pdevice_id=dconstants.PCI_DEVICE_ID_FPGA_INTEL_5GNR_FEC_PF, sriov_totalvfs=8, sriov_numvfs=2) response = self.patch_dict_json( '%s' % self._get_path(self.pci_device['uuid']), sriov_numvfs=-1, expect_errors=True) self.assertEqual(http_client.BAD_REQUEST, response.status_int) self.assertEqual('application/json', response.content_type) self.assertTrue(response.json['error_message']) self.assertIn('is unlocked for the first time', response.json['error_message'])
def setUp(self): super(TestPatchDevice, self).setUp() # Create a pci_device self.pci_device = dbutils.create_test_pci_device( host_id=self.worker.id, pciaddr='0000:b7:00.0', name='pci_0000_b7_00_0', pclass='Processing accelerators', pclass_id=dconstants.PCI_DEVICE_CLASS_FPGA, pvendor='Intel Corporation', pvendor_id='8086', pdevice='Device [0d8f]', pdevice_id=dconstants.PCI_DEVICE_ID_FPGA_INTEL_5GNR_FEC_PF, driver=None, enabled=False, sriov_totalvfs=8, sriov_numvfs=None, sriov_vf_driver=None) time.sleep(2) response = self.get_json(self._get_path(self.pci_device['uuid'])) self.assertEqual('0000:b7:00.0', response['pciaddr']) self.assertEqual('pci_0000_b7_00_0', response['name']) self.assertEqual('Processing accelerators', response['pclass']) self.assertEqual(dconstants.PCI_DEVICE_CLASS_FPGA, response['pclass_id']) self.assertEqual('Intel Corporation', response['pvendor']) self.assertEqual('8086', response['pvendor_id']) self.assertEqual('Device [0d8f]', response['pdevice']) self.assertEqual(dconstants.PCI_DEVICE_ID_FPGA_INTEL_5GNR_FEC_PF, response['pdevice_id']) self.assertEqual(None, response['driver']) self.assertEqual(False, response['enabled']) self.assertEqual(8, response['sriov_totalvfs']) self.assertEqual(None, response['sriov_numvfs']) self.assertEqual(None, response['sriov_vf_driver'])
def _create_device(self, **kw): device = dbutils.create_test_pci_device(**kw) return device