Search in sources :

Example 1 with OfferEvaluator

use of com.mesosphere.sdk.offer.evaluate.OfferEvaluator 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 2 with OfferEvaluator

use of com.mesosphere.sdk.offer.evaluate.OfferEvaluator in project dcos-commons by mesosphere.

the class DefaultRecoveryPlanManagerTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    failureMonitor = spy(new TestingFailureMonitor());
    launchConstrainer = spy(new TestingLaunchConstrainer());
    offerAccepter = mock(OfferAccepter.class);
    Persister persister = new MemPersister();
    frameworkStore = new FrameworkStore(persister);
    stateStore = new StateStore(persister);
    File recoverySpecFile = new File(getClass().getClassLoader().getResource("recovery-plan-manager-test.yml").getPath());
    serviceSpec = DefaultServiceSpec.newGenerator(recoverySpecFile, SCHEDULER_CONFIG).build();
    configStore = new ConfigStore<>(DefaultServiceSpec.getConfigurationFactory(serviceSpec), persister);
    UUID configTarget = configStore.store(serviceSpec);
    configStore.setTargetConfig(configTarget);
    taskInfo = TaskInfo.newBuilder(taskInfo).setLabels(new TaskLabelWriter(taskInfo).setTargetConfiguration(configTarget).setIndex(0).toProto()).setName("test-task-type-0-test-task-name").setTaskId(CommonIdUtils.toTaskId(TestConstants.SERVICE_NAME, "test-task-type-0-test-task-name")).build();
    taskInfos = Collections.singletonList(taskInfo);
    recoveryManager = spy(new DefaultRecoveryPlanManager(stateStore, configStore, new HashSet<>(Arrays.asList(taskInfo.getName())), launchConstrainer, failureMonitor));
    mockDeployManager = mock(PlanManager.class);
    final Plan mockDeployPlan = mock(Plan.class);
    when(mockDeployManager.getPlan()).thenReturn(mockDeployPlan);
    planScheduler = new DefaultPlanScheduler(offerAccepter, new OfferEvaluator(frameworkStore, stateStore, new OfferOutcomeTracker(), serviceSpec.getName(), configTarget, ArtifactResource.getUrlFactory(TestConstants.SERVICE_NAME), SchedulerConfigTestUtils.getTestSchedulerConfig(), Optional.empty(), true), stateStore);
    planCoordinator = new DefaultPlanCoordinator(Arrays.asList(mockDeployManager, recoveryManager));
}
Also used : TestingLaunchConstrainer(com.mesosphere.sdk.scheduler.recovery.constrain.TestingLaunchConstrainer) OfferAccepter(com.mesosphere.sdk.offer.OfferAccepter) MemPersister(com.mesosphere.sdk.storage.MemPersister) StateStore(com.mesosphere.sdk.state.StateStore) OfferEvaluator(com.mesosphere.sdk.offer.evaluate.OfferEvaluator) OfferOutcomeTracker(com.mesosphere.sdk.offer.history.OfferOutcomeTracker) TaskLabelWriter(com.mesosphere.sdk.offer.taskdata.TaskLabelWriter) MemPersister(com.mesosphere.sdk.storage.MemPersister) Persister(com.mesosphere.sdk.storage.Persister) TestingFailureMonitor(com.mesosphere.sdk.scheduler.recovery.monitor.TestingFailureMonitor) FrameworkStore(com.mesosphere.sdk.state.FrameworkStore) File(java.io.File) Before(org.junit.Before)

Aggregations

OfferAccepter (com.mesosphere.sdk.offer.OfferAccepter)2 OfferEvaluator (com.mesosphere.sdk.offer.evaluate.OfferEvaluator)2 OfferOutcomeTracker (com.mesosphere.sdk.offer.history.OfferOutcomeTracker)2 FrameworkStore (com.mesosphere.sdk.state.FrameworkStore)2 StateStore (com.mesosphere.sdk.state.StateStore)2 MemPersister (com.mesosphere.sdk.storage.MemPersister)2 Persister (com.mesosphere.sdk.storage.Persister)2 Before (org.junit.Before)2 TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)1 TestingLaunchConstrainer (com.mesosphere.sdk.scheduler.recovery.constrain.TestingLaunchConstrainer)1 TestingFailureMonitor (com.mesosphere.sdk.scheduler.recovery.monitor.TestingFailureMonitor)1 File (java.io.File)1