use of com.mesosphere.sdk.offer.UnreserveOfferRecommendation in project dcos-commons by mesosphere.
the class DecommissionRecorderTest method testUnreserveNotFound.
@Test
public void testUnreserveNotFound() throws Exception {
when(mockStateStore.fetchGoalOverrideStatus(TestConstants.TASK_NAME)).thenReturn(DecommissionPlanFactory.DECOMMISSIONING_STATUS);
recorder.record(new UnreserveOfferRecommendation(null, otherResource));
verify(mockStateStore, times(0)).storeTasks(any());
}
use of com.mesosphere.sdk.offer.UnreserveOfferRecommendation in project dcos-commons by mesosphere.
the class ResourceCleanupStepTest method testMatchingUpdateOfferStatus.
@Test
public void testMatchingUpdateOfferStatus() throws Exception {
OfferRecommendation offerRecommendation = new UnreserveOfferRecommendation(null, ResourceTestUtils.getReservedCpus(1.0, TestConstants.RESOURCE_ID));
resourceCleanupStep.start();
resourceCleanupStep.updateOfferStatus(Collections.singletonList(offerRecommendation));
assert resourceCleanupStep.getStatus().equals(Status.COMPLETE);
}
use of com.mesosphere.sdk.offer.UnreserveOfferRecommendation in project dcos-commons by mesosphere.
the class OfferEvaluationUtilsTest method testResourceDecrease.
private void testResourceDecrease(Optional<String> namespace) {
String resourceId = UUID.randomUUID().toString();
Protos.Value current = getValue(5);
Protos.Value desired = getValue(4);
Protos.Value toSubtract = ValueUtils.subtract(current, desired);
ResourceSpec resourceSpec = getResourceSpec(desired);
when(mockPool.consumeReserved(RESOURCE_NAME, desired, resourceId)).thenReturn(Optional.of(getMesosResource(getResourceSpec(current), resourceId, namespace)));
when(mockPool.consumeReservableMerged(RESOURCE_NAME, desired, Constants.ANY_ROLE)).thenReturn(Optional.of(getMesosResource(toSubtract)));
ReserveEvaluationOutcome outcome = OfferEvaluationUtils.evaluateSimpleResource(mockStage, resourceSpec, Optional.of(resourceId), namespace, mockPool);
Assert.assertTrue(outcome.getEvaluationOutcome().isPassing());
OfferRecommendation recommendation = outcome.getEvaluationOutcome().getOfferRecommendations().get(0);
Assert.assertTrue(recommendation instanceof UnreserveOfferRecommendation);
Assert.assertTrue(outcome.getResourceId().isPresent());
Protos.Resource resource = recommendation.getOperation().getUnreserve().getResources(0);
Assert.assertEquals(toSubtract.getScalar(), resource.getScalar());
if (namespace.isPresent()) {
Assert.assertEquals(namespace.get(), ResourceUtils.getNamespace(resource).get());
} else {
Assert.assertFalse(ResourceUtils.getNamespace(resource).isPresent());
}
}
use of com.mesosphere.sdk.offer.UnreserveOfferRecommendation in project dcos-commons by mesosphere.
the class ResourceCleanupStepTest method testNonMatchingUpdateOfferStatus.
@Test
public void testNonMatchingUpdateOfferStatus() throws Exception {
OfferRecommendation offerRecommendation = new UnreserveOfferRecommendation(null, ResourceTestUtils.getReservedCpus(1.0, DIFFERENT_RESOURCE_ID));
resourceCleanupStep.start();
resourceCleanupStep.updateOfferStatus(Collections.singletonList(offerRecommendation));
assert resourceCleanupStep.getStatus().equals(Status.PREPARED);
}
use of com.mesosphere.sdk.offer.UnreserveOfferRecommendation in project dcos-commons by mesosphere.
the class ResourceCleanupStepTest method testMixedUpdateOfferStatus.
@Test
public void testMixedUpdateOfferStatus() throws Exception {
OfferRecommendation rec1 = new CreateOfferRecommendation(null, ResourceTestUtils.getReservedRootVolume(999.0));
OfferRecommendation rec2 = new UnreserveOfferRecommendation(null, ResourceTestUtils.getReservedCpus(1.0, TestConstants.RESOURCE_ID));
resourceCleanupStep.start();
resourceCleanupStep.updateOfferStatus(Arrays.asList(rec1, rec2));
assert resourceCleanupStep.getStatus().equals(Status.COMPLETE);
}
Aggregations