@Test
public void verifyTrackingForAggregateLatencyRecords() throws Exception {

  // verify that tracking of aggregate latency records works as expected
  final int numTasks = 100;
  AbfsPerfTracker abfsPerfTracker = new AbfsPerfTracker(accountName, filesystemName, true);
  String latencyDetails = abfsPerfTracker.getClientLatency();
  assertThat(latencyDetails).describedAs("AbfsPerfTracker should be empty").isNull();
  List<Callable<Integer>> tasks = new ArrayList<>();
  AbfsHttpOperation httpOperation = new AbfsHttpOperation(url, "GET", new ArrayList<>());
  for (int i = 0; i < numTasks; i++) {
    tasks.add(() -> {
      try (AbfsPerfInfo tracker = new AbfsPerfInfo(abfsPerfTracker, "oneOperationCaller",
              "oneOperationCallee")) {
        tracker.registerResult(httpOperation).registerSuccess(true)
                .registerAggregates(Instant.now(), TEST_AGGREGATE_COUNT);
        return 0;
      }
    });
  }
  for (Future<Integer> fr: executorService.invokeAll(tasks)) {
    fr.get();
  }
  for (int i = 0; i < numTasks; i++) {
    latencyDetails = abfsPerfTracker.getClientLatency();
    assertThat(latencyDetails).describedAs("AbfsPerfTracker should return non-null record").isNotNull();
    assertThat(latencyDetails).describedAs("Latency record should be in the correct format")
      .containsPattern("h=[^ ]* t=[^ ]* a=bogusFilesystemName c=bogusAccountName cr=oneOperationCaller"
              + " ce=oneOperationCallee r=Succeeded l=[0-9]+ ls=[0-9]+ lc=" + TEST_AGGREGATE_COUNT
              + " s=0 e= ci=[^ ]* ri=[^ ]* bs=0 br=0 m=GET u=http%3A%2F%2Fwww.microsoft.com%2FbogusFile");
  }
  latencyDetails = abfsPerfTracker.getClientLatency();
  assertThat(latencyDetails).describedAs("AbfsPerfTracker should return no record").isNull();
}