use of org.ovirt.engine.core.common.migration.ConvergenceItem in project ovirt-engine by oVirt.
the class ConvergenceConfigProviderTest method jsonProperlyFilled.
@Test
public void jsonProperlyFilled() throws IOException {
Guid id = Guid.newGuid();
List<MigrationPolicy> policies = new ArrayList<>();
ConvergenceConfig config = new ConvergenceConfig();
config.setInitialItems(Collections.singletonList(new ConvergenceItem("setDowntime2", 1)));
config.setLastItems(Collections.singletonList(new ConvergenceItem("setDowntime3", 15)));
config.setConvergenceItems(Collections.singletonList(new ConvergenceItemWithStallingLimit(1, "someAction", 12)));
MigrationPolicy policy = new MigrationPolicy(id, "some name", "some long description", config);
policies.add(policy);
String json = JsonHelper.objectToJson(policies, false);
provider.initMigrationPolicies(json, VERSION);
// just basic sanity check
assertEquals(policy.getName(), provider.getMigrationPolicy(id, VERSION).getName());
assertEquals(policy.getDescription(), provider.getMigrationPolicy(id, VERSION).getDescription());
assertTrue(provider.getMigrationPolicy(id, new Version()) instanceof NoMigrationPolicy);
}
use of org.ovirt.engine.core.common.migration.ConvergenceItem in project ovirt-engine by oVirt.
the class ConvergenceScheduleTest method asMapOneInit.
@Test
public void asMapOneInit() throws IOException {
schedule.addInitStep(new ConvergenceItem("action", 10));
assertEquals(new ExpectedConvergence().addInit("action", 10), schedule.asMap());
}
use of org.ovirt.engine.core.common.migration.ConvergenceItem in project ovirt-engine by oVirt.
the class ConvergenceScheduleTest method asMapTwoInits.
@Test
public void asMapTwoInits() throws IOException {
schedule.addInitStep(new ConvergenceItem("action", 10)).addInitStep(new ConvergenceItem("action2", 15));
assertEquals(new ExpectedConvergence().addInit("action", 10).addInit("action2", 15), schedule.asMap());
}
use of org.ovirt.engine.core.common.migration.ConvergenceItem in project ovirt-engine by oVirt.
the class ConvergenceScheduleTest method asMapBoth.
@Test
public void asMapBoth() throws IOException {
schedule.addInitStep(new ConvergenceItem("action", 10)).addInitStep(new ConvergenceItem("action2", 15)).addStallingStep(new ConvergenceItemWithStallingLimit(8, "action", 10)).addStallingStep(new ConvergenceItemWithStallingLimit(12, "action2", 12));
Map<String, Object> expected = new ExpectedConvergence().addInit("action", 10).addInit("action2", 15).addStalling(8, "action", 10).addStalling(12, "action2", 12);
assertEquals(expected, schedule.asMap());
}
use of org.ovirt.engine.core.common.migration.ConvergenceItem in project ovirt-engine by oVirt.
the class MigrationPoliciesValueHelper method getExamplePolicy.
String getExamplePolicy() {
ConvergenceConfig config = new ConvergenceConfig();
config.setInitialItems(Arrays.asList(new ConvergenceItem("setDowntime", 100)));
config.setConvergenceItems(Arrays.asList(new ConvergenceItemWithStallingLimit(1, "setDowntime", 200)));
config.setLastItems(Arrays.asList(new ConvergenceItem("abort")));
List<MigrationPolicy> policies = Arrays.asList(new MigrationPolicy(Guid.Empty, "name of the policy", "description", config));
try {
return JsonHelper.objectToJson(policies, false);
} catch (IOException e) {
// if this fails, than we really want to fail it with an exception
throw new RuntimeException(e);
}
}
Aggregations