adoroszlai commented on code in PR #7768:
URL: https://github.com/apache/ozone/pull/7768#discussion_r1936687792
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneRepairShell.java:
##########
@@ -105,23 +115,35 @@ public void testUpdateTransactionInfoTable() throws
Exception {
String.format("The highest transaction info has been updated to:
(t:%s, i:%s)", testTerm, testIndex)
);
- String cmdOut2 = scanTransactionInfoTable(dbPath);
+ String cmdOut2 = scanTransactionInfoTable(dbPath, component);
assertThat(cmdOut2).contains(testTerm + "#" + testIndex);
withTextFromSystemIn("y")
- .execute(() -> cmd.execute("om", "update-transaction",
+ .execute(() -> cmd.execute(componentLowerCase, "update-transaction",
"--db", dbPath,
"--term", originalHighestTermIndex[0],
"--index", originalHighestTermIndex[1]));
cluster.getOzoneManager().restart();
try (OzoneClient ozoneClient = cluster.newClient()) {
- ozoneClient.getObjectStore().createVolume("vol1");
+ ozoneClient.getObjectStore().createVolume("vol-" + componentLowerCase);
+ }
+ }
+
+ private String getDbPath(Component component) {
+ switch (component) {
+ case OM:
+ return new File(OMStorage.getOmDbDir(conf) + "/" + OM_DB_NAME).getPath();
+ case SCM:
+ return new File(ServerUtils.getScmDbDir(conf) + "/" +
SCM_DB_NAME).getPath();
+ default:
+ throw new IllegalStateException("Unknown component: " + component);
}
}
- private String scanTransactionInfoTable(String dbPath) {
+ private String scanTransactionInfoTable(String dbPath, Component component) {
CommandLine debugCmd = new OzoneDebug().getCmd();
- debugCmd.execute("ldb", "--db", dbPath, "scan", "--column_family",
"transactionInfoTable");
+ debugCmd.execute("ldb", "--db", dbPath, "scan", "--column_family",
+ transactionInfoRepair.getColumnFamily(component).getName());
Review Comment:
```suggestion
TransactionInfoRepair.getColumnFamily(component).getName());
```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneRepairShell.java:
##########
@@ -80,20 +87,23 @@ static void cleanup() {
IOUtils.closeQuietly(cluster);
}
- @Test
- public void testUpdateTransactionInfoTable() throws Exception {
+ @ParameterizedTest
+ @EnumSource(value = Component.class, names = {"OM", "SCM"})
+ public void testUpdateTransactionInfoTable(Component component) throws
Exception {
CommandLine cmd = new OzoneRepair().getCmd();
- String dbPath = new File(OMStorage.getOmDbDir(conf) + "/" +
OM_DB_NAME).getPath();
+ String dbPath = getDbPath(component);
+ String componentLowerCase = component.toString().toLowerCase();
Review Comment:
Prefer `Enum#name()`, `toString()` may be overridden.
```suggestion
String componentLowerCase = component.name().toLowerCase();
```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneRepairShell.java:
##########
@@ -52,7 +58,7 @@ public class TestOzoneRepairShell {
private static MiniOzoneCluster cluster = null;
private static OzoneConfiguration conf = null;
private static String om;
-
+ private static TransactionInfoRepair transactionInfoRepair;
Review Comment:
```suggestion
```
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/TransactionInfoRepair.java:
##########
@@ -122,8 +122,7 @@ protected Component serviceToBeOffline() {
}
}
- private DBColumnFamilyDefinition<String, TransactionInfo> getColumnFamily() {
- Component component = serviceToBeOffline();
+ public DBColumnFamilyDefinition<String, TransactionInfo>
getColumnFamily(Component component) {
Review Comment:
This method can be `static`, then we don't need to instantiate in the test.
```suggestion
public static DBColumnFamilyDefinition<String, TransactionInfo>
getColumnFamily(Component component) {
```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneRepairShell.java:
##########
@@ -61,6 +67,7 @@ public static void init() throws Exception {
cluster = MiniOzoneCluster.newBuilder(conf).build();
cluster.waitForClusterToBeReady();
om = conf.get(OZONE_OM_ADDRESS_KEY);
+ transactionInfoRepair = new TransactionInfoRepair();
Review Comment:
```suggestion
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]