Search in sources :

Example 6 with Persister

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

the class DefaultPlanGeneratorTest method testCustomPhases.

@Test
public void testCustomPhases() throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("custom-phases.yml").getFile());
    RawServiceSpec rawServiceSpec = RawServiceSpec.newBuilder(file).build();
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(rawServiceSpec, SCHEDULER_CONFIG, file.getParentFile()).build();
    Persister persister = new MemPersister();
    stateStore = new StateStore(persister);
    configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), persister);
    Assert.assertNotNull(serviceSpec);
    DefaultPlanGenerator generator = new DefaultPlanGenerator(configStore, stateStore);
    for (Map.Entry<String, RawPlan> entry : rawServiceSpec.getPlans().entrySet()) {
        Plan plan = generator.generate(entry.getValue(), entry.getKey(), serviceSpec.getPods());
        Assert.assertNotNull(plan);
        Assert.assertEquals(6, plan.getChildren().size());
        Phase serverPhase = plan.getChildren().get(0);
        Phase oncePhase = plan.getChildren().get(1);
        Phase interleavePhase = plan.getChildren().get(2);
        Phase fullCustomPhase = plan.getChildren().get(3);
        Phase partialCustomPhase = plan.getChildren().get(4);
        Phase omitStepPhase = plan.getChildren().get(5);
        validatePhase(serverPhase, Arrays.asList(Arrays.asList("server"), Arrays.asList("server"), Arrays.asList("server")));
        validatePhase(oncePhase, Arrays.asList(Arrays.asList("once"), Arrays.asList("once"), Arrays.asList("once")));
        validatePhase(interleavePhase, Arrays.asList(Arrays.asList("once"), Arrays.asList("server"), Arrays.asList("once"), Arrays.asList("server"), Arrays.asList("once"), Arrays.asList("server")));
        validatePhase(fullCustomPhase, Arrays.asList(Arrays.asList("once"), Arrays.asList("server"), Arrays.asList("server"), Arrays.asList("once"), Arrays.asList("server")));
        validatePhase(partialCustomPhase, Arrays.asList(Arrays.asList("server"), Arrays.asList("once"), Arrays.asList("once"), Arrays.asList("server"), Arrays.asList("server"), Arrays.asList("once")));
        validatePhase(omitStepPhase, Arrays.asList(Arrays.asList("once"), Arrays.asList("server")));
        Assert.assertEquals("hello-1:[once]", omitStepPhase.getChildren().get(0).getName());
        Assert.assertEquals("hello-1:[server]", omitStepPhase.getChildren().get(1).getName());
    }
}
Also used : Phase(com.mesosphere.sdk.scheduler.plan.Phase) MemPersister(com.mesosphere.sdk.storage.MemPersister) RawPlan(com.mesosphere.sdk.specification.yaml.RawPlan) StateStore(com.mesosphere.sdk.state.StateStore) RawPlan(com.mesosphere.sdk.specification.yaml.RawPlan) Plan(com.mesosphere.sdk.scheduler.plan.Plan) RawServiceSpec(com.mesosphere.sdk.specification.yaml.RawServiceSpec) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) File(java.io.File) Map(java.util.Map)

Example 7 with Persister

use of com.mesosphere.sdk.storage.Persister 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 8 with Persister

use of com.mesosphere.sdk.storage.Persister 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 9 with Persister

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

the class DefaultPlanCoordinatorTest method setupTest.

