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