Search in sources :

Example 31 with PodSpec

use of com.mesosphere.sdk.specification.PodSpec in project dcos-commons by mesosphere.

the class PlacementUtilsTest method simpleNotRegionRuleFails.

@Test
public void simpleNotRegionRuleFails() {
    PlacementRule rule = new ZoneRule(ExactMatcher.create("zone"));
    PodSpec podSpec = getPodSpec(rule);
    assertFalse(PlacementUtils.placementRuleReferencesRegion(podSpec));
}
Also used : PodSpec(com.mesosphere.sdk.specification.PodSpec) DefaultPodSpec(com.mesosphere.sdk.specification.DefaultPodSpec) Test(org.junit.Test)

Example 32 with PodSpec

use of com.mesosphere.sdk.specification.PodSpec in project dcos-commons by mesosphere.

the class PlacementUtilsTest method nestedOrRegionRuleSucceeds.

@Test
public void nestedOrRegionRuleSucceeds() {
    PlacementRule regionRule = new RegionRule(ExactMatcher.create("region"));
    PlacementRule zoneRule = new ZoneRule(ExactMatcher.create("zone"));
    PlacementRule orRule = new OrRule(regionRule, zoneRule);
    PlacementRule attributeRule = new AttributeRule(ExactMatcher.create("attribute"));
    PlacementRule andRule = new AndRule(attributeRule, orRule);
    PodSpec podSpec = getPodSpec(andRule);
    assertTrue(PlacementUtils.placementRuleReferencesRegion(podSpec));
}
Also used : PodSpec(com.mesosphere.sdk.specification.PodSpec) DefaultPodSpec(com.mesosphere.sdk.specification.DefaultPodSpec) Test(org.junit.Test)

Example 33 with PodSpec

use of com.mesosphere.sdk.specification.PodSpec in project dcos-commons by mesosphere.

the class PlacementUtilsTest method passThroughRuleNotRegion.

@Test
public void passThroughRuleNotRegion() {
    PlacementRule rule = new PassthroughRule();
    PodSpec podSpec = getPodSpec(rule);
    assertFalse(PlacementUtils.placementRuleReferencesRegion(podSpec));
}
Also used : PodSpec(com.mesosphere.sdk.specification.PodSpec) DefaultPodSpec(com.mesosphere.sdk.specification.DefaultPodSpec) Test(org.junit.Test)

Example 34 with PodSpec

use of com.mesosphere.sdk.specification.PodSpec in project dcos-commons by mesosphere.

the class DefaultPlanSchedulerTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    Driver.setDriver(mockSchedulerDriver);
    mockRecommendations = Arrays.asList(mockRecommendation);
    scheduler = new DefaultPlanScheduler(mockOfferAccepter, mockOfferEvaluator, mockStateStore);
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("valid-minimal.yml").getFile());
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).build();
    PodSpec podSpec = serviceSpec.getPods().get(0);
    PodInstance podInstance = new DefaultPodInstance(podSpec, 0);
    podInstanceRequirement = PodInstanceRequirement.newBuilder(podInstance, TaskUtils.getTaskNames(podInstance)).build();
}
Also used : PodSpec(com.mesosphere.sdk.specification.PodSpec) PodInstance(com.mesosphere.sdk.specification.PodInstance) File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Before(org.junit.Before)

Example 35 with PodSpec

use of com.mesosphere.sdk.specification.PodSpec in project dcos-commons by mesosphere.

the class CanaryStrategyTest method beforeAll.

@BeforeClass
public static void beforeAll() {
    for (int i = 0; i < 5; i++) {
        PodSpec podSpec = DefaultPodSpec.newBuilder("executor-uri").type("type" + i).count(1).tasks(Arrays.asList(TestPodFactory.getTaskSpec())).build();
        PodInstance podInstance = new DefaultPodInstance(podSpec, 0);
        PodInstanceRequirement podInstanceRequirement = PodInstanceRequirement.newBuilder(podInstance, Arrays.asList("task0")).build();
        podInstanceRequirements.add(podInstanceRequirement);
    }
}
Also used : PodSpec(com.mesosphere.sdk.specification.PodSpec) DefaultPodSpec(com.mesosphere.sdk.specification.DefaultPodSpec) PodInstance(com.mesosphere.sdk.specification.PodInstance) BeforeClass(org.junit.BeforeClass)

Aggregations

PodSpec (com.mesosphere.sdk.specification.PodSpec)35 DefaultPodSpec (com.mesosphere.sdk.specification.DefaultPodSpec)21 Test (org.junit.Test)16 PlacementRule (com.mesosphere.sdk.offer.evaluate.placement.PlacementRule)10 PodInstance (com.mesosphere.sdk.specification.PodInstance)10 DefaultPodInstance (com.mesosphere.sdk.scheduler.plan.DefaultPodInstance)9 Protos (org.apache.mesos.Protos)8 Collectors (java.util.stream.Collectors)7 PodInstanceRequirement (com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement)6 ServiceSpec (com.mesosphere.sdk.specification.ServiceSpec)6 OfferRecommendation (com.mesosphere.sdk.offer.OfferRecommendation)4 TaskLabelReader (com.mesosphere.sdk.offer.taskdata.TaskLabelReader)4 DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)4 List (java.util.List)4 InvalidRequirementException (com.mesosphere.sdk.offer.InvalidRequirementException)3 TaskException (com.mesosphere.sdk.offer.TaskException)3 ResourceSet (com.mesosphere.sdk.specification.ResourceSet)3 ArrayList (java.util.ArrayList)3 Optional (java.util.Optional)3 ConfigValidationError (com.mesosphere.sdk.config.validate.ConfigValidationError)2