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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations