Search in sources :

Example 1 with VolumeSpec

use of com.mesosphere.sdk.specification.VolumeSpec 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 VolumeSpec

use of com.mesosphere.sdk.specification.VolumeSpec 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 VolumeSpec

use of com.mesosphere.sdk.specification.VolumeSpec 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 VolumeSpec

use of com.mesosphere.sdk.specification.VolumeSpec 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 VolumeSpec

use of com.mesosphere.sdk.specification.VolumeSpec 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

VolumeSpec (com.mesosphere.sdk.specification.VolumeSpec)9 Protos (org.apache.mesos.Protos)7 DefaultVolumeSpec (com.mesosphere.sdk.specification.DefaultVolumeSpec)6 ResourceSpec (com.mesosphere.sdk.specification.ResourceSpec)3 Constants (com.mesosphere.sdk.offer.Constants)1 PodSpec (com.mesosphere.sdk.specification.PodSpec)1 TaskSpec (com.mesosphere.sdk.specification.TaskSpec)1 TestConstants (com.mesosphere.sdk.testutils.TestConstants)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 Scheduler (org.apache.mesos.Scheduler)1 SchedulerDriver (org.apache.mesos.SchedulerDriver)1