diff options
author | Alexander Polcyn <apolcyn@google.com> | 2018-03-06 17:13:06 -0800 |
---|---|---|
committer | Alexander Polcyn <apolcyn@google.com> | 2018-03-06 19:22:34 -0800 |
commit | 0a05b782fe0acdd4d5d14ee486baf51d779449c7 (patch) | |
tree | f30799b6922e8eb39ee1a2e82486b6cb227c01c5 /test | |
parent | 3c5e12de08a255edf78890d7408e2f98ebca7e2d (diff) |
Move python DNS utilities to utils subdirectory
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/naming/BUILD | 28 | ||||
-rwxr-xr-x | test/cpp/naming/generate_resolver_component_tests.bzl | 6 | ||||
-rwxr-xr-x | test/cpp/naming/resolver_component_tests_runner.sh | 40 | ||||
-rw-r--r-- | test/cpp/naming/resolver_component_tests_runner_invoker.cc | 32 | ||||
-rw-r--r-- | test/cpp/naming/utils/BUILD | 50 | ||||
-rwxr-xr-x | test/cpp/naming/utils/dns_resolver.py (renamed from test/cpp/naming/test_dns_resolver.py) | 0 | ||||
-rwxr-xr-x | test/cpp/naming/utils/dns_server.py (renamed from test/cpp/naming/test_dns_server.py) | 0 | ||||
-rwxr-xr-x | test/cpp/naming/utils/tcp_connect.py (renamed from test/cpp/naming/test_tcp_connect.py) | 0 |
8 files changed, 89 insertions, 67 deletions
diff --git a/test/cpp/naming/BUILD b/test/cpp/naming/BUILD index 9e102286aa..54b53d2792 100644 --- a/test/cpp/naming/BUILD +++ b/test/cpp/naming/BUILD @@ -34,32 +34,4 @@ grpc_sh_binary( ], ) -grpc_py_binary( - name = "test_dns_server", - srcs = ["test_dns_server.py"], - testonly = True, - data = [ - "resolver_test_record_groups.yaml", - ], - external_deps = [ - "twisted", - "yaml", - ] -) - -grpc_py_binary( - name = "test_dns_resolver", - srcs = ["test_dns_resolver.py"], - testonly = True, - external_deps = [ - "twisted", - ] -) - -grpc_py_binary( - name = "test_tcp_connect", - srcs = ["test_tcp_connect.py"], - testonly = True, -) - generate_resolver_component_tests() diff --git a/test/cpp/naming/generate_resolver_component_tests.bzl b/test/cpp/naming/generate_resolver_component_tests.bzl index dc1a1304c7..d0fb51439f 100755 --- a/test/cpp/naming/generate_resolver_component_tests.bzl +++ b/test/cpp/naming/generate_resolver_component_tests.bzl @@ -54,9 +54,9 @@ def generate_resolver_component_tests(): data = [ ":resolver_component_tests_runner", ":resolver_component_test%s" % unsecure_build_config_suffix, - ":test_dns_server", - ":test_dns_resolver", - ":test_tcp_connect", + "//test/cpp/naming/utils:dns_server", + "//test/cpp/naming/utils:dns_resolver", + "//test/cpp/naming/utils:tcp_connect", "resolver_test_record_groups.yaml", # include the transitive dependency so that the dns sever py binary can locate this ], args = [ diff --git a/test/cpp/naming/resolver_component_tests_runner.sh b/test/cpp/naming/resolver_component_tests_runner.sh index 2510afce48..62231c5e16 100755 --- a/test/cpp/naming/resolver_component_tests_runner.sh +++ b/test/cpp/naming/resolver_component_tests_runner.sh @@ -21,11 +21,11 @@ set -ex FLAGS_test_bin_path=$(echo "$1" | grep '\--test_bin_path=' | cut -d "=" -f 2) FLAGS_dns_server_bin_path=$(echo "$2" | grep '\--dns_server_bin_path=' | cut -d "=" -f 2) FLAGS_records_config_path=$(echo "$3" | grep '\--records_config_path=' | cut -d "=" -f 2) -FLAGS_test_dns_server_port=$(echo "$4" | grep '\--test_dns_server_port=' | cut -d "=" -f 2) -FLAGS_test_dns_resolver_bin_path=$(echo "$5" | grep '\--test_dns_resolver_bin_path=' | cut -d "=" -f 2) -FLAGS_test_tcp_connect_bin_path=$(echo "$6" | grep '\--test_tcp_connect_bin_path=' | cut -d "=" -f 2) +FLAGS_dns_server_port=$(echo "$4" | grep '\--dns_server_port=' | cut -d "=" -f 2) +FLAGS_dns_resolver_bin_path=$(echo "$5" | grep '\--dns_resolver_bin_path=' | cut -d "=" -f 2) +FLAGS_tcp_connect_bin_path=$(echo "$6" | grep '\--tcp_connect_bin_path=' | cut -d "=" -f 2) -for cmd_arg in "$FLAGS_test_bin_path" "$FLAGS_dns_server_bin_path" "$FLAGS_records_config_path" "$FLAGS_test_dns_server_port" "$FLAGS_test_dns_resolver_bin_path" "$FLAGS_test_tcp_connect_bin_path"; do +for cmd_arg in "$FLAGS_test_bin_path" "$FLAGS_dns_server_bin_path" "$FLAGS_records_config_path" "$FLAGS_dns_server_port" "$FLAGS_dns_resolver_bin_path" "$FLAGS_tcp_connect_bin_path"; do if [[ "$cmd_arg" == "" ]]; then echo "Missing a CMD arg" && exit 1 fi @@ -36,7 +36,7 @@ if [[ "$GRPC_DNS_RESOLVER" != "" && "$GRPC_DNS_RESOLVER" != ares ]]; then fi export GRPC_DNS_RESOLVER=ares -"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_test_dns_server_port" > /dev/null 2>&1 & +"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_dns_server_port" > /dev/null 2>&1 & DNS_SERVER_PID=$! echo "Local DNS server started. PID: $DNS_SERVER_PID" @@ -45,8 +45,8 @@ for ((i=0;i<30;i++)); do echo "Retry health-check local DNS server by attempting a DNS query and TCP handshake" RETRY=0 - $FLAGS_test_dns_resolver_bin_path -s 127.0.0.1 -p "$FLAGS_test_dns_server_port" -n health-check-local-dns-server-is-alive.resolver-tests.grpctestingexp. -t 1 | grep '123.123.123.123' || RETRY=1 - $FLAGS_test_tcp_connect_bin_path -s 127.0.0.1 -p "$FLAGS_test_dns_server_port" -t 1 || RETRY=1 + $FLAGS_dns_resolver_bin_path -s 127.0.0.1 -p "$FLAGS_dns_server_port" -n health-check-local-dns-server-is-alive.resolver-tests.grpctestingexp. -t 1 | grep '123.123.123.123' || RETRY=1 + $FLAGS_tcp_connect_bin_path -s 127.0.0.1 -p "$FLAGS_dns_server_port" -t 1 || RETRY=1 if [[ "$RETRY" == 0 ]]; then break fi; @@ -79,7 +79,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -87,7 +87,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.5:1234,True;1.2.3.6:1234,True;1.2.3.7:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -95,7 +95,7 @@ $FLAGS_test_bin_path \ --expected_addrs='[2607:f8b0:400a:801::1001]:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -103,7 +103,7 @@ $FLAGS_test_bin_path \ --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1003]:1234,True;[2607:f8b0:400a:801::1004]:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -111,7 +111,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:1234,True' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -119,7 +119,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -127,7 +127,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -135,7 +135,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -143,7 +143,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -151,7 +151,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -159,7 +159,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:1234,True;1.2.3.4:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -167,7 +167,7 @@ $FLAGS_test_bin_path \ --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1002]:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ @@ -175,7 +175,7 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}' \ --expected_lb_policy='' \ - --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & + --local_dns_server_address="127.0.0.1:$FLAGS_dns_server_port" & wait "$!" || EXIT_CODE=1 kill -SIGTERM "$DNS_SERVER_PID" || true diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc index fadfffe0f4..b2a7890549 100644 --- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc +++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc @@ -103,17 +103,17 @@ void InvokeResolverComponentTestsRunner(std::string test_runner_bin_path, std::string test_bin_path, std::string dns_server_bin_path, std::string records_config_path, - std::string test_dns_resolver_bin_path, - std::string test_tcp_connect_bin_path) { - int test_dns_server_port = grpc_pick_unused_port_or_die(); - - SubProcess* test_driver = new SubProcess( - {test_runner_bin_path, "--test_bin_path=" + test_bin_path, - "--dns_server_bin_path=" + dns_server_bin_path, - "--records_config_path=" + records_config_path, - "--test_dns_server_port=" + std::to_string(test_dns_server_port), - "--test_dns_resolver_bin_path=" + test_dns_resolver_bin_path, - "--test_tcp_connect_bin_path=" + test_tcp_connect_bin_path}); + std::string dns_resolver_bin_path, + std::string tcp_connect_bin_path) { + int dns_server_port = grpc_pick_unused_port_or_die(); + + SubProcess* test_driver = + new SubProcess({test_runner_bin_path, "--test_bin_path=" + test_bin_path, + "--dns_server_bin_path=" + dns_server_bin_path, + "--records_config_path=" + records_config_path, + "--dns_server_port=" + std::to_string(dns_server_port), + "--dns_resolver_bin_path=" + dns_resolver_bin_path, + "--tcp_connect_bin_path=" + tcp_connect_bin_path}); gpr_mu test_driver_mu; gpr_mu_init(&test_driver_mu); gpr_cv test_driver_cv; @@ -174,9 +174,9 @@ int main(int argc, char** argv) { // sure that we're using bazel's test environment. grpc::testing::InvokeResolverComponentTestsRunner( bin_dir + "/resolver_component_tests_runner", - bin_dir + "/" + FLAGS_test_bin_name, bin_dir + "/test_dns_server", + bin_dir + "/" + FLAGS_test_bin_name, bin_dir + "/utils/dns_server", bin_dir + "/resolver_test_record_groups.yaml", - bin_dir + "/test_dns_resolver", bin_dir + "/test_tcp_connect"); + bin_dir + "/utils/dns_resolver", bin_dir + "/utils/tcp_connect"); } else { // Get the current binary's directory relative to repo root to invoke the // correct build config (asan/tsan/dbg, etc.). @@ -185,10 +185,10 @@ int main(int argc, char** argv) { grpc::testing::InvokeResolverComponentTestsRunner( "test/cpp/naming/resolver_component_tests_runner.sh", bin_dir + "/" + FLAGS_test_bin_name, - "test/cpp/naming/test_dns_server.py", + "test/cpp/naming/utils/dns_server.py", "test/cpp/naming/resolver_test_record_groups.yaml", - "test/cpp/naming/test_dns_resolver.py", - "test/cpp/naming/test_tcp_connect.py"); + "test/cpp/naming/utils/dns_resolver.py", + "test/cpp/naming/utils/tcp_connect.py"); } grpc_shutdown(); return 0; diff --git a/test/cpp/naming/utils/BUILD b/test/cpp/naming/utils/BUILD new file mode 100644 index 0000000000..e7b6bc5fe7 --- /dev/null +++ b/test/cpp/naming/utils/BUILD @@ -0,0 +1,50 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +package( + default_visibility = ["//visibility:public"], + features = [ + "-layering_check", + "-parse_headers", + ], +) + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_py_binary") + +grpc_py_binary( + name = "dns_server", + srcs = ["dns_server.py"], + testonly = True, + external_deps = [ + "twisted", + "yaml", + ] +) + +grpc_py_binary( + name = "dns_resolver", + srcs = ["dns_resolver.py"], + testonly = True, + external_deps = [ + "twisted", + ] +) + +grpc_py_binary( + name = "tcp_connect", + srcs = ["tcp_connect.py"], + testonly = True, +) diff --git a/test/cpp/naming/test_dns_resolver.py b/test/cpp/naming/utils/dns_resolver.py index 6b272444e7..6b272444e7 100755 --- a/test/cpp/naming/test_dns_resolver.py +++ b/test/cpp/naming/utils/dns_resolver.py diff --git a/test/cpp/naming/test_dns_server.py b/test/cpp/naming/utils/dns_server.py index 9f42f65ee6..9f42f65ee6 100755 --- a/test/cpp/naming/test_dns_server.py +++ b/test/cpp/naming/utils/dns_server.py diff --git a/test/cpp/naming/test_tcp_connect.py b/test/cpp/naming/utils/tcp_connect.py index bf7455e3c2..bf7455e3c2 100755 --- a/test/cpp/naming/test_tcp_connect.py +++ b/test/cpp/naming/utils/tcp_connect.py |