use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class ScriptTest method testExported.
public void testExported() {
Script v = new Script();
v.setFullyQualifiedName("testScript");
Model mo = new DefaultModel();
BtrpOperand o1 = new BtrpElement(BtrpOperand.Type.VM, "vm1", mo.newVM());
v.addExportable("$s", o1, Collections.singleton("*"));
// No restrictions, so every can access the exported variable
Assert.assertEquals(v.getImportable("$s"), o1);
Assert.assertTrue(v.canImport("$s", "foo"));
Assert.assertTrue(v.canImport("$s", "bar.toto"));
// Explicit no restriction
BtrpOperand o2 = new BtrpElement(BtrpOperand.Type.VM, "vm2", mo.newVM());
v.addExportable("$x", o2, Collections.singleton("*"));
Assert.assertEquals(v.getImportable("$x"), o2);
Assert.assertTrue(v.canImport("$x", "foo"));
Assert.assertTrue(v.canImport("$x", "bar.toto"));
// Unknown export
Assert.assertFalse(v.canImport("$z", "foo"));
Assert.assertFalse(v.canImport("$z", "bar.toto"));
Set<String> valid = new HashSet<>();
valid.add("foo");
valid.add("foo.*");
valid.add("bar");
BtrpOperand o3 = new BtrpElement(BtrpOperand.Type.VM, "vm2", mo.newVM());
v.addExportable("$y", o3, valid);
Assert.assertNull(v.getImportable("$y"));
Assert.assertEquals(v.getImportable("$y", "foo"), o3);
Assert.assertNull(v.getImportable("$y", "zog"));
Assert.assertEquals(v.getImportable("$y", "foo.bar.fii"), o3);
Assert.assertEquals(v.getImportable("$y", "bar"), o3);
Assert.assertEquals(v.getExported().size(), 3);
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class AmongBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodAmongs")
public void testGoodSignatures(String str, int nbVMs, int nbNs1, int nbNs2, boolean c) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n@N[1..10] : defaultNode;\n" + str).getConstraints();
Assert.assertEquals(cstrs.size(), 1);
Among x = (Among) cstrs.iterator().next();
Assert.assertEquals(x.getGroupsOfNodes().iterator().next().size(), nbNs1);
Assert.assertEquals(x.getInvolvedNodes().size(), nbNs1 + nbNs2);
Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
Assert.assertEquals(x.isContinuous(), c);
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class BanBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodBans")
public void testGoodSignatures(String str, int nbVMs, int nbNodes, boolean c) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n@N[1..10] : defaultNode;\n" + str).getConstraints();
Assert.assertEquals(cstrs.size(), nbVMs);
Set<VM> vms = new HashSet<>();
for (SatConstraint s : cstrs) {
Assert.assertTrue(s instanceof Ban);
Assert.assertEquals(s.getInvolvedVMs().size(), 1);
Assert.assertTrue(vms.addAll(s.getInvolvedVMs()));
Assert.assertEquals(s.getInvolvedNodes().size(), nbNodes);
Assert.assertEquals(s.isContinuous(), c);
}
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class FenceBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodFences")
public void testGoodSignatures(String str, int nbVMs, int nbNodes, boolean c) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n @N[1..20] : defaultNode;\n" + str).getConstraints();
Assert.assertEquals(cstrs.size(), nbVMs);
Set<VM> vms = new HashSet<>();
for (SatConstraint x : cstrs) {
Assert.assertTrue(x instanceof Fence);
Assert.assertEquals(x.getInvolvedNodes().size(), nbNodes);
Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
Assert.assertEquals(x.isContinuous(), c);
}
}
use of org.btrplace.model.DefaultModel in project scheduler by btrplace.
the class GatherBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodGathers")
public void testGoodSignatures(String str, int nbVMs, boolean c) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Gather x = (Gather) b.build("namespace test; VM[1..10] : tiny;\n" + str).getConstraints().iterator().next();
Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
Assert.assertEquals(x.isContinuous(), c);
}
Aggregations