Merge pull request #15568 from ncteisen/tracers

Default Off for Tracers, Delete an Unused One
diff --git a/src/php/tests/qps/client.php b/src/php/tests/qps/client.php
index 0890405..1fa60a7 100644
--- a/src/php/tests/qps/client.php
+++ b/src/php/tests/qps/client.php
@@ -70,7 +70,7 @@
     $proxystubopts = [];
     $proxystubopts['credentials'] = Grpc\ChannelCredentials::createInsecure();
     $proxystub = new Grpc\Testing\ProxyClientServiceClient($proxy_address, $proxystubopts);
-    list($config, $status) = $proxystub->GetConfig(new Grpc\Testing\Void())->wait();
+    list($config, $status) = $proxystub->GetConfig(new Grpc\Testing\PBVoid())->wait();
     hardAssertIfStatusOk($status);
     hardAssert($config->getOutstandingRpcsPerChannel() == 1, "Only 1 outstanding RPC supported");
 
diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php
deleted file mode 100644
index e402918..0000000
--- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler.  DO NOT EDIT!
-# source: src/proto/grpc/testing/services.proto
-
-namespace GPBMetadata\Src\Proto\Grpc\Testing;
-
-class Services
-{
-    public static $is_initialized = false;
-
-    public static function initOnce() {
-        $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
-
-        if (static::$is_initialized == true) {
-          return;
-        }
-        \GPBMetadata\Src\Proto\Grpc\Testing\Messages::initOnce();
-        \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
-        \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce();
-        $pool->internalAddGeneratedFile(hex2bin(
-            "0aaa070a257372632f70726f746f2f677270632f74657374696e672f7365" .
-            "7276696365732e70726f746f120c677270632e74657374696e671a247372" .
-            "632f70726f746f2f677270632f74657374696e672f636f6e74726f6c2e70" .
-            "726f746f1a227372632f70726f746f2f677270632f74657374696e672f73" .
-            "746174732e70726f746f32a6030a1042656e63686d61726b536572766963" .
-            "6512460a09556e61727943616c6c121b2e677270632e74657374696e672e" .
-            "53696d706c65526571756573741a1c2e677270632e74657374696e672e53" .
-            "696d706c65526573706f6e7365124e0a0d53747265616d696e6743616c6c" .
-            "121b2e677270632e74657374696e672e53696d706c65526571756573741a" .
-            "1c2e677270632e74657374696e672e53696d706c65526573706f6e736528" .
-            "01300112520a1353747265616d696e6746726f6d436c69656e74121b2e67" .
-            "7270632e74657374696e672e53696d706c65526571756573741a1c2e6772" .
-            "70632e74657374696e672e53696d706c65526573706f6e7365280112520a" .
-            "1353747265616d696e6746726f6d536572766572121b2e677270632e7465" .
-            "7374696e672e53696d706c65526571756573741a1c2e677270632e746573" .
-            "74696e672e53696d706c65526573706f6e7365300112520a115374726561" .
-            "6d696e67426f746857617973121b2e677270632e74657374696e672e5369" .
-            "6d706c65526571756573741a1c2e677270632e74657374696e672e53696d" .
-            "706c65526573706f6e7365280130013297020a0d576f726b657253657276" .
-            "69636512450a0952756e53657276657212182e677270632e74657374696e" .
-            "672e536572766572417267731a1a2e677270632e74657374696e672e5365" .
-            "727665725374617475732801300112450a0952756e436c69656e7412182e" .
-            "677270632e74657374696e672e436c69656e74417267731a1a2e67727063" .
-            "2e74657374696e672e436c69656e745374617475732801300112420a0943" .
-            "6f7265436f756e7412192e677270632e74657374696e672e436f72655265" .
-            "71756573741a1a2e677270632e74657374696e672e436f7265526573706f" .
-            "6e736512340a0a51756974576f726b657212122e677270632e7465737469" .
-            "6e672e566f69641a122e677270632e74657374696e672e566f6964325e0a" .
-            "185265706f72745170735363656e6172696f5365727669636512420a0e52" .
-            "65706f72745363656e6172696f121c2e677270632e74657374696e672e53" .
-            "63656e6172696f526573756c741a122e677270632e74657374696e672e56" .
-            "6f6964620670726f746f33"
-        ));
-
-        static::$is_initialized = true;
-    }
-}
-
diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Void.php b/src/php/tests/qps/generated_code/Grpc/Testing/Void.php
deleted file mode 100644
index 623021d..0000000
--- a/src/php/tests/qps/generated_code/Grpc/Testing/Void.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler.  DO NOT EDIT!
-# source: src/proto/grpc/testing/control.proto
-
-namespace Grpc\Testing;
-
-use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\RepeatedField;
-use Google\Protobuf\Internal\GPBUtil;
-
-/**
- * Generated from protobuf message <code>grpc.testing.Void</code>
- */
-class Void extends \Google\Protobuf\Internal\Message
-{
-
-    public function __construct() {
-        \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce();
-        parent::__construct();
-    }
-
-}
-
diff --git a/src/python/grpcio_tests/tests/qps/worker_server.py b/src/python/grpcio_tests/tests/qps/worker_server.py
index db145fb..740bdcf 100644
--- a/src/python/grpcio_tests/tests/qps/worker_server.py
+++ b/src/python/grpcio_tests/tests/qps/worker_server.py
@@ -20,6 +20,7 @@
 from concurrent import futures
 import grpc
 from src.proto.grpc.testing import control_pb2
