Caller superuser = this.populator().getSuperuserCaller();
logger.debug("Submitting backfill requests..");
AsyncCreateRequest backfill1 = this.populator().getBackfillRequest("backfill1", 3);
RequestInfo backfill1Result = rm.addBackfillRequest(backfill1, superuser);
AsyncCreateRequest backfill2 = this.populator().getBackfillRequest("backfill2", 5);
RequestInfo backfill2Result = rm.addBackfillRequest(backfill2, superuser);
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024)
//
// Current SI Requests________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 3 | ACTIVE |
// | backfill2 | 5 | 5 | ACTIVE |
// --------------------------------------------
// Requested SI VMs (alive requests): 0
// Spot price: MINIUM_PRICE (since requestedVMs < availableVMs)
logger.debug("Waiting 10 seconds for resources to be allocated.");
Thread.sleep(10000);
//Verify there are no spot instance requests
SpotRequestInfo[] spotRequestByCaller = rm.getSpotRequestsByCaller(superuser);
assertEquals(0, spotRequestByCaller.length);
spotRequestByCaller = rm.getSpotRequestsByCaller(caller1);
assertEquals(0, spotRequestByCaller.length);
spotRequestByCaller = rm.getSpotRequestsByCaller(caller2);
assertEquals(0, spotRequestByCaller.length);
spotRequestByCaller = rm.getSpotRequestsByCaller(caller3);
assertEquals(0, spotRequestByCaller.length);
//Check backfill request state
RequestInfo[] backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
assertEquals(3, backfill1Result.getVMIds().length);
assertEquals(RequestState.STATE_Active, backfill1Result.getState().getStateStr());
backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
assertEquals(5, backfill2Result.getVMIds().length);
assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());
//New spot price is equal to minimum price (since there are still available resources)
assertEquals(MINIMUM_PRICE, rm.getSpotPrice());
Double previousPrice = rm.getSpotPrice();
final Double lowBid = previousPrice + 1;
final Double mediumBid = previousPrice + 2;
final Double highBid = previousPrice + 3;
SpotCreateRequest lowReq1 = this.populator().getBasicRequestSI("lowReq1", 1, lowBid, false);
SpotCreateRequest lowReq2 = this.populator().getBasicRequestSI("lowReq2", 3, lowBid, true);
SpotCreateRequest lowReq3 = this.populator().getBasicRequestSI("lowReq3", 1, lowBid, false);
SpotCreateRequest mediumReq1 = this.populator().getBasicRequestSI("mediumReq1", 3, mediumBid, false);
SpotCreateRequest mediumReq2 = this.populator().getBasicRequestSI("mediumReq2", 5, mediumBid, true);
SpotCreateRequest highReq = this.populator().getBasicRequestSI("highReq", 10, highBid, false);
logger.debug("Submitting SI requests: lowReq1, lowReq2, mediumReq1");
//Submit 3 SI Requests
String lowReq1Id = rm.requestSpotInstances(lowReq1, caller1).getRequestID();
String lowReq2Id = rm.requestSpotInstances(lowReq2, caller1).getRequestID();
String medReq1Id = rm.requestSpotInstances(mediumReq1, caller2).getRequestID();
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests___________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 1 | previousPrice+1 | ACTIVE | false |
// | lowReq2 | 3 | 3 | previousPrice+1 | ACTIVE | true |
// | mediumReq1 | 3 | 3 | previousPrice+2 | ACTIVE | false |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 1 | ACTIVE |
// | backfill2 | 5 | 0 | OPEN |
// --------------------------------------------
// Requested SI VMs (alive requests): 7
// Spot price: MINIMUM_PRICE (since requestedVMs < availableVMs)
Calendar ts2 = Calendar.getInstance();
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//New spot price is equal to minimum price
assertEquals(MINIMUM_PRICE, rm.getSpotPrice());
//Check if all submitted requests are active
SpotRequestInfo[] caller1Reqs = rm.getSpotRequestsByCaller(caller1);
for (SpotRequestInfo caller1Req : caller1Reqs) {
assertEquals(RequestState.STATE_Active, caller1Req.getState().getStateStr());
}
SpotRequestInfo[] caller2Reqs = rm.getSpotRequestsByCaller(caller2);
assertEquals(RequestState.STATE_Active, caller2Reqs[0].getState().getStateStr());
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
assertEquals(1, backfill1Result.getVMIds().length);
assertEquals(RequestState.STATE_Active, backfill1Result.getState().getStateStr());
backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
assertEquals(0, backfill2Result.getVMIds().length);
assertEquals(RequestState.STATE_Open, backfill2Result.getState().getStateStr());
logger.debug("Submitting SI request: lowReq3");
//Submit another SI Request
String lowReq3Id = rm.requestSpotInstances(lowReq3, caller2).getRequestID();
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests___________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 1 | previousPrice+1 | ACTIVE | false |
// | lowReq2 | 3 | 3 | previousPrice+1 | ACTIVE | true |
// | mediumReq1 | 3 | 3 | previousPrice+2 | ACTIVE | false |
// | lowReq3 | 1 | 1 | previousPrice+1 | ACTIVE | false |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 0 | OPEN |
// | backfill2 | 5 | 0 | OPEN |
// --------------------------------------------
// Requested SI VMs (alive requests): 8
// Spot price: lowBid (previousPrice+1)
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//New spot price is equal to lower bid
assertEquals(lowBid, rm.getSpotPrice());
//Check if submitted request is active
assertEquals(RequestState.STATE_Active, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());
assertEquals(0, backfillRequestsByCaller[1].getVMIds().length);
assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[1].getState().getStateStr());
logger.debug("Submitting SI request: mediumReq2");
//Submit another medium-bid SI Request
String medReq2Id = rm.requestSpotInstances(mediumReq2, caller2).getRequestID();
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests___________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | lowReq2 | 3 | 0 | previousPrice+1 | OPEN | true |
// | mediumReq1 | 3 | 3 | previousPrice+2 | ACTIVE | false |
// | lowReq3 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | mediumReq2 | 5 | 5 | previousPrice+2 | ACTIVE | true |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 0 | OPEN |
// | backfill2 | 5 | 0 | OPEN |
// --------------------------------------------
// Requested SI VMs (alive requests): 11
// Spot price: mediumBid (previousPrice+2)
Calendar ts4 = Calendar.getInstance();
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//New spot price is equal to medium bid
assertEquals(mediumBid, rm.getSpotPrice());
//Check if submitted request is active
assertEquals(RequestState.STATE_Active, rm.getSpotRequest(medReq2Id, caller2).getState().getStateStr());
//Check if previous medium-bid request is still active
assertEquals(RequestState.STATE_Active, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());
//Check if persistent lower-bid requests are open
assertEquals(RequestState.STATE_Open, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());
//Check if non-persistent lower-bid requests are closed
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());
assertEquals(0, backfillRequestsByCaller[1].getVMIds().length);
assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[1].getState().getStateStr());
logger.debug("Submitting SI request: highReq");
//Submit a higher-bid SI Request
String highReqId = rm.requestSpotInstances(highReq, caller3).getRequestID();
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests___________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | lowReq2 | 3 | 0 | previousPrice+1 | OPEN | true |
// | mediumReq1 | 3 | 0 | previousPrice+2 | CLOSED | false |
// | lowReq3 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | mediumReq2 | 5 | 0 | previousPrice+2 | OPEN | true |
// | highReq | 10 | 8 | previousPrice+3 | ACTIVE | false |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 0 | OPEN |
// | backfill2 | 5 | 0 | OPEN |
// --------------------------------------------
// Requested SI VMs (alive requests): 18
// Spot price: highBid (previousPrice+3)
Calendar ts5 = Calendar.getInstance();
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//New spot price is equal to high bid
assertEquals(highBid, rm.getSpotPrice());
//Check if submitted request is active
assertEquals(RequestState.STATE_Active, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());
//Check if persistent requests are open
assertEquals(RequestState.STATE_Open, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());
assertEquals(RequestState.STATE_Open, rm.getSpotRequest(medReq2Id, caller2).getState().getStateStr());
//Check if non-persistent requests are closed
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
assertEquals(0, backfillRequestsByCaller[0].getVMIds().length);
assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[0].getState().getStateStr());
assertEquals(0, backfillRequestsByCaller[1].getVMIds().length);
assertEquals(RequestState.STATE_Open, backfillRequestsByCaller[1].getState().getStateStr());
rm.cancelSpotInstanceRequests(new String[]{lowReq2Id}, caller1);
rm.cancelSpotInstanceRequests(new String[]{highReqId}, caller3);
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests_______________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | lowReq2 | 3 | 0 | previousPrice+1 | CANCELLED | true |
// | mediumReq1 | 3 | 0 | previousPrice+2 | CLOSED | false |
// | lowReq3 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | mediumReq2 | 5 | 0 | previousPrice+2 | OPEN | true |
// | highReq | 10 | 8 | previousPrice+3 | CANCELLED | false |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 0 | OPEN |
// | backfill2 | 5 | 0 | OPEN |
// --------------------------------------------
// Requested SI VMs (alive requests): 15
// Spot price: highBid (previousPrice+3)
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//New spot price is equal to minimum price
assertEquals(highBid, rm.getSpotPrice());
//Check if requests were cancelled
assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());
assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());
//Check if canceled request has allocated VMs
SpotRequestInfo highReq1 = rm.getSpotRequest(highReqId, caller3);
assertEquals(RequestState.STATE_Canceled, highReq1.getState().getStateStr());
assertEquals(8, highReq1.getVMIds().length);
//Check if persistent request is open
SpotRequestInfo medReq2 = rm.getSpotRequest(medReq2Id, caller2);
assertEquals(RequestState.STATE_Open, medReq2.getState().getStateStr());
assertEquals(0, medReq2.getVMIds().length);
//Check if non-persistent requests are closed
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
assertEquals(0, backfill1Result.getVMIds().length);
assertEquals(RequestState.STATE_Open, backfill1Result.getState().getStateStr());
backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
assertEquals(0, backfill2Result.getVMIds().length);
assertEquals(RequestState.STATE_Open, backfill2Result.getState().getStateStr());
//Trash 5 VMs from highReq
for (int i = 0; i < 5; i++) {
rm.trash(highReq1.getVMIds()[i], Manager.INSTANCE, caller3);
}
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests_______________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | lowReq2 | 3 | 0 | previousPrice+1 | CANCELLED | true |
// | mediumReq1 | 3 | 0 | previousPrice+2 | CLOSED | false |
// | lowReq3 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | mediumReq2 | 5 | 5 | previousPrice+2 | ACTIVE | true |
// | highReq | 10 | 3 | previousPrice+3 | CANCELLED | false |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 0 | OPEN |
// | backfill2 | 5 | 0 | OPEN |
// --------------------------------------------
// Requested SI VMs (alive requests): 8
// Spot price: mediumBid (previousPrice+2)
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//New spot price is equal to minimum price
assertEquals(mediumBid, rm.getSpotPrice());
//Check if requests were cancelled
assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());
assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());
//Check if canceled request has allocated VMs
highReq1 = rm.getSpotRequest(highReqId, caller3);
assertEquals(RequestState.STATE_Canceled, highReq1.getState().getStateStr());
assertEquals(3, highReq1.getVMIds().length);
//Check if persistent request is active
medReq2 = rm.getSpotRequest(medReq2Id, caller2);
assertEquals(RequestState.STATE_Active, medReq2.getState().getStateStr());
assertEquals(5, medReq2.getVMIds().length);
//Check if non-persistent requests are closed
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
assertEquals(0, backfill1Result.getVMIds().length);
assertEquals(RequestState.STATE_Open, backfill1Result.getState().getStateStr());
backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
assertEquals(0, backfill2Result.getVMIds().length);
assertEquals(RequestState.STATE_Open, backfill2Result.getState().getStateStr());
rm.trash(highReq1.getGroupID(), Manager.GROUP, caller3);
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests_______________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | lowReq2 | 3 | 0 | previousPrice+1 | CANCELLED | true |
// | mediumReq1 | 3 | 0 | previousPrice+2 | CLOSED | false |
// | lowReq3 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | mediumReq2 | 5 | 5 | previousPrice+2 | ACTIVE | true |
// | highReq | 10 | 0 | previousPrice+3 | CANCELLED | false |
// ---------------------------------------------------------------------------
// Backfill Requests__________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 2 | ACTIVE |
// | backfill2 | 5 | 1 | ACTIVE |
// --------------------------------------------
// Requested SI VMs (alive requests): 5
// Spot price: MINIMUM_PRICE
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//New spot price is equal to minimum price
assertEquals(MINIMUM_PRICE, rm.getSpotPrice());
//Check if requests were cancelled
assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(highReqId, caller3).getState().getStateStr());
assertEquals(RequestState.STATE_Canceled, rm.getSpotRequest(lowReq2Id, caller1).getState().getStateStr());
//Check if persistent request is active
medReq2 = rm.getSpotRequest(medReq2Id, caller2);
assertEquals(RequestState.STATE_Active, medReq2.getState().getStateStr());
assertEquals(5, medReq2.getVMIds().length);
//Check if non-persistent requests are closed
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq1Id, caller1).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(lowReq3Id, caller2).getState().getStateStr());
assertEquals(RequestState.STATE_Closed, rm.getSpotRequest(medReq1Id, caller2).getState().getStateStr());
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
assertEquals(2, backfill1Result.getVMIds().length);
assertEquals(RequestState.STATE_Active, backfill1Result.getState().getStateStr());
backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
assertEquals(1, backfill2Result.getVMIds().length);
assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());
rm.cancelBackfillRequests(new String[]{backfill1Result.getRequestID()}, superuser);
rm.trash(backfill1Result.getGroupID(), Manager.GROUP, superuser);
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests_______________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | lowReq2 | 3 | 0 | previousPrice+1 | CANCELLED | true |
// | mediumReq1 | 3 | 0 | previousPrice+2 | CLOSED | false |
// | lowReq3 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | mediumReq2 | 5 | 5 | previousPrice+2 | ACTIVE | true |
// | highReq | 10 | 0 | previousPrice+3 | CANCELLED | false |
// ---------------------------------------------------------------------------
// Backfill Requests______________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 0 | CANCELLED |
// | backfill2 | 5 | 3 | ACTIVE |
// -----------------------------------------------
// Requested SI VMs (alive requests): 5
// Spot price: MINIMUM_PRICE
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
assertEquals(0, backfill1Result.getVMIds().length);
assertEquals(RequestState.STATE_Canceled, backfill1Result.getState().getStateStr());
backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
assertEquals(3, backfill2Result.getVMIds().length);
assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());
rm.cancelSpotInstanceRequests(new String[]{medReq2Id}, caller2);
rm.trash(medReq2.getGroupID(), Manager.GROUP, caller2);
// Spot Instances Snapshot
//
// Total memory: 1280MB
// Reserved free memory (for ordinary WS requests): 256MB (minimum reserved capacity)
// Available basic SI VMs: 8 (128MB x 8 = 1024MB)
//
// Current Requests_______________________________________________________________
// | Request | reqVMs | allocVMs | Bid | Status | Persistent |
// | lowReq1 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | lowReq2 | 3 | 0 | previousPrice+1 | CANCELLED | true |
// | mediumReq1 | 3 | 0 | previousPrice+2 | CLOSED | false |
// | lowReq3 | 1 | 0 | previousPrice+1 | CLOSED | false |
// | mediumReq2 | 5 | 0 | previousPrice+2 | CANCELLED | true |
// | highReq | 10 | 0 | previousPrice+3 | CANCELLED | false |
// ---------------------------------------------------------------------------
// Backfill Requests______________________________
// | Request | reqVMs | allocVMs | Status |
// | backfill1 | 3 | 0 | CANCELLED |
// | backfill2 | 5 | 5 | ACTIVE |
// -----------------------------------------------
// Requested SI VMs (alive requests): 0
// Spot price: MINIMUM_PRICE
logger.debug("Waiting 10 seconds for resources to be pre-empted.");
Thread.sleep(10000);
//Check if persistent request was cancelled
medReq2 = rm.getSpotRequest(medReq2Id, caller2);
assertEquals(RequestState.STATE_Canceled, medReq2.getState().getStateStr());
assertEquals(0, medReq2.getVMIds().length);
//Check backfill request state
backfillRequestsByCaller = rm.getBackfillRequestsByCaller(superuser);
assertEquals(2, backfillRequestsByCaller.length);
backfill1Result = rm.getBackfillRequest(backfill1Result.getRequestID(), superuser);
assertEquals(0, backfill1Result.getVMIds().length);
assertEquals(RequestState.STATE_Canceled, backfill1Result.getState().getStateStr());
backfill2Result = rm.getBackfillRequest(backfill2Result.getRequestID(), superuser);
assertEquals(5, backfill2Result.getVMIds().length);
assertEquals(RequestState.STATE_Active, backfill2Result.getState().getStateStr());
//Expected prices from full history
Double[] prices = new Double[]{MINIMUM_PRICE, lowBid, mediumBid, highBid, mediumBid, MINIMUM_PRICE};