Search in sources :

Example 6 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class SchedulerBuilderTest method testDeployPlanOverriddenDuringUpdate.

@Test
public void testDeployPlanOverriddenDuringUpdate() throws Exception {
    Persister persister = new MemPersister();
    SchedulerBuilder builder = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, persister);
    Collection<Plan> plans = builder.selectDeployPlan(getDeployUpdatePlans(), true);
    Assert.assertEquals(1, plans.size());
    Plan deployPlan = plans.stream().filter(plan -> plan.isDeployPlan()).findFirst().get();
    Assert.assertEquals(1, deployPlan.getChildren().size());
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) Plan(com.mesosphere.sdk.scheduler.plan.Plan) DefaultPlan(com.mesosphere.sdk.scheduler.plan.DefaultPlan) Test(org.junit.Test)

Example 7 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class SchedulerBuilderTest method testRegionAwarenessEnabledEnvWithSchedulerRegion.

@Test
public void testRegionAwarenessEnabledEnvWithSchedulerRegion() throws PersisterException {
    when(mockSchedulerConfig.getSchedulerRegion()).thenReturn(Optional.of(TestConstants.REMOTE_REGION));
    when(mockSchedulerConfig.isRegionAwarenessEnabled()).thenReturn(true);
    ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, new MemPersister()).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);
    verify(mockSchedulerConfig).isRegionAwarenessEnabled();
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Example 8 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class SchedulerBuilderTest method testRegionAwarenessEnabledWithoutSchedulerRegion.

@Test
public void testRegionAwarenessEnabledWithoutSchedulerRegion() throws PersisterException {
    ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, new MemPersister()).withSingleRegionConstraint().build().getServiceSpec();
    Optional<PlacementRule> rule = updatedServiceSpec.getPods().get(0).getPlacementRule();
    // Pod updated with local region rule:
    Assert.assertTrue(rule.isPresent());
    Assert.assertTrue(rule.get() instanceof IsLocalRegionRule);
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Example 9 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class SchedulerBuilderTest method testDeployPlanPreservedDuringInstall.

@Test
public void testDeployPlanPreservedDuringInstall() throws Exception {
    Persister persister = new MemPersister();
    SchedulerBuilder builder = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, persister);
    Collection<Plan> plans = builder.selectDeployPlan(getDeployUpdatePlans(), false);
    Assert.assertEquals(2, plans.size());
    Plan deployPlan = plans.stream().filter(plan -> plan.isDeployPlan()).findFirst().get();
    Assert.assertEquals(2, deployPlan.getChildren().size());
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) Plan(com.mesosphere.sdk.scheduler.plan.Plan) DefaultPlan(com.mesosphere.sdk.scheduler.plan.DefaultPlan) Test(org.junit.Test)

Example 10 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister in project dcos-commons by mesosphere.

the class DefaultSchedulerTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    Driver.setDriver(mockSchedulerDriver);
    when(mockSchedulerConfig.isStateCacheEnabled()).thenReturn(true);
    ServiceSpec serviceSpec = getServiceSpec(podA, podB);
    persister = new MemPersister();
    stateStore = new StateStore(persister);
    configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), persister);
    Capabilities.overrideCapabilities(getCapabilitiesWithDefaultGpuSupport());
    defaultScheduler = getScheduler(serviceSpec);
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) Before(org.junit.Before)

Aggregations

MemPersister (com.mesosphere.sdk.storage.MemPersister)31 Persister (com.mesosphere.sdk.storage.Persister)14 Test (org.junit.Test)13 StateStore (com.mesosphere.sdk.state.StateStore)12 Before (org.junit.Before)9 DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)7 ServiceSpec (com.mesosphere.sdk.specification.ServiceSpec)7 FrameworkStore (com.mesosphere.sdk.state.FrameworkStore)5 UUID (java.util.UUID)5 File (java.io.File)4 OfferOutcomeTracker (com.mesosphere.sdk.offer.history.OfferOutcomeTracker)3 Plan (com.mesosphere.sdk.scheduler.plan.Plan)3 RawServiceSpec (com.mesosphere.sdk.specification.yaml.RawServiceSpec)3 OfferAccepter (com.mesosphere.sdk.offer.OfferAccepter)2 OfferEvaluator (com.mesosphere.sdk.offer.evaluate.OfferEvaluator)2 DefaultPlan (com.mesosphere.sdk.scheduler.plan.DefaultPlan)2 ConfigStore (com.mesosphere.sdk.state.ConfigStore)2 StringConfiguration (com.mesosphere.sdk.config.StringConfiguration)1 Capabilities (com.mesosphere.sdk.dcos.Capabilities)1 TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)1