diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc index 5c5c246f998..c646f71908c 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 63a0269ed62..1d2e9506451 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 2afef07907b..0bfd22fc79c 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 8fd120e0428..3c6fa9e28b3 100644 --- a/test/core/backoff/backoff_test.cc +++ b/test/core/backoff/backoff_test.cc @@ -20,6 +20,7 @@ #include +#include #include #include @@ -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 686a701dfed..8206afa5afb 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 78a1a5cc9a4..380cbcd8dfa 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 efc691dd43f..9f0f9816635 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 @@ -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 a9a60b88e24..15aebdd2ac4 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 #include @@ -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 6727abc8b93..b77f305ac87 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 #include @@ -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 7550d277aef..9b78d709734 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 79afb49066a..83259cca2f1 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 f0537e03e9d..d307f04fb18 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 0896a27f40b..50293765c3f 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 f56f4f128e4..ad6e126d0c2 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 0292f771fc9..b2d64f4f42a 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 27532035318..9143a225392 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 93c66c73370..f488a2f5925 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 bc368c49657..fc2654426d7 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 2d5a2b21ffc..2a3ea934ac0 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 11933f1fa91..13837ccaa95 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 f730c9f0cff..9a426b055b4 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 ec08e76cfe5..c78f75dc91d 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 659076fe5dc..ce19e5077ad 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 @@ -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 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 8f1f3b07500..1d3f531c124 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 1d84586e18e..114d6ccfd21 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 @@ -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 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()); diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index fd5aff15063..d7d449e8fb7 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 45243183d0a..812bf3b71b9 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 bc9b671e1fb..7c4c17142c3 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" -env_vars { - key: "RUN_TESTS_FLAGS" - value: "--config=dbg" +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: "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 62fc5fc1b38..e7447398713 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" -env_vars { - key: "RUN_TESTS_FLAGS" - value: "--config=opt" +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: "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 434fc1a2804..ed9c97211c4 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 edf771dd184..2d1a629b0eb 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 00000000000..cc201565f71 --- /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