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());
}
}
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());
}
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());
}
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();
}
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);
}
Aggregations