@Test
  public void testFetchCRC() throws IOException, InterruptedException, StoreException, ReflectiveOperationException {
    // This works for TestStore, not real store
    assumeFalse(this.validateRequestOnStoreState);

    // Get rid of  the mock helper, we need the real token-helper to issue real store requests
    FindTokenHelper findTokenHelper1 = new FindTokenHelper(storeKeyFactory, replicationConfig);
    ambryRequests = new AmbryServerRequests(storageManager, requestResponseChannel, clusterMap, dataNodeId,
        clusterMap.getMetricRegistry(), serverMetrics, findTokenHelper1, null, replicationManager,
        storeKeyFactory, serverConfig, diskManagerConfig, storeKeyConverterFactory, statsManager, helixParticipant);

    DataNodeId datanode = clusterMap.getDataNodeIds().stream()
        .filter(node -> node.getDatacenterName().equals(localDc))
        .findFirst().get();
    ReplicaId replica = clusterMap.getReplicaIds(datanode).get(0);
    PartitionId id = replica.getPartitionId();

    // Create local store
    BlobStore localStore =
        new BlobStore(id.getReplicaIds().get(0), new StoreConfig(verifiableProperties),
            Utils.newScheduler(1, false), Utils.newScheduler(1, false),
            null, new DiskIOScheduler(null), StoreTestUtils.DEFAULT_DISK_SPACE_ALLOCATOR,
            new StoreMetrics(clusterMap.getMetricRegistry()), new StoreMetrics("UnderCompaction",
            clusterMap.getMetricRegistry()), null, null, null,
            Collections.singletonList(mock(ReplicaStatusDelegate.class)), new MockTime(),
            new InMemAccountService(false, false), null,
            Utils.newScheduler(1, false));
    localStore.start();
    storageManager.overrideStoreToReturn = localStore;

    // Create a blob
    BlobId blobId = generateRandomBlobId(id);
    String testContent = "test_content";
    BlobProperties properties = new BlobProperties(testContent.length(), "serviceId", blobId.getAccountId(),
        blobId.getAccountId(), false);
    ByteBuffer content_buf = ByteBuffer.allocate(testContent.length());
    content_buf.put(testContent.getBytes());
    content_buf.flip(); // Most important line !
    ByteBuf content_bytebuf = Unpooled.wrappedBuffer(content_buf);

    // Put blob
    String clientId = "replication-metadata-" + datanode.getHostname() + "[" + datanode.getDatacenterName() + "]";
    RequestOrResponse put_request = new PutRequest(TestUtils.RANDOM.nextInt(), clientId, blobId, properties,
        content_buf, content_bytebuf, testContent.length(), BlobType.DataBlob, null);
    Response response = sendRequestGetResponse(put_request, ServerErrorCode.NoError);

    // Send metadata request from regular server app
    verifyCRCInMetadata(id, id.toPathString(), datanode, null);

    // Get CRC from in-mem store
    EnumSet<StoreGetOptions> storeGetOptions = EnumSet.of(StoreGetOptions.Store_Include_Deleted,
        StoreGetOptions.Store_Include_Expired);
    StoreInfo stinfo = localStore.get(Collections.singletonList(blobId), storeGetOptions);
    MessageReadSet rdset = stinfo.getMessageReadSet();
    MessageInfo minfo2 = stinfo.getMessageReadSetInfo().get(0);
    rdset.doPrefetch(0, minfo2.getSize() - MessageFormatRecord.Crc_Size,
        MessageFormatRecord.Crc_Size);
    ByteBuf crcbuf = rdset.getPrefetchedData(0);
    long crc = crcbuf.getLong(0);
    crcbuf.release();
    verifyCRCInMetadata(id, BackupCheckerThread.DR_Verifier_Keyword + File.separator + id.toPathString(),
        datanode, new Long(crc));

    // Delete blob and get metadata again
    RequestOrResponse del_request = new DeleteRequest(TestUtils.RANDOM.nextInt(), clientId, blobId,
        SystemTime.getInstance().milliseconds());
    sendRequestGetResponse(del_request, ServerErrorCode.NoError);
    verifyCRCInMetadata(id, BackupCheckerThread.DR_Verifier_Keyword + File.separator + id.toPathString(),
        datanode, null);
  }
Test that cross-colo metrics are updated correctly when {@link AmbryRequests} handles {@link GetRequest} and
{@link ReplicaMetadataRequest}
@throws Exception
ambry-server/src/test/java/com/github/ambry/server/AmbryServerRequestsTest.java