majian1998 commented on code in PR #17013:
URL: https://github.com/apache/iceberg/pull/17013#discussion_r3504257906


##########
core/src/test/java/org/apache/iceberg/hadoop/TestHadoopTableOperations.java:
##########
@@ -0,0 +1,385 @@
+/*
+ * 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.hadoop;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FSInputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.PathFilter;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.util.Progressable;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.junit.jupiter.api.Test;
+
+public class TestHadoopTableOperations {
+  @Test
+  public void testVersionHintRetryBeforeMetadataScan() {
+    Configuration conf = new Configuration();
+    conf.setInt(ConfigProperties.VERSION_HINT_NUM_RETRIES, 2);
+    conf.setLong(ConfigProperties.VERSION_HINT_RETRY_MIN_WAIT_MS, 0L);
+
+    TestingFileSystem fs = new TestingFileSystem();
+    fs.addDirectory("metadata");
+    fs.addFile("v3.metadata.json", "");
+    fs.addVersionHintAvailableAfterAttempt(3, "7");
+
+    HadoopTableOperations ops = newTableOps(conf, fs);
+
+    assertThat(ops.findVersion()).isEqualTo(7);
+    assertThat(fs.versionHintOpenAttempts()).isEqualTo(3);
+    assertThat(fs.metadataRootExistsCalls()).isEqualTo(1);
+    assertThat(fs.listStatusCalls()).isZero();
+  }
+
+  @Test
+  public void testVersionHintRetriesCanBeDisabled() {
+    Configuration conf = new Configuration();
+    conf.setInt(ConfigProperties.VERSION_HINT_NUM_RETRIES, 0);
+
+    TestingFileSystem fs = new TestingFileSystem();
+    fs.addDirectory("metadata");
+    fs.addFile("v1.metadata.json", "");
+    fs.addFile("v3.metadata.json", "");
+
+    HadoopTableOperations ops = newTableOps(conf, fs);
+
+    assertThat(ops.findVersion()).isEqualTo(3);
+    assertThat(fs.versionHintOpenAttempts()).isEqualTo(1);
+    assertThat(fs.metadataRootExistsCalls()).isEqualTo(1);
+    assertThat(fs.listStatusCalls()).isEqualTo(1);
+  }
+
+  @Test
+  public void testConfirmedMetadataRootIsNotCheckedAgainBeforeFallbackScan() {
+    Configuration conf = new Configuration();
+    conf.setInt(ConfigProperties.VERSION_HINT_NUM_RETRIES, 2);
+    conf.setLong(ConfigProperties.VERSION_HINT_RETRY_MIN_WAIT_MS, 0L);
+
+    TestingFileSystem fs = new TestingFileSystem();
+    fs.addDirectory("metadata");
+    fs.addFile("v3.metadata.json", "");
+    fs.failMetadataRootExistsAfterCall(1);

Review Comment:
   This branch was removed as part of the fallback simplification, so the extra 
test is no longer needed.



-- 
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]

Reply via email to