diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc index 5c5c246f998427ef70357a992324fc51aff15924..c646f71908c0caa1e7a380fed47d4417f87cf775 100644 --- a/src/core/lib/iomgr/endpoint_pair_posix.cc +++ b/src/core/lib/iomgr/endpoint_pair_posix.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index 63a0269ed628a6f3c3f6702729e1d6f934efa82a..1d2e95064517eeec7e64dccbcc6ae307fbbee29d 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -134,6 +134,7 @@ #define GRPC_POSIX_SOCKET_EV_EPOLL1 1 #define GRPC_POSIX_SOCKET_EV_EPOLLEX 1 #define GRPC_POSIX_SOCKET_EV_POLL 1 +#define GRPC_POSIX_SOCKET_IF_NAMETOINDEX 1 #define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1 #define GRPC_POSIX_SOCKET_SOCKADDR 1 #define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1 @@ -141,6 +142,7 @@ #define GRPC_POSIX_SOCKET_TCP_CLIENT 1 #define GRPC_POSIX_SOCKET_TCP_SERVER 1 #define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1 +#define GRPC_POSIX_SOCKET_UDP_SERVER 1 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1 #else #define GRPC_POSIX_SOCKET 1 @@ -227,6 +229,7 @@ #define GRPC_POSIX_SOCKET_TCP_CLIENT 1 #define GRPC_POSIX_SOCKET_TCP_SERVER 1 #define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1 +#define GRPC_POSIX_SOCKET_UDP_SERVER 1 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1 #endif diff --git a/src/core/lib/iomgr/udp_server.cc b/src/core/lib/iomgr/udp_server.cc index 2afef07907b20e6cc1d4adedeaf451fad99ac1a4..0bfd22fc79cf637c3fadce5abed17cbdb6c2494a 100644 --- a/src/core/lib/iomgr/udp_server.cc +++ b/src/core/lib/iomgr/udp_server.cc @@ -29,7 +29,7 @@ #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_UDP_SERVER #include "src/core/lib/iomgr/udp_server.h" diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc index 8fd120e0428f4c5bebf5a15db548df0d283569b0..3c6fa9e28b34d7a4cd80a63702682552df9178c3 100644 --- a/test/core/backoff/backoff_test.cc +++ b/test/core/backoff/backoff_test.cc @@ -20,6 +20,7 @@ #include <algorithm> +#include <grpc/grpc.h> #include <grpc/support/log.h> #include <gtest/gtest.h> @@ -171,7 +172,9 @@ TEST(BackOffTest, JitterBackOff) { } // namespace grpc int main(int argc, char** argv) { + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); + grpc_shutdown(); } diff --git a/test/core/bad_client/tests/large_metadata.cc b/test/core/bad_client/tests/large_metadata.cc index 686a701dfed517b67a24404cf71134d4d76e237f..8206afa5afbfd7a3dceca8ce286544d5ac4e69e6 100644 --- a/test/core/bad_client/tests/large_metadata.cc +++ b/test/core/bad_client/tests/large_metadata.cc @@ -140,7 +140,7 @@ static void server_verifier_sends_too_much_metadata( int main(int argc, char** argv) { int i; - + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); // Test sending more metadata than the server will accept. @@ -173,5 +173,6 @@ int main(int argc, char** argv) { GRPC_RUN_BAD_CLIENT_TEST(server_verifier_sends_too_much_metadata, rst_stream_client_validator, PFX_TOO_MUCH_METADATA_FROM_SERVER_STR, 0); + grpc_shutdown(); return 0; } diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index 78a1a5cc9a49ccd35e13cef7e7ea37474b34fa18..380cbcd8dfadffcba2071ae20040171bcb9b273a 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -24,7 +24,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP #include "test/core/util/test_config.h" @@ -751,8 +751,8 @@ int main(int argc, char** argv) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_TCP */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_TCP */ diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index efc691dd43fd931cba99bb09f6907fd1a123bd0d..9f0f981663551f676f55d6362c19dd7c22a286d2 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV #include <string.h> @@ -370,8 +370,8 @@ int main(int argc, char** argv) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_EV */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_EV */ diff --git a/test/core/handshake/client_ssl.cc b/test/core/handshake/client_ssl.cc index a9a60b88e249d2281c8ddf21b464ad1ace27120b..15aebdd2ac4f13c4ffa0f107c2dbee2f1cbd4baa 100644 --- a/test/core/handshake/client_ssl.cc +++ b/test/core/handshake/client_ssl.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP #include <arpa/inet.h> #include <openssl/err.h> @@ -322,8 +322,8 @@ int main(int /*argc*/, char* /*argv*/ []) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_TCP */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_TCP */ diff --git a/test/core/handshake/verify_peer_options.cc b/test/core/handshake/verify_peer_options.cc index 6727abc8b93e338a7625a0bfed136a060e6d89f8..b77f305ac876decf3fabb493b7737348ec29da49 100644 --- a/test/core/handshake/verify_peer_options.cc +++ b/test/core/handshake/verify_peer_options.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP #include <arpa/inet.h> #include <openssl/err.h> @@ -268,8 +268,8 @@ int main(int /*argc*/, char* /*argv*/ []) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_TCP */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_TCP */ diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD index 7550d277aef5cfd44f86722bc41214f94bdd1728..9b78d709734599e8a3c4ea502b6e9f2cf2afd7c8 100644 --- a/test/core/iomgr/BUILD +++ b/test/core/iomgr/BUILD @@ -254,7 +254,10 @@ grpc_cc_test( name = "tcp_posix_test", srcs = ["tcp_posix_test.cc"], language = "C++", - tags = ["no_windows"], + tags = [ + "no_windows", + "no_mac", # TODO(jtattermusch): Reenable once https://github.com/grpc/grpc/issues/21282 is fixed. + ], deps = [ ":endpoint_tests", "//:gpr", diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc index 79afb49066a437b6166c4eb5181ff3be955d6dba..83259cca2f111db2e26c939d16a23a3e68fce88a 100644 --- a/test/core/iomgr/fd_posix_test.cc +++ b/test/core/iomgr/fd_posix_test.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV #include "src/core/lib/iomgr/ev_posix.h" @@ -533,8 +533,8 @@ int main(int argc, char** argv) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_EV */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_EV */ diff --git a/test/core/iomgr/socket_utils_test.cc b/test/core/iomgr/socket_utils_test.cc index f0537e03e9d26aae3b7a327be373674fee2cbe92..d307f04fb18f92fcb548fc77ccf51b41d3ee37d1 100644 --- a/test/core/iomgr/socket_utils_test.cc +++ b/test/core/iomgr/socket_utils_test.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_UTILS_COMMON #include "src/core/lib/iomgr/socket_utils_posix.h" @@ -132,8 +132,8 @@ int main(int argc, char** argv) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_UTILS_COMMON */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_UTILS_COMMON */ diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc index 0896a27f40bfbd299537436232a854f5ae1596a3..50293765c3fd01b632c8798d207d0b20e2e6f61c 100644 --- a/test/core/iomgr/tcp_client_posix_test.cc +++ b/test/core/iomgr/tcp_client_posix_test.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP_CLIENT #include "src/core/lib/iomgr/tcp_client.h" @@ -215,8 +215,8 @@ int main(int argc, char** argv) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_TCP_CLIENT */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_CLIENT */ diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc index f56f4f128e41f61d091df5ded5e5daf3ac104dc6..ad6e126d0c2a10636ac37bf79b106c922a9af537 100644 --- a/test/core/iomgr/tcp_posix_test.cc +++ b/test/core/iomgr/tcp_posix_test.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP #include "src/core/lib/iomgr/tcp_posix.h" @@ -645,8 +645,8 @@ int main(int argc, char** argv) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_TCP */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_TCP */ diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc index 0292f771fc9453e2d9fdaf264a27ea9d7fb7143d..b2d64f4f42aa83851d50ceb371f1262f998ebf2b 100644 --- a/test/core/iomgr/tcp_server_posix_test.cc +++ b/test/core/iomgr/tcp_server_posix_test.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_TCP_SERVER #include "src/core/lib/iomgr/tcp_server.h" @@ -506,8 +506,8 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_SERVER */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_SERVER */ diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc index 27532035318e4db42b7d30896601394f427880ad..9143a225392297b8b29cd9cc0bc6eef996831397 100644 --- a/test/core/iomgr/udp_server_test.cc +++ b/test/core/iomgr/udp_server_test.cc @@ -19,7 +19,7 @@ #include "src/core/lib/iomgr/port.h" // This test won't work except with posix sockets enabled -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_UDP_SERVER #include "src/core/lib/iomgr/udp_server.h" @@ -383,8 +383,8 @@ int main(int argc, char** argv) { return 0; } -#else /* GRPC_POSIX_SOCKET */ +#else /* GRPC_POSIX_SOCKET_UDP_SERVER */ int main(int argc, char** argv) { return 1; } -#endif /* GRPC_POSIX_SOCKET */ +#endif /* GRPC_POSIX_SOCKET_UDP_SERVER */ diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 93c66c73370a7f465298df5992ab8c926c6132d3..f488a2f59254d16e6365e8cf2e965835d136e170 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -1440,16 +1440,32 @@ static void test_metadata_plugin_failure(void) { static void test_get_well_known_google_credentials_file_path(void) { char* path; char* home = gpr_getenv("HOME"); + bool restore_home_env = false; +#if defined(GRPC_BAZEL_BUILD) && \ + (defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV)) + // when running under bazel locally, the HOME variable is not set + // so we set it to some fake value + restore_home_env = true; + gpr_setenv("HOME", "/fake/home/for/bazel"); +#endif /* defined(GRPC_BAZEL_BUILD) && (defined(GPR_POSIX_ENV) || \ + defined(GPR_LINUX_ENV)) */ path = grpc_get_well_known_google_credentials_file_path(); GPR_ASSERT(path != nullptr); gpr_free(path); #if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV) + restore_home_env = true; gpr_unsetenv("HOME"); path = grpc_get_well_known_google_credentials_file_path(); GPR_ASSERT(path == nullptr); - gpr_setenv("HOME", home); gpr_free(path); #endif /* GPR_POSIX_ENV || GPR_LINUX_ENV */ + if (restore_home_env) { + if (home) { + gpr_setenv("HOME", home); + } else { + gpr_unsetenv("HOME"); + } + } gpr_free(home); } diff --git a/test/core/surface/byte_buffer_reader_test.cc b/test/core/surface/byte_buffer_reader_test.cc index bc368c49657cc6bffe150fa13f3b5657da86151a..fc2654426d706f0e3b4b9b10c21ae231d0fade7a 100644 --- a/test/core/surface/byte_buffer_reader_test.cc +++ b/test/core/surface/byte_buffer_reader_test.cc @@ -334,6 +334,7 @@ static void test_byte_buffer_copy(void) { } int main(int argc, char** argv) { + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); test_read_one_slice(); test_read_one_slice_malloc(); @@ -347,5 +348,6 @@ int main(int argc, char** argv) { test_byte_buffer_from_reader(); test_byte_buffer_copy(); test_readall(); + grpc_shutdown(); return 0; } diff --git a/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc b/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc index 2d5a2b21ffcbe799ad1d119e452faa5c944447c9..2a3ea934ac0a63efca30a1a3158f4c0641248280 100644 --- a/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc +++ b/test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc @@ -68,7 +68,9 @@ static void deserialize_response_test() { int main(int /*argc*/, char** /*argv*/) { /* Tests. */ + grpc_init(); deserialize_response_test(); convert_to_tsi_result_test(); + grpc_shutdown(); return 0; } diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc index 11933f1fa913b8fd8119b836139ff0ac4d9e04a9..13837ccaa95c9dcf4d54b0fddbe039c324ec2cec 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc @@ -445,6 +445,7 @@ static void alts_grpc_record_protocol_tests( } int main(int /*argc*/, char** /*argv*/) { + grpc_init(); alts_grpc_record_protocol_tests( &test_fixture_integrity_only_no_rekey_no_extra_copy_create); alts_grpc_record_protocol_tests(&test_fixture_integrity_only_rekey_create); @@ -453,6 +454,7 @@ int main(int /*argc*/, char** /*argv*/) { alts_grpc_record_protocol_tests( &test_fixture_privacy_integrity_no_rekey_create); alts_grpc_record_protocol_tests(&test_fixture_privacy_integrity_rekey_create); + grpc_shutdown(); return 0; } diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc index f730c9f0cff4552073445a96ebd014f6a993330c..9a426b055b4ed8d7500833e8f1df1c120ce1ba56 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc @@ -296,6 +296,7 @@ static void alts_zero_copy_protector_seal_unseal_large_buffer_tests( } int main(int /*argc*/, char** /*argv*/) { + grpc_init(); alts_zero_copy_protector_seal_unseal_small_buffer_tests( /*enable_extra_copy=*/false); alts_zero_copy_protector_seal_unseal_small_buffer_tests( @@ -304,5 +305,6 @@ int main(int /*argc*/, char** /*argv*/) { /*enable_extra_copy=*/false); alts_zero_copy_protector_seal_unseal_large_buffer_tests( /*enable_extra_copy=*/true); + grpc_shutdown(); return 0; } diff --git a/test/cpp/common/timer_test.cc b/test/cpp/common/timer_test.cc index ec08e76cfe55f5514c4b01e8ddf1947088807a40..c78f75dc91d72ce012e7ebd7a759692327e925e5 100644 --- a/test/cpp/common/timer_test.cc +++ b/test/cpp/common/timer_test.cc @@ -27,7 +27,7 @@ #include "src/core/lib/iomgr/timer_manager.h" #include "test/core/util/test_config.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV #include "src/core/lib/iomgr/ev_posix.h" #endif @@ -46,7 +46,7 @@ class TimerTest : public ::testing::Test { grpc_init(); // Skip test if slowdown factor > 1, or we are // using event manager. -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV if (grpc_test_slowdown_factor() != 1 || grpc_event_engine_run_in_background()) { #else diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 659076fe5dc321dec0e05bfc5b4f6dcd0ac12665..ce19e5077ad0b6f886260649f31af5726a2212fd 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -43,9 +43,9 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV #include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET +#endif // GRPC_POSIX_SOCKET_EV #include <gtest/gtest.h> @@ -362,14 +362,14 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) { return; } int poller_slowdown_factor = 1; -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" grpc_core::UniquePtr<char> poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); if (0 == strcmp(poller.get(), "poll")) { poller_slowdown_factor = 2; } -#endif // GRPC_POSIX_SOCKET +#endif // GRPC_POSIX_SOCKET_EV ResetStub(); SendRpc(1); server_->Shutdown(); diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index 8f1f3b075007510d643efab6450813b5b37810ee..1d3f531c124c756ba81160cc042210ae7919fcba 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -1386,7 +1386,10 @@ INSTANTIATE_TEST_SUITE_P(ClientCallbackEnd2endTest, ClientCallbackEnd2endTest, } // namespace grpc int main(int argc, char** argv) { + grpc_init(); grpc::testing::TestEnvironment env(argc, argv); ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 1d84586e18e0451ca6e82be0b03df387066b797a..114d6ccfd2163c35c3b79273967e51448b029ca9 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -48,9 +48,9 @@ #include "test/cpp/util/string_ref_helper.h" #include "test/cpp/util/test_credentials_provider.h" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV #include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET +#endif // GRPC_POSIX_SOCKET_EV #include <gtest/gtest.h> @@ -833,12 +833,12 @@ TEST_P(End2endTest, ReconnectChannel) { int poller_slowdown_factor = 1; // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" -#ifdef GRPC_POSIX_SOCKET +#ifdef GRPC_POSIX_SOCKET_EV grpc_core::UniquePtr<char> poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); if (0 == strcmp(poller.get(), "poll")) { poller_slowdown_factor = 2; } -#endif // GRPC_POSIX_SOCKET +#endif // GRPC_POSIX_SOCKET_EV ResetStub(); SendRpc(stub_.get(), 1, false); RestartServer(std::shared_ptr<AuthMetadataProcessor>()); diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index fd5aff150637202bbab056fb795128c4b51bc39a..d7d449e8fb77ecf4498ce4643e7252077148ed63 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -136,7 +136,10 @@ grpc_cc_binary( srcs = [ "bm_fullstack_streaming_ping_pong.cc", ], - tags = ["no_windows"], + tags = [ + "no_windows", + "no_mac", # to emulate "excluded_poll_engines: poll" + ], deps = [":fullstack_streaming_ping_pong_h"], ) @@ -155,7 +158,10 @@ grpc_cc_binary( srcs = [ "bm_fullstack_streaming_pump.cc", ], - tags = ["no_windows"], + tags = [ + "no_windows", + "no_mac", # to emulate "excluded_poll_engines: poll" + ], deps = [":fullstack_streaming_pump_h"], ) @@ -163,7 +169,10 @@ grpc_cc_binary( name = "bm_fullstack_trickle", testonly = 1, srcs = ["bm_fullstack_trickle.cc"], - tags = ["no_windows"], + tags = [ + "no_windows", + "no_mac", # to emulate "excluded_poll_engines: poll" + ], deps = [":helpers"], ) @@ -182,7 +191,10 @@ grpc_cc_binary( srcs = [ "bm_fullstack_unary_ping_pong.cc", ], - tags = ["no_windows"], + tags = [ + "no_windows", + "no_mac", # to emulate "excluded_poll_engines: poll" + ], deps = [":fullstack_unary_ping_pong_h"], ) diff --git a/test/cpp/naming/generate_resolver_component_tests.bzl b/test/cpp/naming/generate_resolver_component_tests.bzl index 45243183d0ad42ad9ec276232bd147fc5a229c0f..812bf3b71b922988a4bf81fa2ec9cf643bb90b5a 100755 --- a/test/cpp/naming/generate_resolver_component_tests.bzl +++ b/test/cpp/naming/generate_resolver_component_tests.bzl @@ -82,5 +82,5 @@ def generate_resolver_component_tests(): "--test_bin_name=resolver_component_test%s" % unsecure_build_config_suffix, "--running_under_bazel=true", ], - tags = ["no_windows"], + tags = ["no_windows", "no_mac"], ) diff --git a/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg b/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg index bc9b671e1fb4b44bbedf386c40eb434d5e88cce4..7c4c17142c37b442ca4839145d78aa2bd2a063a5 100644 --- a/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg +++ b/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg @@ -16,7 +16,26 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh" +timeout_mins: 90 + +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/resultstore_api_key" + +bazel_setting { + # In order for Kokoro to recognize this as a bazel build and publish the bazel resultstore link, + # the bazel_setting section needs to be present and "upsalite_frontend_address" needs to be + # set. The rest of configuration from bazel_setting is unused (we configure everything when bazel + # command is invoked). + upsalite_frontend_address: "https://source.cloud.google.com" +} + +env_vars { + # flags will be passed to bazel invocation + key: "BAZEL_FLAGS" + value: "--cache_test_results=no --config=dbg" +} + env_vars { - key: "RUN_TESTS_FLAGS" - value: "--config=dbg" + key: "UPLOAD_TEST_RESULTS" + value: "true" } diff --git a/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg b/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg index 62fc5fc1b388b439b7eab2f9d737a4872df2d33a..e7447398713fa6ffa21d77ac390f5f5abe2e03bf 100644 --- a/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg +++ b/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg @@ -16,7 +16,26 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh" +timeout_mins: 90 + +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/resultstore_api_key" + +bazel_setting { + # In order for Kokoro to recognize this as a bazel build and publish the bazel resultstore link, + # the bazel_setting section needs to be present and "upsalite_frontend_address" needs to be + # set. The rest of configuration from bazel_setting is unused (we configure everything when bazel + # command is invoked). + upsalite_frontend_address: "https://source.cloud.google.com" +} + +env_vars { + # flags will be passed to bazel invocation + key: "BAZEL_FLAGS" + value: "--cache_test_results=no --config=opt" +} + env_vars { - key: "RUN_TESTS_FLAGS" - value: "--config=opt" + key: "UPLOAD_TEST_RESULTS" + value: "true" } diff --git a/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh b/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh index 434fc1a28049f43e8dbd9055e92ed0b65413a978..ed9c97211c49014ed614f5c2fb710c819427058e 100644 --- a/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh +++ b/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh @@ -18,13 +18,40 @@ set -ex # change to grpc repo root cd $(dirname $0)/../../.. +# TODO(jtattermusch): most of the prepare steps should not be needed for bazel +source tools/internal_ci/helper_scripts/prepare_build_macos_rc + +# make sure bazel is available +tools/bazel version + ./tools/run_tests/start_port_server.py +# to get "bazel" link for kokoro build, we need to generate +# invocation UUID, set a flag for bazel to use it +# and upload "bazel_invocation_ids" file as artifact. +# NOTE: UUID needs to be in lowercase for the result link to work +# (on mac "uuidgen" outputs uppercase UUID) +BAZEL_INVOCATION_ID="$(uuidgen | tr '[:upper:]' '[:lower:]')" +echo "${BAZEL_INVOCATION_ID}" >"${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids" + # run all C/C++ tests -# TODO(jtattermusch): try using Bazel RBE remote cache -# TODO(jtattermusch): upload bazel test results to resultstore -tools/bazel test $RUN_TESTS_FLAGS //test/... +tools/bazel \ + --bazelrc=tools/remote_build/mac.bazelrc \ + test \ + --invocation_id="${BAZEL_INVOCATION_ID}" \ + --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh \ + --google_credentials="${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json" \ + $BAZEL_FLAGS \ + -- //test/... || FAILED="true" -# kill port_server.py to prevent the build from hanging -ps aux | grep port_server\\.py | awk '{print $2}' | xargs kill -9 +if [ "$UPLOAD_TEST_RESULTS" != "" ] +then + # Sleep to let ResultStore finish writing results before querying + sleep 60 + python ./tools/run_tests/python_utils/upload_rbe_results.py +fi +if [ "$FAILED" != "" ] +then + exit 1 +fi diff --git a/tools/remote_build/README.md b/tools/remote_build/README.md index edf771dd184026fa656d4be167c0ab71981ced62..2d1a629b0ebe1b1b7e9034782c23ed666f602dac 100644 --- a/tools/remote_build/README.md +++ b/tools/remote_build/README.md @@ -32,7 +32,14 @@ bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/... Run on Windows MSVC: ``` # manual run of bazel tests remotely on RBE Windows (must be run from Windows machine) -bazel --bazelrc=tools/remote_build/windows.bazelrc test //test/... +bazel --bazelrc=tools/remote_build/windows.bazelrc test --config=windows_opt //test/... +``` + +Run on MacOS (experimental for now): +``` +# manual run of bazel tests on Mac (must be run from Mac machine) +# NOTE: it's not really a "remote execution", but uploads results to ResultStore +bazel --bazelrc=tools/remote_build/mac.bazelrc test --config=opt //test/... ``` Available command line options can be found in diff --git a/tools/remote_build/mac.bazelrc b/tools/remote_build/mac.bazelrc new file mode 100644 index 0000000000000000000000000000000000000000..cc201565f71088518b02bc2ddf91bc2f841c13cb --- /dev/null +++ b/tools/remote_build/mac.bazelrc @@ -0,0 +1,35 @@ +# Configuration for mac bazel test runs on CI +# Bazel RBE doesn't currently support MacOS platform, +# so we configure tests to build and run locally, +# but try to use RBE build cache and upload results +# to ResultStore + +startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 + +# remote cache is needed not only for build speedup, +# but also for the test logs to be available in ResultStore +# for now, don't upload results to cache, only the test logs. +# TODO(jtattermusch): setup a "cache-silo-key" before enabling uploads to build cache +build --remote_cache=grpcs://remotebuildexecution.googleapis.com +build --remote_instance_name=projects/grpc-testing/instances/default_instance +build --remote_upload_local_results=false + +build --auth_enabled=true + +build --verbose_failures=true + +build --test_tag_filters=-no_mac +build --build_tag_filters=-no_mac + +# without verbose gRPC logs the test outputs are not very useful +test --test_env=GRPC_VERBOSITY=debug + +# Set flags for uploading to BES in order to view results in the Bazel Build +# Results UI. +build --bes_backend=grpcs://buildeventservice.googleapis.com +build --bes_timeout=600s +build --bes_results_url="https://source.cloud.google.com/results/invocations/" +build --project_id=grpc-testing + +# print output for tests that fail (default is "summary") +build --test_output=errors