You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "nastra (via GitHub)" <gi...@apache.org> on 2023/05/03 06:58:18 UTC

[GitHub] [iceberg] nastra commented on a diff in pull request #7505: Move all S3FileIO related properties into a separate class S3FileIOProperties

nastra commented on code in PR #7505:
URL: https://github.com/apache/iceberg/pull/7505#discussion_r1183300340


##########
aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java:
##########
@@ -0,0 +1,394 @@
+/*
+ * 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.aws.s3;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.assertj.core.api.Assertions;
+import org.junit.Assert;
+import org.junit.Test;
+import software.amazon.awssdk.services.s3.model.ObjectCannedACL;
+import software.amazon.awssdk.services.s3.model.Tag;
+
+public class TestS3FileIOProperties {
+  private static final String S3_TEST_BUCKET_NAME = "my_bucket";
+  private static final String S3_TEST_BUCKET_ACCESS_POINT = "access_point";
+  private static final String S3_WRITE_TAG_KEY = "my_key";
+  private static final String S3_WRITE_TAG_VALUE = "my_value";
+  private static final String S3_DELETE_TAG_KEY = "my_key";
+  private static final String S3_DELETE_TAG_VALUE = "my_value";
+
+  @Test
+  public void testS3FileIOPropertiesDefaultValues() {
+    S3FileIOProperties s3FileIOProperties = new S3FileIOProperties();
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3FILEIO_SSE_TYPE_NONE, s3FileIOProperties.s3FileIoSseType());
+
+    Assert.assertNull(s3FileIOProperties.s3FileIoSseKey());
+    Assert.assertNull(s3FileIOProperties.s3FileIoSseMd5());
+    Assert.assertNull(s3FileIOProperties.s3AccessKeyId());
+    Assert.assertNull(s3FileIOProperties.s3SecretAccessKey());
+    Assert.assertNull(s3FileIOProperties.s3SessionToken());
+    Assert.assertNull(s3FileIOProperties.s3FileIoAcl());
+    Assert.assertNull(s3FileIOProperties.s3Endpoint());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_PRELOAD_CLIENT_ENABLED_DEFAULT,
+        s3FileIOProperties.s3PreloadClientEnabled());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_DUALSTACK_ENABLED_DEFAULT, s3FileIOProperties.isS3DualStackEnabled());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3FILEIO_PATH_STYLE_ACCESS_DEFAULT,
+        s3FileIOProperties.isS3PathStyleAccess());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_USE_ARN_REGION_ENABLED_DEFAULT,
+        s3FileIOProperties.isS3UseArnRegionEnabled());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_ACCELERATION_ENABLED_DEFAULT,
+        s3FileIOProperties.isS3AccelerationEnabled());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_REMOTE_SIGNING_ENABLED_DEFAULT,
+        s3FileIOProperties.isS3RemoteSigningEnabled());
+
+    Assert.assertEquals(
+        Runtime.getRuntime().availableProcessors(),
+        s3FileIOProperties.s3FileIoMultipartUploadThreads());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3FILEIO_MULTIPART_SIZE_DEFAULT,
+        s3FileIOProperties.s3FileIoMultiPartSize());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3FILEIO_MULTIPART_THRESHOLD_FACTOR_DEFAULT,
+        s3FileIOProperties.s3FileIOMultipartThresholdFactor(),
+        0.0);
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3FILEIO_DELETE_BATCH_SIZE_DEFAULT,
+        s3FileIOProperties.s3FileIoDeleteBatchSize(),
+        0.0);
+
+    Assert.assertEquals(
+        System.getProperty("java.io.tmpdir"), s3FileIOProperties.s3fileIoStagingDirectory());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_CHECKSUM_ENABLED_DEFAULT, s3FileIOProperties.isS3ChecksumEnabled());
+
+    Assert.assertEquals(Sets.newHashSet(), s3FileIOProperties.s3WriteTags());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_WRITE_TABLE_TAG_ENABLED_DEFAULT,
+        s3FileIOProperties.s3WriteTableTagEnabled());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_WRITE_NAMESPACE_TAG_ENABLED_DEFAULT,
+        s3FileIOProperties.s3WriteNamespaceTagEnabled());
+
+    Assert.assertEquals(Sets.newHashSet(), s3FileIOProperties.s3DeleteTags());
+
+    Assert.assertEquals(
+        Runtime.getRuntime().availableProcessors(), s3FileIOProperties.s3FileIoDeleteThreads());
+
+    Assert.assertEquals(
+        S3FileIOProperties.S3_DELETE_ENABLED_DEFAULT, s3FileIOProperties.isS3DeleteEnabled());
+
+    Assert.assertEquals(Collections.emptyMap(), s3FileIOProperties.s3BucketToAccessPointMapping());
+  }
+
+  @Test
+  public void testS3FileIOProperties() {
+    Map<String, String> map = getTestProperties();
+    S3FileIOProperties s3FileIOProperties = new S3FileIOProperties(map);
+
+    Assert.assertEquals(

Review Comment:
   I think a slightly better alternative to testing this would be: `Assertions.assertThat(map).containsEntry(S3FileIOProperties.S3FILEIO_SSE_TYPE), s3FileIOProperties.s3FileIoSseType())`.
   
   The main advantage here is that it will show the content of `map` in case the assertion ever fails.



##########
aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java:
##########
@@ -0,0 +1,394 @@
+/*
+ * 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.aws.s3;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.iceberg.exceptions.ValidationException;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.assertj.core.api.Assertions;
+import org.junit.Assert;
+import org.junit.Test;

Review Comment:
   given that we're adding a new test class I think it makes sense to use JUnit5 rather than JUnit4 tests here and potentially also switch to AssertJ rather than using `Assert` from JUnit4 as this will make a future port of the codebase to JUnit5 easier. See also https://iceberg.apache.org/contribute/#testing for some additional information on these topics



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org