Search in sources :

Example 11 with ResourceRefinementCapabilityContext

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

the class ResourceBuilderTest method testFromExistingRootVolume.

@Test
public void testFromExistingRootVolume() {
    testFromExistingRootVolume(Optional.empty());
    testFromExistingRootVolume(Optional.of("foo/bar"));
    ResourceRefinementCapabilityContext context = new ResourceRefinementCapabilityContext(Capabilities.getInstance());
    try {
        testFromExistingRootVolume(Optional.empty());
        testFromExistingRootVolume(Optional.of("foo/bar"));
    } finally {
        context.reset();
    }
}
Also used : ResourceRefinementCapabilityContext(com.mesosphere.sdk.dcos.ResourceRefinementCapabilityContext) Test(org.junit.Test)

Example 12 with ResourceRefinementCapabilityContext

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

the class OfferEvaluatorTest method testResourceRefinementFailsForMissingPreReservation.

@Test
public void testResourceRefinementFailsForMissingPreReservation() throws Exception {
    ResourceRefinementCapabilityContext context = new ResourceRefinementCapabilityContext(Capabilities.getInstance());
    try {
        ServiceSpec serviceSpec = getServiceSpec("resource-refinement.yml");
        Assert.assertEquals(TestConstants.PRE_RESERVED_ROLE, serviceSpec.getPods().get(0).getPreReservedRole());
        Offer badOffer = OfferTestUtils.getOffer(Arrays.asList(ResourceTestUtils.getUnreservedCpus(3.0)));
        PodSpec podSpec = serviceSpec.getPods().get(0);
        PodInstance podInstance = new DefaultPodInstance(podSpec, 0);
        List<String> tasksToLaunch = TaskUtils.getTaskNames(podInstance);
        PodInstanceRequirement podInstanceRequirement = PodInstanceRequirement.newBuilder(podInstance, tasksToLaunch).build();
        List<OfferRecommendation> recommendations = evaluator.evaluate(podInstanceRequirement, Arrays.asList(badOffer));
        Assert.assertEquals(0, recommendations.size());
    } finally {
        context.reset();
    }
}
Also used : ResourceRefinementCapabilityContext(com.mesosphere.sdk.dcos.ResourceRefinementCapabilityContext) Test(org.junit.Test)

Example 13 with ResourceRefinementCapabilityContext

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

the class ResourceBuilderTest method testNewFromMountVolumeSpec.

/*
        name: "disk"
        type: SCALAR
        scalar {
          value: 10.0
        }
        role: "*"
        disk {
          persistence {
            id: "31374544-3579-44eb-a88e-23b232b15a7a"
            principal: "test-principal"
          }
          volume {
            container_path: "test-container-path"
            mode: RW
          }
          source {
            type: MOUNT
            mount {
              root: "/mnt/source"
            }
          }
        }
        reservations {
          principal: "test-principal"
          labels {
            labels {
              key: "resource_id"
              value: "9d400c17-ec13-4236-9453-d5642b2884c5"
            }
          }
          role: "test-role"
        }
    */
@Test
public void testNewFromMountVolumeSpec() {
    testNewFromMountVolumeSpec(Optional.empty());
    testNewFromMountVolumeSpec(Optional.of("foo"));
    ResourceRefinementCapabilityContext context = new ResourceRefinementCapabilityContext(Capabilities.getInstance());
    try {
        testNewFromMountVolumeSpec(Optional.empty());
        testNewFromMountVolumeSpec(Optional.of("foo"));
    } finally {
        context.reset();
    }
}
Also used : ResourceRefinementCapabilityContext(com.mesosphere.sdk.dcos.ResourceRefinementCapabilityContext) Test(org.junit.Test)

Example 14 with ResourceRefinementCapabilityContext

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

the class ResourceBuilderTest method testExistingFromMountVolumeSpec.

@Test
public void testExistingFromMountVolumeSpec() {
    testExistingFromMountVolumeSpec(Optional.empty());
    testExistingFromMountVolumeSpec(Optional.of("some/namespace"));
    ResourceRefinementCapabilityContext context = new ResourceRefinementCapabilityContext(Capabilities.getInstance());
    try {
        testExistingFromMountVolumeSpec(Optional.empty());
        testExistingFromMountVolumeSpec(Optional.of("some/namespace"));
    } finally {
        context.reset();
    }
}
Also used : ResourceRefinementCapabilityContext(com.mesosphere.sdk.dcos.ResourceRefinementCapabilityContext) Test(org.junit.Test)

Aggregations

ResourceRefinementCapabilityContext (com.mesosphere.sdk.dcos.ResourceRefinementCapabilityContext)14 Test (org.junit.Test)12 Capabilities (com.mesosphere.sdk.dcos.Capabilities)1 DefaultResourceSpec (com.mesosphere.sdk.specification.DefaultResourceSpec)1 ResourceSpec (com.mesosphere.sdk.specification.ResourceSpec)1 Protos (org.apache.mesos.Protos)1 Operation (org.apache.mesos.Protos.Offer.Operation)1 BeforeClass (org.junit.BeforeClass)1