Roy Golan has posted comments on this change. Change subject: sla: Add support for basic PolicyUnit testing ......................................................................
Patch Set 12: Code-Review-1 (3 comments) https://gerrit.ovirt.org/#/c/39728/12/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java: Line 56: + curVds.getReservedMem(); Line 57: } Line 58: Line 59: public static Integer getEffectiveCpuCores(VDS vds, VdsGroupDAO vdsGroupDao) { Line 60: VDSGroup vdsGroup = vdsGroupDao.get(vds.getVdsGroupId()); -1 please don't infect our api. I realize this is for testing. I'm working on making SchedulingManager and SLA validator a CDI @Singleton . meanwhile please consider something different? Line 61: return getEffectiveCpuCores(vds, vdsGroup != null ? vdsGroup.getCountThreadsAsCores() : false); Line 62: } Line 63: Line 64: public static Integer getEffectiveCpuCores(VDS vds, boolean countThreadsAsCores) { https://gerrit.ovirt.org/#/c/39728/12/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/scheduling/policyunits/AbstractPolicyUnitTest.java File backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/scheduling/policyunits/AbstractPolicyUnitTest.java: Line 142: throws NoSuchFieldException, InvocationTargetException, NoSuchMethodException, InstantiationException, Line 143: IllegalAccessException, IOException, ParseException { Line 144: Map<Guid, T> entities = new HashMap<>(); Line 145: InputStream inputStream = getClass().getResourceAsStream("/scheduling/" + fixtureName); Line 146: BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); those sources most be closed, its not being treated upon collecting them. (its a well known java pitfall and java embraced something like python's "with" style) use this: try(BufferedReader reader = Files.newBufferedReader( path, StandardCharsets.UTF_8)) { ... } when out of the try block, reader.close() method will be called implicitly. btw its called try-with-resources in java (new in jdk7) Line 147: Line 148: /* First line contains the field names */ Line 149: String header = bufferedReader.readLine(); Line 150: String[] fields = header.split(","); https://gerrit.ovirt.org/#/c/39728/12/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuAndMemoryBalancingPolicyUnitTest.java File backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuAndMemoryBalancingPolicyUnitTest.java: Line 21: import static org.mockito.Mockito.mock; Line 22: import static org.mockito.Mockito.spy; Line 23: Line 24: public class CpuAndMemoryBalancingPolicyUnitTest extends AbstractPolicyUnitTest { Line 25: protected <T extends CpuAndMemoryBalancingPolicyUnit> T mockUnit(Class<T> unitType, create a new line here Line 26: VDSGroup cluster, Line 27: Map<Guid, VDS> hosts, Line 28: Map<Guid, VM> vms) Line 29: throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, -- To view, visit https://gerrit.ovirt.org/39728 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ied30d4ac4c1eeee2911e5f276d5333982147effa Gerrit-PatchSet: 12 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Sivák <msi...@redhat.com> Gerrit-Reviewer: Gilad Chaplik <gchap...@redhat.com> Gerrit-Reviewer: Martin Betak <mbe...@redhat.com> Gerrit-Reviewer: Roy Golan <rgo...@redhat.com> Gerrit-Reviewer: Tomer Saban <tsa...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches