From 7d243df88f359263f4c1ca82a472e49199bd52fe Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 18 Feb 2016 09:58:05 -0800 Subject: Increase Node's per-test timeout and Ruby's overall test timeout --- tools/run_tests/run_node.bat | 2 +- tools/run_tests/run_node.sh | 9 +++++++-- tools/run_tests/run_tests.py | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/run_tests/run_node.bat b/tools/run_tests/run_node.bat index f5cf01f095..ad9ca14b8b 100644 --- a/tools/run_tests/run_node.bat +++ b/tools/run_tests/run_node.bat @@ -29,4 +29,4 @@ set JUNIT_REPORT_PATH=src\node\reports.xml set JUNIT_REPORT_STACK=1 -.\node_modules\.bin\mocha.cmd --reporter mocha-jenkins-reporter src\node\test \ No newline at end of file +.\node_modules\.bin\mocha.cmd --reporter mocha-jenkins-reporter --timeout 8000 src\node\test \ No newline at end of file diff --git a/tools/run_tests/run_node.sh b/tools/run_tests/run_node.sh index 40f61d77cc..178584ae8e 100755 --- a/tools/run_tests/run_node.sh +++ b/tools/run_tests/run_node.sh @@ -41,10 +41,13 @@ cd $(dirname $0)/../.. root=`pwd` +test_directory='src/node/test' +timeout=8000 + if [ "$CONFIG" = "gcov" ] then ./node_modules/.bin/istanbul cover --dir reports/node_coverage \ - -x **/interop/* ./node_modules/.bin/_mocha -- --timeout 8000 src/node/test + -x **/interop/* ./node_modules/.bin/_mocha -- --timeout $timeout $test_directory cd build gcov Release/obj.target/grpc/ext/*.o lcov --base-directory . --directory . -c -o coverage.info @@ -55,5 +58,7 @@ then echo '' > \ ../reports/node_coverage/index.html else - JUNIT_REPORT_PATH=src/node/reports.xml JUNIT_REPORT_STACK=1 ./node_modules/.bin/mocha --reporter mocha-jenkins-reporter src/node/test + JUNIT_REPORT_PATH=src/node/reports.xml JUNIT_REPORT_STACK=1 \ + ./node_modules/.bin/mocha --timeout $timeout \ + --reporter mocha-jenkins-reporter $test_directory fi diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index de3716bc88..0b3efa29e3 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -334,13 +334,14 @@ class RubyLanguage(object): def test_specs(self, config, args): return [config.job_spec(['tools/run_tests/run_ruby.sh'], None, + timeout_seconds=10*60, environ=_FORCE_ENVIRON_FOR_WRAPPERS)] def pre_build_steps(self): return [['tools/run_tests/pre_build_ruby.sh']] def make_targets(self, test_regex): - return ['static_c'] + return [] def make_options(self): return [] @@ -1197,4 +1198,3 @@ else: if BuildAndRunError.POST_TEST in errors: exit_code |= 4 sys.exit(exit_code) - -- cgit v1.2.3 From 7d2a3e1917ebfd4e1262020b021b3bf09d238c86 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 18 Feb 2016 15:41:56 -0800 Subject: Refactor end2end_test. Make the credentials a separate library. --- Makefile | 3 + build.yaml | 2 + test/cpp/end2end/end2end_test.cc | 58 ++++++++--------- test/cpp/util/test_credentials_provider.cc | 74 ++++++++++++++++++++++ test/cpp/util/test_credentials_provider.h | 61 ++++++++++++++++++ tools/run_tests/sources_and_headers.json | 7 +- .../grpc++_test_util/grpc++_test_util.vcxproj | 3 + .../grpc++_test_util.vcxproj.filters | 6 ++ 8 files changed, 181 insertions(+), 33 deletions(-) create mode 100644 test/cpp/util/test_credentials_provider.cc create mode 100644 test/cpp/util/test_credentials_provider.h (limited to 'tools') diff --git a/Makefile b/Makefile index 6c7febdabc..62e873dad7 100644 --- a/Makefile +++ b/Makefile @@ -3162,6 +3162,7 @@ LIBGRPC++_TEST_UTIL_SRC = \ test/cpp/util/create_test_channel.cc \ test/cpp/util/string_ref_helper.cc \ test/cpp/util/subprocess.cc \ + test/cpp/util/test_credentials_provider.cc \ LIBGRPC++_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_TEST_UTIL_SRC)))) @@ -3212,6 +3213,7 @@ $(OBJDIR)/$(CONFIG)/test/cpp/util/cli_call.o: $(GENDIR)/src/proto/grpc/testing/e $(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc LIBGRPC++_UNSECURE_SRC = \ @@ -13015,6 +13017,7 @@ test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP) test/cpp/util/string_ref_helper.cc: $(OPENSSL_DEP) test/cpp/util/subprocess.cc: $(OPENSSL_DEP) test/cpp/util/test_config.cc: $(OPENSSL_DEP) +test/cpp/util/test_credentials_provider.cc: $(OPENSSL_DEP) endif .PHONY: all strip tools dep_error openssl_dep_error openssl_dep_message git_update stop buildtests buildtests_c buildtests_cxx test test_c test_cxx install install_c install_cxx install-headers install-headers_c install-headers_cxx install-shared install-shared_c install-shared_cxx install-static install-static_c install-static_cxx strip strip-shared strip-static strip_c strip-shared_c strip-static_c strip_cxx strip-shared_cxx strip-static_cxx dep_c dep_cxx bins_dep_c bins_dep_cxx clean diff --git a/build.yaml b/build.yaml index b639b5d21e..5b1878eb9f 100644 --- a/build.yaml +++ b/build.yaml @@ -716,6 +716,7 @@ libs: - test/cpp/util/create_test_channel.h - test/cpp/util/string_ref_helper.h - test/cpp/util/subprocess.h + - test/cpp/util/test_credentials_provider.h src: - src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/echo.proto @@ -726,6 +727,7 @@ libs: - test/cpp/util/create_test_channel.cc - test/cpp/util/string_ref_helper.cc - test/cpp/util/subprocess.cc + - test/cpp/util/test_credentials_provider.cc deps: - grpc++ - grpc_test_util diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index c8523847ab..df9aae7436 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -51,11 +51,11 @@ #include "src/core/security/credentials.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" #include "test/cpp/end2end/test_service_impl.h" #include "test/cpp/util/string_ref_helper.h" +#include "test/cpp/util/test_credentials_provider.h" using grpc::testing::EchoRequest; using grpc::testing::EchoResponse; @@ -191,12 +191,14 @@ class TestServiceImplDupPkg class TestScenario { public: - TestScenario(bool proxy, bool tls) : use_proxy(proxy), use_tls(tls) {} + TestScenario(bool proxy, const grpc::string& creds_type) + : use_proxy(proxy), credentials_type(creds_type) {} void Log() const { - gpr_log(GPR_INFO, "Scenario: proxy %d, tls %d", use_proxy, use_tls); + gpr_log(GPR_INFO, "Scenario: proxy %d, credentials %s", use_proxy, + credentials_type.c_str()); } bool use_proxy; - bool use_tls; + const grpc::string credentials_type; }; class End2endTest : public ::testing::TestWithParam { @@ -220,14 +222,8 @@ class End2endTest : public ::testing::TestWithParam { server_address_ << "127.0.0.1:" << port; // Setup server ServerBuilder builder; - auto server_creds = InsecureServerCredentials(); - if (GetParam().use_tls) { - SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, - test_server1_cert}; - SslServerCredentialsOptions ssl_opts; - ssl_opts.pem_root_certs = ""; - ssl_opts.pem_key_cert_pairs.push_back(pkcp); - server_creds = SslServerCredentials(ssl_opts); + auto server_creds = GetServerCredentials(GetParam().credentials_type); + if (GetParam().credentials_type != kInsecureCredentialsType) { server_creds->SetAuthMetadataProcessor(processor); } builder.AddListeningPort(server_address_.str(), server_creds); @@ -246,12 +242,8 @@ class End2endTest : public ::testing::TestWithParam { } EXPECT_TRUE(is_server_started_); ChannelArguments args; - auto channel_creds = InsecureChannelCredentials(); - if (GetParam().use_tls) { - SslCredentialsOptions ssl_opts = {test_root_cert, "", ""}; - args.SetSslTargetNameOverride("foo.test.google.fr"); - channel_creds = SslCredentials(ssl_opts); - } + auto channel_creds = + GetChannelCredentials(GetParam().credentials_type, &args); if (!user_agent_prefix_.empty()) { args.SetUserAgentPrefix(user_agent_prefix_); } @@ -941,7 +933,7 @@ TEST_P(End2endTest, ChannelState) { // Takes 10s. TEST_P(End2endTest, ChannelStateTimeout) { - if (GetParam().use_tls) { + if (GetParam().credentials_type != kInsecureCredentialsType) { return; } int port = grpc_pick_unused_port_or_die(); @@ -1150,7 +1142,7 @@ class SecureEnd2endTest : public End2endTest { protected: SecureEnd2endTest() { GPR_ASSERT(!GetParam().use_proxy); - GPR_ASSERT(GetParam().use_tls); + GPR_ASSERT(GetParam().credentials_type != kInsecureCredentialsType); } }; @@ -1373,21 +1365,25 @@ TEST_P(SecureEnd2endTest, ClientAuthContext) { EXPECT_EQ("*.test.youtube.com", ToString(auth_ctx->GetPeerIdentity()[2])); } -INSTANTIATE_TEST_CASE_P(End2end, End2endTest, - ::testing::Values(TestScenario(false, false), - TestScenario(false, true))); +INSTANTIATE_TEST_CASE_P( + End2end, End2endTest, + ::testing::Values(TestScenario(false, kInsecureCredentialsType), + TestScenario(false, kTlsCredentialsType))); -INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest, - ::testing::Values(TestScenario(false, false))); +INSTANTIATE_TEST_CASE_P( + End2endServerTryCancel, End2endServerTryCancelTest, + ::testing::Values(TestScenario(false, kInsecureCredentialsType))); -INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest, - ::testing::Values(TestScenario(false, false), - TestScenario(false, true), - TestScenario(true, false), - TestScenario(true, true))); +INSTANTIATE_TEST_CASE_P( + ProxyEnd2end, ProxyEnd2endTest, + ::testing::Values(TestScenario(false, kInsecureCredentialsType), + TestScenario(false, kTlsCredentialsType), + TestScenario(true, kInsecureCredentialsType), + TestScenario(true, kTlsCredentialsType))); INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest, - ::testing::Values(TestScenario(false, true))); + ::testing::Values(TestScenario(false, + kTlsCredentialsType))); } // namespace } // namespace testing diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc new file mode 100644 index 0000000000..f8380cdb65 --- /dev/null +++ b/test/cpp/util/test_credentials_provider.cc @@ -0,0 +1,74 @@ + +/* + * + * Copyright 2016, 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. + * + */ + +#include "test/cpp/util/test_credentials_provider.h" + +#include "test/core/end2end/data/ssl_test_data.h" + +namespace grpc { +namespace testing { + +std::shared_ptr GetChannelCredentials( + const grpc::string& type, ChannelArguments* args) { + if (type == kInsecureCredentialsType) { + return InsecureChannelCredentials(); + } else if (type == kTlsCredentialsType) { + SslCredentialsOptions ssl_opts = {test_root_cert, "", ""}; + args->SetSslTargetNameOverride("foo.test.google.fr"); + return SslCredentials(ssl_opts); + } else { + gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str()); + } + return nullptr; +} + +std::shared_ptr GetServerCredentials( + const grpc::string& type) { + if (type == kInsecureCredentialsType) { + return InsecureServerCredentials(); + } else if (type == kTlsCredentialsType) { + SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, + test_server1_cert}; + SslServerCredentialsOptions ssl_opts; + ssl_opts.pem_root_certs = ""; + ssl_opts.pem_key_cert_pairs.push_back(pkcp); + return SslServerCredentials(ssl_opts); + } else { + gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str()); + } + return nullptr; +} + +} // namespace testing +} // namespace grpc diff --git a/test/cpp/util/test_credentials_provider.h b/test/cpp/util/test_credentials_provider.h new file mode 100644 index 0000000000..4f25e3be66 --- /dev/null +++ b/test/cpp/util/test_credentials_provider.h @@ -0,0 +1,61 @@ +/* + * + * Copyright 2016, 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 GRPC_TEST_CPP_UTIL_TEST_CREDENTIALS_PROVIDER_H +#define GRPC_TEST_CPP_UTIL_TEST_CREDENTIALS_PROVIDER_H + +#include + +#include +#include +#include + +namespace grpc { +namespace testing { + +const char kInsecureCredentialsType[] = "INSECURE_CREDENTIALS"; +const char kTlsCredentialsType[] = "TLS_CREDENTIALS"; + +// Provide channel credentials according to the given type. Alter the channel +// arguments if needed. +std::shared_ptr GetChannelCredentials( + const grpc::string& type, ChannelArguments* args); + +// Provide server credentials according to the given type. +std::shared_ptr GetServerCredentials( + const grpc::string& type); + +} // namespace testing +} // namespace grpc + +#endif // GRPC_TEST_CPP_UTIL_TEST_CREDENTIALS_PROVIDER_H diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 5b1b67439d..80edd6d467 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -4186,7 +4186,8 @@ "test/cpp/util/cli_call.h", "test/cpp/util/create_test_channel.h", "test/cpp/util/string_ref_helper.h", - "test/cpp/util/subprocess.h" + "test/cpp/util/subprocess.h", + "test/cpp/util/test_credentials_provider.h" ], "language": "c++", "name": "grpc++_test_util", @@ -4202,7 +4203,9 @@ "test/cpp/util/string_ref_helper.cc", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.cc", - "test/cpp/util/subprocess.h" + "test/cpp/util/subprocess.h", + "test/cpp/util/test_credentials_provider.cc", + "test/cpp/util/test_credentials_provider.h" ] }, { diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj index 3d353716a9..33860af620 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj @@ -153,6 +153,7 @@ + @@ -191,6 +192,8 @@ + + diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters index 27ac6751b9..b35ba1fd91 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters @@ -28,6 +28,9 @@ test\cpp\util + + test\cpp\util + @@ -48,6 +51,9 @@ test\cpp\util + + test\cpp\util + -- cgit v1.2.3