use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class StorageUnitDaoHelperTest method testGetStorageUnitEntityByKeyStorageUnitNoExists.
@Test
public void testGetStorageUnitEntityByKeyStorageUnitNoExists() {
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Create a storage unit key.
BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME);
// Mock the external calls.
when(storageUnitDao.getStorageUnitByKey(businessObjectDataStorageUnitKey)).thenReturn(null);
// Try to call the method under test.
try {
storageUnitDaoHelper.getStorageUnitEntityByKey(businessObjectDataStorageUnitKey);
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object data storage unit {%s, storageName: \"%s\"} doesn't exist.", businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey), STORAGE_NAME), e.getMessage());
}
// Verify the external calls.
verify(storageUnitDao).getStorageUnitByKey(businessObjectDataStorageUnitKey);
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class StorageFileHelperTest method testValidateRegisteredS3FilesActualFileNoExists.
@Test
public void testValidateRegisteredS3FilesActualFileNoExists() throws IOException {
// Create two lists of expected and actual storage files, with one expected file not being added to the list of actual files.
List<StorageFile> testExpectedFiles = Arrays.asList(new StorageFile(TARGET_S3_KEY, FILE_SIZE, ROW_COUNT_1000));
List<S3ObjectSummary> testActualFiles = new ArrayList<>();
// Try to validate S3 files when expected S3 file does not exist.
try {
storageFileHelper.validateRegisteredS3Files(testExpectedFiles, testActualFiles, STORAGE_NAME, new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION));
fail("Should throw an ObjectNotFoundException when the registered S3 file does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Registered file \"%s\" does not exist in \"%s\" storage.", TARGET_S3_KEY, STORAGE_NAME), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceAlgorithmicMaxSearchPriceTooLowAndSpotPriceNotAvailable.
/**
* Tests algorithmic case when the max search price is lower than on-demand price and spot price is not available. The update method should throw an error
* indicating that no subnets satisfied the given criteria.
*/
@Test
public void testBestPriceAlgorithmicMaxSearchPriceTooLowAndSpotPriceNotAvailable() {
String subnetId = SUBNET_1;
// For master instance definition, use instance type that does not have spot price available.
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_4);
masterInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND_LESS_ONE);
InstanceDefinition coreInstanceDefinition = null;
InstanceDefinition taskInstanceDefinition = null;
// Try with master failing criteria
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail();
} catch (ObjectNotFoundException e) {
// Set expected EMR VPC price state.
EmrVpcPricingState expectedEmrVpcPricingState = new EmrVpcPricingState();
expectedEmrVpcPricingState.setSubnetAvailableIpAddressCounts(new HashMap<String, Integer>() {
{
put(SUBNET_1, 10);
}
});
expectedEmrVpcPricingState.setSpotPricesPerAvailabilityZone(new HashMap<String, Map<String, BigDecimal>>() {
{
put(AVAILABILITY_ZONE_1, new HashMap<>());
}
});
expectedEmrVpcPricingState.setOnDemandPricesPerAvailabilityZone(new HashMap<String, Map<String, BigDecimal>>() {
{
put(AVAILABILITY_ZONE_1, new HashMap<String, BigDecimal>() {
{
put(INSTANCE_TYPE_4, ON_DEMAND);
}
});
}
});
assertEquals(String.format("There were no subnets which satisfied your best price search criteria. If you explicitly opted to use spot EC2 instances, please confirm " + "that your instance types support spot pricing. Otherwise, try setting the max price or the on-demand threshold to a higher value.%n%s", emrVpcPricingStateFormatter.format(expectedEmrVpcPricingState)), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceAlgorithmicMaxSearchPriceTooLow.
/**
* Tests algorithmic case when the max search price is lower than both spot and on-demand price. The update method should throw an error indicating that no
* subnets satisfied the given criteria.
* <p/>
* Test case reference ClusterSpotPriceAlgorithm 3
*/
@Test
public void testBestPriceAlgorithmicMaxSearchPriceTooLow() {
String subnetId = SUBNET_1;
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
masterInstanceDefinition.setInstanceMaxSearchPrice(SPOT_PRICE_LOW_LESS_ONE);
InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
coreInstanceDefinition.setInstanceCount(1);
coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
coreInstanceDefinition.setInstanceMaxSearchPrice(SPOT_PRICE_LOW_LESS_ONE);
InstanceDefinition taskInstanceDefinition = new InstanceDefinition();
taskInstanceDefinition.setInstanceCount(1);
taskInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
taskInstanceDefinition.setInstanceMaxSearchPrice(SPOT_PRICE_LOW_LESS_ONE);
// Try with both master, core, and task failing criteria
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("Expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
// Now try with only core and task failing criteria
masterInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND);
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("Expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
// Try with only task failing criteria
coreInstanceDefinition.setInstanceMaxSearchPrice(ON_DEMAND);
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("Expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class EmrPricingHelperTest method testBestPriceSubnetNotFound.
/**
* Tests case where at least one user specified subnet does not exist. This is a user error.
*/
@Test
public void testBestPriceSubnetNotFound() {
String subnetId = "I_DO_NOT_EXIST," + SUBNET_1;
MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
masterInstanceDefinition.setInstanceCount(1);
masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
coreInstanceDefinition.setInstanceCount(1);
coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
InstanceDefinition taskInstanceDefinition = null;
try {
updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
fail("expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", ObjectNotFoundException.class, e.getClass());
}
}
Aggregations