[ 
https://issues.apache.org/jira/browse/HIVE-25716?focusedWorklogId=689892&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-689892
 ]

ASF GitHub Bot logged work on HIVE-25716:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Dec/21 10:34
            Start Date: 03/Dec/21 10:34
    Worklog Time Spent: 10m 
      Work Description: 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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 689892)
    Time Spent: 0.5h  (was: 20m)

> Fix flaky test TestCompactionMetrics#testOldestReadyForCleaningAge
> ------------------------------------------------------------------
>
>                 Key: HIVE-25716
>                 URL: https://issues.apache.org/jira/browse/HIVE-25716
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 4.0.0
>            Reporter: Karen Coppage
>            Assignee: Viktor Csomor
>            Priority: Major
>              Labels: flaky-test, pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Flaky check failed on run #59:
> [http://ci.hive.apache.org/job/hive-flaky-check/467/|http://ci.hive.apache.org/job/hive-flaky-check/467/]
> {code:java}
> java.lang.AssertionError
>       at org.junit.Assert.fail(Assert.java:87)
>       at org.junit.Assert.assertTrue(Assert.java:42)
>       at org.junit.Assert.assertTrue(Assert.java:53)
>       at 
> org.apache.hadoop.hive.ql.txn.compactor.TestCompactionMetrics.testOldestReadyForCleaningAge(TestCompactionMetrics.java:214)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to