use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class PreReservationCannotChangeTest method testFirstPodChangesReservedRoleFailsValidation.
@Test
public void testFirstPodChangesReservedRoleFailsValidation() {
Optional<ServiceSpec> serviceSpec1 = Optional.of(DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1, mockPodSpec2)).build());
final ServiceSpec serviceSpec2 = DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1WithDifferentRole, mockPodSpec2)).build();
assertThat(VALIDATOR.validate(serviceSpec1, serviceSpec2), hasSize(1));
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class RegionCannotChangeTest method testSameRegion.
@Test
public void testSameRegion() {
ServiceSpec oldServiceSpec = DefaultServiceSpec.newBuilder().name("svc").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec)).region(REGION_A).build();
ServiceSpec newServiceSpec = DefaultServiceSpec.newBuilder().name("svc").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec)).region(REGION_A).build();
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(oldServiceSpec), newServiceSpec).size());
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class UserCannotChangeTest method testMultiplePodsOldSettingNoUserNewSettingNoUser.
@Test
public void testMultiplePodsOldSettingNoUserNewSettingNoUser() {
when(mockOldPodSpec.getUser()).thenReturn(Optional.empty());
when(mockOldPodSpec2.getUser()).thenReturn(Optional.empty());
when(mockNewPodSpec.getUser()).thenReturn(Optional.empty());
when(mockNewPodSpec2.getUser()).thenReturn(Optional.empty());
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(0, VALIDATOR.validate(Optional.of(oldServiceSpec), newServiceSpec).size());
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class UserCannotChangeTest method testOldServiceUserUnset.
@Test
public void testOldServiceUserUnset() {
when(mockNewPodSpec.getUser()).thenReturn(Optional.of(USER_A));
ServiceSpec oldServiceSpec = DefaultServiceSpec.newBuilder().name("svc").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockOldPodSpec)).build();
ServiceSpec newServiceSpec = DefaultServiceSpec.newBuilder().name("svc").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockNewPodSpec)).user(USER_A).build();
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(oldServiceSpec), newServiceSpec).size());
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class UserCannotChangeTest method testMultiplePodsOldSettingNoUserNewSettingMultipleUsers.
@Test
public void testMultiplePodsOldSettingNoUserNewSettingMultipleUsers() {
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 + "-2"));
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());
}
Aggregations