@Test
  public void testReplStatsTrackerLimit() {
    MessageSerializer serializer = MessageFactory.getDefaultInstanceForReplMetrics(conf).getSerializer();
    ReplStatsTracker repl = new ReplStatsTracker(10);
    // Check for k=10
    generateStatsString(10, repl);
    String replStatsTracker = repl.toString();
    String gzipSerialized = serializer.serialize(replStatsTracker);
    assertTrue("ReplStat string is " + gzipSerialized.length(), gzipSerialized.length() < ReplStatsTracker.RM_PROGRESS_LENGTH);
    // Check for k=5
    repl = new ReplStatsTracker(5);
    generateStatsString(5, repl);
    replStatsTracker = repl.toString();
    gzipSerialized = serializer.serialize(replStatsTracker);
    assertTrue("ReplStat string is " + gzipSerialized.length(), gzipSerialized.length() < ReplStatsTracker.RM_PROGRESS_LENGTH);
    // Check for k=2 & check NaN values doesn't get messed up due to formatter
    repl = new ReplStatsTracker(2);
    generateStatsString(2, repl);
    assertTrue(repl.toString().contains("NaN"));
  }
Unit Test class for In Memory Replication Metric Collection.
ql/src/test/org/apache/hadoop/hive/ql/parse/repl/metric/TestReplicationMetricCollector.java