pratyakshsharma commented on a change in pull request #1453: HUDI-644 kafka connect checkpoint provider URL: https://github.com/apache/incubator-hudi/pull/1453#discussion_r399218307
########## File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/sources/checkpoint/TestCheckPointProvider.java ########## @@ -0,0 +1,73 @@ +/* + * 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.hudi.utilities.sources.checkpoint; + +import org.apache.hudi.common.HoodieCommonTestHarness; +import org.apache.hudi.common.model.HoodieTestUtils; +import org.apache.hudi.common.util.FSUtils; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; + +import static org.junit.Assert.assertEquals; + +public class TestCheckPointProvider extends HoodieCommonTestHarness { + private FileSystem fs = null; + private String topicPath = null; + + @Before + public void init() { + // Prepare directories + initPath(); + topicPath = basePath + "/topic1"; + final Configuration hadoopConf = HoodieTestUtils.getDefaultHadoopConf(); + fs = FSUtils.getFs(basePath, hadoopConf); + new File(topicPath).mkdirs(); + } + + @Test + public void testKafkaConnectHdfsProvider() throws Exception { + // create regular kafka connect hdfs dirs + new File(topicPath + "/year=2016/month=05/day=01/").mkdirs(); + new File(topicPath + "/year=2016/month=05/day=02/").mkdirs(); + // kafka connect tmp folder + new File(topicPath + "/TMP").mkdirs(); + // tmp file that being written + new File(topicPath + "/TMP/" + "topic1+0+301+400.parquet").createNewFile(); + // regular parquet files + new File(topicPath + "/year=2016/month=05/day=01/" + + "topic1+0+100+200.parquet").createNewFile(); + new File(topicPath + "/year=2016/month=05/day=01/" + + "topic1+1+100+200.parquet").createNewFile(); + new File(topicPath + "/year=2016/month=05/day=02/" + + "topic1+0+201+300.parquet").createNewFile(); + // noise parquet file + new File(topicPath + "/year=2016/month=05/day=01/" + + "random_snappy_1.parquet").createNewFile(); + new File(topicPath + "/year=2016/month=05/day=02/" + + "random_snappy_2.parquet").createNewFile(); + CheckPointProvider c = new KafkaConnectHdfsProvider(new Path(topicPath), fs); + assertEquals(c.getCheckpoint(), "topic1,0:300,1:200"); Review comment: for partition 0, the offset should be 400? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
