Search in sources :

Example 1 with DefaultServiceSpec

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));
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 2 with DefaultServiceSpec

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");
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 3 with DefaultServiceSpec

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);
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 4 with DefaultServiceSpec

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);
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 5 with DefaultServiceSpec

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");
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Aggregations

DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)15 File (java.io.File)15 Test (org.junit.Test)14 PodInstance (com.mesosphere.sdk.specification.PodInstance)1 PodSpec (com.mesosphere.sdk.specification.PodSpec)1 Before (org.junit.Before)1