Search in sources :

Example 1 with SingularityDeleteRequestRequest

use of com.hubspot.singularity.api.SingularityDeleteRequestRequest in project Singularity by HubSpot.

the class SingularitySchedulerTest method testLbCleanupSkippedOnSkipRemoveFlag.

@Test
public void testLbCleanupSkippedOnSkipRemoveFlag() {
    configuration.setDeleteRemovedRequestsFromLoadBalancer(true);
    initLoadBalancedRequest();
    initLoadBalancedDeploy();
    startTask(firstDeploy);
    boolean removeFromLoadBalancer = false;
    SingularityDeleteRequestRequest deleteRequest = new SingularityDeleteRequestRequest(Optional.absent(), Optional.absent(), Optional.of(removeFromLoadBalancer));
    requestResource.deleteRequest(requestId, Optional.of(deleteRequest), singularityUser);
    testingLbClient.setNextBaragonRequestState(BaragonRequestState.WAITING);
    Assert.assertFalse("Tasks should get cleaned up", requestManager.getCleanupRequests().isEmpty());
    cleaner.drainCleanupQueue();
    killKilledTasks();
    Assert.assertFalse("The request should get cleaned up", requestManager.getCleanupRequests().isEmpty());
    cleaner.drainCleanupQueue();
    Assert.assertTrue("The request should not be removed from the load balancer", requestManager.getLbCleanupRequestIds().isEmpty());
}
Also used : SingularityDeleteRequestRequest(com.hubspot.singularity.api.SingularityDeleteRequestRequest) Test(org.junit.Test)

Example 2 with SingularityDeleteRequestRequest

use of com.hubspot.singularity.api.SingularityDeleteRequestRequest in project Singularity by HubSpot.

the class SingularityHistoryTest method testMessage.

@Test
public void testMessage() {
    initRequest();
    String msg = null;
    for (int i = 0; i < 300; i++) {
        msg = msg + i;
    }
    requestResource.scale(requestId, new SingularityScaleRequest(Optional.of(2), Optional.absent(), Optional.absent(), Optional.absent(), Optional.of(msg), Optional.absent(), Optional.absent(), Optional.absent()), singularityUser);
    requestResource.deleteRequest(requestId, Optional.of(new SingularityDeleteRequestRequest(Optional.of("a msg"), Optional.absent(), Optional.absent())), singularityUser);
    cleaner.drainCleanupQueue();
    requestHistoryPersister.runActionOnPoll();
    List<SingularityRequestHistory> history = historyManager.getRequestHistory(requestId, Optional.of(OrderDirection.DESC), 0, 100);
    Assert.assertEquals(4, history.size());
    for (SingularityRequestHistory historyItem : history) {
        if (historyItem.getEventType() == RequestHistoryType.DELETED) {
            Assert.assertEquals("a msg", historyItem.getMessage().get());
        } else if (historyItem.getEventType() == RequestHistoryType.SCALED) {
            Assert.assertEquals(280, historyItem.getMessage().get().length());
        } else if (historyItem.getEventType() == RequestHistoryType.DELETING) {
            Assert.assertEquals("a msg", historyItem.getMessage().get());
        } else {
            Assert.assertTrue(!historyItem.getMessage().isPresent());
        }
    }
}
Also used : SingularityDeleteRequestRequest(com.hubspot.singularity.api.SingularityDeleteRequestRequest) SingularityScaleRequest(com.hubspot.singularity.api.SingularityScaleRequest) Test(org.junit.Test)

Aggregations

SingularityDeleteRequestRequest (com.hubspot.singularity.api.SingularityDeleteRequestRequest)2 Test (org.junit.Test)2 SingularityScaleRequest (com.hubspot.singularity.api.SingularityScaleRequest)1