use of org.btrplace.scheduler.runner.disjoint.FixedSizePartitioning in project scheduler by btrplace.
the class MaxOnlineSplitterTest method testSplit.
@Test
public void testSplit() throws SchedulerException {
MaxOnlineSplitter splitter = new MaxOnlineSplitter();
Model mo = new DefaultModel();
Node[] ns = new Node[10];
for (int i = 0; i < ns.length; i++) {
Node n = mo.newNode();
mo.getMapping().addOnlineNode(n);
ns[i] = n;
}
FixedNodeSetsPartitioning cut = new FixedSizePartitioning(5);
Instance origin = new Instance(mo, Collections.emptyList(), new MinMTTR());
List<Instance> instances = cut.split(new DefaultParameters(), origin);
TIntIntHashMap vmIndex = Instances.makeVMIndex(instances);
TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
MaxOnline m1 = new MaxOnline(new HashSet<>(Arrays.asList(ns[0], ns[1], ns[2], ns[3], ns[4])), 3);
// This one is valid as m1 stay in the first partition
Assert.assertTrue(splitter.split(m1, origin, instances, vmIndex, nodeIndex));
boolean found = false;
for (Instance i : instances) {
if (i.getSatConstraints().contains(m1)) {
if (found) {
Assert.fail(m1 + " is already in a partition");
}
found = true;
}
}
// Invalid, the constraint is over 2 partitions
MaxOnline m2 = new MaxOnline(new HashSet<>(Arrays.asList(ns[0], ns[1], ns[5])), 3);
Assert.assertFalse(splitter.split(m2, origin, instances, vmIndex, nodeIndex));
}
Aggregations