Search in sources :

Example 21 with MemPersister

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

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

the class DefaultServiceSpecTest method validateServiceSpec.

private void validateServiceSpec(String fileName, Boolean supportGpu) throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource(fileName).getFile());
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).build();
    capabilities = mock(Capabilities.class);
    when(capabilities.supportsGpuResource()).thenReturn(supportGpu);
    when(capabilities.supportsCNINetworking()).thenReturn(true);
    when(capabilities.supportsDomains()).thenReturn(true);
    Capabilities.overrideCapabilities(capabilities);
    DefaultScheduler.newBuilder(serviceSpec, SCHEDULER_CONFIG, new MemPersister()).build();
}
Also used : MemPersister(com.mesosphere.sdk.storage.MemPersister) Capabilities(com.mesosphere.sdk.dcos.Capabilities) File(java.io.File)

Example 23 with MemPersister

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

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

the class CassandraRecoveryPlanOverriderTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    stateStore = new StateStore(new MemPersister());
    ConfigStore<ServiceSpec> configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), new MemPersister());
    UUID targetConfig = configStore.store(serviceSpec);
    configStore.setTargetConfig(targetConfig);
    planOverrider = new CassandraRecoveryPlanOverrider(stateStore, getReplacePlan(configStore));
}
Also used : ConfigStore(com.mesosphere.sdk.state.ConfigStore) MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) RawServiceSpec(com.mesosphere.sdk.specification.yaml.RawServiceSpec) UUID(java.util.UUID) Before(org.junit.Before)

Example 25 with MemPersister

use of com.mesosphere.sdk.storage.MemPersister 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

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