use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class IssuesTest method testIssue176.
/**
* Boot plenty of VMs.
*/
@Test
public void testIssue176() {
Model mo = new DefaultModel();
ShareableResource slots = new ShareableResource("slots");
for (int i = 0; i < 4; i++) {
final Node no = mo.newNode();
mo.getMapping().on(no);
slots.setCapacity(no, 100);
for (int j = 0; j < 5; j++) {
mo.getMapping().addRunningVM(mo.newVM(), no);
}
}
// 95 VMs * nbNodes can be hosted.
for (int i = 0; i < 95 * mo.getMapping().getNbNodes(); i++) {
mo.getMapping().addReadyVM(mo.newVM());
}
final List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Running.newRunning(mo.getMapping().getReadyVMs()));
final Instance ii = new Instance(mo, cstrs, new MinMigrations());
ChocoScheduler sched = new DefaultChocoScheduler();
Assert.assertNotNull(sched.solve(ii));
}
use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class CMinMigrationsTest method testNtnx.
@Test
public void testNtnx() {
String root = "src/test/resources/min-migrations.json";
Instance i = JSON.readInstance(new File(root));
i = new Instance(i.getModel(), i.getSatConstraints(), new MinMigrations());
ChocoScheduler s = new DefaultChocoScheduler();
s.doOptimize(true);
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
System.out.println(s.getStatistics());
System.out.println(p);
Assert.assertEquals(p.getActions().stream().filter(x -> x instanceof MigrateVM).count(), 1);
Assert.assertEquals(3, p.getDuration());
}
use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class SchedulerTest method testDefaultMethods.
@Test
public void testDefaultMethods() {
final ReconfigurationPlan expected = new DefaultReconfigurationPlan(new DefaultModel());
final Scheduler sched = i -> expected;
final List<SatConstraint> cstrs = new ArrayList<>();
final MinMigrations obj = new MinMigrations();
Assert.assertEquals(expected, sched.solve(expected.getOrigin(), cstrs, obj));
Assert.assertEquals(expected, sched.solve(expected.getOrigin(), cstrs));
}
Aggregations