Map<InstanceType, InstanceTypeDescription> instanceTypeDescriptions = cm.getMapOfAvailableInstanceTypes();
assertEquals(1, instanceTypeDescriptions.size());
InstanceTypeDescription descr = instanceTypeDescriptions.entrySet().iterator().next().getValue();
assertEquals(3, descr.getMaximumNumberOfAvailableInstances());
// request some instances
JobID jobID = new JobID();
Configuration conf = new Configuration();
InstanceRequestMap instancem = new InstanceRequestMap();
instancem.setNumberOfInstances(cm.getDefaultInstanceType(), 1);
cm.requestInstance(jobID, conf, instancem, null);
ClusterManagerTestUtils.waitForInstances(jobID, testInstanceListener, 1, 1000);
assertEquals(1, testInstanceListener.getNumberOfAllocatedResourcesForJob(jobID));
// wait for the cleanup to kick in
Thread.sleep(2000 * CLEANUP_INTERVAL);
// check that the instances are gone
ClusterManagerTestUtils.waitForInstances(jobID, testInstanceListener, 0, 1000);
assertEquals(0, testInstanceListener.getNumberOfAllocatedResourcesForJob(jobID));
instanceTypeDescriptions = cm.getMapOfAvailableInstanceTypes();
assertEquals(1, instanceTypeDescriptions.size());
descr = instanceTypeDescriptions.entrySet().iterator().next().getValue();
assertEquals(0, descr.getMaximumNumberOfAvailableInstances());
cm.shutdown();
}
catch (Exception e) {
System.err.println(e.getMessage());