Skip to content

Commit 558170a

Browse files
committed
test refactor + use junit5
1 parent 2313e42 commit 558170a

8 files changed

Lines changed: 277 additions & 280 deletions

ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/CompactorTest.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,26 +724,36 @@ protected long compactInTxn(CompactionRequest rqst) throws Exception {
724724

725725
long compactInTxn(CompactionRequest rqst, CommitAction commitAction) throws Exception {
726726
txnHandler.compact(rqst);
727+
727728
FindNextCompactRequest findNextCompactRequest = new FindNextCompactRequest();
728729
findNextCompactRequest.setWorkerId("fred");
729730
findNextCompactRequest.setWorkerVersion(WORKER_VERSION);
731+
730732
CompactionInfo ci = txnHandler.findNextToCompact(findNextCompactRequest);
731733
ci.runAs = rqst.getRunas() == null ? System.getProperty("user.name") : rqst.getRunas();
734+
732735
long compactorTxnId = openTxn(TxnType.COMPACTION);
736+
733737
// Need to create a valid writeIdList to set the highestWriteId in ci
734-
ValidTxnList validTxnList = TxnCommonUtils.createValidReadTxnList(txnHandler.getOpenTxns(), compactorTxnId);
735-
GetValidWriteIdsRequest writeIdsRequest = new GetValidWriteIdsRequest();
738+
ValidTxnList validTxnList = TxnCommonUtils.createValidReadTxnList(
739+
txnHandler.getOpenTxns(Collections.singletonList(TxnType.READ_ONLY)), compactorTxnId);
740+
741+
GetValidWriteIdsRequest writeIdsRequest = new GetValidWriteIdsRequest(
742+
Collections.singletonList(ci.getFullTableName()));
736743
writeIdsRequest.setValidTxnList(validTxnList.writeToString());
737-
writeIdsRequest.setFullTableNames(
738-
Collections.singletonList(TxnUtils.getFullTableName(rqst.getDbname(), rqst.getTablename())));
744+
739745
// with this ValidWriteIdList is capped at whatever HWM validTxnList has
740746
ValidCompactorWriteIdList tblValidWriteIds = TxnUtils.createValidCompactWriteIdList(
741-
txnHandler.getValidWriteIds(writeIdsRequest).getTblValidWriteIds().getFirst());
747+
txnHandler.getValidWriteIds(writeIdsRequest).getTblValidWriteIds()
748+
.getFirst());
742749

743750
ci.highestWriteId = tblValidWriteIds.getHighWatermark();
744751
txnHandler.updateCompactorState(ci, compactorTxnId);
745752

746753
switch (commitAction) {
754+
case MARK_COMPACTED ->
755+
txnHandler.markCompacted(ci);
756+
747757
case COMMIT -> {
748758
txnHandler.markCompacted(ci);
749759
txnHandler.commitTxn(new CommitTxnRequest(compactorTxnId));
@@ -760,6 +770,7 @@ long compactInTxn(CompactionRequest rqst, CommitAction commitAction) throws Exce
760770
enum CommitAction {
761771
COMMIT,
762772
ABORT,
773+
MARK_COMPACTED,
763774
NONE
764775
}
765776

ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestAbortCleanupUsingCompactionCycle.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
package org.apache.hadoop.hive.ql.txn.compactor;
1919

2020
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
21+
import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
2122
import org.junit.jupiter.api.BeforeEach;
2223

2324
public class TestAbortCleanupUsingCompactionCycle extends TestCleaner {
24-
@Override
25+
2526
@BeforeEach
27+
@Override
2628
public void setup() throws Exception {
2729
super.setup();
28-
MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.COMPACTOR_CLEAN_ABORTS_USING_CLEANER, false);
30+
MetastoreConf.setBoolVar(conf, ConfVars.COMPACTOR_CLEAN_ABORTS_USING_CLEANER, false);
2931
}
3032
}

ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestAbortCleanupUsingCompactionCycleWithMinHistoryWriteId.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
package org.apache.hadoop.hive.ql.txn.compactor;
1919

2020
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
21+
import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
2122
import org.junit.jupiter.api.BeforeEach;
2223

2324
public class TestAbortCleanupUsingCompactionCycleWithMinHistoryWriteId extends TestCleaner {
24-
@Override
25+
2526
@BeforeEach
27+
@Override
2628
public void setup() throws Exception {
2729
super.setup();
28-
MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.COMPACTOR_CLEAN_ABORTS_USING_CLEANER, false);
30+
MetastoreConf.setBoolVar(conf, ConfVars.COMPACTOR_CLEAN_ABORTS_USING_CLEANER, false);
2931
}
3032

3133
@Override

0 commit comments

Comments
 (0)