Description
When AwsDomainStoreTest testAwsSyncerInitBadRegion runs locally it fails with an SdkClientException because it tries to make a call to an endpoint with an invalid region (e.g., https://s3.MARS.amazonaws.com/). However, in some CI/CD environments the exception is different: AwsServiceException, specifically S3Exception. These exceptions effectively mean the same thing -- a bad region (MARS) causes a connection failure.
Proposed Solution
Modify unit test to include AwsServiceException and add a finally block to ensure system properties are cleared.
catch (Exception e) {
assertTrue(e instanceof SdkClientException || e instanceof AwsServiceException, "Expected SdkClientException or AwsServiceException, got: " + e.getClass().getName());
} finally {
System.clearProperty(Config.PROP_PREFIX + Config.SYNC_CFG_PARAM_ROOT_PATH);
System.clearProperty(Config.PROP_PREFIX + Config.SYNC_CFG_PARAM_AWS_ACCESS_KEY);
System.clearProperty(Config.PROP_PREFIX + Config.SYNC_CFG_PARAM_AWS_KEY_ID);
System.clearProperty(Config.PROP_PREFIX + Config.SYNC_CFG_PARAM_AWS_S3_REGION);
}
DescriptionWhen AwsDomainStoreTest testAwsSyncerInitBadRegion runs locally it fails with an
SdkClientExceptionbecause it tries to make a call to an endpoint with an invalid region (e.g.,https://s3.MARS.amazonaws.com/). However, in some CI/CD environments the exception is different:AwsServiceException, specificallyS3Exception. These exceptions effectively mean the same thing -- a bad region (MARS) causes a connection failure.Proposed Solution
Modify unit test to include
AwsServiceExceptionand add a finally block to ensure system properties are cleared.