Skip to content

Commit

Permalink
fix: updating integ test to check at correct point (#213)
Browse files Browse the repository at this point in the history
## Description of change
Last integration test run failed because we moved from throwing a file
not found error on read to creation instead.

#### How was the contribution tested?
Tested locally and this passes.

---

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and I agree to the terms of
the [Developer Certificate of Origin
(DCO)](https://developercertificate.org/).
  • Loading branch information
stubz151 authored Jan 29, 2025
1 parent 85b56aa commit 1f59169
Showing 1 changed file with 3 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import static org.junit.jupiter.api.Assertions.assertThrows;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.stream.Stream;
Expand All @@ -26,7 +25,6 @@
import org.junit.jupiter.params.provider.MethodSource;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.s3.analyticsaccelerator.S3SdkObjectClient;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStream;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStreamConfiguration;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStreamFactory;
import software.amazon.s3.analyticsaccelerator.util.S3URI;
Expand All @@ -35,54 +33,19 @@ public class ExceptionCorrectnessTest extends IntegrationTestBase {

private static final String NON_EXISTENT_OBJECT = "non-existent.bin";

private enum ReadMethod {
SIMPLE_READ {
@SuppressFBWarnings(
value = "RR_NOT_CHECKED",
justification = "Test only cares about exception throwing, not the actual bytes read")
void doRead(S3SeekableInputStream stream) throws IOException {
stream.read();
}
},
BUFFER_READ {
@SuppressFBWarnings(
value = "RR_NOT_CHECKED",
justification = "Test only cares about exception throwing, not the actual bytes read")
void doRead(S3SeekableInputStream stream) throws IOException {
stream.read(new byte[10], 0, 10);
}
},
TAIL_READ {
@SuppressFBWarnings(
value = "RR_NOT_CHECKED",
justification = "Test only cares about exception throwing, not the actual bytes read")
void doRead(S3SeekableInputStream stream) throws IOException {
stream.readTail(new byte[10], 0, 10);
}
};

abstract void doRead(S3SeekableInputStream stream) throws IOException;
}

@ParameterizedTest
@MethodSource("provideTestParameters")
void testNonExistentObjectThrowsRightException(S3ClientKind clientKind, ReadMethod readMethod)
throws IOException {
void testNonExistentObjectThrowsRightException(S3ClientKind clientKind) throws IOException {
final S3ExecutionConfiguration config = this.getS3ExecutionContext().getConfiguration();
final S3URI nonExistentURI =
S3URI.of(config.getBucket(), config.getPrefix() + NON_EXISTENT_OBJECT);
S3AsyncClient s3AsyncClient = clientKind.getS3Client(getS3ExecutionContext());
S3SeekableInputStreamFactory factory = createInputStreamFactory(s3AsyncClient);
S3SeekableInputStream inputStream = factory.createStream(nonExistentURI);
assertThrows(FileNotFoundException.class, () -> readMethod.doRead(inputStream));
assertThrows(FileNotFoundException.class, () -> factory.createStream(nonExistentURI));
}

private static Stream<Arguments> provideTestParameters() {
return getS3ClientKinds().stream()
.flatMap(
clientKind ->
Stream.of(ReadMethod.values())
.map(readMethod -> Arguments.of(clientKind, readMethod)));
return getS3ClientKinds().stream().map(Arguments::of);
}

private static S3SeekableInputStreamFactory createInputStreamFactory(
Expand Down

0 comments on commit 1f59169

Please sign in to comment.