Skip to content

Commit

Permalink
Add tests for reusing metadata readers
Browse files Browse the repository at this point in the history
  • Loading branch information
yihua committed Jul 27, 2022
1 parent c4c90e3 commit 966c658
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@

package org.apache.hudi.client.functional;

import org.apache.avro.Schema;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.generic.IndexedRecord;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hudi.avro.HoodieAvroUtils;
import org.apache.hudi.avro.model.HoodieMetadataRecord;
import org.apache.hudi.common.config.HoodieMetadataConfig;
Expand Down Expand Up @@ -51,13 +45,20 @@
import org.apache.hudi.metadata.MetadataPartitionType;
import org.apache.hudi.table.HoodieSparkTable;
import org.apache.hudi.table.HoodieTable;

import org.apache.avro.Schema;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.generic.IndexedRecord;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.parquet.avro.AvroSchemaConverter;
import org.apache.parquet.schema.MessageType;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -81,23 +82,26 @@ public class TestHoodieBackedTableMetadata extends TestHoodieMetadataBase {

private static final Logger LOG = LogManager.getLogger(TestHoodieBackedTableMetadata.class);

@Test
public void testTableOperations() throws Exception {
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void testTableOperations(boolean reuseReaders) throws Exception {
HoodieTableType tableType = HoodieTableType.COPY_ON_WRITE;
init(tableType);
doWriteInsertAndUpsert(testTable);

// trigger an upsert
doWriteOperation(testTable, "0000003");
verifyBaseMetadataTable();
verifyBaseMetadataTable(reuseReaders);
}

private void doWriteInsertAndUpsert(HoodieTestTable testTable) throws Exception {
doWriteInsertAndUpsert(testTable, "0000001", "0000002", false);
}

private void verifyBaseMetadataTable() throws IOException {
HoodieBackedTableMetadata tableMetadata = new HoodieBackedTableMetadata(context, writeConfig.getMetadataConfig(), writeConfig.getBasePath(), writeConfig.getSpillableMapBasePath(), false);
private void verifyBaseMetadataTable(boolean reuseMetadataReaders) throws IOException {
HoodieBackedTableMetadata tableMetadata = new HoodieBackedTableMetadata(
context, writeConfig.getMetadataConfig(), writeConfig.getBasePath(),
writeConfig.getSpillableMapBasePath(), reuseMetadataReaders);
assertTrue(tableMetadata.enabled());
List<java.nio.file.Path> fsPartitionPaths = testTable.getAllPartitionPaths();
List<String> fsPartitions = new ArrayList<>();
Expand Down

0 comments on commit 966c658

Please sign in to comment.