xndai commented on code in PR #17400:
URL: https://github.com/apache/iceberg/pull/17400#discussion_r3670602062
##########
aws/src/test/java/org/apache/iceberg/aws/s3/TestS3InputStream.java:
##########
@@ -44,22 +48,40 @@ public final class TestS3InputStream {
@BeforeEach
void before() {
- when(s3Client.getObject(any(GetObjectRequest.class),
any(ResponseTransformer.class)))
- .thenReturn(inputStream);
s3InputStream = new S3InputStream(s3Client, mock());
}
@Test
void testReadFullyClosesTheStream() throws IOException {
+ when(s3Client.getObject(any(GetObjectRequest.class),
any(ResponseTransformer.class)))
+ .thenReturn(inputStream);
+
s3InputStream.readFully(0, new byte[0]);
verify(inputStream).close();
}
@Test
void testReadTailClosesTheStream() throws IOException {
+ when(s3Client.getObject(any(GetObjectRequest.class),
any(ResponseTransformer.class)))
+ .thenReturn(inputStream);
+
s3InputStream.readTail(new byte[0], 0, 0);
verify(inputStream).close();
}
+
+ @Test
+ void testAccessDeniedTranslatedToForbiddenException() {
+ when(s3Client.getObject(any(GetObjectRequest.class),
any(ResponseTransformer.class)))
+ .thenThrow(
+ S3Exception.builder()
+ .statusCode(HttpStatusCode.FORBIDDEN)
+ .message("Access Denied")
+ .build());
+
+ assertThatThrownBy(() -> s3InputStream.readFully(0, new byte[0]))
+ .isInstanceOf(ForbiddenException.class)
+ .hasMessageContaining("Access Denied");
Review Comment:
Should we validate message content here? The exception message could change
in the future.
##########
core/src/test/java/org/apache/iceberg/TestBaseMetastoreTableOperations.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.iceberg.exceptions.ForbiddenException;
+import org.apache.iceberg.exceptions.NotFoundException;
+import org.apache.iceberg.io.FileIO;
+import org.junit.jupiter.api.Test;
+
+public class TestBaseMetastoreTableOperations {
Review Comment:
Class name is very general. But you are only testing the retries on
transient error and un-recoverable errors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]