use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotShrinkTest method testPodRemoveIsInvalid.
@Test
public void testPodRemoveIsInvalid() throws InvalidRequirementException {
ServiceSpec serviceSpec1 = getServiceSpec(mockPodSpecA1, mockPodSpecB1);
ServiceSpec serviceSpec2 = getServiceSpec("svc2", mockPodSpecA1);
Assert.assertEquals(1, VALIDATOR.validate(Optional.of(serviceSpec1), serviceSpec2).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec2), serviceSpec1).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec1), serviceSpec1).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec2), serviceSpec2).size());
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotShrinkTest method testIdenticalSpecIsValid.
@Test
public void testIdenticalSpecIsValid() throws InvalidRequirementException {
ServiceSpec serviceSpec1 = getServiceSpec(mockPodSpecA1);
ServiceSpec serviceSpec2 = getServiceSpec(mockPodSpecA1);
// only checked against new config
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec1), serviceSpec2).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec2), serviceSpec1).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec1), serviceSpec1).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec2), serviceSpec2).size());
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotShrinkTest method testReducingDestinationAllowedPodCountIsValid.
@Test
public void testReducingDestinationAllowedPodCountIsValid() {
when(mockPodSpecA1.getAllowDecommission()).thenReturn(true);
final ServiceSpec serviceWithManyPods = getServiceSpec(mockPodSpecA1WithHigherCount);
final ServiceSpec serviceWithFewPods = getServiceSpec(mockPodSpecA1);
assertThat(VALIDATOR.validate(Optional.of(serviceWithManyPods), serviceWithFewPods), hasSize(0));
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class PodSpecsCannotShrinkTest method testPodAddIsValid.
@Test
public void testPodAddIsValid() throws InvalidRequirementException {
ServiceSpec serviceSpec1 = getServiceSpec(mockPodSpecA1);
ServiceSpec serviceSpec2 = getServiceSpec("svc2", mockPodSpecA1, mockPodSpecB1);
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec1), serviceSpec2).size());
Assert.assertEquals(1, VALIDATOR.validate(Optional.of(serviceSpec2), serviceSpec1).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec1), serviceSpec1).size());
Assert.assertEquals(0, VALIDATOR.validate(Optional.of(serviceSpec2), serviceSpec2).size());
}
use of com.mesosphere.sdk.specification.ServiceSpec in project dcos-commons by mesosphere.
the class PreReservationCannotChangeTest method testFirstPodRemovalPassesValidation.
@Test
public void testFirstPodRemovalPassesValidation() {
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(mockPodSpec2)).build();
assertThat(VALIDATOR.validate(serviceSpec1, serviceSpec2), is(empty()));
}
Aggregations