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