Search in sources :

Example 1 with ConvergenceItem

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);
}
Also used : NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) ConvergenceConfig(org.ovirt.engine.core.common.migration.ConvergenceConfig) Version(org.ovirt.engine.core.compat.Version) ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) ArrayList(java.util.ArrayList) ConvergenceItemWithStallingLimit(org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit) Guid(org.ovirt.engine.core.compat.Guid) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) Test(org.junit.Test)

Example 2 with ConvergenceItem

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());
}
Also used : ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) Test(org.junit.Test)

Example 3 with ConvergenceItem

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());
}
Also used : ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) Test(org.junit.Test)

Example 4 with ConvergenceItem

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());
}
Also used : ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) ConvergenceItemWithStallingLimit(org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit) Test(org.junit.Test)

Example 5 with ConvergenceItem

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);
    }
}
Also used : ConvergenceConfig(org.ovirt.engine.core.common.migration.ConvergenceConfig) ConvergenceItem(org.ovirt.engine.core.common.migration.ConvergenceItem) ConvergenceItemWithStallingLimit(org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit) IOException(java.io.IOException) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Aggregations

ConvergenceItem (org.ovirt.engine.core.common.migration.ConvergenceItem)5 Test (org.junit.Test)4 ConvergenceItemWithStallingLimit (org.ovirt.engine.core.common.migration.ConvergenceItemWithStallingLimit)3 ConvergenceConfig (org.ovirt.engine.core.common.migration.ConvergenceConfig)2 MigrationPolicy (org.ovirt.engine.core.common.migration.MigrationPolicy)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 NoMigrationPolicy (org.ovirt.engine.core.common.migration.NoMigrationPolicy)1 Guid (org.ovirt.engine.core.compat.Guid)1 Version (org.ovirt.engine.core.compat.Version)1