Browse Source

Merge github.com:grpc/grpc into one-pass

Conflicts:
	Makefile
Craig Tiller 10 years ago
parent
commit
7551fa6149
40 changed files with 361 additions and 717 deletions
  1. 4 2
      BUILD
  2. 24 473
      Makefile
  3. 7 3
      build.json
  4. 0 4
      examples/pubsub/main.cc
  5. 0 2
      examples/pubsub/publisher_test.cc
  6. 0 2
      examples/pubsub/subscriber_test.cc
  7. 15 8
      include/grpc++/client_context.h
  8. 11 7
      include/grpc++/completion_queue.h
  9. 11 11
      include/grpc++/credentials.h
  10. 10 11
      include/grpc++/impl/grpc_library.h
  11. 3 1
      include/grpc++/server.h
  12. 9 4
      include/grpc++/server_context.h
  13. 1 1
      include/grpc++/stream.h
  14. 106 0
      include/grpc++/time.h
  15. 2 3
      src/cpp/client/channel.cc
  16. 3 1
      src/cpp/client/channel.h
  17. 2 13
      src/cpp/client/client_context.cc
  18. 6 6
      src/cpp/client/secure_credentials.cc
  19. 3 9
      src/cpp/common/completion_queue.cc
  20. 2 2
      src/cpp/server/server.cc
  21. 4 4
      src/cpp/server/server_context.cc
  22. 6 1
      src/cpp/util/time.cc
  23. 7 14
      templates/Makefile.template
  24. 57 57
      test/core/end2end/gen_build_json.py
  25. 1 3
      test/cpp/client/credentials_test.cc
  26. 3 7
      test/cpp/end2end/async_end2end_test.cc
  27. 30 13
      test/cpp/end2end/end2end_test.cc
  28. 2 6
      test/cpp/end2end/generic_end2end_test.cc
  29. 0 4
      test/cpp/interop/client.cc
  30. 4 2
      test/cpp/interop/client_helper.cc
  31. 0 2
      test/cpp/interop/server.cc
  32. 0 2
      test/cpp/qps/qps_driver.cc
  33. 0 3
      test/cpp/qps/smoke_test.cc
  34. 1 3
      test/cpp/qps/worker.cc
  35. 1 4
      test/cpp/util/cli_call_test.cc
  36. 0 4
      test/cpp/util/grpc_cli.cc
  37. 1 4
      test/cpp/util/time_test.cc
  38. 17 17
      tools/run_tests/tests.json
  39. 2 1
      vsprojects/grpc++/grpc++.vcxproj
  40. 6 3
      vsprojects/grpc++/grpc++.vcxproj.filters

+ 4 - 2
BUILD