+from src.proto.grpc.testing import benchmark_service_pb2_grpc
 from src.proto.grpc.testing import worker_service_pb2_grpc
 from src.proto.grpc.testing import stats_pb2
 
@@ -72,7 +73,7 @@
         server = test_common.test_server(max_workers=server_threads)
         if config.server_type == control_pb2.ASYNC_SERVER:
             servicer = benchmark_server.BenchmarkServer()
-            worker_service_pb2_grpc.add_BenchmarkServiceServicer_to_server(
+            benchmark_service_pb2_grpc.add_BenchmarkServiceServicer_to_server(
                 servicer, server)
         elif config.server_type == control_pb2.ASYNC_GENERIC_SERVER:
             resp_size = config.payload_config.bytebuf_params.resp_size
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index 57ff737..41c62a8 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -148,6 +148,88 @@
   }
 }
 
+struct fake_class {
+  int foo;
+};
+
+static void* fake_pointer_arg_copy(void* arg) {
+  gpr_log(GPR_DEBUG, "fake_pointer_arg_copy");
+  fake_class* fc = static_cast<fake_class*>(arg);
+  fake_class* new_fc = static_cast<fake_class*>(gpr_malloc(sizeof(fake_class)));
+  new_fc->foo = fc->foo;
+  return new_fc;
+}
+
+static void fake_pointer_arg_destroy(void* arg) {
+  gpr_log(GPR_DEBUG, "fake_pointer_arg_destroy");
+  fake_class* fc = static_cast<fake_class*>(arg);
+  gpr_free(fc);
+}
+
+static int fake_pointer_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
+
+static const grpc_arg_pointer_vtable fake_pointer_arg_vtable = {
+    fake_pointer_arg_copy, fake_pointer_arg_destroy, fake_pointer_cmp};
+
+static void test_channel_create_with_args(void) {
+  grpc_arg client_a[3];
+
+  // adds integer arg
+  client_a[0].type = GRPC_ARG_INTEGER;
+  client_a[0].key = const_cast<char*>("arg_int");
+  client_a[0].value.integer = 0;
+
+  // adds const str arg
+  client_a[1].type = GRPC_ARG_STRING;
+  client_a[1].key = const_cast<char*>("arg_str");
+  client_a[1].value.string = const_cast<char*>("arg_str_val");
+
+  // allocated and adds custom pointer arg
+  fake_class* fc = static_cast<fake_class*>(gpr_malloc(sizeof(fake_class)));
+  fc->foo = 42;
+  client_a[2].type = GRPC_ARG_POINTER;
+  client_a[2].key = const_cast<char*>("arg_pointer");
+  client_a[2].value.pointer.vtable = &fake_pointer_arg_vtable;
+  client_a[2].value.pointer.p = fc;
+
+  // creates channel
+  grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
+  grpc_channel* c =
+      grpc_insecure_channel_create("fake_target", &client_args, nullptr);
+  // user is can free the memory they allocated here
+  gpr_free(fc);
+  grpc_channel_destroy(c);
+}
+
+static void test_server_create_with_args(void) {
+  grpc_arg server_a[3];
+
+  // adds integer arg
+  server_a[0].type = GRPC_ARG_INTEGER;
+  server_a[0].key = const_cast<char*>("arg_int");
+  server_a[0].value.integer = 0;
+
+  // adds const str arg
+  server_a[1].type = GRPC_ARG_STRING;
+  server_a[1].key = const_cast<char*>("arg_str");
+  server_a[1].value.string = const_cast<char*>("arg_str_val");
+
+  // allocated and adds custom pointer arg
+  fake_class* fc = static_cast<fake_class*>(gpr_malloc(sizeof(fake_class)));
+  fc->foo = 42;
+  server_a[2].type = GRPC_ARG_POINTER;
+  server_a[2].key = const_cast<char*>("arg_pointer");
+  server_a[2].value.pointer.vtable = &fake_pointer_arg_vtable;
+  server_a[2].value.pointer.p = fc;
+
+  // creates server
+  grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
+  grpc_server* s = grpc_server_create(&server_args, nullptr);
+  // user is can free the memory they allocated here
+  gpr_free(fc);
+  grpc_server_destroy(s);
+}
+
 int main(int argc, char** argv) {
   grpc_test_init(argc, argv);
   grpc_init();
@@ -155,6 +237,8 @@
   test_set_compression_algorithm();
   test_compression_algorithm_states();
   test_set_socket_mutator();
+  test_channel_create_with_args();
+  test_server_create_with_args();
   grpc_shutdown();
   return 0;
 }