Merge branch 'timer' into pid++

pull/12903/head
Craig Tiller 7 years ago
commit 28157f806c
  1. 71
      CMakeLists.txt
  2. 82
      Makefile
  3. 17
      build.yaml
  4. 1
      src/proto/grpc/testing/echo_messages.proto
  5. 3
      templates/tools/run_tests/generated/tests.json.template
  6. 1
      test/core/end2end/gen_build_yaml.py
  7. 1
      test/core/end2end/generate_tests.bzl
  8. 85
      test/core/end2end/h2_ssl_cert_test.cc
  9. 15
      test/cpp/end2end/end2end_test.cc
  10. 8
      test/cpp/end2end/test_service_impl.cc
  11. 40
      tools/run_tests/generated/sources_and_headers.json
  12. 1964
      tools/run_tests/generated/tests.json

@ -589,7 +589,6 @@ add_dependencies(buildtests_c h2_sockpair_test)
add_dependencies(buildtests_c h2_sockpair+trace_test) add_dependencies(buildtests_c h2_sockpair+trace_test)
add_dependencies(buildtests_c h2_sockpair_1byte_test) add_dependencies(buildtests_c h2_sockpair_1byte_test)
add_dependencies(buildtests_c h2_ssl_test) add_dependencies(buildtests_c h2_ssl_test)
add_dependencies(buildtests_c h2_ssl_cert_test)
add_dependencies(buildtests_c h2_ssl_proxy_test) add_dependencies(buildtests_c h2_ssl_proxy_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c h2_uds_test) add_dependencies(buildtests_c h2_uds_test)
@ -702,6 +701,7 @@ add_dependencies(buildtests_cxx grpc_tool_test)
add_dependencies(buildtests_cxx grpclb_api_test) add_dependencies(buildtests_cxx grpclb_api_test)
add_dependencies(buildtests_cxx grpclb_end2end_test) add_dependencies(buildtests_cxx grpclb_end2end_test)
add_dependencies(buildtests_cxx grpclb_test) add_dependencies(buildtests_cxx grpclb_test)
add_dependencies(buildtests_cxx h2_ssl_cert_test)
add_dependencies(buildtests_cxx health_service_end2end_test) add_dependencies(buildtests_cxx health_service_end2end_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx http2_client) add_dependencies(buildtests_cxx http2_client)
@ -11116,6 +11116,45 @@ target_link_libraries(grpclb_test
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
add_executable(h2_ssl_cert_test
test/core/end2end/h2_ssl_cert_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(h2_ssl_cert_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${BORINGSSL_ROOT_DIR}/include
PRIVATE ${PROTOBUF_ROOT_DIR}/src
PRIVATE ${BENCHMARK_ROOT_DIR}/include
PRIVATE ${ZLIB_ROOT_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(h2_ssl_cert_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc++
grpc
gpr_test_util
gpr
${_gRPC_GFLAGS_LIBRARIES}
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(health_service_end2end_test add_executable(health_service_end2end_test
test/cpp/end2end/health_service_end2end_test.cc test/cpp/end2end/health_service_end2end_test.cc
third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googletest/src/gtest-all.cc
@ -13616,36 +13655,6 @@ target_link_libraries(h2_ssl_test
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
add_executable(h2_ssl_cert_test
test/core/end2end/fixtures/h2_ssl_cert.c
)
target_include_directories(h2_ssl_cert_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${BORINGSSL_ROOT_DIR}/include
PRIVATE ${PROTOBUF_ROOT_DIR}/src
PRIVATE ${BENCHMARK_ROOT_DIR}/include
PRIVATE ${ZLIB_ROOT_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
)
target_link_libraries(h2_ssl_cert_test
${_gRPC_ALLTARGETS_LIBRARIES}
end2end_tests
grpc_test_util
grpc
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(h2_ssl_proxy_test add_executable(h2_ssl_proxy_test
test/core/end2end/fixtures/h2_ssl_proxy.c test/core/end2end/fixtures/h2_ssl_proxy.c
) )

@ -1143,6 +1143,7 @@ grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test
grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test
grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test
grpclb_test: $(BINDIR)/$(CONFIG)/grpclb_test grpclb_test: $(BINDIR)/$(CONFIG)/grpclb_test
h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test
http2_client: $(BINDIR)/$(CONFIG)/http2_client http2_client: $(BINDIR)/$(CONFIG)/http2_client
hybrid_end2end_test: $(BINDIR)/$(CONFIG)/hybrid_end2end_test hybrid_end2end_test: $(BINDIR)/$(CONFIG)/hybrid_end2end_test
@ -1247,7 +1248,6 @@ h2_sockpair_test: $(BINDIR)/$(CONFIG)/h2_sockpair_test
h2_sockpair+trace_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test h2_sockpair+trace_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test
h2_sockpair_1byte_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test h2_sockpair_1byte_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test
h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test
h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test
h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test
inproc_test: $(BINDIR)/$(CONFIG)/inproc_test inproc_test: $(BINDIR)/$(CONFIG)/inproc_test
@ -1504,7 +1504,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_sockpair+trace_test \ $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test \
$(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test \ $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test \
$(BINDIR)/$(CONFIG)/h2_ssl_test \ $(BINDIR)/$(CONFIG)/h2_ssl_test \
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
$(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \ $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \
$(BINDIR)/$(CONFIG)/h2_uds_test \ $(BINDIR)/$(CONFIG)/h2_uds_test \
$(BINDIR)/$(CONFIG)/inproc_test \ $(BINDIR)/$(CONFIG)/inproc_test \
@ -1581,6 +1580,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \
$(BINDIR)/$(CONFIG)/grpclb_end2end_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \
$(BINDIR)/$(CONFIG)/grpclb_test \ $(BINDIR)/$(CONFIG)/grpclb_test \
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
$(BINDIR)/$(CONFIG)/health_service_end2end_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \
$(BINDIR)/$(CONFIG)/http2_client \ $(BINDIR)/$(CONFIG)/http2_client \
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \ $(BINDIR)/$(CONFIG)/hybrid_end2end_test \
@ -1704,6 +1704,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \
$(BINDIR)/$(CONFIG)/grpclb_end2end_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \
$(BINDIR)/$(CONFIG)/grpclb_test \ $(BINDIR)/$(CONFIG)/grpclb_test \
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test \
$(BINDIR)/$(CONFIG)/health_service_end2end_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \
$(BINDIR)/$(CONFIG)/http2_client \ $(BINDIR)/$(CONFIG)/http2_client \
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \ $(BINDIR)/$(CONFIG)/hybrid_end2end_test \
@ -2108,6 +2109,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing grpclb_test" $(E) "[RUN] Testing grpclb_test"
$(Q) $(BINDIR)/$(CONFIG)/grpclb_test || ( echo test grpclb_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpclb_test || ( echo test grpclb_test failed ; exit 1 )
$(E) "[RUN] Testing h2_ssl_cert_test"
$(Q) $(BINDIR)/$(CONFIG)/h2_ssl_cert_test || ( echo test h2_ssl_cert_test failed ; exit 1 )
$(E) "[RUN] Testing health_service_end2end_test" $(E) "[RUN] Testing health_service_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/health_service_end2end_test || ( echo test health_service_end2end_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/health_service_end2end_test || ( echo test health_service_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing interop_test" $(E) "[RUN] Testing interop_test"
@ -15603,6 +15606,49 @@ endif
$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
H2_SSL_CERT_TEST_SRC = \
test/core/end2end/h2_ssl_cert_test.cc \
H2_SSL_CERT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_CERT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: $(PROTOBUF_DEP) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/core/end2end/h2_ssl_cert_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
endif
endif
HEALTH_SERVICE_END2END_TEST_SRC = \ HEALTH_SERVICE_END2END_TEST_SRC = \
test/cpp/end2end/health_service_end2end_test.cc \ test/cpp/end2end/health_service_end2end_test.cc \
@ -19136,38 +19182,6 @@ endif
endif endif
H2_SSL_CERT_TEST_SRC = \
test/core/end2end/fixtures/h2_ssl_cert.c \
H2_SSL_CERT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_CERT_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_cert_test
endif
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_ssl_cert.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(H2_SSL_CERT_TEST_OBJS:.o=.dep)
endif
endif
H2_SSL_PROXY_TEST_SRC = \ H2_SSL_PROXY_TEST_SRC = \
test/core/end2end/fixtures/h2_ssl_proxy.c \ test/core/end2end/fixtures/h2_ssl_proxy.c \

@ -2262,6 +2262,7 @@ targets:
deps: deps:
- gpr_test_util - gpr_test_util
- gpr - gpr
uses_polling: false
- name: gpr_spinlock_test - name: gpr_spinlock_test
cpu_cost: 3 cpu_cost: 3
build: test build: test
@ -4141,6 +4142,22 @@ targets:
excluded_poll_engines: excluded_poll_engines:
- poll - poll
- poll-cv - poll-cv
- name: h2_ssl_cert_test
gtest: true
build: test
language: c++
headers:
- test/core/end2end/end2end_tests.h
src:
- test/core/end2end/h2_ssl_cert_test.cc
deps:
- grpc_test_util
- grpc++
- grpc
- gpr_test_util
- gpr
uses:
- grpc++_test
- name: health_service_end2end_test - name: health_service_end2end_test
gtest: true gtest: true
build: test build: test

@ -45,6 +45,7 @@ message RequestParams {
bool server_die = 12; // Server should not see a request with this set. bool server_die = 12; // Server should not see a request with this set.
string binary_error_details = 13; string binary_error_details = 13;
ErrorStatus expected_error = 14; ErrorStatus expected_error = 14;
int32 server_sleep_us = 15; // Amount to sleep when invoking server
} }
message EchoRequest { message EchoRequest {

@ -13,7 +13,8 @@
"exclude_iomgrs": tgt.get("exclude_iomgrs", []), "exclude_iomgrs": tgt.get("exclude_iomgrs", []),
"args": tgt.get("args", []), "args": tgt.get("args", []),
"flaky": tgt.flaky, "flaky": tgt.flaky,
"cpu_cost": tgt.get("cpu_cost", 1.0)} "cpu_cost": tgt.get("cpu_cost", 1.0),
"uses_polling": tgt.get("uses_polling", True)}
timeout_seconds = tgt.get("timeout_seconds", None) timeout_seconds = tgt.get("timeout_seconds", None)
if timeout_seconds: if timeout_seconds:
out['timeout_seconds'] = timeout_seconds out['timeout_seconds'] = timeout_seconds

@ -60,7 +60,6 @@ END2END_FIXTURES = {
'h2_sockpair+trace': socketpair_unsecure_fixture_options._replace( 'h2_sockpair+trace': socketpair_unsecure_fixture_options._replace(
ci_mac=False, tracing=True, large_writes=False, exclude_iomgrs=['uv']), ci_mac=False, tracing=True, large_writes=False, exclude_iomgrs=['uv']),
'h2_ssl': default_secure_fixture_options, 'h2_ssl': default_secure_fixture_options,
'h2_ssl_cert': default_secure_fixture_options,
'h2_ssl_proxy': default_secure_fixture_options._replace( 'h2_ssl_proxy': default_secure_fixture_options._replace(
includes_proxy=True, ci_mac=False, exclude_iomgrs=['uv']), includes_proxy=True, ci_mac=False, exclude_iomgrs=['uv']),
'h2_uds': uds_fixture_options, 'h2_uds': uds_fixture_options,

@ -56,7 +56,6 @@ END2END_FIXTURES = {
'h2_sockpair+trace': fixture_options(fullstack=False, dns_resolver=False, 'h2_sockpair+trace': fixture_options(fullstack=False, dns_resolver=False,
tracing=True), tracing=True),
'h2_ssl': fixture_options(secure=True), 'h2_ssl': fixture_options(secure=True),
'h2_ssl_cert': fixture_options(secure=True),
'h2_ssl_proxy': fixture_options(includes_proxy=True, secure=True), 'h2_ssl_proxy': fixture_options(includes_proxy=True, secure=True),
'h2_uds': fixture_options(dns_resolver=False, 'h2_uds': fixture_options(dns_resolver=False,
platforms=['linux', 'mac', 'posix']), platforms=['linux', 'mac', 'posix']),

@ -16,7 +16,9 @@
* *
*/ */
extern "C" {
#include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/end2end_tests.h"
}
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -25,6 +27,7 @@
#include <grpc/support/host_port.h> #include <grpc/support/host_port.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
extern "C" {
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/support/env.h" #include "src/core/lib/support/env.h"
@ -34,8 +37,12 @@
#include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
}
extern void simple_request(grpc_end2end_test_config config); #include <gtest/gtest.h>
namespace grpc {
namespace testing {
typedef struct fullstack_secure_fixture_data { typedef struct fullstack_secure_fixture_data {
char *localaddr; char *localaddr;
@ -46,7 +53,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
grpc_end2end_test_fixture f; grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die(); int port = grpc_pick_unused_port_or_die();
fullstack_secure_fixture_data *ffd = fullstack_secure_fixture_data *ffd =
gpr_malloc(sizeof(fullstack_secure_fixture_data)); static_cast<fullstack_secure_fixture_data *>(
gpr_malloc(sizeof(fullstack_secure_fixture_data)));
memset(&f, 0, sizeof(f)); memset(&f, 0, sizeof(f));
gpr_join_host_port(&ffd->localaddr, "localhost", port); gpr_join_host_port(&ffd->localaddr, "localhost", port);
@ -69,7 +77,8 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx,
static void chttp2_init_client_secure_fullstack( static void chttp2_init_client_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args, grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
grpc_channel_credentials *creds) { grpc_channel_credentials *creds) {
fullstack_secure_fixture_data *ffd = f->fixture_data; fullstack_secure_fixture_data *ffd =
static_cast<fullstack_secure_fixture_data *>(f->fixture_data);
f->client = f->client =
grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
GPR_ASSERT(f->client != NULL); GPR_ASSERT(f->client != NULL);
@ -79,7 +88,8 @@ static void chttp2_init_client_secure_fullstack(
static void chttp2_init_server_secure_fullstack( static void chttp2_init_server_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args, grpc_end2end_test_fixture *f, grpc_channel_args *server_args,
grpc_server_credentials *server_creds) { grpc_server_credentials *server_creds) {
fullstack_secure_fixture_data *ffd = f->fixture_data; fullstack_secure_fixture_data *ffd =
static_cast<fullstack_secure_fixture_data *>(f->fixture_data);
if (f->server) { if (f->server) {
grpc_server_destroy(f->server); grpc_server_destroy(f->server);
} }
@ -92,7 +102,8 @@ static void chttp2_init_server_secure_fullstack(
} }
void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
fullstack_secure_fixture_data *ffd = f->fixture_data; fullstack_secure_fixture_data *ffd =
static_cast<fullstack_secure_fixture_data *>(f->fixture_data);
gpr_free(ffd->localaddr); gpr_free(ffd->localaddr);
gpr_free(ffd); gpr_free(ffd);
} }
@ -166,9 +177,10 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
} \ } \
ssl_creds = \ ssl_creds = \
grpc_ssl_credentials_create(test_root_cert, key_cert_pair, NULL); \ grpc_ssl_credentials_create(test_root_cert, key_cert_pair, NULL); \
grpc_arg ssl_name_override = {GRPC_ARG_STRING, \ grpc_arg ssl_name_override = { \
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, \ GRPC_ARG_STRING, \
{"foo.test.google.fr"}}; \ const_cast<char *>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), \
{const_cast<char *>("foo.test.google.fr")}}; \
grpc_channel_args *new_client_args = \ grpc_channel_args *new_client_args = \
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); \ grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); \
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \ chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \
@ -248,18 +260,6 @@ static grpc_end2end_test_config_wrapper configs[] = {
static void *tag(intptr_t t) { return (void *)t; } static void *tag(intptr_t t) { return (void *)t; }
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
const char *test_name,
grpc_channel_args *client_args,
grpc_channel_args *server_args) {
grpc_end2end_test_fixture f;
gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
f = config.create_fixture(client_args, server_args);
config.init_server(&f, server_args);
config.init_client(&f, client_args);
return f;
}
static gpr_timespec n_seconds_time(int n) { static gpr_timespec n_seconds_time(int n) {
return grpc_timeout_seconds_to_deadline(n); return grpc_timeout_seconds_to_deadline(n);
} }
@ -332,15 +332,40 @@ static void simple_request_body(grpc_end2end_test_fixture f,
cq_verifier_destroy(cqv); cq_verifier_destroy(cqv);
} }
class H2SslCertTest
: public ::testing::TestWithParam<grpc_end2end_test_config_wrapper> {
protected:
H2SslCertTest() {
gpr_log(GPR_INFO, "SSL_CERT_tests/%s", GetParam().config.name);
}
void SetUp() override {
fixture_ = GetParam().config.create_fixture(nullptr, nullptr);
GetParam().config.init_server(&fixture_, nullptr);
GetParam().config.init_client(&fixture_, nullptr);
}
void TearDown() override {
end_test(&fixture_);
GetParam().config.tear_down_data(&fixture_);
}
grpc_end2end_test_fixture fixture_;
};
TEST_P(H2SslCertTest, SimpleRequestBody) {
simple_request_body(fixture_, GetParam().result);
}
INSTANTIATE_TEST_CASE_P(H2SslCert, H2SslCertTest, ::testing::ValuesIn(configs));
} // namespace testing
} // namespace grpc
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i;
FILE *roots_file; FILE *roots_file;
size_t roots_size = strlen(test_root_cert); size_t roots_size = strlen(test_root_cert);
char *roots_filename; char *roots_filename;
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
/* Set the SSL roots env var. */ /* Set the SSL roots env var. */
roots_file = roots_file =
gpr_tmpfile("chttp2_simple_ssl_cert_fullstack_test", &roots_filename); gpr_tmpfile("chttp2_simple_ssl_cert_fullstack_test", &roots_filename);
@ -351,21 +376,13 @@ int main(int argc, char **argv) {
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename);
grpc_init(); grpc_init();
::testing::InitGoogleTest(&argc, argv);
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { int ret = RUN_ALL_TESTS();
grpc_end2end_test_fixture f =
begin_test(configs[i].config, "SSL_CERT_tests", NULL, NULL);
simple_request_body(f, configs[i].result);
end_test(&f);
configs[i].config.tear_down_data(&f);
}
grpc_shutdown(); grpc_shutdown();
/* Cleanup. */ /* Cleanup. */
remove(roots_filename); remove(roots_filename);
gpr_free(roots_filename); gpr_free(roots_filename);
return 0; return ret;
} }

@ -1280,6 +1280,8 @@ TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) {
EchoResponse response; EchoResponse response;
request.set_message("Hello"); request.set_message("Hello");
request.mutable_param()->set_skip_cancelled_check(true); request.mutable_param()->set_skip_cancelled_check(true);
// Let server sleep for 2 ms first to guarantee expiry
request.mutable_param()->set_server_sleep_us(2 * 1000);
ClientContext context; ClientContext context;
std::chrono::system_clock::time_point deadline = std::chrono::system_clock::time_point deadline =
@ -1407,6 +1409,10 @@ TEST_P(ProxyEnd2endTest, HugeResponse) {
} }
TEST_P(ProxyEnd2endTest, Peer) { TEST_P(ProxyEnd2endTest, Peer) {
// Peer is not meaningful for inproc
if (GetParam().inproc) {
return;
}
ResetStub(); ResetStub();
EchoRequest request; EchoRequest request;
EchoResponse response; EchoResponse response;
@ -1775,11 +1781,10 @@ std::vector<TestScenario> CreateTestScenarios(bool use_proxy,
credentials_types.push_back(kInsecureCredentialsType); credentials_types.push_back(kInsecureCredentialsType);
} }
GPR_ASSERT(!credentials_types.empty()); GPR_ASSERT(!credentials_types.empty());
for (auto it = credentials_types.begin(); it != credentials_types.end(); for (const auto& cred : credentials_types) {
++it) { scenarios.emplace_back(false, false, cred);
scenarios.emplace_back(false, false, *it);
if (use_proxy) { if (use_proxy) {
scenarios.emplace_back(true, false, *it); scenarios.emplace_back(true, false, cred);
} }
} }
if (test_inproc && insec_ok()) { if (test_inproc && insec_ok()) {
@ -1798,7 +1803,7 @@ INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest,
INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest, INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(true, true, ::testing::ValuesIn(CreateTestScenarios(true, true,
true, false))); true, true)));
INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest, INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(false, false, ::testing::ValuesIn(CreateTestScenarios(false, false,

@ -73,6 +73,14 @@ void CheckServerAuthContext(
Status TestServiceImpl::Echo(ServerContext* context, const EchoRequest* request, Status TestServiceImpl::Echo(ServerContext* context, const EchoRequest* request,
EchoResponse* response) { EchoResponse* response) {
// A bit of sleep to make sure that short deadline tests fail
if (request->has_param() && request->param().server_sleep_us() > 0) {
gpr_sleep_until(
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_micros(request->param().server_sleep_us(),
GPR_TIMESPAN)));
}
if (request->has_param() && request->param().server_die()) { if (request->has_param() && request->param().server_die()) {
gpr_log(GPR_ERROR, "The request should not reach application handler."); gpr_log(GPR_ERROR, "The request should not reach application handler.");
GPR_ASSERT(0); GPR_ASSERT(0);

@ -3457,6 +3457,28 @@
"third_party": false, "third_party": false,
"type": "target" "type": "target"
}, },
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc++",
"grpc++_test",
"grpc_test_util"
],
"headers": [
"test/core/end2end/end2end_tests.h"
],
"is_filegroup": false,
"language": "c++",
"name": "h2_ssl_cert_test",
"src": [
"test/core/end2end/end2end_tests.h",
"test/core/end2end/h2_ssl_cert_test.cc"
],
"third_party": false,
"type": "target"
},
{ {
"deps": [ "deps": [
"gpr", "gpr",
@ -5291,24 +5313,6 @@
"third_party": false, "third_party": false,
"type": "target" "type": "target"
}, },
{
"deps": [
"end2end_tests",
"gpr",
"gpr_test_util",
"grpc",
"grpc_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c",
"name": "h2_ssl_cert_test",
"src": [
"test/core/end2end/fixtures/h2_ssl_cert.c"
],
"third_party": false,
"type": "target"
},
{ {
"deps": [ "deps": [
"end2end_tests", "end2end_tests",

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save