Search in sources :

Example 46 with ServiceSpec

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

the class PreReservationCannotChangeTest method testSecondPodRemovalPassesValidation.

@Test
public void testSecondPodRemovalPassesValidation() {
    Optional<ServiceSpec> serviceSpec1 = Optional.of(DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1, mockPodSpec2)).build());
    ServiceSpec serviceSpec2 = DefaultServiceSpec.newBuilder().name("svc2").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1)).build();
    assertThat(VALIDATOR.validate(serviceSpec1, serviceSpec2), is(empty()));
}
Also used : DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Example 47 with ServiceSpec

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

the class PreReservationCannotChangeTest method testReplacedPodPassesValidation.

@Test
public void testReplacedPodPassesValidation() {
    Optional<ServiceSpec> serviceSpec1 = Optional.of(DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1)).build());
    final ServiceSpec serviceSpec2 = DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1)).build();
    assertThat(VALIDATOR.validate(serviceSpec1, serviceSpec2), is(empty()));
}
Also used : DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Example 48 with ServiceSpec

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

the class PreReservationCannotChangeTest method testMissingPreReservedRolesPassesValidation.

@Test
public void testMissingPreReservedRolesPassesValidation() {
    Optional<ServiceSpec> serviceSpec1 = Optional.of(DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1WithNoRole)).build());
    ServiceSpec serviceSpec2 = DefaultServiceSpec.newBuilder().name("svc2").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1WithNoRole)).build();
    assertThat(VALIDATOR.validate(serviceSpec1, serviceSpec2), is(empty()));
}
Also used : DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Example 49 with ServiceSpec

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

the class PreReservationCannotChangeTest method testRemovalOfPreReservedRoleFailsValidation.

@Test
public void testRemovalOfPreReservedRoleFailsValidation() {
    Optional<ServiceSpec> serviceSpec1 = Optional.of(DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1)).build());
    ServiceSpec serviceSpec2 = DefaultServiceSpec.newBuilder().name("svc2").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1WithNoRole)).build();
    assertThat(VALIDATOR.validate(serviceSpec1, serviceSpec2), hasSize(1));
}
Also used : DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Example 50 with ServiceSpec

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

the class PreReservationCannotChangeTest method testAdditionOfPreReservedRoleFailsValidation.

@Test
public void testAdditionOfPreReservedRoleFailsValidation() {
    Optional<ServiceSpec> serviceSpec1 = Optional.of(DefaultServiceSpec.newBuilder().name("svc1").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1WithNoRole)).build());
    ServiceSpec serviceSpec2 = DefaultServiceSpec.newBuilder().name("svc2").role(TestConstants.ROLE).principal(TestConstants.PRINCIPAL).pods(Arrays.asList(mockPodSpec1)).build();
    assertThat(VALIDATOR.validate(serviceSpec1, serviceSpec2), hasSize(1));
}
Also used : DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Aggregations

ServiceSpec (com.mesosphere.sdk.specification.ServiceSpec)61 DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)55 Test (org.junit.Test)51 MemPersister (com.mesosphere.sdk.storage.MemPersister)7 PodSpec (com.mesosphere.sdk.specification.PodSpec)6 Collectors (java.util.stream.Collectors)5 ConfigStoreException (com.mesosphere.sdk.state.ConfigStoreException)3 java.util (java.util)3 Protos (org.apache.mesos.Protos)3 Capabilities (com.mesosphere.sdk.dcos.Capabilities)2 TaskException (com.mesosphere.sdk.offer.TaskException)2 PlacementRule (com.mesosphere.sdk.offer.evaluate.placement.PlacementRule)2 TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)2 DefaultPodSpec (com.mesosphere.sdk.specification.DefaultPodSpec)2 Persister (com.mesosphere.sdk.storage.Persister)2 PersisterException (com.mesosphere.sdk.storage.PersisterException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 Optional (java.util.Optional)2