FrontendIntegrationTest.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:ambry 作者:
/**
 * Tests {@link RestUtils.SubResource#Replicas} requests
 * <p/>
 * For each {@link PartitionId} in the {@link ClusterMap}, a {@link BlobId} is created. The replica list returned from
 * server is checked for equality against a locally obtained replica list.
 * @throws Exception
 */
@Test
public void getReplicasTest() throws Exception {
  List<? extends PartitionId> partitionIds = CLUSTER_MAP.getWritablePartitionIds();
  for (PartitionId partitionId : partitionIds) {
    String originalReplicaStr = partitionId.getReplicaIds().toString().replace(", ", ",");
    BlobId blobId = new BlobId(CommonTestUtils.getCurrentBlobIdVersion(), BlobId.BlobIdType.NATIVE,
        ClusterMapUtils.UNKNOWN_DATACENTER_ID, Account.UNKNOWN_ACCOUNT_ID, Container.UNKNOWN_CONTAINER_ID,
        partitionId, false);
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
        blobId.getID() + "/" + RestUtils.SubResource.Replicas, Unpooled.buffer(0));
    ResponseParts responseParts = nettyClient.sendRequest(httpRequest, null, null).get();
    HttpResponse response = getHttpResponse(responseParts);
    assertEquals("Unexpected response status", HttpResponseStatus.OK, response.status());
    ByteBuffer content = getContent(responseParts.queue, HttpUtil.getContentLength(response));
    JSONObject responseJson = new JSONObject(new String(content.array()));
    String returnedReplicasStr = responseJson.getString(GetReplicasHandler.REPLICAS_KEY).replace("\"", "");
    assertEquals("Replica IDs returned for the BlobId do no match with the replicas IDs of partition",
        originalReplicaStr, returnedReplicasStr);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号