use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class SyncMacsOfDbNicsWithSnapshotTest method testSyncWhenNothingChanged.
@Test
public void testSyncWhenNothingChanged() {
String macAddress = "1";
VmNic nic = createNic(macAddress);
createSyncMacsOfDbNicsWithSnapshot(false).sync(Arrays.asList(nic), Arrays.asList(nic));
verify(nic, times(2)).getMacAddress();
verify(macPool).freeMacs(Collections.emptyList());
verify(macPool).addMacs(Collections.emptyList());
Mockito.verifyNoMoreInteractions(nic);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNic in project ovirt-engine by oVirt.
the class SyncMacsOfDbNicsWithSnapshotTest method testSyncWhenNeedToSyncMacsWithStatefulSnapshotAndRelocate.
@Test
public void testSyncWhenNeedToSyncMacsWithStatefulSnapshotAndRelocate() {
// note that reallocation is only possible, when macs from snapshots are not reserved.
String currentMac1 = "1";
String currentMac2 = "3";
String snapshottedMac1 = "1";
String snapshottedMac2 = "2";
String reallocatingMac = "4";
VmNic currentNic1 = createNic(currentMac1);
VmNic currentNic2 = createNic(currentMac2);
VmNic snapshottedNic1 = createNic(snapshottedMac1);
VmNic snapshottedNic2 = createNic(snapshottedMac2);
List<String> macsToBeAdded = Collections.singletonList(snapshottedMac2);
when(macPool.addMacs(macsToBeAdded)).thenReturn(macsToBeAdded);
when(macPool.allocateNewMac()).thenReturn(reallocatingMac);
createSyncMacsOfDbNicsWithSnapshot(false).sync(Arrays.asList(currentNic1, currentNic2), Arrays.asList(snapshottedNic1, snapshottedNic2));
verify(snapshottedNic2).setMacAddress(reallocatingMac);
verifyMethodCallOn(VmNic::getMacAddress, 1, currentNic1, currentNic2);
// because in reallocation all(in this case) snapshotted nics will be queried again.
verifyMethodCallOn(VmNic::getMacAddress, 2, snapshottedNic1, snapshottedNic2);
verify(macPool).allocateNewMac();
verify(macPool).freeMacs(Collections.singletonList(currentMac2));
verify(macPool).addMacs(macsToBeAdded);
verifyNoMoreInteractionsOn(snapshottedNic1, snapshottedNic2, currentNic1, currentNic2);
}
Aggregations