[HUDI-995] Use HoodieTestTable in more classes (#2079)
* [HUDI-995] Use HoodieTestTable in more classes Migrate test data prep logic in - TestStatsCommand - TestHoodieROTablePathFilter Re-implement methods for create new commit times in HoodieTestUtils and HoodieClientTestHarness - Move relevant APIs to HoodieTestTable - Migrate usages After changing to HoodieTestTable APIs, removed unused deprecated APIs in HoodieTestUtils
This commit is contained in:
@@ -27,7 +27,7 @@ import org.apache.hudi.cli.testutils.HoodieTestCommitMetadataGenerator;
|
||||
import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.table.timeline.versioning.TimelineLayoutVersion;
|
||||
import org.apache.hudi.common.testutils.HoodieTestDataGenerator;
|
||||
import org.apache.hudi.common.testutils.HoodieTestUtils;
|
||||
import org.apache.hudi.common.testutils.HoodieTestTable;
|
||||
import org.apache.hudi.common.util.Option;
|
||||
|
||||
import com.codahale.metrics.Histogram;
|
||||
@@ -66,6 +66,7 @@ public class TestStatsCommand extends AbstractShellIntegrationTest {
|
||||
new TableCommand().createTable(
|
||||
tablePath, tableName, HoodieTableType.COPY_ON_WRITE.name(),
|
||||
"", TimelineLayoutVersion.VERSION_1, "org.apache.hudi.common.model.HoodieAvroPayload");
|
||||
metaClient = HoodieCLI.getTableMetaClient();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +113,7 @@ public class TestStatsCommand extends AbstractShellIntegrationTest {
|
||||
* Test case for command 'stats filesizes'.
|
||||
*/
|
||||
@Test
|
||||
public void testFileSizeStats() throws IOException {
|
||||
public void testFileSizeStats() throws Exception {
|
||||
String commit1 = "100";
|
||||
String commit2 = "101";
|
||||
Map<String, Integer[]> data = new LinkedHashMap<>();
|
||||
@@ -124,18 +125,20 @@ public class TestStatsCommand extends AbstractShellIntegrationTest {
|
||||
String partition2 = HoodieTestDataGenerator.DEFAULT_SECOND_PARTITION_PATH;
|
||||
String partition3 = HoodieTestDataGenerator.DEFAULT_THIRD_PARTITION_PATH;
|
||||
|
||||
HoodieTestTable testTable = HoodieTestTable.of(metaClient);
|
||||
Integer[] data1 = data.get(commit1);
|
||||
assertTrue(3 <= data1.length);
|
||||
HoodieTestUtils.createNewDataFile(tablePath, partition1, commit1, data1[0]);
|
||||
HoodieTestUtils.createNewDataFile(tablePath, partition2, commit1, data1[1]);
|
||||
HoodieTestUtils.createNewDataFile(tablePath, partition3, commit1, data1[2]);
|
||||
testTable.addCommit(commit1)
|
||||
.withBaseFilesInPartition(partition1, data1[0])
|
||||
.withBaseFilesInPartition(partition2, data1[1])
|
||||
.withBaseFilesInPartition(partition3, data1[2]);
|
||||
|
||||
Integer[] data2 = data.get(commit2);
|
||||
assertTrue(4 <= data2.length);
|
||||
HoodieTestUtils.createNewDataFile(tablePath, partition1, commit2, data2[0]);
|
||||
HoodieTestUtils.createNewDataFile(tablePath, partition2, commit2, data2[1]);
|
||||
HoodieTestUtils.createNewDataFile(tablePath, partition2, commit2, data2[2]);
|
||||
HoodieTestUtils.createNewDataFile(tablePath, partition3, commit2, data2[3]);
|
||||
testTable.addCommit(commit2)
|
||||
.withBaseFilesInPartition(partition1, data2[0])
|
||||
.withBaseFilesInPartition(partition2, data2[1], data2[2])
|
||||
.withBaseFilesInPartition(partition3, data2[3]);
|
||||
|
||||
CommandResult cr = getShell().executeCommand("stats filesizes");
|
||||
assertTrue(cr.isSuccess());
|
||||
|
||||
Reference in New Issue
Block a user