@Before
public void setupTest() throws Exception {
    MockitoAnnotations.initMocks(this);
    serviceSpecification = DefaultServiceSpec.newBuilder().name(SERVICE_NAME).role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).zookeeperConnection("foo.bar.com").pods(Arrays.asList(podA)).build();
    Persister persister = new MemPersister();
    FrameworkStore frameworkStore = new FrameworkStore(persister);
    frameworkStore.storeFrameworkId(TestConstants.FRAMEWORK_ID);
    stateStore = new StateStore(persister);
    stepFactory = new DefaultStepFactory(mock(ConfigStore.class), stateStore);
    phaseFactory = new DefaultPhaseFactory(stepFactory);
    planScheduler = new DefaultPlanScheduler(new OfferAccepter(Arrays.asList()), new OfferEvaluator(frameworkStore, stateStore, new OfferOutcomeTracker(), TestConstants.SERVICE_NAME, UUID.randomUUID(), ArtifactResource.getUrlFactory(TestConstants.SERVICE_NAME), SchedulerConfigTestUtils.getTestSchedulerConfig(), Optional.empty(), true), stateStore);
    serviceSpecificationB = DefaultServiceSpec.newBuilder().name(SERVICE_NAME + "-B").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).zookeeperConnection("foo.bar.com").pods(Arrays.asList(podB)).build();
}
Also used : OfferOutcomeTracker(com.mesosphere.sdk.offer.history.OfferOutcomeTracker) OfferAccepter(com.mesosphere.sdk.offer.OfferAccepter) MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) OfferEvaluator(com.mesosphere.sdk.offer.evaluate.OfferEvaluator) FrameworkStore(com.mesosphere.sdk.state.FrameworkStore) Before(org.junit.Before)

Example 10 with Persister

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

the class DefaultStepFactoryTest method getPodInstanceWithASingleTask.

private PodInstance getPodInstanceWithASingleTask() throws Exception {
    TaskSpec taskSpec0 = TestPodFactory.getTaskSpec(TestConstants.TASK_NAME + 0, TestConstants.RESOURCE_SET_ID);
    PodSpec podSpec = DefaultPodSpec.newBuilder(SCHEDULER_CONFIG.getExecutorURI()).type(TestConstants.POD_TYPE).count(1).tasks(Arrays.asList(taskSpec0)).build();
    ServiceSpec serviceSpec = DefaultServiceSpec.newBuilder().name(TestConstants.SERVICE_NAME).role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).zookeeperConnection("foo.bar.com").pods(Arrays.asList(podSpec)).build();
    Persister persister = new MemPersister();
    stateStore = new StateStore(persister);
    configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), persister);
    UUID configId = configStore.store(serviceSpec);
    configStore.setTargetConfig(configId);
    stepFactory = new DefaultStepFactory(configStore, stateStore);
    return new DefaultPodInstance(podSpec, 0);
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) UUID(java.util.UUID)

Aggregations

Persister (com.mesosphere.sdk.storage.Persister)21 MemPersister (com.mesosphere.sdk.storage.MemPersister)17 StateStore (com.mesosphere.sdk.state.StateStore)10 Test (org.junit.Test)8 FrameworkStore (com.mesosphere.sdk.state.FrameworkStore)6 Plan (com.mesosphere.sdk.scheduler.plan.Plan)4 UUID (java.util.UUID)4 Before (org.junit.Before)4 OfferOutcomeTracker (com.mesosphere.sdk.offer.history.OfferOutcomeTracker)3 OfferAccepter (com.mesosphere.sdk.offer.OfferAccepter)2 OfferEvaluator (com.mesosphere.sdk.offer.evaluate.OfferEvaluator)2 DefaultPlan (com.mesosphere.sdk.scheduler.plan.DefaultPlan)2 Phase (com.mesosphere.sdk.scheduler.plan.Phase)2 RawServiceSpec (com.mesosphere.sdk.specification.yaml.RawServiceSpec)2 PersisterException (com.mesosphere.sdk.storage.PersisterException)2 File (java.io.File)2 ApiServer (com.mesosphere.sdk.framework.ApiServer)1 FrameworkRunner (com.mesosphere.sdk.framework.FrameworkRunner)1 HealthResource (com.mesosphere.sdk.http.endpoints.HealthResource)1 PlansResource (com.mesosphere.sdk.http.endpoints.PlansResource)1