use of org.btrplace.model.Model in project scheduler by btrplace.
the class RunningTest method testEquals.
@Test
public void testEquals() {
Model mo = new DefaultModel();
VM vm = mo.newVM();
Running s = new Running(vm);
Assert.assertTrue(s.equals(s));
Assert.assertTrue(new Running(vm).equals(s));
Assert.assertEquals(new Running(vm).hashCode(), s.hashCode());
Assert.assertFalse(new Running(mo.newVM()).equals(s));
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class RunningTest method testInstantiation.
@Test
public void testInstantiation() {
Model mo = new DefaultModel();
VM vm = mo.newVM();
Running s = new Running(vm);
Assert.assertNotNull(s.getChecker());
Assert.assertEquals(Collections.singletonList(vm), s.getInvolvedVMs());
Assert.assertTrue(s.getInvolvedNodes().isEmpty());
Assert.assertNotNull(s.toString());
Assert.assertTrue(s.setContinuous(false));
System.out.println(s);
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class SpreadTest method testEquals.
@Test
public void testEquals() {
Model mo = new DefaultModel();
Set<VM> x = new HashSet<>(Arrays.asList(mo.newVM(), mo.newVM()));
Spread s = new Spread(x);
Assert.assertTrue(s.equals(s));
Assert.assertTrue(new Spread(x).equals(s));
Assert.assertEquals(s.hashCode(), new Spread(x).hashCode());
Assert.assertNotEquals(s.hashCode(), new Spread(new HashSet<>()).hashCode());
x = new HashSet<>(Collections.singletonList(mo.newVM()));
Assert.assertFalse(new Spread(x).equals(s));
Assert.assertFalse(new Spread(x, false).equals(new Spread(x, true)));
Assert.assertNotSame(new Spread(x, false).hashCode(), new Spread(x, true).hashCode());
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class SpreadTest method testInstantiation.
@Test
public void testInstantiation() {
Model mo = new DefaultModel();
Set<VM> x = new HashSet<>(Arrays.asList(mo.newVM(), mo.newVM()));
Spread s = new Spread(x);
Assert.assertNotNull(s.getChecker());
Assert.assertEquals(x, s.getInvolvedVMs());
Assert.assertTrue(s.getInvolvedNodes().isEmpty());
Assert.assertTrue(s.isContinuous());
Assert.assertNotNull(s.toString());
Assert.assertTrue(s.setContinuous(false));
Assert.assertFalse(s.isContinuous());
System.out.println(s);
s = new Spread(x, false);
Assert.assertFalse(s.isContinuous());
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class VMConsumptionComparatorTest method testSimpleResource.
@Test
public void testSimpleResource() {
ShareableResource rc = new ShareableResource("foo");
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 10);
Random rnd = new Random();
for (VM id : vms) {
rc.setConsumption(id, rnd.nextInt(5));
}
VMConsumptionComparator c1 = new VMConsumptionComparator(rc, true);
vms.sort(c1);
for (int i = 0; i < vms.size() - 1; i++) {
Assert.assertTrue(rc.getConsumption(vms.get(i)) - rc.getConsumption(vms.get(i + 1)) <= 0);
}
// Descending order
c1 = new VMConsumptionComparator(rc, false);
vms.sort(c1);
for (int i = 0; i < vms.size() - 1; i++) {
Assert.assertTrue(rc.getConsumption(vms.get(i)) - rc.getConsumption(vms.get(i + 1)) >= 0);
}
}
Aggregations