Search in sources :

Example 16 with Persister

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

the class CuratorUtilsTest method testInitServicePathExistingService.

@Test
public void testInitServicePathExistingService() throws Exception {
    String originalServiceName = "/folder/path/to/myservice";
    Persister persister = new CuratorPersister(originalServiceName, mockClient);
    Mockito.when(mockClient.getData()).thenReturn(mockGetDataBuilder);
    Mockito.when(mockGetDataBuilder.forPath(Mockito.anyString())).thenReturn(originalServiceName.getBytes(StandardCharsets.UTF_8));
    CuratorUtils.initServiceName(persister, originalServiceName);
    Mockito.verify(mockGetDataBuilder).forPath(Mockito.eq("/dcos-service-folder__path__to__myservice/servicename"));
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) Test(org.junit.Test)

Example 17 with Persister

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

the class CuratorUtilsTest method testServiceNameCollision.

@Test
public void testServiceNameCollision() {
    Persister persister = new MemPersister();
    CuratorUtils.initServiceName(persister, "/path/to/myservice");
    try {
        CuratorUtils.initServiceName(persister, "/path/to__myservice");
        fail("expected exception");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Collision"));
    }
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) Test(org.junit.Test)

Example 18 with Persister

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

the class OfferEvaluatorTestBase method beforeEach.

@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    Persister persister = new MemPersister();
    frameworkStore = new FrameworkStore(persister);
    frameworkStore.storeFrameworkId(Protos.FrameworkID.newBuilder().setValue("framework-id").build());
    stateStore = new StateStore(persister);
    targetConfig = UUID.randomUUID();
    evaluator = new OfferEvaluator(frameworkStore, stateStore, new OfferOutcomeTracker(), TestConstants.SERVICE_NAME, targetConfig, ArtifactResource.getUrlFactory(TestConstants.SERVICE_NAME), SCHEDULER_CONFIG, Optional.empty(), true);
}
Also used : OfferOutcomeTracker(com.mesosphere.sdk.offer.history.OfferOutcomeTracker) MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) FrameworkStore(com.mesosphere.sdk.state.FrameworkStore) Before(org.junit.Before)

Example 19 with Persister

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

the class UninstallSchedulerTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    Persister persister = new MemPersister();
    frameworkStore = new FrameworkStore(persister);
    frameworkStore.storeFrameworkId(TestConstants.FRAMEWORK_ID);
    stateStore = new StateStore(persister);
    stateStore.storeTasks(Collections.singletonList(TASK_A));
    // Have the mock plan customizer default to returning the plan unchanged.
    when(mockPlanCustomizer.updateUninstallPlan(any())).thenAnswer(invocation -> invocation.getArguments()[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) FrameworkStore(com.mesosphere.sdk.state.FrameworkStore) Before(org.junit.Before)

Example 20 with Persister

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

the class DefaultStepFactoryTest method getPodInstanceWithSameDnsPrefixes.

private PodInstance getPodInstanceWithSameDnsPrefixes() throws Exception {
    TaskSpec taskSpec0 = TestPodFactory.getTaskSpec(TestConstants.TASK_NAME + 0, TestConstants.RESOURCE_SET_ID + 0, TestConstants.TASK_DNS_PREFIX);
    TaskSpec taskSpec1 = TestPodFactory.getTaskSpec(TestConstants.TASK_NAME + 1, TestConstants.RESOURCE_SET_ID + 1, TestConstants.TASK_DNS_PREFIX);
    PodSpec podSpec = DefaultPodSpec.newBuilder(SCHEDULER_CONFIG.getExecutorURI()).type(TestConstants.POD_TYPE).count(1).tasks(Arrays.asList(taskSpec0, taskSpec1)).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