use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.
the class SchedulerBuilderTest method testExistingRegionRuleUnmodified.
@Test
public void testExistingRegionRuleUnmodified() throws PersisterException {
PlacementRule remoteRegionRule = RegionRuleFactory.getInstance().require(ExactMatcher.create(TestConstants.REMOTE_REGION));
PlacementRule localRegionRule = new IsLocalRegionRule();
ServiceSpec serviceSpec = DefaultServiceSpec.newBuilder(minimalServiceSpec).addPod(DefaultPodSpec.newBuilder(getPodSpec("foo")).placementRule(remoteRegionRule).build()).addPod(DefaultPodSpec.newBuilder(getPodSpec("bar")).placementRule(localRegionRule).build()).build();
ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(serviceSpec, mockSchedulerConfig, new MemPersister()).withSingleRegionConstraint().build().getServiceSpec();
// Pod without placement rules from valid-minimal.yml had a rule added:
Assert.assertTrue(updatedServiceSpec.getPods().get(0).getPlacementRule().get() instanceof IsLocalRegionRule);
// Pods with region placement rules were left as-is:
Assert.assertSame(remoteRegionRule, updatedServiceSpec.getPods().get(1).getPlacementRule().get());
Assert.assertSame(localRegionRule, updatedServiceSpec.getPods().get(2).getPlacementRule().get());
}
use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.
the class SchedulerBuilderTest method testRegionAwarenessEnabledJavaWithSchedulerRegion.
@Test
public void testRegionAwarenessEnabledJavaWithSchedulerRegion() throws PersisterException {
when(mockSchedulerConfig.getSchedulerRegion()).thenReturn(Optional.of(TestConstants.REMOTE_REGION));
ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, new MemPersister()).withSingleRegionConstraint().build().getServiceSpec();
Optional<PlacementRule> rule = updatedServiceSpec.getPods().get(0).getPlacementRule();
// Pod updated with exact region rule:
Assert.assertTrue(rule.isPresent());
Assert.assertTrue(rule.get() instanceof RegionRule);
// Not hit since enabled directly in java:
verify(mockSchedulerConfig, never()).isRegionAwarenessEnabled();
}
use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.
the class SchedulerRunnerTest method checkSchemaVersion.
@Test
public void checkSchemaVersion() throws Exception {
// Set up a schema version which shouldn't work, to verify that the schema version is being checked:
Persister persister = new MemPersister();
persister.set("SchemaVersion", "123".getBytes(StandardCharsets.UTF_8));
when(mockSchedulerBuilder.getPersister()).thenReturn(persister);
when(mockSchedulerBuilder.getSchedulerConfig()).thenReturn(mockSchedulerConfig);
when(mockSchedulerBuilder.getServiceSpec()).thenReturn(mockServiceSpec);
SchedulerRunner runner = SchedulerRunner.fromSchedulerBuilder(mockSchedulerBuilder);
try {
runner.run();
Assert.fail("Expected exception due to bad schema version");
} catch (IllegalStateException e) {
Assert.assertEquals("Storage schema version 123 is not supported by this software (expected: 1)", e.getMessage());
}
}
use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.
the class SchemaVersionStoreTest method beforeEach.
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
persister = new MemPersister();
store = new SchemaVersionStore(persister);
store2 = new SchemaVersionStore(persister);
storeWithMock = new SchemaVersionStore(mockPersister);
}
use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.
the class StateStoreUtilsTest method beforeEach.
@Before
public void beforeEach() throws Exception {
this.persister = new MemPersister();
this.stateStore = new StateStore(this.persister);
}
Aggregations