Search in sources :

Example 11 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecFailsWhenEnvSecretIsNotSupported.

@Test
public void testSpecFailsWhenEnvSecretIsNotSupported() throws Exception {
    when(mockCapabilities.supportsEnvBasedSecretsProtobuf()).thenReturn(false);
    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();
    checkValidationErrorWithValue(serviceSpec, "secrets:env");
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 12 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method testSpecSucceedsWithRLimits.

@Test
public void testSpecSucceedsWithRLimits() throws Exception {
    when(mockCapabilities.supportsRLimits()).thenReturn(true);
    when(mockCapabilities.supportsGpuResource()).thenReturn(true);
    when(mockCapabilities.supportsCNINetworking()).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();
    checkValidationPasses(serviceSpec);
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 13 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method validGpuResource.

@Test
public void validGpuResource() throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("valid-gpu-resource.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 14 with DefaultServiceSpec

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

the class PodSpecsCannotUseUnsupportedFeaturesTest method validSimple.

@Test
public void validSimple() throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("valid-simple.yml").getFile());
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).build();
    Assert.assertNotNull(serviceSpec);
    Assert.assertEquals(DcosConstants.DEFAULT_GPU_POLICY, PodSpecsCannotUseUnsupportedFeatures.serviceRequestsGpuResources(serviceSpec));
}
Also used : File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Test(org.junit.Test)

Example 15 with DefaultServiceSpec

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

the class DefaultPlanSchedulerTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    MockitoAnnotations.initMocks(this);
    Driver.setDriver(mockSchedulerDriver);
    mockRecommendations = Arrays.asList(mockRecommendation);
    scheduler = new DefaultPlanScheduler(mockOfferAccepter, mockOfferEvaluator, mockStateStore);
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("valid-minimal.yml").getFile());
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).build();
    PodSpec podSpec = serviceSpec.getPods().get(0);
    PodInstance podInstance = new DefaultPodInstance(podSpec, 0);
    podInstanceRequirement = PodInstanceRequirement.newBuilder(podInstance, TaskUtils.getTaskNames(podInstance)).build();
}
Also used : PodSpec(com.mesosphere.sdk.specification.PodSpec) PodInstance(com.mesosphere.sdk.specification.PodInstance) File(java.io.File) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) Before(org.junit.Before)

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