use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class UserCannotChangeTest method testMultiplePodsOldSettingNoUserNewSettingOneUser.
@Test
public void testMultiplePodsOldSettingNoUserNewSettingOneUser() {
when(mockOldPodSpec.getUser()).thenReturn(Optional.empty());
when(mockOldPodSpec2.getUser()).thenReturn(Optional.empty());
when(mockNewPodSpec.getUser()).thenReturn(Optional.of(USER_B + "-1"));
when(mockNewPodSpec2.getUser()).thenReturn(Optional.of(USER_B + "-1"));
ServiceSpec oldServiceSpec = DefaultServiceSpec.newBuilder().name("svc").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockOldPodSpec, mockOldPodSpec2)).build();
ServiceSpec newServiceSpec = DefaultServiceSpec.newBuilder().name("svc").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockNewPodSpec, mockNewPodSpec2)).build();
Assert.assertEquals(3, VALIDATOR.validate(Optional.of(oldServiceSpec), newServiceSpec).size());
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class SchedulerBuilderTest method testRegionAwarenessDisabledWithSchedulerRegion.
@Test
public void testRegionAwarenessDisabledWithSchedulerRegion() throws PersisterException {
when(mockSchedulerConfig.getSchedulerRegion()).thenReturn(Optional.of(TestConstants.REMOTE_REGION));
ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, new MemPersister()).build().getServiceSpec();
Optional<PlacementRule> rule = updatedServiceSpec.getPods().get(0).getPlacementRule();
// Pod updated with local region rule:
Assert.assertTrue(rule.isPresent());
Assert.assertTrue(rule.get() instanceof IsLocalRegionRule);
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class SchedulerBuilderTest method testDomainsNotSupportedByCluster.
@Test
public void testDomainsNotSupportedByCluster() throws Exception {
when(mockCapabilities.supportsDomains()).thenReturn(false);
ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, new MemPersister()).build().getServiceSpec();
// No rule changes:
Assert.assertFalse(updatedServiceSpec.getPods().get(0).getPlacementRule().isPresent());
// Not hit since unsupported by cluster:
verify(mockCapabilities, atLeastOnce()).supportsDomains();
verify(mockSchedulerConfig, never()).isRegionAwarenessEnabled();
verify(mockSchedulerConfig, never()).getSchedulerRegion();
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class SchedulerBuilderTest method testRegionAwarenessDisabledWithoutSchedulerRegion.
@Test
public void testRegionAwarenessDisabledWithoutSchedulerRegion() throws PersisterException {
ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, new MemPersister()).build().getServiceSpec();
Optional<PlacementRule> rule = updatedServiceSpec.getPods().get(0).getPlacementRule();
// Pod updated with local region rule:
Assert.assertTrue(rule.isPresent());
Assert.assertTrue(rule.get() instanceof IsLocalRegionRule);
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class SchedulerBuilderTest method testRegionAwarenessEnabledEnvWithSchedulerRegion.
@Test
public void testRegionAwarenessEnabledEnvWithSchedulerRegion() throws PersisterException {
when(mockSchedulerConfig.getSchedulerRegion()).thenReturn(Optional.of(TestConstants.REMOTE_REGION));
when(mockSchedulerConfig.isRegionAwarenessEnabled()).thenReturn(true);
ServiceSpec updatedServiceSpec = DefaultScheduler.newBuilder(minimalServiceSpec, mockSchedulerConfig, new MemPersister()).build().getServiceSpec();
Optional<PlacementRule> rule = updatedServiceSpec.getPods().get(0).getPlacementRule();
// Pod updated with exact region rule:
Assert.assertTrue(rule.isPresent());
Assert.assertTrue(rule.get() instanceof RegionRule);
verify(mockSchedulerConfig).isRegionAwarenessEnabled();
}
Aggregations