@Test
public void testLegacyAllocationTrackingWorkflow() throws Exception {

  int time1 = 5;
  int time2 = 10;
  // Enable a tracking session on Process 1
  TrackAllocationsResponse expected1 = TrackAllocationsResponse.newBuilder()
    .setStatus(TrackStatus.newBuilder().setStatus(TrackStatus.Status.SUCCESS).setStartTime(time1))
    .setInfo(
      AllocationsInfo.newBuilder().setStartTime(time1).setEndTime(Long.MAX_VALUE).setLegacy(true).build()).build();
  StreamObserver<TrackAllocationsResponse> observer1 = mock(StreamObserver.class);
  myProxy.trackAllocations(
    TrackAllocationsRequest.newBuilder().setSession(SESSION1).setEnabled(true).setRequestTime(time1).build(),
    observer1);
  assertThat(myTracker.getTrackingState()).isTrue();
  verify(observer1, times(1)).onNext(expected1);
  verify(observer1, times(1)).onCompleted();
  // Verify that query for bytes on at ongoing session does not return any byte contents
  assertThat(myProxyBytesCache.containsKey(Integer.toString(time1))).isFalse();
  // Disable a tracking session on Process 1
  TrackAllocationsResponse expected2 = TrackAllocationsResponse.newBuilder()
    .setStatus(TrackStatus.newBuilder().setStatus(TrackStatus.Status.SUCCESS).setStartTime(time1))
    .setInfo(AllocationsInfo.newBuilder().setStartTime(time1).setEndTime(time2).setSuccess(true).setLegacy(true).build())
    .build();
  StreamObserver<TrackAllocationsResponse> observer2 = mock(StreamObserver.class);
  myProxy.trackAllocations(
    TrackAllocationsRequest.newBuilder().setSession(SESSION1).setEnabled(false).setRequestTime(time2).build(),
    observer2);
  verify(observer2, times(1)).onNext(expected2);
  verify(observer2, times(1)).onCompleted();
  // Mock completion of the parsing process and the resulting data.
  myTracker.getParsingWaitLatch().countDown();
  myTracker.getParsingDoneLatch().await();
  assertThat(myProxyBytesCache.get(Integer.toString(time1)))
    .isEqualTo(ByteString.copyFrom(FakeLegacyAllocationTracker.Companion.getRAW_DATA()));
}