private void assertWithTolerance(String txt, long expected, long actual) {
    long lowExpected = expected - (expected / 10L);
    long highExpected = expected + (expected / 10L);

    StringBuffer msg = new StringBuffer(txt);
    msg.append(" (expected ");
    msg.append(lowExpected);
    msg.append(" <= x <= ");
    msg.append(highExpected);
    msg.append(" but actual = ");
    msg.append(actual);
    msg.append(")");

    assertTrue(msg.toString(), actual >= lowExpected && actual <= highExpected);
  }
Helper to verify the actual value by comparing it with a +/- tolerance of
10% with the expected value.

@param txt Assertion message
@param expected The expected value (tolerance will be applied)
@param actual Actual test outcome
llap-common/src/test/org/apache/hadoop/hive/llap/metrics/TestReadWriteLockMetrics.java