[HUDI-265] Failed to delete tmp dirs created in unit tests (#928)
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.common;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
import org.apache.hudi.common.table.HoodieTimeline;
|
||||
import org.apache.hudi.common.table.SyncableFileSystemView;
|
||||
import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class HoodieCommonTestHarness {
|
||||
|
||||
protected String basePath = null;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
protected transient HoodieTableMetaClient metaClient;
|
||||
|
||||
/**
|
||||
* Initializes basePath.
|
||||
*/
|
||||
protected void initPath() {
|
||||
this.basePath = folder.getRoot().getAbsolutePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an instance of {@link HoodieTableMetaClient} with a special table type
|
||||
* specified by {@code getTableType()}.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void initMetaClient() throws IOException {
|
||||
metaClient = HoodieTestUtils.init(folder.getRoot().getAbsolutePath(), getTableType());
|
||||
basePath = metaClient.getBasePath();
|
||||
}
|
||||
|
||||
protected void refreshFsView() throws IOException {
|
||||
metaClient = new HoodieTableMetaClient(metaClient.getHadoopConf(), basePath, true);
|
||||
}
|
||||
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTimeline timeline) throws IOException {
|
||||
return getFileSystemView(timeline, false);
|
||||
}
|
||||
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTimeline timeline, boolean enableIncrementalTimelineSync) {
|
||||
return new HoodieTableFileSystemView(metaClient, timeline, enableIncrementalTimelineSync);
|
||||
}
|
||||
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTableMetaClient metaClient)
|
||||
throws IOException {
|
||||
return getFileSystemView(metaClient, metaClient.getActiveTimeline().filterCompletedAndCompactionInstants());
|
||||
}
|
||||
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTableMetaClient metaClient, HoodieTimeline timeline)
|
||||
throws IOException {
|
||||
return getFileSystemView(timeline, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a default {@link HoodieTableType#COPY_ON_WRITE} table type.
|
||||
* Sub-classes can override this method to specify a new table type.
|
||||
*
|
||||
* @return an instance of Hoodie table type.
|
||||
*/
|
||||
protected HoodieTableType getTableType() {
|
||||
return HoodieTableType.COPY_ON_WRITE;
|
||||
}
|
||||
}
|
||||
@@ -31,28 +31,20 @@ import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.io.SequenceFile;
|
||||
import org.apache.hadoop.io.Text;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
|
||||
import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
|
||||
import org.apache.hudi.common.table.timeline.HoodieInstant;
|
||||
import org.apache.hudi.common.util.Option;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class HoodieTableMetaClientTest {
|
||||
public class HoodieTableMetaClientTest extends HoodieCommonTestHarness {
|
||||
|
||||
private HoodieTableMetaClient metaClient;
|
||||
private String basePath;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||
|
||||
@Before
|
||||
public void init() throws IOException {
|
||||
metaClient = HoodieTestUtils.init(tmpFolder.getRoot().getAbsolutePath());
|
||||
basePath = metaClient.getBasePath();
|
||||
initMetaClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.minicluster.MiniClusterUtil;
|
||||
import org.apache.hudi.common.model.HoodieArchivedLogFile;
|
||||
import org.apache.hudi.common.model.HoodieKey;
|
||||
@@ -65,21 +66,20 @@ import org.apache.hudi.common.util.FSUtils;
|
||||
import org.apache.hudi.common.util.HoodieAvroUtils;
|
||||
import org.apache.hudi.common.util.SchemaTestUtil;
|
||||
import org.apache.hudi.exception.CorruptedLogFileException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@RunWith(Parameterized.class)
|
||||
public class HoodieLogFormatTest {
|
||||
public class HoodieLogFormatTest extends HoodieCommonTestHarness {
|
||||
|
||||
private static final String BASE_OUTPUT_PATH = "/tmp/";
|
||||
private static String basePath;
|
||||
private static String BASE_OUTPUT_PATH = "/tmp/";
|
||||
private FileSystem fs;
|
||||
private Path partitionPath;
|
||||
private int bufferSize = 4096;
|
||||
@@ -108,8 +108,7 @@ public class HoodieLogFormatTest {
|
||||
@Before
|
||||
public void setUp() throws IOException, InterruptedException {
|
||||
this.fs = MiniClusterUtil.fileSystem;
|
||||
TemporaryFolder folder = new TemporaryFolder();
|
||||
folder.create();
|
||||
|
||||
assertTrue(fs.mkdirs(new Path(folder.getRoot().getPath())));
|
||||
this.partitionPath = new Path(folder.getRoot().getPath());
|
||||
this.basePath = folder.getRoot().getParent();
|
||||
|
||||
@@ -24,8 +24,9 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
import org.apache.hudi.common.table.HoodieTimeline;
|
||||
import org.apache.hudi.common.table.timeline.HoodieActiveTimeline;
|
||||
import org.apache.hudi.common.table.timeline.HoodieInstant;
|
||||
@@ -34,20 +35,16 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class HoodieActiveTimelineTest {
|
||||
public class HoodieActiveTimelineTest extends HoodieCommonTestHarness {
|
||||
|
||||
private HoodieActiveTimeline timeline;
|
||||
private HoodieTableMetaClient metaClient;
|
||||
@Rule
|
||||
public final ExpectedException exception = ExpectedException.none();
|
||||
@Rule
|
||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.metaClient = HoodieTestUtils.init(tmpFolder.getRoot().getAbsolutePath());
|
||||
initMetaClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,6 +38,7 @@ import java.util.stream.Stream;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hudi.avro.model.HoodieCompactionPlan;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.CompactionOperation;
|
||||
import org.apache.hudi.common.model.FileSlice;
|
||||
import org.apache.hudi.common.model.HoodieDataFile;
|
||||
@@ -45,8 +46,6 @@ import org.apache.hudi.common.model.HoodieFileGroup;
|
||||
import org.apache.hudi.common.model.HoodieFileGroupId;
|
||||
import org.apache.hudi.common.model.HoodieLogFile;
|
||||
import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
import org.apache.hudi.common.table.HoodieTimeline;
|
||||
import org.apache.hudi.common.table.SyncableFileSystemView;
|
||||
import org.apache.hudi.common.table.TableFileSystemView;
|
||||
@@ -62,50 +61,38 @@ import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class HoodieTableFileSystemViewTest {
|
||||
public class HoodieTableFileSystemViewTest extends HoodieCommonTestHarness {
|
||||
|
||||
private static final transient Logger log = LogManager.getLogger(HoodieTableFileSystemViewTest.class);
|
||||
|
||||
private static String TEST_WRITE_TOKEN = "1-0-1";
|
||||
|
||||
protected HoodieTableMetaClient metaClient;
|
||||
protected String basePath;
|
||||
protected SyncableFileSystemView fsView;
|
||||
protected TableFileSystemView.ReadOptimizedView roView;
|
||||
protected TableFileSystemView.RealtimeView rtView;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||
|
||||
@Before
|
||||
public void init() throws IOException {
|
||||
initializeMetaClient();
|
||||
initMetaClient();
|
||||
refreshFsView();
|
||||
}
|
||||
|
||||
protected void initializeMetaClient() throws IOException {
|
||||
metaClient = HoodieTestUtils.init(tmpFolder.getRoot().getAbsolutePath(), HoodieTableType.MERGE_ON_READ);
|
||||
basePath = metaClient.getBasePath();
|
||||
}
|
||||
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTimeline timeline) throws IOException {
|
||||
return new HoodieTableFileSystemView(metaClient, timeline);
|
||||
}
|
||||
|
||||
protected void refreshFsView() throws IOException {
|
||||
metaClient = new HoodieTableMetaClient(metaClient.getHadoopConf(), basePath, true);
|
||||
super.refreshFsView();
|
||||
closeFsView();
|
||||
fsView = getFileSystemView(metaClient.getActiveTimeline().filterCompletedAndCompactionInstants());
|
||||
roView = fsView;
|
||||
rtView = fsView;
|
||||
}
|
||||
|
||||
private void closeFsView() {
|
||||
if (null != fsView) {
|
||||
fsView.close();
|
||||
fsView = null;
|
||||
}
|
||||
fsView = getFileSystemView(metaClient.getActiveTimeline().filterCompletedAndCompactionInstants());
|
||||
roView = (TableFileSystemView.ReadOptimizedView) fsView;
|
||||
rtView = (TableFileSystemView.RealtimeView) fsView;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1185,4 +1172,9 @@ public class HoodieTableFileSystemViewTest {
|
||||
Assert.assertEquals(1, fileIdsInCompaction.size());
|
||||
Assert.assertTrue(fileIdsInCompaction.contains(fileId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HoodieTableType getTableType() {
|
||||
return HoodieTableType.MERGE_ON_READ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.apache.hudi.avro.model.HoodieCompactionPlan;
|
||||
import org.apache.hudi.avro.model.HoodieRestoreMetadata;
|
||||
import org.apache.hudi.avro.model.HoodieRollbackMetadata;
|
||||
import org.apache.hudi.common.HoodieCleanStat;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.HoodieRollbackStat;
|
||||
import org.apache.hudi.common.model.CompactionOperation;
|
||||
import org.apache.hudi.common.model.FileSlice;
|
||||
@@ -50,7 +51,6 @@ import org.apache.hudi.common.model.HoodieDataFile;
|
||||
import org.apache.hudi.common.model.HoodieFileGroup;
|
||||
import org.apache.hudi.common.model.HoodieFileGroupId;
|
||||
import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.model.HoodieWriteStat;
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
import org.apache.hudi.common.table.HoodieTimeline;
|
||||
@@ -67,62 +67,36 @@ import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class IncrementalFSViewSyncTest {
|
||||
public class IncrementalFSViewSyncTest extends HoodieCommonTestHarness {
|
||||
|
||||
private static final transient Logger log = LogManager.getLogger(IncrementalFSViewSyncTest.class);
|
||||
|
||||
private static String TEST_WRITE_TOKEN = "1-0-1";
|
||||
|
||||
protected HoodieTableMetaClient metaClient;
|
||||
protected String basePath;
|
||||
|
||||
private final List<String> partitions = Arrays.asList("2018/01/01", "2018/01/02",
|
||||
"2019/03/01");
|
||||
private final List<String> fileIdsPerPartition =
|
||||
IntStream.range(0, 10).mapToObj(x -> UUID.randomUUID().toString()).collect(Collectors.toList());
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||
|
||||
@Before
|
||||
public void init() throws IOException {
|
||||
initializeMetaClient();
|
||||
refreshFsView();
|
||||
}
|
||||
|
||||
protected void initializeMetaClient() throws IOException {
|
||||
metaClient = HoodieTestUtils.init(tmpFolder.getRoot().getAbsolutePath(), HoodieTableType.MERGE_ON_READ);
|
||||
basePath = metaClient.getBasePath();
|
||||
initMetaClient();
|
||||
partitions.forEach(p -> new File(basePath + "/" + p).mkdirs());
|
||||
}
|
||||
|
||||
protected void refreshFsView() throws IOException {
|
||||
metaClient = new HoodieTableMetaClient(metaClient.getHadoopConf(), basePath, true);
|
||||
}
|
||||
|
||||
protected SyncableFileSystemView getNewFileSystemView(HoodieTableMetaClient metaClient) throws IOException {
|
||||
return getNewFileSystemView(metaClient, metaClient.getActiveTimeline().filterCompletedAndCompactionInstants());
|
||||
}
|
||||
|
||||
protected SyncableFileSystemView getNewFileSystemView(HoodieTableMetaClient metaClient, HoodieTimeline timeline)
|
||||
throws IOException {
|
||||
return new HoodieTableFileSystemView(metaClient, timeline, true);
|
||||
refreshFsView();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyPartitionsAndTimeline() throws IOException {
|
||||
SyncableFileSystemView view = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView view = getFileSystemView(metaClient);
|
||||
Assert.assertFalse(view.getLastInstant().isPresent());
|
||||
partitions.forEach(p -> Assert.assertEquals(0, view.getLatestFileSlices(p).count()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsyncCompaction() throws IOException {
|
||||
SyncableFileSystemView view = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView view = getFileSystemView(metaClient);
|
||||
view.sync();
|
||||
|
||||
// Run 3 ingestion on MOR table (3 delta commits)
|
||||
@@ -181,7 +155,7 @@ public class IncrementalFSViewSyncTest {
|
||||
|
||||
@Test
|
||||
public void testIngestion() throws IOException {
|
||||
SyncableFileSystemView view = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView view = getFileSystemView(metaClient);
|
||||
|
||||
// Add an empty ingestion
|
||||
String firstEmptyInstantTs = "11";
|
||||
@@ -198,7 +172,7 @@ public class IncrementalFSViewSyncTest {
|
||||
partitions.forEach(p -> Assert.assertEquals(0, view.getLatestFileSlices(p).count()));
|
||||
|
||||
metaClient.reloadActiveTimeline();
|
||||
SyncableFileSystemView newView = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView newView = getFileSystemView(metaClient);
|
||||
for (String partition : partitions) {
|
||||
newView.getAllFileGroups(partition).count();
|
||||
}
|
||||
@@ -225,7 +199,7 @@ public class IncrementalFSViewSyncTest {
|
||||
@Test
|
||||
public void testMultipleTransitions() throws IOException {
|
||||
|
||||
SyncableFileSystemView view1 = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView view1 = getFileSystemView(metaClient);
|
||||
view1.sync();
|
||||
Map<String, List<String>> instantsToFiles = null;
|
||||
|
||||
@@ -237,7 +211,7 @@ public class IncrementalFSViewSyncTest {
|
||||
testMultipleWriteSteps(view1, Arrays.asList("11"), true, "11");
|
||||
|
||||
SyncableFileSystemView view2 =
|
||||
getNewFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
getFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
|
||||
// Run 2 more ingestion on MOR table. View1 is not yet synced but View2 is
|
||||
instantsToFiles.putAll(testMultipleWriteSteps(view2, Arrays.asList("12", "13"), true, "11"));
|
||||
@@ -247,7 +221,7 @@ public class IncrementalFSViewSyncTest {
|
||||
|
||||
view2.sync();
|
||||
SyncableFileSystemView view3 =
|
||||
getNewFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
getFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
partitions.stream().forEach(p -> view3.getLatestFileSlices(p).count());
|
||||
view3.sync();
|
||||
areViewsConsistent(view1, view2, partitions.size() * fileIdsPerPartition.size());
|
||||
@@ -260,7 +234,7 @@ public class IncrementalFSViewSyncTest {
|
||||
view1.sync();
|
||||
areViewsConsistent(view1, view2, partitions.size() * fileIdsPerPartition.size());
|
||||
SyncableFileSystemView view4 =
|
||||
getNewFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
getFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
partitions.stream().forEach(p -> view4.getLatestFileSlices(p).count());
|
||||
view4.sync();
|
||||
|
||||
@@ -275,7 +249,7 @@ public class IncrementalFSViewSyncTest {
|
||||
view1.sync();
|
||||
areViewsConsistent(view1, view2, partitions.size() * fileIdsPerPartition.size() * 2);
|
||||
SyncableFileSystemView view5 =
|
||||
getNewFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
getFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
partitions.stream().forEach(p -> view5.getLatestFileSlices(p).count());
|
||||
view5.sync();
|
||||
|
||||
@@ -296,7 +270,7 @@ public class IncrementalFSViewSyncTest {
|
||||
view1.sync();
|
||||
areViewsConsistent(view1, view2, partitions.size() * fileIdsPerPartition.size() * 2);
|
||||
SyncableFileSystemView view6 =
|
||||
getNewFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
getFileSystemView(new HoodieTableMetaClient(metaClient.getHadoopConf(), metaClient.getBasePath()));
|
||||
partitions.stream().forEach(p -> view5.getLatestFileSlices(p).count());
|
||||
view6.sync();
|
||||
|
||||
@@ -375,7 +349,7 @@ public class IncrementalFSViewSyncTest {
|
||||
partitions.forEach(p -> Assert.assertEquals(expTotalFileSlicesPerPartition, view.getAllFileSlices(p).count()));
|
||||
|
||||
metaClient.reloadActiveTimeline();
|
||||
SyncableFileSystemView newView = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView newView = getFileSystemView(metaClient);
|
||||
for (String partition : partitions) {
|
||||
newView.getAllFileGroups(partition).count();
|
||||
}
|
||||
@@ -427,7 +401,7 @@ public class IncrementalFSViewSyncTest {
|
||||
partitions.forEach(p -> Assert.assertEquals(expTotalFileSlicesPerPartition, view.getAllFileSlices(p).count()));
|
||||
|
||||
metaClient.reloadActiveTimeline();
|
||||
SyncableFileSystemView newView = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView newView = getFileSystemView(metaClient);
|
||||
for (String partition : partitions) {
|
||||
newView.getAllFileGroups(partition).count();
|
||||
}
|
||||
@@ -559,7 +533,7 @@ public class IncrementalFSViewSyncTest {
|
||||
});
|
||||
|
||||
metaClient.reloadActiveTimeline();
|
||||
SyncableFileSystemView newView = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView newView = getFileSystemView(metaClient);
|
||||
partitions.forEach(p -> newView.getLatestFileSlices(p).count());
|
||||
areViewsConsistent(view, newView, initialExpTotalFileSlices + partitions.size() * fileIdsPerPartition.size());
|
||||
}
|
||||
@@ -681,7 +655,7 @@ public class IncrementalFSViewSyncTest {
|
||||
}
|
||||
|
||||
metaClient.reloadActiveTimeline();
|
||||
SyncableFileSystemView newView = getNewFileSystemView(metaClient);
|
||||
SyncableFileSystemView newView = getFileSystemView(metaClient);
|
||||
for (String partition : partitions) {
|
||||
newView.getAllFileGroups(partition).count();
|
||||
}
|
||||
@@ -788,4 +762,10 @@ public class IncrementalFSViewSyncTest {
|
||||
new HoodieInstant(State.REQUESTED, HoodieTimeline.COMPACTION_ACTION, instant).getFileName()));
|
||||
return writeStats.stream().map(e -> e.getValue().getPath()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HoodieTableType getTableType() {
|
||||
return HoodieTableType.MERGE_ON_READ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ import org.apache.hudi.common.table.SyncableFileSystemView;
|
||||
public class RocksDBBasedIncrementalFSViewSyncTest extends IncrementalFSViewSyncTest {
|
||||
|
||||
@Override
|
||||
protected SyncableFileSystemView getNewFileSystemView(HoodieTableMetaClient metaClient, HoodieTimeline timeline)
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTableMetaClient metaClient, HoodieTimeline timeline)
|
||||
throws IOException {
|
||||
return new RocksDbBasedFileSystemView(metaClient, timeline,
|
||||
FileSystemViewStorageConfig.newBuilder().withRocksDBPath(tmpFolder.newFolder().getAbsolutePath())
|
||||
FileSystemViewStorageConfig.newBuilder().withRocksDBPath(folder.newFolder().getAbsolutePath())
|
||||
.withIncrementalTimelineSync(true).build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class RocksDbBasedFileSystemViewTest extends HoodieTableFileSystemViewTes
|
||||
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTimeline timeline) throws IOException {
|
||||
return new RocksDbBasedFileSystemView(metaClient, timeline,
|
||||
FileSystemViewStorageConfig.newBuilder().withRocksDBPath(tmpFolder.newFolder().getAbsolutePath())
|
||||
FileSystemViewStorageConfig.newBuilder().withRocksDBPath(folder.newFolder().getAbsolutePath())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.apache.hudi.common.table.SyncableFileSystemView;
|
||||
public class SpillableMapBasedIncrementalFSViewSyncTest extends IncrementalFSViewSyncTest {
|
||||
|
||||
@Override
|
||||
protected SyncableFileSystemView getNewFileSystemView(HoodieTableMetaClient metaClient, HoodieTimeline timeline) {
|
||||
protected SyncableFileSystemView getFileSystemView(HoodieTableMetaClient metaClient, HoodieTimeline timeline) {
|
||||
return new SpillableMapBasedFileSystemView(metaClient, timeline,
|
||||
FileSystemViewStorageConfig.newBuilder().withMaxMemoryForView(0L).withIncrementalTimelineSync(true).build());
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.apache.hudi.common.util;
|
||||
|
||||
import static org.apache.hudi.common.model.HoodieTestUtils.DEFAULT_PARTITION_PATHS;
|
||||
import static org.apache.hudi.common.model.HoodieTestUtils.getDefaultHadoopConf;
|
||||
import static org.apache.hudi.common.util.CompactionTestUtils.createCompactionPlan;
|
||||
import static org.apache.hudi.common.util.CompactionTestUtils.scheduleCompaction;
|
||||
import static org.apache.hudi.common.util.CompactionTestUtils.setupAndValidateCompactionOperations;
|
||||
@@ -35,21 +34,19 @@ import java.util.stream.IntStream;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hudi.avro.model.HoodieCompactionOperation;
|
||||
import org.apache.hudi.avro.model.HoodieCompactionPlan;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.FileSlice;
|
||||
import org.apache.hudi.common.model.HoodieFileGroupId;
|
||||
import org.apache.hudi.common.model.HoodieLogFile;
|
||||
import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
import org.apache.hudi.common.util.CompactionTestUtils.TestHoodieDataFile;
|
||||
import org.apache.hudi.common.util.collection.Pair;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class TestCompactionUtils {
|
||||
public class TestCompactionUtils extends HoodieCommonTestHarness {
|
||||
|
||||
private static String TEST_WRITE_TOKEN = "1-0-1";
|
||||
|
||||
@@ -57,17 +54,11 @@ public class TestCompactionUtils {
|
||||
new ImmutableMap.Builder<String, Double>()
|
||||
.put("key1", 1.0)
|
||||
.put("key2", 3.0).build();
|
||||
@Rule
|
||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||
private HoodieTableMetaClient metaClient;
|
||||
private String basePath;
|
||||
private Function<Pair<String, FileSlice>, Map<String, Double>> metricsCaptureFn = (partitionFileSlice) -> metrics;
|
||||
|
||||
@Before
|
||||
public void init() throws IOException {
|
||||
metaClient = HoodieTestUtils.init(getDefaultHadoopConf(),
|
||||
tmpFolder.getRoot().getAbsolutePath(), HoodieTableType.MERGE_ON_READ);
|
||||
basePath = metaClient.getBasePath();
|
||||
initMetaClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -237,4 +228,9 @@ public class TestCompactionUtils {
|
||||
});
|
||||
Assert.assertEquals("Metrics set", metrics, op.getMetrics());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HoodieTableType getTableType() {
|
||||
return HoodieTableType.MERGE_ON_READ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,23 +32,29 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.HoodieLogFile;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
import org.apache.hudi.exception.HoodieException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.contrib.java.lang.system.EnvironmentVariables;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class TestFSUtils {
|
||||
public class TestFSUtils extends HoodieCommonTestHarness {
|
||||
|
||||
private static String TEST_WRITE_TOKEN = "1-0-1";
|
||||
|
||||
@Rule
|
||||
public final EnvironmentVariables environmentVariables = new EnvironmentVariables();
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
initMetaClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMakeDataFileName() {
|
||||
String commitTime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
||||
@@ -75,13 +81,9 @@ public class TestFSUtils {
|
||||
* This code tests the fix by ensuring ".hoodie" and their subfolders are never processed.
|
||||
*/
|
||||
public void testProcessFiles() throws Exception {
|
||||
TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||
tmpFolder.create();
|
||||
// All directories including marker dirs.
|
||||
List<String> folders = Arrays.asList("2016/04/15", "2016/05/16", ".hoodie/.temp/2/2016/04/15",
|
||||
".hoodie/.temp/2/2016/05/16");
|
||||
HoodieTableMetaClient metaClient = HoodieTestUtils.init(tmpFolder.getRoot().getAbsolutePath());
|
||||
String basePath = metaClient.getBasePath();
|
||||
folders.stream().forEach(f -> {
|
||||
try {
|
||||
metaClient.getFs().mkdirs(new Path(new Path(basePath), f));
|
||||
|
||||
@@ -27,15 +27,14 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class TestFileIOUtils {
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestFileIOUtils extends HoodieCommonTestHarness {
|
||||
|
||||
@Test
|
||||
public void testMkdirAndDelete() throws IOException {
|
||||
TemporaryFolder folder = new TemporaryFolder();
|
||||
folder.create();
|
||||
try {
|
||||
FileIOUtils.mkdir(folder.getRoot());
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -21,7 +21,6 @@ package org.apache.hudi.common.util;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -34,6 +33,7 @@ import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hudi.avro.HoodieAvroWriteSupport;
|
||||
import org.apache.hudi.common.BloomFilter;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.HoodieRecord;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.parquet.avro.AvroSchemaConverter;
|
||||
@@ -41,19 +41,12 @@ import org.apache.parquet.hadoop.ParquetWriter;
|
||||
import org.apache.parquet.hadoop.metadata.CompressionCodecName;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class TestParquetUtils {
|
||||
|
||||
|
||||
private String basePath;
|
||||
public class TestParquetUtils extends HoodieCommonTestHarness {
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
// Create a temp folder as the base path
|
||||
TemporaryFolder folder = new TemporaryFolder();
|
||||
folder.create();
|
||||
basePath = folder.getRoot().getAbsolutePath();
|
||||
public void setup() {
|
||||
initPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.apache.hudi.common.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -33,14 +32,21 @@ import org.apache.hudi.common.table.view.FileSystemViewStorageConfig;
|
||||
import org.apache.hudi.common.util.collection.Pair;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestRocksDBManager {
|
||||
|
||||
private static RocksDBDAO dbManager;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
dbManager = new RocksDBDAO("/dummy/path",
|
||||
FileSystemViewStorageConfig.newBuilder().build().newBuilder().build().getRocksdbBasePath());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void drop() throws IOException {
|
||||
public static void tearDownClass() {
|
||||
if (dbManager != null) {
|
||||
dbManager.close();
|
||||
dbManager = null;
|
||||
@@ -66,8 +72,6 @@ public class TestRocksDBManager {
|
||||
return new Payload(prefix, key, val, family);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
dbManager = new RocksDBDAO("/dummy/path",
|
||||
FileSystemViewStorageConfig.newBuilder().build().newBuilder().build().getRocksdbBasePath());
|
||||
colFamilies.stream().forEach(family -> dbManager.dropColumnFamily(family));
|
||||
colFamilies.stream().forEach(family -> dbManager.addColumnFamily(family));
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ import java.util.stream.Collectors;
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.avro.generic.IndexedRecord;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.AvroBinaryTestPayload;
|
||||
import org.apache.hudi.common.model.HoodieAvroPayload;
|
||||
import org.apache.hudi.common.model.HoodieKey;
|
||||
import org.apache.hudi.common.model.HoodieRecord;
|
||||
import org.apache.hudi.common.model.HoodieRecordPayload;
|
||||
@@ -47,19 +47,20 @@ import org.apache.hudi.common.util.Option;
|
||||
import org.apache.hudi.common.util.SchemaTestUtil;
|
||||
import org.apache.hudi.common.util.SpillableMapTestUtils;
|
||||
import org.apache.hudi.common.util.SpillableMapUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestDiskBasedMap {
|
||||
public class TestDiskBasedMap extends HoodieCommonTestHarness {
|
||||
|
||||
private static final String BASE_OUTPUT_PATH = "/tmp/";
|
||||
@Before
|
||||
public void setup() {
|
||||
initPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleInsert() throws IOException, URISyntaxException {
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(getSimpleSchema());
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
DiskBasedMap records = new DiskBasedMap<>(BASE_OUTPUT_PATH);
|
||||
DiskBasedMap records = new DiskBasedMap<>(basePath);
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
((GenericRecord) iRecords.get(0)).get(HoodieRecord.COMMIT_TIME_METADATA_FIELD).toString();
|
||||
List<String> recordKeys = SpillableMapTestUtils.upsertRecords(iRecords, records);
|
||||
@@ -77,10 +78,7 @@ public class TestDiskBasedMap {
|
||||
|
||||
@Test
|
||||
public void testSimpleInsertWithoutHoodieMetadata() throws IOException, URISyntaxException {
|
||||
Schema schema = getSimpleSchema();
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
DiskBasedMap records = new DiskBasedMap<>(BASE_OUTPUT_PATH);
|
||||
DiskBasedMap records = new DiskBasedMap<>(basePath);
|
||||
List<HoodieRecord> hoodieRecords = SchemaTestUtil
|
||||
.generateHoodieTestRecordsWithoutHoodieMetadata(0, 1000);
|
||||
Set<String> recordKeys = new HashSet<>();
|
||||
@@ -102,11 +100,9 @@ public class TestDiskBasedMap {
|
||||
|
||||
@Test
|
||||
public void testSimpleUpsert() throws IOException, URISyntaxException {
|
||||
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(getSimpleSchema());
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
DiskBasedMap records = new DiskBasedMap<>(BASE_OUTPUT_PATH);
|
||||
DiskBasedMap records = new DiskBasedMap<>(basePath);
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
|
||||
// perform some inserts
|
||||
|
||||
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -32,6 +31,7 @@ import java.util.List;
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.avro.generic.IndexedRecord;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.HoodieAvroPayload;
|
||||
import org.apache.hudi.common.model.HoodieKey;
|
||||
import org.apache.hudi.common.model.HoodieRecord;
|
||||
@@ -43,23 +43,20 @@ import org.apache.hudi.common.util.HoodieRecordSizeEstimator;
|
||||
import org.apache.hudi.common.util.Option;
|
||||
import org.apache.hudi.common.util.SchemaTestUtil;
|
||||
import org.apache.hudi.common.util.SpillableMapTestUtils;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class TestExternalSpillableMap {
|
||||
public class TestExternalSpillableMap extends HoodieCommonTestHarness {
|
||||
|
||||
private static final String FAILURE_OUTPUT_PATH = "/tmp/test_fail";
|
||||
private static final String BASE_OUTPUT_PATH = "/tmp/";
|
||||
private static String failureOutputPath;
|
||||
|
||||
@BeforeClass
|
||||
public static void cleanUp() {
|
||||
File file = new File(BASE_OUTPUT_PATH);
|
||||
file.delete();
|
||||
file = new File(FAILURE_OUTPUT_PATH);
|
||||
file.delete();
|
||||
@Before
|
||||
public void setUp() {
|
||||
initPath();
|
||||
failureOutputPath = basePath + "/test_fail";
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +64,7 @@ public class TestExternalSpillableMap {
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(SchemaTestUtil.getSimpleSchema());
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH,
|
||||
new ExternalSpillableMap<>(16L, basePath,
|
||||
new DefaultSizeEstimator(), new HoodieRecordSizeEstimator(schema)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -89,7 +86,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH,
|
||||
new ExternalSpillableMap<>(16L, basePath,
|
||||
new DefaultSizeEstimator(), new HoodieRecordSizeEstimator(schema)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -127,7 +124,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH,
|
||||
new ExternalSpillableMap<>(16L, basePath,
|
||||
new DefaultSizeEstimator(), new HoodieRecordSizeEstimator(schema)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -180,10 +177,9 @@ public class TestExternalSpillableMap {
|
||||
@Test(expected = IOException.class)
|
||||
public void simpleTestWithException() throws IOException, URISyntaxException {
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(SchemaTestUtil.getSimpleSchema());
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, FAILURE_OUTPUT_PATH,
|
||||
new ExternalSpillableMap<>(16L, failureOutputPath,
|
||||
new DefaultSizeEstimator(), new HoodieRecordSizeEstimator(schema)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -202,7 +198,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH,
|
||||
new ExternalSpillableMap<>(16L, basePath,
|
||||
new DefaultSizeEstimator(), new HoodieRecordSizeEstimator(schema)); //16B
|
||||
|
||||
List<String> recordKeys = new ArrayList<>();
|
||||
@@ -255,7 +251,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH,
|
||||
new ExternalSpillableMap<>(16L, basePath,
|
||||
new DefaultSizeEstimator(), new HoodieRecordSizeEstimator(schema)); //16B
|
||||
|
||||
List<String> recordKeys = new ArrayList<>();
|
||||
|
||||
@@ -25,20 +25,25 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.avro.generic.IndexedRecord;
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.model.HoodieRecord;
|
||||
import org.apache.hudi.common.model.HoodieRecordPayload;
|
||||
import org.apache.hudi.common.util.SchemaTestUtil;
|
||||
import org.apache.hudi.common.util.SpillableMapTestUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestRocksDbBasedMap {
|
||||
public class TestRocksDbBasedMap extends HoodieCommonTestHarness {
|
||||
|
||||
private static final String BASE_OUTPUT_PATH = "/tmp/";
|
||||
@Before
|
||||
public void setUp() {
|
||||
initPath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws IOException, URISyntaxException {
|
||||
RocksDBBasedMap records = new RocksDBBasedMap(BASE_OUTPUT_PATH);
|
||||
RocksDBBasedMap records = new RocksDBBasedMap(basePath);
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
((GenericRecord) iRecords.get(0)).get(HoodieRecord.COMMIT_TIME_METADATA_FIELD).toString();
|
||||
List<String> recordKeys = SpillableMapTestUtils.upsertRecords(iRecords, records);
|
||||
|
||||
Reference in New Issue
Block a user