Last active
December 17, 2015 10:59
-
-
Save tudang/5598942 to your computer and use it in GitHub Desktop.
This test includes: Among, Spread, and SingleRunningCapacity and it should have a solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void amongTest1() { | |
Mapping map = new MappingBuilder().on(n1, n2, n3) | |
.run(n1, vm1, vm2) | |
.run(n2, vm3) | |
.run(n3, vm4).build(); | |
Model model = new DefaultModel(map); | |
Set<UUID> vms = new HashSet<UUID>(Arrays.asList(vm1, vm2, vm4)); | |
Set<UUID> vms2 = new HashSet<UUID>(Arrays.asList(vm3, vm4)); | |
Set<UUID> ns1 = new HashSet<UUID>(Arrays.asList(n1, n2)); | |
Set<UUID> ns2 = new HashSet<UUID>(Arrays.asList(n3)); | |
Set<Set<UUID>> nodeSets = new HashSet<Set<UUID>>(); | |
nodeSets.add(ns1); | |
nodeSets.add(ns2); | |
log.info(model.toString()); | |
Among among = new Among(vms, nodeSets); | |
Collection<SatConstraint> ctrs = new HashSet<SatConstraint>(); | |
ctrs.add(among); | |
ctrs.add(new Spread(vms2)); | |
// Change below line from CumulatedRunningCapacity to SingleRunningCapacity | |
ctrs.add(new SingleRunningCapacity(map.getAllNodes(), 2)); | |
ChocoReconfigurationAlgorithm cra = new DefaultChocoReconfigurationAlgorithm(); | |
try { | |
ReconfigurationPlan plan = cra.solve(model, ctrs); | |
Assert.assertNotNull(plan); | |
if (among.isSatisfied(plan)) { | |
log.info(model.getMapping().toString()); | |
log.info(among.toString()); | |
log.info(plan.toString()); | |
} | |
} catch (SolverException e) { | |
log.error(e.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment