use of org.ovirt.engine.core.common.migration.NoMigrationPolicy in project ovirt-engine by oVirt.
the class ConvergenceConfigProvider method initMigrationPolicies.
void initMigrationPolicies(String policiesStr, Version version) {
List<MigrationPolicy> policies = Collections.emptyList();
try {
policies = parse(policiesStr);
} catch (IOException e) {
log.error("The provided migration policies: '{}' are not valid, ignoring", policiesStr);
}
// init it to an empty map even the parsing failed
Map<Guid, MigrationPolicy> migrationPolicies = policies.stream().collect(toMap(MigrationPolicy::getId, identity()));
// the null object
migrationPolicies.put(NoMigrationPolicy.ID, new NoMigrationPolicy());
migrationPoliciesByVersion.put(version, migrationPolicies);
}
use of org.ovirt.engine.core.common.migration.NoMigrationPolicy in project ovirt-engine by oVirt.
the class ConvergenceConfigProviderTest method jsonInvalidJson.
@Test
public void jsonInvalidJson() throws IOException {
provider.initMigrationPolicies("this is not a valid json", VERSION);
MigrationPolicy policy = provider.getMigrationPolicy(Guid.newGuid(), VERSION);
assertTrue(policy instanceof NoMigrationPolicy);
}
use of org.ovirt.engine.core.common.migration.NoMigrationPolicy 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);
}
Aggregations