aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/connection_refused_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/end2end/connection_refused_test.c')
-rw-r--r--test/core/end2end/connection_refused_test.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c
index 07d7010daa..13414c0378 100644
--- a/test/core/end2end/connection_refused_test.c
+++ b/test/core/end2end/connection_refused_test.c
@@ -39,8 +39,11 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/transport/metadata.h"
+#include "src/core/lib/transport/method_config.h"
+
#include "test/core/end2end/cq_verifier.h"
-#include "test/core/end2end/fake_resolver.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -62,7 +65,6 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
gpr_log(GPR_INFO, "TEST: wait_for_ready=%d use_service_config=%d",
wait_for_ready, use_service_config);
- grpc_fake_resolver_init();
grpc_init();
grpc_metadata_array_init(&trailing_metadata_recv);
@@ -70,21 +72,30 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
cq = grpc_completion_queue_create(NULL);
cqv = cq_verifier_create(cq);
+ /* if using service config, create channel args */
+ grpc_channel_args *args = NULL;
+ if (use_service_config) {
+ GPR_ASSERT(wait_for_ready);
+ grpc_method_config_table_entry entry = {
+ grpc_mdstr_from_string("/service/method"),
+ grpc_method_config_create(&wait_for_ready, NULL, NULL, NULL),
+ };
+ grpc_method_config_table *method_config_table =
+ grpc_method_config_table_create(1, &entry);
+ GRPC_MDSTR_UNREF(entry.method_name);
+ grpc_method_config_unref(entry.method_config);
+ grpc_arg arg =
+ grpc_method_config_table_create_channel_arg(method_config_table);
+ args = grpc_channel_args_copy_and_add(args, &arg, 1);
+ grpc_method_config_table_unref(method_config_table);
+ }
+
/* create a call, channel to a port which will refuse connection */
int port = grpc_pick_unused_port_or_die();
char *addr;
gpr_join_host_port(&addr, "127.0.0.1", port);
- if (use_service_config) {
- GPR_ASSERT(wait_for_ready);
- char *server_uri;
- gpr_asprintf(&server_uri,
- "test:%s?method_name=/service/method&wait_for_ready=1", addr);
- gpr_free(addr);
- addr = server_uri;
- }
gpr_log(GPR_INFO, "server: %s", addr);
-
- chan = grpc_insecure_channel_create(addr, NULL, NULL);
+ chan = grpc_insecure_channel_create(addr, args, NULL);
call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
"/service/method", "nonexistant", deadline,
NULL);
@@ -133,6 +144,8 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
gpr_free(details);
grpc_metadata_array_destroy(&trailing_metadata_recv);
+ if (args != NULL) grpc_channel_args_destroy(args);
+
grpc_shutdown();
}