use of com.mesosphere.sdk.specification.DefaultServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotUseUnsupportedFeaturesTest method validGpuResourceSet.
@Test
public void validGpuResourceSet() throws Exception {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("valid-gpu-resourceset.yml").getFile());
DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).build();
Assert.assertNotNull(serviceSpec);
Assert.assertTrue("Expected serviceSpec to request support GPUs", PodSpecsCannotUseUnsupportedFeatures.serviceRequestsGpuResources(serviceSpec));
}
use of com.mesosphere.sdk.specification.DefaultServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecFailsWhenCniPortMappingIsNotSupported.
@Test
public void testSpecFailsWhenCniPortMappingIsNotSupported() throws Exception {
when(mockCapabilities.supportsGpuResource()).thenReturn(true);
when(mockCapabilities.supportsRLimits()).thenReturn(true);
Capabilities.overrideCapabilities(mockCapabilities);
when(mockConfigTemplateReader.read("config-one.conf.mustache")).thenReturn("hello");
when(mockConfigTemplateReader.read("config-two.xml.mustache")).thenReturn("hey");
when(mockConfigTemplateReader.read("config-three.conf.mustache")).thenReturn("hi");
File file2 = new File(getClass().getClassLoader().getResource("valid-exhaustive.yml").getFile());
DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file2, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
checkValidationErrorWithValue(serviceSpec, "network");
}
use of com.mesosphere.sdk.specification.DefaultServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecSucceedsWhenEnvSecretIsSupported.
@Test
public void testSpecSucceedsWhenEnvSecretIsSupported() throws Exception {
when(mockCapabilities.supportsEnvBasedSecretsProtobuf()).thenReturn(true);
Capabilities.overrideCapabilities(mockCapabilities);
File file = new File(getClass().getClassLoader().getResource("valid-secrets-env.yml").getFile());
DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
checkValidationPasses(serviceSpec);
}
use of com.mesosphere.sdk.specification.DefaultServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecSucceedsWhenGpuResourceIsSupported.
@Test
public void testSpecSucceedsWhenGpuResourceIsSupported() throws Exception {
when(mockCapabilities.supportsGpuResource()).thenReturn(true);
Capabilities.overrideCapabilities(mockCapabilities);
when(mockConfigTemplateReader.read("config-one.conf.mustache")).thenReturn("hello");
when(mockConfigTemplateReader.read("config-two.xml.mustache")).thenReturn("hey");
when(mockConfigTemplateReader.read("config-three.conf.mustache")).thenReturn("hi");
File file = new File(getClass().getClassLoader().getResource("valid-gpu-resource.yml").getFile());
DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
checkValidationPasses(serviceSpec);
when(mockCapabilities.supportsRLimits()).thenReturn(true);
when(mockCapabilities.supportsCNINetworking()).thenReturn(true);
File file2 = new File(getClass().getClassLoader().getResource("valid-exhaustive.yml").getFile());
serviceSpec = DefaultServiceSpec.newGenerator(file2, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
checkValidationPasses(serviceSpec);
}
use of com.mesosphere.sdk.specification.DefaultServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecFailsWhenGpuResourceNotSupported.
@Test
public void testSpecFailsWhenGpuResourceNotSupported() throws Exception {
when(mockCapabilities.supportsGpuResource()).thenReturn(false);
Capabilities.overrideCapabilities(mockCapabilities);
when(mockConfigTemplateReader.read("config-one.conf.mustache")).thenReturn("hello");
when(mockConfigTemplateReader.read("config-two.xml.mustache")).thenReturn("hey");
when(mockConfigTemplateReader.read("config-three.conf.mustache")).thenReturn("hi");
// check that it works when GPUs are specified at the task level
File file = new File(getClass().getClassLoader().getResource("valid-gpu-resource.yml").getFile());
DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
checkValidationErrorWithValue(serviceSpec, "gpus");
// check that it works when GPUs are specified at the resourceSet level
file = new File(getClass().getClassLoader().getResource("valid-gpu-resourceset.yml").getFile());
serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
checkValidationErrorWithValue(serviceSpec, "gpus");
}
Aggregations