Search in sources :

Example 1 with DefaultVolumeSpec

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

the class ResourceBuilderTest method testNewFromMountVolumeSpec.

private static void testNewFromMountVolumeSpec(Optional<String> namespace) {
    VolumeSpec volumeSpec = new DefaultVolumeSpec(10, VolumeSpec.Type.MOUNT, TestConstants.CONTAINER_PATH, TestConstants.ROLE, Constants.ANY_ROLE, TestConstants.PRINCIPAL);
    ResourceBuilder resourceBuilder = ResourceBuilder.fromSpec(volumeSpec, Optional.empty(), namespace, Optional.empty(), Optional.of(TestConstants.MOUNT_SOURCE_ROOT));
    Protos.Resource resource = resourceBuilder.build();
    validateDisk(resource, Optional.empty(), namespace);
    Protos.Resource.DiskInfo diskInfo = resource.getDisk();
    Assert.assertTrue(diskInfo.hasSource());
    Protos.Resource.DiskInfo.Source source = diskInfo.getSource();
    Assert.assertEquals("MOUNT", source.getType().toString());
    Assert.assertTrue(source.hasMount());
    Assert.assertEquals(TestConstants.MOUNT_SOURCE_ROOT, source.getMount().getRoot());
}
Also used : DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec) VolumeSpec(com.mesosphere.sdk.specification.VolumeSpec) Protos(org.apache.mesos.Protos) DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec)

Example 2 with DefaultVolumeSpec

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

the class ResourceBuilderTest method testExistingFromRootVolumeSpec.

private static void testExistingFromRootVolumeSpec(Optional<String> namespace) {
    VolumeSpec volumeSpec = new DefaultVolumeSpec(10, VolumeSpec.Type.ROOT, TestConstants.CONTAINER_PATH, TestConstants.ROLE, Constants.ANY_ROLE, TestConstants.PRINCIPAL);
    Optional<String> resourceId = Optional.of(UUID.randomUUID().toString());
    Optional<String> persistenceId = Optional.of(UUID.randomUUID().toString());
    ResourceBuilder resourceBuilder = ResourceBuilder.fromSpec(volumeSpec, resourceId, namespace, persistenceId, Optional.empty());
    Protos.Resource resource = resourceBuilder.build();
    validateDisk(resource, resourceId, namespace);
    Assert.assertEquals(persistenceId.get(), resource.getDisk().getPersistence().getId());
}
Also used : DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec) VolumeSpec(com.mesosphere.sdk.specification.VolumeSpec) Protos(org.apache.mesos.Protos) DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec)

Example 3 with DefaultVolumeSpec

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

the class ResourceBuilderTest method testFromExistingRootVolume.

private static void testFromExistingRootVolume(Optional<String> namespace) {
    VolumeSpec volumeSpec = new DefaultVolumeSpec(10, VolumeSpec.Type.ROOT, TestConstants.CONTAINER_PATH, TestConstants.ROLE, Constants.ANY_ROLE, TestConstants.PRINCIPAL);
    Optional<String> resourceId = Optional.of(UUID.randomUUID().toString());
    Optional<String> persistenceId = Optional.of(UUID.randomUUID().toString());
    Protos.Resource originalResource = ResourceBuilder.fromSpec(volumeSpec, resourceId, namespace, persistenceId, Optional.empty()).build();
    Protos.Resource reconstructedResource = ResourceBuilder.fromExistingResource(originalResource).build();
    Assert.assertEquals(originalResource, reconstructedResource);
}
Also used : DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec) VolumeSpec(com.mesosphere.sdk.specification.VolumeSpec) Protos(org.apache.mesos.Protos) DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec)

Example 4 with DefaultVolumeSpec

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

the class ResourceBuilderTest method testNewFromRootVolumeSpec.

private static void testNewFromRootVolumeSpec(Optional<String> namespace) {
    VolumeSpec volumeSpec = new DefaultVolumeSpec(10, VolumeSpec.Type.ROOT, TestConstants.CONTAINER_PATH, TestConstants.ROLE, Constants.ANY_ROLE, TestConstants.PRINCIPAL);
    ResourceBuilder resourceBuilder = ResourceBuilder.fromSpec(volumeSpec, Optional.empty(), namespace, Optional.empty(), Optional.empty());
    Protos.Resource resource = resourceBuilder.build();
    validateDisk(resource, Optional.empty(), namespace);
}
Also used : DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec) VolumeSpec(com.mesosphere.sdk.specification.VolumeSpec) Protos(org.apache.mesos.Protos) DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec)

Example 5 with DefaultVolumeSpec

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

the class ResourceBuilderTest method testFromExistingMountVolume.

private static void testFromExistingMountVolume(Optional<String> namespace) {
    VolumeSpec volumeSpec = new DefaultVolumeSpec(10, VolumeSpec.Type.MOUNT, TestConstants.CONTAINER_PATH, TestConstants.ROLE, Constants.ANY_ROLE, TestConstants.PRINCIPAL);
    Optional<String> resourceId = Optional.of(UUID.randomUUID().toString());
    Optional<String> persistenceId = Optional.of(UUID.randomUUID().toString());
    Optional<String> sourceRoot = Optional.of(TestConstants.MOUNT_SOURCE_ROOT);
    Protos.Resource originalResource = ResourceBuilder.fromSpec(volumeSpec, resourceId, namespace, persistenceId, sourceRoot).build();
    Protos.Resource reconstructedResource = ResourceBuilder.fromExistingResource(originalResource).build();
    Assert.assertEquals(originalResource, reconstructedResource);
}
Also used : DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec) VolumeSpec(com.mesosphere.sdk.specification.VolumeSpec) Protos(org.apache.mesos.Protos) DefaultVolumeSpec(com.mesosphere.sdk.specification.DefaultVolumeSpec)

Aggregations

DefaultVolumeSpec (com.mesosphere.sdk.specification.DefaultVolumeSpec)8 Protos (org.apache.mesos.Protos)8 VolumeSpec (com.mesosphere.sdk.specification.VolumeSpec)6 OfferRecommendation (com.mesosphere.sdk.offer.OfferRecommendation)2 PodInstanceRequirement (com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement)2 Operation (org.apache.mesos.Protos.Offer.Operation)2 Resource (org.apache.mesos.Protos.Resource)2 Test (org.junit.Test)2