deniskuzZ commented on a change in pull request #2837:
URL: https://github.com/apache/hive/pull/2837#discussion_r761821097
##########
File path:
ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCompactionMetrics.java
##########
@@ -178,41 +178,42 @@ public void testInitiatorPerfMetricsDisabled() throws
Exception {
}
@Test
- @org.junit.Ignore("HIVE-25716")
public void testOldestReadyForCleaningAge() throws Exception {
conf.setIntVar(HiveConf.ConfVars.COMPACTOR_MAX_NUM_DELTA, 1);
- long oldStart = System.currentTimeMillis();
- Table old = newTable("default", "old_rfc", true);
- Partition oldP = newPartition(old, "part");
+ final String DB_NAME = "default";
+ final String OLD_TABLE_NAME = "old_rfc";
+ final String OLD_PARTITION_NAME = "part";
+ final String YOUNG_TABLE_NAME = "young_rfc";
+ final String YOUNG_PARTITION_NAME = "part";
+
+ Table old = newTable(DB_NAME, OLD_TABLE_NAME, true);
+ Partition oldP = newPartition(old, OLD_PARTITION_NAME);
addBaseFile(old, oldP, 20L, 20);
addDeltaFile(old, oldP, 21L, 22L, 2);
addDeltaFile(old, oldP, 23L, 24L, 2);
- burnThroughTransactions("default", "old_rfc", 25);
- CompactionRequest rqst = new CompactionRequest("default", "old_rfc",
CompactionType.MINOR);
- rqst.setPartitionname("ds=part");
- txnHandler.compact(rqst);
- startWorker();
+ burnThroughTransactions(DB_NAME, OLD_TABLE_NAME, 25);
+ doCompaction(DB_NAME, OLD_TABLE_NAME, OLD_PARTITION_NAME,
CompactionType.MINOR);
+ long oldTableClosestCqCommitTime = System.currentTimeMillis();
- long youngStart = System.currentTimeMillis();
- Table young = newTable("default", "young_rfc", true);
- Partition youngP = newPartition(young, "part");
+ Table young = newTable(DB_NAME, YOUNG_TABLE_NAME, true);
+ Partition youngP = newPartition(young, YOUNG_PARTITION_NAME);
addBaseFile(young, youngP, 20L, 20);
addDeltaFile(young, youngP, 21L, 22L, 2);
addDeltaFile(young, youngP, 23L, 24L, 2);
- burnThroughTransactions("default", "young_rfc", 25);
- rqst = new CompactionRequest("default", "young_rfc", CompactionType.MINOR);
- rqst.setPartitionname("ds=part");
- txnHandler.compact(rqst);
- startWorker();
+ burnThroughTransactions(DB_NAME, YOUNG_TABLE_NAME, 25);
+ doCompaction(DB_NAME, YOUNG_TABLE_NAME, YOUNG_PARTITION_NAME,
CompactionType.MINOR);
+ long youngTableClosestCqCommitTime = System.currentTimeMillis();
runAcidMetricService();
- long oldDiff = (System.currentTimeMillis() - oldStart)/1000;
- long youngDiff = (System.currentTimeMillis() - youngStart)/1000;
+ long nowClosestToAcidMetricServiceEnd = System.currentTimeMillis();
- long threshold = 1000;
-
Assert.assertTrue(Metrics.getOrCreateGauge(MetricsConstants.OLDEST_READY_FOR_CLEANING_AGE).intValue()
<= oldDiff + threshold);
-
Assert.assertTrue(Metrics.getOrCreateGauge(MetricsConstants.OLDEST_READY_FOR_CLEANING_AGE).intValue()
>= youngDiff);
+ long oldAgeInSeconds = (nowClosestToAcidMetricServiceEnd -
oldTableClosestCqCommitTime) / 1000;
+ long youngAgeInSeconds = (nowClosestToAcidMetricServiceEnd -
youngTableClosestCqCommitTime) / 1000;
+
+ int gaugeValue =
Metrics.getOrCreateGauge(MetricsConstants.OLDEST_READY_FOR_CLEANING_AGE).intValue();
+ Assert.assertTrue(gaugeValue <= oldAgeInSeconds);
Review comment:
why not check that the gauge value is in some range of `oldAgeInSeconds`
(+- 10ms)? Not sure why youngAgeInSeconds is even relevant here.
--
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]