@Test
  public void testGetAvgMetricForTaskTypeAndMetricName() {
    Map<Integer, TonyTaskData> taskDataMap = new TreeMap<>();
    TonyTaskData worker0Data = new TonyTaskData("worker", 0);
    TonyTaskData worker1Data = new TonyTaskData("worker", 1);

    double worker0AvgGPUUtilization = 10.0d;
    double worker1AvgGPUUtilization = 20.0d;
    double worker0AvgGPUFBMemoryUsage = 30.0d;
    double worker1AvgGPUFBMemoryUsage = 0.0d;
    double worker0AvgGPUMainMemoryUsage = 40.0d;
    double worker1AvgGPUMainMemoryUsage = -1.0d;

    worker0Data.setMetrics(ImmutableList.of(
        new Metric(Constants.AVG_GPU_UTILIZATION, worker0AvgGPUUtilization),
        new Metric(Constants.AVG_GPU_FB_MEMORY_USAGE, worker0AvgGPUFBMemoryUsage),
        new Metric(Constants.AVG_GPU_MAIN_MEMORY_USAGE, worker0AvgGPUMainMemoryUsage))
    );
    worker1Data.setMetrics(ImmutableList.of(
        new Metric(Constants.AVG_GPU_UTILIZATION, worker1AvgGPUUtilization),
        new Metric(Constants.AVG_GPU_FB_MEMORY_USAGE, worker1AvgGPUFBMemoryUsage),
        new Metric(Constants.AVG_GPU_MAIN_MEMORY_USAGE, worker1AvgGPUMainMemoryUsage)
    ));

    taskDataMap.put(0, worker0Data);
    taskDataMap.put(1, worker1Data);

    Assert.assertEquals(15.0d,
        TonyUtils.getAvgMetricForTaskTypeAndMetricName(ImmutableMap.of("worker", taskDataMap), "worker",
            Constants.AVG_GPU_UTILIZATION), 0);
    Assert.assertEquals(30.0d,
        TonyUtils.getAvgMetricForTaskTypeAndMetricName(ImmutableMap.of("worker", taskDataMap), "worker",
            Constants.AVG_GPU_FB_MEMORY_USAGE), 0);
    Assert.assertEquals(40.0d,
        TonyUtils.getAvgMetricForTaskTypeAndMetricName(ImmutableMap.of("worker", taskDataMap), "worker",
            Constants.AVG_GPU_MAIN_MEMORY_USAGE), 0);
  }
Worker 0 is missing metrics, but worker 1 has metrics; we should use worker 1's
max memory metrics.
test/com/linkedin/drelephant/tony/util/TonyUtilsTest.java