@Test
  public void testBasicMetricsUpdate() {
    TezSessionPoolManager poolManager = mock(TezSessionPoolManager.class);
    List<TezSessionState> sessions = testSessions();
    when(poolManager.getSessions()).thenReturn(sessions);

    TezSessionPoolManagerMetrics metrics = new TezSessionPoolManagerMetrics(poolManager);
    metrics.collectMetrics();

    double expectedRunningTasks = NO_OF_SESSIONS * NO_OF_RUNNING_TASKS_PER_SESSION;
    double expectedPendingTasks = NO_OF_SESSIONS * NO_OF_PENDING_TASKS_PER_SESSION;
    double expectedBacklog = expectedPendingTasks / (expectedRunningTasks + 1);

    Assert.assertEquals(expectedRunningTasks, metrics.runningTasksCount.value, 0.0001);
    Assert.assertEquals(expectedPendingTasks, metrics.pendingTasksCount.value, 0.0001);
    Assert.assertEquals(expectedBacklog, metrics.taskBacklogRatio.value, 0.0001);
  }
This method tests the core metric calculation logic (refreshMetrics)
without involving the actual metric collection process.
ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestTezSessionPoolManagerMetrics.java