modified caching test

added logic to test that cached response is specific to request payload.
Removed trailing '\0' from query parameter
pull/10588/head
Makarand Dharmapurikar 8 years ago
parent c3f494558b
commit e1b238458f
  1. 4
      src/core/lib/channel/http_client_filter.c
  2. 20
      test/cpp/interop/interop_client.cc

@ -332,10 +332,8 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
*/
char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice);
/* safe to use strlen since base64_encode will always add '\0' */
size_t path_length = strlen(t) + 1;
*(t + path_length) = '\0';
path_with_query_slice =
grpc_slice_sub(path_with_query_slice, 0, path_length);
grpc_slice_sub(path_with_query_slice, 0, strlen(t));
/* substitute previous path with the new path+query */
grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices(

@ -918,6 +918,26 @@ bool InteropClient::DoCacheableUnary() {
// second response is a cached copy of the first response
GPR_ASSERT(response2.payload().body() == response1.payload().body());
// Request 3
// Modify the request body so it will not get a cache hit
ts = gpr_now(GPR_CLOCK_PRECISE);
timestamp = std::to_string((long long unsigned)ts.tv_nsec);
SimpleRequest request1;
request1.mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
ClientContext context3;
SimpleResponse response3;
context3.set_cacheable(true);
context3.AddMetadata("x-user-ip", "1.2.3.4");
Status s3 =
serviceStub_.Get()->CacheableUnaryCall(&context3, request1, &response3);
if (!AssertStatusOk(s3)) {
return false;
}
gpr_log(GPR_DEBUG, "response 3 payload: %s",
response3.payload().body().c_str());
// Check that the response is different from the previous response.
GPR_ASSERT(response3.payload().body() != response1.payload().body());
return true;
}

Loading…
Cancel
Save