@@ -575,7 +575,6 @@ cc_library(
     "src/cpp/client/channel.h",
     "src/cpp/proto/proto_utils.h",
     "src/cpp/server/thread_pool.h",
-    "src/cpp/util/time.h",
     "src/cpp/client/secure_credentials.cc",
     "src/cpp/server/secure_server_credentials.cc",
     "src/cpp/client/channel.cc",
@@ -617,6 +616,7 @@ cc_library(
     "include/grpc++/generic_stub.h",
     "include/grpc++/impl/call.h",
     "include/grpc++/impl/client_unary_call.h",
+    "include/grpc++/impl/grpc_library.h",
     "include/grpc++/impl/internal_stub.h",
     "include/grpc++/impl/rpc_method.h",
     "include/grpc++/impl/rpc_service_method.h",
@@ -636,6 +636,7 @@ cc_library(
     "include/grpc++/status_code_enum.h",
     "include/grpc++/stream.h",
     "include/grpc++/thread_pool_interface.h",
+    "include/grpc++/time.h",
   ],
   includes = [
     "include",
@@ -655,7 +656,6 @@ cc_library(
     "src/cpp/client/channel.h",
     "src/cpp/proto/proto_utils.h",
     "src/cpp/server/thread_pool.h",
-    "src/cpp/util/time.h",
     "src/cpp/client/channel.cc",
     "src/cpp/client/channel_arguments.cc",
     "src/cpp/client/client_context.cc",
@@ -695,6 +695,7 @@ cc_library(
     "include/grpc++/generic_stub.h",
     "include/grpc++/impl/call.h",
     "include/grpc++/impl/client_unary_call.h",
+    "include/grpc++/impl/grpc_library.h",
     "include/grpc++/impl/internal_stub.h",
     "include/grpc++/impl/rpc_method.h",
     "include/grpc++/impl/rpc_service_method.h",
@@ -714,6 +715,7 @@ cc_library(
     "include/grpc++/status_code_enum.h",
     "include/grpc++/stream.h",
     "include/grpc++/thread_pool_interface.h",
+    "include/grpc++/time.h",
   ],
   includes = [
     "include",

File diff suppressed because it is too large
+ 24 - 473
Makefile


+ 7 - 3
build.json

@@ -28,6 +28,7 @@
         "include/grpc++/generic_stub.h",
         "include/grpc++/impl/call.h",
         "include/grpc++/impl/client_unary_call.h",
+        "include/grpc++/impl/grpc_library.h",
         "include/grpc++/impl/internal_stub.h",
         "include/grpc++/impl/rpc_method.h",
         "include/grpc++/impl/rpc_service_method.h",
@@ -46,13 +47,13 @@
         "include/grpc++/status.h",
         "include/grpc++/status_code_enum.h",
         "include/grpc++/stream.h",
-        "include/grpc++/thread_pool_interface.h"
+        "include/grpc++/thread_pool_interface.h",
+        "include/grpc++/time.h"
       ],
       "headers": [
         "src/cpp/client/channel.h",
         "src/cpp/proto/proto_utils.h",
-        "src/cpp/server/thread_pool.h",
-        "src/cpp/util/time.h"
+        "src/cpp/server/thread_pool.h"
       ],
       "src": [
         "src/cpp/client/channel.cc",
@@ -808,6 +809,7 @@
     },
     {
       "name": "census_statistics_multiple_writers_test",
+      "flaky": true,
       "build": "test",
       "language": "c",
       "src": [
@@ -822,6 +824,7 @@
     },
     {
       "name": "census_statistics_performance_test",
+      "flaky": true,
       "build": "test",
       "language": "c",
       "src": [
@@ -836,6 +839,7 @@
     },
     {
       "name": "census_statistics_quick_test",
+      "flaky": true,
       "build": "test",
       "language": "c",
       "src": [

+ 0 - 4
examples/pubsub/main.cc

@@ -31,7 +31,6 @@
  *
  */
 
-#include <chrono>
 #include <fstream>
 #include <memory>
 #include <sstream>
@@ -65,7 +64,6 @@ const char kMessageData[] = "Test Data";
 }  // namespace
 
 int main(int argc, char** argv) {
-  grpc_init();
   grpc::testing::InitTest(&argc, &argv, true);
   gpr_log(GPR_INFO, "Start PUBSUB client");
 
@@ -146,7 +144,5 @@ int main(int argc, char** argv) {
 
   subscriber.Shutdown();
   publisher.Shutdown();
-  channel.reset();
-  grpc_shutdown();
   return 0;
 }

+ 0 - 2
examples/pubsub/publisher_test.cc

@@ -148,10 +148,8 @@ TEST_F(PublisherTest, TestPublisher) {
 
 int main(int argc, char** argv) {
   grpc_test_init(argc, argv);
-  grpc_init();
   ::testing::InitGoogleTest(&argc, argv);
   gpr_log(GPR_INFO, "Start test ...");
   int result = RUN_ALL_TESTS();
-  grpc_shutdown();
   return result;
 }

+ 0 - 2
examples/pubsub/subscriber_test.cc

@@ -147,10 +147,8 @@ TEST_F(SubscriberTest, TestSubscriber) {
 
 int main(int argc, char** argv) {
   grpc_test_init(argc, argv);
-  grpc_init();
   ::testing::InitGoogleTest(&argc, argv);
   gpr_log(GPR_INFO, "Start test ...");
   int result = RUN_ALL_TESTS();
-  grpc_shutdown();
   return result;
 }

+ 15 - 8
include/grpc++/client_context.h

@@ -34,15 +34,13 @@
 #ifndef GRPCXX_CLIENT_CONTEXT_H
 #define GRPCXX_CLIENT_CONTEXT_H
 
-#include <chrono>
 #include <map>
 #include <string>
 
 #include <grpc/support/log.h>
 #include <grpc/support/time.h>
 #include <grpc++/config.h>
-
-using std::chrono::system_clock;
+#include <grpc++/time.h>
 
 struct grpc_call;
 struct grpc_completion_queue;
@@ -87,8 +85,19 @@ class ClientContext {
     return trailing_metadata_;
   }
 
-  void set_absolute_deadline(const system_clock::time_point& deadline);
-  system_clock::time_point absolute_deadline();
+  template <typename T>
+  void set_deadline(const T& deadline) {
+    TimePoint<T> deadline_tp(deadline);
+    deadline_ = deadline_tp.raw_time();
+  }
+
+#ifndef GRPC_CXX0X_NO_CHRONO
+  std::chrono::system_clock::time_point deadline() {
+    return Timespec2Timepoint(deadline_);
+  }
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+  gpr_timespec raw_deadline() { return deadline_; }
 
   void set_authority(const grpc::string& authority) { authority_ = authority; }
 
@@ -125,14 +134,12 @@ class ClientContext {
   grpc_completion_queue* cq() { return cq_; }
   void set_cq(grpc_completion_queue* cq) { cq_ = cq; }
 
-  gpr_timespec RawDeadline() { return absolute_deadline_; }
-
   grpc::string authority() { return authority_; }
 
   bool initial_metadata_received_;
   grpc_call* call_;
   grpc_completion_queue* cq_;
-  gpr_timespec absolute_deadline_;
+  gpr_timespec deadline_;
   grpc::string authority_;
   std::multimap<grpc::string, grpc::string> send_initial_metadata_;
   std::multimap<grpc::string, grpc::string> recv_initial_metadata_;

+ 11 - 7
include/grpc++/completion_queue.h

@@ -34,9 +34,10 @@
 #ifndef GRPCXX_COMPLETION_QUEUE_H
 #define GRPCXX_COMPLETION_QUEUE_H
 
-#include <chrono>
-#include <grpc++/impl/client_unary_call.h>
 #include <grpc/support/time.h>
+#include <grpc++/impl/client_unary_call.h>
+#include <grpc++/impl/grpc_library.h>
+#include <grpc++/time.h>
 
 struct grpc_completion_queue;
 
@@ -71,21 +72,24 @@ class CompletionQueueTag {
 };
 
 // grpc_completion_queue wrapper class
-class CompletionQueue {
+class CompletionQueue : public GrpcLibrary {
  public:
   CompletionQueue();
   explicit CompletionQueue(grpc_completion_queue* take);
-  ~CompletionQueue();
+  ~CompletionQueue() GRPC_OVERRIDE;
 
   // Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT
   enum NextStatus { SHUTDOWN, GOT_EVENT, TIMEOUT };
 
   // Nonblocking (until deadline) read from queue.
   // Cannot rely on result of tag or ok if return is TIMEOUT
-  NextStatus AsyncNext(void** tag, bool* ok,
-                       std::chrono::system_clock::time_point deadline);
+  template<typename T>
+  NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) {
+    TimePoint<T> deadline_tp(deadline);
+    return AsyncNextInternal(tag, ok, deadline_tp.raw_time());
+  }
 
-  // Blocking (until deadline) read from queue.
+  // Blocking read from queue.
   // Returns false if the queue is ready for destruction, true if event
 
   bool Next(void** tag, bool* ok) {

+ 11 - 11
include/grpc++/credentials.h

@@ -34,19 +34,19 @@
 #ifndef GRPCXX_CREDENTIALS_H
 #define GRPCXX_CREDENTIALS_H
 
-#include <chrono>
 #include <memory>
 
 #include <grpc++/config.h>
+#include <grpc++/impl/grpc_library.h>
 
 namespace grpc {
 class ChannelArguments;
 class ChannelInterface;
 class SecureCredentials;
 
-class Credentials {
+class Credentials : public GrpcLibrary {
  public:
-  virtual ~Credentials();
+  ~Credentials() GRPC_OVERRIDE;
 
  protected:
   friend std::unique_ptr<Credentials> CompositeCredentials(
@@ -98,20 +98,20 @@ std::unique_ptr<Credentials> ComputeEngineCredentials();
 // Builds service account credentials.
 // json_key is the JSON key string containing the client's private key.
 // scope is a space-delimited list of the requested permissions.
-// token_lifetime is the lifetime of each token acquired through this service
-// account credentials. It should be positive and should not exceed
-// grpc_max_auth_token_lifetime or will be cropped to this value.
+// token_lifetime_seconds is the lifetime in seconds of each token acquired
+// through this service account credentials. It should be positive and should
+// not exceed grpc_max_auth_token_lifetime or will be cropped to this value.
 std::unique_ptr<Credentials> ServiceAccountCredentials(
     const grpc::string& json_key, const grpc::string& scope,
-    std::chrono::seconds token_lifetime);
+    long token_lifetime_seconds);
 
 // Builds JWT credentials.
 // json_key is the JSON key string containing the client's private key.
-// token_lifetime is the lifetime of each Json Web Token (JWT) created with
-// this credentials.  It should not exceed grpc_max_auth_token_lifetime or
-// will be cropped to this value.
+// token_lifetime_seconds is the lifetime in seconds of each Json Web Token
+// (JWT) created with this credentials. It should not exceed
+// grpc_max_auth_token_lifetime or will be cropped to this value.
 std::unique_ptr<Credentials> JWTCredentials(
-    const grpc::string& json_key, std::chrono::seconds token_lifetime);
+    const grpc::string& json_key, long token_lifetime_seconds);
 
 // Builds refresh token credentials.
 // json_refresh_token is the JSON string containing the refresh token along

+ 10 - 11
src/cpp/util/time.h → include/grpc++/impl/grpc_library.h

@@ -31,21 +31,20 @@
  *
  */
 
-#ifndef GRPC_INTERNAL_CPP_UTIL_TIME_H
-#define GRPC_INTERNAL_CPP_UTIL_TIME_H
+#ifndef GRPCXX_IMPL_GRPC_LIBRARY_H
+#define GRPCXX_IMPL_GRPC_LIBRARY_H
 
-#include <chrono>
-
-#include <grpc/support/time.h>
+#include <grpc/grpc.h>
 
 namespace grpc {
 
-// from and to should be absolute time.
-void Timepoint2Timespec(const std::chrono::system_clock::time_point& from,
-                        gpr_timespec* to);
-
-std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);
+class GrpcLibrary {
+ public:
+  GrpcLibrary() { grpc_init(); }
+  virtual ~GrpcLibrary() { grpc_shutdown(); }
+};
 
 }  // namespace grpc
 
-#endif  // GRPC_INTERNAL_CPP_UTIL_TIME_H
+
+#endif  // GRPCXX_IMPL_GRPC_LIBRARY_H

+ 3 - 1
include/grpc++/server.h

@@ -40,6 +40,7 @@
 #include <grpc++/completion_queue.h>
 #include <grpc++/config.h>
 #include <grpc++/impl/call.h>
+#include <grpc++/impl/grpc_library.h>
 #include <grpc++/impl/service_type.h>
 #include <grpc++/impl/sync.h>
 #include <grpc++/status.h>
@@ -56,7 +57,8 @@ class ServerCredentials;
 class ThreadPoolInterface;
 
 // Currently it only supports handling rpcs in a single thread.
-class Server GRPC_FINAL : private CallHook,
+class Server GRPC_FINAL : public GrpcLibrary,
+                          private CallHook,
                           private AsynchronousService::DispatchImpl {
  public:
   ~Server();

+ 9 - 4
include/grpc++/server_context.h

@@ -34,10 +34,11 @@
 #ifndef GRPCXX_SERVER_CONTEXT_H
 #define GRPCXX_SERVER_CONTEXT_H
 
-#include <chrono>
 #include <map>
 
+#include <grpc/support/time.h>
 #include <grpc++/config.h>
+#include <grpc++/time.h>
 
 struct gpr_timespec;
 struct grpc_metadata;
@@ -71,9 +72,13 @@ class ServerContext {
   ServerContext();  // for async calls
   ~ServerContext();
 
-  std::chrono::system_clock::time_point absolute_deadline() {
-    return deadline_;
+#ifndef GRPC_CXX0X_NO_CHRONO
+  std::chrono::system_clock::time_point deadline() {
+    return Timespec2Timepoint(deadline_);
   }
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+  gpr_timespec raw_deadline() { return deadline_; }
 
   void AddInitialMetadata(const grpc::string& key, const grpc::string& value);
   void AddTrailingMetadata(const grpc::string& key, const grpc::string& value);
@@ -110,7 +115,7 @@ class ServerContext {
 
   CompletionOp* completion_op_;
 
-  std::chrono::system_clock::time_point deadline_;
+  gpr_timespec deadline_;
   grpc_call* call_;
   CompletionQueue* cq_;
   bool sent_initial_metadata_;

+ 1 - 1
include/grpc++/stream.h

@@ -173,7 +173,7 @@ class ClientWriter GRPC_FINAL : public ClientStreamingInterface,
     buf.AddRecvMessage(response_);
     buf.AddClientRecvStatus(context_, &status);
     call_.PerformOps(&buf);
-    GPR_ASSERT(cq_.Pluck(&buf) && buf.got_message);
+    GPR_ASSERT(cq_.Pluck(&buf));
     return status;
   }
 

+ 106 - 0
include/grpc++/time.h

@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPCXX_TIME_H
+#define GRPCXX_TIME_H
+
+#include <grpc++/config.h>
+
+namespace grpc {
+
+/* If you are trying to use CompletionQueue::AsyncNext with a time class that
+   isn't either gpr_timespec or std::chrono::system_clock::time_point, you
+   will most likely be looking at this comment as your compiler will have
+   fired an error below. In order to fix this issue, you have two potential
+   solutions:
+
+     1. Use gpr_timespec or std::chrono::system_clock::time_point instead
+     2. Specialize the TimePoint class with whichever time class that you
+        want to use here. See below for two examples of how to do this.
+ */
+
+template <typename T>
+class TimePoint {
+ public:
+  TimePoint(const T& time) {
+    you_need_a_specialization_of_TimePoint();
+  }
+  gpr_timespec raw_time() {
+    gpr_timespec t;
+    return t;
+  }
+ private:
+  void you_need_a_specialization_of_TimePoint();
+};
+
+template<>
+class TimePoint<gpr_timespec> {
+ public:
+  TimePoint(const gpr_timespec& time) : time_(time) { }
+  gpr_timespec raw_time() { return time_; }
+ private:
+  gpr_timespec time_;
+};
+
+}  // namespace grpc
+
+#ifndef GRPC_CXX0X_NO_CHRONO
+
+#include <chrono>
+
+#include <grpc/support/time.h>
+
+namespace grpc {
+
+// from and to should be absolute time.
+void Timepoint2Timespec(const std::chrono::system_clock::time_point& from,
+                        gpr_timespec* to);
+
+std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);
+
+template <>
+class TimePoint<std::chrono::system_clock::time_point> {
+ public:
+  TimePoint(const std::chrono::system_clock::time_point& time) {
+	Timepoint2Timespec(time, &time_);
+  }
+  gpr_timespec raw_time() const { return time_; }
+ private:
+  gpr_timespec time_;
+};
+
+}  // namespace grpc
+
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+#endif  // GRPCXX_TIME_H

+ 2 - 3
src/cpp/client/channel.cc

@@ -33,7 +33,6 @@
 
 #include "src/cpp/client/channel.h"
 
-#include <chrono>
 #include <memory>
 
 #include <grpc/grpc.h>
@@ -65,12 +64,12 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
       method.channel_tag()
           ? grpc_channel_create_registered_call(c_channel_, cq->cq(),
                                                 method.channel_tag(),
-                                                context->RawDeadline())
+                                                context->raw_deadline())
           : grpc_channel_create_call(c_channel_, cq->cq(), method.name(),
                                      context->authority().empty()
                                          ? target_.c_str()
                                          : context->authority().c_str(),
-                                     context->RawDeadline());
+                                     context->raw_deadline());
   GRPC_TIMER_MARK(CALL_CREATED, c_call);
   context->set_call(c_call);
   return Call(c_call, this, cq);

+ 3 - 1
src/cpp/client/channel.h

@@ -38,6 +38,7 @@
 
 #include <grpc++/channel_interface.h>
 #include <grpc++/config.h>
+#include <grpc++/impl/grpc_library.h>
 
 struct grpc_channel;
 
@@ -49,7 +50,8 @@ class CompletionQueue;
 class Credentials;
 class StreamContextInterface;
 
-class Channel GRPC_FINAL : public ChannelInterface {
+class Channel GRPC_FINAL : public GrpcLibrary,
+                           public ChannelInterface {
  public:
   Channel(const grpc::string& target, grpc_channel* c_channel);
   ~Channel() GRPC_OVERRIDE;

+ 2 - 13
src/cpp/client/client_context.cc

@@ -34,9 +34,7 @@
 #include <grpc++/client_context.h>
 
 #include <grpc/grpc.h>
-#include "src/cpp/util/time.h"
-
-using std::chrono::system_clock;
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -44,7 +42,7 @@ ClientContext::ClientContext()
     : initial_metadata_received_(false),
       call_(nullptr),
       cq_(nullptr),
-      absolute_deadline_(gpr_inf_future) {}
+      deadline_(gpr_inf_future) {}
 
 ClientContext::~ClientContext() {
   if (call_) {
@@ -64,15 +62,6 @@ ClientContext::~ClientContext() {
   }
 }
 
-void ClientContext::set_absolute_deadline(
-    const system_clock::time_point& deadline) {
-  Timepoint2Timespec(deadline, &absolute_deadline_);
-}
-
-system_clock::time_point ClientContext::absolute_deadline() {
-  return Timespec2Timepoint(absolute_deadline_);
-}
-
 void ClientContext::AddMetadata(const grpc::string& meta_key,
                                 const grpc::string& meta_value) {
   send_initial_metadata_.insert(std::make_pair(meta_key, meta_value));

+ 6 - 6
src/cpp/client/secure_credentials.cc

@@ -81,27 +81,27 @@ std::unique_ptr<Credentials> ComputeEngineCredentials() {
 // Builds service account credentials.
 std::unique_ptr<Credentials> ServiceAccountCredentials(
     const grpc::string& json_key, const grpc::string& scope,
-    std::chrono::seconds token_lifetime) {
-  if (token_lifetime.count() <= 0) {
+    long token_lifetime_seconds) {
+  if (token_lifetime_seconds <= 0) {
     gpr_log(GPR_ERROR,
             "Trying to create ServiceAccountCredentials "
             "with non-positive lifetime");
     return WrapCredentials(nullptr);
   }
-  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime_seconds);
   return WrapCredentials(grpc_service_account_credentials_create(
       json_key.c_str(), scope.c_str(), lifetime));
 }
 
 // Builds JWT credentials.
 std::unique_ptr<Credentials> JWTCredentials(
-    const grpc::string& json_key, std::chrono::seconds token_lifetime) {
-  if (token_lifetime.count() <= 0) {
+    const grpc::string& json_key, long token_lifetime_seconds) {
+  if (token_lifetime_seconds <= 0) {
     gpr_log(GPR_ERROR,
             "Trying to create JWTCredentials with non-positive lifetime");
     return WrapCredentials(nullptr);
   }
-  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime_seconds);
   return WrapCredentials(
       grpc_jwt_credentials_create(json_key.c_str(), lifetime));
 }

+ 3 - 9
src/cpp/common/completion_queue.cc

@@ -36,7 +36,7 @@
 
 #include <grpc/grpc.h>
 #include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -77,13 +77,6 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
   }
 }
 
-CompletionQueue::NextStatus CompletionQueue::AsyncNext(
-    void** tag, bool* ok, std::chrono::system_clock::time_point deadline) {
-  gpr_timespec gpr_deadline;
-  Timepoint2Timespec(deadline, &gpr_deadline);
-  return AsyncNextInternal(tag, ok, gpr_deadline);
-}
-
 bool CompletionQueue::Pluck(CompletionQueueTag* tag) {
   std::unique_ptr<grpc_event, EventDeleter> ev;
 
@@ -92,7 +85,8 @@ bool CompletionQueue::Pluck(CompletionQueueTag* tag) {
   void* ignored = tag;
   GPR_ASSERT(tag->FinalizeResult(&ignored, &ok));
   GPR_ASSERT(ignored == tag);
-  return ok;
+  // Ignore mutations by FinalizeResult: Pluck returns the C API status
+  return ev->data.op_complete == GRPC_OP_OK;
 }
 
 void CompletionQueue::TryPluck(CompletionQueueTag* tag) {

+ 2 - 2
src/cpp/server/server.cc

@@ -45,10 +45,10 @@
 #include <grpc++/server_context.h>
 #include <grpc++/server_credentials.h>
 #include <grpc++/thread_pool_interface.h>
+#include <grpc++/time.h>
 
 #include "src/core/profiling/timers.h"
 #include "src/cpp/proto/proto_utils.h"
-#include "src/cpp/util/time.h"
 
 namespace grpc {
 
@@ -353,7 +353,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
     ServerContext* ctx = ctx_ ? ctx_ : generic_ctx_;
     GPR_ASSERT(ctx);
     if (*status) {
-      ctx->deadline_ = Timespec2Timepoint(call_details_.deadline);
+      ctx->deadline_ = call_details_.deadline;
       for (size_t i = 0; i < array_.count; i++) {
         ctx->client_metadata_.insert(std::make_pair(
             grpc::string(array_.metadata[i].key),

+ 4 - 4
src/cpp/server/server_context.cc

@@ -33,11 +33,11 @@
 
 #include <grpc++/server_context.h>
 
-#include <grpc++/impl/call.h>
-#include <grpc++/impl/sync.h>
 #include <grpc/grpc.h>
 #include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/impl/call.h>
+#include <grpc++/impl/sync.h>
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -99,7 +99,7 @@ ServerContext::ServerContext()
 ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
                              size_t metadata_count)
     : completion_op_(nullptr),
-      deadline_(Timespec2Timepoint(deadline)),
+      deadline_(deadline),
       call_(nullptr),
       cq_(nullptr),
       sent_initial_metadata_(false) {

+ 6 - 1
src/cpp/util/time.cc

@@ -31,9 +31,12 @@
  *
  */
 
-#include "src/cpp/util/time.h"
+#include <grpc++/config.h>
+
+#ifndef GRPC_CXX0X_NO_CHRONO
 
 #include <grpc/support/time.h>
+#include <grpc++/time.h>
 
 using std::chrono::duration_cast;
 using std::chrono::nanoseconds;
@@ -68,3 +71,5 @@ system_clock::time_point Timespec2Timepoint(gpr_timespec t) {
 }
 
 }  // namespace grpc
+
+#endif  // !GRPC_CXX0X_NO_CHRONO

+ 7 - 14
templates/Makefile.template

@@ -362,8 +362,8 @@ OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/ope
 ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
 PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
 PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
-PROTOC_CMD = which protoc > /dev/null
-PROTOC_CHECK_CMD = protoc --version | grep -q libprotoc.3
+PROTOC_CHECK_CMD = which protoc > /dev/null
+PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
 
 ifeq ($(OPENSSL_REQUIRES_DL),true)
 OPENSSL_ALPN_CHECK_CMD += -ldl
@@ -389,9 +389,9 @@ HAS_SYSTEM_ZLIB = false
 HAS_SYSTEM_PROTOBUF = false
 endif
 
-HAS_PROTOC = $(shell $(PROTOC_CMD) 2> /dev/null && echo true || echo false)
+HAS_PROTOC = $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
 ifeq ($(HAS_PROTOC),true)
-HAS_VALID_PROTOC = $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
+HAS_VALID_PROTOC = $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
 else
 HAS_VALID_PROTOC = false
 endif
@@ -587,7 +587,7 @@ run_dep_checks:
 	$(ZLIB_CHECK_CMD) || true
 	$(PERFTOOLS_CHECK_CMD) || true
 	$(PROTOBUF_CHECK_CMD) || true
-	$(PROTOC_CHECK_CMD) || true
+	$(PROTOC_CHECK_VERSION_CMD) || true
 
 $(LIBDIR)/$(CONFIG)/zlib/libz.a:
 	$(E) "[MAKE]    Building zlib"
@@ -1208,17 +1208,10 @@ endif
 % if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
 endif
 % endif
-
 % for src in lib.src:
-% if not proto_re.match(src):
-$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
-% for src2 in lib.src:
-% if proto_re.match(src2):
-    ${proto_to_cc(src2)}\
+% if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
+$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
 % endif
-% endfor
-% endif
-
 % endfor
 </%def>
 

+ 57 - 57
test/core/end2end/gen_build_json.py

@@ -46,60 +46,60 @@ END2END_FIXTURES = {
     'chttp2_socket_pair_one_byte_at_a_time': False,
 }
 
+# maps tests names to whether they run fine or not (aka, not flaky)
+END2END_TESTS = {
+    'bad_hostname': True,
+    'cancel_after_accept': False,
+    'cancel_after_accept_and_writes_closed': True,
+    'cancel_after_invoke': True,
+    'cancel_before_invoke': True,
+    'cancel_in_a_vacuum': True,
+    'census_simple_request': True,
+    'disappearing_server': True,
+    'early_server_shutdown_finishes_inflight_calls': True,
+    'early_server_shutdown_finishes_tags': True,
+    'empty_batch': True,
+    'graceful_server_shutdown': True,
+    'invoke_large_request': False,
+    'max_concurrent_streams': True,
+    'no_op': True,
+    'ping_pong_streaming': True,
+    'request_response_with_binary_metadata_and_payload': True,
+    'request_response_with_metadata_and_payload': True,
+    'request_response_with_payload': True,
+    'request_with_large_metadata': True,
+    'request_with_payload': True,
+    'simple_delayed_request': True,
+    'simple_request': True,
+    'registered_call': True,
+    'thread_stress': True,
+    'writes_done_hangs_with_pending_read': True,
 
-END2END_TESTS = [
-    'bad_hostname',
-    'cancel_after_accept',
-    'cancel_after_accept_and_writes_closed',
-    'cancel_after_invoke',
-    'cancel_before_invoke',
-    'cancel_in_a_vacuum',
-    'census_simple_request',
-    'disappearing_server',
-    'early_server_shutdown_finishes_inflight_calls',
-    'early_server_shutdown_finishes_tags',
-    'empty_batch',
-    'graceful_server_shutdown',
-    'invoke_large_request',
-    'max_concurrent_streams',
-    'no_op',
-    'ping_pong_streaming',
-    'request_response_with_binary_metadata_and_payload',
-    'request_response_with_metadata_and_payload',
-    'request_response_with_payload',
-    'request_with_large_metadata',
-    'request_with_payload',
-    'simple_delayed_request',
-    'simple_request',
-    'registered_call',
-    'thread_stress',
-    'writes_done_hangs_with_pending_read',
-
-    'cancel_after_accept_legacy',
-    'cancel_after_accept_and_writes_closed_legacy',
-    'cancel_after_invoke_legacy',
-    'cancel_before_invoke_legacy',
-    'cancel_in_a_vacuum_legacy',
-    'census_simple_request_legacy',
-    'disappearing_server_legacy',
-    'early_server_shutdown_finishes_inflight_calls_legacy',
-    'early_server_shutdown_finishes_tags_legacy',
-    'graceful_server_shutdown_legacy',
-    'invoke_large_request_legacy',
-    'max_concurrent_streams_legacy',
-    'no_op_legacy',
-    'ping_pong_streaming_legacy',
-    'request_response_with_binary_metadata_and_payload_legacy',
-    'request_response_with_metadata_and_payload_legacy',
-    'request_response_with_payload_legacy',
-    'request_response_with_trailing_metadata_and_payload_legacy',
-    'request_with_large_metadata_legacy',
-    'request_with_payload_legacy',
-    'simple_delayed_request_legacy',
-    'simple_request_legacy',
-    'thread_stress_legacy',
-    'writes_done_hangs_with_pending_read_legacy',
-]
+    'cancel_after_accept_legacy': False,
+    'cancel_after_accept_and_writes_closed_legacy': True,
+    'cancel_after_invoke_legacy': True,
+    'cancel_before_invoke_legacy': True,
+    'cancel_in_a_vacuum_legacy': True,
+    'census_simple_request_legacy': True,
+    'disappearing_server_legacy': True,
+    'early_server_shutdown_finishes_inflight_calls_legacy': True,
+    'early_server_shutdown_finishes_tags_legacy': True,
+    'graceful_server_shutdown_legacy': True,
+    'invoke_large_request_legacy': False,
+    'max_concurrent_streams_legacy': True,
+    'no_op_legacy': True,
+    'ping_pong_streaming_legacy': True,
+    'request_response_with_binary_metadata_and_payload_legacy': True,
+    'request_response_with_metadata_and_payload_legacy': True,
+    'request_response_with_payload_legacy': True,
+    'request_response_with_trailing_metadata_and_payload_legacy': True,
+    'request_with_large_metadata_legacy': True,
+    'request_with_payload_legacy': True,
+    'simple_delayed_request_legacy': True,
+    'simple_request_legacy': True,
+    'thread_stress_legacy': True,
+    'writes_done_hangs_with_pending_read_legacy': True,
+}
 
 
 def main():
@@ -122,7 +122,7 @@ def main():
               'src': ['test/core/end2end/tests/%s.c' % t],
               'headers': ['test/core/end2end/tests/cancel_test_helpers.h']
           }
-          for t in sorted(END2END_TESTS)] + [
+          for t in sorted(END2END_TESTS.keys())] + [
           {
               'name': 'end2end_certs',
               'build': 'private',
@@ -140,7 +140,7 @@ def main():
               'build': 'test',
               'language': 'c',
               'src': [],
-              'flaky': 'invoke_large_request' in t,
+              'flaky': not END2END_TESTS[t],
               'deps': [
                   'end2end_fixture_%s' % f,
                   'end2end_test_%s' % t,
@@ -152,7 +152,7 @@ def main():
               ]
           }
       for f in sorted(END2END_FIXTURES.keys())
-      for t in sorted(END2END_TESTS)] + [
+      for t in sorted(END2END_TESTS.keys())] + [
           {
               'name': '%s_%s_unsecure_test' % (f, t),
               'build': 'test',
@@ -170,7 +170,7 @@ def main():
               ]
           }
       for f in sorted(END2END_FIXTURES.keys()) if not END2END_FIXTURES[f]
-      for t in sorted(END2END_TESTS)]}
+      for t in sorted(END2END_TESTS.keys())]}
   print simplejson.dumps(json, sort_keys=True, indent=2 * ' ')
 
 

+ 1 - 3
test/cpp/client/credentials_test.cc

@@ -47,7 +47,7 @@ class CredentialsTest : public ::testing::Test {
 
 TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
   std::unique_ptr<Credentials> bad1 =
-      ServiceAccountCredentials("", "", std::chrono::seconds(1));
+      ServiceAccountCredentials("", "", 1);
   EXPECT_EQ(nullptr, bad1.get());
 }
 
@@ -56,8 +56,6 @@ TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
 
 int main(int argc, char** argv) {
   ::testing::InitGoogleTest(&argc, argv);
-  grpc_init();
   int ret = RUN_ALL_TESTS();
-  grpc_shutdown();
   return ret;
 }

+ 3 - 7
test/cpp/end2end/async_end2end_test.cc

@@ -31,13 +31,12 @@
  *
  */
 
-#include <chrono>
 #include <memory>
 
+#include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo_duplicate.grpc.pb.h"
 #include "test/cpp/util/echo.grpc.pb.h"
-#include "src/cpp/util/time.h"
 #include <grpc++/async_unary_call.h>
 #include <grpc++/channel_arguments.h>
 #include <grpc++/channel_interface.h>
@@ -50,7 +49,7 @@
 #include <grpc++/server_credentials.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
-#include "test/core/util/port.h"
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>
@@ -595,9 +594,6 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
 
 int main(int argc, char** argv) {
   grpc_test_init(argc, argv);
-  grpc_init();
   ::testing::InitGoogleTest(&argc, argv);
-  int result = RUN_ALL_TESTS();
-  grpc_shutdown();
-  return result;
+  return RUN_ALL_TESTS();
 }

+ 30 - 13
test/cpp/end2end/end2end_test.cc

@@ -31,13 +31,12 @@
  *
  */
 
-#include <chrono>
 #include <thread>
 
+#include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo_duplicate.grpc.pb.h"
 #include "test/cpp/util/echo.grpc.pb.h"
-#include "src/cpp/util/time.h"
 #include "src/cpp/server/thread_pool.h"
 #include <grpc++/channel_arguments.h>
 #include <grpc++/channel_interface.h>
@@ -50,7 +49,7 @@
 #include <grpc++/server_credentials.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
-#include "test/core/util/port.h"
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>
@@ -72,8 +71,8 @@ void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
                        EchoResponse* response) {
   if (request->has_param() && request->param().echo_deadline()) {
     gpr_timespec deadline = gpr_inf_future;
-    if (context->absolute_deadline() != system_clock::time_point::max()) {
-      Timepoint2Timespec(context->absolute_deadline(), &deadline);
+    if (context->deadline() != system_clock::time_point::max()) {
+      Timepoint2Timespec(context->deadline(), &deadline);
     }
     response->mutable_param()->set_request_deadline(deadline.tv_sec);
   }
@@ -245,7 +244,7 @@ TEST_F(End2endTest, RpcDeadlineExpires) {
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::microseconds(10);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.code());
 }
@@ -260,7 +259,7 @@ TEST_F(End2endTest, RpcLongDeadline) {
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::hours(1);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(response.message(), request.message());
   EXPECT_TRUE(s.IsOk());
@@ -277,7 +276,7 @@ TEST_F(End2endTest, EchoDeadline) {
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::seconds(100);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(response.message(), request.message());
   EXPECT_TRUE(s.IsOk());
@@ -428,7 +427,7 @@ TEST_F(End2endTest, DiffPackageServices) {
 // rpc and stream should fail on bad credentials.
 TEST_F(End2endTest, BadCredentials) {
   std::unique_ptr<Credentials> bad_creds =
-      ServiceAccountCredentials("", "", std::chrono::seconds(1));
+      ServiceAccountCredentials("", "", 1);
   EXPECT_EQ(nullptr, bad_creds.get());
   std::shared_ptr<ChannelInterface> channel =
       CreateChannel(server_address_.str(), bad_creds, ChannelArguments());
@@ -491,6 +490,27 @@ TEST_F(End2endTest, ServerCancelsRpc) {
   EXPECT_TRUE(s.details().empty());
 }
 
+// Client cancels request stream after sending two messages
+TEST_F(End2endTest, ClientCancelsRequestStream) {
+  ResetStub();
+  EchoRequest request;
+  EchoResponse response;
+  ClientContext context;
+  request.set_message("hello");
+
+  auto stream = stub_->RequestStream(&context, &response);
+  EXPECT_TRUE(stream->Write(request));
+  EXPECT_TRUE(stream->Write(request));
+  
+  context.TryCancel();
+
+  Status s = stream->Finish();
+  EXPECT_EQ(grpc::StatusCode::CANCELLED, s.code());
+  
+  EXPECT_EQ(response.message(), "");
+
+}
+
 // Client cancels server stream after sending some messages
 TEST_F(End2endTest, ClientCancelsResponseStream) {
   ResetStub();
@@ -562,9 +582,6 @@ TEST_F(End2endTest, ClientCancelsBidi) {
 
 int main(int argc, char** argv) {
   grpc_test_init(argc, argv);
-  grpc_init();
   ::testing::InitGoogleTest(&argc, argv);
-  int result = RUN_ALL_TESTS();
-  grpc_shutdown();
-  return result;
+  return RUN_ALL_TESTS();
 }

+ 2 - 6
test/cpp/end2end/generic_end2end_test.cc

@@ -31,11 +31,9 @@
  *
  */
 
-#include <chrono>
 #include <memory>
 
 #include "src/cpp/proto/proto_utils.h"
-#include "src/cpp/util/time.h"
 #include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo.grpc.pb.h"
@@ -55,6 +53,7 @@
 #include <grpc++/slice.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>
@@ -280,9 +279,6 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
 
 int main(int argc, char** argv) {
   grpc_test_init(argc, argv);
-  grpc_init();
   ::testing::InitGoogleTest(&argc, argv);
-  int result = RUN_ALL_TESTS();
-  grpc_shutdown();
-  return result;
+  return RUN_ALL_TESTS();
 }

+ 0 - 4
test/cpp/interop/client.cc

@@ -76,8 +76,6 @@ using grpc::testing::CreateChannelForTestCase;
 using grpc::testing::GetServiceAccountJsonKey;
 
 int main(int argc, char** argv) {
-  grpc_init();
-
   grpc::testing::InitTest(&argc, &argv, true);
 
   int ret = 0;
@@ -129,8 +127,6 @@ int main(int argc, char** argv) {
         FLAGS_test_case.c_str());
     ret = 1;
   }
-  client.Reset(nullptr);
 
-  grpc_shutdown();
   return ret;
 }

+ 4 - 2
test/cpp/interop/client_helper.cc

@@ -85,8 +85,9 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase(
     std::unique_ptr<Credentials> creds;
     GPR_ASSERT(FLAGS_enable_ssl);
     grpc::string json_key = GetServiceAccountJsonKey();
+    std::chrono::seconds token_lifetime = std::chrono::hours(1);
     creds = ServiceAccountCredentials(json_key, FLAGS_oauth_scope,
-                                      std::chrono::hours(1));
+                                      token_lifetime.count());
     return CreateTestChannel(host_port, FLAGS_server_host_override,
                              FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
   } else if (test_case == "compute_engine_creds") {
@@ -99,7 +100,8 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase(
     std::unique_ptr<Credentials> creds;
     GPR_ASSERT(FLAGS_enable_ssl);
     grpc::string json_key = GetServiceAccountJsonKey();
-    creds = JWTCredentials(json_key, std::chrono::hours(1));
+    std::chrono::seconds token_lifetime = std::chrono::hours(1);
+    creds = JWTCredentials(json_key, token_lifetime.count());
     return CreateTestChannel(host_port, FLAGS_server_host_override,
                              FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
   } else {

+ 0 - 2
test/cpp/interop/server.cc

@@ -218,13 +218,11 @@ void RunServer() {
 static void sigint_handler(int x) { got_sigint = true; }
 
 int main(int argc, char** argv) {
-  grpc_init();
   grpc::testing::InitTest(&argc, &argv, true);
   signal(SIGINT, sigint_handler);
 
   GPR_ASSERT(FLAGS_port != 0);
   RunServer();
 
-  grpc_shutdown();
   return 0;
 }

+ 0 - 2
test/cpp/qps/qps_driver.cc

@@ -69,7 +69,6 @@ using grpc::testing::RpcType;
 using grpc::testing::ResourceUsage;
 
 int main(int argc, char** argv) {
-  grpc_init();
   grpc::testing::InitTest(&argc, &argv, true);
 
   RpcType rpc_type;
@@ -104,6 +103,5 @@ int main(int argc, char** argv) {
   ReportLatency(result);
   ReportTimes(result);
 
-  grpc_shutdown();
   return 0;
 }

+ 0 - 3
test/cpp/qps/smoke_test.cc

@@ -136,14 +136,11 @@ static void RunQPS() {
 }  // namespace grpc
 
 int main(int argc, char** argv) {
-  grpc_init();
-
   using namespace grpc::testing;
   RunSynchronousStreamingPingPong();
   RunSynchronousUnaryPingPong();
   RunAsyncUnaryPingPong();
   RunQPS();
 
-  grpc_shutdown();
   return 0;
 }

+ 1 - 3
test/cpp/qps/worker.cc

@@ -64,13 +64,11 @@ static void RunServer() {
 }  // namespace grpc
 
 int main(int argc, char** argv) {
-  grpc_init();
   grpc::testing::InitTest(&argc, &argv, true);
 
   signal(SIGINT, sigint_handler);
 
   grpc::testing::RunServer();
-
-  grpc_shutdown();
+  
   return 0;
 }

+ 1 - 4
test/cpp/util/cli_call_test.cc

@@ -123,9 +123,6 @@ TEST_F(CliCallTest, SimpleRpc) {
 
 int main(int argc, char** argv) {
   grpc_test_init(argc, argv);
-  grpc_init();
   ::testing::InitGoogleTest(&argc, argv);
-  int result = RUN_ALL_TESTS();
-  grpc_shutdown();
-  return result;
+  return RUN_ALL_TESTS();
 }

+ 0 - 4
test/cpp/util/grpc_cli.cc

@@ -79,8 +79,6 @@ DEFINE_string(output_binary_file, "output.bin",
               "Path to output file to write serialized response.");
 
 int main(int argc, char** argv) {
-  grpc_init();
-
   grpc::testing::InitTest(&argc, &argv, true);
 
   if (argc < 4 || grpc::string(argv[1]) != "call") {
@@ -127,7 +125,5 @@ int main(int argc, char** argv) {
     output_file << response;
   }
 
-  channel.reset();
-  grpc_shutdown();
   return 0;
 }

+ 1 - 4
test/cpp/util/time_test.cc

@@ -31,11 +31,8 @@
  *
  */
 
-#include "src/cpp/util/time.h"
-
-#include <chrono>
-
 #include <grpc/support/time.h>
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 using std::chrono::duration_cast;

+ 17 - 17
tools/run_tests/tests.json

@@ -65,7 +65,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "census_statistics_multiple_writers_test", 
     "platforms": [
@@ -74,7 +74,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "census_statistics_performance_test", 
     "platforms": [
@@ -83,7 +83,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "census_statistics_quick_test", 
     "platforms": [
@@ -703,7 +703,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_fake_security_cancel_after_accept_test", 
     "platforms": [
@@ -730,7 +730,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_fake_security_cancel_after_accept_legacy_test", 
     "platforms": [
@@ -1153,7 +1153,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_fullstack_cancel_after_accept_test", 
     "platforms": [
@@ -1180,7 +1180,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_fullstack_cancel_after_accept_legacy_test", 
     "platforms": [
@@ -1603,7 +1603,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_fullstack_uds_cancel_after_accept_test", 
     "platforms": [
@@ -1630,7 +1630,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_fullstack_uds_cancel_after_accept_legacy_test", 
     "platforms": [
@@ -2053,7 +2053,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_simple_ssl_fullstack_cancel_after_accept_test", 
     "platforms": [
@@ -2080,7 +2080,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_simple_ssl_fullstack_cancel_after_accept_legacy_test", 
     "platforms": [
@@ -2503,7 +2503,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test", 
     "platforms": [
@@ -2530,7 +2530,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_legacy_test", 
     "platforms": [
@@ -2953,7 +2953,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_socket_pair_cancel_after_accept_test", 
     "platforms": [
@@ -2980,7 +2980,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_socket_pair_cancel_after_accept_legacy_test", 
     "platforms": [
@@ -3403,7 +3403,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test", 
     "platforms": [
@@ -3430,7 +3430,7 @@
     ]
   }, 
   {
-    "flaky": false, 
+    "flaky": true, 
     "language": "c", 
     "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_legacy_test", 
     "platforms": [

+ 2 - 1
vsprojects/grpc++/grpc++.vcxproj

@@ -96,6 +96,7 @@
     <ClInclude Include="..\..\include\grpc++\generic_stub.h" />
     <ClInclude Include="..\..\include\grpc++\impl\call.h" />
     <ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h" />
+    <ClInclude Include="..\..\include\grpc++\impl\grpc_library.h" />
     <ClInclude Include="..\..\include\grpc++\impl\internal_stub.h" />
     <ClInclude Include="..\..\include\grpc++\impl\rpc_method.h" />
     <ClInclude Include="..\..\include\grpc++\impl\rpc_service_method.h" />
@@ -115,6 +116,7 @@
     <ClInclude Include="..\..\include\grpc++\status_code_enum.h" />
     <ClInclude Include="..\..\include\grpc++\stream.h" />
     <ClInclude Include="..\..\include\grpc++\thread_pool_interface.h" />
+    <ClInclude Include="..\..\include\grpc++\time.h" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cpp\client\secure_credentials.h" />
@@ -122,7 +124,6 @@
     <ClInclude Include="..\..\src\cpp\client\channel.h" />
     <ClInclude Include="..\..\src\cpp\proto\proto_utils.h" />
     <ClInclude Include="..\..\src\cpp\server\thread_pool.h" />
-    <ClInclude Include="..\..\src\cpp\util\time.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\cpp\client\secure_credentials.cc">

+ 6 - 3
vsprojects/grpc++/grpc++.vcxproj.filters

@@ -120,6 +120,9 @@
     <ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h">
       <Filter>include\grpc++\impl</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\include\grpc++\impl\grpc_library.h">
+      <Filter>include\grpc++\impl</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\include\grpc++\impl\internal_stub.h">
       <Filter>include\grpc++\impl</Filter>
     </ClInclude>
@@ -177,6 +180,9 @@
     <ClInclude Include="..\..\include\grpc++\thread_pool_interface.h">
       <Filter>include\grpc++</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\include\grpc++\time.h">
+      <Filter>include\grpc++</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cpp\client\secure_credentials.h">
@@ -194,9 +200,6 @@
     <ClInclude Include="..\..\src\cpp\server\thread_pool.h">
       <Filter>src\cpp\server</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\cpp\util\time.h">
-      <Filter>src\cpp\util</Filter>
-    </ClInclude>
   </ItemGroup>
 
   <ItemGroup>

Some files were not shown because too many files changed in this diff