[HUDI-810] Migrate ClientTestHarness to JUnit 5 (#1553)
This commit is contained in:
@@ -20,10 +20,10 @@ package org.apache.hudi.cli;
|
||||
|
||||
import org.apache.hudi.common.HoodieClientTestHarness;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.springframework.shell.Bootstrap;
|
||||
import org.springframework.shell.core.JLineShellComponent;
|
||||
|
||||
@@ -31,25 +31,26 @@ import org.springframework.shell.core.JLineShellComponent;
|
||||
* Class to start Bootstrap and JLineShellComponent.
|
||||
*/
|
||||
public abstract class AbstractShellIntegrationTest extends HoodieClientTestHarness {
|
||||
|
||||
private static JLineShellComponent shell;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void startup() {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
shell = bootstrap.getJLineShellComponent();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void shutdown() {
|
||||
shell.stop();
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
initResources();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() throws Exception {
|
||||
cleanupResources();
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ import org.apache.hudi.config.HoodieCompactionConfig;
|
||||
import org.apache.hudi.config.HoodieWriteConfig;
|
||||
import org.apache.hudi.table.HoodieTimelineArchiveLog;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.shell.core.CommandResult;
|
||||
|
||||
import java.io.File;
|
||||
@@ -43,8 +43,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Cases for {@link ArchivedCommitsCommand}.
|
||||
@@ -53,7 +53,7 @@ public class TestArchivedCommitsCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
private String tablePath;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() throws IOException {
|
||||
initDFS();
|
||||
jsc.hadoopConfiguration().addResource(dfs.getConf());
|
||||
@@ -95,7 +95,7 @@ public class TestArchivedCommitsCommand extends AbstractShellIntegrationTest {
|
||||
archiveLog.archiveIfRequired(jsc);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void clean() throws IOException {
|
||||
cleanupDFS();
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class TestArchivedCommitsCommand extends AbstractShellIntegrationTest {
|
||||
for (int i = 100; i < 104; i++) {
|
||||
String instant = String.valueOf(i);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
Comparable[] defaultComp = new Comparable[]{"commit", instant,
|
||||
Comparable[] defaultComp = new Comparable[] {"commit", instant,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_SECOND_PARTITION_PATH,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_FILEID,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_PRE_COMMIT,
|
||||
@@ -162,12 +162,12 @@ public class TestArchivedCommitsCommand extends AbstractShellIntegrationTest {
|
||||
TableHeader header = new TableHeader().addTableHeaderField("CommitTime").addTableHeaderField("CommitType");
|
||||
for (int i = 100; i < 103; i++) {
|
||||
String instant = String.valueOf(i);
|
||||
Comparable[] result = new Comparable[]{instant, "commit"};
|
||||
Comparable[] result = new Comparable[] {instant, "commit"};
|
||||
rows.add(result);
|
||||
rows.add(result);
|
||||
rows.add(result);
|
||||
}
|
||||
rows.add(new Comparable[]{"103", "commit"});
|
||||
rows.add(new Comparable[] {"103", "commit"});
|
||||
String expected = HoodiePrintHelper.print(header, new HashMap<>(), "", false, 10, false, rows);
|
||||
assertEquals(expected, cr.getResult().toString());
|
||||
|
||||
@@ -181,7 +181,7 @@ public class TestArchivedCommitsCommand extends AbstractShellIntegrationTest {
|
||||
for (int i = 100; i < 104; i++) {
|
||||
String instant = String.valueOf(i);
|
||||
// Since HoodiePrintHelper order data by default, need to order commitMetadata
|
||||
Comparable[] result = new Comparable[]{
|
||||
Comparable[] result = new Comparable[] {
|
||||
instant, "commit", HoodieTestCommitUtilities.convertAndOrderCommitMetadata(metadata)};
|
||||
rows.add(result);
|
||||
rows.add(result);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package org.apache.hudi.cli.commands;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hudi.avro.model.HoodieCleanMetadata;
|
||||
import org.apache.hudi.cli.AbstractShellIntegrationTest;
|
||||
import org.apache.hudi.cli.HoodieCLI;
|
||||
@@ -36,20 +35,23 @@ import org.apache.hudi.common.table.timeline.HoodieTimeline;
|
||||
import org.apache.hudi.common.table.timeline.TimelineMetadataUtils;
|
||||
import org.apache.hudi.common.table.timeline.versioning.TimelineLayoutVersion;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.shell.core.CommandResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Cases for {@link CleansCommand}.
|
||||
@@ -59,7 +61,7 @@ public class TestCleansCommand extends AbstractShellIntegrationTest {
|
||||
private String tablePath;
|
||||
private URL propsFilePath;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() throws IOException {
|
||||
HoodieCLI.conf = jsc.hadoopConfiguration();
|
||||
|
||||
@@ -98,14 +100,15 @@ public class TestCleansCommand extends AbstractShellIntegrationTest {
|
||||
@Test
|
||||
public void testShowCleans() throws Exception {
|
||||
// Check properties file exists.
|
||||
assertNotNull("Not found properties file", propsFilePath);
|
||||
assertNotNull(propsFilePath, "Not found properties file");
|
||||
|
||||
// First, run clean
|
||||
new File(tablePath + File.separator + HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH
|
||||
+ File.separator + HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE).createNewFile();
|
||||
Files.createFile(Paths.get(tablePath,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH,
|
||||
HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE));
|
||||
SparkMain.clean(jsc, HoodieCLI.basePath, propsFilePath.getPath(), new ArrayList<>());
|
||||
assertEquals("Loaded 1 clean and the count should match", 1,
|
||||
metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().count());
|
||||
assertEquals(1, metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().count(),
|
||||
"Loaded 1 clean and the count should match");
|
||||
|
||||
CommandResult cr = getShell().executeCommand("cleans show");
|
||||
assertTrue(cr.isSuccess());
|
||||
@@ -122,7 +125,7 @@ public class TestCleansCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
// EarliestCommandRetained should be 102, since hoodie.cleaner.commits.retained=2
|
||||
// Total Time Taken need read from metadata
|
||||
rows.add(new Comparable[]{clean.getTimestamp(), "102", "0", getLatestCleanTimeTakenInMillis().toString()});
|
||||
rows.add(new Comparable[] {clean.getTimestamp(), "102", "0", getLatestCleanTimeTakenInMillis().toString()});
|
||||
|
||||
String expected = HoodiePrintHelper.print(header, new HashMap<>(), "", false, -1, false, rows);
|
||||
assertEquals(expected, cr.getResult().toString());
|
||||
@@ -134,16 +137,18 @@ public class TestCleansCommand extends AbstractShellIntegrationTest {
|
||||
@Test
|
||||
public void testShowCleanPartitions() throws IOException {
|
||||
// Check properties file exists.
|
||||
assertNotNull("Not found properties file", propsFilePath);
|
||||
assertNotNull(propsFilePath, "Not found properties file");
|
||||
|
||||
// First, run clean with two partition
|
||||
new File(tablePath + File.separator + HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH
|
||||
+ File.separator + HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE).createNewFile();
|
||||
new File(tablePath + File.separator + HoodieTestCommitMetadataGenerator.DEFAULT_SECOND_PARTITION_PATH
|
||||
+ File.separator + HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE).createNewFile();
|
||||
Files.createFile(Paths.get(tablePath,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH,
|
||||
HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE));
|
||||
Files.createFile(Paths.get(tablePath,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_SECOND_PARTITION_PATH,
|
||||
HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE));
|
||||
SparkMain.clean(jsc, HoodieCLI.basePath, propsFilePath.toString(), new ArrayList<>());
|
||||
assertEquals("Loaded 1 clean and the count should match", 1,
|
||||
metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().count());
|
||||
assertEquals(1, metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().count(),
|
||||
"Loaded 1 clean and the count should match");
|
||||
|
||||
HoodieInstant clean = metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().findFirst().get();
|
||||
|
||||
@@ -157,9 +162,9 @@ public class TestCleansCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
// There should be two partition path
|
||||
List<Comparable[]> rows = new ArrayList<>();
|
||||
rows.add(new Comparable[]{HoodieTestCommitMetadataGenerator.DEFAULT_SECOND_PARTITION_PATH,
|
||||
rows.add(new Comparable[] {HoodieTestCommitMetadataGenerator.DEFAULT_SECOND_PARTITION_PATH,
|
||||
HoodieCleaningPolicy.KEEP_LATEST_COMMITS, "0", "0"});
|
||||
rows.add(new Comparable[]{HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH,
|
||||
rows.add(new Comparable[] {HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH,
|
||||
HoodieCleaningPolicy.KEEP_LATEST_COMMITS, "0", "0"});
|
||||
|
||||
String expected = HoodiePrintHelper.print(header, new HashMap<>(), "", false, -1, false, rows);
|
||||
|
||||
@@ -33,12 +33,13 @@ import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
|
||||
import org.apache.hudi.common.table.view.SyncableFileSystemView;
|
||||
import org.apache.hudi.common.util.NumericUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.shell.core.CommandResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -48,23 +49,24 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test class for {@link FileSystemViewCommand}.
|
||||
*/
|
||||
public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
private String partitionPath;
|
||||
private SyncableFileSystemView fsView;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() throws IOException {
|
||||
HoodieCLI.conf = jsc.hadoopConfiguration();
|
||||
|
||||
// Create table and connect
|
||||
String tableName = "test_table";
|
||||
String tablePath = basePath + File.separator + tableName;
|
||||
String tablePath = Paths.get(basePath, tableName).toString();
|
||||
new TableCommand().createTable(
|
||||
tablePath, tableName,
|
||||
"COPY_ON_WRITE", "", 1, "org.apache.hudi.common.model.HoodieAvroPayload");
|
||||
@@ -72,8 +74,8 @@ public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
|
||||
metaClient = HoodieCLI.getTableMetaClient();
|
||||
|
||||
partitionPath = HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH;
|
||||
String fullPartitionPath = tablePath + "/" + partitionPath;
|
||||
new File(fullPartitionPath).mkdirs();
|
||||
String fullPartitionPath = Paths.get(tablePath, partitionPath).toString();
|
||||
Files.createDirectories(Paths.get(fullPartitionPath));
|
||||
|
||||
// Generate 2 commits
|
||||
String commitTime1 = "1";
|
||||
@@ -83,20 +85,18 @@ public class TestFileSystemViewCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
// Write date files and log file
|
||||
String testWriteToken = "1-0-1";
|
||||
new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime1, testWriteToken, fileId1))
|
||||
.createNewFile();
|
||||
new File(fullPartitionPath + "/"
|
||||
+ FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, testWriteToken))
|
||||
.createNewFile();
|
||||
new File(fullPartitionPath + "/" + FSUtils.makeDataFileName(commitTime2, testWriteToken, fileId1))
|
||||
.createNewFile();
|
||||
new File(fullPartitionPath + "/"
|
||||
+ FSUtils.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, testWriteToken))
|
||||
.createNewFile();
|
||||
Files.createFile(Paths.get(fullPartitionPath, FSUtils
|
||||
.makeDataFileName(commitTime1, testWriteToken, fileId1)));
|
||||
Files.createFile(Paths.get(fullPartitionPath, FSUtils
|
||||
.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime1, 0, testWriteToken)));
|
||||
Files.createFile(Paths.get(fullPartitionPath, FSUtils
|
||||
.makeDataFileName(commitTime2, testWriteToken, fileId1)));
|
||||
Files.createFile(Paths.get(fullPartitionPath, FSUtils
|
||||
.makeLogFileName(fileId1, HoodieLogFile.DELTA_EXTENSION, commitTime2, 0, testWriteToken)));
|
||||
|
||||
// Write commit files
|
||||
new File(tablePath + "/.hoodie/" + commitTime1 + ".commit").createNewFile();
|
||||
new File(tablePath + "/.hoodie/" + commitTime2 + ".commit").createNewFile();
|
||||
Files.createFile(Paths.get(tablePath, ".hoodie", commitTime1 + ".commit"));
|
||||
Files.createFile(Paths.get(tablePath, ".hoodie", commitTime2 + ".commit"));
|
||||
|
||||
// Reload meta client and create fsView
|
||||
metaClient = HoodieTableMetaClient.reload(metaClient);
|
||||
|
||||
@@ -21,11 +21,11 @@ package org.apache.hudi.cli.commands;
|
||||
import org.apache.hudi.cli.AbstractShellIntegrationTest;
|
||||
import org.apache.hudi.cli.HoodiePrintHelper;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.shell.core.CommandResult;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Cases for {@link SparkEnvCommand}.
|
||||
@@ -48,7 +48,7 @@ public class TestSparkEnvCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
//Get
|
||||
cr = getShell().executeCommand("show env --key SPARK_HOME");
|
||||
String result = HoodiePrintHelper.print(new String[] {"key", "value"}, new String[][]{new String[]{"SPARK_HOME", "/usr/etc/spark"}});
|
||||
String result = HoodiePrintHelper.print(new String[] {"key", "value"}, new String[][] {new String[] {"SPARK_HOME", "/usr/etc/spark"}});
|
||||
assertEquals(result, cr.getResult().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,30 +24,30 @@ import org.apache.hudi.common.fs.ConsistencyGuardConfig;
|
||||
import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.shell.core.CommandResult;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.apache.hudi.common.table.HoodieTableMetaClient.METAFOLDER_NAME;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Cases for {@link TableCommand}.
|
||||
*/
|
||||
public class TestTableCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
private String tableName = "test_table";
|
||||
private final String tableName = "test_table";
|
||||
private String tablePath;
|
||||
private String metaPath;
|
||||
|
||||
/**
|
||||
* Init path after Mini hdfs init.
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
HoodieCLI.conf = jsc.hadoopConfiguration();
|
||||
tablePath = basePath + File.separator + tableName;
|
||||
@@ -74,7 +74,7 @@ public class TestTableCommand extends AbstractShellIntegrationTest {
|
||||
// Test connect with specified values
|
||||
CommandResult cr = getShell().executeCommand(
|
||||
"connect --path " + tablePath + " --initialCheckIntervalMs 3000 "
|
||||
+ "--maxWaitIntervalMs 40000 --maxCheckIntervalMs 8");
|
||||
+ "--maxWaitIntervalMs 40000 --maxCheckIntervalMs 8");
|
||||
assertTrue(cr.isSuccess());
|
||||
|
||||
// Check specified values
|
||||
@@ -113,7 +113,7 @@ public class TestTableCommand extends AbstractShellIntegrationTest {
|
||||
// Test create with specified values
|
||||
CommandResult cr = getShell().executeCommand(
|
||||
"create --path " + tablePath + " --tableName " + tableName
|
||||
+ " --tableType MERGE_ON_READ --archiveLogFolder archive");
|
||||
+ " --tableType MERGE_ON_READ --archiveLogFolder archive");
|
||||
assertTrue(cr.isSuccess());
|
||||
assertEquals("Metadata for table " + tableName + " loaded", cr.getResult().toString());
|
||||
HoodieTableMetaClient client = HoodieCLI.getTableMetaClient();
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package org.apache.hudi.cli.integ;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hudi.cli.AbstractShellIntegrationTest;
|
||||
import org.apache.hudi.cli.HoodieCLI;
|
||||
import org.apache.hudi.cli.commands.TableCommand;
|
||||
@@ -29,23 +28,27 @@ import org.apache.hudi.common.table.timeline.HoodieInstant;
|
||||
import org.apache.hudi.common.table.timeline.HoodieTimeline;
|
||||
import org.apache.hudi.common.table.timeline.versioning.TimelineLayoutVersion;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.shell.core.CommandResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ITTestCleansCommand extends AbstractShellIntegrationTest {
|
||||
|
||||
private String tablePath;
|
||||
private URL propsFilePath;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() throws IOException {
|
||||
HoodieCLI.conf = jsc.hadoopConfiguration();
|
||||
|
||||
@@ -83,19 +86,21 @@ public class ITTestCleansCommand extends AbstractShellIntegrationTest {
|
||||
assertEquals(0, metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().count());
|
||||
|
||||
// Check properties file exists.
|
||||
assertNotNull("Not found properties file", propsFilePath);
|
||||
assertNotNull(propsFilePath, "Not found properties file");
|
||||
|
||||
// Create partition metadata
|
||||
new File(tablePath + File.separator + HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH
|
||||
+ File.separator + HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE).createNewFile();
|
||||
new File(tablePath + File.separator + HoodieTestCommitMetadataGenerator.DEFAULT_SECOND_PARTITION_PATH
|
||||
+ File.separator + HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE).createNewFile();
|
||||
Files.createFile(Paths.get(tablePath,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_FIRST_PARTITION_PATH,
|
||||
HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE));
|
||||
Files.createFile(Paths.get(tablePath,
|
||||
HoodieTestCommitMetadataGenerator.DEFAULT_SECOND_PARTITION_PATH,
|
||||
HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE));
|
||||
|
||||
CommandResult cr = getShell().executeCommand("cleans run --sparkMaster local --propsFilePath " + propsFilePath.toString());
|
||||
assertTrue(cr.isSuccess());
|
||||
|
||||
// After run clean, there should have 1 clean instant
|
||||
assertEquals("Loaded 1 clean and the count should match", 1,
|
||||
metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().count());
|
||||
assertEquals(1, metaClient.getActiveTimeline().reload().getCleanerTimeline().getInstants().count(),
|
||||
"Loaded 1 clean and the count should match");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user