private void commonUpdateHostNicVfsConfigWithNumVfsData(int numOfVfs) { when(pciDevice.getTotalVirtualFunctions()).thenReturn(TOTAL_NUM_OF_VFS); List<HostDevice> vfs = mockVfsOnNetDevice(numOfVfs); mockHostDevices(vfs); networkDeviceHelper.updateHostNicVfsConfigWithNumVfsData(hostNicVfsConfig); verify(hostNicVfsConfig).setMaxNumOfVfs(TOTAL_NUM_OF_VFS); verify(hostNicVfsConfig).setNumOfVfs(numOfVfs); }
@Test public void getHostNicVfsConfigsWithNumVfsDataByHostId() { when(hostNicVfsConfigDao.getAllVfsConfigByHostId(HOST_ID)) .thenReturn(Collections.singletonList(hostNicVfsConfig)); when(pciDevice.getTotalVirtualFunctions()).thenReturn(TOTAL_NUM_OF_VFS); List<HostDevice> vfs = mockVfsOnNetDevice(2); mockHostDevices(vfs); List<HostNicVfsConfig> vfsConfigList = networkDeviceHelper.getHostNicVfsConfigsWithNumVfsDataByHostId(HOST_ID); assertEquals(1, vfsConfigList.size()); assertEquals(hostNicVfsConfig, vfsConfigList.get(0)); verify(hostNicVfsConfig).setMaxNumOfVfs(TOTAL_NUM_OF_VFS); verify(hostNicVfsConfig).setNumOfVfs(2); }
private void commonIsSriovDevice(boolean isSriov) { when(pciDevice.getTotalVirtualFunctions()).thenReturn(isSriov ? TOTAL_NUM_OF_VFS : null); assertEquals(isSriov, networkDeviceHelper.isSriovDevice(pciDevice)); }