Search in sources :

Example 16 with DefaultModel

use of org.btrplace.model.DefaultModel in project scheduler by btrplace.

the class NamingServiceTest method testResolution.

@Test(dependsOnMethods = { "testRegisterAndGets" })
public void testResolution() {
    NamingService<VM> ns = NamingService.newVMNS();
    Assert.assertEquals(ns.getElementIdentifier(), VM.TYPE);
    Model mo = new DefaultModel();
    VM v = mo.newVM();
    ns.register(v, "vm0");
    Assert.assertEquals(ns.resolve(v), "vm0");
    Assert.assertEquals(ns.resolve("vm0"), v);
    Assert.assertNull(ns.resolve("vm1"));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 17 with DefaultModel

use of org.btrplace.model.DefaultModel in project scheduler by btrplace.

the class NamingServiceTest method testSubstitution.

@Test(dependsOnMethods = { "testRegisterAndGets" })
public void testSubstitution() {
    NamingService<VM> ns = NamingService.newVMNS();
    Model mo = new DefaultModel();
    VM v = mo.newVM();
    ns.register(v, "vm0");
    VM v2 = mo.newVM();
    ns.substituteVM(v, v2);
    Assert.assertNull(ns.resolve(v));
    Assert.assertEquals(ns.resolve(v2), "vm0");
    Assert.assertEquals(ns.resolve("vm0"), v2);
    NamingService<Node> ns2 = NamingService.newNodeNS();
    ns2.register(mo.newNode(), "n0");
    Assert.assertTrue(ns2.substituteVM(mo.newVM(), mo.newVM()));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 18 with DefaultModel

use of org.btrplace.model.DefaultModel in project scheduler by btrplace.

the class NamingServiceTest method testClone.

@Test(dependsOnMethods = { "testRegisterAndGets", "testResolution" })
public void testClone() {
    NamingService<Node> ns = NamingService.newNodeNS();
    Model mo = new DefaultModel();
    Node n = mo.newNode();
    NamingService<Node> ns2 = ns.copy();
    Assert.assertTrue(ns2.register(n, "n0"));
    Assert.assertNull(ns.resolve(n));
    Assert.assertNull(ns.resolve("n0"));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 19 with DefaultModel

use of org.btrplace.model.DefaultModel in project scheduler by btrplace.

the class NamingServiceTest method testRegisterAndGets.

@Test
public void testRegisterAndGets() {
    NamingService<Node> ns = NamingService.newNodeNS();
    Model mo = new DefaultModel();
    Node n = mo.newNode();
    Assert.assertTrue(ns.register(n, "n0"));
    Assert.assertFalse(ns.register(mo.newNode(), "n0"));
    Assert.assertEquals(ns.getElementIdentifier(), Node.TYPE);
    Assert.assertEquals(ns.getNamedElements().size(), 1);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 20 with DefaultModel

use of org.btrplace.model.DefaultModel in project scheduler by btrplace.

the class NamingServiceTest method testGetViews.

@Test
public void testGetViews() {
    Model mo = new DefaultModel();
    Assert.assertNull(NamingService.getVMNames(mo));
    Assert.assertNull(NamingService.getNodeNames(mo));
    NamingService<VM> vmNs = NamingService.newVMNS();
    NamingService<Node> nodeNs = NamingService.newNodeNS();
    mo.attach(vmNs);
    mo.attach(nodeNs);
    Assert.assertEquals(NamingService.getNodeNames(mo), nodeNs);
    Assert.assertEquals(NamingService.getVMNames(mo), vmNs);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

DefaultModel (org.btrplace.model.DefaultModel)201 Test (org.testng.annotations.Test)177 Model (org.btrplace.model.Model)157 Node (org.btrplace.model.Node)91 VM (org.btrplace.model.VM)91 HashSet (java.util.HashSet)48 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)40 Mapping (org.btrplace.model.Mapping)39 ArrayList (java.util.ArrayList)26 ShareableResource (org.btrplace.model.view.ShareableResource)24 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)22 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)18 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)17 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)17 MigrateVM (org.btrplace.plan.event.MigrateVM)16 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)16 BootVM (org.btrplace.scheduler.choco.transition.BootVM)16 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)16 KillVM (org.btrplace.scheduler.choco.transition.KillVM)16