Mike Kolesnik has posted comments on this change.
Change subject: engine: Validate Dup MAC Addresses upon Iface Plug
......................................................................
Patch Set 1: (2 inline comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/ActivateDeactivateVmNicCommand.java
Line 167: private boolean
existsPluggedInterfaceWithSameMac(VmNetworkInterface interfaceToPlug) {
Line 168: List<VmNetworkInterface> vmNetworkIntrefaces =
Line 169:
getDbFacade().getVmNetworkInterfaceDao().getAllForMac(interfaceToPlug.getMacAddress());
Line 170: for (VmNetworkInterface vmNetworkInterface :
vmNetworkIntrefaces) {
Line 171: if
(!interfaceToPlug.getId().equals(vmNetworkInterface.getId()) &&
vmNetworkInterface.isPlugged()) {
I don't think that this is a good practice for internal API, I would prefer
that we do what is necessary now and in the future if anyone wants a more
generic API then he can either refactor this code or add a new method.
Line 172: return true;
Line 173: }
Line 174: }
Line 175: return false;
....................................................
File
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VmNetworkInterfaceDaoTest.java
Line 279:
Line 280: @Test
Line 281: public void testGetAllForMac() throws Exception {
Line 282: List<VmNetworkInterface> result =
dao.getAllForMac(FixturesTool.MAC_ADDRESS);
Line 283: assertEquals(1, result.size());
You are not testing the API that you have.
You have a method that's supposed to find NICs with a certain MAC address, but
what you test is that a "magic" ID is found, not the actual thing that the API
is supposed to do.
Also it's a bad idea to assume how much of these NICs there will be, unless MAC
address is unique (but we know it's not).
Line 284: assertEquals(FixturesTool.VM_NETWORK_INTERFACE2,
result.get(0).getId());
Line 285: }
Line 286:
Line 287: private void
assertCorrectResultForTemplate(List<VmNetworkInterface> result) {
--
To view, visit http://gerrit.ovirt.org/12242
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: If1476e8bec112c0c592e5cc16deefcf67076f5dc
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Muli Salem <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: Muli Salem <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches