Search in sources :

Example 6 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecSucceedsWhenSecretIsSupported.

@Test
public void testSpecSucceedsWhenSecretIsSupported() throws Exception {
    when(mockCapabilities.supportsFileBasedSecrets()).thenReturn(true);
    when(mockCapabilities.supportsEnvBasedSecretsProtobuf()).thenReturn(true);
    Capabilities.overrideCapabilities(mockCapabilities);
    File file = new File(getClass().getClassLoader().getResource("valid-secrets.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 7 with DefaultServiceSpec

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

the class YAMLServiceSpecFactoryTest method testGenerateSpecFromYAML.

@Test
public void testGenerateSpecFromYAML() throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("valid-exhaustive.yml").getFile());
    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");
    when(mockSchedulerConfig.getApiServerPort()).thenReturn(123);
    when(mockSchedulerConfig.getExecutorURI()).thenReturn("test-executor-uri");
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, mockSchedulerConfig).setConfigTemplateReader(mockConfigTemplateReader).build();
    Assert.assertNotNull(serviceSpec);
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 8 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecFailsWithRLimitsButWithoutCapability.

@Test
public void testSpecFailsWithRLimitsButWithoutCapability() throws Exception {
    when(mockCapabilities.supportsRLimits()).thenReturn(false);
    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-exhaustive.yml").getFile());
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
    checkValidationErrorWithValue(serviceSpec, "rlimits");
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 9 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecFailsWhenFileSecretIsNotSupported.

@Test
public void testSpecFailsWhenFileSecretIsNotSupported() throws Exception {
    when(mockCapabilities.supportsFileBasedSecrets()).thenReturn(false);
    when(mockCapabilities.supportsEnvBasedSecretsProtobuf()).thenReturn(true);
    Capabilities.overrideCapabilities(mockCapabilities);
    File file = new File(getClass().getClassLoader().getResource("valid-secrets.yml").getFile());
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).setConfigTemplateReader(mockConfigTemplateReader).build();
    checkValidationErrorWithValue(serviceSpec, "secrets:file");
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 10 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecSucceedsWithoutRLimits.

@Test
public void testSpecSucceedsWithoutRLimits() throws Exception {
    when(mockCapabilities.supportsRLimits()).thenReturn(false);
    when(mockCapabilities.supportsGpuResource()).thenReturn(true);
    Capabilities.overrideCapabilities(mockCapabilities);
    File file = new File(getClass().getClassLoader().getResource("valid-minimal.yml").getFile());
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).build();
    checkValidationPasses(serviceSpec);
}
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